xref: /aosp_15_r20/external/scapy/scapy/contrib/bgp.uts (revision 7dc08ffc4802948ccbc861daaf1e81c405c2c4bd)
1*7dc08ffcSJunyu Lai#################################### bgp.py ##################################
2*7dc08ffcSJunyu Lai% Regression tests for the bgp module
3*7dc08ffcSJunyu Lai
4*7dc08ffcSJunyu Lai# Default configuration : OLD speaker (see RFC 6793)
5*7dc08ffcSJunyu Laibgp_module_conf.use_2_bytes_asn  = True
6*7dc08ffcSJunyu Lai
7*7dc08ffcSJunyu Lai################################ BGPNLRI_IPv4 ################################
8*7dc08ffcSJunyu Lai+ BGPNLRI_IPv4 class tests
9*7dc08ffcSJunyu Lai
10*7dc08ffcSJunyu Lai= BGPNLRI_IPv4 - Instantiation
11*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv4()) == b'\x00'
12*7dc08ffcSJunyu Lai
13*7dc08ffcSJunyu Lai= BGPNLRI_IPv4 - Instantiation with specific values (1)
14*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv4(prefix = '255.255.255.255/32')) == b' \xff\xff\xff\xff'
15*7dc08ffcSJunyu Lai
16*7dc08ffcSJunyu Lai= BGPNLRI_IPv4 - Instantiation with specific values (2)
17*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv4(prefix = '0.0.0.0/0')) == b'\x00'
18*7dc08ffcSJunyu Lai
19*7dc08ffcSJunyu Lai= BGPNLRI_IPv4 - Instantiation with specific values (3)
20*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv4(prefix = '192.0.2.0/24')) == b'\x18\xc0\x00\x02'
21*7dc08ffcSJunyu Lai
22*7dc08ffcSJunyu Lai= BGPNLRI_IPv4 - Basic dissection
23*7dc08ffcSJunyu Lainlri = BGPNLRI_IPv4(b'\x00')
24*7dc08ffcSJunyu Lainlri.prefix == '0.0.0.0/0'
25*7dc08ffcSJunyu Lai
26*7dc08ffcSJunyu Lai= BGPNLRI_IPv4 - Dissection with specific values
27*7dc08ffcSJunyu Lainlri = BGPNLRI_IPv4(b'\x18\xc0\x00\x02')
28*7dc08ffcSJunyu Lainlri.prefix == '192.0.2.0/24'
29*7dc08ffcSJunyu Lai
30*7dc08ffcSJunyu Lai
31*7dc08ffcSJunyu Lai################################ BGPNLRI_IPv6 ################################
32*7dc08ffcSJunyu Lai+ BGPNLRI_IPv6 class tests
33*7dc08ffcSJunyu Lai
34*7dc08ffcSJunyu Lai= BGPNLRI_IPv6 - Instantiation
35*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv6()) == b'\x00'
36*7dc08ffcSJunyu Lai
37*7dc08ffcSJunyu Lai= BGPNLRI_IPv6 - Instantiation with specific values (1)
38*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv6(prefix = '::/0')) == b'\x00'
39*7dc08ffcSJunyu Lai
40*7dc08ffcSJunyu Lai= BGPNLRI_IPv6 - Instantiation with specific values (2)
41*7dc08ffcSJunyu Lairaw(BGPNLRI_IPv6(prefix = '2001:db8::/32')) == b'  \x01\r\xb8'
42*7dc08ffcSJunyu Lai
43*7dc08ffcSJunyu Lai= BGPNLRI_IPv6 - Basic dissection
44*7dc08ffcSJunyu Lainlri = BGPNLRI_IPv6(b'\x00')
45*7dc08ffcSJunyu Lainlri.prefix == '::/0'
46*7dc08ffcSJunyu Lai
47*7dc08ffcSJunyu Lai= BGPNLRI_IPv6 - Dissection with specific values
48*7dc08ffcSJunyu Lainlri = BGPNLRI_IPv6(b'  \x01\r\xb8')
49*7dc08ffcSJunyu Lainlri.prefix == '2001:db8::/32'
50*7dc08ffcSJunyu Lai
51*7dc08ffcSJunyu Lai
52*7dc08ffcSJunyu Lai#################################### BGP #####################################
53*7dc08ffcSJunyu Lai+ BGP class tests
54*7dc08ffcSJunyu Lai
55*7dc08ffcSJunyu Lai= BGP - Instantiation (Should be a KEEPALIVE)
56*7dc08ffcSJunyu Laim = BGP()
57*7dc08ffcSJunyu Laiassert(raw(m) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04')
58*7dc08ffcSJunyu Laiassert(m.type == BGP.KEEPALIVE_TYPE)
59*7dc08ffcSJunyu Lai
60*7dc08ffcSJunyu Lai= BGP - Instantiation with specific values (1)
61*7dc08ffcSJunyu Lairaw(BGP(type = 0)) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x00'
62*7dc08ffcSJunyu Lai
63*7dc08ffcSJunyu Lai= BGP - Instantiation with specific values (2)
64*7dc08ffcSJunyu Lairaw(BGP(type = 1)) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x01'
65*7dc08ffcSJunyu Lai
66*7dc08ffcSJunyu Lai= BGP - Instantiation with specific values (3)
67*7dc08ffcSJunyu Lairaw(BGP(type = 2)) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x02'
68*7dc08ffcSJunyu Lai
69*7dc08ffcSJunyu Lai= BGP - Instantiation with specific values (4)
70*7dc08ffcSJunyu Lairaw(BGP(type = 3)) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x03'
71*7dc08ffcSJunyu Lai
72*7dc08ffcSJunyu Lai= BGP - Instantiation with specific values (5)
73*7dc08ffcSJunyu Lairaw(BGP(type = 4)) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04'
74*7dc08ffcSJunyu Lai
75*7dc08ffcSJunyu Lai= BGP - Instantiation with specific values (6)
76*7dc08ffcSJunyu Lairaw(BGP(type = 5)) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x05'
77*7dc08ffcSJunyu Lai
78*7dc08ffcSJunyu Lai= BGP - Basic dissection
79*7dc08ffcSJunyu Laih = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04')
80*7dc08ffcSJunyu Laiassert(h.type == BGP.KEEPALIVE_TYPE)
81*7dc08ffcSJunyu Laiassert(h.len == 19)
82*7dc08ffcSJunyu Lai
83*7dc08ffcSJunyu Lai= BGP - Dissection with specific values
84*7dc08ffcSJunyu Laih = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x01')
85*7dc08ffcSJunyu Laiassert(h.type == BGP.OPEN_TYPE)
86*7dc08ffcSJunyu Laiassert(h.len == 19)
87*7dc08ffcSJunyu Lai
88*7dc08ffcSJunyu Lai############################### BGPKeepAlive  #################################
89*7dc08ffcSJunyu Lai+ BGPKeepAlive class tests
90*7dc08ffcSJunyu Lai
91*7dc08ffcSJunyu Lai= BGPKeepAlive - Instantiation (by default, should be a "generic" capability)
92*7dc08ffcSJunyu Lairaw(BGPKeepAlive())
93*7dc08ffcSJunyu Lairaw(BGPKeepAlive()) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04'
94*7dc08ffcSJunyu Lai
95*7dc08ffcSJunyu Lai= BGPKeepAlive - Swallowing tests: combined BGPKeepAlive
96*7dc08ffcSJunyu Laio = BGPKeepAlive()
97*7dc08ffcSJunyu Laim=IP(src="12.0.0.1",dst="12.0.0.2")/TCP(dport=54321)/BGP(raw(o)*2)
98*7dc08ffcSJunyu Laim.show()
99*7dc08ffcSJunyu Laiassert isinstance(m[BGPKeepAlive].payload, BGPKeepAlive)
100*7dc08ffcSJunyu Laiassert m[BGPKeepAlive].payload.marker == 0xffffffffffffffffffffffffffffffff
101*7dc08ffcSJunyu Lai
102*7dc08ffcSJunyu Lai############################### BGPCapability #################################
103*7dc08ffcSJunyu Lai+ BGPCapability class tests
104*7dc08ffcSJunyu Lai
105*7dc08ffcSJunyu Lai= BGPCapability - Instantiation (by default, should be a "generic" capability)
106*7dc08ffcSJunyu Lairaw(BGPCapability())
107*7dc08ffcSJunyu Lairaw(BGPCapability()) == b'\x00\x00'
108*7dc08ffcSJunyu Lai
109*7dc08ffcSJunyu Lai= BGPCapability - Instantiation with specific values (1)
110*7dc08ffcSJunyu Laic = BGPCapability(code = 70)
111*7dc08ffcSJunyu Laiassert(raw(c) == b'F\x00')
112*7dc08ffcSJunyu Lai
113*7dc08ffcSJunyu Lai= BGPCapability - Check exception
114*7dc08ffcSJunyu Laifrom scapy.contrib.bgp import _BGPInvalidDataException
115*7dc08ffcSJunyu Laitry:
116*7dc08ffcSJunyu Lai  BGPCapability("\x00")
117*7dc08ffcSJunyu Lai  False
118*7dc08ffcSJunyu Laiexcept _BGPInvalidDataException:
119*7dc08ffcSJunyu Lai  True
120*7dc08ffcSJunyu Lai
121*7dc08ffcSJunyu Lai= BGPCapability - Test haslayer()
122*7dc08ffcSJunyu Laiassert BGPCapFourBytesASN().haslayer(BGPCapability)
123*7dc08ffcSJunyu Laiassert BGPCapability in BGPCapFourBytesASN()
124*7dc08ffcSJunyu Lai
125*7dc08ffcSJunyu Lai= BGPCapability - Test getlayer()
126*7dc08ffcSJunyu Laiassert isinstance(BGPCapFourBytesASN().getlayer(BGPCapability), BGPCapFourBytesASN)
127*7dc08ffcSJunyu Laiassert isinstance(BGPCapFourBytesASN()[BGPCapability], BGPCapFourBytesASN)
128*7dc08ffcSJunyu Lai
129*7dc08ffcSJunyu Lai
130*7dc08ffcSJunyu Lai############################ BGPCapMultiprotocol ##############################
131*7dc08ffcSJunyu Lai+ BGPCapMultiprotocol class tests
132*7dc08ffcSJunyu Lai
133*7dc08ffcSJunyu Lai= BGPCapMultiprotocol - Inheritance
134*7dc08ffcSJunyu Laic = BGPCapMultiprotocol()
135*7dc08ffcSJunyu Laiassert(isinstance(c, BGPCapability))
136*7dc08ffcSJunyu Lai
137*7dc08ffcSJunyu Lai= BGPCapMultiprotocol - Instantiation
138*7dc08ffcSJunyu Lairaw(BGPCapMultiprotocol()) == b'\x01\x04\x00\x00\x00\x00'
139*7dc08ffcSJunyu Lai
140*7dc08ffcSJunyu Lai= BGPCapMultiprotocol - Instantiation with specific values (1)
141*7dc08ffcSJunyu Lairaw(BGPCapMultiprotocol(afi = 1, safi = 1)) == b'\x01\x04\x00\x01\x00\x01'
142*7dc08ffcSJunyu Lai
143*7dc08ffcSJunyu Lai= BGPCapMultiprotocol - Instantiation with specific values (2)
144*7dc08ffcSJunyu Lairaw(BGPCapMultiprotocol(afi = 2, safi = 1)) == b'\x01\x04\x00\x02\x00\x01'
145*7dc08ffcSJunyu Lai
146*7dc08ffcSJunyu Lai= BGPCapMultiprotocol - Dissection with specific values
147*7dc08ffcSJunyu Laic = BGPCapMultiprotocol(b'\x01\x04\x00\x02\x00\x01')
148*7dc08ffcSJunyu Laiassert(c.code == 1)
149*7dc08ffcSJunyu Laiassert(c.length == 4)
150*7dc08ffcSJunyu Laiassert(c.afi == 2)
151*7dc08ffcSJunyu Laiassert(c.reserved == 0)
152*7dc08ffcSJunyu Laiassert(c.safi == 1)
153*7dc08ffcSJunyu Lai
154*7dc08ffcSJunyu Lai############################### BGPCapORFBlock ###############################
155*7dc08ffcSJunyu Lai+ BGPCapORFBlock class tests
156*7dc08ffcSJunyu Lai
157*7dc08ffcSJunyu Lai= BGPCapORFBlock - Instantiation
158*7dc08ffcSJunyu Lairaw(BGPCapORFBlock()) == b'\x00\x00\x00\x00\x00'
159*7dc08ffcSJunyu Lai
160*7dc08ffcSJunyu Lai= BGPCapORFBlock - Instantiation with specific values (1)
161*7dc08ffcSJunyu Lairaw(BGPCapORFBlock(afi = 1, safi = 1)) == b'\x00\x01\x00\x01\x00'
162*7dc08ffcSJunyu Lai
163*7dc08ffcSJunyu Lai= BGPCapORFBlock - Instantiation with specific values (2)
164*7dc08ffcSJunyu Lairaw(BGPCapORFBlock(afi = 2, safi = 1)) == b'\x00\x02\x00\x01\x00'
165*7dc08ffcSJunyu Lai
166*7dc08ffcSJunyu Lai= BGPCapORFBlock - Basic dissection
167*7dc08ffcSJunyu Laic = BGPCapORFBlock(b'\x00\x00\x00\x00\x00')
168*7dc08ffcSJunyu Laic.afi == 0 and c.reserved == 0 and c.safi == 0 and c.orf_number == 0
169*7dc08ffcSJunyu Lai
170*7dc08ffcSJunyu Lai= BGPCapORFBlock - Dissection with specific values
171*7dc08ffcSJunyu Laic = BGPCapORFBlock(b'\x00\x02\x00\x01\x00')
172*7dc08ffcSJunyu Laic.afi == 2 and c.reserved == 0 and c.safi == 1 and c.orf_number == 0
173*7dc08ffcSJunyu Lai
174*7dc08ffcSJunyu Lai
175*7dc08ffcSJunyu Lai############################# BGPCapORFBlock.ORF ##############################
176*7dc08ffcSJunyu Lai+ BGPCapORFBlock.ORF class tests
177*7dc08ffcSJunyu Lai
178*7dc08ffcSJunyu Lai= BGPCapORFBlock.ORF - Instantiation
179*7dc08ffcSJunyu Lairaw(BGPCapORFBlock.ORFTuple()) == b'\x00\x00'
180*7dc08ffcSJunyu Lai
181*7dc08ffcSJunyu Lai= BGPCapORFBlock.ORF - Instantiation with specific values (1)
182*7dc08ffcSJunyu Lairaw(BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)) == b'@\x03'
183*7dc08ffcSJunyu Lai
184*7dc08ffcSJunyu Lai= BGPCapORFBlock.ORF - Basic dissection
185*7dc08ffcSJunyu Laic = BGPCapORFBlock.ORFTuple(b'\x00\x00')
186*7dc08ffcSJunyu Laic.orf_type == 0 and c.send_receive == 0
187*7dc08ffcSJunyu Lai
188*7dc08ffcSJunyu Lai= BGPCapORFBlock.ORF - Dissection with specific values
189*7dc08ffcSJunyu Laic = BGPCapORFBlock.ORFTuple(b'@\x03')
190*7dc08ffcSJunyu Laic.orf_type == 64 and c.send_receive == 3
191*7dc08ffcSJunyu Lai
192*7dc08ffcSJunyu Lai
193*7dc08ffcSJunyu Lai################################# BGPCapORF ###################################
194*7dc08ffcSJunyu Lai+ BGPCapORF class tests
195*7dc08ffcSJunyu Lai
196*7dc08ffcSJunyu Lai= BGPCapORF - Inheritance
197*7dc08ffcSJunyu Laic = BGPCapORF()
198*7dc08ffcSJunyu Laiassert(isinstance(c, BGPCapability))
199*7dc08ffcSJunyu Lai
200*7dc08ffcSJunyu Lai= BGPCapORF - Instantiation
201*7dc08ffcSJunyu Lairaw(BGPCapORF()) == b'\x03\x00'
202*7dc08ffcSJunyu Lai
203*7dc08ffcSJunyu Lai= BGPCapORF - Instantiation with specific values (1)
204*7dc08ffcSJunyu Lairaw(BGPCapORF(orf = [BGPCapORFBlock(afi = 1, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)])])) == b'\x03\x07\x00\x01\x00\x01\x01@\x03'
205*7dc08ffcSJunyu Lai
206*7dc08ffcSJunyu Lai= BGPCapORF - Instantiation with specific values (2)
207*7dc08ffcSJunyu Lairaw(BGPCapORF(orf = [BGPCapORFBlock(afi = 1, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)]), BGPCapORFBlock(afi = 2, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)])])) == b'\x03\x0e\x00\x01\x00\x01\x01@\x03\x00\x02\x00\x01\x01@\x03'
208*7dc08ffcSJunyu Lai
209*7dc08ffcSJunyu Lai= BGPCapORF - Basic dissection
210*7dc08ffcSJunyu Laic = BGPCapORF(b'\x03\x00')
211*7dc08ffcSJunyu Laic.code == 3 and c.length == 0
212*7dc08ffcSJunyu Lai
213*7dc08ffcSJunyu Lai= BGPCapORF - Dissection with specific values
214*7dc08ffcSJunyu Laic = BGPCapORF(orf = [BGPCapORFBlock(afi = 1, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)]), BGPCapORFBlock(afi = 2, safi = 1, entries = [BGPCapORFBlock.ORFTuple(orf_type = 64, send_receive = 3)])])
215*7dc08ffcSJunyu Laic.code == 3 and c.orf[0].afi == 1 and c.orf[0].safi == 1 and c.orf[0].entries[0].orf_type == 64 and c.orf[0].entries[0].send_receive == 3 and c.orf[1].afi == 2 and c.orf[1].safi == 1 and c.orf[1].entries[0].orf_type == 64 and c.orf[1].entries[0].send_receive == 3
216*7dc08ffcSJunyu Lai
217*7dc08ffcSJunyu Lai= BGPCapORF - Dissection
218*7dc08ffcSJunyu Laip = BGPCapORF(b'\x03\x07\x00\x01\x00\x01\x01@\x03')
219*7dc08ffcSJunyu Laiassert(len(p.orf) == 1)
220*7dc08ffcSJunyu Lai
221*7dc08ffcSJunyu Lai
222*7dc08ffcSJunyu Lai####################### BGPCapGracefulRestart.GRTuple #########################
223*7dc08ffcSJunyu Lai+ BGPCapGracefulRestart.GRTuple class tests
224*7dc08ffcSJunyu Lai
225*7dc08ffcSJunyu Lai= BGPCapGracefulRestart.GRTuple - Instantiation
226*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart.GRTuple()) == b'\x00\x00\x00\x00'
227*7dc08ffcSJunyu Lai
228*7dc08ffcSJunyu Lai= BGPCapGracefulRestart.GRTuple - Instantiation with specific values
229*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart.GRTuple(afi = 1, safi = 1, flags = 128)) == b'\x00\x01\x01\x80'
230*7dc08ffcSJunyu Lai
231*7dc08ffcSJunyu Lai= BGPCapGracefulRestart.GRTuple - Basic dissection
232*7dc08ffcSJunyu Laic = BGPCapGracefulRestart.GRTuple(b'\x00\x00\x00\x00')
233*7dc08ffcSJunyu Laic.afi == 0 and c.safi == 0 and c.flags == 0
234*7dc08ffcSJunyu Lai
235*7dc08ffcSJunyu Lai= BGPCapGracefulRestart.GRTuple - Dissection with specific values
236*7dc08ffcSJunyu Laic = BGPCapGracefulRestart.GRTuple(b'\x00\x01\x01\x80')
237*7dc08ffcSJunyu Laic.afi == 1 and c.safi == 1 and c.flags == 128
238*7dc08ffcSJunyu Lai
239*7dc08ffcSJunyu Lai
240*7dc08ffcSJunyu Lai########################### BGPCapGracefulRestart #############################
241*7dc08ffcSJunyu Lai+ BGPCapGracefulRestart class tests
242*7dc08ffcSJunyu Lai
243*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Inheritance
244*7dc08ffcSJunyu Laic = BGPCapGracefulRestart()
245*7dc08ffcSJunyu Laiassert(isinstance(c, BGPCapGracefulRestart))
246*7dc08ffcSJunyu Lai
247*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Instantiation
248*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart()) == b'@\x02\x00\x00'
249*7dc08ffcSJunyu Lai
250*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Instantiation with specific values (1)
251*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart(restart_time = 120, entries = [BGPCapGracefulRestart.GRTuple(afi = 1, safi = 1)])) == b'@\x06\x00x\x00\x01\x01\x00'
252*7dc08ffcSJunyu Lai
253*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Instantiation with specific values (2)
254*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart(restart_time = 120, entries = [BGPCapGracefulRestart.GRTuple(afi = 1, safi = 1)])) == b'@\x06\x00x\x00\x01\x01\x00'
255*7dc08ffcSJunyu Lai
256*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Instantiation with specific values (3)
257*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart(restart_time = 120, entries = [BGPCapGracefulRestart.GRTuple(afi = 1, safi = 1, flags = 128)])) == b'@\x06\x00x\x00\x01\x01\x80'
258*7dc08ffcSJunyu Lai
259*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Instantiation with specific values (4)
260*7dc08ffcSJunyu Lairaw(BGPCapGracefulRestart(restart_time = 120, restart_flags = 0x8, entries = [BGPCapGracefulRestart.GRTuple(afi = 1, safi = 1, flags = 128)])) == b'@\x06\x80x\x00\x01\x01\x80'
261*7dc08ffcSJunyu Lai
262*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Basic dissection
263*7dc08ffcSJunyu Laic = BGPCapGracefulRestart(b'@\x02\x00\x00')
264*7dc08ffcSJunyu Laic.code == 64 and c.restart_flags == 0 and c.restart_time == 0
265*7dc08ffcSJunyu Lai
266*7dc08ffcSJunyu Lai= BGPCapGracefulRestart - Dissection with specific values
267*7dc08ffcSJunyu Laic = BGPCapGracefulRestart(b'@\x06\x80x\x00\x01\x01\x80')
268*7dc08ffcSJunyu Laic.code == 64 and c.restart_time == 120 and c.restart_flags == 0x8 and c.entries[0].afi == 1 and c.entries[0].safi == 1 and c.entries[0].flags == 128
269*7dc08ffcSJunyu Lai
270*7dc08ffcSJunyu Lai
271*7dc08ffcSJunyu Lai############################ BGPCapFourBytesASN ###############################
272*7dc08ffcSJunyu Lai+ BGPCapFourBytesASN class tests
273*7dc08ffcSJunyu Lai
274*7dc08ffcSJunyu Lai= BGPCapFourBytesASN - Inheritance
275*7dc08ffcSJunyu Laic = BGPCapFourBytesASN()
276*7dc08ffcSJunyu Laiassert(isinstance(c, BGPCapFourBytesASN))
277*7dc08ffcSJunyu Lai
278*7dc08ffcSJunyu Lai= BGPCapFourBytesASN - Instantiation
279*7dc08ffcSJunyu Lairaw(BGPCapFourBytesASN()) == b'A\x04\x00\x00\x00\x00'
280*7dc08ffcSJunyu Lai
281*7dc08ffcSJunyu Lai= BGPCapFourBytesASN - Instantiation with specific values (1)
282*7dc08ffcSJunyu Lairaw(BGPCapFourBytesASN(asn = 6555555)) == b'A\x04\x00d\x07\xa3'
283*7dc08ffcSJunyu Lai
284*7dc08ffcSJunyu Lai= BGPCapFourBytesASN - Instantiation with specific values (2)
285*7dc08ffcSJunyu Lairaw(BGPCapFourBytesASN(asn = 4294967295)) == b'A\x04\xff\xff\xff\xff'
286*7dc08ffcSJunyu Lai
287*7dc08ffcSJunyu Lai= BGPCapFourBytesASN - Basic dissection
288*7dc08ffcSJunyu Laic = BGPCapFourBytesASN(b'A\x04\x00\x00\x00\x00')
289*7dc08ffcSJunyu Laic.code == 65 and c.length == 4 and c.asn == 0
290*7dc08ffcSJunyu Lai
291*7dc08ffcSJunyu Lai= BGPCapFourBytesASN - Dissection with specific values
292*7dc08ffcSJunyu Laic = BGPCapFourBytesASN(b'A\x04\xff\xff\xff\xff')
293*7dc08ffcSJunyu Laic.code == 65 and c.length == 4 and c.asn == 4294967295
294*7dc08ffcSJunyu Lai
295*7dc08ffcSJunyu Lai
296*7dc08ffcSJunyu Lai####################### BGPAuthenticationInformation ##########################
297*7dc08ffcSJunyu Lai+ BGPAuthenticationInformation class tests
298*7dc08ffcSJunyu Lai
299*7dc08ffcSJunyu Lai= BGPAuthenticationInformation - Instantiation
300*7dc08ffcSJunyu Lairaw(BGPAuthenticationInformation()) == b'\x00'
301*7dc08ffcSJunyu Lai
302*7dc08ffcSJunyu Lai= BGPAuthenticationInformation - Basic dissection
303*7dc08ffcSJunyu Laic = BGPAuthenticationInformation(b'\x00')
304*7dc08ffcSJunyu Laic.authentication_code == 0 and c.authentication_data == None
305*7dc08ffcSJunyu Lai
306*7dc08ffcSJunyu Lai
307*7dc08ffcSJunyu Lai################################# BGPOptParam #################################
308*7dc08ffcSJunyu Lai+ BGPOptParam class tests
309*7dc08ffcSJunyu Lai
310*7dc08ffcSJunyu Lai= BGPOptParam - Instantiation
311*7dc08ffcSJunyu Lairaw(BGPOptParam()) == b'\x02\x00'
312*7dc08ffcSJunyu Lai
313*7dc08ffcSJunyu Lai= BGPOptParam - Instantiation with specific values (1)
314*7dc08ffcSJunyu Lairaw(BGPOptParam(param_type = 1)) == b'\x01\x00'
315*7dc08ffcSJunyu Lairaw(BGPOptParam(param_type = 1, param_value = BGPAuthenticationInformation())) == b'\x01\x00'
316*7dc08ffcSJunyu Lai
317*7dc08ffcSJunyu Lai= BGPOptParam - Instantiation with specific values (2)
318*7dc08ffcSJunyu Lairaw(BGPOptParam(param_type = 2)) == b'\x02\x00'
319*7dc08ffcSJunyu Lai
320*7dc08ffcSJunyu Lai= BGPOptParam - Instantiation with specific values (3)
321*7dc08ffcSJunyu Lairaw(BGPOptParam(param_type = 2, param_value = BGPCapFourBytesASN(asn = 4294967295))) == b'\x02\x06A\x04\xff\xff\xff\xff'
322*7dc08ffcSJunyu Lai
323*7dc08ffcSJunyu Lai= BGPOptParam - Instantiation with specific values (4)
324*7dc08ffcSJunyu Lairaw(BGPOptParam(param_type = 2, param_value = BGPCapability(code = 127))) == b'\x02\x02\x7f\x00'
325*7dc08ffcSJunyu Lai
326*7dc08ffcSJunyu Lai= BGPOptParam - Instantiation with specific values (5)
327*7dc08ffcSJunyu Lairaw(BGPOptParam(param_type = 2, param_value = BGPCapability(code = 255))) == b'\x02\x02\xff\x00'
328*7dc08ffcSJunyu Lai
329*7dc08ffcSJunyu Lai= BGPOptParam - Basic dissection
330*7dc08ffcSJunyu Laip = BGPOptParam(b'\x02\x00')
331*7dc08ffcSJunyu Laip.param_type == 2 and p.param_length == 0
332*7dc08ffcSJunyu Lai
333*7dc08ffcSJunyu Lai= BGPOptParam - Dissection with specific values
334*7dc08ffcSJunyu Laip = BGPOptParam(b'\x02\x06A\x04\xff\xff\xff\xff')
335*7dc08ffcSJunyu Laip.param_type == 2 and p.param_length == 6 and p.param_value[0].code == 65 and p.param_value[0].length == 4 and p.param_value[0].asn == 4294967295
336*7dc08ffcSJunyu Lai
337*7dc08ffcSJunyu Lai
338*7dc08ffcSJunyu Lai################################### BGPOpen ###################################
339*7dc08ffcSJunyu Lai+ BGPOpen class tests
340*7dc08ffcSJunyu Lai
341*7dc08ffcSJunyu Lai= BGPOpen - Instantiation
342*7dc08ffcSJunyu Lairaw(BGPOpen()) == b'\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00'
343*7dc08ffcSJunyu Lai
344*7dc08ffcSJunyu Lai= BGPOpen - Instantiation with specific values (1)
345*7dc08ffcSJunyu Lairaw(BGPOpen(my_as = 64501, bgp_id = "192.0.2.1")) == b'\x04\xfb\xf5\x00\x00\xc0\x00\x02\x01\x00'
346*7dc08ffcSJunyu Lai
347*7dc08ffcSJunyu Lai= BGPOpen - Instantiation with specific values (2)
348*7dc08ffcSJunyu Laiopt = BGPOptParam(param_value = BGPCapMultiprotocol(afi = 1, safi = 1))
349*7dc08ffcSJunyu Lairaw(BGPOpen(my_as = 64501, bgp_id = "192.0.2.1", opt_params = [opt])) == b'\x04\xfb\xf5\x00\x00\xc0\x00\x02\x01\x08\x02\x06\x01\x04\x00\x01\x00\x01'
350*7dc08ffcSJunyu Lai
351*7dc08ffcSJunyu Lai= BGPOpen - Instantiation with specific values (3)
352*7dc08ffcSJunyu Laicap = BGPOptParam(param_value = BGPCapMultiprotocol(afi = 1, safi = 1))
353*7dc08ffcSJunyu Laicapabilities = [cap]
354*7dc08ffcSJunyu Laicap = BGPOptParam(param_value = BGPCapability(code = 128))
355*7dc08ffcSJunyu Laicapabilities.append(cap)
356*7dc08ffcSJunyu Laicap = BGPOptParam(param_value = BGPCapability(code = 2))
357*7dc08ffcSJunyu Laicapabilities.append(cap)
358*7dc08ffcSJunyu Laicap = BGPOptParam(param_value = BGPCapGracefulRestart(restart_time = 120, entries = [BGPCapGracefulRestart.GRTuple(afi = 1, safi= 1, flags = 128)]))
359*7dc08ffcSJunyu Laicapabilities.append(cap)
360*7dc08ffcSJunyu Laicap = BGPOptParam(param_value = BGPCapFourBytesASN(asn = 64503))
361*7dc08ffcSJunyu Laicapabilities.append(cap)
362*7dc08ffcSJunyu Lairaw(BGPOpen(my_as = 64503, bgp_id = "192.168.100.3", hold_time = 30, opt_params = capabilities)) == b'\x04\xfb\xf7\x00\x1e\xc0\xa8d\x03"\x02\x06\x01\x04\x00\x01\x00\x01\x02\x02\x80\x00\x02\x02\x02\x00\x02\x08@\x06\x00x\x00\x01\x01\x80\x02\x06A\x04\x00\x00\xfb\xf7'
363*7dc08ffcSJunyu Lai
364*7dc08ffcSJunyu Lai= BGPOpen - Dissection with specific values (1)
365*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00?\x01\x04\xfb\xf7\x00\x1e\xc0\xa8d\x03"\x02\x06\x01\x04\x00\x01\x00\x01\x02\x02\x80\x00\x02\x02\x02\x00\x02\x08@\x06\x00x\x00\x01\x01\x80\x02\x06A\x04\x00\x00\xfb\xf7')
366*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPOpen in m)
367*7dc08ffcSJunyu Laiassert(m.len == 63)
368*7dc08ffcSJunyu Laiassert(m.type == BGP.OPEN_TYPE)
369*7dc08ffcSJunyu Laiassert(m.version == 4)
370*7dc08ffcSJunyu Laiassert(m.my_as == 64503)
371*7dc08ffcSJunyu Laiassert(m.hold_time == 30)
372*7dc08ffcSJunyu Laiassert(m.bgp_id == "192.168.100.3")
373*7dc08ffcSJunyu Laiassert(m.opt_param_len == 34)
374*7dc08ffcSJunyu Laiassert(isinstance(m.opt_params[0].param_value, BGPCapMultiprotocol))
375*7dc08ffcSJunyu Laiassert(isinstance(m.opt_params[1].param_value, BGPCapability))
376*7dc08ffcSJunyu Laiassert(isinstance(m.opt_params[2].param_value, BGPCapability))
377*7dc08ffcSJunyu Laiassert(isinstance(m.opt_params[3].param_value, BGPCapGracefulRestart))
378*7dc08ffcSJunyu Lai
379*7dc08ffcSJunyu Lai= BGPOpen - Dissection with specific values (2) (followed by a KEEPALIVE)
380*7dc08ffcSJunyu Laimessages = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00=\x01\x04\xfb\xf6\x00\xb4\xc0\xa8ze \x02\x06\x01\x04\x00\x01\x00\x01\x02\x06\x01\x04\x00\x02\x00\x01\x02\x02\x80\x00\x02\x02\x02\x00\x02\x06A\x04\x00\x00\xfb\xf6\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04'
381*7dc08ffcSJunyu Laim = BGP(messages)
382*7dc08ffcSJunyu Lairaw(m) == b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00=\x01\x04\xfb\xf6\x00\xb4\xc0\xa8ze \x02\x06\x01\x04\x00\x01\x00\x01\x02\x06\x01\x04\x00\x02\x00\x01\x02\x02\x80\x00\x02\x02\x02\x00\x02\x06A\x04\x00\x00\xfb\xf6\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x13\x04'
383*7dc08ffcSJunyu Lai
384*7dc08ffcSJunyu Lai= BGPOpen - Dissection with specific values (3)
385*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x8f\x01\x04\xfd\xe8\x00\xb4\n\xff\xff\x01r\x02\x06\x01\x04\x00\x01\x00\x84\x02\x06\x01\x04\x00\x19\x00A\x02\x06\x01\x04\x00\x02\x00\x02\x02\x06\x01\x04\x00\x01\x00\x02\x02\x06\x01\x04\x00\x02\x00\x80\x02\x06\x01\x04\x00\x01\x00\x80\x02\x06\x01\x04\x00\x01\x00B\x02\x06\x01\x04\x00\x02\x00\x01\x02\x06\x01\x04\x00\x02\x00\x04\x02\x06\x01\x04\x00\x01\x00\x01\x02\x06\x01\x04\x00\x01\x00\x04\x02\x02\x80\x00\x02\x02\x02\x00\x02\x04@\x02\x80x\x02\x02F\x00\x02\x06A\x04\x00\x00\xfd\xe8')
386*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPOpen in m)
387*7dc08ffcSJunyu Lai
388*7dc08ffcSJunyu Lai= BGPOpen - Dissection with specific values (4)
389*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x8f\x01\x04\xfd\xe8\x00\xb4\n\xff\xff\x02r\x02\x06\x01\x04\x00\x01\x00\x84\x02\x06\x01\x04\x00\x19\x00A\x02\x06\x01\x04\x00\x02\x00\x02\x02\x06\x01\x04\x00\x01\x00\x02\x02\x06\x01\x04\x00\x02\x00\x80\x02\x06\x01\x04\x00\x01\x00\x80\x02\x06\x01\x04\x00\x01\x00B\x02\x06\x01\x04\x00\x02\x00\x01\x02\x06\x01\x04\x00\x02\x00\x04\x02\x06\x01\x04\x00\x01\x00\x01\x02\x06\x01\x04\x00\x01\x00\x04\x02\x02\x80\x00\x02\x02\x02\x00\x02\x04@\x02\x00x\x02\x02F\x00\x02\x06A\x04\x00\x00\xfd\xe8')
390*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPOpen in m)
391*7dc08ffcSJunyu Lai
392*7dc08ffcSJunyu Lai
393*7dc08ffcSJunyu Lai################################# BGPPAOrigin #################################
394*7dc08ffcSJunyu Lai+ BGPPAOrigin class tests
395*7dc08ffcSJunyu Lai
396*7dc08ffcSJunyu Lai= BGPPAOrigin - Instantiation
397*7dc08ffcSJunyu Lairaw(BGPPAOrigin()) == b'\x00'
398*7dc08ffcSJunyu Lai
399*7dc08ffcSJunyu Lai= BGPPAOrigin - Instantiation with specific values
400*7dc08ffcSJunyu Lairaw(BGPPAOrigin(origin = 1)) == b'\x01'
401*7dc08ffcSJunyu Lai
402*7dc08ffcSJunyu Lai= BGPPAOrigin - Dissection
403*7dc08ffcSJunyu Laia = BGPPAOrigin(b'\x00')
404*7dc08ffcSJunyu Laia.origin == 0
405*7dc08ffcSJunyu Lai
406*7dc08ffcSJunyu Lai
407*7dc08ffcSJunyu Lai################################ BGPPAASPath ##################################
408*7dc08ffcSJunyu Lai+ BGPPAASPath class tests
409*7dc08ffcSJunyu Lai
410*7dc08ffcSJunyu Lai= BGPPAASPath - Instantiation
411*7dc08ffcSJunyu Lairaw(BGPPAASPath()) == b''
412*7dc08ffcSJunyu Lai
413*7dc08ffcSJunyu Lai= BGPPAASPath - Instantiation with specific values (1)
414*7dc08ffcSJunyu Lairaw(BGPPAASPath(segments = [BGPPAASPath.ASPathSegment(segment_type = 2, segment_value = [64496, 64497, 64498])])) == b'\x02\x03\xfb\xf0\xfb\xf1\xfb\xf2'
415*7dc08ffcSJunyu Lai
416*7dc08ffcSJunyu Lai= BGPPAASPath - Instantiation with specific values (2)
417*7dc08ffcSJunyu Lairaw(BGPPAASPath(segments = [BGPPAASPath.ASPathSegment(segment_type = 1, segment_value = [64496, 64497, 64498])])) == b'\x01\x03\xfb\xf0\xfb\xf1\xfb\xf2'
418*7dc08ffcSJunyu Lai
419*7dc08ffcSJunyu Lai= BGPPAASPath - Instantiation with specific values (3)
420*7dc08ffcSJunyu Lairaw(BGPPAASPath(segments = [BGPPAASPath.ASPathSegment(segment_type = 1, segment_value = [64496, 64497, 64498]), BGPPAASPath.ASPathSegment(segment_type = 2, segment_value = [64500, 64501, 64502, 64502, 64503])])) == b'\x01\x03\xfb\xf0\xfb\xf1\xfb\xf2\x02\x05\xfb\xf4\xfb\xf5\xfb\xf6\xfb\xf6\xfb\xf7'
421*7dc08ffcSJunyu Lai
422*7dc08ffcSJunyu Lai= BGPPAASPath - Dissection (1)
423*7dc08ffcSJunyu Laia = BGPPAASPath(b'\x02\x03\xfb\xf0\xfb\xf1\xfb\xf2')
424*7dc08ffcSJunyu Laia.segments[0].segment_type == 2 and a.segments[0].segment_length == 3 and a.segments[0].segment_value == [64496, 64497, 64498]
425*7dc08ffcSJunyu Lai
426*7dc08ffcSJunyu Lai= BGPPAASPath - Dissection (2)
427*7dc08ffcSJunyu Laia = BGPPAASPath(b'\x01\x03\xfb\xf0\xfb\xf1\xfb\xf2\x02\x05\xfb\xf4\xfb\xf5\xfb\xf6\xfb\xf6\xfb\xf7')
428*7dc08ffcSJunyu Laia.segments[0].segment_type == 1 and a.segments[0].segment_length == 3 and a.segments[0].segment_value == [64496, 64497, 64498] and a.segments[1].segment_type == 2 and a.segments[1].segment_length == 5 and a.segments[1].segment_value == [64500, 64501, 64502, 64502, 64503]
429*7dc08ffcSJunyu Lai
430*7dc08ffcSJunyu Lai
431*7dc08ffcSJunyu Lai############################### BGPPANextHop ##################################
432*7dc08ffcSJunyu Lai+ BGPPANextHop class tests
433*7dc08ffcSJunyu Lai
434*7dc08ffcSJunyu Lai= BGPPANextHop - Instantiation
435*7dc08ffcSJunyu Lairaw(BGPPANextHop()) == b'\x00\x00\x00\x00'
436*7dc08ffcSJunyu Lai
437*7dc08ffcSJunyu Lai= BGPPANextHop - Instantiation with specific values
438*7dc08ffcSJunyu Lairaw(BGPPANextHop(next_hop = "192.0.2.1")) == b'\xc0\x00\x02\x01'
439*7dc08ffcSJunyu Lai
440*7dc08ffcSJunyu Lai= BGPPANextHop - Basic dissection
441*7dc08ffcSJunyu Laia = BGPPANextHop(b'\x00\x00\x00\x00')
442*7dc08ffcSJunyu Laia.next_hop == "0.0.0.0"
443*7dc08ffcSJunyu Lai
444*7dc08ffcSJunyu Lai= BGPPANextHop - Dissection with specific values
445*7dc08ffcSJunyu Laia = BGPPANextHop(b'\xc0\x00\x02\x01')
446*7dc08ffcSJunyu Laia.next_hop == '192.0.2.1'
447*7dc08ffcSJunyu Lai
448*7dc08ffcSJunyu Lai
449*7dc08ffcSJunyu Lai############################ BGPPAMultiExitDisc ##############################
450*7dc08ffcSJunyu Lai+ BGPPAMultiExitDisc class tests
451*7dc08ffcSJunyu Lai
452*7dc08ffcSJunyu Lai= BGPPAMultiExitDisc - Instantiation
453*7dc08ffcSJunyu Lairaw(BGPPAMultiExitDisc()) == b'\x00\x00\x00\x00'
454*7dc08ffcSJunyu Lai
455*7dc08ffcSJunyu Lai= BGPPAMultiExitDisc - Instantiation with specific values (1)
456*7dc08ffcSJunyu Lairaw(BGPPAMultiExitDisc(med = 4)) == b'\x00\x00\x00\x04'
457*7dc08ffcSJunyu Lai
458*7dc08ffcSJunyu Lai= BGPPAMultiExitDisc - Basic dissection
459*7dc08ffcSJunyu Laia = BGPPAMultiExitDisc(b'\x00\x00\x00\x00')
460*7dc08ffcSJunyu Laia.med == 0
461*7dc08ffcSJunyu Lai
462*7dc08ffcSJunyu Lai
463*7dc08ffcSJunyu Lai############################## BGPPALocalPref ################################
464*7dc08ffcSJunyu Lai+ BGPPALocalPref class tests
465*7dc08ffcSJunyu Lai
466*7dc08ffcSJunyu Lai= BGPPALocalPref - Instantiation
467*7dc08ffcSJunyu Lairaw(BGPPALocalPref()) == b'\x00\x00\x00\x00'
468*7dc08ffcSJunyu Lai
469*7dc08ffcSJunyu Lai= BGPPALocalPref - Instantiation with specific values (1)
470*7dc08ffcSJunyu Lairaw(BGPPALocalPref(local_pref = 110)) == b'\x00\x00\x00n'
471*7dc08ffcSJunyu Lai
472*7dc08ffcSJunyu Lai= BGPPALocalPref - Basic dissection
473*7dc08ffcSJunyu Laia = BGPPALocalPref(b'\x00\x00\x00n')
474*7dc08ffcSJunyu Laia.local_pref == 110
475*7dc08ffcSJunyu Lai
476*7dc08ffcSJunyu Lai
477*7dc08ffcSJunyu Lai############################## BGPPAAggregator ###############################
478*7dc08ffcSJunyu Lai+ BGPPAAggregator class tests
479*7dc08ffcSJunyu Lai
480*7dc08ffcSJunyu Lai= BGPPAAggregator - Instantiation
481*7dc08ffcSJunyu Lairaw(BGPPAAggregator()) == b'\x00\x00\x00\x00\x00\x00'
482*7dc08ffcSJunyu Lai
483*7dc08ffcSJunyu Lai= BGPPAAggregator - Instantiation with specific values (1)
484*7dc08ffcSJunyu Lairaw(BGPPAAggregator(aggregator_asn = 64500, speaker_address = "192.0.2.1")) == b'\xfb\xf4\xc0\x00\x02\x01'
485*7dc08ffcSJunyu Lai
486*7dc08ffcSJunyu Lai= BGPPAAggregator - Dissection
487*7dc08ffcSJunyu Laia = BGPPAAggregator(b'\xfb\xf4\xc0\x00\x02\x01')
488*7dc08ffcSJunyu Laia.aggregator_asn == 64500 and a.speaker_address == "192.0.2.1"
489*7dc08ffcSJunyu Lai
490*7dc08ffcSJunyu Lai
491*7dc08ffcSJunyu Lai############################## BGPPACommunity ################################
492*7dc08ffcSJunyu Lai+ BGPPACommunity class tests
493*7dc08ffcSJunyu Lai
494*7dc08ffcSJunyu Lai= BGPPACommunity - Basic instantiation
495*7dc08ffcSJunyu Lairaw(BGPPACommunity()) == b'\x00\x00\x00\x00'
496*7dc08ffcSJunyu Lai
497*7dc08ffcSJunyu Lai= BGPPACommunity - Instantiation with specific value
498*7dc08ffcSJunyu Lairaw(BGPPACommunity(community = 0xFFFFFF01)) == b'\xff\xff\xff\x01'
499*7dc08ffcSJunyu Lai
500*7dc08ffcSJunyu Lai= BGPPACommunity - Dissection
501*7dc08ffcSJunyu Laia = BGPPACommunity(b'\xff\xff\xff\x01')
502*7dc08ffcSJunyu Laia.community == 0xFFFFFF01
503*7dc08ffcSJunyu Lai
504*7dc08ffcSJunyu Lai
505*7dc08ffcSJunyu Lai############################ BGPPAOriginatorID ###############################
506*7dc08ffcSJunyu Lai+ BGPPAOriginatorID class tests
507*7dc08ffcSJunyu Lai
508*7dc08ffcSJunyu Lai= BGPPAOriginatorID - Basic instantiation
509*7dc08ffcSJunyu Lairaw(BGPPAOriginatorID()) == b'\x00\x00\x00\x00'
510*7dc08ffcSJunyu Lai
511*7dc08ffcSJunyu Lai= BGPPAOriginatorID - Instantiation with specific value
512*7dc08ffcSJunyu Lairaw(BGPPAOriginatorID(originator_id = '192.0.2.1')) == b'\xc0\x00\x02\x01'
513*7dc08ffcSJunyu Lai
514*7dc08ffcSJunyu Lai= BGPPAOriginatorID - Dissection
515*7dc08ffcSJunyu Laia = BGPPAOriginatorID(b'\xc0\x00\x02\x01')
516*7dc08ffcSJunyu Laia.originator_id == "192.0.2.1"
517*7dc08ffcSJunyu Lai
518*7dc08ffcSJunyu Lai
519*7dc08ffcSJunyu Lai############################ BGPPAClusterList ################################
520*7dc08ffcSJunyu Lai+ BGPPAClusterList class tests
521*7dc08ffcSJunyu Lai
522*7dc08ffcSJunyu Lai= BGPPAClusterList - Basic instantiation
523*7dc08ffcSJunyu Lairaw(BGPPAClusterList()) == b''
524*7dc08ffcSJunyu Lai
525*7dc08ffcSJunyu Lai= BGPPAClusterList - Instantiation with specific values
526*7dc08ffcSJunyu Lairaw(BGPPAClusterList(cluster_list = [150000, 165465465, 132132])) == b'\x00\x02I\xf0\t\xdc\xcdy\x00\x02\x04$'
527*7dc08ffcSJunyu Lai
528*7dc08ffcSJunyu Lai= BGPPAClusterList - Dissection
529*7dc08ffcSJunyu Laia = BGPPAClusterList(b'\x00\x02I\xf0\t\xdc\xcdy\x00\x02\x04$')
530*7dc08ffcSJunyu Laia.cluster_list[0] == 150000 and a.cluster_list[1] == 165465465 and a.cluster_list[2] == 132132
531*7dc08ffcSJunyu Lai
532*7dc08ffcSJunyu Lai
533*7dc08ffcSJunyu Lai########################### BGPPAMPReachNLRI  ###############################
534*7dc08ffcSJunyu Lai+ BGPPAMPReachNLRI class tests
535*7dc08ffcSJunyu Lai
536*7dc08ffcSJunyu Lai= BGPPAMPReachNLRI - Instantiation
537*7dc08ffcSJunyu Lairaw(BGPPAMPReachNLRI()) == b'\x00\x00\x00\x00\x00'
538*7dc08ffcSJunyu Lai
539*7dc08ffcSJunyu Lai= BGPPAMPReachNLRI - Instantiation with specific values (1)
540*7dc08ffcSJunyu Lairaw(BGPPAMPReachNLRI(afi=2, safi=1, nh_addr_len=16, nh_v6_addr = "2001:db8::2", nlri = [BGPNLRI_IPv6(prefix = "2001:db8:2::/64")])) == b'\x00\x02\x01\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00@ \x01\r\xb8\x00\x02\x00\x00'
541*7dc08ffcSJunyu Lai
542*7dc08ffcSJunyu Lai= BGPPAMPReachNLRI - Dissection (1)
543*7dc08ffcSJunyu Laia = BGPPAMPReachNLRI(b'\x00\x02\x01  \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xfe\x80\x00\x00\x00\x00\x00\x00\xc0\x02\x0b\xff\xfe~\x00\x00\x00@ \x01\r\xb8\x00\x02\x00\x02@ \x01\r\xb8\x00\x02\x00\x01@ \x01\r\xb8\x00\x02\x00\x00')
544*7dc08ffcSJunyu Laia.afi == 2 and a.safi == 1 and a.nh_addr_len == 32 and a.nh_v6_global == "2001:db8::2" and a.nh_v6_link_local == "fe80::c002:bff:fe7e:0" and a.reserved == 0 and a.nlri[0].prefix == "2001:db8:2:2::/64" and a.nlri[1].prefix == "2001:db8:2:1::/64" and a.nlri[2].prefix == "2001:db8:2::/64"
545*7dc08ffcSJunyu Lai
546*7dc08ffcSJunyu Lai= BGPPAMPReachNLRI - Dissection (2)
547*7dc08ffcSJunyu Laia = BGPPAMPReachNLRI(b'\x00\x02\x01 \xfe\x80\x00\x00\x00\x00\x00\x00\xfa\xc0\x01\x00\x15\xde\x15\x81\xfe\x80\x00\x00\x00\x00\x00\x00\xfa\xc0\x01\x00\x15\xde\x15\x81\x00\x06\x04\x05\x08\x04\x10\x03`\x03\x80\x03\xa0\x03\xc0\x04\xe0\x05\xf0\x06\xf8\t\xfe\x00\x16 \x01<\x08-\x07.\x040\x10?\xfe\x10 \x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff@\x01\x00\x00\x00\x00\x00\x00\x00\x17 \x01\x00  \x01\x00\x000 \x01\x00\x02\x00\x00  \x01\r\xb8\x1c \x01\x00\x10\x07\xfc\n\xfe\x80\x08\xff\n\xfe\xc0\x03 \x03@\x08_`\x00d\xff\x9b\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x08\x01\x07\x02')
548*7dc08ffcSJunyu Laia.afi == 2 and a.safi == 1 and a.nh_addr_len == 32 and a.nh_v6_global == "fe80::fac0:100:15de:1581" and a.nh_v6_link_local == "fe80::fac0:100:15de:1581" and a.reserved == 0 and a.nlri[0].prefix == "400::/6" and a.nlri[1].prefix == "800::/5" and  raw(a.nlri[18]) == b'`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff' and a.nlri[35].prefix == "200::/7"
549*7dc08ffcSJunyu Lai
550*7dc08ffcSJunyu Lai
551*7dc08ffcSJunyu Lai############################# BGPPAMPUnreachNLRI #############################
552*7dc08ffcSJunyu Lai+ BGPPAMPUnreachNLRI class tests
553*7dc08ffcSJunyu Lai
554*7dc08ffcSJunyu Lai= BGPPAMPUnreachNLRI - Instantiation
555*7dc08ffcSJunyu Lairaw(BGPPAMPUnreachNLRI()) == b'\x00\x00\x00'
556*7dc08ffcSJunyu Lai
557*7dc08ffcSJunyu Lai= BGPPAMPUnreachNLRI - Instantiation with specific values (1)
558*7dc08ffcSJunyu Lairaw(BGPPAMPUnreachNLRI(afi = 2, safi = 1)) == b'\x00\x02\x01'
559*7dc08ffcSJunyu Lai
560*7dc08ffcSJunyu Lai= BGPPAMPUnreachNLRI - Instantiation with specific values (2)
561*7dc08ffcSJunyu Lairaw(BGPPAMPUnreachNLRI(afi = 2, safi = 1, afi_safi_specific = BGPPAMPUnreachNLRI_IPv6(withdrawn_routes = [BGPNLRI_IPv6(prefix = "2001:db8:2::/64")]))) == b'\x00\x02\x01@ \x01\r\xb8\x00\x02\x00\x00'
562*7dc08ffcSJunyu Lai
563*7dc08ffcSJunyu Lai= BGPPAMPUnreachNLRI - Dissection (1)
564*7dc08ffcSJunyu Laia = BGPPAMPUnreachNLRI(b'\x00\x02\x01')
565*7dc08ffcSJunyu Laia.afi == 2 and a.safi == 1
566*7dc08ffcSJunyu Lai
567*7dc08ffcSJunyu Lai= BGPPAMPUnreachNLRI - Dissection (2)
568*7dc08ffcSJunyu Laia = BGPPAMPUnreachNLRI(b'\x00\x02\x01\x03`\x03\x80\x03\xa0\x03\xc0\x04\xe0\x05\xf0\x06\xf8\x10 \x02`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff@\x01\x00\x00\x00\x00\x00\x00\x00\x17 \x01\x00  \x01\x00\x000 \x01\x00\x02\x00\x00  \x01\r\xb8\n\xfe\xc0\x07\xfc\n\xfe\x80\x1c \x01\x00\x10\x03 \x06\x04\x03@\x08_\x05\x08\x04\x10')
569*7dc08ffcSJunyu Laia.afi == 2 and a.safi == 1 and a.afi_safi_specific.withdrawn_routes[0].prefix == "6000::/3" and a.afi_safi_specific.withdrawn_routes[11].prefix == "2001::/32" and a.afi_safi_specific.withdrawn_routes[23].prefix == "1000::/4"
570*7dc08ffcSJunyu Lai
571*7dc08ffcSJunyu Lai
572*7dc08ffcSJunyu Lai############################# BGPPAAS4Aggregator #############################
573*7dc08ffcSJunyu Lai+ BGPPAAS4Aggregator class tests
574*7dc08ffcSJunyu Lai
575*7dc08ffcSJunyu Lai= BGPPAAS4Aggregator - Instantiation
576*7dc08ffcSJunyu Lairaw(BGPPAAS4Aggregator()) == b'\x00\x00\x00\x00\x00\x00\x00\x00'
577*7dc08ffcSJunyu Lai
578*7dc08ffcSJunyu Lai= BGPPAAS4Aggregator - Instantiation with specific values
579*7dc08ffcSJunyu Lairaw(BGPPAAS4Aggregator(aggregator_asn = 644566565, speaker_address = "192.0.2.1")) == b'&kN%\xc0\x00\x02\x01'
580*7dc08ffcSJunyu Lai
581*7dc08ffcSJunyu Lai= BGPPAAS4Aggregator - Dissection
582*7dc08ffcSJunyu Laia = BGPPAAS4Aggregator(b'&kN%\xc0\x00\x02\x01')
583*7dc08ffcSJunyu Laia.aggregator_asn == 644566565 and a.speaker_address == "192.0.2.1"
584*7dc08ffcSJunyu Lai
585*7dc08ffcSJunyu Lai
586*7dc08ffcSJunyu Lai################################ BGPPathAttr #################################
587*7dc08ffcSJunyu Lai+ BGPPathAttr class tests
588*7dc08ffcSJunyu Lai
589*7dc08ffcSJunyu Lai= BGPPathAttr - Instantiation
590*7dc08ffcSJunyu Lairaw(BGPPathAttr()) == b'\x80\x00\x00'
591*7dc08ffcSJunyu Lai
592*7dc08ffcSJunyu Lai= BGPPathAttr - Instantiation with specific values (1)
593*7dc08ffcSJunyu Lairaw(BGPPathAttr(type_code = 1, attribute = BGPPAOrigin(origin = 0)))
594*7dc08ffcSJunyu Lai
595*7dc08ffcSJunyu Lai= BGPPathAttr - Instantiation with specific values (2)
596*7dc08ffcSJunyu Lairaw(BGPPathAttr(type_code = 2, attribute = BGPPAASPath(segments = [BGPPAASPath.ASPathSegment(segment_type = 2, segment_value = [64501, 64501, 64501])]))) == b'\x80\x02\x08\x02\x03\xfb\xf5\xfb\xf5\xfb\xf5'
597*7dc08ffcSJunyu Lai
598*7dc08ffcSJunyu Lai= BGPPathAttr - Instantiation with specific values (3)
599*7dc08ffcSJunyu Lai
600*7dc08ffcSJunyu Lairaw(BGPPathAttr(type_code = 14, attribute = BGPPAMPReachNLRI(afi = 2, safi = 1, nh_addr_len = 16, nh_v6_addr = "2001:db8::2", nlri = [BGPNLRI_IPv6(prefix = "2001:db8:2::/64")]))) == b'\x80\x0e\x1e\x00\x02\x01\x10 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00@ \x01\r\xb8\x00\x02\x00\x00'
601*7dc08ffcSJunyu Lai
602*7dc08ffcSJunyu Lai= BGPPathAttr - Dissection (1)
603*7dc08ffcSJunyu Laia = BGPPathAttr(b'\x90\x0f\x00X\x00\x02\x01\x03`\x03\x80\x03\xa0\x03\xc0\x04\xe0\x05\xf0\x06\xf8\x10 \x02`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff@\x01\x00\x00\x00\x00\x00\x00\x00\x17 \x01\x00  \x01\x00\x000 \x01\x00\x02\x00\x00  \x01\r\xb8\n\xfe\xc0\x07\xfc\n\xfe\x80\x1c \x01\x00\x10\x03 \x06\x04\x03@\x08_\x05\x08\x04\x10')
604*7dc08ffcSJunyu Laia.type_flags == 0x90 and a.type_code == 15 and a.attr_ext_len == 88 and a.attribute.afi == 2 and a.attribute.safi == 1 and a.attribute.afi_safi_specific.withdrawn_routes[0].prefix == "6000::/3" and a.attribute.afi_safi_specific.withdrawn_routes[1].prefix == "8000::/3" and a.attribute.afi_safi_specific.withdrawn_routes[2].prefix == "a000::/3" and a.attribute.afi_safi_specific.withdrawn_routes[3].prefix == "c000::/3" and a.attribute.afi_safi_specific.withdrawn_routes[4].prefix == "e000::/4" and a.attribute.afi_safi_specific.withdrawn_routes[5].prefix == "f000::/5" and a.attribute.afi_safi_specific.withdrawn_routes[23].prefix == "1000::/4"
605*7dc08ffcSJunyu Lai
606*7dc08ffcSJunyu Lai
607*7dc08ffcSJunyu Lai################################# BGPUpdate ##################################
608*7dc08ffcSJunyu Lai+ BGPUpdate class tests
609*7dc08ffcSJunyu Lai
610*7dc08ffcSJunyu Lai= BGPUpdate - Instantiation
611*7dc08ffcSJunyu Lairaw(BGPUpdate()) == b'\x00\x00\x00\x00'
612*7dc08ffcSJunyu Lai
613*7dc08ffcSJunyu Lai= BGPUpdate - Dissection (1)
614*7dc08ffcSJunyu Laibgp_module_conf.use_2_bytes_asn = True
615*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x000\x02\x00\x19\x18\xc0\xa8\x96\x18\x07\x07\x07\x18\xc63d\x18\xc0\xa8\x01\x19\x06\x06\x06\x00\x18\xc0\xa8\x1a\x00\x00')
616*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPUpdate in m)
617*7dc08ffcSJunyu Laiassert(m.withdrawn_routes_len == 25)
618*7dc08ffcSJunyu Laiassert(m.withdrawn_routes[0].prefix == "192.168.150.0/24")
619*7dc08ffcSJunyu Laiassert(m.withdrawn_routes[5].prefix == "192.168.26.0/24")
620*7dc08ffcSJunyu Laiassert(m.path_attr_len == 0)
621*7dc08ffcSJunyu Lai
622*7dc08ffcSJunyu Lai= BGPUpdate - Behave like a NEW speaker (RFC 6793) - Dissection (2)
623*7dc08ffcSJunyu Laibgp_module_conf.use_2_bytes_asn = False
624*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00=\x02\x00\x00\x00"@\x01\x01\x00@\x02\x06\x02\x01\x00\x00\xfb\xfa@\x03\x04\xc0\xa8\x10\x06\x80\x04\x04\x00\x00\x00\x00\xc0\x08\x04\xff\xff\xff\x01\x18\xc0\xa8\x01')
625*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPUpdate in m)
626*7dc08ffcSJunyu Laiassert(m.path_attr[1].attribute.segments[0].segment_value == [64506])
627*7dc08ffcSJunyu Laiassert(m.path_attr[4].attribute.community == 0xFFFFFF01)
628*7dc08ffcSJunyu Laiassert(m.nlri[0].prefix == "192.168.1.0/24")
629*7dc08ffcSJunyu Lai
630*7dc08ffcSJunyu Lai
631*7dc08ffcSJunyu Lai
632*7dc08ffcSJunyu Lai= BGPUpdate - Dissection (MP_REACH_NLRI)
633*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\xd8\x02\x00\x00\x00\xc1@\x01\x01\x00@\x02\x06\x02\x01\x00\x00\xfb\xf6\x90\x0e\x00\xb0\x00\x02\x01 \xfe\x80\x00\x00\x00\x00\x00\x00\xfa\xc0\x01\x00\x15\xde\x15\x81\xfe\x80\x00\x00\x00\x00\x00\x00\xfa\xc0\x01\x00\x15\xde\x15\x81\x00\x06\x04\x05\x08\x04\x10\x03`\x03\x80\x03\xa0\x03\xc0\x04\xe0\x05\xf0\x06\xf8\t\xfe\x00\x16 \x01<\x08-\x07.\x040\x10?\xfe\x10 \x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff@\x01\x00\x00\x00\x00\x00\x00\x00\x17 \x01\x00  \x01\x00\x000 \x01\x00\x02\x00\x00  \x01\r\xb8\x1c \x01\x00\x10\x07\xfc\n\xfe\x80\x08\xff\n\xfe\xc0\x03 \x03@\x08_`\x00d\xff\x9b\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x08\x01\x07\x02')
634*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPUpdate in m)
635*7dc08ffcSJunyu Laiassert(m.path_attr[2].attribute.afi == 2)
636*7dc08ffcSJunyu Laiassert(m.path_attr[2].attribute.safi == 1)
637*7dc08ffcSJunyu Laiassert(m.path_attr[2].attribute.nh_addr_len == 32)
638*7dc08ffcSJunyu Laiassert(m.path_attr[2].attribute.nh_v6_global == "fe80::fac0:100:15de:1581")
639*7dc08ffcSJunyu Laiassert(m.path_attr[2].attribute.nh_v6_link_local == "fe80::fac0:100:15de:1581")
640*7dc08ffcSJunyu Laiassert(m.path_attr[2].attribute.nlri[0].prefix == "400::/6")
641*7dc08ffcSJunyu Laiassert(m.nlri == [])
642*7dc08ffcSJunyu Lai
643*7dc08ffcSJunyu Lai= BGPUpdate - Dissection (MP_UNREACH_NLRI)
644*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00s\x02\x00\x00\x00\\\x90\x0f\x00X\x00\x02\x01\x03`\x03\x80\x03\xa0\x03\xc0\x04\xe0\x05\xf0\x06\xf8\x10 \x02`\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff@\x01\x00\x00\x00\x00\x00\x00\x00\x17 \x01\x00  \x01\x00\x000 \x01\x00\x02\x00\x00  \x01\r\xb8\n\xfe\xc0\x07\xfc\n\xfe\x80\x1c \x01\x00\x10\x03 \x06\x04\x03@\x08_\x05\x08\x04\x10')
645*7dc08ffcSJunyu Laiassert(BGPHeader in m and BGPUpdate in m)
646*7dc08ffcSJunyu Laiassert(m.path_attr[0].attribute.afi == 2)
647*7dc08ffcSJunyu Laiassert(m.path_attr[0].attribute.safi == 1)
648*7dc08ffcSJunyu Laiassert(m.path_attr[0].attribute.afi_safi_specific.withdrawn_routes[0].prefix == "6000::/3")
649*7dc08ffcSJunyu Laiassert(m.nlri == [])
650*7dc08ffcSJunyu Lai
651*7dc08ffcSJunyu Lai= BGPUpdate - with BGPHeader
652*7dc08ffcSJunyu Laip = BGP(raw(BGPHeader()/BGPUpdate()))
653*7dc08ffcSJunyu Laiassert(BGPHeader in p and BGPUpdate in p)
654*7dc08ffcSJunyu Lai
655*7dc08ffcSJunyu Lai
656*7dc08ffcSJunyu Lai########## BGPNotification Class ###################################
657*7dc08ffcSJunyu Lai+ BGPNotification class tests
658*7dc08ffcSJunyu Lai
659*7dc08ffcSJunyu Lai= BGPNotification - Instantiation
660*7dc08ffcSJunyu Lairaw(BGPNotification()) == b'\x00\x00'
661*7dc08ffcSJunyu Lai
662*7dc08ffcSJunyu Lai= BGPNotification - Dissection (Administratively Reset)
663*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x15\x03\x06\x04')
664*7dc08ffcSJunyu Laim.type == BGP.NOTIFICATION_TYPE and m.error_code == 6 and m.error_subcode == 4
665*7dc08ffcSJunyu Lai
666*7dc08ffcSJunyu Lai= BGPNotification - Dissection (Bad Peer AS)
667*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x17\x03\x02\x02\x00\x00')
668*7dc08ffcSJunyu Laim.type == BGP.NOTIFICATION_TYPE and m.error_code == 2 and m.error_subcode == 2
669*7dc08ffcSJunyu Lai
670*7dc08ffcSJunyu Lai= BGPNotification - Dissection (Attribute Flags Error)
671*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x19\x03\x03\x04\x80\x01\x01\x00')
672*7dc08ffcSJunyu Laim.type == BGP.NOTIFICATION_TYPE and m.error_code == 3 and m.error_subcode == 4
673*7dc08ffcSJunyu Lai
674*7dc08ffcSJunyu Lai
675*7dc08ffcSJunyu Lai########## BGPRouteRefresh Class ###################################
676*7dc08ffcSJunyu Lai+ BGPRouteRefresh class tests
677*7dc08ffcSJunyu Lai
678*7dc08ffcSJunyu Lai= BGPRouteRefresh - Instantiation
679*7dc08ffcSJunyu Lairaw(BGPRouteRefresh()) == b'\x00\x01\x00\x01'
680*7dc08ffcSJunyu Lai
681*7dc08ffcSJunyu Lai= BGPRouteRefresh - Instantiation with specific values
682*7dc08ffcSJunyu Lairaw(BGPRouteRefresh(afi = 1, safi = 1)) == b'\x00\x01\x00\x01'
683*7dc08ffcSJunyu Lai
684*7dc08ffcSJunyu Lai= BGPRouteRefresh - Dissection (1)
685*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x17\x05\x00\x02\x00\x01')
686*7dc08ffcSJunyu Laim.type == BGP.ROUTEREFRESH_TYPE and m.len == 23 and m.afi == 2 and m.subtype == 0 and m.safi == 1
687*7dc08ffcSJunyu Lai
688*7dc08ffcSJunyu Lai
689*7dc08ffcSJunyu Lai= BGPRouteRefresh - Dissection (2) - With ORFs
690*7dc08ffcSJunyu Laim = BGP(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00.\x05\x00\x01\x00\x01\x01\x80\x00\x13 \x00\x00\x00\x05\x18\x18\x15\x01\x01\x00\x00\x00\x00\x00\n\x00 \x00')
691*7dc08ffcSJunyu Laiassert(m.type == BGP.ROUTEREFRESH_TYPE)
692*7dc08ffcSJunyu Laiassert(m.len == 46)
693*7dc08ffcSJunyu Laiassert(m.afi == 1)
694*7dc08ffcSJunyu Laiassert(m.subtype == 0)
695*7dc08ffcSJunyu Laiassert(m.safi == 1)
696*7dc08ffcSJunyu Laiassert(m.orf_data[0].when_to_refresh == 1)
697*7dc08ffcSJunyu Laiassert(m.orf_data[0].orf_type == 128)
698*7dc08ffcSJunyu Laiassert(m.orf_data[0].orf_len == 19)
699*7dc08ffcSJunyu Laiassert(len(m.orf_data[0].entries) == 2)
700*7dc08ffcSJunyu Laiassert(m.orf_data[0].entries[0].action == 0)
701*7dc08ffcSJunyu Laiassert(m.orf_data[0].entries[0].match == 1)
702*7dc08ffcSJunyu Laiassert(m.orf_data[0].entries[0].prefix.prefix == "1.1.0.0/21")
703*7dc08ffcSJunyu Laiassert(m.orf_data[0].entries[1].action == 0)
704*7dc08ffcSJunyu Laiassert(m.orf_data[0].entries[1].match == 0)
705*7dc08ffcSJunyu Laiassert(m.orf_data[0].entries[1].prefix.prefix == "0.0.0.0/0")
706*7dc08ffcSJunyu Lai
707