Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [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 common |
| 13 | import action |
| 14 | import instruction |
| 15 | import oxm |
| 16 | import action_id |
| 17 | import instruction_id |
| 18 | import meter_band |
Rich Lane | 1a82041 | 2014-01-06 14:15:07 -0800 | [diff] [blame] | 19 | import bsn_tlv |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 20 | import util |
| 21 | import loxi.generic_util |
| 22 | |
| 23 | class instruction_id(loxi.OFObject): |
| 24 | subtypes = {} |
| 25 | |
| 26 | @staticmethod |
| 27 | def unpack(reader): |
| 28 | subtype, = reader.peek('!H', 0) |
| 29 | try: |
| 30 | subclass = instruction_id.subtypes[subtype] |
| 31 | except KeyError: |
| 32 | raise loxi.ProtocolError("unknown instruction_id subtype %#x" % subtype) |
| 33 | return subclass.unpack(reader) |
| 34 | |
| 35 | |
| 36 | class apply_actions(instruction_id): |
| 37 | type = 4 |
| 38 | |
| 39 | def __init__(self): |
| 40 | return |
| 41 | |
| 42 | def pack(self): |
| 43 | packed = [] |
| 44 | packed.append(struct.pack("!H", self.type)) |
| 45 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 46 | packed.append('\x00' * 4) |
| 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 | obj = apply_actions() |
| 54 | _type = reader.read("!H")[0] |
| 55 | assert(_type == 4) |
| 56 | _len = reader.read("!H")[0] |
| 57 | orig_reader = reader |
| 58 | reader = orig_reader.slice(_len - (2 + 2)) |
| 59 | reader.skip(4) |
| 60 | return obj |
| 61 | |
| 62 | def __eq__(self, other): |
| 63 | if type(self) != type(other): return False |
| 64 | return True |
| 65 | |
| 66 | def pretty_print(self, q): |
| 67 | q.text("apply_actions {") |
| 68 | with q.group(): |
| 69 | with q.indent(2): |
| 70 | q.breakable() |
| 71 | q.breakable() |
| 72 | q.text('}') |
| 73 | |
| 74 | instruction_id.subtypes[4] = apply_actions |
| 75 | |
| 76 | class experimenter(instruction_id): |
| 77 | subtypes = {} |
| 78 | |
| 79 | @staticmethod |
| 80 | def unpack(reader): |
| 81 | subtype, = reader.peek('!L', 4) |
| 82 | try: |
| 83 | subclass = experimenter.subtypes[subtype] |
| 84 | except KeyError: |
| 85 | raise loxi.ProtocolError("unknown experimenter instruction_id subtype %#x" % subtype) |
| 86 | return subclass.unpack(reader) |
| 87 | |
| 88 | instruction_id.subtypes[65535] = experimenter |
| 89 | |
| 90 | class bsn(experimenter): |
| 91 | subtypes = {} |
| 92 | |
| 93 | @staticmethod |
| 94 | def unpack(reader): |
| 95 | subtype, = reader.peek('!L', 8) |
| 96 | try: |
| 97 | subclass = bsn.subtypes[subtype] |
| 98 | except KeyError: |
| 99 | raise loxi.ProtocolError("unknown bsn experimenter instruction_id subtype %#x" % subtype) |
| 100 | return subclass.unpack(reader) |
| 101 | |
| 102 | experimenter.subtypes[6035143] = bsn |
| 103 | |
| 104 | class bsn_disable_src_mac_check(bsn): |
| 105 | type = 65535 |
| 106 | experimenter = 6035143 |
| 107 | subtype = 0 |
| 108 | |
| 109 | def __init__(self): |
| 110 | return |
| 111 | |
| 112 | def pack(self): |
| 113 | packed = [] |
| 114 | packed.append(struct.pack("!H", self.type)) |
| 115 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 116 | packed.append(struct.pack("!L", self.experimenter)) |
| 117 | packed.append(struct.pack("!L", self.subtype)) |
| 118 | packed.append('\x00' * 4) |
| 119 | length = sum([len(x) for x in packed]) |
| 120 | packed[1] = struct.pack("!H", length) |
| 121 | return ''.join(packed) |
| 122 | |
| 123 | @staticmethod |
| 124 | def unpack(reader): |
| 125 | obj = bsn_disable_src_mac_check() |
| 126 | _type = reader.read("!H")[0] |
| 127 | assert(_type == 65535) |
| 128 | _len = reader.read("!H")[0] |
| 129 | orig_reader = reader |
| 130 | reader = orig_reader.slice(_len - (2 + 2)) |
| 131 | _experimenter = reader.read("!L")[0] |
| 132 | assert(_experimenter == 6035143) |
| 133 | _subtype = reader.read("!L")[0] |
| 134 | assert(_subtype == 0) |
| 135 | reader.skip(4) |
| 136 | return obj |
| 137 | |
| 138 | def __eq__(self, other): |
| 139 | if type(self) != type(other): return False |
| 140 | return True |
| 141 | |
| 142 | def pretty_print(self, q): |
| 143 | q.text("bsn_disable_src_mac_check {") |
| 144 | with q.group(): |
| 145 | with q.indent(2): |
| 146 | q.breakable() |
| 147 | q.breakable() |
| 148 | q.text('}') |
| 149 | |
| 150 | bsn.subtypes[0] = bsn_disable_src_mac_check |
| 151 | |
| 152 | class clear_actions(instruction_id): |
| 153 | type = 5 |
| 154 | |
| 155 | def __init__(self): |
| 156 | return |
| 157 | |
| 158 | def pack(self): |
| 159 | packed = [] |
| 160 | packed.append(struct.pack("!H", self.type)) |
| 161 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 162 | packed.append('\x00' * 4) |
| 163 | length = sum([len(x) for x in packed]) |
| 164 | packed[1] = struct.pack("!H", length) |
| 165 | return ''.join(packed) |
| 166 | |
| 167 | @staticmethod |
| 168 | def unpack(reader): |
| 169 | obj = clear_actions() |
| 170 | _type = reader.read("!H")[0] |
| 171 | assert(_type == 5) |
| 172 | _len = reader.read("!H")[0] |
| 173 | orig_reader = reader |
| 174 | reader = orig_reader.slice(_len - (2 + 2)) |
| 175 | reader.skip(4) |
| 176 | return obj |
| 177 | |
| 178 | def __eq__(self, other): |
| 179 | if type(self) != type(other): return False |
| 180 | return True |
| 181 | |
| 182 | def pretty_print(self, q): |
| 183 | q.text("clear_actions {") |
| 184 | with q.group(): |
| 185 | with q.indent(2): |
| 186 | q.breakable() |
| 187 | q.breakable() |
| 188 | q.text('}') |
| 189 | |
| 190 | instruction_id.subtypes[5] = clear_actions |
| 191 | |
| 192 | class goto_table(instruction_id): |
| 193 | type = 1 |
| 194 | |
| 195 | def __init__(self): |
| 196 | return |
| 197 | |
| 198 | def pack(self): |
| 199 | packed = [] |
| 200 | packed.append(struct.pack("!H", self.type)) |
| 201 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 202 | packed.append('\x00' * 3) |
| 203 | length = sum([len(x) for x in packed]) |
| 204 | packed[1] = struct.pack("!H", length) |
| 205 | return ''.join(packed) |
| 206 | |
| 207 | @staticmethod |
| 208 | def unpack(reader): |
| 209 | obj = goto_table() |
| 210 | _type = reader.read("!H")[0] |
| 211 | assert(_type == 1) |
| 212 | _len = reader.read("!H")[0] |
| 213 | orig_reader = reader |
| 214 | reader = orig_reader.slice(_len - (2 + 2)) |
| 215 | reader.skip(3) |
| 216 | return obj |
| 217 | |
| 218 | def __eq__(self, other): |
| 219 | if type(self) != type(other): return False |
| 220 | return True |
| 221 | |
| 222 | def pretty_print(self, q): |
| 223 | q.text("goto_table {") |
| 224 | with q.group(): |
| 225 | with q.indent(2): |
| 226 | q.breakable() |
| 227 | q.breakable() |
| 228 | q.text('}') |
| 229 | |
| 230 | instruction_id.subtypes[1] = goto_table |
| 231 | |
| 232 | class meter(instruction_id): |
| 233 | type = 6 |
| 234 | |
| 235 | def __init__(self): |
| 236 | return |
| 237 | |
| 238 | def pack(self): |
| 239 | packed = [] |
| 240 | packed.append(struct.pack("!H", self.type)) |
| 241 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 242 | length = sum([len(x) for x in packed]) |
| 243 | packed[1] = struct.pack("!H", length) |
| 244 | return ''.join(packed) |
| 245 | |
| 246 | @staticmethod |
| 247 | def unpack(reader): |
| 248 | obj = meter() |
| 249 | _type = reader.read("!H")[0] |
| 250 | assert(_type == 6) |
| 251 | _len = reader.read("!H")[0] |
| 252 | orig_reader = reader |
| 253 | reader = orig_reader.slice(_len - (2 + 2)) |
| 254 | return obj |
| 255 | |
| 256 | def __eq__(self, other): |
| 257 | if type(self) != type(other): return False |
| 258 | return True |
| 259 | |
| 260 | def pretty_print(self, q): |
| 261 | q.text("meter {") |
| 262 | with q.group(): |
| 263 | with q.indent(2): |
| 264 | q.breakable() |
| 265 | q.breakable() |
| 266 | q.text('}') |
| 267 | |
| 268 | instruction_id.subtypes[6] = meter |
| 269 | |
| 270 | class write_actions(instruction_id): |
| 271 | type = 3 |
| 272 | |
| 273 | def __init__(self): |
| 274 | return |
| 275 | |
| 276 | def pack(self): |
| 277 | packed = [] |
| 278 | packed.append(struct.pack("!H", self.type)) |
| 279 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 280 | packed.append('\x00' * 4) |
| 281 | length = sum([len(x) for x in packed]) |
| 282 | packed[1] = struct.pack("!H", length) |
| 283 | return ''.join(packed) |
| 284 | |
| 285 | @staticmethod |
| 286 | def unpack(reader): |
| 287 | obj = write_actions() |
| 288 | _type = reader.read("!H")[0] |
| 289 | assert(_type == 3) |
| 290 | _len = reader.read("!H")[0] |
| 291 | orig_reader = reader |
| 292 | reader = orig_reader.slice(_len - (2 + 2)) |
| 293 | reader.skip(4) |
| 294 | return obj |
| 295 | |
| 296 | def __eq__(self, other): |
| 297 | if type(self) != type(other): return False |
| 298 | return True |
| 299 | |
| 300 | def pretty_print(self, q): |
| 301 | q.text("write_actions {") |
| 302 | with q.group(): |
| 303 | with q.indent(2): |
| 304 | q.breakable() |
| 305 | q.breakable() |
| 306 | q.text('}') |
| 307 | |
| 308 | instruction_id.subtypes[3] = write_actions |
| 309 | |
| 310 | class write_metadata(instruction_id): |
| 311 | type = 2 |
| 312 | |
| 313 | def __init__(self): |
| 314 | return |
| 315 | |
| 316 | def pack(self): |
| 317 | packed = [] |
| 318 | packed.append(struct.pack("!H", self.type)) |
| 319 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 320 | packed.append('\x00' * 4) |
| 321 | length = sum([len(x) for x in packed]) |
| 322 | packed[1] = struct.pack("!H", length) |
| 323 | return ''.join(packed) |
| 324 | |
| 325 | @staticmethod |
| 326 | def unpack(reader): |
| 327 | obj = write_metadata() |
| 328 | _type = reader.read("!H")[0] |
| 329 | assert(_type == 2) |
| 330 | _len = reader.read("!H")[0] |
| 331 | orig_reader = reader |
| 332 | reader = orig_reader.slice(_len - (2 + 2)) |
| 333 | reader.skip(4) |
| 334 | return obj |
| 335 | |
| 336 | def __eq__(self, other): |
| 337 | if type(self) != type(other): return False |
| 338 | return True |
| 339 | |
| 340 | def pretty_print(self, q): |
| 341 | q.text("write_metadata {") |
| 342 | with q.group(): |
| 343 | with q.indent(2): |
| 344 | q.breakable() |
| 345 | q.breakable() |
| 346 | q.text('}') |
| 347 | |
| 348 | instruction_id.subtypes[2] = write_metadata |
| 349 | |
| 350 | |