Rich Lane | ca3da27 | 2013-05-05 09:07:33 -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. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 5 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6 | # Automatically generated by LOXI from template module.py |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 7 | # Do not modify |
| 8 | |
| 9 | import struct |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 10 | import loxi |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 11 | import const |
Harshmeet Singh | 1db4633 | 2014-10-14 16:29:13 -0700 | [diff] [blame] | 12 | import bsn_tlv |
| 13 | import meter_band |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 14 | import instruction |
| 15 | import oxm |
Harshmeet Singh | 1db4633 | 2014-10-14 16:29:13 -0700 | [diff] [blame] | 16 | import common |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 17 | import instruction_id |
Harshmeet Singh | 1db4633 | 2014-10-14 16:29:13 -0700 | [diff] [blame] | 18 | import action |
| 19 | import message |
| 20 | import action_id |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 21 | import util |
| 22 | import loxi.generic_util |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 23 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 24 | class instruction(loxi.OFObject): |
| 25 | subtypes = {} |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 26 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 27 | |
| 28 | def __init__(self, type=None): |
| 29 | if type != None: |
| 30 | self.type = type |
| 31 | else: |
| 32 | self.type = 0 |
| 33 | return |
| 34 | |
| 35 | def pack(self): |
| 36 | packed = [] |
| 37 | packed.append(struct.pack("!H", self.type)) |
| 38 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 39 | length = sum([len(x) for x in packed]) |
| 40 | packed[1] = struct.pack("!H", length) |
| 41 | return ''.join(packed) |
| 42 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 43 | @staticmethod |
| 44 | def unpack(reader): |
| 45 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 46 | subclass = instruction.subtypes.get(subtype) |
| 47 | if subclass: |
| 48 | return subclass.unpack(reader) |
| 49 | |
| 50 | obj = instruction() |
| 51 | obj.type = reader.read("!H")[0] |
| 52 | _len = reader.read("!H")[0] |
| 53 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 54 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 55 | return obj |
| 56 | |
| 57 | def __eq__(self, other): |
| 58 | if type(self) != type(other): return False |
| 59 | if self.type != other.type: return False |
| 60 | return True |
| 61 | |
| 62 | def pretty_print(self, q): |
| 63 | q.text("instruction {") |
| 64 | with q.group(): |
| 65 | with q.indent(2): |
| 66 | q.breakable() |
| 67 | q.breakable() |
| 68 | q.text('}') |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 69 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 70 | |
| 71 | class apply_actions(instruction): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 72 | type = 4 |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 73 | |
| 74 | def __init__(self, actions=None): |
| 75 | if actions != None: |
| 76 | self.actions = actions |
| 77 | else: |
| 78 | self.actions = [] |
| 79 | return |
| 80 | |
| 81 | def pack(self): |
| 82 | packed = [] |
| 83 | packed.append(struct.pack("!H", self.type)) |
| 84 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 85 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 86 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 87 | length = sum([len(x) for x in packed]) |
| 88 | packed[1] = struct.pack("!H", length) |
| 89 | return ''.join(packed) |
| 90 | |
| 91 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 92 | def unpack(reader): |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 93 | obj = apply_actions() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 94 | _type = reader.read("!H")[0] |
| 95 | assert(_type == 4) |
| 96 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 97 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 98 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 99 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 100 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 101 | return obj |
| 102 | |
| 103 | def __eq__(self, other): |
| 104 | if type(self) != type(other): return False |
| 105 | if self.actions != other.actions: return False |
| 106 | return True |
| 107 | |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 108 | def pretty_print(self, q): |
| 109 | q.text("apply_actions {") |
| 110 | with q.group(): |
| 111 | with q.indent(2): |
| 112 | q.breakable() |
| 113 | q.text("actions = "); |
| 114 | q.pp(self.actions) |
| 115 | q.breakable() |
| 116 | q.text('}') |
| 117 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 118 | instruction.subtypes[4] = apply_actions |
| 119 | |
| 120 | class experimenter(instruction): |
| 121 | subtypes = {} |
| 122 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 123 | type = 65535 |
| 124 | |
| 125 | def __init__(self, experimenter=None, data=None): |
| 126 | if experimenter != None: |
| 127 | self.experimenter = experimenter |
| 128 | else: |
| 129 | self.experimenter = 0 |
| 130 | if data != None: |
| 131 | self.data = data |
| 132 | else: |
| 133 | self.data = '' |
| 134 | return |
| 135 | |
| 136 | def pack(self): |
| 137 | packed = [] |
| 138 | packed.append(struct.pack("!H", self.type)) |
| 139 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 140 | packed.append(struct.pack("!L", self.experimenter)) |
| 141 | packed.append(self.data) |
| 142 | length = sum([len(x) for x in packed]) |
| 143 | packed[1] = struct.pack("!H", length) |
| 144 | return ''.join(packed) |
| 145 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 146 | @staticmethod |
| 147 | def unpack(reader): |
| 148 | subtype, = reader.peek('!L', 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 149 | subclass = experimenter.subtypes.get(subtype) |
| 150 | if subclass: |
| 151 | return subclass.unpack(reader) |
| 152 | |
| 153 | obj = experimenter() |
| 154 | _type = reader.read("!H")[0] |
| 155 | assert(_type == 65535) |
| 156 | _len = reader.read("!H")[0] |
| 157 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 158 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 159 | obj.experimenter = reader.read("!L")[0] |
| 160 | obj.data = str(reader.read_all()) |
| 161 | return obj |
| 162 | |
| 163 | def __eq__(self, other): |
| 164 | if type(self) != type(other): return False |
| 165 | if self.experimenter != other.experimenter: return False |
| 166 | if self.data != other.data: return False |
| 167 | return True |
| 168 | |
| 169 | def pretty_print(self, q): |
| 170 | q.text("experimenter {") |
| 171 | with q.group(): |
| 172 | with q.indent(2): |
| 173 | q.breakable() |
| 174 | q.text("data = "); |
| 175 | q.pp(self.data) |
| 176 | q.breakable() |
| 177 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 178 | |
| 179 | instruction.subtypes[65535] = experimenter |
| 180 | |
| 181 | class bsn(experimenter): |
| 182 | subtypes = {} |
| 183 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 184 | type = 65535 |
| 185 | experimenter = 6035143 |
| 186 | |
| 187 | def __init__(self, subtype=None): |
| 188 | if subtype != None: |
| 189 | self.subtype = subtype |
| 190 | else: |
| 191 | self.subtype = 0 |
| 192 | return |
| 193 | |
| 194 | def pack(self): |
| 195 | packed = [] |
| 196 | packed.append(struct.pack("!H", self.type)) |
| 197 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 198 | packed.append(struct.pack("!L", self.experimenter)) |
| 199 | packed.append(struct.pack("!L", self.subtype)) |
| 200 | packed.append('\x00' * 4) |
| 201 | length = sum([len(x) for x in packed]) |
| 202 | packed[1] = struct.pack("!H", length) |
| 203 | return ''.join(packed) |
| 204 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 205 | @staticmethod |
| 206 | def unpack(reader): |
| 207 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 208 | subclass = bsn.subtypes.get(subtype) |
| 209 | if subclass: |
| 210 | return subclass.unpack(reader) |
| 211 | |
| 212 | obj = bsn() |
| 213 | _type = reader.read("!H")[0] |
| 214 | assert(_type == 65535) |
| 215 | _len = reader.read("!H")[0] |
| 216 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 217 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 218 | _experimenter = reader.read("!L")[0] |
| 219 | assert(_experimenter == 6035143) |
| 220 | obj.subtype = reader.read("!L")[0] |
| 221 | reader.skip(4) |
| 222 | return obj |
| 223 | |
| 224 | def __eq__(self, other): |
| 225 | if type(self) != type(other): return False |
| 226 | if self.subtype != other.subtype: return False |
| 227 | return True |
| 228 | |
| 229 | def pretty_print(self, q): |
| 230 | q.text("bsn {") |
| 231 | with q.group(): |
| 232 | with q.indent(2): |
| 233 | q.breakable() |
| 234 | q.breakable() |
| 235 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 236 | |
| 237 | experimenter.subtypes[6035143] = bsn |
| 238 | |
Rich Lane | 5454b68 | 2014-01-14 17:07:36 -0800 | [diff] [blame] | 239 | class bsn_arp_offload(bsn): |
| 240 | type = 65535 |
| 241 | experimenter = 6035143 |
| 242 | subtype = 1 |
| 243 | |
| 244 | def __init__(self): |
| 245 | return |
| 246 | |
| 247 | def pack(self): |
| 248 | packed = [] |
| 249 | packed.append(struct.pack("!H", self.type)) |
| 250 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 251 | packed.append(struct.pack("!L", self.experimenter)) |
| 252 | packed.append(struct.pack("!L", self.subtype)) |
| 253 | packed.append('\x00' * 4) |
| 254 | length = sum([len(x) for x in packed]) |
| 255 | packed[1] = struct.pack("!H", length) |
| 256 | return ''.join(packed) |
| 257 | |
| 258 | @staticmethod |
| 259 | def unpack(reader): |
| 260 | obj = bsn_arp_offload() |
| 261 | _type = reader.read("!H")[0] |
| 262 | assert(_type == 65535) |
| 263 | _len = reader.read("!H")[0] |
| 264 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 265 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 5454b68 | 2014-01-14 17:07:36 -0800 | [diff] [blame] | 266 | _experimenter = reader.read("!L")[0] |
| 267 | assert(_experimenter == 6035143) |
| 268 | _subtype = reader.read("!L")[0] |
| 269 | assert(_subtype == 1) |
| 270 | reader.skip(4) |
| 271 | return obj |
| 272 | |
| 273 | def __eq__(self, other): |
| 274 | if type(self) != type(other): return False |
| 275 | return True |
| 276 | |
| 277 | def pretty_print(self, q): |
| 278 | q.text("bsn_arp_offload {") |
| 279 | with q.group(): |
| 280 | with q.indent(2): |
| 281 | q.breakable() |
| 282 | q.breakable() |
| 283 | q.text('}') |
| 284 | |
| 285 | bsn.subtypes[1] = bsn_arp_offload |
| 286 | |
Harshmeet Singh | 301f717 | 2014-12-08 13:07:29 -0800 | [diff] [blame] | 287 | class bsn_auto_negotiation(bsn): |
| 288 | type = 65535 |
| 289 | experimenter = 6035143 |
| 290 | subtype = 11 |
| 291 | |
| 292 | def __init__(self): |
| 293 | return |
| 294 | |
| 295 | def pack(self): |
| 296 | packed = [] |
| 297 | packed.append(struct.pack("!H", self.type)) |
| 298 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 299 | packed.append(struct.pack("!L", self.experimenter)) |
| 300 | packed.append(struct.pack("!L", self.subtype)) |
| 301 | packed.append('\x00' * 4) |
| 302 | length = sum([len(x) for x in packed]) |
| 303 | packed[1] = struct.pack("!H", length) |
| 304 | return ''.join(packed) |
| 305 | |
| 306 | @staticmethod |
| 307 | def unpack(reader): |
| 308 | obj = bsn_auto_negotiation() |
| 309 | _type = reader.read("!H")[0] |
| 310 | assert(_type == 65535) |
| 311 | _len = reader.read("!H")[0] |
| 312 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 313 | reader = orig_reader.slice(_len, 4) |
Harshmeet Singh | 301f717 | 2014-12-08 13:07:29 -0800 | [diff] [blame] | 314 | _experimenter = reader.read("!L")[0] |
| 315 | assert(_experimenter == 6035143) |
| 316 | _subtype = reader.read("!L")[0] |
| 317 | assert(_subtype == 11) |
| 318 | reader.skip(4) |
| 319 | return obj |
| 320 | |
| 321 | def __eq__(self, other): |
| 322 | if type(self) != type(other): return False |
| 323 | return True |
| 324 | |
| 325 | def pretty_print(self, q): |
| 326 | q.text("bsn_auto_negotiation {") |
| 327 | with q.group(): |
| 328 | with q.indent(2): |
| 329 | q.breakable() |
| 330 | q.breakable() |
| 331 | q.text('}') |
| 332 | |
| 333 | bsn.subtypes[11] = bsn_auto_negotiation |
| 334 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 335 | class bsn_deny(bsn): |
| 336 | type = 65535 |
| 337 | experimenter = 6035143 |
| 338 | subtype = 5 |
| 339 | |
| 340 | def __init__(self): |
| 341 | return |
| 342 | |
| 343 | def pack(self): |
| 344 | packed = [] |
| 345 | packed.append(struct.pack("!H", self.type)) |
| 346 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 347 | packed.append(struct.pack("!L", self.experimenter)) |
| 348 | packed.append(struct.pack("!L", self.subtype)) |
| 349 | packed.append('\x00' * 4) |
| 350 | length = sum([len(x) for x in packed]) |
| 351 | packed[1] = struct.pack("!H", length) |
| 352 | return ''.join(packed) |
| 353 | |
| 354 | @staticmethod |
| 355 | def unpack(reader): |
| 356 | obj = bsn_deny() |
| 357 | _type = reader.read("!H")[0] |
| 358 | assert(_type == 65535) |
| 359 | _len = reader.read("!H")[0] |
| 360 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 361 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 362 | _experimenter = reader.read("!L")[0] |
| 363 | assert(_experimenter == 6035143) |
| 364 | _subtype = reader.read("!L")[0] |
| 365 | assert(_subtype == 5) |
| 366 | reader.skip(4) |
| 367 | return obj |
| 368 | |
| 369 | def __eq__(self, other): |
| 370 | if type(self) != type(other): return False |
| 371 | return True |
| 372 | |
| 373 | def pretty_print(self, q): |
| 374 | q.text("bsn_deny {") |
| 375 | with q.group(): |
| 376 | with q.indent(2): |
| 377 | q.breakable() |
| 378 | q.breakable() |
| 379 | q.text('}') |
| 380 | |
| 381 | bsn.subtypes[5] = bsn_deny |
| 382 | |
Rich Lane | 1b75abf | 2014-02-05 11:23:20 -0800 | [diff] [blame] | 383 | class bsn_dhcp_offload(bsn): |
| 384 | type = 65535 |
| 385 | experimenter = 6035143 |
| 386 | subtype = 2 |
| 387 | |
| 388 | def __init__(self): |
| 389 | return |
| 390 | |
| 391 | def pack(self): |
| 392 | packed = [] |
| 393 | packed.append(struct.pack("!H", self.type)) |
| 394 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 395 | packed.append(struct.pack("!L", self.experimenter)) |
| 396 | packed.append(struct.pack("!L", self.subtype)) |
| 397 | packed.append('\x00' * 4) |
| 398 | length = sum([len(x) for x in packed]) |
| 399 | packed[1] = struct.pack("!H", length) |
| 400 | return ''.join(packed) |
| 401 | |
| 402 | @staticmethod |
| 403 | def unpack(reader): |
| 404 | obj = bsn_dhcp_offload() |
| 405 | _type = reader.read("!H")[0] |
| 406 | assert(_type == 65535) |
| 407 | _len = reader.read("!H")[0] |
| 408 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 409 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 1b75abf | 2014-02-05 11:23:20 -0800 | [diff] [blame] | 410 | _experimenter = reader.read("!L")[0] |
| 411 | assert(_experimenter == 6035143) |
| 412 | _subtype = reader.read("!L")[0] |
| 413 | assert(_subtype == 2) |
| 414 | reader.skip(4) |
| 415 | return obj |
| 416 | |
| 417 | def __eq__(self, other): |
| 418 | if type(self) != type(other): return False |
| 419 | return True |
| 420 | |
| 421 | def pretty_print(self, q): |
| 422 | q.text("bsn_dhcp_offload {") |
| 423 | with q.group(): |
| 424 | with q.indent(2): |
| 425 | q.breakable() |
| 426 | q.breakable() |
| 427 | q.text('}') |
| 428 | |
| 429 | bsn.subtypes[2] = bsn_dhcp_offload |
| 430 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 431 | class bsn_disable_split_horizon_check(bsn): |
| 432 | type = 65535 |
| 433 | experimenter = 6035143 |
| 434 | subtype = 3 |
| 435 | |
| 436 | def __init__(self): |
| 437 | return |
| 438 | |
| 439 | def pack(self): |
| 440 | packed = [] |
| 441 | packed.append(struct.pack("!H", self.type)) |
| 442 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 443 | packed.append(struct.pack("!L", self.experimenter)) |
| 444 | packed.append(struct.pack("!L", self.subtype)) |
| 445 | packed.append('\x00' * 4) |
| 446 | length = sum([len(x) for x in packed]) |
| 447 | packed[1] = struct.pack("!H", length) |
| 448 | return ''.join(packed) |
| 449 | |
| 450 | @staticmethod |
| 451 | def unpack(reader): |
| 452 | obj = bsn_disable_split_horizon_check() |
| 453 | _type = reader.read("!H")[0] |
| 454 | assert(_type == 65535) |
| 455 | _len = reader.read("!H")[0] |
| 456 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 457 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 458 | _experimenter = reader.read("!L")[0] |
| 459 | assert(_experimenter == 6035143) |
| 460 | _subtype = reader.read("!L")[0] |
| 461 | assert(_subtype == 3) |
| 462 | reader.skip(4) |
| 463 | return obj |
| 464 | |
| 465 | def __eq__(self, other): |
| 466 | if type(self) != type(other): return False |
| 467 | return True |
| 468 | |
| 469 | def pretty_print(self, q): |
| 470 | q.text("bsn_disable_split_horizon_check {") |
| 471 | with q.group(): |
| 472 | with q.indent(2): |
| 473 | q.breakable() |
| 474 | q.breakable() |
| 475 | q.text('}') |
| 476 | |
| 477 | bsn.subtypes[3] = bsn_disable_split_horizon_check |
| 478 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 479 | class bsn_disable_src_mac_check(bsn): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 480 | type = 65535 |
| 481 | experimenter = 6035143 |
| 482 | subtype = 0 |
| 483 | |
| 484 | def __init__(self): |
| 485 | return |
| 486 | |
| 487 | def pack(self): |
| 488 | packed = [] |
| 489 | packed.append(struct.pack("!H", self.type)) |
| 490 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 491 | packed.append(struct.pack("!L", self.experimenter)) |
| 492 | packed.append(struct.pack("!L", self.subtype)) |
| 493 | packed.append('\x00' * 4) |
| 494 | length = sum([len(x) for x in packed]) |
| 495 | packed[1] = struct.pack("!H", length) |
| 496 | return ''.join(packed) |
| 497 | |
| 498 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 499 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 500 | obj = bsn_disable_src_mac_check() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 501 | _type = reader.read("!H")[0] |
| 502 | assert(_type == 65535) |
| 503 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 504 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 505 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 506 | _experimenter = reader.read("!L")[0] |
| 507 | assert(_experimenter == 6035143) |
| 508 | _subtype = reader.read("!L")[0] |
| 509 | assert(_subtype == 0) |
| 510 | reader.skip(4) |
| 511 | return obj |
| 512 | |
| 513 | def __eq__(self, other): |
| 514 | if type(self) != type(other): return False |
| 515 | return True |
| 516 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 517 | def pretty_print(self, q): |
| 518 | q.text("bsn_disable_src_mac_check {") |
| 519 | with q.group(): |
| 520 | with q.indent(2): |
| 521 | q.breakable() |
| 522 | q.breakable() |
| 523 | q.text('}') |
| 524 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 525 | bsn.subtypes[0] = bsn_disable_src_mac_check |
| 526 | |
Harshmeet Singh | c0378a9 | 2014-07-22 17:09:36 -0700 | [diff] [blame] | 527 | class bsn_disable_vlan_counters(bsn): |
| 528 | type = 65535 |
| 529 | experimenter = 6035143 |
| 530 | subtype = 9 |
| 531 | |
| 532 | def __init__(self): |
| 533 | return |
| 534 | |
| 535 | def pack(self): |
| 536 | packed = [] |
| 537 | packed.append(struct.pack("!H", self.type)) |
| 538 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 539 | packed.append(struct.pack("!L", self.experimenter)) |
| 540 | packed.append(struct.pack("!L", self.subtype)) |
| 541 | packed.append('\x00' * 4) |
| 542 | length = sum([len(x) for x in packed]) |
| 543 | packed[1] = struct.pack("!H", length) |
| 544 | return ''.join(packed) |
| 545 | |
| 546 | @staticmethod |
| 547 | def unpack(reader): |
| 548 | obj = bsn_disable_vlan_counters() |
| 549 | _type = reader.read("!H")[0] |
| 550 | assert(_type == 65535) |
| 551 | _len = reader.read("!H")[0] |
| 552 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 553 | reader = orig_reader.slice(_len, 4) |
Harshmeet Singh | c0378a9 | 2014-07-22 17:09:36 -0700 | [diff] [blame] | 554 | _experimenter = reader.read("!L")[0] |
| 555 | assert(_experimenter == 6035143) |
| 556 | _subtype = reader.read("!L")[0] |
| 557 | assert(_subtype == 9) |
| 558 | reader.skip(4) |
| 559 | return obj |
| 560 | |
| 561 | def __eq__(self, other): |
| 562 | if type(self) != type(other): return False |
| 563 | return True |
| 564 | |
| 565 | def pretty_print(self, q): |
| 566 | q.text("bsn_disable_vlan_counters {") |
| 567 | with q.group(): |
| 568 | with q.indent(2): |
| 569 | q.breakable() |
| 570 | q.breakable() |
| 571 | q.text('}') |
| 572 | |
| 573 | bsn.subtypes[9] = bsn_disable_vlan_counters |
| 574 | |
Rich Lane | f50b7c3 | 2014-03-20 11:38:02 -0700 | [diff] [blame] | 575 | class bsn_packet_of_death(bsn): |
| 576 | type = 65535 |
| 577 | experimenter = 6035143 |
| 578 | subtype = 6 |
| 579 | |
| 580 | def __init__(self): |
| 581 | return |
| 582 | |
| 583 | def pack(self): |
| 584 | packed = [] |
| 585 | packed.append(struct.pack("!H", self.type)) |
| 586 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 587 | packed.append(struct.pack("!L", self.experimenter)) |
| 588 | packed.append(struct.pack("!L", self.subtype)) |
| 589 | packed.append('\x00' * 4) |
| 590 | length = sum([len(x) for x in packed]) |
| 591 | packed[1] = struct.pack("!H", length) |
| 592 | return ''.join(packed) |
| 593 | |
| 594 | @staticmethod |
| 595 | def unpack(reader): |
| 596 | obj = bsn_packet_of_death() |
| 597 | _type = reader.read("!H")[0] |
| 598 | assert(_type == 65535) |
| 599 | _len = reader.read("!H")[0] |
| 600 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 601 | reader = orig_reader.slice(_len, 4) |
Rich Lane | f50b7c3 | 2014-03-20 11:38:02 -0700 | [diff] [blame] | 602 | _experimenter = reader.read("!L")[0] |
| 603 | assert(_experimenter == 6035143) |
| 604 | _subtype = reader.read("!L")[0] |
| 605 | assert(_subtype == 6) |
| 606 | reader.skip(4) |
| 607 | return obj |
| 608 | |
| 609 | def __eq__(self, other): |
| 610 | if type(self) != type(other): return False |
| 611 | return True |
| 612 | |
| 613 | def pretty_print(self, q): |
| 614 | q.text("bsn_packet_of_death {") |
| 615 | with q.group(): |
| 616 | with q.indent(2): |
| 617 | q.breakable() |
| 618 | q.breakable() |
| 619 | q.text('}') |
| 620 | |
| 621 | bsn.subtypes[6] = bsn_packet_of_death |
| 622 | |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 623 | class bsn_permit(bsn): |
| 624 | type = 65535 |
| 625 | experimenter = 6035143 |
| 626 | subtype = 4 |
| 627 | |
| 628 | def __init__(self): |
| 629 | return |
| 630 | |
| 631 | def pack(self): |
| 632 | packed = [] |
| 633 | packed.append(struct.pack("!H", self.type)) |
| 634 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 635 | packed.append(struct.pack("!L", self.experimenter)) |
| 636 | packed.append(struct.pack("!L", self.subtype)) |
| 637 | packed.append('\x00' * 4) |
| 638 | length = sum([len(x) for x in packed]) |
| 639 | packed[1] = struct.pack("!H", length) |
| 640 | return ''.join(packed) |
| 641 | |
| 642 | @staticmethod |
| 643 | def unpack(reader): |
| 644 | obj = bsn_permit() |
| 645 | _type = reader.read("!H")[0] |
| 646 | assert(_type == 65535) |
| 647 | _len = reader.read("!H")[0] |
| 648 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 649 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 9ec3fca | 2014-02-26 16:22:56 -0800 | [diff] [blame] | 650 | _experimenter = reader.read("!L")[0] |
| 651 | assert(_experimenter == 6035143) |
| 652 | _subtype = reader.read("!L")[0] |
| 653 | assert(_subtype == 4) |
| 654 | reader.skip(4) |
| 655 | return obj |
| 656 | |
| 657 | def __eq__(self, other): |
| 658 | if type(self) != type(other): return False |
| 659 | return True |
| 660 | |
| 661 | def pretty_print(self, q): |
| 662 | q.text("bsn_permit {") |
| 663 | with q.group(): |
| 664 | with q.indent(2): |
| 665 | q.breakable() |
| 666 | q.breakable() |
| 667 | q.text('}') |
| 668 | |
| 669 | bsn.subtypes[4] = bsn_permit |
| 670 | |
Rich Lane | 78d9bcb | 2014-05-12 13:27:44 -0700 | [diff] [blame] | 671 | class bsn_prioritize_pdus(bsn): |
| 672 | type = 65535 |
| 673 | experimenter = 6035143 |
| 674 | subtype = 7 |
| 675 | |
| 676 | def __init__(self): |
| 677 | return |
| 678 | |
| 679 | def pack(self): |
| 680 | packed = [] |
| 681 | packed.append(struct.pack("!H", self.type)) |
| 682 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 683 | packed.append(struct.pack("!L", self.experimenter)) |
| 684 | packed.append(struct.pack("!L", self.subtype)) |
| 685 | packed.append('\x00' * 4) |
| 686 | length = sum([len(x) for x in packed]) |
| 687 | packed[1] = struct.pack("!H", length) |
| 688 | return ''.join(packed) |
| 689 | |
| 690 | @staticmethod |
| 691 | def unpack(reader): |
| 692 | obj = bsn_prioritize_pdus() |
| 693 | _type = reader.read("!H")[0] |
| 694 | assert(_type == 65535) |
| 695 | _len = reader.read("!H")[0] |
| 696 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 697 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 78d9bcb | 2014-05-12 13:27:44 -0700 | [diff] [blame] | 698 | _experimenter = reader.read("!L")[0] |
| 699 | assert(_experimenter == 6035143) |
| 700 | _subtype = reader.read("!L")[0] |
| 701 | assert(_subtype == 7) |
| 702 | reader.skip(4) |
| 703 | return obj |
| 704 | |
| 705 | def __eq__(self, other): |
| 706 | if type(self) != type(other): return False |
| 707 | return True |
| 708 | |
| 709 | def pretty_print(self, q): |
| 710 | q.text("bsn_prioritize_pdus {") |
| 711 | with q.group(): |
| 712 | with q.indent(2): |
| 713 | q.breakable() |
| 714 | q.breakable() |
| 715 | q.text('}') |
| 716 | |
| 717 | bsn.subtypes[7] = bsn_prioritize_pdus |
| 718 | |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 719 | class bsn_require_vlan_xlate(bsn): |
| 720 | type = 65535 |
| 721 | experimenter = 6035143 |
| 722 | subtype = 8 |
| 723 | |
| 724 | def __init__(self): |
| 725 | return |
| 726 | |
| 727 | def pack(self): |
| 728 | packed = [] |
| 729 | packed.append(struct.pack("!H", self.type)) |
| 730 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 731 | packed.append(struct.pack("!L", self.experimenter)) |
| 732 | packed.append(struct.pack("!L", self.subtype)) |
| 733 | packed.append('\x00' * 4) |
| 734 | length = sum([len(x) for x in packed]) |
| 735 | packed[1] = struct.pack("!H", length) |
| 736 | return ''.join(packed) |
| 737 | |
| 738 | @staticmethod |
| 739 | def unpack(reader): |
| 740 | obj = bsn_require_vlan_xlate() |
| 741 | _type = reader.read("!H")[0] |
| 742 | assert(_type == 65535) |
| 743 | _len = reader.read("!H")[0] |
| 744 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 745 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 746 | _experimenter = reader.read("!L")[0] |
| 747 | assert(_experimenter == 6035143) |
| 748 | _subtype = reader.read("!L")[0] |
| 749 | assert(_subtype == 8) |
| 750 | reader.skip(4) |
| 751 | return obj |
| 752 | |
| 753 | def __eq__(self, other): |
| 754 | if type(self) != type(other): return False |
| 755 | return True |
| 756 | |
| 757 | def pretty_print(self, q): |
| 758 | q.text("bsn_require_vlan_xlate {") |
| 759 | with q.group(): |
| 760 | with q.indent(2): |
| 761 | q.breakable() |
| 762 | q.breakable() |
| 763 | q.text('}') |
| 764 | |
| 765 | bsn.subtypes[8] = bsn_require_vlan_xlate |
| 766 | |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 767 | class bsn_span_destination(bsn): |
| 768 | type = 65535 |
| 769 | experimenter = 6035143 |
| 770 | subtype = 10 |
| 771 | |
| 772 | def __init__(self): |
| 773 | return |
| 774 | |
| 775 | def pack(self): |
| 776 | packed = [] |
| 777 | packed.append(struct.pack("!H", self.type)) |
| 778 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 779 | packed.append(struct.pack("!L", self.experimenter)) |
| 780 | packed.append(struct.pack("!L", self.subtype)) |
| 781 | packed.append('\x00' * 4) |
| 782 | length = sum([len(x) for x in packed]) |
| 783 | packed[1] = struct.pack("!H", length) |
| 784 | return ''.join(packed) |
| 785 | |
| 786 | @staticmethod |
| 787 | def unpack(reader): |
| 788 | obj = bsn_span_destination() |
| 789 | _type = reader.read("!H")[0] |
| 790 | assert(_type == 65535) |
| 791 | _len = reader.read("!H")[0] |
| 792 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 793 | reader = orig_reader.slice(_len, 4) |
Rich Lane | f9530c4 | 2014-09-15 09:59:43 -0700 | [diff] [blame] | 794 | _experimenter = reader.read("!L")[0] |
| 795 | assert(_experimenter == 6035143) |
| 796 | _subtype = reader.read("!L")[0] |
| 797 | assert(_subtype == 10) |
| 798 | reader.skip(4) |
| 799 | return obj |
| 800 | |
| 801 | def __eq__(self, other): |
| 802 | if type(self) != type(other): return False |
| 803 | return True |
| 804 | |
| 805 | def pretty_print(self, q): |
| 806 | q.text("bsn_span_destination {") |
| 807 | with q.group(): |
| 808 | with q.indent(2): |
| 809 | q.breakable() |
| 810 | q.breakable() |
| 811 | q.text('}') |
| 812 | |
| 813 | bsn.subtypes[10] = bsn_span_destination |
| 814 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 815 | class clear_actions(instruction): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 816 | type = 5 |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 817 | |
| 818 | def __init__(self): |
| 819 | return |
| 820 | |
| 821 | def pack(self): |
| 822 | packed = [] |
| 823 | packed.append(struct.pack("!H", self.type)) |
| 824 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 825 | packed.append('\x00' * 4) |
| 826 | length = sum([len(x) for x in packed]) |
| 827 | packed[1] = struct.pack("!H", length) |
| 828 | return ''.join(packed) |
| 829 | |
| 830 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 831 | def unpack(reader): |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 832 | obj = clear_actions() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 833 | _type = reader.read("!H")[0] |
| 834 | assert(_type == 5) |
| 835 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 836 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 837 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 838 | reader.skip(4) |
| 839 | return obj |
| 840 | |
| 841 | def __eq__(self, other): |
| 842 | if type(self) != type(other): return False |
| 843 | return True |
| 844 | |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 845 | def pretty_print(self, q): |
| 846 | q.text("clear_actions {") |
| 847 | with q.group(): |
| 848 | with q.indent(2): |
| 849 | q.breakable() |
| 850 | q.breakable() |
| 851 | q.text('}') |
| 852 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 853 | instruction.subtypes[5] = clear_actions |
| 854 | |
| 855 | class goto_table(instruction): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 856 | type = 1 |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 857 | |
| 858 | def __init__(self, table_id=None): |
| 859 | if table_id != None: |
| 860 | self.table_id = table_id |
| 861 | else: |
| 862 | self.table_id = 0 |
| 863 | return |
| 864 | |
| 865 | def pack(self): |
| 866 | packed = [] |
| 867 | packed.append(struct.pack("!H", self.type)) |
| 868 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 869 | packed.append(struct.pack("!B", self.table_id)) |
| 870 | packed.append('\x00' * 3) |
| 871 | length = sum([len(x) for x in packed]) |
| 872 | packed[1] = struct.pack("!H", length) |
| 873 | return ''.join(packed) |
| 874 | |
| 875 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 876 | def unpack(reader): |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 877 | obj = goto_table() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 878 | _type = reader.read("!H")[0] |
| 879 | assert(_type == 1) |
| 880 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 881 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 882 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 883 | obj.table_id = reader.read("!B")[0] |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 884 | reader.skip(3) |
| 885 | return obj |
| 886 | |
| 887 | def __eq__(self, other): |
| 888 | if type(self) != type(other): return False |
| 889 | if self.table_id != other.table_id: return False |
| 890 | return True |
| 891 | |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 892 | def pretty_print(self, q): |
| 893 | q.text("goto_table {") |
| 894 | with q.group(): |
| 895 | with q.indent(2): |
| 896 | q.breakable() |
| 897 | q.text("table_id = "); |
| 898 | q.text("%#x" % self.table_id) |
| 899 | q.breakable() |
| 900 | q.text('}') |
| 901 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 902 | instruction.subtypes[1] = goto_table |
| 903 | |
| 904 | class meter(instruction): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 905 | type = 6 |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 906 | |
| 907 | def __init__(self, meter_id=None): |
| 908 | if meter_id != None: |
| 909 | self.meter_id = meter_id |
| 910 | else: |
| 911 | self.meter_id = 0 |
| 912 | return |
| 913 | |
| 914 | def pack(self): |
| 915 | packed = [] |
| 916 | packed.append(struct.pack("!H", self.type)) |
| 917 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 918 | packed.append(struct.pack("!L", self.meter_id)) |
| 919 | length = sum([len(x) for x in packed]) |
| 920 | packed[1] = struct.pack("!H", length) |
| 921 | return ''.join(packed) |
| 922 | |
| 923 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 924 | def unpack(reader): |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 925 | obj = meter() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 926 | _type = reader.read("!H")[0] |
| 927 | assert(_type == 6) |
| 928 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 929 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 930 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 931 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 932 | return obj |
| 933 | |
| 934 | def __eq__(self, other): |
| 935 | if type(self) != type(other): return False |
| 936 | if self.meter_id != other.meter_id: return False |
| 937 | return True |
| 938 | |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 939 | def pretty_print(self, q): |
| 940 | q.text("meter {") |
| 941 | with q.group(): |
| 942 | with q.indent(2): |
| 943 | q.breakable() |
| 944 | q.text("meter_id = "); |
| 945 | q.text("%#x" % self.meter_id) |
| 946 | q.breakable() |
| 947 | q.text('}') |
| 948 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 949 | instruction.subtypes[6] = meter |
| 950 | |
| 951 | class write_actions(instruction): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 952 | type = 3 |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 953 | |
| 954 | def __init__(self, actions=None): |
| 955 | if actions != None: |
| 956 | self.actions = actions |
| 957 | else: |
| 958 | self.actions = [] |
| 959 | return |
| 960 | |
| 961 | def pack(self): |
| 962 | packed = [] |
| 963 | packed.append(struct.pack("!H", self.type)) |
| 964 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 965 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 966 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 967 | length = sum([len(x) for x in packed]) |
| 968 | packed[1] = struct.pack("!H", length) |
| 969 | return ''.join(packed) |
| 970 | |
| 971 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 972 | def unpack(reader): |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 973 | obj = write_actions() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 974 | _type = reader.read("!H")[0] |
| 975 | assert(_type == 3) |
| 976 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 977 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 978 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 979 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 980 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 981 | return obj |
| 982 | |
| 983 | def __eq__(self, other): |
| 984 | if type(self) != type(other): return False |
| 985 | if self.actions != other.actions: return False |
| 986 | return True |
| 987 | |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 988 | def pretty_print(self, q): |
| 989 | q.text("write_actions {") |
| 990 | with q.group(): |
| 991 | with q.indent(2): |
| 992 | q.breakable() |
| 993 | q.text("actions = "); |
| 994 | q.pp(self.actions) |
| 995 | q.breakable() |
| 996 | q.text('}') |
| 997 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 998 | instruction.subtypes[3] = write_actions |
| 999 | |
| 1000 | class write_metadata(instruction): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1001 | type = 2 |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 1002 | |
| 1003 | def __init__(self, metadata=None, metadata_mask=None): |
| 1004 | if metadata != None: |
| 1005 | self.metadata = metadata |
| 1006 | else: |
| 1007 | self.metadata = 0 |
| 1008 | if metadata_mask != None: |
| 1009 | self.metadata_mask = metadata_mask |
| 1010 | else: |
| 1011 | self.metadata_mask = 0 |
| 1012 | return |
| 1013 | |
| 1014 | def pack(self): |
| 1015 | packed = [] |
| 1016 | packed.append(struct.pack("!H", self.type)) |
| 1017 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1018 | packed.append('\x00' * 4) |
| 1019 | packed.append(struct.pack("!Q", self.metadata)) |
| 1020 | packed.append(struct.pack("!Q", self.metadata_mask)) |
| 1021 | length = sum([len(x) for x in packed]) |
| 1022 | packed[1] = struct.pack("!H", length) |
| 1023 | return ''.join(packed) |
| 1024 | |
| 1025 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1026 | def unpack(reader): |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 1027 | obj = write_metadata() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1028 | _type = reader.read("!H")[0] |
| 1029 | assert(_type == 2) |
| 1030 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1031 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1032 | reader = orig_reader.slice(_len, 4) |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 1033 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1034 | obj.metadata = reader.read("!Q")[0] |
| 1035 | obj.metadata_mask = reader.read("!Q")[0] |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 1036 | return obj |
| 1037 | |
| 1038 | def __eq__(self, other): |
| 1039 | if type(self) != type(other): return False |
| 1040 | if self.metadata != other.metadata: return False |
| 1041 | if self.metadata_mask != other.metadata_mask: return False |
| 1042 | return True |
| 1043 | |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 1044 | def pretty_print(self, q): |
| 1045 | q.text("write_metadata {") |
| 1046 | with q.group(): |
| 1047 | with q.indent(2): |
| 1048 | q.breakable() |
| 1049 | q.text("metadata = "); |
| 1050 | q.text("%#x" % self.metadata) |
| 1051 | q.text(","); q.breakable() |
| 1052 | q.text("metadata_mask = "); |
| 1053 | q.text("%#x" % self.metadata_mask) |
| 1054 | q.breakable() |
| 1055 | q.text('}') |
| 1056 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1057 | instruction.subtypes[2] = write_metadata |
Rich Lane | ca3da27 | 2013-05-05 09:07:33 -0700 | [diff] [blame] | 1058 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1059 | |