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 queue_desc_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 = queue_desc_prop.subtypes.get(subtype) |
| 55 | if subclass: |
| 56 | return subclass.unpack(reader) |
| 57 | |
| 58 | obj = queue_desc_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("queue_desc_prop {") |
| 72 | with q.group(): |
| 73 | with q.indent(2): |
| 74 | q.breakable() |
| 75 | q.breakable() |
| 76 | q.text('}') |
| 77 | |
| 78 | |
| 79 | class experimenter(queue_desc_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 | queue_desc_prop.subtypes[65535] = experimenter |
| 139 | |
| 140 | class max_rate(queue_desc_prop): |
| 141 | type = 2 |
| 142 | |
| 143 | def __init__(self, rate=None): |
| 144 | if rate != None: |
| 145 | self.rate = rate |
| 146 | else: |
| 147 | self.rate = 0 |
| 148 | return |
| 149 | |
| 150 | def pack(self): |
| 151 | packed = [] |
| 152 | packed.append(struct.pack("!H", self.type)) |
| 153 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 154 | packed.append(struct.pack("!H", self.rate)) |
| 155 | packed.append('\x00' * 2) |
| 156 | length = sum([len(x) for x in packed]) |
| 157 | packed[1] = struct.pack("!H", length) |
| 158 | return ''.join(packed) |
| 159 | |
| 160 | @staticmethod |
| 161 | def unpack(reader): |
| 162 | obj = max_rate() |
| 163 | _type = reader.read("!H")[0] |
| 164 | assert(_type == 2) |
| 165 | _length = reader.read("!H")[0] |
| 166 | orig_reader = reader |
| 167 | reader = orig_reader.slice(_length - (2 + 2)) |
| 168 | obj.rate = reader.read("!H")[0] |
| 169 | reader.skip(2) |
| 170 | return obj |
| 171 | |
| 172 | def __eq__(self, other): |
| 173 | if type(self) != type(other): return False |
| 174 | if self.rate != other.rate: return False |
| 175 | return True |
| 176 | |
| 177 | def pretty_print(self, q): |
| 178 | q.text("max_rate {") |
| 179 | with q.group(): |
| 180 | with q.indent(2): |
| 181 | q.breakable() |
| 182 | q.text("rate = "); |
| 183 | q.text("%#x" % self.rate) |
| 184 | q.breakable() |
| 185 | q.text('}') |
| 186 | |
| 187 | queue_desc_prop.subtypes[2] = max_rate |
| 188 | |
| 189 | class min_rate(queue_desc_prop): |
| 190 | type = 1 |
| 191 | |
| 192 | def __init__(self, rate=None): |
| 193 | if rate != None: |
| 194 | self.rate = rate |
| 195 | else: |
| 196 | self.rate = 0 |
| 197 | return |
| 198 | |
| 199 | def pack(self): |
| 200 | packed = [] |
| 201 | packed.append(struct.pack("!H", self.type)) |
| 202 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 203 | packed.append(struct.pack("!H", self.rate)) |
| 204 | packed.append('\x00' * 2) |
| 205 | length = sum([len(x) for x in packed]) |
| 206 | packed[1] = struct.pack("!H", length) |
| 207 | return ''.join(packed) |
| 208 | |
| 209 | @staticmethod |
| 210 | def unpack(reader): |
| 211 | obj = min_rate() |
| 212 | _type = reader.read("!H")[0] |
| 213 | assert(_type == 1) |
| 214 | _length = reader.read("!H")[0] |
| 215 | orig_reader = reader |
| 216 | reader = orig_reader.slice(_length - (2 + 2)) |
| 217 | obj.rate = reader.read("!H")[0] |
| 218 | reader.skip(2) |
| 219 | return obj |
| 220 | |
| 221 | def __eq__(self, other): |
| 222 | if type(self) != type(other): return False |
| 223 | if self.rate != other.rate: return False |
| 224 | return True |
| 225 | |
| 226 | def pretty_print(self, q): |
| 227 | q.text("min_rate {") |
| 228 | with q.group(): |
| 229 | with q.indent(2): |
| 230 | q.breakable() |
| 231 | q.text("rate = "); |
| 232 | q.text("%#x" % self.rate) |
| 233 | q.breakable() |
| 234 | q.text('}') |
| 235 | |
| 236 | queue_desc_prop.subtypes[1] = min_rate |
| 237 | |
| 238 | |