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

MaxBw.unpack()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
# encoding: utf-8
2
"""
3
maxbw.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 unpack
10
11
from exabgp.bgp.message.notification import Notify
12
from exabgp.bgp.message.update.attribute.bgpls.linkstate import LinkState
13
from exabgp.bgp.message.update.attribute.bgpls.linkstate import BaseLS
14
15
#  This sub-TLV contains the maximum bandwidth that can be used on this
16
#   link in this direction (from the system originating the LSP to its
17
#   neighbors).
18
#    https://tools.ietf.org/html/rfc5305#section-3.4
19
#
20
#  Units are in Bytes not Bits.
21
#  ----------------------------
22
23
24
@LinkState.register()
25
class MaxBw(BaseLS):
26
    TLV = 1089
27
    REPR = 'Maximum link bandwidth'
28
    JSON = 'maximum-link-bandwidth'
29
    LEN = 4
30
31
    @classmethod
32
    def unpack(cls, data, length):
33
        cls.check(length)
34
        return cls(unpack('!f', data)[0])
35