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_vlan(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 594 | type = 18 |
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_vlan() |
| 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 == 18) |
| 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_vlan {") |
| 634 | with q.group(): |
| 635 | with q.indent(2): |
| 636 | q.breakable() |
| 637 | q.breakable() |
| 638 | q.text('}') |
| 639 | |
| 640 | class push_mpls(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 641 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 642 | |
| 643 | def __init__(self, ethertype=None): |
| 644 | if ethertype != None: |
| 645 | self.ethertype = ethertype |
| 646 | else: |
| 647 | self.ethertype = 0 |
| 648 | return |
| 649 | |
| 650 | def pack(self): |
| 651 | packed = [] |
| 652 | packed.append(struct.pack("!H", self.type)) |
| 653 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 654 | packed.append(struct.pack("!H", self.ethertype)) |
| 655 | packed.append('\x00' * 2) |
| 656 | length = sum([len(x) for x in packed]) |
| 657 | packed[1] = struct.pack("!H", length) |
| 658 | return ''.join(packed) |
| 659 | |
| 660 | @staticmethod |
| 661 | def unpack(buf): |
| 662 | obj = push_mpls() |
| 663 | if type(buf) == loxi.generic_util.OFReader: |
| 664 | reader = buf |
| 665 | else: |
| 666 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 667 | _type = reader.read("!H")[0] |
| 668 | assert(_type == 19) |
| 669 | _len = reader.read("!H")[0] |
| 670 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 671 | reader.skip(2) |
| 672 | return obj |
| 673 | |
| 674 | def __eq__(self, other): |
| 675 | if type(self) != type(other): return False |
| 676 | if self.ethertype != other.ethertype: return False |
| 677 | return True |
| 678 | |
| 679 | def __ne__(self, other): |
| 680 | return not self.__eq__(other) |
| 681 | |
| 682 | def show(self): |
| 683 | import loxi.pp |
| 684 | return loxi.pp.pp(self) |
| 685 | |
| 686 | def pretty_print(self, q): |
| 687 | q.text("push_mpls {") |
| 688 | with q.group(): |
| 689 | with q.indent(2): |
| 690 | q.breakable() |
| 691 | q.text("ethertype = "); |
| 692 | q.text("%#x" % self.ethertype) |
| 693 | q.breakable() |
| 694 | q.text('}') |
| 695 | |
| 696 | class push_vlan(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 697 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 698 | |
| 699 | def __init__(self, ethertype=None): |
| 700 | if ethertype != None: |
| 701 | self.ethertype = ethertype |
| 702 | else: |
| 703 | self.ethertype = 0 |
| 704 | return |
| 705 | |
| 706 | def pack(self): |
| 707 | packed = [] |
| 708 | packed.append(struct.pack("!H", self.type)) |
| 709 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 710 | packed.append(struct.pack("!H", self.ethertype)) |
| 711 | packed.append('\x00' * 2) |
| 712 | length = sum([len(x) for x in packed]) |
| 713 | packed[1] = struct.pack("!H", length) |
| 714 | return ''.join(packed) |
| 715 | |
| 716 | @staticmethod |
| 717 | def unpack(buf): |
| 718 | obj = push_vlan() |
| 719 | if type(buf) == loxi.generic_util.OFReader: |
| 720 | reader = buf |
| 721 | else: |
| 722 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 723 | _type = reader.read("!H")[0] |
| 724 | assert(_type == 17) |
| 725 | _len = reader.read("!H")[0] |
| 726 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 727 | reader.skip(2) |
| 728 | return obj |
| 729 | |
| 730 | def __eq__(self, other): |
| 731 | if type(self) != type(other): return False |
| 732 | if self.ethertype != other.ethertype: return False |
| 733 | return True |
| 734 | |
| 735 | def __ne__(self, other): |
| 736 | return not self.__eq__(other) |
| 737 | |
| 738 | def show(self): |
| 739 | import loxi.pp |
| 740 | return loxi.pp.pp(self) |
| 741 | |
| 742 | def pretty_print(self, q): |
| 743 | q.text("push_vlan {") |
| 744 | with q.group(): |
| 745 | with q.indent(2): |
| 746 | q.breakable() |
| 747 | q.text("ethertype = "); |
| 748 | q.text("%#x" % self.ethertype) |
| 749 | q.breakable() |
| 750 | q.text('}') |
| 751 | |
| 752 | class set_dl_dst(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 753 | type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 754 | |
| 755 | def __init__(self, dl_addr=None): |
| 756 | if dl_addr != None: |
| 757 | self.dl_addr = dl_addr |
| 758 | else: |
| 759 | self.dl_addr = [0,0,0,0,0,0] |
| 760 | return |
| 761 | |
| 762 | def pack(self): |
| 763 | packed = [] |
| 764 | packed.append(struct.pack("!H", self.type)) |
| 765 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 766 | packed.append(struct.pack("!6B", *self.dl_addr)) |
| 767 | packed.append('\x00' * 6) |
| 768 | length = sum([len(x) for x in packed]) |
| 769 | packed[1] = struct.pack("!H", length) |
| 770 | return ''.join(packed) |
| 771 | |
| 772 | @staticmethod |
| 773 | def unpack(buf): |
| 774 | obj = set_dl_dst() |
| 775 | if type(buf) == loxi.generic_util.OFReader: |
| 776 | reader = buf |
| 777 | else: |
| 778 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 779 | _type = reader.read("!H")[0] |
| 780 | assert(_type == 4) |
| 781 | _len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 782 | obj.dl_addr = list(reader.read('!6B')) |
| 783 | reader.skip(6) |
| 784 | return obj |
| 785 | |
| 786 | def __eq__(self, other): |
| 787 | if type(self) != type(other): return False |
| 788 | if self.dl_addr != other.dl_addr: return False |
| 789 | return True |
| 790 | |
| 791 | def __ne__(self, other): |
| 792 | return not self.__eq__(other) |
| 793 | |
| 794 | def show(self): |
| 795 | import loxi.pp |
| 796 | return loxi.pp.pp(self) |
| 797 | |
| 798 | def pretty_print(self, q): |
| 799 | q.text("set_dl_dst {") |
| 800 | with q.group(): |
| 801 | with q.indent(2): |
| 802 | q.breakable() |
| 803 | q.text("dl_addr = "); |
| 804 | q.text(util.pretty_mac(self.dl_addr)) |
| 805 | q.breakable() |
| 806 | q.text('}') |
| 807 | |
| 808 | class set_dl_src(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 809 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 810 | |
| 811 | def __init__(self, dl_addr=None): |
| 812 | if dl_addr != None: |
| 813 | self.dl_addr = dl_addr |
| 814 | else: |
| 815 | self.dl_addr = [0,0,0,0,0,0] |
| 816 | return |
| 817 | |
| 818 | def pack(self): |
| 819 | packed = [] |
| 820 | packed.append(struct.pack("!H", self.type)) |
| 821 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 822 | packed.append(struct.pack("!6B", *self.dl_addr)) |
| 823 | packed.append('\x00' * 6) |
| 824 | length = sum([len(x) for x in packed]) |
| 825 | packed[1] = struct.pack("!H", length) |
| 826 | return ''.join(packed) |
| 827 | |
| 828 | @staticmethod |
| 829 | def unpack(buf): |
| 830 | obj = set_dl_src() |
| 831 | if type(buf) == loxi.generic_util.OFReader: |
| 832 | reader = buf |
| 833 | else: |
| 834 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 835 | _type = reader.read("!H")[0] |
| 836 | assert(_type == 3) |
| 837 | _len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 838 | obj.dl_addr = list(reader.read('!6B')) |
| 839 | reader.skip(6) |
| 840 | return obj |
| 841 | |
| 842 | def __eq__(self, other): |
| 843 | if type(self) != type(other): return False |
| 844 | if self.dl_addr != other.dl_addr: return False |
| 845 | return True |
| 846 | |
| 847 | def __ne__(self, other): |
| 848 | return not self.__eq__(other) |
| 849 | |
| 850 | def show(self): |
| 851 | import loxi.pp |
| 852 | return loxi.pp.pp(self) |
| 853 | |
| 854 | def pretty_print(self, q): |
| 855 | q.text("set_dl_src {") |
| 856 | with q.group(): |
| 857 | with q.indent(2): |
| 858 | q.breakable() |
| 859 | q.text("dl_addr = "); |
| 860 | q.text(util.pretty_mac(self.dl_addr)) |
| 861 | q.breakable() |
| 862 | q.text('}') |
| 863 | |
| 864 | class set_mpls_label(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 865 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 866 | |
| 867 | def __init__(self, mpls_label=None): |
| 868 | if mpls_label != None: |
| 869 | self.mpls_label = mpls_label |
| 870 | else: |
| 871 | self.mpls_label = 0 |
| 872 | return |
| 873 | |
| 874 | def pack(self): |
| 875 | packed = [] |
| 876 | packed.append(struct.pack("!H", self.type)) |
| 877 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 878 | packed.append(struct.pack("!L", self.mpls_label)) |
| 879 | length = sum([len(x) for x in packed]) |
| 880 | packed[1] = struct.pack("!H", length) |
| 881 | return ''.join(packed) |
| 882 | |
| 883 | @staticmethod |
| 884 | def unpack(buf): |
| 885 | obj = set_mpls_label() |
| 886 | if type(buf) == loxi.generic_util.OFReader: |
| 887 | reader = buf |
| 888 | else: |
| 889 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 890 | _type = reader.read("!H")[0] |
| 891 | assert(_type == 13) |
| 892 | _len = reader.read("!H")[0] |
| 893 | obj.mpls_label = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 894 | return obj |
| 895 | |
| 896 | def __eq__(self, other): |
| 897 | if type(self) != type(other): return False |
| 898 | if self.mpls_label != other.mpls_label: return False |
| 899 | return True |
| 900 | |
| 901 | def __ne__(self, other): |
| 902 | return not self.__eq__(other) |
| 903 | |
| 904 | def show(self): |
| 905 | import loxi.pp |
| 906 | return loxi.pp.pp(self) |
| 907 | |
| 908 | def pretty_print(self, q): |
| 909 | q.text("set_mpls_label {") |
| 910 | with q.group(): |
| 911 | with q.indent(2): |
| 912 | q.breakable() |
| 913 | q.text("mpls_label = "); |
| 914 | q.text("%#x" % self.mpls_label) |
| 915 | q.breakable() |
| 916 | q.text('}') |
| 917 | |
| 918 | class set_mpls_tc(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 919 | type = 14 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 920 | |
| 921 | def __init__(self, mpls_tc=None): |
| 922 | if mpls_tc != None: |
| 923 | self.mpls_tc = mpls_tc |
| 924 | else: |
| 925 | self.mpls_tc = 0 |
| 926 | return |
| 927 | |
| 928 | def pack(self): |
| 929 | packed = [] |
| 930 | packed.append(struct.pack("!H", self.type)) |
| 931 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 932 | packed.append(struct.pack("!B", self.mpls_tc)) |
| 933 | packed.append('\x00' * 3) |
| 934 | length = sum([len(x) for x in packed]) |
| 935 | packed[1] = struct.pack("!H", length) |
| 936 | return ''.join(packed) |
| 937 | |
| 938 | @staticmethod |
| 939 | def unpack(buf): |
| 940 | obj = set_mpls_tc() |
| 941 | if type(buf) == loxi.generic_util.OFReader: |
| 942 | reader = buf |
| 943 | else: |
| 944 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 945 | _type = reader.read("!H")[0] |
| 946 | assert(_type == 14) |
| 947 | _len = reader.read("!H")[0] |
| 948 | obj.mpls_tc = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 949 | reader.skip(3) |
| 950 | return obj |
| 951 | |
| 952 | def __eq__(self, other): |
| 953 | if type(self) != type(other): return False |
| 954 | if self.mpls_tc != other.mpls_tc: return False |
| 955 | return True |
| 956 | |
| 957 | def __ne__(self, other): |
| 958 | return not self.__eq__(other) |
| 959 | |
| 960 | def show(self): |
| 961 | import loxi.pp |
| 962 | return loxi.pp.pp(self) |
| 963 | |
| 964 | def pretty_print(self, q): |
| 965 | q.text("set_mpls_tc {") |
| 966 | with q.group(): |
| 967 | with q.indent(2): |
| 968 | q.breakable() |
| 969 | q.text("mpls_tc = "); |
| 970 | q.text("%#x" % self.mpls_tc) |
| 971 | q.breakable() |
| 972 | q.text('}') |
| 973 | |
| 974 | class set_mpls_ttl(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 975 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 976 | |
| 977 | def __init__(self, mpls_ttl=None): |
| 978 | if mpls_ttl != None: |
| 979 | self.mpls_ttl = mpls_ttl |
| 980 | else: |
| 981 | self.mpls_ttl = 0 |
| 982 | return |
| 983 | |
| 984 | def pack(self): |
| 985 | packed = [] |
| 986 | packed.append(struct.pack("!H", self.type)) |
| 987 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 988 | packed.append(struct.pack("!B", self.mpls_ttl)) |
| 989 | packed.append('\x00' * 3) |
| 990 | length = sum([len(x) for x in packed]) |
| 991 | packed[1] = struct.pack("!H", length) |
| 992 | return ''.join(packed) |
| 993 | |
| 994 | @staticmethod |
| 995 | def unpack(buf): |
| 996 | obj = set_mpls_ttl() |
| 997 | if type(buf) == loxi.generic_util.OFReader: |
| 998 | reader = buf |
| 999 | else: |
| 1000 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1001 | _type = reader.read("!H")[0] |
| 1002 | assert(_type == 15) |
| 1003 | _len = reader.read("!H")[0] |
| 1004 | obj.mpls_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1005 | reader.skip(3) |
| 1006 | return obj |
| 1007 | |
| 1008 | def __eq__(self, other): |
| 1009 | if type(self) != type(other): return False |
| 1010 | if self.mpls_ttl != other.mpls_ttl: return False |
| 1011 | return True |
| 1012 | |
| 1013 | def __ne__(self, other): |
| 1014 | return not self.__eq__(other) |
| 1015 | |
| 1016 | def show(self): |
| 1017 | import loxi.pp |
| 1018 | return loxi.pp.pp(self) |
| 1019 | |
| 1020 | def pretty_print(self, q): |
| 1021 | q.text("set_mpls_ttl {") |
| 1022 | with q.group(): |
| 1023 | with q.indent(2): |
| 1024 | q.breakable() |
| 1025 | q.text("mpls_ttl = "); |
| 1026 | q.text("%#x" % self.mpls_ttl) |
| 1027 | q.breakable() |
| 1028 | q.text('}') |
| 1029 | |
| 1030 | class set_nw_dst(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1031 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1032 | |
| 1033 | def __init__(self, nw_addr=None): |
| 1034 | if nw_addr != None: |
| 1035 | self.nw_addr = nw_addr |
| 1036 | else: |
| 1037 | self.nw_addr = 0 |
| 1038 | return |
| 1039 | |
| 1040 | def pack(self): |
| 1041 | packed = [] |
| 1042 | packed.append(struct.pack("!H", self.type)) |
| 1043 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1044 | packed.append(struct.pack("!L", self.nw_addr)) |
| 1045 | length = sum([len(x) for x in packed]) |
| 1046 | packed[1] = struct.pack("!H", length) |
| 1047 | return ''.join(packed) |
| 1048 | |
| 1049 | @staticmethod |
| 1050 | def unpack(buf): |
| 1051 | obj = set_nw_dst() |
| 1052 | if type(buf) == loxi.generic_util.OFReader: |
| 1053 | reader = buf |
| 1054 | else: |
| 1055 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1056 | _type = reader.read("!H")[0] |
| 1057 | assert(_type == 6) |
| 1058 | _len = reader.read("!H")[0] |
| 1059 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1060 | return obj |
| 1061 | |
| 1062 | def __eq__(self, other): |
| 1063 | if type(self) != type(other): return False |
| 1064 | if self.nw_addr != other.nw_addr: return False |
| 1065 | return True |
| 1066 | |
| 1067 | def __ne__(self, other): |
| 1068 | return not self.__eq__(other) |
| 1069 | |
| 1070 | def show(self): |
| 1071 | import loxi.pp |
| 1072 | return loxi.pp.pp(self) |
| 1073 | |
| 1074 | def pretty_print(self, q): |
| 1075 | q.text("set_nw_dst {") |
| 1076 | with q.group(): |
| 1077 | with q.indent(2): |
| 1078 | q.breakable() |
| 1079 | q.text("nw_addr = "); |
| 1080 | q.text("%#x" % self.nw_addr) |
| 1081 | q.breakable() |
| 1082 | q.text('}') |
| 1083 | |
| 1084 | class set_nw_ecn(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1085 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1086 | |
| 1087 | def __init__(self, nw_ecn=None): |
| 1088 | if nw_ecn != None: |
| 1089 | self.nw_ecn = nw_ecn |
| 1090 | else: |
| 1091 | self.nw_ecn = 0 |
| 1092 | return |
| 1093 | |
| 1094 | def pack(self): |
| 1095 | packed = [] |
| 1096 | packed.append(struct.pack("!H", self.type)) |
| 1097 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1098 | packed.append(struct.pack("!B", self.nw_ecn)) |
| 1099 | packed.append('\x00' * 3) |
| 1100 | length = sum([len(x) for x in packed]) |
| 1101 | packed[1] = struct.pack("!H", length) |
| 1102 | return ''.join(packed) |
| 1103 | |
| 1104 | @staticmethod |
| 1105 | def unpack(buf): |
| 1106 | obj = set_nw_ecn() |
| 1107 | if type(buf) == loxi.generic_util.OFReader: |
| 1108 | reader = buf |
| 1109 | else: |
| 1110 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1111 | _type = reader.read("!H")[0] |
| 1112 | assert(_type == 8) |
| 1113 | _len = reader.read("!H")[0] |
| 1114 | obj.nw_ecn = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1115 | reader.skip(3) |
| 1116 | return obj |
| 1117 | |
| 1118 | def __eq__(self, other): |
| 1119 | if type(self) != type(other): return False |
| 1120 | if self.nw_ecn != other.nw_ecn: return False |
| 1121 | return True |
| 1122 | |
| 1123 | def __ne__(self, other): |
| 1124 | return not self.__eq__(other) |
| 1125 | |
| 1126 | def show(self): |
| 1127 | import loxi.pp |
| 1128 | return loxi.pp.pp(self) |
| 1129 | |
| 1130 | def pretty_print(self, q): |
| 1131 | q.text("set_nw_ecn {") |
| 1132 | with q.group(): |
| 1133 | with q.indent(2): |
| 1134 | q.breakable() |
| 1135 | q.text("nw_ecn = "); |
| 1136 | q.text("%#x" % self.nw_ecn) |
| 1137 | q.breakable() |
| 1138 | q.text('}') |
| 1139 | |
| 1140 | class set_nw_src(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1141 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1142 | |
| 1143 | def __init__(self, nw_addr=None): |
| 1144 | if nw_addr != None: |
| 1145 | self.nw_addr = nw_addr |
| 1146 | else: |
| 1147 | self.nw_addr = 0 |
| 1148 | return |
| 1149 | |
| 1150 | def pack(self): |
| 1151 | packed = [] |
| 1152 | packed.append(struct.pack("!H", self.type)) |
| 1153 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1154 | packed.append(struct.pack("!L", self.nw_addr)) |
| 1155 | length = sum([len(x) for x in packed]) |
| 1156 | packed[1] = struct.pack("!H", length) |
| 1157 | return ''.join(packed) |
| 1158 | |
| 1159 | @staticmethod |
| 1160 | def unpack(buf): |
| 1161 | obj = set_nw_src() |
| 1162 | if type(buf) == loxi.generic_util.OFReader: |
| 1163 | reader = buf |
| 1164 | else: |
| 1165 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1166 | _type = reader.read("!H")[0] |
| 1167 | assert(_type == 5) |
| 1168 | _len = reader.read("!H")[0] |
| 1169 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1170 | return obj |
| 1171 | |
| 1172 | def __eq__(self, other): |
| 1173 | if type(self) != type(other): return False |
| 1174 | if self.nw_addr != other.nw_addr: return False |
| 1175 | return True |
| 1176 | |
| 1177 | def __ne__(self, other): |
| 1178 | return not self.__eq__(other) |
| 1179 | |
| 1180 | def show(self): |
| 1181 | import loxi.pp |
| 1182 | return loxi.pp.pp(self) |
| 1183 | |
| 1184 | def pretty_print(self, q): |
| 1185 | q.text("set_nw_src {") |
| 1186 | with q.group(): |
| 1187 | with q.indent(2): |
| 1188 | q.breakable() |
| 1189 | q.text("nw_addr = "); |
| 1190 | q.text("%#x" % self.nw_addr) |
| 1191 | q.breakable() |
| 1192 | q.text('}') |
| 1193 | |
| 1194 | class set_nw_tos(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1195 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1196 | |
| 1197 | def __init__(self, nw_tos=None): |
| 1198 | if nw_tos != None: |
| 1199 | self.nw_tos = nw_tos |
| 1200 | else: |
| 1201 | self.nw_tos = 0 |
| 1202 | return |
| 1203 | |
| 1204 | def pack(self): |
| 1205 | packed = [] |
| 1206 | packed.append(struct.pack("!H", self.type)) |
| 1207 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1208 | packed.append(struct.pack("!B", self.nw_tos)) |
| 1209 | packed.append('\x00' * 3) |
| 1210 | length = sum([len(x) for x in packed]) |
| 1211 | packed[1] = struct.pack("!H", length) |
| 1212 | return ''.join(packed) |
| 1213 | |
| 1214 | @staticmethod |
| 1215 | def unpack(buf): |
| 1216 | obj = set_nw_tos() |
| 1217 | if type(buf) == loxi.generic_util.OFReader: |
| 1218 | reader = buf |
| 1219 | else: |
| 1220 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1221 | _type = reader.read("!H")[0] |
| 1222 | assert(_type == 7) |
| 1223 | _len = reader.read("!H")[0] |
| 1224 | obj.nw_tos = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1225 | reader.skip(3) |
| 1226 | return obj |
| 1227 | |
| 1228 | def __eq__(self, other): |
| 1229 | if type(self) != type(other): return False |
| 1230 | if self.nw_tos != other.nw_tos: return False |
| 1231 | return True |
| 1232 | |
| 1233 | def __ne__(self, other): |
| 1234 | return not self.__eq__(other) |
| 1235 | |
| 1236 | def show(self): |
| 1237 | import loxi.pp |
| 1238 | return loxi.pp.pp(self) |
| 1239 | |
| 1240 | def pretty_print(self, q): |
| 1241 | q.text("set_nw_tos {") |
| 1242 | with q.group(): |
| 1243 | with q.indent(2): |
| 1244 | q.breakable() |
| 1245 | q.text("nw_tos = "); |
| 1246 | q.text("%#x" % self.nw_tos) |
| 1247 | q.breakable() |
| 1248 | q.text('}') |
| 1249 | |
| 1250 | class set_nw_ttl(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1251 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1252 | |
| 1253 | def __init__(self, nw_ttl=None): |
| 1254 | if nw_ttl != None: |
| 1255 | self.nw_ttl = nw_ttl |
| 1256 | else: |
| 1257 | self.nw_ttl = 0 |
| 1258 | return |
| 1259 | |
| 1260 | def pack(self): |
| 1261 | packed = [] |
| 1262 | packed.append(struct.pack("!H", self.type)) |
| 1263 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1264 | packed.append(struct.pack("!B", self.nw_ttl)) |
| 1265 | packed.append('\x00' * 3) |
| 1266 | length = sum([len(x) for x in packed]) |
| 1267 | packed[1] = struct.pack("!H", length) |
| 1268 | return ''.join(packed) |
| 1269 | |
| 1270 | @staticmethod |
| 1271 | def unpack(buf): |
| 1272 | obj = set_nw_ttl() |
| 1273 | if type(buf) == loxi.generic_util.OFReader: |
| 1274 | reader = buf |
| 1275 | else: |
| 1276 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1277 | _type = reader.read("!H")[0] |
| 1278 | assert(_type == 23) |
| 1279 | _len = reader.read("!H")[0] |
| 1280 | obj.nw_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1281 | reader.skip(3) |
| 1282 | return obj |
| 1283 | |
| 1284 | def __eq__(self, other): |
| 1285 | if type(self) != type(other): return False |
| 1286 | if self.nw_ttl != other.nw_ttl: return False |
| 1287 | return True |
| 1288 | |
| 1289 | def __ne__(self, other): |
| 1290 | return not self.__eq__(other) |
| 1291 | |
| 1292 | def show(self): |
| 1293 | import loxi.pp |
| 1294 | return loxi.pp.pp(self) |
| 1295 | |
| 1296 | def pretty_print(self, q): |
| 1297 | q.text("set_nw_ttl {") |
| 1298 | with q.group(): |
| 1299 | with q.indent(2): |
| 1300 | q.breakable() |
| 1301 | q.text("nw_ttl = "); |
| 1302 | q.text("%#x" % self.nw_ttl) |
| 1303 | q.breakable() |
| 1304 | q.text('}') |
| 1305 | |
| 1306 | class set_queue(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1307 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1308 | |
| 1309 | def __init__(self, queue_id=None): |
| 1310 | if queue_id != None: |
| 1311 | self.queue_id = queue_id |
| 1312 | else: |
| 1313 | self.queue_id = 0 |
| 1314 | return |
| 1315 | |
| 1316 | def pack(self): |
| 1317 | packed = [] |
| 1318 | packed.append(struct.pack("!H", self.type)) |
| 1319 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1320 | packed.append(struct.pack("!L", self.queue_id)) |
| 1321 | length = sum([len(x) for x in packed]) |
| 1322 | packed[1] = struct.pack("!H", length) |
| 1323 | return ''.join(packed) |
| 1324 | |
| 1325 | @staticmethod |
| 1326 | def unpack(buf): |
| 1327 | obj = set_queue() |
| 1328 | if type(buf) == loxi.generic_util.OFReader: |
| 1329 | reader = buf |
| 1330 | else: |
| 1331 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1332 | _type = reader.read("!H")[0] |
| 1333 | assert(_type == 21) |
| 1334 | _len = reader.read("!H")[0] |
| 1335 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1336 | return obj |
| 1337 | |
| 1338 | def __eq__(self, other): |
| 1339 | if type(self) != type(other): return False |
| 1340 | if self.queue_id != other.queue_id: return False |
| 1341 | return True |
| 1342 | |
| 1343 | def __ne__(self, other): |
| 1344 | return not self.__eq__(other) |
| 1345 | |
| 1346 | def show(self): |
| 1347 | import loxi.pp |
| 1348 | return loxi.pp.pp(self) |
| 1349 | |
| 1350 | def pretty_print(self, q): |
| 1351 | q.text("set_queue {") |
| 1352 | with q.group(): |
| 1353 | with q.indent(2): |
| 1354 | q.breakable() |
| 1355 | q.text("queue_id = "); |
| 1356 | q.text("%#x" % self.queue_id) |
| 1357 | q.breakable() |
| 1358 | q.text('}') |
| 1359 | |
| 1360 | class set_tp_dst(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1361 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1362 | |
| 1363 | def __init__(self, tp_port=None): |
| 1364 | if tp_port != None: |
| 1365 | self.tp_port = tp_port |
| 1366 | else: |
| 1367 | self.tp_port = 0 |
| 1368 | return |
| 1369 | |
| 1370 | def pack(self): |
| 1371 | packed = [] |
| 1372 | packed.append(struct.pack("!H", self.type)) |
| 1373 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1374 | packed.append(struct.pack("!H", self.tp_port)) |
| 1375 | packed.append('\x00' * 2) |
| 1376 | length = sum([len(x) for x in packed]) |
| 1377 | packed[1] = struct.pack("!H", length) |
| 1378 | return ''.join(packed) |
| 1379 | |
| 1380 | @staticmethod |
| 1381 | def unpack(buf): |
| 1382 | obj = set_tp_dst() |
| 1383 | if type(buf) == loxi.generic_util.OFReader: |
| 1384 | reader = buf |
| 1385 | else: |
| 1386 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1387 | _type = reader.read("!H")[0] |
| 1388 | assert(_type == 10) |
| 1389 | _len = reader.read("!H")[0] |
| 1390 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1391 | reader.skip(2) |
| 1392 | return obj |
| 1393 | |
| 1394 | def __eq__(self, other): |
| 1395 | if type(self) != type(other): return False |
| 1396 | if self.tp_port != other.tp_port: return False |
| 1397 | return True |
| 1398 | |
| 1399 | def __ne__(self, other): |
| 1400 | return not self.__eq__(other) |
| 1401 | |
| 1402 | def show(self): |
| 1403 | import loxi.pp |
| 1404 | return loxi.pp.pp(self) |
| 1405 | |
| 1406 | def pretty_print(self, q): |
| 1407 | q.text("set_tp_dst {") |
| 1408 | with q.group(): |
| 1409 | with q.indent(2): |
| 1410 | q.breakable() |
| 1411 | q.text("tp_port = "); |
| 1412 | q.text("%#x" % self.tp_port) |
| 1413 | q.breakable() |
| 1414 | q.text('}') |
| 1415 | |
| 1416 | class set_tp_src(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1417 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1418 | |
| 1419 | def __init__(self, tp_port=None): |
| 1420 | if tp_port != None: |
| 1421 | self.tp_port = tp_port |
| 1422 | else: |
| 1423 | self.tp_port = 0 |
| 1424 | return |
| 1425 | |
| 1426 | def pack(self): |
| 1427 | packed = [] |
| 1428 | packed.append(struct.pack("!H", self.type)) |
| 1429 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1430 | packed.append(struct.pack("!H", self.tp_port)) |
| 1431 | packed.append('\x00' * 2) |
| 1432 | length = sum([len(x) for x in packed]) |
| 1433 | packed[1] = struct.pack("!H", length) |
| 1434 | return ''.join(packed) |
| 1435 | |
| 1436 | @staticmethod |
| 1437 | def unpack(buf): |
| 1438 | obj = set_tp_src() |
| 1439 | if type(buf) == loxi.generic_util.OFReader: |
| 1440 | reader = buf |
| 1441 | else: |
| 1442 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1443 | _type = reader.read("!H")[0] |
| 1444 | assert(_type == 9) |
| 1445 | _len = reader.read("!H")[0] |
| 1446 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1447 | reader.skip(2) |
| 1448 | return obj |
| 1449 | |
| 1450 | def __eq__(self, other): |
| 1451 | if type(self) != type(other): return False |
| 1452 | if self.tp_port != other.tp_port: return False |
| 1453 | return True |
| 1454 | |
| 1455 | def __ne__(self, other): |
| 1456 | return not self.__eq__(other) |
| 1457 | |
| 1458 | def show(self): |
| 1459 | import loxi.pp |
| 1460 | return loxi.pp.pp(self) |
| 1461 | |
| 1462 | def pretty_print(self, q): |
| 1463 | q.text("set_tp_src {") |
| 1464 | with q.group(): |
| 1465 | with q.indent(2): |
| 1466 | q.breakable() |
| 1467 | q.text("tp_port = "); |
| 1468 | q.text("%#x" % self.tp_port) |
| 1469 | q.breakable() |
| 1470 | q.text('}') |
| 1471 | |
| 1472 | class set_vlan_pcp(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1473 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1474 | |
| 1475 | def __init__(self, vlan_pcp=None): |
| 1476 | if vlan_pcp != None: |
| 1477 | self.vlan_pcp = vlan_pcp |
| 1478 | else: |
| 1479 | self.vlan_pcp = 0 |
| 1480 | return |
| 1481 | |
| 1482 | def pack(self): |
| 1483 | packed = [] |
| 1484 | packed.append(struct.pack("!H", self.type)) |
| 1485 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1486 | packed.append(struct.pack("!B", self.vlan_pcp)) |
| 1487 | packed.append('\x00' * 3) |
| 1488 | length = sum([len(x) for x in packed]) |
| 1489 | packed[1] = struct.pack("!H", length) |
| 1490 | return ''.join(packed) |
| 1491 | |
| 1492 | @staticmethod |
| 1493 | def unpack(buf): |
| 1494 | obj = set_vlan_pcp() |
| 1495 | if type(buf) == loxi.generic_util.OFReader: |
| 1496 | reader = buf |
| 1497 | else: |
| 1498 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1499 | _type = reader.read("!H")[0] |
| 1500 | assert(_type == 2) |
| 1501 | _len = reader.read("!H")[0] |
| 1502 | obj.vlan_pcp = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1503 | reader.skip(3) |
| 1504 | return obj |
| 1505 | |
| 1506 | def __eq__(self, other): |
| 1507 | if type(self) != type(other): return False |
| 1508 | if self.vlan_pcp != other.vlan_pcp: return False |
| 1509 | return True |
| 1510 | |
| 1511 | def __ne__(self, other): |
| 1512 | return not self.__eq__(other) |
| 1513 | |
| 1514 | def show(self): |
| 1515 | import loxi.pp |
| 1516 | return loxi.pp.pp(self) |
| 1517 | |
| 1518 | def pretty_print(self, q): |
| 1519 | q.text("set_vlan_pcp {") |
| 1520 | with q.group(): |
| 1521 | with q.indent(2): |
| 1522 | q.breakable() |
| 1523 | q.text("vlan_pcp = "); |
| 1524 | q.text("%#x" % self.vlan_pcp) |
| 1525 | q.breakable() |
| 1526 | q.text('}') |
| 1527 | |
| 1528 | class set_vlan_vid(Action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1529 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1530 | |
| 1531 | def __init__(self, vlan_vid=None): |
| 1532 | if vlan_vid != None: |
| 1533 | self.vlan_vid = vlan_vid |
| 1534 | else: |
| 1535 | self.vlan_vid = 0 |
| 1536 | return |
| 1537 | |
| 1538 | def pack(self): |
| 1539 | packed = [] |
| 1540 | packed.append(struct.pack("!H", self.type)) |
| 1541 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1542 | packed.append(struct.pack("!H", self.vlan_vid)) |
| 1543 | packed.append('\x00' * 2) |
| 1544 | length = sum([len(x) for x in packed]) |
| 1545 | packed[1] = struct.pack("!H", length) |
| 1546 | return ''.join(packed) |
| 1547 | |
| 1548 | @staticmethod |
| 1549 | def unpack(buf): |
| 1550 | obj = set_vlan_vid() |
| 1551 | if type(buf) == loxi.generic_util.OFReader: |
| 1552 | reader = buf |
| 1553 | else: |
| 1554 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1555 | _type = reader.read("!H")[0] |
| 1556 | assert(_type == 1) |
| 1557 | _len = reader.read("!H")[0] |
| 1558 | obj.vlan_vid = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1559 | reader.skip(2) |
| 1560 | return obj |
| 1561 | |
| 1562 | def __eq__(self, other): |
| 1563 | if type(self) != type(other): return False |
| 1564 | if self.vlan_vid != other.vlan_vid: return False |
| 1565 | return True |
| 1566 | |
| 1567 | def __ne__(self, other): |
| 1568 | return not self.__eq__(other) |
| 1569 | |
| 1570 | def show(self): |
| 1571 | import loxi.pp |
| 1572 | return loxi.pp.pp(self) |
| 1573 | |
| 1574 | def pretty_print(self, q): |
| 1575 | q.text("set_vlan_vid {") |
| 1576 | with q.group(): |
| 1577 | with q.indent(2): |
| 1578 | q.breakable() |
| 1579 | q.text("vlan_vid = "); |
| 1580 | q.text("%#x" % self.vlan_vid) |
| 1581 | q.breakable() |
| 1582 | q.text('}') |
| 1583 | |
| 1584 | |
| 1585 | def parse_experimenter(reader): |
| 1586 | |
| 1587 | experimenter, = reader.peek("!4xL") |
| 1588 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 1589 | subtype, = reader.peek("!8xL") |
| 1590 | elif experimenter == 0x00002320: # Nicira |
| 1591 | subtype, = reader.peek("!8xH") |
| 1592 | else: |
| 1593 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 1594 | |
| 1595 | if subtype in experimenter_parsers[experimenter]: |
| 1596 | return experimenter_parsers[experimenter][subtype](reader) |
| 1597 | else: |
| 1598 | raise loxi.ProtocolError("unexpected BSN experimenter subtype %#x" % subtype) |
| 1599 | |
| 1600 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1601 | const.OFPAT_OUTPUT : output.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1602 | const.OFPAT_SET_VLAN_VID : set_vlan_vid.unpack, |
| 1603 | const.OFPAT_SET_VLAN_PCP : set_vlan_pcp.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1604 | const.OFPAT_SET_DL_SRC : set_dl_src.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1605 | const.OFPAT_SET_DL_DST : set_dl_dst.unpack, |
| 1606 | const.OFPAT_SET_NW_SRC : set_nw_src.unpack, |
| 1607 | const.OFPAT_SET_NW_DST : set_nw_dst.unpack, |
| 1608 | const.OFPAT_SET_NW_TOS : set_nw_tos.unpack, |
| 1609 | const.OFPAT_SET_NW_ECN : set_nw_ecn.unpack, |
| 1610 | const.OFPAT_SET_TP_SRC : set_tp_src.unpack, |
| 1611 | const.OFPAT_SET_TP_DST : set_tp_dst.unpack, |
| 1612 | const.OFPAT_COPY_TTL_OUT : copy_ttl_out.unpack, |
| 1613 | const.OFPAT_COPY_TTL_IN : copy_ttl_in.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1614 | const.OFPAT_SET_MPLS_LABEL : set_mpls_label.unpack, |
| 1615 | const.OFPAT_SET_MPLS_TC : set_mpls_tc.unpack, |
| 1616 | const.OFPAT_SET_MPLS_TTL : set_mpls_ttl.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1617 | const.OFPAT_DEC_MPLS_TTL : dec_mpls_ttl.unpack, |
| 1618 | const.OFPAT_PUSH_VLAN : push_vlan.unpack, |
| 1619 | const.OFPAT_POP_VLAN : pop_vlan.unpack, |
| 1620 | const.OFPAT_PUSH_MPLS : push_mpls.unpack, |
| 1621 | const.OFPAT_POP_MPLS : pop_mpls.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1622 | const.OFPAT_SET_QUEUE : set_queue.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1623 | const.OFPAT_GROUP : group.unpack, |
| 1624 | const.OFPAT_SET_NW_TTL : set_nw_ttl.unpack, |
| 1625 | const.OFPAT_DEC_NW_TTL : dec_nw_ttl.unpack, |
| 1626 | const.OFPAT_EXPERIMENTER : parse_experimenter, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1627 | } |
| 1628 | |
| 1629 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1630 | 8992 : { |
| 1631 | 18: nicira_dec_ttl.unpack, |
| 1632 | }, |
| 1633 | 6035143 : { |
| 1634 | 1: bsn_mirror.unpack, |
| 1635 | 2: bsn_set_tunnel_dst.unpack, |
| 1636 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1637 | } |