Skip to content

Instantly share code, notes, and snippets.

@tomerfiliba
Created June 6, 2013 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomerfiliba/5719848 to your computer and use it in GitHub Desktop.
Save tomerfiliba/5719848 to your computer and use it in GitHub Desktop.
VlanTagOrType = Struct("VlanTagOrType",
Enum(UBInt16("type"),
IPv4 = 0x0800,
ARP = 0x0806,
RARP = 0x8035,
X25 = 0x0805,
IPX = 0x8137,
IPv6 = 0x86DD,
VLAN_TAG = 0x8100,
_default_ = Pass,
),
If(lambda ctx: ctx.type == "VLAN_TAG",
Struct("VlanTag",
UBInt16("whatever_the_tag_is"),
LazyBound(lambda: VlanTagOrType)
)
)
)
ethernet_header = Struct("ethernet_header",
MacAddress("destination"),
MacAddress("source"),
VlanTagOrType,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment