VLAN problem

25 views
Skip to first unread message

Daniel Bujnik

unread,
Nov 6, 2015, 11:04:32 AM11/6/15
to libcrafter
Hello,

I have been trying to serialize and deserialize an ARP packet encapsulated in VLAN tagged Ethernet frame. While serialization seems to be working correctly I have been struggling with deserialization bit.

Please have a look at the code snipped below. After deserialization the pArp pointer is NULL. Could you please point out what I am doing wrong?

Many thanks in advance,
Daniel B

-------------------------------------------------------------------------------------
Ethernet ethHeader;
ethHeader.SetDestinationMAC("01:01:01:01:01:01");
ethHeader.SetSourceMAC("02:02:02:02:02:02");

Dot1Q vlan;
vlan.SetDEI(0);
vlan.SetPCP(0);
vlan.SetVID(1000);

ARP arp;
arp.SetHardwareType(1);
arp.SetProtocolType(IP::PROTO);
arp.SetHardwareLength(6);
arp.SetProtocolLength(4);
arp.SetOperation(ARP::Reply);
arp.SetSenderMAC("03:03:03:03:03:03");
arp.SetSenderIP("4.4.4.4");
arp.SetTargetMAC("05:05:05:05:05:05");
arp.SetTargetIP("6.6.6.6");

Packet packetA;
packetA.PushLayer(ethHeader);
packetA.PushLayer(vlan);
packetA.PushLayer(arp);

unsigned char buf[100];
packetA.Craft();
unsigned short len = packetA.GetData(buf);

Packet packetB;
packetB.PacketFromEthernet(buf, len);

Ethernet* pEth = packetB.GetLayer<Ethernet>();
Dot1Q* pVlan = packetB.GetLayer<Dot1Q>();
ARP* pArp = packetB.GetLayer<ARP>();

unsigned short vid = pVlan->GetVID();
string ip = pArp->GetTargetIP();
-------------------------------------------------------------------------------------


Esteban Pellegrino

unread,
Nov 6, 2015, 12:16:07 PM11/6/15
to libcr...@googlegroups.com
I see... I'm not able to test the code but I guess this is happening because the Dot1Q Craft method is not getting information about the layer on the bottom. I'll check that out and see if can be fixed. For now you can probably force the Type on the Dot1Q to be ARP when you create the first packet :

vlan.SetType(ARP::PROTO)


--
You received this message because you are subscribed to the Google Groups "libcrafter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libcrafter+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Esteban Pellegrino | Mobile Team Leader
LinkedIn | Twitter | Zimperium.com


Daniel Bujnik

unread,
Nov 9, 2015, 3:43:33 AM11/9/15
to libcrafter
Hi Esteban,

You are right. In my case Dot1Q layer serializes Type field as 0x0800, which is IPv4. Calling the setter method you advice solves the problem for me.

Cheers,
Daniel B
Reply all
Reply to author
Forward
0 new messages