packet lib: fix vlan pcp bitshift

Signed-off-by: HIYAMA Manabu <hiyama.manabu@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
HIYAMA Manabu 2012-09-26 13:09:29 +09:00 committed by FUJITA Tomonori
parent 79e7d09cf0
commit 19c205b897

View File

@ -36,13 +36,13 @@ class vlan(packet_base.PacketBase):
@classmethod
def parser(cls, buf):
tci, ethertype = struct.unpack_from(cls._PACK_STR, buf)
pcp = tci >> 15
pcp = tci >> 13
cfi = (tci >> 12) & 1
vid = tci & ((1 << 12) - 1)
return cls(pcp, cfi, vid, ethertype), vlan.get_packet_type(ethertype)
def serialize(self, payload, prev):
tci = self.pcp << 15 | self.cfi << 12 | self.vid
tci = self.pcp << 13 | self.cfi << 12 | self.vid
return struct.pack(vlan._PACK_STR, tci, self.ethertype)
vlan.register_packet_type(arp.arp, ether.ETH_TYPE_ARP)