blob: ef537dda19b1ec008f4f2c2d7419c60d1ecadd81 [file] [log] [blame]
Rich Laneca3da272013-05-05 09:07:33 -07001# Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2# Copyright (c) 2011, 2012 Open Networking Foundation
3# Copyright (c) 2012, 2013 Big Switch Networks, Inc.
Dan Talaycof6202252013-07-02 01:00:29 -07004# See the file LICENSE.pyloxi which should have been included in the source distribution
Rich Laneca3da272013-05-05 09:07:33 -07005
Rich Lane7dcdf022013-12-11 14:45:27 -08006# Automatically generated by LOXI from template module.py
Rich Laneca3da272013-05-05 09:07:33 -07007# Do not modify
8
9import struct
Rich Lane7dcdf022013-12-11 14:45:27 -080010import loxi
Rich Laneca3da272013-05-05 09:07:33 -070011import const
Harshmeet Singh1db46332014-10-14 16:29:13 -070012import bsn_tlv
13import meter_band
Rich Lane7dcdf022013-12-11 14:45:27 -080014import instruction
15import oxm
Harshmeet Singh1db46332014-10-14 16:29:13 -070016import common
Rich Lane7dcdf022013-12-11 14:45:27 -080017import instruction_id
Harshmeet Singh1db46332014-10-14 16:29:13 -070018import action
19import message
20import action_id
Rich Laneca3da272013-05-05 09:07:33 -070021import util
22import loxi.generic_util
Rich Laneca3da272013-05-05 09:07:33 -070023
Rich Lane7dcdf022013-12-11 14:45:27 -080024class instruction(loxi.OFObject):
25 subtypes = {}
Rich Laneca3da272013-05-05 09:07:33 -070026
Rich Lane95f7fc92014-01-27 17:08:16 -080027
28 def __init__(self, type=None):
29 if type != None:
30 self.type = type
31 else:
32 self.type = 0
33 return
34
35 def pack(self):
36 packed = []
37 packed.append(struct.pack("!H", self.type))
38 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
39 length = sum([len(x) for x in packed])
40 packed[1] = struct.pack("!H", length)
41 return ''.join(packed)
42
Rich Lane7dcdf022013-12-11 14:45:27 -080043 @staticmethod
44 def unpack(reader):
45 subtype, = reader.peek('!H', 0)
Rich Lane95f7fc92014-01-27 17:08:16 -080046 subclass = instruction.subtypes.get(subtype)
47 if subclass:
48 return subclass.unpack(reader)
49
50 obj = instruction()
51 obj.type = reader.read("!H")[0]
52 _len = reader.read("!H")[0]
53 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080054 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -080055 return obj
56
57 def __eq__(self, other):
58 if type(self) != type(other): return False
59 if self.type != other.type: return False
60 return True
61
62 def pretty_print(self, q):
63 q.text("instruction {")
64 with q.group():
65 with q.indent(2):
66 q.breakable()
67 q.breakable()
68 q.text('}')
Rich Laneca3da272013-05-05 09:07:33 -070069
Rich Lane7dcdf022013-12-11 14:45:27 -080070
71class apply_actions(instruction):
Dan Talaycof6202252013-07-02 01:00:29 -070072 type = 4
Rich Laneca3da272013-05-05 09:07:33 -070073
74 def __init__(self, actions=None):
75 if actions != None:
76 self.actions = actions
77 else:
78 self.actions = []
79 return
80
81 def pack(self):
82 packed = []
83 packed.append(struct.pack("!H", self.type))
84 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
85 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -080086 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Laneca3da272013-05-05 09:07:33 -070087 length = sum([len(x) for x in packed])
88 packed[1] = struct.pack("!H", length)
89 return ''.join(packed)
90
91 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -080092 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -070093 obj = apply_actions()
Dan Talaycof6202252013-07-02 01:00:29 -070094 _type = reader.read("!H")[0]
95 assert(_type == 4)
96 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -080097 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -080098 reader = orig_reader.slice(_len, 4)
Rich Laneca3da272013-05-05 09:07:33 -070099 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800100 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Laneca3da272013-05-05 09:07:33 -0700101 return obj
102
103 def __eq__(self, other):
104 if type(self) != type(other): return False
105 if self.actions != other.actions: return False
106 return True
107
Rich Laneca3da272013-05-05 09:07:33 -0700108 def pretty_print(self, q):
109 q.text("apply_actions {")
110 with q.group():
111 with q.indent(2):
112 q.breakable()
113 q.text("actions = ");
114 q.pp(self.actions)
115 q.breakable()
116 q.text('}')
117
Rich Lane7dcdf022013-12-11 14:45:27 -0800118instruction.subtypes[4] = apply_actions
119
120class experimenter(instruction):
121 subtypes = {}
122
Rich Lane95f7fc92014-01-27 17:08:16 -0800123 type = 65535
124
125 def __init__(self, experimenter=None, data=None):
126 if experimenter != None:
127 self.experimenter = experimenter
128 else:
129 self.experimenter = 0
130 if data != None:
131 self.data = data
132 else:
133 self.data = ''
134 return
135
136 def pack(self):
137 packed = []
138 packed.append(struct.pack("!H", self.type))
139 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
140 packed.append(struct.pack("!L", self.experimenter))
141 packed.append(self.data)
142 length = sum([len(x) for x in packed])
143 packed[1] = struct.pack("!H", length)
144 return ''.join(packed)
145
Rich Lane7dcdf022013-12-11 14:45:27 -0800146 @staticmethod
147 def unpack(reader):
148 subtype, = reader.peek('!L', 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800149 subclass = experimenter.subtypes.get(subtype)
150 if subclass:
151 return subclass.unpack(reader)
152
153 obj = experimenter()
154 _type = reader.read("!H")[0]
155 assert(_type == 65535)
156 _len = reader.read("!H")[0]
157 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800158 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800159 obj.experimenter = reader.read("!L")[0]
160 obj.data = str(reader.read_all())
161 return obj
162
163 def __eq__(self, other):
164 if type(self) != type(other): return False
165 if self.experimenter != other.experimenter: return False
166 if self.data != other.data: return False
167 return True
168
169 def pretty_print(self, q):
170 q.text("experimenter {")
171 with q.group():
172 with q.indent(2):
173 q.breakable()
174 q.text("data = ");
175 q.pp(self.data)
176 q.breakable()
177 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800178
179instruction.subtypes[65535] = experimenter
180
181class bsn(experimenter):
182 subtypes = {}
183
Rich Lane95f7fc92014-01-27 17:08:16 -0800184 type = 65535
185 experimenter = 6035143
186
187 def __init__(self, subtype=None):
188 if subtype != None:
189 self.subtype = subtype
190 else:
191 self.subtype = 0
192 return
193
194 def pack(self):
195 packed = []
196 packed.append(struct.pack("!H", self.type))
197 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
198 packed.append(struct.pack("!L", self.experimenter))
199 packed.append(struct.pack("!L", self.subtype))
200 packed.append('\x00' * 4)
201 length = sum([len(x) for x in packed])
202 packed[1] = struct.pack("!H", length)
203 return ''.join(packed)
204
Rich Lane7dcdf022013-12-11 14:45:27 -0800205 @staticmethod
206 def unpack(reader):
207 subtype, = reader.peek('!L', 8)
Rich Lane95f7fc92014-01-27 17:08:16 -0800208 subclass = bsn.subtypes.get(subtype)
209 if subclass:
210 return subclass.unpack(reader)
211
212 obj = bsn()
213 _type = reader.read("!H")[0]
214 assert(_type == 65535)
215 _len = reader.read("!H")[0]
216 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800217 reader = orig_reader.slice(_len, 4)
Rich Lane95f7fc92014-01-27 17:08:16 -0800218 _experimenter = reader.read("!L")[0]
219 assert(_experimenter == 6035143)
220 obj.subtype = reader.read("!L")[0]
221 reader.skip(4)
222 return obj
223
224 def __eq__(self, other):
225 if type(self) != type(other): return False
226 if self.subtype != other.subtype: return False
227 return True
228
229 def pretty_print(self, q):
230 q.text("bsn {")
231 with q.group():
232 with q.indent(2):
233 q.breakable()
234 q.breakable()
235 q.text('}')
Rich Lane7dcdf022013-12-11 14:45:27 -0800236
237experimenter.subtypes[6035143] = bsn
238
Rich Lane5454b682014-01-14 17:07:36 -0800239class bsn_arp_offload(bsn):
240 type = 65535
241 experimenter = 6035143
242 subtype = 1
243
244 def __init__(self):
245 return
246
247 def pack(self):
248 packed = []
249 packed.append(struct.pack("!H", self.type))
250 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
251 packed.append(struct.pack("!L", self.experimenter))
252 packed.append(struct.pack("!L", self.subtype))
253 packed.append('\x00' * 4)
254 length = sum([len(x) for x in packed])
255 packed[1] = struct.pack("!H", length)
256 return ''.join(packed)
257
258 @staticmethod
259 def unpack(reader):
260 obj = bsn_arp_offload()
261 _type = reader.read("!H")[0]
262 assert(_type == 65535)
263 _len = reader.read("!H")[0]
264 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800265 reader = orig_reader.slice(_len, 4)
Rich Lane5454b682014-01-14 17:07:36 -0800266 _experimenter = reader.read("!L")[0]
267 assert(_experimenter == 6035143)
268 _subtype = reader.read("!L")[0]
269 assert(_subtype == 1)
270 reader.skip(4)
271 return obj
272
273 def __eq__(self, other):
274 if type(self) != type(other): return False
275 return True
276
277 def pretty_print(self, q):
278 q.text("bsn_arp_offload {")
279 with q.group():
280 with q.indent(2):
281 q.breakable()
282 q.breakable()
283 q.text('}')
284
285bsn.subtypes[1] = bsn_arp_offload
286
Harshmeet Singh301f7172014-12-08 13:07:29 -0800287class bsn_auto_negotiation(bsn):
288 type = 65535
289 experimenter = 6035143
290 subtype = 11
291
292 def __init__(self):
293 return
294
295 def pack(self):
296 packed = []
297 packed.append(struct.pack("!H", self.type))
298 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
299 packed.append(struct.pack("!L", self.experimenter))
300 packed.append(struct.pack("!L", self.subtype))
301 packed.append('\x00' * 4)
302 length = sum([len(x) for x in packed])
303 packed[1] = struct.pack("!H", length)
304 return ''.join(packed)
305
306 @staticmethod
307 def unpack(reader):
308 obj = bsn_auto_negotiation()
309 _type = reader.read("!H")[0]
310 assert(_type == 65535)
311 _len = reader.read("!H")[0]
312 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800313 reader = orig_reader.slice(_len, 4)
Harshmeet Singh301f7172014-12-08 13:07:29 -0800314 _experimenter = reader.read("!L")[0]
315 assert(_experimenter == 6035143)
316 _subtype = reader.read("!L")[0]
317 assert(_subtype == 11)
318 reader.skip(4)
319 return obj
320
321 def __eq__(self, other):
322 if type(self) != type(other): return False
323 return True
324
325 def pretty_print(self, q):
326 q.text("bsn_auto_negotiation {")
327 with q.group():
328 with q.indent(2):
329 q.breakable()
330 q.breakable()
331 q.text('}')
332
333bsn.subtypes[11] = bsn_auto_negotiation
334
Rich Lane9ec3fca2014-02-26 16:22:56 -0800335class bsn_deny(bsn):
336 type = 65535
337 experimenter = 6035143
338 subtype = 5
339
340 def __init__(self):
341 return
342
343 def pack(self):
344 packed = []
345 packed.append(struct.pack("!H", self.type))
346 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
347 packed.append(struct.pack("!L", self.experimenter))
348 packed.append(struct.pack("!L", self.subtype))
349 packed.append('\x00' * 4)
350 length = sum([len(x) for x in packed])
351 packed[1] = struct.pack("!H", length)
352 return ''.join(packed)
353
354 @staticmethod
355 def unpack(reader):
356 obj = bsn_deny()
357 _type = reader.read("!H")[0]
358 assert(_type == 65535)
359 _len = reader.read("!H")[0]
360 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800361 reader = orig_reader.slice(_len, 4)
Rich Lane9ec3fca2014-02-26 16:22:56 -0800362 _experimenter = reader.read("!L")[0]
363 assert(_experimenter == 6035143)
364 _subtype = reader.read("!L")[0]
365 assert(_subtype == 5)
366 reader.skip(4)
367 return obj
368
369 def __eq__(self, other):
370 if type(self) != type(other): return False
371 return True
372
373 def pretty_print(self, q):
374 q.text("bsn_deny {")
375 with q.group():
376 with q.indent(2):
377 q.breakable()
378 q.breakable()
379 q.text('}')
380
381bsn.subtypes[5] = bsn_deny
382
Rich Lane1b75abf2014-02-05 11:23:20 -0800383class bsn_dhcp_offload(bsn):
384 type = 65535
385 experimenter = 6035143
386 subtype = 2
387
388 def __init__(self):
389 return
390
391 def pack(self):
392 packed = []
393 packed.append(struct.pack("!H", self.type))
394 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
395 packed.append(struct.pack("!L", self.experimenter))
396 packed.append(struct.pack("!L", self.subtype))
397 packed.append('\x00' * 4)
398 length = sum([len(x) for x in packed])
399 packed[1] = struct.pack("!H", length)
400 return ''.join(packed)
401
402 @staticmethod
403 def unpack(reader):
404 obj = bsn_dhcp_offload()
405 _type = reader.read("!H")[0]
406 assert(_type == 65535)
407 _len = reader.read("!H")[0]
408 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800409 reader = orig_reader.slice(_len, 4)
Rich Lane1b75abf2014-02-05 11:23:20 -0800410 _experimenter = reader.read("!L")[0]
411 assert(_experimenter == 6035143)
412 _subtype = reader.read("!L")[0]
413 assert(_subtype == 2)
414 reader.skip(4)
415 return obj
416
417 def __eq__(self, other):
418 if type(self) != type(other): return False
419 return True
420
421 def pretty_print(self, q):
422 q.text("bsn_dhcp_offload {")
423 with q.group():
424 with q.indent(2):
425 q.breakable()
426 q.breakable()
427 q.text('}')
428
429bsn.subtypes[2] = bsn_dhcp_offload
430
Rich Lane9ec3fca2014-02-26 16:22:56 -0800431class bsn_disable_split_horizon_check(bsn):
432 type = 65535
433 experimenter = 6035143
434 subtype = 3
435
436 def __init__(self):
437 return
438
439 def pack(self):
440 packed = []
441 packed.append(struct.pack("!H", self.type))
442 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
443 packed.append(struct.pack("!L", self.experimenter))
444 packed.append(struct.pack("!L", self.subtype))
445 packed.append('\x00' * 4)
446 length = sum([len(x) for x in packed])
447 packed[1] = struct.pack("!H", length)
448 return ''.join(packed)
449
450 @staticmethod
451 def unpack(reader):
452 obj = bsn_disable_split_horizon_check()
453 _type = reader.read("!H")[0]
454 assert(_type == 65535)
455 _len = reader.read("!H")[0]
456 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800457 reader = orig_reader.slice(_len, 4)
Rich Lane9ec3fca2014-02-26 16:22:56 -0800458 _experimenter = reader.read("!L")[0]
459 assert(_experimenter == 6035143)
460 _subtype = reader.read("!L")[0]
461 assert(_subtype == 3)
462 reader.skip(4)
463 return obj
464
465 def __eq__(self, other):
466 if type(self) != type(other): return False
467 return True
468
469 def pretty_print(self, q):
470 q.text("bsn_disable_split_horizon_check {")
471 with q.group():
472 with q.indent(2):
473 q.breakable()
474 q.breakable()
475 q.text('}')
476
477bsn.subtypes[3] = bsn_disable_split_horizon_check
478
Rich Lane7dcdf022013-12-11 14:45:27 -0800479class bsn_disable_src_mac_check(bsn):
Rich Lane7b0f2012013-11-22 14:15:26 -0800480 type = 65535
481 experimenter = 6035143
482 subtype = 0
483
484 def __init__(self):
485 return
486
487 def pack(self):
488 packed = []
489 packed.append(struct.pack("!H", self.type))
490 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
491 packed.append(struct.pack("!L", self.experimenter))
492 packed.append(struct.pack("!L", self.subtype))
493 packed.append('\x00' * 4)
494 length = sum([len(x) for x in packed])
495 packed[1] = struct.pack("!H", length)
496 return ''.join(packed)
497
498 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800499 def unpack(reader):
Rich Lane7b0f2012013-11-22 14:15:26 -0800500 obj = bsn_disable_src_mac_check()
Rich Lane7b0f2012013-11-22 14:15:26 -0800501 _type = reader.read("!H")[0]
502 assert(_type == 65535)
503 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800504 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800505 reader = orig_reader.slice(_len, 4)
Rich Lane7b0f2012013-11-22 14:15:26 -0800506 _experimenter = reader.read("!L")[0]
507 assert(_experimenter == 6035143)
508 _subtype = reader.read("!L")[0]
509 assert(_subtype == 0)
510 reader.skip(4)
511 return obj
512
513 def __eq__(self, other):
514 if type(self) != type(other): return False
515 return True
516
Rich Lane7b0f2012013-11-22 14:15:26 -0800517 def pretty_print(self, q):
518 q.text("bsn_disable_src_mac_check {")
519 with q.group():
520 with q.indent(2):
521 q.breakable()
522 q.breakable()
523 q.text('}')
524
Rich Lane7dcdf022013-12-11 14:45:27 -0800525bsn.subtypes[0] = bsn_disable_src_mac_check
526
Harshmeet Singhc0378a92014-07-22 17:09:36 -0700527class bsn_disable_vlan_counters(bsn):
528 type = 65535
529 experimenter = 6035143
530 subtype = 9
531
532 def __init__(self):
533 return
534
535 def pack(self):
536 packed = []
537 packed.append(struct.pack("!H", self.type))
538 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
539 packed.append(struct.pack("!L", self.experimenter))
540 packed.append(struct.pack("!L", self.subtype))
541 packed.append('\x00' * 4)
542 length = sum([len(x) for x in packed])
543 packed[1] = struct.pack("!H", length)
544 return ''.join(packed)
545
546 @staticmethod
547 def unpack(reader):
548 obj = bsn_disable_vlan_counters()
549 _type = reader.read("!H")[0]
550 assert(_type == 65535)
551 _len = reader.read("!H")[0]
552 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800553 reader = orig_reader.slice(_len, 4)
Harshmeet Singhc0378a92014-07-22 17:09:36 -0700554 _experimenter = reader.read("!L")[0]
555 assert(_experimenter == 6035143)
556 _subtype = reader.read("!L")[0]
557 assert(_subtype == 9)
558 reader.skip(4)
559 return obj
560
561 def __eq__(self, other):
562 if type(self) != type(other): return False
563 return True
564
565 def pretty_print(self, q):
566 q.text("bsn_disable_vlan_counters {")
567 with q.group():
568 with q.indent(2):
569 q.breakable()
570 q.breakable()
571 q.text('}')
572
573bsn.subtypes[9] = bsn_disable_vlan_counters
574
Rich Lanef50b7c32014-03-20 11:38:02 -0700575class bsn_packet_of_death(bsn):
576 type = 65535
577 experimenter = 6035143
578 subtype = 6
579
580 def __init__(self):
581 return
582
583 def pack(self):
584 packed = []
585 packed.append(struct.pack("!H", self.type))
586 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
587 packed.append(struct.pack("!L", self.experimenter))
588 packed.append(struct.pack("!L", self.subtype))
589 packed.append('\x00' * 4)
590 length = sum([len(x) for x in packed])
591 packed[1] = struct.pack("!H", length)
592 return ''.join(packed)
593
594 @staticmethod
595 def unpack(reader):
596 obj = bsn_packet_of_death()
597 _type = reader.read("!H")[0]
598 assert(_type == 65535)
599 _len = reader.read("!H")[0]
600 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800601 reader = orig_reader.slice(_len, 4)
Rich Lanef50b7c32014-03-20 11:38:02 -0700602 _experimenter = reader.read("!L")[0]
603 assert(_experimenter == 6035143)
604 _subtype = reader.read("!L")[0]
605 assert(_subtype == 6)
606 reader.skip(4)
607 return obj
608
609 def __eq__(self, other):
610 if type(self) != type(other): return False
611 return True
612
613 def pretty_print(self, q):
614 q.text("bsn_packet_of_death {")
615 with q.group():
616 with q.indent(2):
617 q.breakable()
618 q.breakable()
619 q.text('}')
620
621bsn.subtypes[6] = bsn_packet_of_death
622
Rich Lane9ec3fca2014-02-26 16:22:56 -0800623class bsn_permit(bsn):
624 type = 65535
625 experimenter = 6035143
626 subtype = 4
627
628 def __init__(self):
629 return
630
631 def pack(self):
632 packed = []
633 packed.append(struct.pack("!H", self.type))
634 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
635 packed.append(struct.pack("!L", self.experimenter))
636 packed.append(struct.pack("!L", self.subtype))
637 packed.append('\x00' * 4)
638 length = sum([len(x) for x in packed])
639 packed[1] = struct.pack("!H", length)
640 return ''.join(packed)
641
642 @staticmethod
643 def unpack(reader):
644 obj = bsn_permit()
645 _type = reader.read("!H")[0]
646 assert(_type == 65535)
647 _len = reader.read("!H")[0]
648 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800649 reader = orig_reader.slice(_len, 4)
Rich Lane9ec3fca2014-02-26 16:22:56 -0800650 _experimenter = reader.read("!L")[0]
651 assert(_experimenter == 6035143)
652 _subtype = reader.read("!L")[0]
653 assert(_subtype == 4)
654 reader.skip(4)
655 return obj
656
657 def __eq__(self, other):
658 if type(self) != type(other): return False
659 return True
660
661 def pretty_print(self, q):
662 q.text("bsn_permit {")
663 with q.group():
664 with q.indent(2):
665 q.breakable()
666 q.breakable()
667 q.text('}')
668
669bsn.subtypes[4] = bsn_permit
670
Rich Lane78d9bcb2014-05-12 13:27:44 -0700671class bsn_prioritize_pdus(bsn):
672 type = 65535
673 experimenter = 6035143
674 subtype = 7
675
676 def __init__(self):
677 return
678
679 def pack(self):
680 packed = []
681 packed.append(struct.pack("!H", self.type))
682 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
683 packed.append(struct.pack("!L", self.experimenter))
684 packed.append(struct.pack("!L", self.subtype))
685 packed.append('\x00' * 4)
686 length = sum([len(x) for x in packed])
687 packed[1] = struct.pack("!H", length)
688 return ''.join(packed)
689
690 @staticmethod
691 def unpack(reader):
692 obj = bsn_prioritize_pdus()
693 _type = reader.read("!H")[0]
694 assert(_type == 65535)
695 _len = reader.read("!H")[0]
696 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800697 reader = orig_reader.slice(_len, 4)
Rich Lane78d9bcb2014-05-12 13:27:44 -0700698 _experimenter = reader.read("!L")[0]
699 assert(_experimenter == 6035143)
700 _subtype = reader.read("!L")[0]
701 assert(_subtype == 7)
702 reader.skip(4)
703 return obj
704
705 def __eq__(self, other):
706 if type(self) != type(other): return False
707 return True
708
709 def pretty_print(self, q):
710 q.text("bsn_prioritize_pdus {")
711 with q.group():
712 with q.indent(2):
713 q.breakable()
714 q.breakable()
715 q.text('}')
716
717bsn.subtypes[7] = bsn_prioritize_pdus
718
Rich Lane5587ab12014-06-30 11:19:09 -0700719class bsn_require_vlan_xlate(bsn):
720 type = 65535
721 experimenter = 6035143
722 subtype = 8
723
724 def __init__(self):
725 return
726
727 def pack(self):
728 packed = []
729 packed.append(struct.pack("!H", self.type))
730 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
731 packed.append(struct.pack("!L", self.experimenter))
732 packed.append(struct.pack("!L", self.subtype))
733 packed.append('\x00' * 4)
734 length = sum([len(x) for x in packed])
735 packed[1] = struct.pack("!H", length)
736 return ''.join(packed)
737
738 @staticmethod
739 def unpack(reader):
740 obj = bsn_require_vlan_xlate()
741 _type = reader.read("!H")[0]
742 assert(_type == 65535)
743 _len = reader.read("!H")[0]
744 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800745 reader = orig_reader.slice(_len, 4)
Rich Lane5587ab12014-06-30 11:19:09 -0700746 _experimenter = reader.read("!L")[0]
747 assert(_experimenter == 6035143)
748 _subtype = reader.read("!L")[0]
749 assert(_subtype == 8)
750 reader.skip(4)
751 return obj
752
753 def __eq__(self, other):
754 if type(self) != type(other): return False
755 return True
756
757 def pretty_print(self, q):
758 q.text("bsn_require_vlan_xlate {")
759 with q.group():
760 with q.indent(2):
761 q.breakable()
762 q.breakable()
763 q.text('}')
764
765bsn.subtypes[8] = bsn_require_vlan_xlate
766
Rich Lanef9530c42014-09-15 09:59:43 -0700767class bsn_span_destination(bsn):
768 type = 65535
769 experimenter = 6035143
770 subtype = 10
771
772 def __init__(self):
773 return
774
775 def pack(self):
776 packed = []
777 packed.append(struct.pack("!H", self.type))
778 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
779 packed.append(struct.pack("!L", self.experimenter))
780 packed.append(struct.pack("!L", self.subtype))
781 packed.append('\x00' * 4)
782 length = sum([len(x) for x in packed])
783 packed[1] = struct.pack("!H", length)
784 return ''.join(packed)
785
786 @staticmethod
787 def unpack(reader):
788 obj = bsn_span_destination()
789 _type = reader.read("!H")[0]
790 assert(_type == 65535)
791 _len = reader.read("!H")[0]
792 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800793 reader = orig_reader.slice(_len, 4)
Rich Lanef9530c42014-09-15 09:59:43 -0700794 _experimenter = reader.read("!L")[0]
795 assert(_experimenter == 6035143)
796 _subtype = reader.read("!L")[0]
797 assert(_subtype == 10)
798 reader.skip(4)
799 return obj
800
801 def __eq__(self, other):
802 if type(self) != type(other): return False
803 return True
804
805 def pretty_print(self, q):
806 q.text("bsn_span_destination {")
807 with q.group():
808 with q.indent(2):
809 q.breakable()
810 q.breakable()
811 q.text('}')
812
813bsn.subtypes[10] = bsn_span_destination
814
Rich Lane7dcdf022013-12-11 14:45:27 -0800815class clear_actions(instruction):
Dan Talaycof6202252013-07-02 01:00:29 -0700816 type = 5
Rich Laneca3da272013-05-05 09:07:33 -0700817
818 def __init__(self):
819 return
820
821 def pack(self):
822 packed = []
823 packed.append(struct.pack("!H", self.type))
824 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
825 packed.append('\x00' * 4)
826 length = sum([len(x) for x in packed])
827 packed[1] = struct.pack("!H", length)
828 return ''.join(packed)
829
830 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800831 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -0700832 obj = clear_actions()
Dan Talaycof6202252013-07-02 01:00:29 -0700833 _type = reader.read("!H")[0]
834 assert(_type == 5)
835 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800836 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800837 reader = orig_reader.slice(_len, 4)
Rich Laneca3da272013-05-05 09:07:33 -0700838 reader.skip(4)
839 return obj
840
841 def __eq__(self, other):
842 if type(self) != type(other): return False
843 return True
844
Rich Laneca3da272013-05-05 09:07:33 -0700845 def pretty_print(self, q):
846 q.text("clear_actions {")
847 with q.group():
848 with q.indent(2):
849 q.breakable()
850 q.breakable()
851 q.text('}')
852
Rich Lane7dcdf022013-12-11 14:45:27 -0800853instruction.subtypes[5] = clear_actions
854
855class goto_table(instruction):
Dan Talaycof6202252013-07-02 01:00:29 -0700856 type = 1
Rich Laneca3da272013-05-05 09:07:33 -0700857
858 def __init__(self, table_id=None):
859 if table_id != None:
860 self.table_id = table_id
861 else:
862 self.table_id = 0
863 return
864
865 def pack(self):
866 packed = []
867 packed.append(struct.pack("!H", self.type))
868 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
869 packed.append(struct.pack("!B", self.table_id))
870 packed.append('\x00' * 3)
871 length = sum([len(x) for x in packed])
872 packed[1] = struct.pack("!H", length)
873 return ''.join(packed)
874
875 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800876 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -0700877 obj = goto_table()
Dan Talaycof6202252013-07-02 01:00:29 -0700878 _type = reader.read("!H")[0]
879 assert(_type == 1)
880 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800881 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800882 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700883 obj.table_id = reader.read("!B")[0]
Rich Laneca3da272013-05-05 09:07:33 -0700884 reader.skip(3)
885 return obj
886
887 def __eq__(self, other):
888 if type(self) != type(other): return False
889 if self.table_id != other.table_id: return False
890 return True
891
Rich Laneca3da272013-05-05 09:07:33 -0700892 def pretty_print(self, q):
893 q.text("goto_table {")
894 with q.group():
895 with q.indent(2):
896 q.breakable()
897 q.text("table_id = ");
898 q.text("%#x" % self.table_id)
899 q.breakable()
900 q.text('}')
901
Rich Lane7dcdf022013-12-11 14:45:27 -0800902instruction.subtypes[1] = goto_table
903
904class meter(instruction):
Dan Talaycof6202252013-07-02 01:00:29 -0700905 type = 6
Rich Laneca3da272013-05-05 09:07:33 -0700906
907 def __init__(self, meter_id=None):
908 if meter_id != None:
909 self.meter_id = meter_id
910 else:
911 self.meter_id = 0
912 return
913
914 def pack(self):
915 packed = []
916 packed.append(struct.pack("!H", self.type))
917 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
918 packed.append(struct.pack("!L", self.meter_id))
919 length = sum([len(x) for x in packed])
920 packed[1] = struct.pack("!H", length)
921 return ''.join(packed)
922
923 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800924 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -0700925 obj = meter()
Dan Talaycof6202252013-07-02 01:00:29 -0700926 _type = reader.read("!H")[0]
927 assert(_type == 6)
928 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800929 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800930 reader = orig_reader.slice(_len, 4)
Dan Talaycof6202252013-07-02 01:00:29 -0700931 obj.meter_id = reader.read("!L")[0]
Rich Laneca3da272013-05-05 09:07:33 -0700932 return obj
933
934 def __eq__(self, other):
935 if type(self) != type(other): return False
936 if self.meter_id != other.meter_id: return False
937 return True
938
Rich Laneca3da272013-05-05 09:07:33 -0700939 def pretty_print(self, q):
940 q.text("meter {")
941 with q.group():
942 with q.indent(2):
943 q.breakable()
944 q.text("meter_id = ");
945 q.text("%#x" % self.meter_id)
946 q.breakable()
947 q.text('}')
948
Rich Lane7dcdf022013-12-11 14:45:27 -0800949instruction.subtypes[6] = meter
950
951class write_actions(instruction):
Dan Talaycof6202252013-07-02 01:00:29 -0700952 type = 3
Rich Laneca3da272013-05-05 09:07:33 -0700953
954 def __init__(self, actions=None):
955 if actions != None:
956 self.actions = actions
957 else:
958 self.actions = []
959 return
960
961 def pack(self):
962 packed = []
963 packed.append(struct.pack("!H", self.type))
964 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
965 packed.append('\x00' * 4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800966 packed.append(loxi.generic_util.pack_list(self.actions))
Rich Laneca3da272013-05-05 09:07:33 -0700967 length = sum([len(x) for x in packed])
968 packed[1] = struct.pack("!H", length)
969 return ''.join(packed)
970
971 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -0800972 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -0700973 obj = write_actions()
Dan Talaycof6202252013-07-02 01:00:29 -0700974 _type = reader.read("!H")[0]
975 assert(_type == 3)
976 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -0800977 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -0800978 reader = orig_reader.slice(_len, 4)
Rich Laneca3da272013-05-05 09:07:33 -0700979 reader.skip(4)
Rich Lane7dcdf022013-12-11 14:45:27 -0800980 obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack)
Rich Laneca3da272013-05-05 09:07:33 -0700981 return obj
982
983 def __eq__(self, other):
984 if type(self) != type(other): return False
985 if self.actions != other.actions: return False
986 return True
987
Rich Laneca3da272013-05-05 09:07:33 -0700988 def pretty_print(self, q):
989 q.text("write_actions {")
990 with q.group():
991 with q.indent(2):
992 q.breakable()
993 q.text("actions = ");
994 q.pp(self.actions)
995 q.breakable()
996 q.text('}')
997
Rich Lane7dcdf022013-12-11 14:45:27 -0800998instruction.subtypes[3] = write_actions
999
1000class write_metadata(instruction):
Dan Talaycof6202252013-07-02 01:00:29 -07001001 type = 2
Rich Laneca3da272013-05-05 09:07:33 -07001002
1003 def __init__(self, metadata=None, metadata_mask=None):
1004 if metadata != None:
1005 self.metadata = metadata
1006 else:
1007 self.metadata = 0
1008 if metadata_mask != None:
1009 self.metadata_mask = metadata_mask
1010 else:
1011 self.metadata_mask = 0
1012 return
1013
1014 def pack(self):
1015 packed = []
1016 packed.append(struct.pack("!H", self.type))
1017 packed.append(struct.pack("!H", 0)) # placeholder for len at index 1
1018 packed.append('\x00' * 4)
1019 packed.append(struct.pack("!Q", self.metadata))
1020 packed.append(struct.pack("!Q", self.metadata_mask))
1021 length = sum([len(x) for x in packed])
1022 packed[1] = struct.pack("!H", length)
1023 return ''.join(packed)
1024
1025 @staticmethod
Rich Lane7dcdf022013-12-11 14:45:27 -08001026 def unpack(reader):
Rich Laneca3da272013-05-05 09:07:33 -07001027 obj = write_metadata()
Dan Talaycof6202252013-07-02 01:00:29 -07001028 _type = reader.read("!H")[0]
1029 assert(_type == 2)
1030 _len = reader.read("!H")[0]
Rich Lane7dcdf022013-12-11 14:45:27 -08001031 orig_reader = reader
Rich Lanecb18dbd2014-12-18 10:02:29 -08001032 reader = orig_reader.slice(_len, 4)
Rich Laneca3da272013-05-05 09:07:33 -07001033 reader.skip(4)
Dan Talaycof6202252013-07-02 01:00:29 -07001034 obj.metadata = reader.read("!Q")[0]
1035 obj.metadata_mask = reader.read("!Q")[0]
Rich Laneca3da272013-05-05 09:07:33 -07001036 return obj
1037
1038 def __eq__(self, other):
1039 if type(self) != type(other): return False
1040 if self.metadata != other.metadata: return False
1041 if self.metadata_mask != other.metadata_mask: return False
1042 return True
1043
Rich Laneca3da272013-05-05 09:07:33 -07001044 def pretty_print(self, q):
1045 q.text("write_metadata {")
1046 with q.group():
1047 with q.indent(2):
1048 q.breakable()
1049 q.text("metadata = ");
1050 q.text("%#x" % self.metadata)
1051 q.text(","); q.breakable()
1052 q.text("metadata_mask = ");
1053 q.text("%#x" % self.metadata_mask)
1054 q.breakable()
1055 q.text('}')
1056
Rich Lane7dcdf022013-12-11 14:45:27 -08001057instruction.subtypes[2] = write_metadata
Rich Laneca3da272013-05-05 09:07:33 -07001058
Rich Lane7b0f2012013-11-22 14:15:26 -08001059