Completed
Push — master ( 3df76a...5af33a )
by Thomas
10:27
created

RemoteTeRid.__repr__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 2
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 2
loc 2
rs 10
c 0
b 0
f 0
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
from exabgp.bgp.message.update.attribute.bgpls.linkstate import BaseLS
14
15
16
#   |    1030   | IPv4 Router-ID of   |   134/---    | [RFC5305]/4.3    |
17
#   |           | Remote Node         |              |                  |
18
#   |    1031   | IPv6 Router-ID of   |   140/---    | [RFC6119]/4.1    |
19
#   |           | Remote Node         |              |                  |
20
21
22
@LinkState.register(lsid=1030)
23
@LinkState.register(lsid=1031)
24
class RemoteTeRid(BaseLS):
25
    REPR = 'Remote TE Router ID'
26
    JSON = 'remote-te-router-id'
27
28
    @classmethod
29
    def unpack(cls, data, length):
30
        size = len(data)
31
        if size not in (4, 16):
32
            raise Notify(3, 5, "Invalid remote-te size")
33
        return cls(IP.unpack(data[:size]))
34