• 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                     ]),
102                     ISIS_ExtendedIpPrefix(metric=10, pfx="10.1.0.181/30", subtlvindicator=1,
103                     subtlvs=[
104                        ISIS_GenericSubTlv(type=123, val=b"\x11\x1f\x01\x1c")
105                     ])
106                 ]
107             ),
108             ISIS_Ipv6ReachabilityTlv(
109                 pfxs=[
110                     ISIS_Ipv6Prefix(metric=0, pfx="fe10:1::10/128"),
111                     ISIS_Ipv6Prefix(metric=10, pfx="fd1f:1::/64", subtlvindicator=1,
112                     subtlvs=[
113                        ISIS_GenericSubTlv(type=99, val=b"\x1f\x01\x1f\x01\x11\x1f\x01\x1c")
114                     ]),
115                     ISIS_Ipv6Prefix(metric=10, pfx="fd1f:1:12::/64")
116                 ]
117             ),
118             ISIS_ExtendedIsReachabilityTlv(
119                 neighbours=[
120                     ISIS_ExtendedIsNeighbourEntry(neighbourid="1720.1600.8004.00", metric=10,
121                     subtlvs=[
122                        ISIS_IPv4InterfaceAddressSubTlv(address="172.16.8.4"),
123                        ISIS_LinkLocalRemoteIdentifiersSubTlv(localid=418, remoteid=54321),
124                        ISIS_IPv6NeighborAddressSubTlv(address="fe10:1::5")
125                     ])
126                 ]
127             )
128         ])
129p = p.__class__(raw(p))
130assert(p[ISIS_L2_LSP].pdulength == 231)
131assert(p[ISIS_L2_LSP].checksum == 0xf8df)
132assert(p[ISIS_ExtendedIpReachabilityTlv].pfxs[1].subtlvs[1].tags[0]==54321)
133assert(p[ISIS_Ipv6ReachabilityTlv].pfxs[1].subtlvs[0].len==8)
134assert(p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[0].address=='172.16.8.4')
135assert(p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[1].localid==418)
136
137