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

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

1
# encoding: utf-8
2
"""
3
nodename.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
16
#
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
#     //              Opaque Prefix Attributes  (variable)           //
22
#     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23
#     https://tools.ietf.org/html/rfc7752#section-3.3.3.6
24
#
25
26
27 View Code Duplication
@LINKSTATE.register()
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
28
class PrefixOpaque(object):
29
    TLV = 1157
30
31
    def __init__(self, opaque):
32
        self.opaque = opaque
33
34
    def __repr__(self):
35
        return "Prefix Opaque attribute: %s" % (self.opaque)
36
37
    @classmethod
38
    def unpack(cls, data, length):
39
        return cls(unpack("!%ds" % length, data[:length])[0])
40
41
    # XXX: Missing JSON