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