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

exabgp.bgp.message.update.attribute.bgpls.link.opaque   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A LinkOpaque.unpack() 0 4 1
1
# encoding: utf-8
2
"""
3
opaque.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 struct import pack
10
from struct import unpack
11
12
from exabgp.bgp.message.notification import Notify
13
14
from exabgp.bgp.message.update.attribute.bgpls.linkstate import LinkState
15
from exabgp.bgp.message.update.attribute.bgpls.linkstate import BaseLS
16
17
#
18
#     0                   1                   2                   3
19
#     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
20
#    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21
#    |              Type             |             Length            |
22
#    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23
#    //                     Opaque link attributes (variable)       //
24
#    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
#     https://tools.ietf.org/html/rfc7752#section-3.3.2.6 Opaque Link Attribute TLV
26
#
27
# This TLV is added here for completeness but we don't look into the TLV.
28
29
30
@LinkState.register()
31
class LinkOpaque(object):
32
    TLV = 1097
33
    REPR = 'Opaque Link attribute'
34
    REPR = 'opaque-link'
35
36
    @classmethod
37
    def unpack(cls, data, length):
38
        # XXX: cls.check(length)
39
        return cls(unpack("!%ds" % length, data[:length])[0])
40