New issue 32 by m...@galloway.me.uk: VLAN tagging of Ethernet frames
http://code.google.com/p/dpkt/issues/detail?id=32
It would be great if there was support for VLAN tagging of Ethernet frames.
There seems to be support for understanding a tagged packet, but not for
actually tagging them.
I've roughly added support myself, but no where near ready for a patch. But
I will keep going and hopefully submit something.
I just wanted to lodge here in case it was already being worked on?
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
Not currently being worked on. Feel free to submit a patch when you're
ready.
Comment #2 on issue 32 by dugsong: VLAN tagging of Ethernet frames
http://code.google.com/p/dpkt/issues/detail?id=32
I just committed support for decoding MPLS labels, Cisco ISL VLAN tags, and
802.2 LLC
fields, but not for encoding them. Feel free to post what code you have and
we can try
to adapt it, if you want.
dugsong: Yes I think I saw that. My code extends Ethernet class to create
one which
is adds an extra header to tag the packet. (After all, all it needs is an
extra 4
bytes after the ethernet header). Currently it's extremely crude so I
definitely want
to tidy it up.
Also I'm not sure using a subclass is necessarily the best idea, but I
couldn't see a
way to make __hdr__ in Ethernet be different depending on if the packets
are meant to
be tagged or not.
Meh, here we go so far.
Like I say, it's extremely crude and was just something I knocked up as I
needed to
quickly send out some VLAN tagged packets. It's by no means the best
solution. I
really hope to get some more time to look at it soon.
Attachments:
vlan.patch 594 bytes
So, the true fix for this...
The problem is that __hdr__ can't be dynamic depending on some condition.
For VLAN
tagged packets we need __hdr__ to be 4 bytes longer, if we've selected the
packet to
be tagged. So, we'd need __hdr__ to be a function which returns the headers.
Or we stick with the idea of my patch and have a separate class for it.
That's not
all that bad and it works and stays with the same paradigm that dpkt
already has.
What do you think?
Forgive me if this is a stupid question. How do you extract the VLAN tag
from an Ethernet packet using dpkt? I understand that the 802.1q VLAN tag
is 4 additional bytes in the header, that you can tell a packet is tagged
because bytes 13 and 14 contain 0x8100, and that moves the ethertype or
length field and the payload 4 bytes back.
Thank you
Hi,
I have dpkt-1.7 and I don't see a way to extract vlan tags. Is there some
way to do it that someone can point me to?
Thanks