Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 1 | # 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. |
| 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 5 | |
| 6 | # Automatically generated by LOXI from template module.py |
| 7 | # Do not modify |
| 8 | |
| 9 | import struct |
| 10 | import loxi |
| 11 | import const |
| 12 | import port_desc_prop |
Rich Lane | ccd32ed | 2014-11-10 17:48:24 -0800 | [diff] [blame^] | 13 | import bsn_tlv |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 14 | import meter_band |
| 15 | import table_mod_prop |
| 16 | import instruction |
| 17 | import queue_desc_prop |
| 18 | import oxm |
| 19 | import bundle_prop |
| 20 | import common |
| 21 | import instruction_id |
| 22 | import action |
| 23 | import role_prop |
| 24 | import message |
| 25 | import queue_stats_prop |
| 26 | import port_stats_prop |
| 27 | import port_mod_prop |
| 28 | import async_config_prop |
| 29 | import action_id |
| 30 | import util |
| 31 | import loxi.generic_util |
| 32 | |
| 33 | class table_mod_prop(loxi.OFObject): |
| 34 | subtypes = {} |
| 35 | |
| 36 | |
| 37 | def __init__(self, type=None): |
| 38 | if type != None: |
| 39 | self.type = type |
| 40 | else: |
| 41 | self.type = 0 |
| 42 | return |
| 43 | |
| 44 | def pack(self): |
| 45 | packed = [] |
| 46 | packed.append(struct.pack("!H", self.type)) |
| 47 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 48 | length = sum([len(x) for x in packed]) |
| 49 | packed[1] = struct.pack("!H", length) |
| 50 | return ''.join(packed) |
| 51 | |
| 52 | @staticmethod |
| 53 | def unpack(reader): |
| 54 | subtype, = reader.peek('!H', 0) |
| 55 | subclass = table_mod_prop.subtypes.get(subtype) |
| 56 | if subclass: |
| 57 | return subclass.unpack(reader) |
| 58 | |
| 59 | obj = table_mod_prop() |
| 60 | obj.type = reader.read("!H")[0] |
| 61 | _length = reader.read("!H")[0] |
| 62 | orig_reader = reader |
| 63 | reader = orig_reader.slice(_length - (2 + 2)) |
| 64 | return obj |
| 65 | |
| 66 | def __eq__(self, other): |
| 67 | if type(self) != type(other): return False |
| 68 | if self.type != other.type: return False |
| 69 | return True |
| 70 | |
| 71 | def pretty_print(self, q): |
| 72 | q.text("table_mod_prop {") |
| 73 | with q.group(): |
| 74 | with q.indent(2): |
| 75 | q.breakable() |
| 76 | q.breakable() |
| 77 | q.text('}') |
| 78 | |
| 79 | |
| 80 | |