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 util |
| 12 | import loxi.generic_util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 13 | |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 14 | import sys |
| 15 | ofp = sys.modules['loxi.of13'] |
| 16 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 17 | class action(loxi.OFObject): |
| 18 | subtypes = {} |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 19 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 20 | |
| 21 | def __init__(self, type=None): |
| 22 | if type != None: |
| 23 | self.type = type |
| 24 | else: |
| 25 | self.type = 0 |
| 26 | return |
| 27 | |
| 28 | def pack(self): |
| 29 | packed = [] |
| 30 | packed.append(struct.pack("!H", self.type)) |
| 31 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 32 | packed.append('\x00' * 4) |
| 33 | length = sum([len(x) for x in packed]) |
| 34 | packed[1] = struct.pack("!H", length) |
| 35 | return ''.join(packed) |
| 36 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 37 | @staticmethod |
| 38 | def unpack(reader): |
| 39 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 40 | subclass = action.subtypes.get(subtype) |
| 41 | if subclass: |
| 42 | return subclass.unpack(reader) |
| 43 | |
| 44 | obj = action() |
| 45 | obj.type = reader.read("!H")[0] |
| 46 | _len = reader.read("!H")[0] |
| 47 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 48 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 49 | reader.skip(4) |
| 50 | return obj |
| 51 | |
| 52 | def __eq__(self, other): |
| 53 | if type(self) != type(other): return False |
| 54 | if self.type != other.type: return False |
| 55 | return True |
| 56 | |
| 57 | def pretty_print(self, q): |
| 58 | q.text("action {") |
| 59 | with q.group(): |
| 60 | with q.indent(2): |
| 61 | q.breakable() |
| 62 | q.breakable() |
| 63 | q.text('}') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 64 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 65 | |
| 66 | class experimenter(action): |
| 67 | subtypes = {} |
| 68 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 69 | type = 65535 |
| 70 | |
| 71 | def __init__(self, experimenter=None, data=None): |
| 72 | if experimenter != None: |
| 73 | self.experimenter = experimenter |
| 74 | else: |
| 75 | self.experimenter = 0 |
| 76 | if data != None: |
| 77 | self.data = data |
| 78 | else: |
| 79 | self.data = '' |
| 80 | return |
| 81 | |
| 82 | def pack(self): |
| 83 | packed = [] |
| 84 | packed.append(struct.pack("!H", self.type)) |
| 85 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 86 | packed.append(struct.pack("!L", self.experimenter)) |
| 87 | packed.append(self.data) |
| 88 | length = sum([len(x) for x in packed]) |
| 89 | packed.append(loxi.generic_util.pad_to(8, length)) |
| 90 | length += len(packed[-1]) |
| 91 | packed[1] = struct.pack("!H", length) |
| 92 | return ''.join(packed) |
| 93 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 94 | @staticmethod |
| 95 | def unpack(reader): |
| 96 | subtype, = reader.peek('!L', 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 97 | subclass = experimenter.subtypes.get(subtype) |
| 98 | if subclass: |
| 99 | return subclass.unpack(reader) |
| 100 | |
| 101 | obj = experimenter() |
| 102 | _type = reader.read("!H")[0] |
| 103 | assert(_type == 65535) |
| 104 | _len = reader.read("!H")[0] |
| 105 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 106 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 107 | obj.experimenter = reader.read("!L")[0] |
| 108 | obj.data = str(reader.read_all()) |
| 109 | return obj |
| 110 | |
| 111 | def __eq__(self, other): |
| 112 | if type(self) != type(other): return False |
| 113 | if self.experimenter != other.experimenter: return False |
| 114 | if self.data != other.data: return False |
| 115 | return True |
| 116 | |
| 117 | def pretty_print(self, q): |
| 118 | q.text("experimenter {") |
| 119 | with q.group(): |
| 120 | with q.indent(2): |
| 121 | q.breakable() |
| 122 | q.text("data = "); |
| 123 | q.pp(self.data) |
| 124 | q.breakable() |
| 125 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 126 | |
| 127 | action.subtypes[65535] = experimenter |
macauley_cheng | 8e0b3ee | 2015-08-31 15:18:57 +0800 | [diff] [blame] | 128 | """ |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 129 | class bsn(experimenter): |
| 130 | subtypes = {} |
| 131 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 132 | type = 65535 |
| 133 | experimenter = 6035143 |
| 134 | |
| 135 | def __init__(self, subtype=None): |
| 136 | if subtype != None: |
| 137 | self.subtype = subtype |
| 138 | else: |
| 139 | self.subtype = 0 |
| 140 | return |
| 141 | |
| 142 | def pack(self): |
| 143 | packed = [] |
| 144 | packed.append(struct.pack("!H", self.type)) |
| 145 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 146 | packed.append(struct.pack("!L", self.experimenter)) |
| 147 | packed.append(struct.pack("!L", self.subtype)) |
| 148 | packed.append('\x00' * 4) |
| 149 | length = sum([len(x) for x in packed]) |
| 150 | packed[1] = struct.pack("!H", length) |
| 151 | return ''.join(packed) |
| 152 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 153 | @staticmethod |
| 154 | def unpack(reader): |
| 155 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 156 | subclass = bsn.subtypes.get(subtype) |
| 157 | if subclass: |
| 158 | return subclass.unpack(reader) |
| 159 | |
| 160 | obj = bsn() |
| 161 | _type = reader.read("!H")[0] |
| 162 | assert(_type == 65535) |
| 163 | _len = reader.read("!H")[0] |
| 164 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 165 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 166 | _experimenter = reader.read("!L")[0] |
| 167 | assert(_experimenter == 6035143) |
| 168 | obj.subtype = reader.read("!L")[0] |
| 169 | reader.skip(4) |
| 170 | return obj |
| 171 | |
| 172 | def __eq__(self, other): |
| 173 | if type(self) != type(other): return False |
| 174 | if self.subtype != other.subtype: return False |
| 175 | return True |
| 176 | |
| 177 | def pretty_print(self, q): |
| 178 | q.text("bsn {") |
| 179 | with q.group(): |
| 180 | with q.indent(2): |
| 181 | q.breakable() |
| 182 | q.breakable() |
| 183 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 184 | |
| 185 | experimenter.subtypes[6035143] = bsn |
| 186 | |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 187 | class bsn_checksum(bsn): |
| 188 | type = 65535 |
| 189 | experimenter = 6035143 |
| 190 | subtype = 4 |
| 191 | |
| 192 | def __init__(self, checksum=None): |
| 193 | if checksum != None: |
| 194 | self.checksum = checksum |
| 195 | else: |
| 196 | self.checksum = 0 |
| 197 | return |
| 198 | |
| 199 | def pack(self): |
| 200 | packed = [] |
| 201 | packed.append(struct.pack("!H", self.type)) |
| 202 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 203 | packed.append(struct.pack("!L", self.experimenter)) |
| 204 | packed.append(struct.pack("!L", self.subtype)) |
| 205 | packed.append(util.pack_checksum_128(self.checksum)) |
| 206 | length = sum([len(x) for x in packed]) |
| 207 | packed[1] = struct.pack("!H", length) |
| 208 | return ''.join(packed) |
| 209 | |
| 210 | @staticmethod |
| 211 | def unpack(reader): |
| 212 | obj = bsn_checksum() |
| 213 | _type = reader.read("!H")[0] |
| 214 | assert(_type == 65535) |
| 215 | _len = reader.read("!H")[0] |
| 216 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 217 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 218 | _experimenter = reader.read("!L")[0] |
| 219 | assert(_experimenter == 6035143) |
| 220 | _subtype = reader.read("!L")[0] |
| 221 | assert(_subtype == 4) |
| 222 | obj.checksum = util.unpack_checksum_128(reader) |
| 223 | return obj |
| 224 | |
| 225 | def __eq__(self, other): |
| 226 | if type(self) != type(other): return False |
| 227 | if self.checksum != other.checksum: return False |
| 228 | return True |
| 229 | |
| 230 | def pretty_print(self, q): |
| 231 | q.text("bsn_checksum {") |
| 232 | with q.group(): |
| 233 | with q.indent(2): |
| 234 | q.breakable() |
| 235 | q.text("checksum = "); |
| 236 | q.pp(self.checksum) |
| 237 | q.breakable() |
| 238 | q.text('}') |
| 239 | |
| 240 | bsn.subtypes[4] = bsn_checksum |
| 241 | |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 242 | class bsn_gentable(bsn): |
| 243 | type = 65535 |
| 244 | experimenter = 6035143 |
| 245 | subtype = 5 |
| 246 | |
| 247 | def __init__(self, table_id=None, key=None): |
| 248 | if table_id != None: |
| 249 | self.table_id = table_id |
| 250 | else: |
| 251 | self.table_id = 0 |
| 252 | if key != None: |
| 253 | self.key = key |
| 254 | else: |
| 255 | self.key = [] |
| 256 | return |
| 257 | |
| 258 | def pack(self): |
| 259 | packed = [] |
| 260 | packed.append(struct.pack("!H", self.type)) |
| 261 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 262 | packed.append(struct.pack("!L", self.experimenter)) |
| 263 | packed.append(struct.pack("!L", self.subtype)) |
| 264 | packed.append(struct.pack("!L", self.table_id)) |
| 265 | packed.append(loxi.generic_util.pack_list(self.key)) |
| 266 | length = sum([len(x) for x in packed]) |
| 267 | packed[1] = struct.pack("!H", length) |
| 268 | return ''.join(packed) |
| 269 | |
| 270 | @staticmethod |
| 271 | def unpack(reader): |
| 272 | obj = bsn_gentable() |
| 273 | _type = reader.read("!H")[0] |
| 274 | assert(_type == 65535) |
| 275 | _len = reader.read("!H")[0] |
| 276 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 277 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 278 | _experimenter = reader.read("!L")[0] |
| 279 | assert(_experimenter == 6035143) |
| 280 | _subtype = reader.read("!L")[0] |
| 281 | assert(_subtype == 5) |
| 282 | obj.table_id = reader.read("!L")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 283 | obj.key = loxi.generic_util.unpack_list(reader, ofp.bsn_tlv.bsn_tlv.unpack) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 284 | return obj |
| 285 | |
| 286 | def __eq__(self, other): |
| 287 | if type(self) != type(other): return False |
| 288 | if self.table_id != other.table_id: return False |
| 289 | if self.key != other.key: return False |
| 290 | return True |
| 291 | |
| 292 | def pretty_print(self, q): |
| 293 | q.text("bsn_gentable {") |
| 294 | with q.group(): |
| 295 | with q.indent(2): |
| 296 | q.breakable() |
| 297 | q.text("table_id = "); |
| 298 | q.text("%#x" % self.table_id) |
| 299 | q.text(","); q.breakable() |
| 300 | q.text("key = "); |
| 301 | q.pp(self.key) |
| 302 | q.breakable() |
| 303 | q.text('}') |
| 304 | |
| 305 | bsn.subtypes[5] = bsn_gentable |
| 306 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 307 | class bsn_mirror(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 308 | type = 65535 |
| 309 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 310 | subtype = 1 |
| 311 | |
| 312 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
| 313 | if dest_port != None: |
| 314 | self.dest_port = dest_port |
| 315 | else: |
| 316 | self.dest_port = 0 |
| 317 | if vlan_tag != None: |
| 318 | self.vlan_tag = vlan_tag |
| 319 | else: |
| 320 | self.vlan_tag = 0 |
| 321 | if copy_stage != None: |
| 322 | self.copy_stage = copy_stage |
| 323 | else: |
| 324 | self.copy_stage = 0 |
| 325 | return |
| 326 | |
| 327 | def pack(self): |
| 328 | packed = [] |
| 329 | packed.append(struct.pack("!H", self.type)) |
| 330 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 331 | packed.append(struct.pack("!L", self.experimenter)) |
| 332 | packed.append(struct.pack("!L", self.subtype)) |
| 333 | packed.append(struct.pack("!L", self.dest_port)) |
| 334 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 335 | packed.append(struct.pack("!B", self.copy_stage)) |
| 336 | packed.append('\x00' * 3) |
| 337 | length = sum([len(x) for x in packed]) |
| 338 | packed[1] = struct.pack("!H", length) |
| 339 | return ''.join(packed) |
| 340 | |
| 341 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 342 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 343 | obj = bsn_mirror() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 344 | _type = reader.read("!H")[0] |
| 345 | assert(_type == 65535) |
| 346 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 347 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 348 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 349 | _experimenter = reader.read("!L")[0] |
| 350 | assert(_experimenter == 6035143) |
| 351 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 352 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 353 | obj.dest_port = reader.read("!L")[0] |
| 354 | obj.vlan_tag = reader.read("!L")[0] |
| 355 | obj.copy_stage = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 356 | reader.skip(3) |
| 357 | return obj |
| 358 | |
| 359 | def __eq__(self, other): |
| 360 | if type(self) != type(other): return False |
| 361 | if self.dest_port != other.dest_port: return False |
| 362 | if self.vlan_tag != other.vlan_tag: return False |
| 363 | if self.copy_stage != other.copy_stage: return False |
| 364 | return True |
| 365 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 366 | def pretty_print(self, q): |
| 367 | q.text("bsn_mirror {") |
| 368 | with q.group(): |
| 369 | with q.indent(2): |
| 370 | q.breakable() |
| 371 | q.text("dest_port = "); |
| 372 | q.text("%#x" % self.dest_port) |
| 373 | q.text(","); q.breakable() |
| 374 | q.text("vlan_tag = "); |
| 375 | q.text("%#x" % self.vlan_tag) |
| 376 | q.text(","); q.breakable() |
| 377 | q.text("copy_stage = "); |
| 378 | q.text("%#x" % self.copy_stage) |
| 379 | q.breakable() |
| 380 | q.text('}') |
| 381 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 382 | bsn.subtypes[1] = bsn_mirror |
| 383 | |
| 384 | class bsn_set_tunnel_dst(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 385 | type = 65535 |
| 386 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 387 | subtype = 2 |
| 388 | |
| 389 | def __init__(self, dst=None): |
| 390 | if dst != None: |
| 391 | self.dst = dst |
| 392 | else: |
| 393 | self.dst = 0 |
| 394 | return |
| 395 | |
| 396 | def pack(self): |
| 397 | packed = [] |
| 398 | packed.append(struct.pack("!H", self.type)) |
| 399 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 400 | packed.append(struct.pack("!L", self.experimenter)) |
| 401 | packed.append(struct.pack("!L", self.subtype)) |
| 402 | packed.append(struct.pack("!L", self.dst)) |
| 403 | length = sum([len(x) for x in packed]) |
| 404 | packed[1] = struct.pack("!H", length) |
| 405 | return ''.join(packed) |
| 406 | |
| 407 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 408 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 409 | obj = bsn_set_tunnel_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 410 | _type = reader.read("!H")[0] |
| 411 | assert(_type == 65535) |
| 412 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 413 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 414 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 415 | _experimenter = reader.read("!L")[0] |
| 416 | assert(_experimenter == 6035143) |
| 417 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 418 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 419 | obj.dst = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 420 | return obj |
| 421 | |
| 422 | def __eq__(self, other): |
| 423 | if type(self) != type(other): return False |
| 424 | if self.dst != other.dst: return False |
| 425 | return True |
| 426 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 427 | def pretty_print(self, q): |
| 428 | q.text("bsn_set_tunnel_dst {") |
| 429 | with q.group(): |
| 430 | with q.indent(2): |
| 431 | q.breakable() |
| 432 | q.text("dst = "); |
| 433 | q.text("%#x" % self.dst) |
| 434 | q.breakable() |
| 435 | q.text('}') |
| 436 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 437 | bsn.subtypes[2] = bsn_set_tunnel_dst |
macauley_cheng | 8e0b3ee | 2015-08-31 15:18:57 +0800 | [diff] [blame] | 438 | """ |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 439 | |
| 440 | class copy_ttl_in(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 441 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 442 | |
| 443 | def __init__(self): |
| 444 | return |
| 445 | |
| 446 | def pack(self): |
| 447 | packed = [] |
| 448 | packed.append(struct.pack("!H", self.type)) |
| 449 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 450 | packed.append('\x00' * 4) |
| 451 | length = sum([len(x) for x in packed]) |
| 452 | packed[1] = struct.pack("!H", length) |
| 453 | return ''.join(packed) |
| 454 | |
| 455 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 456 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 457 | obj = copy_ttl_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 458 | _type = reader.read("!H")[0] |
| 459 | assert(_type == 12) |
| 460 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 461 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 462 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 463 | reader.skip(4) |
| 464 | return obj |
| 465 | |
| 466 | def __eq__(self, other): |
| 467 | if type(self) != type(other): return False |
| 468 | return True |
| 469 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 470 | def pretty_print(self, q): |
| 471 | q.text("copy_ttl_in {") |
| 472 | with q.group(): |
| 473 | with q.indent(2): |
| 474 | q.breakable() |
| 475 | q.breakable() |
| 476 | q.text('}') |
| 477 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 478 | action.subtypes[12] = copy_ttl_in |
| 479 | |
| 480 | class copy_ttl_out(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 481 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 482 | |
| 483 | def __init__(self): |
| 484 | return |
| 485 | |
| 486 | def pack(self): |
| 487 | packed = [] |
| 488 | packed.append(struct.pack("!H", self.type)) |
| 489 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 490 | packed.append('\x00' * 4) |
| 491 | length = sum([len(x) for x in packed]) |
| 492 | packed[1] = struct.pack("!H", length) |
| 493 | return ''.join(packed) |
| 494 | |
| 495 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 496 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 497 | obj = copy_ttl_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 498 | _type = reader.read("!H")[0] |
| 499 | assert(_type == 11) |
| 500 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 501 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 502 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 503 | reader.skip(4) |
| 504 | return obj |
| 505 | |
| 506 | def __eq__(self, other): |
| 507 | if type(self) != type(other): return False |
| 508 | return True |
| 509 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 510 | def pretty_print(self, q): |
| 511 | q.text("copy_ttl_out {") |
| 512 | with q.group(): |
| 513 | with q.indent(2): |
| 514 | q.breakable() |
| 515 | q.breakable() |
| 516 | q.text('}') |
| 517 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 518 | action.subtypes[11] = copy_ttl_out |
| 519 | |
| 520 | class dec_mpls_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 521 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 522 | |
| 523 | def __init__(self): |
| 524 | return |
| 525 | |
| 526 | def pack(self): |
| 527 | packed = [] |
| 528 | packed.append(struct.pack("!H", self.type)) |
| 529 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 530 | packed.append('\x00' * 4) |
| 531 | length = sum([len(x) for x in packed]) |
| 532 | packed[1] = struct.pack("!H", length) |
| 533 | return ''.join(packed) |
| 534 | |
| 535 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 536 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 537 | obj = dec_mpls_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 538 | _type = reader.read("!H")[0] |
| 539 | assert(_type == 16) |
| 540 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 541 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 542 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 543 | reader.skip(4) |
| 544 | return obj |
| 545 | |
| 546 | def __eq__(self, other): |
| 547 | if type(self) != type(other): return False |
| 548 | return True |
| 549 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 550 | def pretty_print(self, q): |
| 551 | q.text("dec_mpls_ttl {") |
| 552 | with q.group(): |
| 553 | with q.indent(2): |
| 554 | q.breakable() |
| 555 | q.breakable() |
| 556 | q.text('}') |
| 557 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 558 | action.subtypes[16] = dec_mpls_ttl |
| 559 | |
| 560 | class dec_nw_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 561 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 562 | |
| 563 | def __init__(self): |
| 564 | return |
| 565 | |
| 566 | def pack(self): |
| 567 | packed = [] |
| 568 | packed.append(struct.pack("!H", self.type)) |
| 569 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 570 | packed.append('\x00' * 4) |
| 571 | length = sum([len(x) for x in packed]) |
| 572 | packed[1] = struct.pack("!H", length) |
| 573 | return ''.join(packed) |
| 574 | |
| 575 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 576 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 577 | obj = dec_nw_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 578 | _type = reader.read("!H")[0] |
| 579 | assert(_type == 24) |
| 580 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 581 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 582 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 583 | reader.skip(4) |
| 584 | return obj |
| 585 | |
| 586 | def __eq__(self, other): |
| 587 | if type(self) != type(other): return False |
| 588 | return True |
| 589 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 590 | def pretty_print(self, q): |
| 591 | q.text("dec_nw_ttl {") |
| 592 | with q.group(): |
| 593 | with q.indent(2): |
| 594 | q.breakable() |
| 595 | q.breakable() |
| 596 | q.text('}') |
| 597 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 598 | action.subtypes[24] = dec_nw_ttl |
| 599 | |
| 600 | class group(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 601 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 602 | |
| 603 | def __init__(self, group_id=None): |
| 604 | if group_id != None: |
| 605 | self.group_id = group_id |
| 606 | else: |
| 607 | self.group_id = 0 |
| 608 | return |
| 609 | |
| 610 | def pack(self): |
| 611 | packed = [] |
| 612 | packed.append(struct.pack("!H", self.type)) |
| 613 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 614 | packed.append(struct.pack("!L", self.group_id)) |
| 615 | length = sum([len(x) for x in packed]) |
| 616 | packed[1] = struct.pack("!H", length) |
| 617 | return ''.join(packed) |
| 618 | |
| 619 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 620 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 621 | obj = group() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 622 | _type = reader.read("!H")[0] |
| 623 | assert(_type == 22) |
| 624 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 625 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 626 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 627 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 628 | return obj |
| 629 | |
| 630 | def __eq__(self, other): |
| 631 | if type(self) != type(other): return False |
| 632 | if self.group_id != other.group_id: return False |
| 633 | return True |
| 634 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 635 | def pretty_print(self, q): |
| 636 | q.text("group {") |
| 637 | with q.group(): |
| 638 | with q.indent(2): |
| 639 | q.breakable() |
| 640 | q.text("group_id = "); |
| 641 | q.text("%#x" % self.group_id) |
| 642 | q.breakable() |
| 643 | q.text('}') |
| 644 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 645 | action.subtypes[22] = group |
macauley_cheng | 4ba9477 | 2015-08-31 17:46:11 +0800 | [diff] [blame] | 646 | """ |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 647 | class nicira(experimenter): |
| 648 | subtypes = {} |
| 649 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 650 | type = 65535 |
| 651 | experimenter = 8992 |
| 652 | |
| 653 | def __init__(self, subtype=None): |
| 654 | if subtype != None: |
| 655 | self.subtype = subtype |
| 656 | else: |
| 657 | self.subtype = 0 |
| 658 | return |
| 659 | |
| 660 | def pack(self): |
| 661 | packed = [] |
| 662 | packed.append(struct.pack("!H", self.type)) |
| 663 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 664 | packed.append(struct.pack("!L", self.experimenter)) |
| 665 | packed.append(struct.pack("!H", self.subtype)) |
| 666 | packed.append('\x00' * 2) |
| 667 | packed.append('\x00' * 4) |
| 668 | length = sum([len(x) for x in packed]) |
| 669 | packed[1] = struct.pack("!H", length) |
| 670 | return ''.join(packed) |
| 671 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 672 | @staticmethod |
| 673 | def unpack(reader): |
| 674 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 675 | subclass = nicira.subtypes.get(subtype) |
| 676 | if subclass: |
| 677 | return subclass.unpack(reader) |
| 678 | |
| 679 | obj = nicira() |
| 680 | _type = reader.read("!H")[0] |
| 681 | assert(_type == 65535) |
| 682 | _len = reader.read("!H")[0] |
| 683 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 684 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 685 | _experimenter = reader.read("!L")[0] |
| 686 | assert(_experimenter == 8992) |
| 687 | obj.subtype = reader.read("!H")[0] |
| 688 | reader.skip(2) |
| 689 | reader.skip(4) |
| 690 | return obj |
| 691 | |
| 692 | def __eq__(self, other): |
| 693 | if type(self) != type(other): return False |
| 694 | if self.subtype != other.subtype: return False |
| 695 | return True |
| 696 | |
| 697 | def pretty_print(self, q): |
| 698 | q.text("nicira {") |
| 699 | with q.group(): |
| 700 | with q.indent(2): |
| 701 | q.breakable() |
| 702 | q.breakable() |
| 703 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 704 | |
| 705 | experimenter.subtypes[8992] = nicira |
| 706 | |
| 707 | class nicira_dec_ttl(nicira): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 708 | type = 65535 |
| 709 | experimenter = 8992 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 710 | subtype = 18 |
| 711 | |
| 712 | def __init__(self): |
| 713 | return |
| 714 | |
| 715 | def pack(self): |
| 716 | packed = [] |
| 717 | packed.append(struct.pack("!H", self.type)) |
| 718 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 719 | packed.append(struct.pack("!L", self.experimenter)) |
| 720 | packed.append(struct.pack("!H", self.subtype)) |
| 721 | packed.append('\x00' * 2) |
| 722 | packed.append('\x00' * 4) |
| 723 | length = sum([len(x) for x in packed]) |
| 724 | packed[1] = struct.pack("!H", length) |
| 725 | return ''.join(packed) |
| 726 | |
| 727 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 728 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 729 | obj = nicira_dec_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 730 | _type = reader.read("!H")[0] |
| 731 | assert(_type == 65535) |
| 732 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 733 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 734 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 735 | _experimenter = reader.read("!L")[0] |
| 736 | assert(_experimenter == 8992) |
| 737 | _subtype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 738 | assert(_subtype == 18) |
| 739 | reader.skip(2) |
| 740 | reader.skip(4) |
| 741 | return obj |
| 742 | |
| 743 | def __eq__(self, other): |
| 744 | if type(self) != type(other): return False |
| 745 | return True |
| 746 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 747 | def pretty_print(self, q): |
| 748 | q.text("nicira_dec_ttl {") |
| 749 | with q.group(): |
| 750 | with q.indent(2): |
| 751 | q.breakable() |
| 752 | q.breakable() |
| 753 | q.text('}') |
| 754 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 755 | nicira.subtypes[18] = nicira_dec_ttl |
macauley_cheng | 4ba9477 | 2015-08-31 17:46:11 +0800 | [diff] [blame] | 756 | """ |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 757 | class output(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 758 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 759 | |
| 760 | def __init__(self, port=None, max_len=None): |
| 761 | if port != None: |
| 762 | self.port = port |
| 763 | else: |
| 764 | self.port = 0 |
| 765 | if max_len != None: |
| 766 | self.max_len = max_len |
| 767 | else: |
| 768 | self.max_len = 0 |
| 769 | return |
| 770 | |
| 771 | def pack(self): |
| 772 | packed = [] |
| 773 | packed.append(struct.pack("!H", self.type)) |
| 774 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 775 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 776 | packed.append(struct.pack("!H", self.max_len)) |
| 777 | packed.append('\x00' * 6) |
| 778 | length = sum([len(x) for x in packed]) |
| 779 | packed[1] = struct.pack("!H", length) |
| 780 | return ''.join(packed) |
| 781 | |
| 782 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 783 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 784 | obj = output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 785 | _type = reader.read("!H")[0] |
| 786 | assert(_type == 0) |
| 787 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 788 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 789 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 790 | obj.port = util.unpack_port_no(reader) |
| 791 | obj.max_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 792 | reader.skip(6) |
| 793 | return obj |
| 794 | |
| 795 | def __eq__(self, other): |
| 796 | if type(self) != type(other): return False |
| 797 | if self.port != other.port: return False |
| 798 | if self.max_len != other.max_len: return False |
| 799 | return True |
| 800 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 801 | def pretty_print(self, q): |
| 802 | q.text("output {") |
| 803 | with q.group(): |
| 804 | with q.indent(2): |
| 805 | q.breakable() |
| 806 | q.text("port = "); |
| 807 | q.text(util.pretty_port(self.port)) |
| 808 | q.text(","); q.breakable() |
| 809 | q.text("max_len = "); |
| 810 | q.text("%#x" % self.max_len) |
| 811 | q.breakable() |
| 812 | q.text('}') |
| 813 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 814 | action.subtypes[0] = output |
| 815 | |
| 816 | class pop_mpls(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 817 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 818 | |
| 819 | def __init__(self, ethertype=None): |
| 820 | if ethertype != None: |
| 821 | self.ethertype = ethertype |
| 822 | else: |
| 823 | self.ethertype = 0 |
| 824 | return |
| 825 | |
| 826 | def pack(self): |
| 827 | packed = [] |
| 828 | packed.append(struct.pack("!H", self.type)) |
| 829 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 830 | packed.append(struct.pack("!H", self.ethertype)) |
| 831 | packed.append('\x00' * 2) |
| 832 | length = sum([len(x) for x in packed]) |
| 833 | packed[1] = struct.pack("!H", length) |
| 834 | return ''.join(packed) |
| 835 | |
| 836 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 837 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 838 | obj = pop_mpls() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 839 | _type = reader.read("!H")[0] |
| 840 | assert(_type == 20) |
| 841 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 842 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 843 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 844 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 845 | reader.skip(2) |
| 846 | return obj |
| 847 | |
| 848 | def __eq__(self, other): |
| 849 | if type(self) != type(other): return False |
| 850 | if self.ethertype != other.ethertype: return False |
| 851 | return True |
| 852 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 853 | def pretty_print(self, q): |
| 854 | q.text("pop_mpls {") |
| 855 | with q.group(): |
| 856 | with q.indent(2): |
| 857 | q.breakable() |
| 858 | q.text("ethertype = "); |
| 859 | q.text("%#x" % self.ethertype) |
| 860 | q.breakable() |
| 861 | q.text('}') |
| 862 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 863 | action.subtypes[20] = pop_mpls |
| 864 | |
| 865 | class pop_pbb(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 866 | type = 27 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 867 | |
| 868 | def __init__(self): |
| 869 | return |
| 870 | |
| 871 | def pack(self): |
| 872 | packed = [] |
| 873 | packed.append(struct.pack("!H", self.type)) |
| 874 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 875 | packed.append('\x00' * 4) |
| 876 | length = sum([len(x) for x in packed]) |
| 877 | packed[1] = struct.pack("!H", length) |
| 878 | return ''.join(packed) |
| 879 | |
| 880 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 881 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 882 | obj = pop_pbb() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 883 | _type = reader.read("!H")[0] |
| 884 | assert(_type == 27) |
| 885 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 886 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 887 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 888 | reader.skip(4) |
| 889 | return obj |
| 890 | |
| 891 | def __eq__(self, other): |
| 892 | if type(self) != type(other): return False |
| 893 | return True |
| 894 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 895 | def pretty_print(self, q): |
| 896 | q.text("pop_pbb {") |
| 897 | with q.group(): |
| 898 | with q.indent(2): |
| 899 | q.breakable() |
| 900 | q.breakable() |
| 901 | q.text('}') |
| 902 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 903 | action.subtypes[27] = pop_pbb |
| 904 | |
| 905 | class pop_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 906 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 907 | |
| 908 | def __init__(self): |
| 909 | return |
| 910 | |
| 911 | def pack(self): |
| 912 | packed = [] |
| 913 | packed.append(struct.pack("!H", self.type)) |
| 914 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 915 | packed.append('\x00' * 4) |
| 916 | length = sum([len(x) for x in packed]) |
| 917 | packed[1] = struct.pack("!H", length) |
| 918 | return ''.join(packed) |
| 919 | |
| 920 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 921 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 922 | obj = pop_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 923 | _type = reader.read("!H")[0] |
| 924 | assert(_type == 18) |
| 925 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 926 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 927 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 928 | reader.skip(4) |
| 929 | return obj |
| 930 | |
| 931 | def __eq__(self, other): |
| 932 | if type(self) != type(other): return False |
| 933 | return True |
| 934 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 935 | def pretty_print(self, q): |
| 936 | q.text("pop_vlan {") |
| 937 | with q.group(): |
| 938 | with q.indent(2): |
| 939 | q.breakable() |
| 940 | q.breakable() |
| 941 | q.text('}') |
| 942 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 943 | action.subtypes[18] = pop_vlan |
| 944 | |
| 945 | class push_mpls(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 946 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 947 | |
| 948 | def __init__(self, ethertype=None): |
| 949 | if ethertype != None: |
| 950 | self.ethertype = ethertype |
| 951 | else: |
| 952 | self.ethertype = 0 |
| 953 | return |
| 954 | |
| 955 | def pack(self): |
| 956 | packed = [] |
| 957 | packed.append(struct.pack("!H", self.type)) |
| 958 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 959 | packed.append(struct.pack("!H", self.ethertype)) |
| 960 | packed.append('\x00' * 2) |
| 961 | length = sum([len(x) for x in packed]) |
| 962 | packed[1] = struct.pack("!H", length) |
| 963 | return ''.join(packed) |
| 964 | |
| 965 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 966 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 967 | obj = push_mpls() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 968 | _type = reader.read("!H")[0] |
| 969 | assert(_type == 19) |
| 970 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 971 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 972 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 973 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 974 | reader.skip(2) |
| 975 | return obj |
| 976 | |
| 977 | def __eq__(self, other): |
| 978 | if type(self) != type(other): return False |
| 979 | if self.ethertype != other.ethertype: return False |
| 980 | return True |
| 981 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 982 | def pretty_print(self, q): |
| 983 | q.text("push_mpls {") |
| 984 | with q.group(): |
| 985 | with q.indent(2): |
| 986 | q.breakable() |
| 987 | q.text("ethertype = "); |
| 988 | q.text("%#x" % self.ethertype) |
| 989 | q.breakable() |
| 990 | q.text('}') |
| 991 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 992 | action.subtypes[19] = push_mpls |
| 993 | |
| 994 | class push_pbb(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 995 | type = 26 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 996 | |
| 997 | def __init__(self, ethertype=None): |
| 998 | if ethertype != None: |
| 999 | self.ethertype = ethertype |
| 1000 | else: |
| 1001 | self.ethertype = 0 |
| 1002 | return |
| 1003 | |
| 1004 | def pack(self): |
| 1005 | packed = [] |
| 1006 | packed.append(struct.pack("!H", self.type)) |
| 1007 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1008 | packed.append(struct.pack("!H", self.ethertype)) |
| 1009 | packed.append('\x00' * 2) |
| 1010 | length = sum([len(x) for x in packed]) |
| 1011 | packed[1] = struct.pack("!H", length) |
| 1012 | return ''.join(packed) |
| 1013 | |
| 1014 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1015 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1016 | obj = push_pbb() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1017 | _type = reader.read("!H")[0] |
| 1018 | assert(_type == 26) |
| 1019 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1020 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1021 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1022 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1023 | reader.skip(2) |
| 1024 | return obj |
| 1025 | |
| 1026 | def __eq__(self, other): |
| 1027 | if type(self) != type(other): return False |
| 1028 | if self.ethertype != other.ethertype: return False |
| 1029 | return True |
| 1030 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1031 | def pretty_print(self, q): |
| 1032 | q.text("push_pbb {") |
| 1033 | with q.group(): |
| 1034 | with q.indent(2): |
| 1035 | q.breakable() |
| 1036 | q.text("ethertype = "); |
| 1037 | q.text("%#x" % self.ethertype) |
| 1038 | q.breakable() |
| 1039 | q.text('}') |
| 1040 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1041 | action.subtypes[26] = push_pbb |
| 1042 | |
| 1043 | class push_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1044 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1045 | |
| 1046 | def __init__(self, ethertype=None): |
| 1047 | if ethertype != None: |
| 1048 | self.ethertype = ethertype |
| 1049 | else: |
| 1050 | self.ethertype = 0 |
| 1051 | return |
| 1052 | |
| 1053 | def pack(self): |
| 1054 | packed = [] |
| 1055 | packed.append(struct.pack("!H", self.type)) |
| 1056 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1057 | packed.append(struct.pack("!H", self.ethertype)) |
| 1058 | packed.append('\x00' * 2) |
| 1059 | length = sum([len(x) for x in packed]) |
| 1060 | packed[1] = struct.pack("!H", length) |
| 1061 | return ''.join(packed) |
| 1062 | |
| 1063 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1064 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1065 | obj = push_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1066 | _type = reader.read("!H")[0] |
| 1067 | assert(_type == 17) |
| 1068 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1069 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1070 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1071 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1072 | reader.skip(2) |
| 1073 | return obj |
| 1074 | |
| 1075 | def __eq__(self, other): |
| 1076 | if type(self) != type(other): return False |
| 1077 | if self.ethertype != other.ethertype: return False |
| 1078 | return True |
| 1079 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1080 | def pretty_print(self, q): |
| 1081 | q.text("push_vlan {") |
| 1082 | with q.group(): |
| 1083 | with q.indent(2): |
| 1084 | q.breakable() |
| 1085 | q.text("ethertype = "); |
| 1086 | q.text("%#x" % self.ethertype) |
| 1087 | q.breakable() |
| 1088 | q.text('}') |
| 1089 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1090 | action.subtypes[17] = push_vlan |
| 1091 | |
| 1092 | class set_field(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1093 | type = 25 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1094 | |
| 1095 | def __init__(self, field=None): |
| 1096 | if field != None: |
| 1097 | self.field = field |
| 1098 | else: |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1099 | self.field = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1100 | return |
| 1101 | |
| 1102 | def pack(self): |
| 1103 | packed = [] |
| 1104 | packed.append(struct.pack("!H", self.type)) |
| 1105 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1106 | packed.append(self.field.pack()) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1107 | length = sum([len(x) for x in packed]) |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1108 | packed.append(loxi.generic_util.pad_to(8, length)) |
| 1109 | length += len(packed[-1]) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1110 | packed[1] = struct.pack("!H", length) |
| 1111 | return ''.join(packed) |
| 1112 | |
| 1113 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1114 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1115 | obj = set_field() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1116 | _type = reader.read("!H")[0] |
| 1117 | assert(_type == 25) |
| 1118 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1119 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1120 | reader = orig_reader.slice(_len, 4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 1121 | obj.field = ofp.oxm.oxm.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1122 | return obj |
| 1123 | |
| 1124 | def __eq__(self, other): |
| 1125 | if type(self) != type(other): return False |
| 1126 | if self.field != other.field: return False |
| 1127 | return True |
| 1128 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1129 | def pretty_print(self, q): |
| 1130 | q.text("set_field {") |
| 1131 | with q.group(): |
| 1132 | with q.indent(2): |
| 1133 | q.breakable() |
| 1134 | q.text("field = "); |
| 1135 | q.pp(self.field) |
| 1136 | q.breakable() |
| 1137 | q.text('}') |
| 1138 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1139 | action.subtypes[25] = set_field |
| 1140 | |
| 1141 | class set_mpls_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1142 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1143 | |
| 1144 | def __init__(self, mpls_ttl=None): |
| 1145 | if mpls_ttl != None: |
| 1146 | self.mpls_ttl = mpls_ttl |
| 1147 | else: |
| 1148 | self.mpls_ttl = 0 |
| 1149 | return |
| 1150 | |
| 1151 | def pack(self): |
| 1152 | packed = [] |
| 1153 | packed.append(struct.pack("!H", self.type)) |
| 1154 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1155 | packed.append(struct.pack("!B", self.mpls_ttl)) |
| 1156 | packed.append('\x00' * 3) |
| 1157 | length = sum([len(x) for x in packed]) |
| 1158 | packed[1] = struct.pack("!H", length) |
| 1159 | return ''.join(packed) |
| 1160 | |
| 1161 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1162 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1163 | obj = set_mpls_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1164 | _type = reader.read("!H")[0] |
| 1165 | assert(_type == 15) |
| 1166 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1167 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1168 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1169 | obj.mpls_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1170 | reader.skip(3) |
| 1171 | return obj |
| 1172 | |
| 1173 | def __eq__(self, other): |
| 1174 | if type(self) != type(other): return False |
| 1175 | if self.mpls_ttl != other.mpls_ttl: return False |
| 1176 | return True |
| 1177 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1178 | def pretty_print(self, q): |
| 1179 | q.text("set_mpls_ttl {") |
| 1180 | with q.group(): |
| 1181 | with q.indent(2): |
| 1182 | q.breakable() |
| 1183 | q.text("mpls_ttl = "); |
| 1184 | q.text("%#x" % self.mpls_ttl) |
| 1185 | q.breakable() |
| 1186 | q.text('}') |
| 1187 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1188 | action.subtypes[15] = set_mpls_ttl |
| 1189 | |
| 1190 | class set_nw_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1191 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1192 | |
| 1193 | def __init__(self, nw_ttl=None): |
| 1194 | if nw_ttl != None: |
| 1195 | self.nw_ttl = nw_ttl |
| 1196 | else: |
| 1197 | self.nw_ttl = 0 |
| 1198 | return |
| 1199 | |
| 1200 | def pack(self): |
| 1201 | packed = [] |
| 1202 | packed.append(struct.pack("!H", self.type)) |
| 1203 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1204 | packed.append(struct.pack("!B", self.nw_ttl)) |
| 1205 | packed.append('\x00' * 3) |
| 1206 | length = sum([len(x) for x in packed]) |
| 1207 | packed[1] = struct.pack("!H", length) |
| 1208 | return ''.join(packed) |
| 1209 | |
| 1210 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1211 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1212 | obj = set_nw_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1213 | _type = reader.read("!H")[0] |
| 1214 | assert(_type == 23) |
| 1215 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1216 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1217 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1218 | obj.nw_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1219 | reader.skip(3) |
| 1220 | return obj |
| 1221 | |
| 1222 | def __eq__(self, other): |
| 1223 | if type(self) != type(other): return False |
| 1224 | if self.nw_ttl != other.nw_ttl: return False |
| 1225 | return True |
| 1226 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1227 | def pretty_print(self, q): |
| 1228 | q.text("set_nw_ttl {") |
| 1229 | with q.group(): |
| 1230 | with q.indent(2): |
| 1231 | q.breakable() |
| 1232 | q.text("nw_ttl = "); |
| 1233 | q.text("%#x" % self.nw_ttl) |
| 1234 | q.breakable() |
| 1235 | q.text('}') |
| 1236 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1237 | action.subtypes[23] = set_nw_ttl |
| 1238 | |
| 1239 | class set_queue(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1240 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1241 | |
| 1242 | def __init__(self, queue_id=None): |
| 1243 | if queue_id != None: |
| 1244 | self.queue_id = queue_id |
| 1245 | else: |
| 1246 | self.queue_id = 0 |
| 1247 | return |
| 1248 | |
| 1249 | def pack(self): |
| 1250 | packed = [] |
| 1251 | packed.append(struct.pack("!H", self.type)) |
| 1252 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1253 | packed.append(struct.pack("!L", self.queue_id)) |
| 1254 | length = sum([len(x) for x in packed]) |
| 1255 | packed[1] = struct.pack("!H", length) |
| 1256 | return ''.join(packed) |
| 1257 | |
| 1258 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1259 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1260 | obj = set_queue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1261 | _type = reader.read("!H")[0] |
| 1262 | assert(_type == 21) |
| 1263 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1264 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1265 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1266 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1267 | return obj |
| 1268 | |
| 1269 | def __eq__(self, other): |
| 1270 | if type(self) != type(other): return False |
| 1271 | if self.queue_id != other.queue_id: return False |
| 1272 | return True |
| 1273 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1274 | def pretty_print(self, q): |
| 1275 | q.text("set_queue {") |
| 1276 | with q.group(): |
| 1277 | with q.indent(2): |
| 1278 | q.breakable() |
| 1279 | q.text("queue_id = "); |
| 1280 | q.text("%#x" % self.queue_id) |
| 1281 | q.breakable() |
| 1282 | q.text('}') |
| 1283 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1284 | action.subtypes[21] = set_queue |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1285 | |
macauley_cheng | 8e0b3ee | 2015-08-31 15:18:57 +0800 | [diff] [blame] | 1286 | OFDPA_EXPERIMETER =0x00001018 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1287 | |
macauley_cheng | 8e0b3ee | 2015-08-31 15:18:57 +0800 | [diff] [blame] | 1288 | class ofdpa(experimenter): |
| 1289 | subtypes = {} |
| 1290 | |
| 1291 | type = 65535 |
| 1292 | experimenter = OFDPA_EXPERIMETER |
| 1293 | |
| 1294 | def __init__(self, subtype=None): |
| 1295 | if subtype != None: |
| 1296 | self.subtype = subtype |
| 1297 | else: |
| 1298 | self.subtype = 0 |
| 1299 | return |
| 1300 | |
| 1301 | def pack(self): |
| 1302 | packed = [] |
| 1303 | packed.append(struct.pack("!H", self.type)) |
| 1304 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1305 | packed.append(struct.pack("!L", self.experimenter)) |
| 1306 | packed.append(struct.pack("!H", self.subtype)) |
| 1307 | packed.append('\x00' * 6) |
| 1308 | length = sum([len(x) for x in packed]) |
| 1309 | packed[1] = struct.pack("!H", length) |
| 1310 | return ''.join(packed) |
| 1311 | |
| 1312 | @staticmethod |
| 1313 | def unpack(reader): |
| 1314 | #8 is offset, ref OFReader |
| 1315 | subtype, = reader.peek('!H', 8) |
| 1316 | subclass = ofdpa.subtypes.get(subtype) |
| 1317 | if subclass: |
| 1318 | return subclass.unpack(reader) |
| 1319 | |
| 1320 | obj = ofdpa() |
| 1321 | _type = reader.read("!H")[0] |
| 1322 | assert(_type == 65535) |
| 1323 | _len = reader.read("!H")[0] |
| 1324 | orig_reader = reader |
| 1325 | reader = orig_reader.slice(_len, 4) |
| 1326 | _experimenter = reader.read("!L")[0] |
| 1327 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1328 | obj.subtype = reader.read("!H")[0] |
| 1329 | reader.skip(6) |
| 1330 | return obj |
| 1331 | |
| 1332 | def __eq__(self, other): |
| 1333 | if type(self) != type(other): return False |
| 1334 | if self.subtype != other.subtype: return False |
| 1335 | return True |
| 1336 | |
| 1337 | def pretty_print(self, q): |
| 1338 | q.text("ofdpa {") |
| 1339 | with q.group(): |
| 1340 | with q.indent(2): |
| 1341 | q.breakable() |
| 1342 | q.breakable() |
| 1343 | q.text('}') |
| 1344 | |
| 1345 | experimenter.subtypes[OFDPA_EXPERIMETER] = ofdpa |
| 1346 | |
| 1347 | OFDPA_ACT_PUSH_L2_HEADER=1 |
| 1348 | OFDPA_ACT_POP_L2_HEADER=2 |
| 1349 | OFDPA_ACT_PUSH_CW=3 |
| 1350 | OFDPA_ACT_POP_CW=4 |
| 1351 | OFDPA_ACT_COPY_TC_IN=5 |
| 1352 | OFDPA_ACT_COPY_TC_OUT=6 |
| 1353 | OFDPA_ACT_SET_TC_FROM_TABLE=7 |
| 1354 | OFDPA_ACT_SET_PCP_DFI_FROM_TABLE=9 |
| 1355 | OFDPA_ACT_OAM_LM_RX_COUNT=10 |
| 1356 | OFDPA_ACT_OAM_LM_TX_COUNT=11 |
| 1357 | OFDPA_ACT_OAM_SET_COUNTER_FIELDS=12 |
| 1358 | OFDPA_ACT_DEC_TTL_MTU=13 |
| 1359 | OFDPA_ACT_CHECK_DROP_STATUS=14 |
| 1360 | OFDPA_ACT_SET_QOS_FROM_TABLE=15 |
| 1361 | |
| 1362 | |
| 1363 | class ofdpa_push_l2_header(ofdpa): |
| 1364 | type = 65535 |
| 1365 | experimenter = OFDPA_EXPERIMETER |
| 1366 | subtype = OFDPA_ACT_PUSH_L2_HEADER |
| 1367 | |
| 1368 | def __init__(self): |
| 1369 | return |
| 1370 | |
| 1371 | def pack(self): |
| 1372 | packed = [] |
| 1373 | packed.append(struct.pack("!H", self.type)) |
| 1374 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1375 | packed.append(struct.pack("!L", self.experimenter)) |
| 1376 | packed.append(struct.pack("!H", self.subtype)) |
| 1377 | packed.append('\x00' * 6) |
| 1378 | length = sum([len(x) for x in packed]) |
| 1379 | packed[1] = struct.pack("!H", length) |
| 1380 | return ''.join(packed) |
| 1381 | |
| 1382 | @staticmethod |
| 1383 | def unpack(reader): |
| 1384 | obj = ofdpa_push_l2_header() |
| 1385 | _type = reader.read("!H")[0] |
| 1386 | assert(_type == 65535) |
| 1387 | _len = reader.read("!H")[0] |
| 1388 | orig_reader = reader |
| 1389 | reader = orig_reader.slice(_len, 4) |
| 1390 | _experimenter = reader.read("!L")[0] |
| 1391 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1392 | _subtype = reader.read("!H")[0] |
| 1393 | assert(_subtype == OFDPA_ACT_PUSH_L2_HEADER) |
| 1394 | reader.skip(6) |
| 1395 | return obj |
| 1396 | |
| 1397 | def __eq__(self, other): |
| 1398 | if type(self) != type(other): return False |
| 1399 | return True |
| 1400 | |
| 1401 | def pretty_print(self, q): |
| 1402 | q.text("ofdpa_push_l2_header {") |
| 1403 | with q.group(): |
| 1404 | with q.indent(2): |
| 1405 | q.breakable() |
| 1406 | q.text("ofdpa_push_l2_header"); |
| 1407 | q.breakable() |
| 1408 | q.text('}') |
| 1409 | |
| 1410 | ofdpa.subtypes[OFDPA_ACT_PUSH_L2_HEADER] = ofdpa_push_l2_header |
| 1411 | |
| 1412 | class ofdpa_pop_l2_header(ofdpa): |
| 1413 | type = 65535 |
| 1414 | experimenter = OFDPA_EXPERIMETER |
| 1415 | subtype = OFDPA_ACT_POP_L2_HEADER |
| 1416 | |
| 1417 | def __init__(self): |
| 1418 | return |
| 1419 | |
| 1420 | def pack(self): |
| 1421 | packed = [] |
| 1422 | packed.append(struct.pack("!H", self.type)) |
| 1423 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1424 | packed.append(struct.pack("!L", self.experimenter)) |
| 1425 | packed.append(struct.pack("!H", self.subtype)) |
| 1426 | packed.append('\x00' * 6) |
| 1427 | length = sum([len(x) for x in packed]) |
| 1428 | packed[1] = struct.pack("!H", length) |
| 1429 | return ''.join(packed) |
| 1430 | |
| 1431 | @staticmethod |
| 1432 | def unpack(reader): |
| 1433 | obj = ofdpa_pop_l2_header() |
| 1434 | _type = reader.read("!H")[0] |
| 1435 | assert(_type == 65535) |
| 1436 | _len = reader.read("!H")[0] |
| 1437 | orig_reader = reader |
| 1438 | reader = orig_reader.slice(_len, 4) |
| 1439 | _experimenter = reader.read("!L")[0] |
| 1440 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1441 | _subtype = reader.read("!H")[0] |
| 1442 | assert(_subtype == OFDPA_ACT_POP_L2_HEADER) |
| 1443 | return obj |
| 1444 | |
| 1445 | def __eq__(self, other): |
| 1446 | if type(self) != type(other): return False |
| 1447 | return True |
| 1448 | |
| 1449 | def pretty_print(self, q): |
| 1450 | q.text("ofdpa_pop_l2_header {") |
| 1451 | with q.group(): |
| 1452 | with q.indent(2): |
| 1453 | q.breakable() |
| 1454 | q.text("ofdpa_pop_l2_header"); |
| 1455 | q.breakable() |
| 1456 | q.text('}') |
| 1457 | |
| 1458 | ofdpa.subtypes[OFDPA_ACT_POP_L2_HEADER] = ofdpa_pop_l2_header |
| 1459 | |
| 1460 | class ofdpa_push_cw(ofdpa): |
| 1461 | type = 65535 |
| 1462 | experimenter = OFDPA_EXPERIMETER |
| 1463 | subtype = OFDPA_ACT_PUSH_CW |
| 1464 | |
| 1465 | def __init__(self): |
| 1466 | return |
| 1467 | |
| 1468 | def pack(self): |
| 1469 | packed = [] |
| 1470 | packed.append(struct.pack("!H", self.type)) |
| 1471 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1472 | packed.append(struct.pack("!L", self.experimenter)) |
| 1473 | packed.append(struct.pack("!H", self.subtype)) |
| 1474 | packed.append('\x00' * 6) |
| 1475 | length = sum([len(x) for x in packed]) |
| 1476 | packed[1] = struct.pack("!H", length) |
| 1477 | return ''.join(packed) |
| 1478 | |
| 1479 | @staticmethod |
| 1480 | def unpack(reader): |
| 1481 | obj = ofdpa_push_cw() |
| 1482 | _type = reader.read("!H")[0] |
| 1483 | assert(_type == 65535) |
| 1484 | _len = reader.read("!H")[0] |
| 1485 | orig_reader = reader |
| 1486 | reader = orig_reader.slice(_len, 4) |
| 1487 | _experimenter = reader.read("!L")[0] |
| 1488 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1489 | _subtype = reader.read("!H")[0] |
| 1490 | assert(_subtype == OFDPA_ACT_PUSH_CW) |
| 1491 | return obj |
| 1492 | |
| 1493 | def __eq__(self, other): |
| 1494 | if type(self) != type(other): return False |
| 1495 | return True |
| 1496 | |
| 1497 | def pretty_print(self, q): |
| 1498 | q.text("ofdpa_push_cw {") |
| 1499 | with q.group(): |
| 1500 | with q.indent(2): |
| 1501 | q.breakable() |
| 1502 | q.text("ofdpa_push_cw"); |
| 1503 | q.breakable() |
| 1504 | q.text('}') |
| 1505 | |
| 1506 | ofdpa.subtypes[OFDPA_ACT_PUSH_CW] = ofdpa_push_cw |
| 1507 | |
| 1508 | class ofdpa_pop_cw(ofdpa): |
| 1509 | type = 65535 |
| 1510 | experimenter = OFDPA_EXPERIMETER |
| 1511 | subtype = OFDPA_ACT_POP_CW |
| 1512 | |
| 1513 | def __init__(self): |
| 1514 | return |
| 1515 | |
| 1516 | def pack(self): |
| 1517 | packed = [] |
| 1518 | packed.append(struct.pack("!H", self.type)) |
| 1519 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1520 | packed.append(struct.pack("!L", self.experimenter)) |
| 1521 | packed.append(struct.pack("!H", self.subtype)) |
| 1522 | packed.append('\x00' * 6) |
| 1523 | length = sum([len(x) for x in packed]) |
| 1524 | packed[1] = struct.pack("!H", length) |
| 1525 | return ''.join(packed) |
| 1526 | |
| 1527 | @staticmethod |
| 1528 | def unpack(reader): |
| 1529 | obj = ofdpa_pop_cw() |
| 1530 | _type = reader.read("!H")[0] |
| 1531 | assert(_type == 65535) |
| 1532 | _len = reader.read("!H")[0] |
| 1533 | orig_reader = reader |
| 1534 | reader = orig_reader.slice(_len, 4) |
| 1535 | _experimenter = reader.read("!L")[0] |
| 1536 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1537 | _subtype = reader.read("!H")[0] |
| 1538 | assert(_subtype == OFDPA_ACT_POP_CW) |
| 1539 | return obj |
| 1540 | |
| 1541 | def __eq__(self, other): |
| 1542 | if type(self) != type(other): return False |
| 1543 | return True |
| 1544 | |
| 1545 | def pretty_print(self, q): |
| 1546 | q.text("ofdpa_pop_cw {") |
| 1547 | with q.group(): |
| 1548 | with q.indent(2): |
| 1549 | q.breakable() |
| 1550 | q.text("ofdpa_pop_cw"); |
| 1551 | q.breakable() |
| 1552 | q.text('}') |
| 1553 | |
| 1554 | ofdpa.subtypes[OFDPA_ACT_POP_CW] = ofdpa_pop_cw |
| 1555 | |
| 1556 | class ofdpa_copy_tc_in(ofdpa): |
| 1557 | type = 65535 |
| 1558 | experimenter = OFDPA_EXPERIMETER |
| 1559 | subtype = OFDPA_ACT_COPY_TC_IN |
| 1560 | |
| 1561 | def __init__(self): |
| 1562 | return |
| 1563 | |
| 1564 | def pack(self): |
| 1565 | packed = [] |
| 1566 | packed.append(struct.pack("!H", self.type)) |
| 1567 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1568 | packed.append(struct.pack("!L", self.experimenter)) |
| 1569 | packed.append(struct.pack("!H", self.subtype)) |
| 1570 | packed.append('\x00' * 6) |
| 1571 | length = sum([len(x) for x in packed]) |
| 1572 | packed[1] = struct.pack("!H", length) |
| 1573 | return ''.join(packed) |
| 1574 | |
| 1575 | @staticmethod |
| 1576 | def unpack(reader): |
| 1577 | obj = ofdpa_copy_tc_in() |
| 1578 | _type = reader.read("!H")[0] |
| 1579 | assert(_type == 65535) |
| 1580 | _len = reader.read("!H")[0] |
| 1581 | orig_reader = reader |
| 1582 | reader = orig_reader.slice(_len, 4) |
| 1583 | _experimenter = reader.read("!L")[0] |
| 1584 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1585 | _subtype = reader.read("!H")[0] |
| 1586 | assert(_subtype == OFDPA_ACT_COPY_TC_IN) |
| 1587 | return obj |
| 1588 | |
| 1589 | def __eq__(self, other): |
| 1590 | if type(self) != type(other): return False |
| 1591 | return True |
| 1592 | |
| 1593 | def pretty_print(self, q): |
| 1594 | q.text("ofdpa_copy_tc_in {") |
| 1595 | with q.group(): |
| 1596 | with q.indent(2): |
| 1597 | q.breakable() |
| 1598 | q.text("ofdpa_copy_tc_in"); |
| 1599 | q.breakable() |
| 1600 | q.text('}') |
| 1601 | |
| 1602 | ofdpa.subtypes[OFDPA_ACT_COPY_TC_IN] = ofdpa_copy_tc_in |
| 1603 | |
| 1604 | class ofdpa_copy_tc_out(ofdpa): |
| 1605 | type = 65535 |
| 1606 | experimenter = OFDPA_EXPERIMETER |
| 1607 | subtype = OFDPA_ACT_COPY_TC_OUT |
| 1608 | |
| 1609 | def __init__(self): |
| 1610 | return |
| 1611 | |
| 1612 | def pack(self): |
| 1613 | packed = [] |
| 1614 | packed.append(struct.pack("!H", self.type)) |
| 1615 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1616 | packed.append(struct.pack("!L", self.experimenter)) |
| 1617 | packed.append(struct.pack("!H", self.subtype)) |
| 1618 | packed.append('\x00' * 6) |
| 1619 | length = sum([len(x) for x in packed]) |
| 1620 | packed[1] = struct.pack("!H", length) |
| 1621 | return ''.join(packed) |
| 1622 | |
| 1623 | @staticmethod |
| 1624 | def unpack(reader): |
| 1625 | obj = ofdpa_copy_tc_out() |
| 1626 | _type = reader.read("!H")[0] |
| 1627 | assert(_type == 65535) |
| 1628 | _len = reader.read("!H")[0] |
| 1629 | orig_reader = reader |
| 1630 | reader = orig_reader.slice(_len, 4) |
| 1631 | _experimenter = reader.read("!L")[0] |
| 1632 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1633 | _subtype = reader.read("!H")[0] |
| 1634 | assert(_subtype == OFDPA_ACT_COPY_TC_OUT) |
| 1635 | return obj |
| 1636 | |
| 1637 | def __eq__(self, other): |
| 1638 | if type(self) != type(other): return False |
| 1639 | return True |
| 1640 | |
| 1641 | def pretty_print(self, q): |
| 1642 | q.text("ofdpa_copy_tc_out {") |
| 1643 | with q.group(): |
| 1644 | with q.indent(2): |
| 1645 | q.breakable() |
| 1646 | q.text("ofdpa_copy_tc_out"); |
| 1647 | q.breakable() |
| 1648 | q.text('}') |
| 1649 | |
| 1650 | ofdpa.subtypes[OFDPA_ACT_COPY_TC_OUT] = ofdpa_copy_tc_out |
| 1651 | |
| 1652 | class ofdpa_dec_ttl_mtu(ofdpa): |
| 1653 | type = 65535 |
| 1654 | experimenter = OFDPA_EXPERIMETER |
| 1655 | subtype = OFDPA_ACT_DEC_TTL_MTU |
| 1656 | |
| 1657 | def __init__(self): |
| 1658 | return |
| 1659 | |
| 1660 | def pack(self): |
| 1661 | packed = [] |
| 1662 | packed.append(struct.pack("!H", self.type)) |
| 1663 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1664 | packed.append(struct.pack("!L", self.experimenter)) |
| 1665 | packed.append(struct.pack("!H", self.subtype)) |
| 1666 | packed.append('\x00' * 6) |
| 1667 | length = sum([len(x) for x in packed]) |
| 1668 | packed[1] = struct.pack("!H", length) |
| 1669 | return ''.join(packed) |
| 1670 | |
| 1671 | @staticmethod |
| 1672 | def unpack(reader): |
| 1673 | obj = ofdpa_dec_ttl_mtu() |
| 1674 | _type = reader.read("!H")[0] |
| 1675 | assert(_type == 65535) |
| 1676 | _len = reader.read("!H")[0] |
| 1677 | orig_reader = reader |
| 1678 | reader = orig_reader.slice(_len, 4) |
| 1679 | _experimenter = reader.read("!L")[0] |
| 1680 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1681 | _subtype = reader.read("!H")[0] |
| 1682 | assert(_subtype == OFDPA_ACT_DEC_TTL_MTU) |
| 1683 | return obj |
| 1684 | |
| 1685 | def __eq__(self, other): |
| 1686 | if type(self) != type(other): return False |
| 1687 | return True |
| 1688 | |
| 1689 | def pretty_print(self, q): |
| 1690 | q.text("ofdpa_dec_ttl_mtu {") |
| 1691 | with q.group(): |
| 1692 | with q.indent(2): |
| 1693 | q.breakable() |
| 1694 | q.text("ofdpa_dec_ttl_mtu"); |
| 1695 | q.breakable() |
| 1696 | q.text('}') |
| 1697 | |
| 1698 | ofdpa.subtypes[OFDPA_ACT_DEC_TTL_MTU] = ofdpa_dec_ttl_mtu |
| 1699 | |
| 1700 | class ofdpa_set_tc_from_table(ofdpa): |
| 1701 | type = 65535 |
| 1702 | experimenter = OFDPA_EXPERIMETER |
| 1703 | subtype = OFDPA_ACT_SET_TC_FROM_TABLE |
| 1704 | |
| 1705 | def __init__(self, qos_index=None): |
| 1706 | if qos_index != None: |
| 1707 | self.qos_index = qos_index |
| 1708 | else: |
| 1709 | self.qos_index = 0 |
| 1710 | return |
| 1711 | |
| 1712 | def pack(self): |
| 1713 | packed = [] |
| 1714 | packed.append(struct.pack("!H", self.type)) |
| 1715 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1716 | packed.append(struct.pack("!L", self.experimenter)) |
| 1717 | packed.append(struct.pack("!H", self.subtype)) |
| 1718 | packed.append(struct.pack("!B", self.qos_index)) |
| 1719 | packed.append('\x00' * 5) |
| 1720 | length = sum([len(x) for x in packed]) |
| 1721 | packed[1] = struct.pack("!H", length) |
| 1722 | return ''.join(packed) |
| 1723 | |
| 1724 | @staticmethod |
| 1725 | def unpack(reader): |
| 1726 | obj = ofdpa_set_tc_from_table() |
| 1727 | _type = reader.read("!H")[0] |
| 1728 | assert(_type == 65535) |
| 1729 | _len = reader.read("!H")[0] |
| 1730 | orig_reader = reader |
| 1731 | reader = orig_reader.slice(_len, 4) |
| 1732 | _experimenter = reader.read("!L")[0] |
| 1733 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1734 | _subtype = reader.read("!H")[0] |
| 1735 | assert(_subtype == OFDPA_ACT_SET_TC_FROM_TABLE) |
| 1736 | obj.qos_index = reader.read("!B")[0] |
| 1737 | return obj |
| 1738 | |
| 1739 | def __eq__(self, other): |
| 1740 | if type(self) != type(other): return False |
| 1741 | if self.qos_index != other.qos_index: return False |
| 1742 | return True |
| 1743 | |
| 1744 | def pretty_print(self, q): |
| 1745 | q.text("ofdpa_set_tc_from_table {") |
| 1746 | with q.group(): |
| 1747 | with q.indent(2): |
| 1748 | q.breakable() |
| 1749 | q.text("ofdpa_set_tc_from_table"); |
| 1750 | q.pp(self.qos_index) |
| 1751 | q.breakable() |
| 1752 | q.text('}') |
| 1753 | |
| 1754 | ofdpa.subtypes[OFDPA_ACT_SET_TC_FROM_TABLE] = ofdpa_set_tc_from_table |
| 1755 | |
| 1756 | |
| 1757 | class ofdpa_set_pcp_dfi_from_table(ofdpa): |
| 1758 | type = 65535 |
| 1759 | experimenter = OFDPA_EXPERIMETER |
| 1760 | subtype = OFDPA_ACT_SET_PCP_DFI_FROM_TABLE |
| 1761 | |
| 1762 | def __init__(self, qos_index=None): |
| 1763 | if qos_index != None: |
| 1764 | self.qos_index = qos_index |
| 1765 | else: |
| 1766 | self.qos_index = 0 |
| 1767 | return |
| 1768 | |
| 1769 | def pack(self): |
| 1770 | packed = [] |
| 1771 | packed.append(struct.pack("!H", self.type)) |
| 1772 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1773 | packed.append(struct.pack("!L", self.experimenter)) |
| 1774 | packed.append(struct.pack("!H", self.subtype)) |
| 1775 | packed.append(struct.pack("!B", self.qos_index)) |
| 1776 | packed.append('\x00' * 5) |
| 1777 | length = sum([len(x) for x in packed]) |
| 1778 | packed[1] = struct.pack("!H", length) |
| 1779 | return ''.join(packed) |
| 1780 | |
| 1781 | @staticmethod |
| 1782 | def unpack(reader): |
| 1783 | obj = ofdpa_set_pcp_dfi_from_table() |
| 1784 | _type = reader.read("!H")[0] |
| 1785 | assert(_type == 65535) |
| 1786 | _len = reader.read("!H")[0] |
| 1787 | orig_reader = reader |
| 1788 | reader = orig_reader.slice(_len, 4) |
| 1789 | _experimenter = reader.read("!L")[0] |
| 1790 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1791 | _subtype = reader.read("!H")[0] |
| 1792 | assert(_subtype == OFDPA_ACT_SET_PCP_DFI_FROM_TABLE) |
| 1793 | obj.qos_index = reader.read("!B")[0] |
| 1794 | return obj |
| 1795 | |
| 1796 | def __eq__(self, other): |
| 1797 | if type(self) != type(other): return False |
| 1798 | if self.qos_index != other.qos_index: return False |
| 1799 | return True |
| 1800 | |
| 1801 | def pretty_print(self, q): |
| 1802 | q.text("ofdpa_set_pcp_dfi_from_table {") |
| 1803 | with q.group(): |
| 1804 | with q.indent(2): |
| 1805 | q.breakable() |
| 1806 | q.text("ofdpa_set_pcp_dfi_from_table"); |
| 1807 | q.pp(self.qos_index) |
| 1808 | q.breakable() |
| 1809 | q.text('}') |
| 1810 | |
| 1811 | ofdpa.subtypes[OFDPA_ACT_SET_PCP_DFI_FROM_TABLE] = ofdpa_set_pcp_dfi_from_table |
| 1812 | |
| 1813 | |
| 1814 | class ofdpa_check_drop_status(ofdpa): |
| 1815 | type = 65535 |
| 1816 | experimenter = OFDPA_EXPERIMETER |
| 1817 | subtype = OFDPA_ACT_CHECK_DROP_STATUS |
| 1818 | |
| 1819 | def __init__(self, index, status_type): |
| 1820 | self.index = index |
| 1821 | self.status_type = status_type |
| 1822 | return |
| 1823 | |
| 1824 | def pack(self): |
| 1825 | packed = [] |
| 1826 | packed.append(struct.pack("!H", self.type)) |
| 1827 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1828 | packed.append(struct.pack("!L", self.experimenter)) |
| 1829 | packed.append(struct.pack("!H", self.subtype)) |
| 1830 | packed.append(struct.pack("!L", self.index)) |
| 1831 | packed.append(struct.pack("!B", self.status_type)) |
| 1832 | packed.append('\x00' * 1) |
| 1833 | length = sum([len(x) for x in packed]) |
| 1834 | packed[1] = struct.pack("!H", length) |
| 1835 | return ''.join(packed) |
| 1836 | |
| 1837 | @staticmethod |
| 1838 | def unpack(reader): |
| 1839 | obj = ofdpa_check_drop_status() |
| 1840 | _type = reader.read("!H")[0] |
| 1841 | assert(_type == 65535) |
| 1842 | _len = reader.read("!H")[0] |
| 1843 | orig_reader = reader |
| 1844 | reader = orig_reader.slice(_len, 4) |
| 1845 | _experimenter = reader.read("!L")[0] |
| 1846 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1847 | _subtype = reader.read("!H")[0] |
| 1848 | assert(_subtype == OFDPA_ACT_CHECK_DROP_STATUS) |
| 1849 | obj.status_type = reader.read("!L")[0] |
| 1850 | obj.index = reader.read("!B")[0] |
| 1851 | return obj |
| 1852 | |
| 1853 | def __eq__(self, other): |
| 1854 | if type(self) != type(other): return False |
| 1855 | if self.index != other.index: return False |
| 1856 | if self.status_type != other.status_type: return False |
| 1857 | return True |
| 1858 | |
| 1859 | def pretty_print(self, q): |
| 1860 | q.text("ofdpa_check_drop_status {") |
| 1861 | with q.group(): |
| 1862 | with q.indent(2): |
| 1863 | q.breakable() |
| 1864 | q.text("ofdpa_check_drop_status = "); |
| 1865 | q.pp(self.index) |
| 1866 | q.pp(self.status_type) |
| 1867 | q.breakable() |
| 1868 | q.text('}') |
| 1869 | |
| 1870 | ofdpa.subtypes[OFDPA_ACT_CHECK_DROP_STATUS] = ofdpa_check_drop_status |
| 1871 | |
| 1872 | |
| 1873 | class ofdpa_set_qos_from_table(ofdpa): |
| 1874 | type = 65535 |
| 1875 | experimenter = OFDPA_EXPERIMETER |
| 1876 | subtype = OFDPA_ACT_SET_QOS_FROM_TABLE |
| 1877 | |
| 1878 | def __init__(self, qos_index, mpls_tc): |
| 1879 | self.qos_index = qos_index |
| 1880 | self.mpls_tc = mpls_tc |
| 1881 | return |
| 1882 | |
| 1883 | def pack(self): |
| 1884 | packed = [] |
| 1885 | packed.append(struct.pack("!H", self.type)) |
| 1886 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1887 | packed.append(struct.pack("!L", self.experimenter)) |
| 1888 | packed.append(struct.pack("!H", self.subtype)) |
| 1889 | packed.append(struct.pack("!B", self.qos_index)) |
| 1890 | packed.append(struct.pack("!B", self.mpls_tc)) |
| 1891 | packed.append('\x00' * 4) |
| 1892 | length = sum([len(x) for x in packed]) |
| 1893 | packed[1] = struct.pack("!H", length) |
| 1894 | return ''.join(packed) |
| 1895 | |
| 1896 | @staticmethod |
| 1897 | def unpack(reader): |
| 1898 | obj = ofdpa_check_drop_status() |
| 1899 | _type = reader.read("!H")[0] |
| 1900 | assert(_type == 65535) |
| 1901 | _len = reader.read("!H")[0] |
| 1902 | orig_reader = reader |
| 1903 | reader = orig_reader.slice(_len, 4) |
| 1904 | _experimenter = reader.read("!L")[0] |
| 1905 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1906 | _subtype = reader.read("!H")[0] |
| 1907 | assert(_subtype == OFDPA_ACT_SET_QOS_FROM_TABLE) |
| 1908 | obj.qos_index = reader.read("!B")[0] |
| 1909 | obj.mpls_tc = reader.read("!B")[0] |
| 1910 | return obj |
| 1911 | |
| 1912 | def __eq__(self, other): |
| 1913 | if type(self) != type(other): return False |
| 1914 | if self.qos_index != other.qos_index: return False |
| 1915 | if self.mpls_tc != other.mpls_tc: return False |
| 1916 | return True |
| 1917 | |
| 1918 | def pretty_print(self, q): |
| 1919 | q.text("ofdpa_set_qos_from_table {") |
| 1920 | with q.group(): |
| 1921 | with q.indent(2): |
| 1922 | q.breakable() |
| 1923 | q.text("ofdpa_set_qos_from_table = "); |
| 1924 | q.pp(self.qos_index) |
| 1925 | q.pp(self.mpls_tc) |
| 1926 | q.breakable() |
| 1927 | q.text('}') |
| 1928 | |
| 1929 | ofdpa.subtypes[OFDPA_ACT_SET_QOS_FROM_TABLE] = ofdpa_set_qos_from_table |
| 1930 | |
| 1931 | |
| 1932 | class ofdpa_oam_lm_tx_count(ofdpa): |
| 1933 | type = 65535 |
| 1934 | experimenter = OFDPA_EXPERIMETER |
| 1935 | subtype = OFDPA_ACT_OAM_LM_TX_COUNT |
| 1936 | |
| 1937 | def __init__(self, lmep_id, traffic_class): |
| 1938 | self.lmep_id = lmep_id |
| 1939 | self.traffic_class = traffic_class |
| 1940 | return |
| 1941 | |
| 1942 | def pack(self): |
| 1943 | packed = [] |
| 1944 | packed.append(struct.pack("!H", self.type)) |
| 1945 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1946 | packed.append(struct.pack("!L", self.experimenter)) |
| 1947 | packed.append(struct.pack("!H", self.subtype)) |
| 1948 | packed.append(struct.pack("!L", self.lmep_id)) |
| 1949 | packed.append(struct.pack("!B", self.traffic_class)) |
| 1950 | packed.append('\x00' * 1) |
| 1951 | length = sum([len(x) for x in packed]) |
| 1952 | packed[1] = struct.pack("!H", length) |
| 1953 | return ''.join(packed) |
| 1954 | |
| 1955 | @staticmethod |
| 1956 | def unpack(reader): |
| 1957 | obj = ofdpa_check_drop_status() |
| 1958 | _type = reader.read("!H")[0] |
| 1959 | assert(_type == 65535) |
| 1960 | _len = reader.read("!H")[0] |
| 1961 | orig_reader = reader |
| 1962 | reader = orig_reader.slice(_len, 4) |
| 1963 | _experimenter = reader.read("!L")[0] |
| 1964 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 1965 | _subtype = reader.read("!H")[0] |
| 1966 | assert(_subtype == OFDPA_ACT_OAM_LM_TX_COUNT) |
| 1967 | obj.lmep_id = reader.read("!L")[0] |
| 1968 | obj.traffic_class = reader.read("!B")[0] |
| 1969 | return obj |
| 1970 | |
| 1971 | def __eq__(self, other): |
| 1972 | if type(self) != type(other): return False |
| 1973 | if self.lmep_id != other.lmep_id: return False |
| 1974 | if self.traffic_class != other.traffic_class: return False |
| 1975 | return True |
| 1976 | |
| 1977 | def pretty_print(self, q): |
| 1978 | q.text("ofdpa_oam_lm_tx_count {") |
| 1979 | with q.group(): |
| 1980 | with q.indent(2): |
| 1981 | q.breakable() |
| 1982 | q.text("ofdpa_oam_lm_tx_count = "); |
| 1983 | q.pp(self.lmep_id) |
| 1984 | q.pp(self.traffic_class) |
| 1985 | q.breakable() |
| 1986 | q.text('}') |
| 1987 | |
| 1988 | ofdpa.subtypes[OFDPA_ACT_OAM_LM_TX_COUNT] = ofdpa_oam_lm_tx_count |
| 1989 | |
| 1990 | class ofdpa_oam_lm_rx_count(ofdpa): |
| 1991 | type = 65535 |
| 1992 | experimenter = OFDPA_EXPERIMETER |
| 1993 | subtype = OFDPA_ACT_OAM_LM_RX_COUNT |
| 1994 | |
| 1995 | def __init__(self, lmep_id, traffic_class): |
| 1996 | self.lmep_id = lmep_id |
| 1997 | self.traffic_class = traffic_class |
| 1998 | return |
| 1999 | |
| 2000 | def pack(self): |
| 2001 | packed = [] |
| 2002 | packed.append(struct.pack("!H", self.type)) |
| 2003 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2004 | packed.append(struct.pack("!L", self.experimenter)) |
| 2005 | packed.append(struct.pack("!H", self.subtype)) |
| 2006 | packed.append(struct.pack("!L", self.lmep_id)) |
| 2007 | packed.append(struct.pack("!B", self.traffic_class)) |
| 2008 | packed.append('\x00' * 1) |
| 2009 | length = sum([len(x) for x in packed]) |
| 2010 | packed[1] = struct.pack("!H", length) |
| 2011 | return ''.join(packed) |
| 2012 | |
| 2013 | @staticmethod |
| 2014 | def unpack(reader): |
| 2015 | obj = ofdpa_check_drop_status() |
| 2016 | _type = reader.read("!H")[0] |
| 2017 | assert(_type == 65535) |
| 2018 | _len = reader.read("!H")[0] |
| 2019 | orig_reader = reader |
| 2020 | reader = orig_reader.slice(_len, 4) |
| 2021 | _experimenter = reader.read("!L")[0] |
| 2022 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 2023 | _subtype = reader.read("!H")[0] |
| 2024 | assert(_subtype == OFDPA_ACT_OAM_LM_RX_COUNT) |
| 2025 | obj.lmep_id = reader.read("!L")[0] |
| 2026 | obj.traffic_class = reader.read("!B")[0] |
| 2027 | return obj |
| 2028 | |
| 2029 | def __eq__(self, other): |
| 2030 | if type(self) != type(other): return False |
| 2031 | if self.lmep_id != other.lmep_id: return False |
| 2032 | if self.traffic_class != other.traffic_class: return False |
| 2033 | return True |
| 2034 | |
| 2035 | def pretty_print(self, q): |
| 2036 | q.text("ofdpa_oam_lm_rx_count {") |
| 2037 | with q.group(): |
| 2038 | with q.indent(2): |
| 2039 | q.breakable() |
| 2040 | q.text("ofdpa_oam_lm_rx_count = "); |
| 2041 | q.pp(self.lmep_id) |
| 2042 | q.pp(self.traffic_class) |
| 2043 | q.breakable() |
| 2044 | q.text('}') |
| 2045 | |
| 2046 | ofdpa.subtypes[OFDPA_ACT_OAM_LM_RX_COUNT] = ofdpa_oam_lm_rx_count |
| 2047 | |
| 2048 | |
| 2049 | class ofdpa_oam_set_counter_field(ofdpa): |
| 2050 | type = 65535 |
| 2051 | experimenter = OFDPA_EXPERIMETER |
| 2052 | subtype = OFDPA_ACT_OAM_SET_COUNTER_FIELDS |
| 2053 | |
| 2054 | def __init__(self, lmep_id, traffic_class): |
| 2055 | self.lmep_id = lmep_id |
| 2056 | self.traffic_class = traffic_class |
| 2057 | return |
| 2058 | |
| 2059 | def pack(self): |
| 2060 | packed = [] |
| 2061 | packed.append(struct.pack("!H", self.type)) |
| 2062 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 2063 | packed.append(struct.pack("!L", self.experimenter)) |
| 2064 | packed.append(struct.pack("!H", self.subtype)) |
| 2065 | packed.append(struct.pack("!L", self.lmep_id)) |
| 2066 | packed.append(struct.pack("!B", self.traffic_class)) |
| 2067 | packed.append('\x00' * 1) |
| 2068 | length = sum([len(x) for x in packed]) |
| 2069 | packed[1] = struct.pack("!H", length) |
| 2070 | return ''.join(packed) |
| 2071 | |
| 2072 | @staticmethod |
| 2073 | def unpack(reader): |
| 2074 | obj = ofdpa_check_drop_status() |
| 2075 | _type = reader.read("!H")[0] |
| 2076 | assert(_type == 65535) |
| 2077 | _len = reader.read("!H")[0] |
| 2078 | orig_reader = reader |
| 2079 | reader = orig_reader.slice(_len, 4) |
| 2080 | _experimenter = reader.read("!L")[0] |
| 2081 | assert(_experimenter == OFDPA_EXPERIMETER) |
| 2082 | _subtype = reader.read("!H")[0] |
| 2083 | assert(_subtype == OFDPA_ACT_OAM_SET_COUNTER_FIELDS) |
| 2084 | obj.lmep_id = reader.read("!L")[0] |
| 2085 | obj.traffic_class = reader.read("!B")[0] |
| 2086 | return obj |
| 2087 | |
| 2088 | def __eq__(self, other): |
| 2089 | if type(self) != type(other): return False |
| 2090 | if self.lmep_id != other.lmep_id: return False |
| 2091 | if self.traffic_class != other.traffic_class: return False |
| 2092 | return True |
| 2093 | |
| 2094 | def pretty_print(self, q): |
| 2095 | q.text("ofdpa_oam_set_counter_field {") |
| 2096 | with q.group(): |
| 2097 | with q.indent(2): |
| 2098 | q.breakable() |
| 2099 | q.text("ofdpa_oam_set_counter_field = "); |
| 2100 | q.pp(self.lmep_id) |
| 2101 | q.pp(self.traffic_class) |
| 2102 | q.breakable() |
| 2103 | q.text('}') |
| 2104 | |
| 2105 | ofdpa.subtypes[OFDPA_ACT_OAM_SET_COUNTER_FIELDS] = ofdpa_oam_set_counter_field |