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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 55 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 113 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 172 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 224 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 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 | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 249 | class bsn_gentable(bsn): |
| 250 | type = 65535 |
| 251 | experimenter = 6035143 |
| 252 | subtype = 5 |
| 253 | |
| 254 | def __init__(self, table_id=None, key=None): |
| 255 | if table_id != None: |
| 256 | self.table_id = table_id |
| 257 | else: |
| 258 | self.table_id = 0 |
| 259 | if key != None: |
| 260 | self.key = key |
| 261 | else: |
| 262 | self.key = [] |
| 263 | return |
| 264 | |
| 265 | def pack(self): |
| 266 | packed = [] |
| 267 | packed.append(struct.pack("!H", self.type)) |
| 268 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 269 | packed.append(struct.pack("!L", self.experimenter)) |
| 270 | packed.append(struct.pack("!L", self.subtype)) |
| 271 | packed.append(struct.pack("!L", self.table_id)) |
| 272 | packed.append(loxi.generic_util.pack_list(self.key)) |
| 273 | length = sum([len(x) for x in packed]) |
| 274 | packed[1] = struct.pack("!H", length) |
| 275 | return ''.join(packed) |
| 276 | |
| 277 | @staticmethod |
| 278 | def unpack(reader): |
| 279 | obj = bsn_gentable() |
| 280 | _type = reader.read("!H")[0] |
| 281 | assert(_type == 65535) |
| 282 | _len = reader.read("!H")[0] |
| 283 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 284 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 2e079da | 2014-10-29 15:30:24 -0700 | [diff] [blame] | 285 | _experimenter = reader.read("!L")[0] |
| 286 | assert(_experimenter == 6035143) |
| 287 | _subtype = reader.read("!L")[0] |
| 288 | assert(_subtype == 5) |
| 289 | obj.table_id = reader.read("!L")[0] |
| 290 | obj.key = loxi.generic_util.unpack_list(reader, bsn_tlv.bsn_tlv.unpack) |
| 291 | return obj |
| 292 | |
| 293 | def __eq__(self, other): |
| 294 | if type(self) != type(other): return False |
| 295 | if self.table_id != other.table_id: return False |
| 296 | if self.key != other.key: return False |
| 297 | return True |
| 298 | |
| 299 | def pretty_print(self, q): |
| 300 | q.text("bsn_gentable {") |
| 301 | with q.group(): |
| 302 | with q.indent(2): |
| 303 | q.breakable() |
| 304 | q.text("table_id = "); |
| 305 | q.text("%#x" % self.table_id) |
| 306 | q.text(","); q.breakable() |
| 307 | q.text("key = "); |
| 308 | q.pp(self.key) |
| 309 | q.breakable() |
| 310 | q.text('}') |
| 311 | |
| 312 | bsn.subtypes[5] = bsn_gentable |
| 313 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 314 | class bsn_mirror(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 315 | type = 65535 |
| 316 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 317 | subtype = 1 |
| 318 | |
| 319 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
| 320 | if dest_port != None: |
| 321 | self.dest_port = dest_port |
| 322 | else: |
| 323 | self.dest_port = 0 |
| 324 | if vlan_tag != None: |
| 325 | self.vlan_tag = vlan_tag |
| 326 | else: |
| 327 | self.vlan_tag = 0 |
| 328 | if copy_stage != None: |
| 329 | self.copy_stage = copy_stage |
| 330 | else: |
| 331 | self.copy_stage = 0 |
| 332 | return |
| 333 | |
| 334 | def pack(self): |
| 335 | packed = [] |
| 336 | packed.append(struct.pack("!H", self.type)) |
| 337 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 338 | packed.append(struct.pack("!L", self.experimenter)) |
| 339 | packed.append(struct.pack("!L", self.subtype)) |
| 340 | packed.append(struct.pack("!L", self.dest_port)) |
| 341 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 342 | packed.append(struct.pack("!B", self.copy_stage)) |
| 343 | packed.append('\x00' * 3) |
| 344 | length = sum([len(x) for x in packed]) |
| 345 | packed[1] = struct.pack("!H", length) |
| 346 | return ''.join(packed) |
| 347 | |
| 348 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 349 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 350 | obj = bsn_mirror() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 351 | _type = reader.read("!H")[0] |
| 352 | assert(_type == 65535) |
| 353 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 354 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 355 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 356 | _experimenter = reader.read("!L")[0] |
| 357 | assert(_experimenter == 6035143) |
| 358 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 359 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 360 | obj.dest_port = reader.read("!L")[0] |
| 361 | obj.vlan_tag = reader.read("!L")[0] |
| 362 | obj.copy_stage = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 363 | reader.skip(3) |
| 364 | return obj |
| 365 | |
| 366 | def __eq__(self, other): |
| 367 | if type(self) != type(other): return False |
| 368 | if self.dest_port != other.dest_port: return False |
| 369 | if self.vlan_tag != other.vlan_tag: return False |
| 370 | if self.copy_stage != other.copy_stage: return False |
| 371 | return True |
| 372 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 373 | def pretty_print(self, q): |
| 374 | q.text("bsn_mirror {") |
| 375 | with q.group(): |
| 376 | with q.indent(2): |
| 377 | q.breakable() |
| 378 | q.text("dest_port = "); |
| 379 | q.text("%#x" % self.dest_port) |
| 380 | q.text(","); q.breakable() |
| 381 | q.text("vlan_tag = "); |
| 382 | q.text("%#x" % self.vlan_tag) |
| 383 | q.text(","); q.breakable() |
| 384 | q.text("copy_stage = "); |
| 385 | q.text("%#x" % self.copy_stage) |
| 386 | q.breakable() |
| 387 | q.text('}') |
| 388 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 389 | bsn.subtypes[1] = bsn_mirror |
| 390 | |
| 391 | class bsn_set_tunnel_dst(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 392 | type = 65535 |
| 393 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 394 | subtype = 2 |
| 395 | |
| 396 | def __init__(self, dst=None): |
| 397 | if dst != None: |
| 398 | self.dst = dst |
| 399 | else: |
| 400 | self.dst = 0 |
| 401 | return |
| 402 | |
| 403 | def pack(self): |
| 404 | packed = [] |
| 405 | packed.append(struct.pack("!H", self.type)) |
| 406 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 407 | packed.append(struct.pack("!L", self.experimenter)) |
| 408 | packed.append(struct.pack("!L", self.subtype)) |
| 409 | packed.append(struct.pack("!L", self.dst)) |
| 410 | length = sum([len(x) for x in packed]) |
| 411 | packed[1] = struct.pack("!H", length) |
| 412 | return ''.join(packed) |
| 413 | |
| 414 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 415 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 416 | obj = bsn_set_tunnel_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 417 | _type = reader.read("!H")[0] |
| 418 | assert(_type == 65535) |
| 419 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 420 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 421 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 422 | _experimenter = reader.read("!L")[0] |
| 423 | assert(_experimenter == 6035143) |
| 424 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 425 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 426 | obj.dst = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 427 | return obj |
| 428 | |
| 429 | def __eq__(self, other): |
| 430 | if type(self) != type(other): return False |
| 431 | if self.dst != other.dst: return False |
| 432 | return True |
| 433 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 434 | def pretty_print(self, q): |
| 435 | q.text("bsn_set_tunnel_dst {") |
| 436 | with q.group(): |
| 437 | with q.indent(2): |
| 438 | q.breakable() |
| 439 | q.text("dst = "); |
| 440 | q.text("%#x" % self.dst) |
| 441 | q.breakable() |
| 442 | q.text('}') |
| 443 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 444 | bsn.subtypes[2] = bsn_set_tunnel_dst |
| 445 | |
| 446 | class copy_ttl_in(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 447 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 448 | |
| 449 | def __init__(self): |
| 450 | return |
| 451 | |
| 452 | def pack(self): |
| 453 | packed = [] |
| 454 | packed.append(struct.pack("!H", self.type)) |
| 455 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 456 | packed.append('\x00' * 4) |
| 457 | length = sum([len(x) for x in packed]) |
| 458 | packed[1] = struct.pack("!H", length) |
| 459 | return ''.join(packed) |
| 460 | |
| 461 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 462 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 463 | obj = copy_ttl_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 464 | _type = reader.read("!H")[0] |
| 465 | assert(_type == 12) |
| 466 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 467 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 468 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 469 | reader.skip(4) |
| 470 | return obj |
| 471 | |
| 472 | def __eq__(self, other): |
| 473 | if type(self) != type(other): return False |
| 474 | return True |
| 475 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 476 | def pretty_print(self, q): |
| 477 | q.text("copy_ttl_in {") |
| 478 | with q.group(): |
| 479 | with q.indent(2): |
| 480 | q.breakable() |
| 481 | q.breakable() |
| 482 | q.text('}') |
| 483 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 484 | action.subtypes[12] = copy_ttl_in |
| 485 | |
| 486 | class copy_ttl_out(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 487 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 488 | |
| 489 | def __init__(self): |
| 490 | return |
| 491 | |
| 492 | def pack(self): |
| 493 | packed = [] |
| 494 | packed.append(struct.pack("!H", self.type)) |
| 495 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 496 | packed.append('\x00' * 4) |
| 497 | length = sum([len(x) for x in packed]) |
| 498 | packed[1] = struct.pack("!H", length) |
| 499 | return ''.join(packed) |
| 500 | |
| 501 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 502 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 503 | obj = copy_ttl_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 504 | _type = reader.read("!H")[0] |
| 505 | assert(_type == 11) |
| 506 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 507 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 508 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 509 | reader.skip(4) |
| 510 | return obj |
| 511 | |
| 512 | def __eq__(self, other): |
| 513 | if type(self) != type(other): return False |
| 514 | return True |
| 515 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 516 | def pretty_print(self, q): |
| 517 | q.text("copy_ttl_out {") |
| 518 | with q.group(): |
| 519 | with q.indent(2): |
| 520 | q.breakable() |
| 521 | q.breakable() |
| 522 | q.text('}') |
| 523 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 524 | action.subtypes[11] = copy_ttl_out |
| 525 | |
| 526 | class dec_mpls_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 527 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 528 | |
| 529 | def __init__(self): |
| 530 | return |
| 531 | |
| 532 | def pack(self): |
| 533 | packed = [] |
| 534 | packed.append(struct.pack("!H", self.type)) |
| 535 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 536 | packed.append('\x00' * 4) |
| 537 | length = sum([len(x) for x in packed]) |
| 538 | packed[1] = struct.pack("!H", length) |
| 539 | return ''.join(packed) |
| 540 | |
| 541 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 542 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 543 | obj = dec_mpls_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 544 | _type = reader.read("!H")[0] |
| 545 | assert(_type == 16) |
| 546 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 547 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 548 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 549 | reader.skip(4) |
| 550 | return obj |
| 551 | |
| 552 | def __eq__(self, other): |
| 553 | if type(self) != type(other): return False |
| 554 | return True |
| 555 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 556 | def pretty_print(self, q): |
| 557 | q.text("dec_mpls_ttl {") |
| 558 | with q.group(): |
| 559 | with q.indent(2): |
| 560 | q.breakable() |
| 561 | q.breakable() |
| 562 | q.text('}') |
| 563 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 564 | action.subtypes[16] = dec_mpls_ttl |
| 565 | |
| 566 | class dec_nw_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 567 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 568 | |
| 569 | def __init__(self): |
| 570 | return |
| 571 | |
| 572 | def pack(self): |
| 573 | packed = [] |
| 574 | packed.append(struct.pack("!H", self.type)) |
| 575 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 576 | packed.append('\x00' * 4) |
| 577 | length = sum([len(x) for x in packed]) |
| 578 | packed[1] = struct.pack("!H", length) |
| 579 | return ''.join(packed) |
| 580 | |
| 581 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 582 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 583 | obj = dec_nw_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 584 | _type = reader.read("!H")[0] |
| 585 | assert(_type == 24) |
| 586 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 587 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 588 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 589 | reader.skip(4) |
| 590 | return obj |
| 591 | |
| 592 | def __eq__(self, other): |
| 593 | if type(self) != type(other): return False |
| 594 | return True |
| 595 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 596 | def pretty_print(self, q): |
| 597 | q.text("dec_nw_ttl {") |
| 598 | with q.group(): |
| 599 | with q.indent(2): |
| 600 | q.breakable() |
| 601 | q.breakable() |
| 602 | q.text('}') |
| 603 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 604 | action.subtypes[24] = dec_nw_ttl |
| 605 | |
| 606 | class group(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 607 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 608 | |
| 609 | def __init__(self, group_id=None): |
| 610 | if group_id != None: |
| 611 | self.group_id = group_id |
| 612 | else: |
| 613 | self.group_id = 0 |
| 614 | return |
| 615 | |
| 616 | def pack(self): |
| 617 | packed = [] |
| 618 | packed.append(struct.pack("!H", self.type)) |
| 619 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 620 | packed.append(struct.pack("!L", self.group_id)) |
| 621 | length = sum([len(x) for x in packed]) |
| 622 | packed[1] = struct.pack("!H", length) |
| 623 | return ''.join(packed) |
| 624 | |
| 625 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 626 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 627 | obj = group() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 628 | _type = reader.read("!H")[0] |
| 629 | assert(_type == 22) |
| 630 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 631 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 632 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 633 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 634 | return obj |
| 635 | |
| 636 | def __eq__(self, other): |
| 637 | if type(self) != type(other): return False |
| 638 | if self.group_id != other.group_id: return False |
| 639 | return True |
| 640 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 641 | def pretty_print(self, q): |
| 642 | q.text("group {") |
| 643 | with q.group(): |
| 644 | with q.indent(2): |
| 645 | q.breakable() |
| 646 | q.text("group_id = "); |
| 647 | q.text("%#x" % self.group_id) |
| 648 | q.breakable() |
| 649 | q.text('}') |
| 650 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 651 | action.subtypes[22] = group |
| 652 | |
| 653 | class nicira(experimenter): |
| 654 | subtypes = {} |
| 655 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 656 | type = 65535 |
| 657 | experimenter = 8992 |
| 658 | |
| 659 | def __init__(self, subtype=None): |
| 660 | if subtype != None: |
| 661 | self.subtype = subtype |
| 662 | else: |
| 663 | self.subtype = 0 |
| 664 | return |
| 665 | |
| 666 | def pack(self): |
| 667 | packed = [] |
| 668 | packed.append(struct.pack("!H", self.type)) |
| 669 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 670 | packed.append(struct.pack("!L", self.experimenter)) |
| 671 | packed.append(struct.pack("!H", self.subtype)) |
| 672 | packed.append('\x00' * 2) |
| 673 | packed.append('\x00' * 4) |
| 674 | length = sum([len(x) for x in packed]) |
| 675 | packed[1] = struct.pack("!H", length) |
| 676 | return ''.join(packed) |
| 677 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 678 | @staticmethod |
| 679 | def unpack(reader): |
| 680 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 681 | subclass = nicira.subtypes.get(subtype) |
| 682 | if subclass: |
| 683 | return subclass.unpack(reader) |
| 684 | |
| 685 | obj = nicira() |
| 686 | _type = reader.read("!H")[0] |
| 687 | assert(_type == 65535) |
| 688 | _len = reader.read("!H")[0] |
| 689 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 690 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 691 | _experimenter = reader.read("!L")[0] |
| 692 | assert(_experimenter == 8992) |
| 693 | obj.subtype = reader.read("!H")[0] |
| 694 | reader.skip(2) |
| 695 | reader.skip(4) |
| 696 | return obj |
| 697 | |
| 698 | def __eq__(self, other): |
| 699 | if type(self) != type(other): return False |
| 700 | if self.subtype != other.subtype: return False |
| 701 | return True |
| 702 | |
| 703 | def pretty_print(self, q): |
| 704 | q.text("nicira {") |
| 705 | with q.group(): |
| 706 | with q.indent(2): |
| 707 | q.breakable() |
| 708 | q.breakable() |
| 709 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 710 | |
| 711 | experimenter.subtypes[8992] = nicira |
| 712 | |
| 713 | class nicira_dec_ttl(nicira): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 714 | type = 65535 |
| 715 | experimenter = 8992 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 716 | subtype = 18 |
| 717 | |
| 718 | def __init__(self): |
| 719 | return |
| 720 | |
| 721 | def pack(self): |
| 722 | packed = [] |
| 723 | packed.append(struct.pack("!H", self.type)) |
| 724 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 725 | packed.append(struct.pack("!L", self.experimenter)) |
| 726 | packed.append(struct.pack("!H", self.subtype)) |
| 727 | packed.append('\x00' * 2) |
| 728 | packed.append('\x00' * 4) |
| 729 | length = sum([len(x) for x in packed]) |
| 730 | packed[1] = struct.pack("!H", length) |
| 731 | return ''.join(packed) |
| 732 | |
| 733 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 734 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 735 | obj = nicira_dec_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 736 | _type = reader.read("!H")[0] |
| 737 | assert(_type == 65535) |
| 738 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 739 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 740 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 741 | _experimenter = reader.read("!L")[0] |
| 742 | assert(_experimenter == 8992) |
| 743 | _subtype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 744 | assert(_subtype == 18) |
| 745 | reader.skip(2) |
| 746 | reader.skip(4) |
| 747 | return obj |
| 748 | |
| 749 | def __eq__(self, other): |
| 750 | if type(self) != type(other): return False |
| 751 | return True |
| 752 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 753 | def pretty_print(self, q): |
| 754 | q.text("nicira_dec_ttl {") |
| 755 | with q.group(): |
| 756 | with q.indent(2): |
| 757 | q.breakable() |
| 758 | q.breakable() |
| 759 | q.text('}') |
| 760 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 761 | nicira.subtypes[18] = nicira_dec_ttl |
| 762 | |
| 763 | class output(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 764 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 765 | |
| 766 | def __init__(self, port=None, max_len=None): |
| 767 | if port != None: |
| 768 | self.port = port |
| 769 | else: |
| 770 | self.port = 0 |
| 771 | if max_len != None: |
| 772 | self.max_len = max_len |
| 773 | else: |
| 774 | self.max_len = 0 |
| 775 | return |
| 776 | |
| 777 | def pack(self): |
| 778 | packed = [] |
| 779 | packed.append(struct.pack("!H", self.type)) |
| 780 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 781 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 782 | packed.append(struct.pack("!H", self.max_len)) |
| 783 | packed.append('\x00' * 6) |
| 784 | length = sum([len(x) for x in packed]) |
| 785 | packed[1] = struct.pack("!H", length) |
| 786 | return ''.join(packed) |
| 787 | |
| 788 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 789 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 790 | obj = output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 791 | _type = reader.read("!H")[0] |
| 792 | assert(_type == 0) |
| 793 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 794 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 795 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 796 | obj.port = util.unpack_port_no(reader) |
| 797 | obj.max_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 798 | reader.skip(6) |
| 799 | return obj |
| 800 | |
| 801 | def __eq__(self, other): |
| 802 | if type(self) != type(other): return False |
| 803 | if self.port != other.port: return False |
| 804 | if self.max_len != other.max_len: return False |
| 805 | return True |
| 806 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 807 | def pretty_print(self, q): |
| 808 | q.text("output {") |
| 809 | with q.group(): |
| 810 | with q.indent(2): |
| 811 | q.breakable() |
| 812 | q.text("port = "); |
| 813 | q.text(util.pretty_port(self.port)) |
| 814 | q.text(","); q.breakable() |
| 815 | q.text("max_len = "); |
| 816 | q.text("%#x" % self.max_len) |
| 817 | q.breakable() |
| 818 | q.text('}') |
| 819 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 820 | action.subtypes[0] = output |
| 821 | |
| 822 | class pop_mpls(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 823 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 824 | |
| 825 | def __init__(self, ethertype=None): |
| 826 | if ethertype != None: |
| 827 | self.ethertype = ethertype |
| 828 | else: |
| 829 | self.ethertype = 0 |
| 830 | return |
| 831 | |
| 832 | def pack(self): |
| 833 | packed = [] |
| 834 | packed.append(struct.pack("!H", self.type)) |
| 835 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 836 | packed.append(struct.pack("!H", self.ethertype)) |
| 837 | packed.append('\x00' * 2) |
| 838 | length = sum([len(x) for x in packed]) |
| 839 | packed[1] = struct.pack("!H", length) |
| 840 | return ''.join(packed) |
| 841 | |
| 842 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 843 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 844 | obj = pop_mpls() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 845 | _type = reader.read("!H")[0] |
| 846 | assert(_type == 20) |
| 847 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 848 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 849 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 850 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 851 | reader.skip(2) |
| 852 | return obj |
| 853 | |
| 854 | def __eq__(self, other): |
| 855 | if type(self) != type(other): return False |
| 856 | if self.ethertype != other.ethertype: return False |
| 857 | return True |
| 858 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 859 | def pretty_print(self, q): |
| 860 | q.text("pop_mpls {") |
| 861 | with q.group(): |
| 862 | with q.indent(2): |
| 863 | q.breakable() |
| 864 | q.text("ethertype = "); |
| 865 | q.text("%#x" % self.ethertype) |
| 866 | q.breakable() |
| 867 | q.text('}') |
| 868 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 869 | action.subtypes[20] = pop_mpls |
| 870 | |
| 871 | class pop_pbb(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 872 | type = 27 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 873 | |
| 874 | def __init__(self): |
| 875 | return |
| 876 | |
| 877 | def pack(self): |
| 878 | packed = [] |
| 879 | packed.append(struct.pack("!H", self.type)) |
| 880 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 881 | packed.append('\x00' * 4) |
| 882 | length = sum([len(x) for x in packed]) |
| 883 | packed[1] = struct.pack("!H", length) |
| 884 | return ''.join(packed) |
| 885 | |
| 886 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 887 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 888 | obj = pop_pbb() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 889 | _type = reader.read("!H")[0] |
| 890 | assert(_type == 27) |
| 891 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 892 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 893 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 894 | reader.skip(4) |
| 895 | return obj |
| 896 | |
| 897 | def __eq__(self, other): |
| 898 | if type(self) != type(other): return False |
| 899 | return True |
| 900 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 901 | def pretty_print(self, q): |
| 902 | q.text("pop_pbb {") |
| 903 | with q.group(): |
| 904 | with q.indent(2): |
| 905 | q.breakable() |
| 906 | q.breakable() |
| 907 | q.text('}') |
| 908 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 909 | action.subtypes[27] = pop_pbb |
| 910 | |
| 911 | class pop_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 912 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 913 | |
| 914 | def __init__(self): |
| 915 | return |
| 916 | |
| 917 | def pack(self): |
| 918 | packed = [] |
| 919 | packed.append(struct.pack("!H", self.type)) |
| 920 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 921 | packed.append('\x00' * 4) |
| 922 | length = sum([len(x) for x in packed]) |
| 923 | packed[1] = struct.pack("!H", length) |
| 924 | return ''.join(packed) |
| 925 | |
| 926 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 927 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 928 | obj = pop_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 929 | _type = reader.read("!H")[0] |
| 930 | assert(_type == 18) |
| 931 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 932 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 933 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 934 | reader.skip(4) |
| 935 | return obj |
| 936 | |
| 937 | def __eq__(self, other): |
| 938 | if type(self) != type(other): return False |
| 939 | return True |
| 940 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 941 | def pretty_print(self, q): |
| 942 | q.text("pop_vlan {") |
| 943 | with q.group(): |
| 944 | with q.indent(2): |
| 945 | q.breakable() |
| 946 | q.breakable() |
| 947 | q.text('}') |
| 948 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 949 | action.subtypes[18] = pop_vlan |
| 950 | |
| 951 | class push_mpls(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 952 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 953 | |
| 954 | def __init__(self, ethertype=None): |
| 955 | if ethertype != None: |
| 956 | self.ethertype = ethertype |
| 957 | else: |
| 958 | self.ethertype = 0 |
| 959 | return |
| 960 | |
| 961 | def pack(self): |
| 962 | packed = [] |
| 963 | packed.append(struct.pack("!H", self.type)) |
| 964 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 965 | packed.append(struct.pack("!H", self.ethertype)) |
| 966 | packed.append('\x00' * 2) |
| 967 | length = sum([len(x) for x in packed]) |
| 968 | packed[1] = struct.pack("!H", length) |
| 969 | return ''.join(packed) |
| 970 | |
| 971 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 972 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 973 | obj = push_mpls() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 974 | _type = reader.read("!H")[0] |
| 975 | assert(_type == 19) |
| 976 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 977 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 978 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 979 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 980 | reader.skip(2) |
| 981 | return obj |
| 982 | |
| 983 | def __eq__(self, other): |
| 984 | if type(self) != type(other): return False |
| 985 | if self.ethertype != other.ethertype: return False |
| 986 | return True |
| 987 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 988 | def pretty_print(self, q): |
| 989 | q.text("push_mpls {") |
| 990 | with q.group(): |
| 991 | with q.indent(2): |
| 992 | q.breakable() |
| 993 | q.text("ethertype = "); |
| 994 | q.text("%#x" % self.ethertype) |
| 995 | q.breakable() |
| 996 | q.text('}') |
| 997 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 998 | action.subtypes[19] = push_mpls |
| 999 | |
| 1000 | class push_pbb(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1001 | type = 26 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1002 | |
| 1003 | def __init__(self, ethertype=None): |
| 1004 | if ethertype != None: |
| 1005 | self.ethertype = ethertype |
| 1006 | else: |
| 1007 | self.ethertype = 0 |
| 1008 | return |
| 1009 | |
| 1010 | def pack(self): |
| 1011 | packed = [] |
| 1012 | packed.append(struct.pack("!H", self.type)) |
| 1013 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1014 | packed.append(struct.pack("!H", self.ethertype)) |
| 1015 | packed.append('\x00' * 2) |
| 1016 | length = sum([len(x) for x in packed]) |
| 1017 | packed[1] = struct.pack("!H", length) |
| 1018 | return ''.join(packed) |
| 1019 | |
| 1020 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1021 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1022 | obj = push_pbb() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1023 | _type = reader.read("!H")[0] |
| 1024 | assert(_type == 26) |
| 1025 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1026 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 1027 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1028 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1029 | reader.skip(2) |
| 1030 | return obj |
| 1031 | |
| 1032 | def __eq__(self, other): |
| 1033 | if type(self) != type(other): return False |
| 1034 | if self.ethertype != other.ethertype: return False |
| 1035 | return True |
| 1036 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1037 | def pretty_print(self, q): |
| 1038 | q.text("push_pbb {") |
| 1039 | with q.group(): |
| 1040 | with q.indent(2): |
| 1041 | q.breakable() |
| 1042 | q.text("ethertype = "); |
| 1043 | q.text("%#x" % self.ethertype) |
| 1044 | q.breakable() |
| 1045 | q.text('}') |
| 1046 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1047 | action.subtypes[26] = push_pbb |
| 1048 | |
| 1049 | class push_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1050 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1051 | |
| 1052 | def __init__(self, ethertype=None): |
| 1053 | if ethertype != None: |
| 1054 | self.ethertype = ethertype |
| 1055 | else: |
| 1056 | self.ethertype = 0 |
| 1057 | return |
| 1058 | |
| 1059 | def pack(self): |
| 1060 | packed = [] |
| 1061 | packed.append(struct.pack("!H", self.type)) |
| 1062 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1063 | packed.append(struct.pack("!H", self.ethertype)) |
| 1064 | packed.append('\x00' * 2) |
| 1065 | length = sum([len(x) for x in packed]) |
| 1066 | packed[1] = struct.pack("!H", length) |
| 1067 | return ''.join(packed) |
| 1068 | |
| 1069 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1070 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1071 | obj = push_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1072 | _type = reader.read("!H")[0] |
| 1073 | assert(_type == 17) |
| 1074 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1075 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 1076 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1077 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1078 | reader.skip(2) |
| 1079 | return obj |
| 1080 | |
| 1081 | def __eq__(self, other): |
| 1082 | if type(self) != type(other): return False |
| 1083 | if self.ethertype != other.ethertype: return False |
| 1084 | return True |
| 1085 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1086 | def pretty_print(self, q): |
| 1087 | q.text("push_vlan {") |
| 1088 | with q.group(): |
| 1089 | with q.indent(2): |
| 1090 | q.breakable() |
| 1091 | q.text("ethertype = "); |
| 1092 | q.text("%#x" % self.ethertype) |
| 1093 | q.breakable() |
| 1094 | q.text('}') |
| 1095 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1096 | action.subtypes[17] = push_vlan |
| 1097 | |
| 1098 | class set_field(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1099 | type = 25 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1100 | |
| 1101 | def __init__(self, field=None): |
| 1102 | if field != None: |
| 1103 | self.field = field |
| 1104 | else: |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1105 | self.field = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1106 | return |
| 1107 | |
| 1108 | def pack(self): |
| 1109 | packed = [] |
| 1110 | packed.append(struct.pack("!H", self.type)) |
| 1111 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1112 | packed.append(self.field.pack()) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1113 | length = sum([len(x) for x in packed]) |
Rich Lane | d53156a | 2013-08-05 17:17:33 -0700 | [diff] [blame] | 1114 | packed.append(loxi.generic_util.pad_to(8, length)) |
| 1115 | length += len(packed[-1]) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1116 | packed[1] = struct.pack("!H", length) |
| 1117 | return ''.join(packed) |
| 1118 | |
| 1119 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1120 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1121 | obj = set_field() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1122 | _type = reader.read("!H")[0] |
| 1123 | assert(_type == 25) |
| 1124 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1125 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 1126 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1127 | obj.field = oxm.oxm.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1128 | return obj |
| 1129 | |
| 1130 | def __eq__(self, other): |
| 1131 | if type(self) != type(other): return False |
| 1132 | if self.field != other.field: return False |
| 1133 | return True |
| 1134 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1135 | def pretty_print(self, q): |
| 1136 | q.text("set_field {") |
| 1137 | with q.group(): |
| 1138 | with q.indent(2): |
| 1139 | q.breakable() |
| 1140 | q.text("field = "); |
| 1141 | q.pp(self.field) |
| 1142 | q.breakable() |
| 1143 | q.text('}') |
| 1144 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1145 | action.subtypes[25] = set_field |
| 1146 | |
| 1147 | class set_mpls_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1148 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1149 | |
| 1150 | def __init__(self, mpls_ttl=None): |
| 1151 | if mpls_ttl != None: |
| 1152 | self.mpls_ttl = mpls_ttl |
| 1153 | else: |
| 1154 | self.mpls_ttl = 0 |
| 1155 | return |
| 1156 | |
| 1157 | def pack(self): |
| 1158 | packed = [] |
| 1159 | packed.append(struct.pack("!H", self.type)) |
| 1160 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1161 | packed.append(struct.pack("!B", self.mpls_ttl)) |
| 1162 | packed.append('\x00' * 3) |
| 1163 | length = sum([len(x) for x in packed]) |
| 1164 | packed[1] = struct.pack("!H", length) |
| 1165 | return ''.join(packed) |
| 1166 | |
| 1167 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1168 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1169 | obj = set_mpls_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1170 | _type = reader.read("!H")[0] |
| 1171 | assert(_type == 15) |
| 1172 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1173 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 1174 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1175 | obj.mpls_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1176 | reader.skip(3) |
| 1177 | return obj |
| 1178 | |
| 1179 | def __eq__(self, other): |
| 1180 | if type(self) != type(other): return False |
| 1181 | if self.mpls_ttl != other.mpls_ttl: return False |
| 1182 | return True |
| 1183 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1184 | def pretty_print(self, q): |
| 1185 | q.text("set_mpls_ttl {") |
| 1186 | with q.group(): |
| 1187 | with q.indent(2): |
| 1188 | q.breakable() |
| 1189 | q.text("mpls_ttl = "); |
| 1190 | q.text("%#x" % self.mpls_ttl) |
| 1191 | q.breakable() |
| 1192 | q.text('}') |
| 1193 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1194 | action.subtypes[15] = set_mpls_ttl |
| 1195 | |
| 1196 | class set_nw_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1197 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1198 | |
| 1199 | def __init__(self, nw_ttl=None): |
| 1200 | if nw_ttl != None: |
| 1201 | self.nw_ttl = nw_ttl |
| 1202 | else: |
| 1203 | self.nw_ttl = 0 |
| 1204 | return |
| 1205 | |
| 1206 | def pack(self): |
| 1207 | packed = [] |
| 1208 | packed.append(struct.pack("!H", self.type)) |
| 1209 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1210 | packed.append(struct.pack("!B", self.nw_ttl)) |
| 1211 | packed.append('\x00' * 3) |
| 1212 | length = sum([len(x) for x in packed]) |
| 1213 | packed[1] = struct.pack("!H", length) |
| 1214 | return ''.join(packed) |
| 1215 | |
| 1216 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1217 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1218 | obj = set_nw_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1219 | _type = reader.read("!H")[0] |
| 1220 | assert(_type == 23) |
| 1221 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1222 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 1223 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1224 | obj.nw_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1225 | reader.skip(3) |
| 1226 | return obj |
| 1227 | |
| 1228 | def __eq__(self, other): |
| 1229 | if type(self) != type(other): return False |
| 1230 | if self.nw_ttl != other.nw_ttl: return False |
| 1231 | return True |
| 1232 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1233 | def pretty_print(self, q): |
| 1234 | q.text("set_nw_ttl {") |
| 1235 | with q.group(): |
| 1236 | with q.indent(2): |
| 1237 | q.breakable() |
| 1238 | q.text("nw_ttl = "); |
| 1239 | q.text("%#x" % self.nw_ttl) |
| 1240 | q.breakable() |
| 1241 | q.text('}') |
| 1242 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1243 | action.subtypes[23] = set_nw_ttl |
| 1244 | |
| 1245 | class set_queue(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1246 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1247 | |
| 1248 | def __init__(self, queue_id=None): |
| 1249 | if queue_id != None: |
| 1250 | self.queue_id = queue_id |
| 1251 | else: |
| 1252 | self.queue_id = 0 |
| 1253 | return |
| 1254 | |
| 1255 | def pack(self): |
| 1256 | packed = [] |
| 1257 | packed.append(struct.pack("!H", self.type)) |
| 1258 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1259 | packed.append(struct.pack("!L", self.queue_id)) |
| 1260 | length = sum([len(x) for x in packed]) |
| 1261 | packed[1] = struct.pack("!H", length) |
| 1262 | return ''.join(packed) |
| 1263 | |
| 1264 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1265 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1266 | obj = set_queue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1267 | _type = reader.read("!H")[0] |
| 1268 | assert(_type == 21) |
| 1269 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1270 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame^] | 1271 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1272 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1273 | return obj |
| 1274 | |
| 1275 | def __eq__(self, other): |
| 1276 | if type(self) != type(other): return False |
| 1277 | if self.queue_id != other.queue_id: return False |
| 1278 | return True |
| 1279 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1280 | def pretty_print(self, q): |
| 1281 | q.text("set_queue {") |
| 1282 | with q.group(): |
| 1283 | with q.indent(2): |
| 1284 | q.breakable() |
| 1285 | q.text("queue_id = "); |
| 1286 | q.text("%#x" % self.queue_id) |
| 1287 | q.breakable() |
| 1288 | q.text('}') |
| 1289 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1290 | action.subtypes[21] = set_queue |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1291 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1292 | |