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

TeMetric.__repr__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
# encoding: utf-8
2
"""
3
temetric.py
4
5
Created by Evelio Vila on 2016-12-01.
6
Copyright (c) 2014-2017 Exa Networks. All rights reserved.
7
"""
8
from struct import unpack
9
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
#     0                   1                   2                   3
17
#     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
18
#    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19
#    |              Type             |             Length            |
20
#    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21
#    |                    TE Default Link Metric                     |
22
#    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23
#    https://tools.ietf.org/html/rfc7752#section-3.3.2.3 TE Metric
24
25
26
@LinkState.register()
27
class TeMetric(BaseLS):
28
    TLV = 1092
29
    REPR = 'TE Default Metric'
30
    JSON = 'te-metric'
31
    LEN = 4
32
33
    @classmethod
34
    def unpack(cls, data, length):
35
        cls.check(length)
36
        return cls(unpack('!L', data)[0])
37