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 instruction_id(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 len 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 = instruction_id.subtypes.get(subtype) |
| 55 | if subclass: |
| 56 | return subclass.unpack(reader) |
| 57 | |
| 58 | obj = instruction_id() |
| 59 | obj.type = reader.read("!H")[0] |
| 60 | _len = reader.read("!H")[0] |
| 61 | orig_reader = reader |
| 62 | reader = orig_reader.slice(_len - (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("instruction_id {") |
| 72 | with q.group(): |
| 73 | with q.indent(2): |
| 74 | q.breakable() |
| 75 | q.breakable() |
| 76 | q.text('}') |
| 77 | |
| 78 | |
| 79 | class apply_actions(instruction_id): |
| 80 | type = 4 |
| 81 | |
| 82 | def __init__(self): |
| 83 | return |
| 84 | |
| 85 | def pack(self): |
| 86 | packed = [] |
| 87 | packed.append(struct.pack("!H", self.type)) |
| 88 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 89 | length = sum([len(x) for x in packed]) |
| 90 | packed[1] = struct.pack("!H", length) |
| 91 | return ''.join(packed) |
| 92 | |
| 93 | @staticmethod |
| 94 | def unpack(reader): |
| 95 | obj = apply_actions() |
| 96 | _type = reader.read("!H")[0] |
| 97 | assert(_type == 4) |
| 98 | _len = reader.read("!H")[0] |
| 99 | orig_reader = reader |
| 100 | reader = orig_reader.slice(_len - (2 + 2)) |
| 101 | return obj |
| 102 | |
| 103 | def __eq__(self, other): |
| 104 | if type(self) != type(other): return False |
| 105 | return True |
| 106 | |
| 107 | def pretty_print(self, q): |
| 108 | q.text("apply_actions {") |
| 109 | with q.group(): |
| 110 | with q.indent(2): |
| 111 | q.breakable() |
| 112 | q.breakable() |
| 113 | q.text('}') |
| 114 | |
| 115 | instruction_id.subtypes[4] = apply_actions |
| 116 | |
| 117 | class clear_actions(instruction_id): |
| 118 | type = 5 |
| 119 | |
| 120 | def __init__(self): |
| 121 | return |
| 122 | |
| 123 | def pack(self): |
| 124 | packed = [] |
| 125 | packed.append(struct.pack("!H", self.type)) |
| 126 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 127 | length = sum([len(x) for x in packed]) |
| 128 | packed[1] = struct.pack("!H", length) |
| 129 | return ''.join(packed) |
| 130 | |
| 131 | @staticmethod |
| 132 | def unpack(reader): |
| 133 | obj = clear_actions() |
| 134 | _type = reader.read("!H")[0] |
| 135 | assert(_type == 5) |
| 136 | _len = reader.read("!H")[0] |
| 137 | orig_reader = reader |
| 138 | reader = orig_reader.slice(_len - (2 + 2)) |
| 139 | return obj |
| 140 | |
| 141 | def __eq__(self, other): |
| 142 | if type(self) != type(other): return False |
| 143 | return True |
| 144 | |
| 145 | def pretty_print(self, q): |
| 146 | q.text("clear_actions {") |
| 147 | with q.group(): |
| 148 | with q.indent(2): |
| 149 | q.breakable() |
| 150 | q.breakable() |
| 151 | q.text('}') |
| 152 | |
| 153 | instruction_id.subtypes[5] = clear_actions |
| 154 | |
| 155 | class experimenter(instruction_id): |
| 156 | subtypes = {} |
| 157 | |
| 158 | type = 65535 |
| 159 | |
| 160 | def __init__(self, experimenter=None): |
| 161 | if experimenter != None: |
| 162 | self.experimenter = experimenter |
| 163 | else: |
| 164 | self.experimenter = 0 |
| 165 | return |
| 166 | |
| 167 | def pack(self): |
| 168 | packed = [] |
| 169 | packed.append(struct.pack("!H", self.type)) |
| 170 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 171 | packed.append(struct.pack("!L", self.experimenter)) |
| 172 | length = sum([len(x) for x in packed]) |
| 173 | packed[1] = struct.pack("!H", length) |
| 174 | return ''.join(packed) |
| 175 | |
| 176 | @staticmethod |
| 177 | def unpack(reader): |
| 178 | subtype, = reader.peek('!L', 4) |
| 179 | subclass = experimenter.subtypes.get(subtype) |
| 180 | if subclass: |
| 181 | return subclass.unpack(reader) |
| 182 | |
| 183 | obj = experimenter() |
| 184 | _type = reader.read("!H")[0] |
| 185 | assert(_type == 65535) |
| 186 | _len = reader.read("!H")[0] |
| 187 | orig_reader = reader |
| 188 | reader = orig_reader.slice(_len - (2 + 2)) |
| 189 | obj.experimenter = reader.read("!L")[0] |
| 190 | return obj |
| 191 | |
| 192 | def __eq__(self, other): |
| 193 | if type(self) != type(other): return False |
| 194 | if self.experimenter != other.experimenter: return False |
| 195 | return True |
| 196 | |
| 197 | def pretty_print(self, q): |
| 198 | q.text("experimenter {") |
| 199 | with q.group(): |
| 200 | with q.indent(2): |
| 201 | q.breakable() |
| 202 | q.breakable() |
| 203 | q.text('}') |
| 204 | |
| 205 | instruction_id.subtypes[65535] = experimenter |
| 206 | |
| 207 | class goto_table(instruction_id): |
| 208 | type = 1 |
| 209 | |
| 210 | def __init__(self): |
| 211 | return |
| 212 | |
| 213 | def pack(self): |
| 214 | packed = [] |
| 215 | packed.append(struct.pack("!H", self.type)) |
| 216 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 217 | length = sum([len(x) for x in packed]) |
| 218 | packed[1] = struct.pack("!H", length) |
| 219 | return ''.join(packed) |
| 220 | |
| 221 | @staticmethod |
| 222 | def unpack(reader): |
| 223 | obj = goto_table() |
| 224 | _type = reader.read("!H")[0] |
| 225 | assert(_type == 1) |
| 226 | _len = reader.read("!H")[0] |
| 227 | orig_reader = reader |
| 228 | reader = orig_reader.slice(_len - (2 + 2)) |
| 229 | return obj |
| 230 | |
| 231 | def __eq__(self, other): |
| 232 | if type(self) != type(other): return False |
| 233 | return True |
| 234 | |
| 235 | def pretty_print(self, q): |
| 236 | q.text("goto_table {") |
| 237 | with q.group(): |
| 238 | with q.indent(2): |
| 239 | q.breakable() |
| 240 | q.breakable() |
| 241 | q.text('}') |
| 242 | |
| 243 | instruction_id.subtypes[1] = goto_table |
| 244 | |
| 245 | class meter(instruction_id): |
| 246 | type = 6 |
| 247 | |
| 248 | def __init__(self): |
| 249 | return |
| 250 | |
| 251 | def pack(self): |
| 252 | packed = [] |
| 253 | packed.append(struct.pack("!H", self.type)) |
| 254 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 255 | length = sum([len(x) for x in packed]) |
| 256 | packed[1] = struct.pack("!H", length) |
| 257 | return ''.join(packed) |
| 258 | |
| 259 | @staticmethod |
| 260 | def unpack(reader): |
| 261 | obj = meter() |
| 262 | _type = reader.read("!H")[0] |
| 263 | assert(_type == 6) |
| 264 | _len = reader.read("!H")[0] |
| 265 | orig_reader = reader |
| 266 | reader = orig_reader.slice(_len - (2 + 2)) |
| 267 | return obj |
| 268 | |
| 269 | def __eq__(self, other): |
| 270 | if type(self) != type(other): return False |
| 271 | return True |
| 272 | |
| 273 | def pretty_print(self, q): |
| 274 | q.text("meter {") |
| 275 | with q.group(): |
| 276 | with q.indent(2): |
| 277 | q.breakable() |
| 278 | q.breakable() |
| 279 | q.text('}') |
| 280 | |
| 281 | instruction_id.subtypes[6] = meter |
| 282 | |
| 283 | class write_actions(instruction_id): |
| 284 | type = 3 |
| 285 | |
| 286 | def __init__(self): |
| 287 | return |
| 288 | |
| 289 | def pack(self): |
| 290 | packed = [] |
| 291 | packed.append(struct.pack("!H", self.type)) |
| 292 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 293 | length = sum([len(x) for x in packed]) |
| 294 | packed[1] = struct.pack("!H", length) |
| 295 | return ''.join(packed) |
| 296 | |
| 297 | @staticmethod |
| 298 | def unpack(reader): |
| 299 | obj = write_actions() |
| 300 | _type = reader.read("!H")[0] |
| 301 | assert(_type == 3) |
| 302 | _len = reader.read("!H")[0] |
| 303 | orig_reader = reader |
| 304 | reader = orig_reader.slice(_len - (2 + 2)) |
| 305 | return obj |
| 306 | |
| 307 | def __eq__(self, other): |
| 308 | if type(self) != type(other): return False |
| 309 | return True |
| 310 | |
| 311 | def pretty_print(self, q): |
| 312 | q.text("write_actions {") |
| 313 | with q.group(): |
| 314 | with q.indent(2): |
| 315 | q.breakable() |
| 316 | q.breakable() |
| 317 | q.text('}') |
| 318 | |
| 319 | instruction_id.subtypes[3] = write_actions |
| 320 | |
| 321 | class write_metadata(instruction_id): |
| 322 | type = 2 |
| 323 | |
| 324 | def __init__(self): |
| 325 | return |
| 326 | |
| 327 | def pack(self): |
| 328 | packed = [] |
| 329 | packed.append(struct.pack("!H", self.type)) |
| 330 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 331 | length = sum([len(x) for x in packed]) |
| 332 | packed[1] = struct.pack("!H", length) |
| 333 | return ''.join(packed) |
| 334 | |
| 335 | @staticmethod |
| 336 | def unpack(reader): |
| 337 | obj = write_metadata() |
| 338 | _type = reader.read("!H")[0] |
| 339 | assert(_type == 2) |
| 340 | _len = reader.read("!H")[0] |
| 341 | orig_reader = reader |
| 342 | reader = orig_reader.slice(_len - (2 + 2)) |
| 343 | return obj |
| 344 | |
| 345 | def __eq__(self, other): |
| 346 | if type(self) != type(other): return False |
| 347 | return True |
| 348 | |
| 349 | def pretty_print(self, q): |
| 350 | q.text("write_metadata {") |
| 351 | with q.group(): |
| 352 | with q.indent(2): |
| 353 | q.breakable() |
| 354 | q.breakable() |
| 355 | q.text('}') |
| 356 | |
| 357 | instruction_id.subtypes[2] = write_metadata |
| 358 | |
| 359 | |