Completed
Push — master ( 229cac...232edf )
by Thomas
10:56
created

message/update/attribute/bgpls/prefix/igptags.py (1 issue)

1
# encoding: utf-8
2
"""
3
igptags.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
14
#   The IGP Route Tag TLV carries original IGP Tags (IS-IS [RFC5130] or
15
#   OSPF) of the prefix and is encoded as follows:
16
#
17
#      0                   1                   2                   3
18
#      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
19
#     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
20
#     |              Type             |             Length            |
21
#     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22
#     //                    Route Tags (one or more)                 //
23
#     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24
#     https://tools.ietf.org/html/rfc7752#section-3.3.3.2
25
26
27
@LINKSTATE.register()
28
class IgpTags(object):
29
    TLV = 1153
30
31
    def __init__(self, igptags):
32
        self.igptags = igptags
33
34
    def __repr__(self):
35
        return "IGP Route Tags: %s" % (self.igptags)
36
37
    @classmethod
38
    def unpack(cls, data, length):
39
        return cls([unpack("!L", _)[0] for _ in split(data, 4)])
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable split does not seem to be defined.
Loading history...
40
41
42
    def json(self, compact=None):
43
        return '"igp-route-tags": %s' % self.igptags
44