Home | History | Annotate | Download | only in contrib
      1 % IS-IS Tests
      2 * Tests for the IS-IS layer
      3 
      4 + Syntax check
      5 
      6 = Import the isis layer
      7 from scapy.contrib.isis import *
      8 
      9 + Basic Layer Tests
     10 
     11 = Layer Binding
     12 p = Dot3()/LLC()/ISIS_CommonHdr()/ISIS_P2P_Hello()
     13 assert(p[LLC].dsap == 0xfe)
     14 assert(p[LLC].ssap == 0xfe)
     15 assert(p[LLC].ctrl == 0x03)
     16 assert(p[ISIS_CommonHdr].nlpid == 0x83)
     17 assert(p[ISIS_CommonHdr].pdutype == 17)
     18 assert(p[ISIS_CommonHdr].hdrlen == 20)
     19 
     20 + Package Tests
     21 
     22 = P2P Hello
     23 p = 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          ])
     28 p = p.__class__(raw(p))
     29 assert(p[ISIS_P2P_Hello].pdulength == 24)
     30 assert(network_layer_protocol_ids[p[ISIS_ProtocolsSupportedTlv].nlpids[1]] == "IPv6")
     31 
     32 = LSP
     33 p = 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          ])
     70 p = p.__class__(raw(p))
     71 assert(p[ISIS_L2_LSP].pdulength == 150)
     72 assert(p[ISIS_L2_LSP].checksum == 0x8701)
     73 
     74 = LSP with Sub-TLVs
     75 p = 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          ])
    129 p = p.__class__(raw(p))
    130 assert(p[ISIS_L2_LSP].pdulength == 231)
    131 assert(p[ISIS_L2_LSP].checksum == 0xf8df)
    132 assert(p[ISIS_ExtendedIpReachabilityTlv].pfxs[1].subtlvs[1].tags[0]==54321)
    133 assert(p[ISIS_Ipv6ReachabilityTlv].pfxs[1].subtlvs[0].len==8)
    134 assert(p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[0].address=='172.16.8.4')
    135 assert(p[ISIS_ExtendedIsReachabilityTlv].neighbours[0].subtlvs[1].localid==418)
    136 
    137