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 |
| 13 | import meter_band |
| 14 | import table_mod_prop |
| 15 | import instruction |
| 16 | import queue_desc_prop |
| 17 | import oxm |
| 18 | import bundle_prop |
| 19 | import common |
| 20 | import instruction_id |
| 21 | import action |
| 22 | import role_prop |
| 23 | import message |
| 24 | import queue_stats_prop |
| 25 | import port_stats_prop |
| 26 | import port_mod_prop |
| 27 | import async_config_prop |
| 28 | import action_id |
| 29 | import util |
| 30 | import loxi.generic_util |
| 31 | |
| 32 | class role_prop(loxi.OFObject): |
| 33 | subtypes = {} |
| 34 | |
| 35 | |
| 36 | def __init__(self, type=None): |
| 37 | if type != None: |
| 38 | self.type = type |
| 39 | else: |
| 40 | self.type = 0 |
| 41 | return |
| 42 | |
| 43 | def pack(self): |
| 44 | packed = [] |
| 45 | packed.append(struct.pack("!H", self.type)) |
| 46 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 47 | length = sum([len(x) for x in packed]) |
| 48 | packed[1] = struct.pack("!H", length) |
| 49 | return ''.join(packed) |
| 50 | |
| 51 | @staticmethod |
| 52 | def unpack(reader): |
| 53 | subtype, = reader.peek('!H', 0) |
| 54 | subclass = role_prop.subtypes.get(subtype) |
| 55 | if subclass: |
| 56 | return subclass.unpack(reader) |
| 57 | |
| 58 | obj = role_prop() |
| 59 | obj.type = reader.read("!H")[0] |
| 60 | _length = reader.read("!H")[0] |
| 61 | orig_reader = reader |
| 62 | reader = orig_reader.slice(_length - (2 + 2)) |
| 63 | return obj |
| 64 | |
| 65 | def __eq__(self, other): |
| 66 | if type(self) != type(other): return False |
| 67 | if self.type != other.type: return False |
| 68 | return True |
| 69 | |
| 70 | def pretty_print(self, q): |
| 71 | q.text("role_prop {") |
| 72 | with q.group(): |
| 73 | with q.indent(2): |
| 74 | q.breakable() |
| 75 | q.breakable() |
| 76 | q.text('}') |
| 77 | |
| 78 | |
| 79 | class experimenter(role_prop): |
| 80 | subtypes = {} |
| 81 | |
| 82 | type = 65535 |
| 83 | |
| 84 | def __init__(self, experimenter=None, exp_type=None): |
| 85 | if experimenter != None: |
| 86 | self.experimenter = experimenter |
| 87 | else: |
| 88 | self.experimenter = 0 |
| 89 | if exp_type != None: |
| 90 | self.exp_type = exp_type |
| 91 | else: |
| 92 | self.exp_type = 0 |
| 93 | return |
| 94 | |
| 95 | def pack(self): |
| 96 | packed = [] |
| 97 | packed.append(struct.pack("!H", self.type)) |
| 98 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 99 | packed.append(struct.pack("!L", self.experimenter)) |
| 100 | packed.append(struct.pack("!L", self.exp_type)) |
| 101 | length = sum([len(x) for x in packed]) |
| 102 | packed[1] = struct.pack("!H", length) |
| 103 | return ''.join(packed) |
| 104 | |
| 105 | @staticmethod |
| 106 | def unpack(reader): |
| 107 | subtype, = reader.peek('!L', 4) |
| 108 | subclass = experimenter.subtypes.get(subtype) |
| 109 | if subclass: |
| 110 | return subclass.unpack(reader) |
| 111 | |
| 112 | obj = experimenter() |
| 113 | _type = reader.read("!H")[0] |
| 114 | assert(_type == 65535) |
| 115 | _length = reader.read("!H")[0] |
| 116 | orig_reader = reader |
| 117 | reader = orig_reader.slice(_length - (2 + 2)) |
| 118 | obj.experimenter = reader.read("!L")[0] |
| 119 | obj.exp_type = reader.read("!L")[0] |
| 120 | return obj |
| 121 | |
| 122 | def __eq__(self, other): |
| 123 | if type(self) != type(other): return False |
| 124 | if self.experimenter != other.experimenter: return False |
| 125 | if self.exp_type != other.exp_type: return False |
| 126 | return True |
| 127 | |
| 128 | def pretty_print(self, q): |
| 129 | q.text("experimenter {") |
| 130 | with q.group(): |
| 131 | with q.indent(2): |
| 132 | q.breakable() |
| 133 | q.text("exp_type = "); |
| 134 | q.text("%#x" % self.exp_type) |
| 135 | q.breakable() |
| 136 | q.text('}') |
| 137 | |
| 138 | role_prop.subtypes[65535] = experimenter |
| 139 | |
| 140 | |