Completed
Push — master ( 5af33a...81e1b1 )
by Thomas
13:24
created

exabgp.bgp.message.update.attribute.bgpls.prefix.srrid   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A SrSourceRouterID.unpack() 0 6 2
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")
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Notify does not seem to be defined.
Loading history...
35
        return cls(IP.unpack(data[:size]))
36