• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1% IS-IS Tests
2* Tests for the IS-IS layer
3
4+ Syntax check
5
6= Import the isis layer
7from scapy.contrib.isis import *
8
9+ Basic Layer Tests
10
11= Layer Binding
12p = Dot3()/LLC()/ISIS_CommonHdr()/ISIS_P2P_Hello()
13assert p[LLC].dsap == 0xfe
14assert p[LLC].ssap == 0xfe
15assert p[LLC].ctrl == 0x03
16assert p[ISIS_CommonHdr].nlpid == 0x83
17assert p[ISIS_CommonHdr].pdutype == 17
18assert p[ISIS_CommonHdr].hdrlen == 20
19
20+ Package Tests
21
22= P2P Hello
23p = Dot3(dst="09:00:2b:00:00:05",src="00:00:00:aa:00:8c")/LLC()/ISIS_CommonHdr()/ISIS_P2P_Hello(
24         holdingtime=40, sourceid="1720.1600.8016",
25         tlvs=[
26            ISIS_ProtocolsSupportedTlv(nlpids=["IPv4", "IPv6"])
27         ])
28p = p.__class__(raw(p))
29assert p[ISIS_P2P_Hello].pdulength == 24
30assert network_layer_protocol_ids[p[ISIS_ProtocolsSupportedTlv].nlpids[1]] == "IPv6"
31
32= LSP
33p = Dot3(dst="09:00:2b:00:00:05",src="00:00:00:aa:00:8c")/LLC()/ISIS_CommonHdr()/ISIS_L2_LSP(
34         lifetime=863, lspid="1720.1600.8016.00-00", seqnum=0x1f0, typeblock="L1+L2",
35         tlvs=[
36             ISIS_AreaTlv(
37                 areas=[ISIS_AreaEntry(areaid="49.1000")]
38             ),
39             ISIS_ProtocolsSupportedTlv(
40                 nlpids=["IPv4", "IPv6"]
41             ),
42             ISIS_DynamicHostnameTlv(
43                 hostname="BR-HH"
44             ),
45             ISIS_IpInterfaceAddressTlv(
46                 addresses=["172.16.8.16"]
47             ),
48             ISIS_GenericTlv(
49                 type=134,
50                 val=b"\xac\x10\x08\x10"
51             ),
52             ISIS_ExtendedIpReachabilityTlv(
53                 pfxs=[
54                     ISIS_ExtendedIpPrefix(metric=0, pfx="172.16.8.16/32"),
55                     ISIS_ExtendedIpPrefix(metric=10, pfx="10.1.0.109/30"),
56                     ISIS_ExtendedIpPrefix(metric=10, pfx="10.1.0.181/30")
57                 ]
58             ),
59             ISIS_Ipv6ReachabilityTlv(
60                 pfxs=[
61                     ISIS_Ipv6Prefix(metric=0, pfx="fe10:1::10/128"),
62                     ISIS_Ipv6Prefix(metric=10, pfx="fd1f:1::/64"),
63                     ISIS_Ipv6Prefix(metric=10, pfx="fd1f:1:12::/64")
64                 ]
65             ),
66             ISIS_ExtendedIsReachabilityTlv(
67                 neighbours=[ISIS_ExtendedIsNeighbourEntry(neighbourid="1720.1600.8004.00", metric=10)]
68             )
69         ])
70p = p.__class__(raw(p))
71assert p[ISIS_L2_LSP].pdulength == 150
72assert p[ISIS_L2_LSP].checksum == 0x8701
73
74= LSP with Sub-TLVs
75p = Dot3(dst="09:00:2b:00:00:05",src="00:00:00:aa:00:8c")/LLC()/ISIS_CommonHdr()/ISIS_L2_LSP(
76         lifetime=863, lspid="1720.1600.8016.00-00", seqnum=0x1f0, typeblock="L1+L2",
77         tlvs=[
78             ISIS_AreaTlv(
79                 areas=[ISIS_AreaEntry(areaid="49.1000")]
80             ),
81             ISIS_ProtocolsSupportedTlv(
82                 nlpids=["IPv4", "IPv6"]
83             ),
84             ISIS_DynamicHostnameTlv(
85                 hostname="BR-HH"
86             ),
87             ISIS_IpInterfaceAddressTlv(
88                 addresses=["172.16.8.16"]
89             ),
90             ISIS_GenericTlv(
91                 type=134,
92                 val=b"\xac\x10\x08\x10"
93             ),
94             ISIS_ExtendedIpReachabilityTlv(
95                 pfxs=[
96                     ISIS_ExtendedIpPrefix(metric=0, pfx="172.16.8.16/32"),
97                     ISIS_ExtendedIpPrefix(metric=10, pfx="10.1.0.109/30", subtlvindicator=1,
98                     subtlvs=[
99                        ISIS_32bitAdministrativeTagSubTlv(tags=[321, 123]),
100                        ISIS_64bitAdministrativeTagSubTlv(tags=[54321, 4294967311]),
101                        ISIS_PrefixSegmentIdentifierSubTlv(flags="P", algorithm=0, idx=20)
102                     ]),
103                     ISIS_ExtendedIpPrefix(metric=10, pfx="10.20.30.40/32", subtlvindicator=1,
104                     subtlvs=[
105                         ISIS_PrefixSegmentIdentifierSubTlv(flags=["L", "V", "N"], algorithm=0, sid=1000)
106                     ]),
107                     ISIS_ExtendedIpPrefix(metric=10, pfx="10.1.0.181/30", subtlvindicator=1,
108                     subtlvs=[
109                        ISIS_GenericSubTlv(type=123, val=b"\x11\x1f\x01\x1c")
110                     ])
111                 ]
112             ),
113             ISIS_Ipv6ReachabilityTlv(
114                 pfxs=[
115                     ISIS_Ipv6Prefix(metric=0, pfx="fe10:1::10/128"),
116                     ISIS_Ipv6Prefix(metric=10, pfx="fd1f:1::/64", subtlvindicator=1,
117                     subtlvs=[
118                        ISIS_GenericSubTlv(type=99, val=b"\x1f\x01\x1f\x01\x11\x1f\x01\x1c")
119                     ]),
120                     ISIS_Ipv6Prefix(metric=10, pfx="fd1f:1:12::/64")
121                 ]
122             ),
123             ISIS_ExtendedIsReachabilityTlv(
124                 neighbours=[
125                     ISIS_ExtendedIsNeighbourEntry(neighbourid="1720.1600.8004.00", metric=10,
126                     subtlvs=[
127                        ISIS_IPv4InterfaceAddressSubTlv(address="172.16.8.4"),
128                        ISIS_LinkLocalRemoteIdentifiersSubTlv(localid=418, remoteid=54321),
129                        ISIS_IPv6NeighborAddressSubTlv(address="fe10:1::5"),
130                        ISIS_MaximumLinkBandwidthSubTlv(maxbw=125000000),
131                        ISIS_UnreservedBandwidthSubTlv(unrsvbw=[125000000, 125000000, 125000000, 125000000, 125000000, 125000000, 125000000, 125000000]),
132                        ISIS_TEDefaultMetricSubTlv(temetric=16777214)
133                     ])
134                 ]
135             ),
136             ISIS_ExternalIpReachabilityTlv(
137                 type=130
138             ),
139             ISIS_RouterCapabilityTlv(
140                 type=242,
141                 routerid="10.20.30.40",
142                 subtlvs=[
143                     ISIS_SRCapabilitiesSubTLV(
144                         flags='I',
145                         srgb_ranges=[
146                             ISIS_SRGBDescriptorEntry(
147                                 range=1000,
148                                 sid_label=ISIS_SIDLabelSubTLV(
149                                     sid=10
150                                     )
151                                ),
152                             ISIS_SRGBDescriptorEntry(
153                                 range=5000,
154                                 sid_label=ISIS_SIDLabelSubTLV(
155                                     idx=20
156                                     )
157                                ),
158                         ]
159                     ),
160                     ISIS_SRAlgorithmSubTLV(algorithms=[0, 1])
161                 ]
162             )
163         ])
164p = p.__class__(raw(p))
165assert p[ISIS_L2_LSP].pdulength == 332
166assert p[ISIS_L2_LSP].checksum == 0x074f
167assert p[ISIS_ExtendedIpReachabilityTlv].pfxs[1].subtlvs[1].tags[0]==54321
168assert p[ISIS_ExtendedIpReachabilityTlv].pfxs[2].subtlvs[0].sid==1000
169assert p[ISIS_Ipv6ReachabilityTlv].pfxs[1].subtlvs[0].len==8
170assert p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[0].address=='172.16.8.4'
171assert p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[1].localid==418
172assert p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[3].maxbw==125000000
173assert p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[4].unrsvbw[0]==125000000
174assert p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[5].temetric==16777214
175assert p[ISIS_ExternalIpReachabilityTlv].type==130
176assert p[ISIS_RouterCapabilityTlv].type==242
177assert p[ISIS_RouterCapabilityTlv].subtlvs[0].srgb_ranges[0].range==1000
178assert p[ISIS_RouterCapabilityTlv].subtlvs[0].srgb_ranges[0].sid_label.sid==10
179assert p[ISIS_RouterCapabilityTlv].subtlvs[1].algorithms==[0, 1]