Skip to content

Commit 0ec60bd

Browse files
committed
Added support for two new TLVs to IS-IS
The IS-IS listener now supports two new LSP TLVs: * Extended IS Reachability (code 22) * Extended IP Reachability (code 135)
1 parent ef8c7f4 commit 0ec60bd

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

isis.py

+67
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,36 @@ def parseVLenField(ftype, flen, fval, verbose=1, level=0):
650650

651651
fval = fval[16:]
652652

653+
elif ftype == VLEN_FIELDS["TEIISNeighbor"]:
654+
## 22
655+
rv["V"] = []
656+
cnt = 0
657+
while len(fval) > 0:
658+
cnt = cnt + 1
659+
(nid, psn, m1, m2, m3, s_tlv_len) =\
660+
struct.unpack("> 6sBBBBB", fval[0:11])
661+
fval = fval[11:]
662+
663+
metric = (m1 << 16) | (m2 << 8) | m3
664+
665+
node = {
666+
'NID': nid,
667+
'PSEUDONODE': psn,
668+
'METRIC': metric,
669+
'SUB_TLV_LEN': s_tlv_len
670+
}
671+
672+
rv["V"].append(node)
673+
674+
# Handling of sub TLVs will come later
675+
if s_tlv_len > 0:
676+
fval = fval[s_tlv_len:]
677+
678+
if verbose > 0:
679+
print level*INDENT +\
680+
"IS Neighbour %d: %s, pseudonode: %d, metric: %d" % (cnt, str2hex(nid), psn, metric)
681+
682+
653683
elif ftype == VLEN_FIELDS["IPIntReach"]:
654684
## 128
655685
rv["V"] = []
@@ -731,6 +761,43 @@ def parseVLenField(ftype, flen, fval, verbose=1, level=0):
731761
if verbose > 0:
732762
print level*INDENT + "interface IP addresses: " + `addrs_strs`
733763

764+
elif ftype == VLEN_FIELDS["TEIPReach"]:
765+
## 135
766+
rv["V"] = []
767+
768+
while len(fval) > 0:
769+
assert len(fval) >= 5
770+
metric, control = struct.unpack("> iB", fval[:5])
771+
fval = fval[5:]
772+
up = bool(control & 1 << 7)
773+
sub_tlvs = bool(control & 1 << 6)
774+
preflen = int(control & 63)
775+
776+
assert preflen <= 32 and preflen >= 0
777+
778+
if preflen == 0:
779+
prefix = "0.0.0.0/0"
780+
else:
781+
n_octets = (preflen - 1)/8 + 1
782+
prefix_data = struct.unpack("> %dB" % n_octets, fval[:n_octets])
783+
fval = fval[n_octets:]
784+
785+
prefix = ".".join([ "%d" % d for d in prefix_data ])
786+
prefix += ".".join([ '0' for i in range(4 - n_octets) ])
787+
prefix += "/%d" % preflen
788+
789+
if verbose > 0:
790+
print level*INDENT + "prefix: %s metric: %d up: %s sub TLVs: %s" % (prefix, metric, str(up), str(sub_tlvs))
791+
792+
prefix_reach = {
793+
'METRIC': metric,
794+
'UP': up,
795+
'SUB_TLVS': sub_tlvs,
796+
'PREFIX': prefix
797+
}
798+
799+
rv["V"].append(prefix_reach)
800+
734801
elif ftype == VLEN_FIELDS["DynamicHostname"]:
735802
## 137
736803
name = struct.unpack("> %ds" % flen, fval)

0 commit comments

Comments
 (0)