~ubuntu-branches/ubuntu/utopic/exabgp/utopic

« back to all changes in this revision

Viewing changes to QA/unittest/decode-route.py

  • Committer: Package Import Robot
  • Author(s): Henry-Nicolas Tourneur
  • Date: 2014-03-08 19:07:00 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140308190700-xjbibpg1g6001c9x
Tags: 3.3.1-1
* New upstream release
* Bump python minimal required version (2.7)
* Closes: #726066 Debian packaging improvements proposed by Vincent Bernat
* Closes: #703774 not existent rundir (/var/run/exabgp) after reboot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
from exabgp.structure.environment import environment
4
 
env = environment.setup('')
5
 
 
6
 
header = [
7
 
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, # marker
8
 
        0x1, 0x37, # len 311 (body is 296 - 296 + 19 = 315 !!)
9
 
        0x2, # type Update
10
 
]
11
 
 
12
 
body = [
13
 
        0x0, 0x0, #len withdrawn routes
14
 
        # No routes to remove
15
 
        # Attributes
16
 
        0x0, 0x30, # len attributes (48)
17
 
                0x40, # Flag Transitive
18
 
                0x1, # Code : AttributeID Origin
19
 
                0x1, # len
20
 
                        0x0, # Origin : IGP
21
 
                0x50, # Flag Transitive + extended length
22
 
                0x2, # Code : AS Path
23
 
                0x0, 0x16, # len 22
24
 
                        0x2, # Type (AS_Sequence)
25
 
                        0x5, # length (in ASes as every asn is 0x0 0x0 prefixed ASN4 must have been negotiated)
26
 
                                0x0, 0x0, 0xfe, 0xb0,           # ASN 65200
27
 
                                0x0, 0x0, 0x78, 0x14,           # ASN 30740
28
 
                                0x0, 0x0, 0x19, 0x35,           # ASN 6453
29
 
                                0x0, 0x0, 0xb, 0x62,            # ASN 2914
30
 
                                0x0, 0x0, 0x9, 0xd7,            # ASN 2519
31
 
                0x40, # Flag Transitive
32
 
                0x3, # Code: Next HOP
33
 
                0x4, # len
34
 
                        0x7f, 0x0, 0x0, 0x1, # 127.0.0.1
35
 
                0xc0, # 0x40 + 0x80 (Transitive Optional)
36
 
                0x8, # Community
37
 
                0x8, # Size 8
38
 
                        0x78, 0x14, 0x19, 0x35, # 30740:6453
39
 
                        0x78, 0x14, 0xfd, 0xeb, # 30740:65003
40
 
        # routes :
41
 
                0x18, 0x1, 0x0, 0x19, # 1.0.25.0/24
42
 
                0x10, 0xde, 0xe6, # 222.330.0.0/16
43
 
                0x11, 0xde, 0xe5, 0x80,
44
 
                0x12, 0xde, 0xe5, 0x0,
45
 
                0x10, 0xde, 0xe4,
46
 
                0x11, 0xdc, 0xf7, 0x0,
47
 
                0x11, 0xdc, 0x9e, 0x0,
48
 
                0x18, 0xdb, 0x79, 0xff,
49
 
                0x18, 0xdb, 0x79, 0xf9,
50
 
                0x16, 0xd8, 0xb3, 0xcc,
51
 
                0x18, 0xd8, 0xb3, 0xb6,
52
 
                0x17, 0xd8, 0xb3, 0xb4,
53
 
                0x16, 0xd8, 0xb3, 0xb0,
54
 
                0x18, 0xd8, 0xb3, 0x99,
55
 
                0x12, 0xd2, 0xaa, 0x0,
56
 
                0x11, 0xd2, 0x92, 0x80,
57
 
                0x11, 0xd2, 0x83, 0x80,
58
 
                0x13, 0xcb, 0x8c, 0x20,
59
 
                0x18, 0xca, 0xf5, 0xfe,
60
 
                0x18, 0xca, 0xf5, 0x8e,
61
 
                0x18, 0xca, 0xf3, 0xba,
62
 
                0x18, 0xca, 0xf0, 0x8d,
63
 
                0x12, 0xca, 0xef, 0xc0,
64
 
                0x12, 0xca, 0xe7, 0x40,
65
 
                0x10, 0xca, 0xd7,
66
 
                0x18, 0xca, 0xd2, 0x8,
67
 
                0x13, 0xca, 0xbd, 0xc0,
68
 
                0x14, 0xca, 0x58, 0x30,
69
 
                0x18, 0xca, 0x22, 0xbf,
70
 
                0x17, 0xca, 0x22, 0x96,
71
 
                0x18, 0xc0, 0x32, 0x6e,
72
 
                0x10, 0xb7, 0xb4,
73
 
                0x11, 0xb7, 0xb1, 0x80,
74
 
                0x10, 0xa3, 0x8b,
75
 
                0x11, 0x9d, 0x78, 0x80,
76
 
                0x15, 0x7c, 0xf1, 0x78,
77
 
                0x10, 0x7c, 0x6e,
78
 
                0x10, 0x7a, 0x67,
79
 
                0x10, 0x78, 0x33,
80
 
                0x10, 0x74, 0x5b,
81
 
                0x15, 0x73, 0xbb, 0x48,
82
 
                0x16, 0x73, 0xbb, 0x44,
83
 
                0x10, 0x73, 0xb3,
84
 
                0x11, 0x72, 0x45, 0x0,
85
 
                0x14, 0x71, 0x34, 0xf0,
86
 
                0x15, 0x70, 0x6d, 0x18,
87
 
                0x18, 0x67, 0xf6, 0xb3,
88
 
                0x17, 0x67, 0xb, 0x6,
89
 
                0x18, 0x67, 0x5, 0x75,
90
 
                0x18, 0x67, 0x5, 0x74,
91
 
                0x18, 0x67, 0x3, 0x10,
92
 
                0x13, 0x65, 0x37, 0xc0,
93
 
                0x11, 0x65, 0x32, 0x80,
94
 
                0x18, 0x65, 0x0, 0x1f,
95
 
                0x18, 0x65, 0x0, 0x1e,
96
 
                0x18, 0x65, 0x0, 0x1d,
97
 
                0x18, 0x65, 0x0, 0x1c,
98
 
                0xf, 0x24, 0x2,
99
 
                0x11, 0x1b, 0x79, 0x80,
100
 
                0x13, 0x1b, 0x60, 0x20,
101
 
                0x15, 0x1b, 0x60, 0x10,
102
 
                0x10, 0x1, 0x15,
103
 
                0x16, 0x1, 0x0, 0x1c,
104
 
                0x17, 0x1, 0x0, 0x1a
105
 
]
106
 
 
107
 
 
108
 
header = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1, 0x22, 0x2]
109
 
 
110
 
body = [
111
 
        0x0, 0x0,
112
 
        0x0, 0x38,
113
 
        0x40,
114
 
                0x1,
115
 
                0x1,
116
 
                        0x0,
117
 
        0x50,
118
 
                0x2,
119
 
                0x0, 0x12,
120
 
                        0x2,
121
 
                        0x4,
122
 
                                0x0, 0x0, 0xc7, 0x9d,
123
 
                                0x0, 0x0, 0x9b, 0xbd,
124
 
                                0x0, 0x0, 0xb, 0x62,
125
 
                                0x0, 0x0, 0x9, 0xd7,
126
 
        0x40,
127
 
                0x3,
128
 
                0x4,
129
 
                        0xb2, 0xd9, 0x76, 0x1,
130
 
        0xc0,
131
 
                0x8,
132
 
                0x14,
133
 
                        0xb, 0x62, 0x1, 0x9a,
134
 
                        0xb, 0x62, 0x5, 0x7b,
135
 
                        0xb, 0x62, 0x9, 0x61,
136
 
                        0xb, 0x62, 0xd, 0x48,
137
 
                        0x9b, 0xbd, 0x1d, 0x1a,
138
 
        0x18, 0x1, 0x0, 0x19,
139
 
        0x10, 0xde, 0xe6,
140
 
        0x11, 0xde, 0xe5, 0x80,
141
 
        0x12, 0xde, 0xe5, 0x0,
142
 
        0x18, 0xdb, 0x79, 0xff,
143
 
        0x18, 0xdb, 0x79, 0xf9,
144
 
        0x16, 0xd8, 0xb3, 0xcc,
145
 
        0x18, 0xd8, 0xb3, 0xb6,
146
 
        0x17, 0xd8, 0xb3, 0xb4,
147
 
        0x16, 0xd8, 0xb3, 0xb0,
148
 
        0x18, 0xd8, 0xb3, 0x99,
149
 
        0x12, 0xd2, 0xaa, 0x0,
150
 
        0x11, 0xd2, 0x92, 0x80,
151
 
        0x11, 0xd2, 0x83, 0x80,
152
 
        0x13, 0xcb, 0x8c, 0x20,
153
 
        0x18, 0xca, 0xf5, 0xfe,
154
 
        0x18, 0xca, 0xf5, 0x8e,
155
 
        0x18, 0xca, 0xf3, 0xba,
156
 
        0x18, 0xca, 0xf0, 0x8d,
157
 
        0x12, 0xca, 0xef, 0xc0,
158
 
        0x12, 0xca, 0xe7, 0x40,
159
 
        0x18, 0xca, 0xd2, 0x8,
160
 
        0x13, 0xca, 0xbd, 0xc0,
161
 
        0x14, 0xca, 0x58, 0x30,
162
 
        0x18, 0xca, 0x22, 0xbf,
163
 
        0x17, 0xca, 0x22, 0x96,
164
 
        0x18, 0xc0, 0x32, 0x6e,
165
 
        0x10, 0xb7, 0xb4,
166
 
        0x11, 0x9d, 0x78, 0x80,
167
 
        0x15, 0x7c, 0xf1, 0x78,
168
 
        0x10, 0x7a, 0x67,
169
 
        0x15, 0x73, 0xbb, 0x48,
170
 
        0x16, 0x73, 0xbb, 0x44,
171
 
        0x11, 0x72, 0x45, 0x0,
172
 
        0x14, 0x71, 0x34, 0xf0,
173
 
        0x15, 0x70, 0x6d, 0x18,
174
 
        0x18, 0x67, 0xf6, 0xb3,
175
 
        0x17, 0x67, 0xb, 0x6,
176
 
        0x18, 0x67, 0x5, 0x75,
177
 
        0x18, 0x67, 0x5, 0x74,
178
 
        0x18, 0x67, 0x3, 0x10,
179
 
        0x13, 0x65, 0x37, 0xc0,
180
 
        0x11, 0x65, 0x32, 0x80,
181
 
        0x18, 0x65, 0x0, 0x1f,
182
 
        0x18, 0x65, 0x0, 0x1e,
183
 
        0x18, 0x65, 0x0, 0x1d,
184
 
        0x18, 0x65, 0x0, 0x1c,
185
 
        0xf, 0x24, 0x2,
186
 
        0x11, 0x1b, 0x79, 0x80,
187
 
        0x13, 0x1b, 0x60, 0x20,
188
 
        0x15, 0x1b, 0x60, 0x10,
189
 
        0x10, 0x1, 0x15,
190
 
        0x16, 0x1, 0x0, 0x1c,
191
 
        0x17, 0x1, 0x0, 0x1a
192
 
]
193
 
 
194
 
route = header + body
195
 
 
196
 
from StringIO import StringIO
197
 
from exabgp.bgp.protocol import Protocol
198
 
from exabgp.bgp.peer import Peer
199
 
from exabgp.bgp.neighbor import Neighbor
200
 
 
201
 
class Connection (StringIO):
202
 
        def pending (self,**argv):
203
 
                return True
204
 
 
205
 
cnx = Connection(''.join([chr(_) for _ in route]))
206
 
neibor = Neighbor()
207
 
peer = Peer(neibor,None)
208
 
 
209
 
#import pdb
210
 
#pdb.set_trace()
211
 
 
212
 
proto = Protocol(peer,cnx)
213
 
proto._asn4 = True
214
 
print proto.UpdateFactory(body)