1
2
3 """Virtual Router Redundancy Protocol."""
4
5 import dpkt
6
7 -class VRRP(dpkt.Packet):
8 __hdr__ = (
9 ('vtype', 'B', 0x21),
10 ('vrid', 'B', 0),
11 ('priority', 'B', 0),
12 ('count', 'B', 0),
13 ('atype', 'B', 0),
14 ('advtime', 'B', 0),
15 ('sum', 'H', 0),
16 )
17 addrs = ()
18 auth = ''
20 return self.vtype >> 4
22 self.vtype = (self.vtype & ~0xf) | (v << 4)
23 v = property(_get_v, _set_v)
24
26 return self.vtype & 0xf
28 self.vtype = (self.vtype & ~0xf0) | (v & 0xf)
29 type = property(_get_v, _set_v)
30
32 dpkt.Packet.unpack(self, buf)
33 l = []
34 for off in range(0, 4 * self.count, 4):
35 l.append(self.data[off:off+4])
36 self.addrs = l
37 self.auth = self.data[off+4:]
38 self.data = ''
39
42
48