1 | # encoding: utf-8 |
||
2 | """ |
||
3 | rterid.py |
||
4 | |||
5 | Created by Evelio Vila on 2016-12-01. |
||
6 | Copyright (c) 2014-2017 Exa Networks. All rights reserved. |
||
7 | """ |
||
8 | |||
9 | from exabgp.protocol.ip import IP |
||
10 | from exabgp.bgp.message.notification import Notify |
||
11 | |||
12 | from exabgp.bgp.message.update.attribute.bgpls.linkstate import LinkState |
||
13 | |||
14 | |||
15 | # | 1030 | IPv4 Router-ID of | 134/--- | [RFC5305]/4.3 | |
||
16 | # | | Remote Node | | | |
||
17 | # | 1031 | IPv6 Router-ID of | 140/--- | [RFC6119]/4.1 | |
||
18 | # | | Remote Node | | | |
||
19 | |||
20 | |||
21 | View Code Duplication | @LinkState.register(lsid=1030) |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
22 | @LinkState.register(lsid=1031) |
||
23 | class RemoteTeRid(object): |
||
24 | def __init__(self, terid): |
||
25 | self.terid = terid |
||
26 | |||
27 | def __repr__(self): |
||
28 | return "Remote TE Router ID: %s" % (self.terid) |
||
29 | |||
30 | @classmethod |
||
31 | def unpack(cls, data, length): |
||
32 | size = len(data) |
||
33 | |||
34 | if size not in (4, 16): |
||
35 | raise Notify(3, 5, "Invalid remote-te size") |
||
36 | |||
37 | terid = IP.unpack(data[:size]) |
||
38 | return cls(terid=terid) |
||
39 | |||
40 | def json(self, compact=None): |
||
41 | return '"remote-te-router-id": "%s"' % str(self.terid) |
||
42 |