1
2
3 """Routing Information Protocol."""
4 from __future__ import print_function
5 from __future__ import absolute_import
6
7 from . import dpkt
8
9
10
11
12 REQUEST = 1
13 RESPONSE = 2
14
15
16 -class RIP(dpkt.Packet):
17 """Routing Information Protocol.
18
19 TODO: Longer class information....
20
21 Attributes:
22 __hdr__: Header fields of RIP.
23 TODO.
24 """
25
26 __hdr__ = (
27 ('cmd', 'B', REQUEST),
28 ('v', 'B', 2),
29 ('rsvd', 'H', 0)
30 )
31
44
51
57
58
59 -class RTE(dpkt.Packet):
60 __hdr__ = (
61 ('family', 'H', 2),
62 ('route_tag', 'H', 0),
63 ('addr', 'I', 0),
64 ('subnet', 'I', 0),
65 ('next_hop', 'I', 0),
66 ('metric', 'I', 1)
67 )
68
69
70 -class Auth(dpkt.Packet):
71 __hdr__ = (
72 ('rsvd', 'H', 0xFFFF),
73 ('type', 'H', 2),
74 ('auth', '16s', 0)
75 )
76
77
78 __s = b'\x02\x02\x00\x00\x00\x02\x00\x00\x01\x02\x03\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x00\x00\xc0\xa8\x01\x08\xff\xff\xff\xfc\x00\x00\x00\x00\x00\x00\x00\x01'
79
80
84
85
87 r = RIP(__s)
88 assert (r.auth is None)
89 assert (len(r.rtes) == 2)
90
91 rte = r.rtes[1]
92 assert (rte.family == 2)
93 assert (rte.route_tag == 0)
94 assert (rte.metric == 1)
95
96
97 if __name__ == '__main__':
98 test_rtp_pack()
99 test_rtp_unpack()
100 print('Tests Successful...')
101