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 | |||
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 | # // Opaque link attributes (variable) // |
||
23 | # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
||
24 | # https://tools.ietf.org/html/rfc7752#section-3.3.2.6 Opaque Link Attribute TLV |
||
25 | # |
||
26 | # This TLV is added here for completeness but we don't look into the TLV. |
||
27 | |||
28 | |||
29 | View Code Duplication | @LinkState.register() |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
30 | class LinkOpaque(object): |
||
31 | TLV = 1097 |
||
32 | |||
33 | def __init__(self, opaque): |
||
34 | self.opaque = opaque |
||
35 | |||
36 | def __repr__(self): |
||
37 | return "Link Opaque attribute: %s" % (self.opaque) |
||
38 | |||
39 | @classmethod |
||
40 | def unpack(cls, data, length): |
||
41 | return cls(unpack("!%ds" % length, data[:length])[0]) |
||
42 |