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