Total Complexity | 2 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # encoding: utf-8 |
||
2 | """ |
||
3 | srrid.py |
||
4 | |||
5 | Created by Evelio Vila |
||
6 | Copyright (c) 2014-2017 Exa Networks. All rights reserved. |
||
7 | """ |
||
8 | |||
9 | from exabgp.protocol.ip import IP |
||
10 | from exabgp.bgp.message.update.attribute.bgpls.linkstate import LinkState |
||
11 | from exabgp.bgp.message.update.attribute.bgpls.linkstate import BaseLS |
||
12 | |||
13 | # draft-gredler-idr-bgp-ls-segment-routing-ext-03 |
||
14 | # 0 1 2 3 |
||
15 | # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
||
16 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
||
17 | # | Type | Length | |
||
18 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
||
19 | # // IPv4/IPv6 Address (Router-ID) // |
||
20 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
||
21 | # Source Router Identifier (Source Router-ID) TLV |
||
22 | |||
23 | |||
24 | @LinkState.register() |
||
25 | class SrSourceRouterID(BaseLS): |
||
26 | TLV = 1171 |
||
27 | REPR = 'Source router identifier' |
||
28 | JSON = 'sr-source-router-id' |
||
29 | |||
30 | @classmethod |
||
31 | def unpack(cls, data, length): |
||
32 | size = len(data) |
||
33 | if size not in (4, 16): |
||
34 | raise Notify(3, 5, "Error parsing SR Source Router ID. Wrong size") |
||
|
|||
35 | return cls(IP.unpack(data[:size])) |
||
36 |