• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1% EIGRP Tests
2* Tests for the Scapy EIGRP layer
3
4+ Basic Layer Tests
5* These are just some basic tests
6
7= EIGRP IPv4 Binding
8~ eigrp_ipv4_binding
9p = IP()/EIGRP()
10p[IP].proto == 88
11
12= EIGRP IPv6 Binding
13~ eigrp_ipv6_binding
14p = IPv6()/EIGRP()
15p[IPv6].nh == 88
16
17= EIGRP checksum field
18~ eigrp_chksum_field
19p = IP()/EIGRP(flags=0xa, seq=23, ack=42, asn=100)
20s = p[EIGRP].build()
21struct.unpack("!H", s[2:4])[0] == 64843
22
23+ Custom Field Tests
24* Test funciontally of custom made fields
25
26= ShortVersionField nice representation
27f = ShortVersionField("ver", 3072)
28f.i2repr(None, 3072) == "v12.0" and f.i2repr(None, 258) == "v1.2"
29
30= ShortVersionField h2i function
31f = ShortVersionField("ver", 0)
32f.h2i(None, 3073) == f.h2i(None, "v12.1")
33
34= EigrpIPField length with prefix length of 8 bit
35f = EigrpIPField("ipaddr", "192.168.1.0", length=8)
36f.i2len(None, "") == 1
37
38= EigrpIPField length with prefix length of 12 bit
39f = EigrpIPField("ipaddr", "192.168.1.0", length=12)
40f.i2len(None, "") == 2
41
42= EigrpIPField length with prefix length of 24 bit
43f = EigrpIPField("ipaddr", "192.168.1.0", length=24)
44f.i2len(None, "") == 3
45
46= EigrpIPField length with prefix length of 28 bit
47f = EigrpIPField("ipaddr", "192.168.1.0", length=28)
48f.i2len(None, "") == 4
49
50= EigrpIP6Field length with prefix length of 8 bit
51f = EigrpIP6Field("ipaddr", "2000::", length=8)
52f.i2len(None, "") == 2
53
54= EigrpIP6Field length with prefix length of 99 bit
55f = EigrpIP6Field("ipaddr", "2000::", length=99)
56f.i2len(None, "") == 13
57
58= EigrpIP6Field length with prefix length of 128 bit
59f = EigrpIP6Field("ipaddr", "2000::", length=128)
60f.i2len(None, "") == 16
61
62= EIGRPGuessPayloadClass function: Return Parameters TLV
63from scapy.contrib.eigrp import _EIGRPGuessPayloadClass
64isinstance(_EIGRPGuessPayloadClass(b"\x00\x01"), EIGRPParam)
65
66= EIGRPGuessPayloadClass function: Return Authentication Data TLV
67isinstance(_EIGRPGuessPayloadClass(b"\x00\x02"), EIGRPAuthData)
68
69= EIGRPGuessPayloadClass function: Return Sequence TLV
70isinstance(_EIGRPGuessPayloadClass(b"\x00\x03"), EIGRPSeq)
71
72= EIGRPGuessPayloadClass function: Return Software Version TLV
73isinstance(_EIGRPGuessPayloadClass(b"\x00\x04"), EIGRPSwVer)
74
75= EIGRPGuessPayloadClass function: Return Next Multicast Sequence TLV
76isinstance(_EIGRPGuessPayloadClass(b"\x00\x05"), EIGRPNms)
77
78= EIGRPGuessPayloadClass function: Return Stub Router TLV
79isinstance(_EIGRPGuessPayloadClass(b"\x00\x06"), EIGRPStub)
80
81= EIGRPGuessPayloadClass function: Return Internal Route TLV
82isinstance(_EIGRPGuessPayloadClass(b"\x01\x02"), EIGRPIntRoute)
83
84= EIGRPGuessPayloadClass function: Return External Route TLV
85isinstance(_EIGRPGuessPayloadClass(b"\x01\x03"), EIGRPExtRoute)
86
87= EIGRPGuessPayloadClass function: Return IPv6 Internal Route TLV
88isinstance(_EIGRPGuessPayloadClass(b"\x04\x02"), EIGRPv6IntRoute)
89
90= EIGRPGuessPayloadClass function: Return IPv6 External Route TLV
91isinstance(_EIGRPGuessPayloadClass(b"\x04\x03"), EIGRPv6ExtRoute)
92
93= EIGRPGuessPayloadClass function: Return EIGRPGeneric
94isinstance(_EIGRPGuessPayloadClass(b"\x23\x42"), EIGRPGeneric)
95
96+ TLV List
97
98= EIGRP parameters and software version
99p = IP()/EIGRP(tlvlist=[EIGRPParam()/EIGRPSwVer()])
100s = b'\x45\x00\x00\x3C\x00\x01\x00\x00\x40\x58\x7C\x67\x7F\x00\x00\x01\x7F\x00\x00\x01\x02\x05\xEE\x6C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\x00\x01\x00\x0C\x01\x00\x01\x00\x00\x00\x00\x0F\x00\x04\x00\x08\x0C\x00\x01\x02'
101raw(p) == s
102
103= EIGRP internal route length field
104p = IP()/EIGRP(tlvlist=[EIGRPIntRoute(prefixlen=24, dst="192.168.1.0")])
105struct.unpack("!H", p[EIGRPIntRoute].build()[2:4])[0] == 28
106
107= EIGRP external route length field
108p = IP()/EIGRP(tlvlist=[EIGRPExtRoute(prefixlen=16, dst="10.1.0.0")])
109struct.unpack("!H", p[EIGRPExtRoute].build()[2:4])[0] == 47
110
111= EIGRPv6 internal route length field
112p = IP()/EIGRP(tlvlist=[EIGRPv6IntRoute(prefixlen=64, dst="2000::")])
113struct.unpack("!H", p[EIGRPv6IntRoute].build()[2:4])[0] == 46
114
115= EIGRPv6 external route length field
116p = IP()/EIGRP(tlvlist=[EIGRPv6ExtRoute(prefixlen=99, dst="2000::")])
117struct.unpack("!H", p[EIGRPv6ExtRoute].build()[2:4])[0] == 70
118
119+ Stub Flags
120* The receive-only flag is always set, when a router anounces itself as stub router.
121
122= Receive-Only
123p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="receive-only")])
124p[EIGRPStub].flags == 0x0008
125
126= Connected
127p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="connected+receive-only")])
128p[EIGRPStub].flags == 0x0009
129
130= Static
131p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="static+receive-only")])
132p[EIGRPStub].flags == 0x000a
133
134= Summary
135p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="summary+receive-only")])
136p[EIGRPStub].flags == 0x000c
137
138= Connected, Summary
139p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="connected+summary+receive-only")])
140p[EIGRPStub].flags == 0x000d
141
142= Static, Summary
143p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="static+summary+receive-only")])
144p[EIGRPStub].flags == 0x000e
145
146= Redistributed, Connected
147p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="redistributed+connected+receive-only")])
148p[EIGRPStub].flags == 0x0019
149
150= Redistributed, Static
151p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="redistributed+static+receive-only")])
152p[EIGRPStub].flags == 0x001a
153
154= Redistributed, Static, Connected
155p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="redistributed+static+connected+receive-only")])
156p[EIGRPStub].flags == 0x001b
157
158= Redistributed, Summary
159p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="redistributed+summary+receive-only")])
160p[EIGRPStub].flags == 0x001c
161
162= Redistributed, Connected, Summary
163p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="redistributed+connected+summary+receive-only")])
164p[EIGRPStub].flags == 0x001d
165
166= Connected, Redistributed, Static, Summary
167p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="connected+redistributed+static+summary+receive-only")])
168p[EIGRPStub].flags == 0x001f
169
170= Leak-Map
171p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="leak-map+receive-only")])
172p[EIGRPStub].flags == 0x0028
173
174= Connected, Leak-Map
175p = IP()/EIGRP(tlvlist=[EIGRPStub(flags="connected+leak-map+receive-only")])
176p[EIGRPStub].flags == 0x0029
177
178+ Routing Updates
179
180= External route flag external
181p = EIGRPExtRoute(flags="external")
182p.flags == 0x1
183
184= External route flag candidate-default route
185p = EIGRPExtRoute(flags="candidate-default")
186p.flags == 0x2
187
188= Multiple internal routing updates
189p = IP()/EIGRP(tlvlist=[EIGRPIntRoute(), EIGRPIntRoute(hopcount=12), EIGRPIntRoute()])
190p[EIGRPIntRoute:2].hopcount == 12
191
192= Multiple external routing updates
193p = IP()/EIGRP(tlvlist=[EIGRPExtRoute(), EIGRPExtRoute(mtu=23), EIGRPExtRoute()])
194p[EIGRPExtRoute:2].mtu == 23
195
196+ Authentication Data TLV
197
198= Verify keysize calculation
199p = IP()/EIGRP(tlvlist=[EIGRPAuthData(authdata=b"\xaa\xbb\xcc")])
200p[EIGRPAuthData].build()[6:8] == b"\x00\x03"
201
202= Verify length calculation
203p = IP()/EIGRP(tlvlist=[EIGRPAuthData(authdata=b"\xaa\xbb\xcc\xdd")])
204p[EIGRPAuthData].build()[2:4] == b"\x00\x1c"
205