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