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 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 12 | import action |
Harshmeet Singh | 1db4633 | 2014-10-14 16:29:13 -0700 | [diff] [blame^] | 13 | import message |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 14 | import instruction |
Harshmeet Singh | 1db4633 | 2014-10-14 16:29:13 -0700 | [diff] [blame^] | 15 | import common |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 16 | import util |
| 17 | import loxi.generic_util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 18 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 19 | class action(loxi.OFObject): |
| 20 | subtypes = {} |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 21 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 22 | |
| 23 | def __init__(self, type=None): |
| 24 | if type != None: |
| 25 | self.type = type |
| 26 | else: |
| 27 | self.type = 0 |
| 28 | return |
| 29 | |
| 30 | def pack(self): |
| 31 | packed = [] |
| 32 | packed.append(struct.pack("!H", self.type)) |
| 33 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 34 | packed.append('\x00' * 4) |
| 35 | length = sum([len(x) for x in packed]) |
| 36 | packed[1] = struct.pack("!H", length) |
| 37 | return ''.join(packed) |
| 38 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 39 | @staticmethod |
| 40 | def unpack(reader): |
| 41 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 42 | subclass = action.subtypes.get(subtype) |
| 43 | if subclass: |
| 44 | return subclass.unpack(reader) |
| 45 | |
| 46 | obj = action() |
| 47 | obj.type = reader.read("!H")[0] |
| 48 | _len = reader.read("!H")[0] |
| 49 | orig_reader = reader |
| 50 | reader = orig_reader.slice(_len - (2 + 2)) |
| 51 | reader.skip(4) |
| 52 | return obj |
| 53 | |
| 54 | def __eq__(self, other): |
| 55 | if type(self) != type(other): return False |
| 56 | if self.type != other.type: return False |
| 57 | return True |
| 58 | |
| 59 | def pretty_print(self, q): |
| 60 | q.text("action {") |
| 61 | with q.group(): |
| 62 | with q.indent(2): |
| 63 | q.breakable() |
| 64 | q.breakable() |
| 65 | q.text('}') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 66 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 67 | |
| 68 | class experimenter(action): |
| 69 | subtypes = {} |
| 70 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 71 | type = 65535 |
| 72 | |
| 73 | def __init__(self, experimenter=None, data=None): |
| 74 | if experimenter != None: |
| 75 | self.experimenter = experimenter |
| 76 | else: |
| 77 | self.experimenter = 0 |
| 78 | if data != None: |
| 79 | self.data = data |
| 80 | else: |
| 81 | self.data = '' |
| 82 | return |
| 83 | |
| 84 | def pack(self): |
| 85 | packed = [] |
| 86 | packed.append(struct.pack("!H", self.type)) |
| 87 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 88 | packed.append(struct.pack("!L", self.experimenter)) |
| 89 | packed.append(self.data) |
| 90 | length = sum([len(x) for x in packed]) |
| 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 |
| 106 | reader = orig_reader.slice(_len - (2 + 2)) |
| 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 |
| 128 | |
| 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 |
| 165 | reader = orig_reader.slice(_len - (2 + 2)) |
| 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 |
| 217 | reader = orig_reader.slice(_len - (2 + 2)) |
| 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 | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 242 | class bsn_mirror(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 243 | type = 65535 |
| 244 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 245 | subtype = 1 |
| 246 | |
| 247 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
| 248 | if dest_port != None: |
| 249 | self.dest_port = dest_port |
| 250 | else: |
| 251 | self.dest_port = 0 |
| 252 | if vlan_tag != None: |
| 253 | self.vlan_tag = vlan_tag |
| 254 | else: |
| 255 | self.vlan_tag = 0 |
| 256 | if copy_stage != None: |
| 257 | self.copy_stage = copy_stage |
| 258 | else: |
| 259 | self.copy_stage = 0 |
| 260 | return |
| 261 | |
| 262 | def pack(self): |
| 263 | packed = [] |
| 264 | packed.append(struct.pack("!H", self.type)) |
| 265 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 266 | packed.append(struct.pack("!L", self.experimenter)) |
| 267 | packed.append(struct.pack("!L", self.subtype)) |
| 268 | packed.append(struct.pack("!L", self.dest_port)) |
| 269 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 270 | packed.append(struct.pack("!B", self.copy_stage)) |
| 271 | packed.append('\x00' * 3) |
| 272 | length = sum([len(x) for x in packed]) |
| 273 | packed[1] = struct.pack("!H", length) |
| 274 | return ''.join(packed) |
| 275 | |
| 276 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 277 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 278 | obj = bsn_mirror() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 279 | _type = reader.read("!H")[0] |
| 280 | assert(_type == 65535) |
| 281 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 282 | orig_reader = reader |
| 283 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 284 | _experimenter = reader.read("!L")[0] |
| 285 | assert(_experimenter == 6035143) |
| 286 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 287 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 288 | obj.dest_port = reader.read("!L")[0] |
| 289 | obj.vlan_tag = reader.read("!L")[0] |
| 290 | obj.copy_stage = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 291 | reader.skip(3) |
| 292 | return obj |
| 293 | |
| 294 | def __eq__(self, other): |
| 295 | if type(self) != type(other): return False |
| 296 | if self.dest_port != other.dest_port: return False |
| 297 | if self.vlan_tag != other.vlan_tag: return False |
| 298 | if self.copy_stage != other.copy_stage: return False |
| 299 | return True |
| 300 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 301 | def pretty_print(self, q): |
| 302 | q.text("bsn_mirror {") |
| 303 | with q.group(): |
| 304 | with q.indent(2): |
| 305 | q.breakable() |
| 306 | q.text("dest_port = "); |
| 307 | q.text("%#x" % self.dest_port) |
| 308 | q.text(","); q.breakable() |
| 309 | q.text("vlan_tag = "); |
| 310 | q.text("%#x" % self.vlan_tag) |
| 311 | q.text(","); q.breakable() |
| 312 | q.text("copy_stage = "); |
| 313 | q.text("%#x" % self.copy_stage) |
| 314 | q.breakable() |
| 315 | q.text('}') |
| 316 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 317 | bsn.subtypes[1] = bsn_mirror |
| 318 | |
| 319 | class bsn_set_tunnel_dst(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 320 | type = 65535 |
| 321 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 322 | subtype = 2 |
| 323 | |
| 324 | def __init__(self, dst=None): |
| 325 | if dst != None: |
| 326 | self.dst = dst |
| 327 | else: |
| 328 | self.dst = 0 |
| 329 | return |
| 330 | |
| 331 | def pack(self): |
| 332 | packed = [] |
| 333 | packed.append(struct.pack("!H", self.type)) |
| 334 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 335 | packed.append(struct.pack("!L", self.experimenter)) |
| 336 | packed.append(struct.pack("!L", self.subtype)) |
| 337 | packed.append(struct.pack("!L", self.dst)) |
| 338 | length = sum([len(x) for x in packed]) |
| 339 | packed[1] = struct.pack("!H", length) |
| 340 | return ''.join(packed) |
| 341 | |
| 342 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 343 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 344 | obj = bsn_set_tunnel_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 345 | _type = reader.read("!H")[0] |
| 346 | assert(_type == 65535) |
| 347 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 348 | orig_reader = reader |
| 349 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 350 | _experimenter = reader.read("!L")[0] |
| 351 | assert(_experimenter == 6035143) |
| 352 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 353 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 354 | obj.dst = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 355 | return obj |
| 356 | |
| 357 | def __eq__(self, other): |
| 358 | if type(self) != type(other): return False |
| 359 | if self.dst != other.dst: return False |
| 360 | return True |
| 361 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 362 | def pretty_print(self, q): |
| 363 | q.text("bsn_set_tunnel_dst {") |
| 364 | with q.group(): |
| 365 | with q.indent(2): |
| 366 | q.breakable() |
| 367 | q.text("dst = "); |
| 368 | q.text("%#x" % self.dst) |
| 369 | q.breakable() |
| 370 | q.text('}') |
| 371 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 372 | bsn.subtypes[2] = bsn_set_tunnel_dst |
| 373 | |
| 374 | class copy_ttl_in(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 375 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 376 | |
| 377 | def __init__(self): |
| 378 | return |
| 379 | |
| 380 | def pack(self): |
| 381 | packed = [] |
| 382 | packed.append(struct.pack("!H", self.type)) |
| 383 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 384 | packed.append('\x00' * 4) |
| 385 | length = sum([len(x) for x in packed]) |
| 386 | packed[1] = struct.pack("!H", length) |
| 387 | return ''.join(packed) |
| 388 | |
| 389 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 390 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 391 | obj = copy_ttl_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 392 | _type = reader.read("!H")[0] |
| 393 | assert(_type == 12) |
| 394 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 395 | orig_reader = reader |
| 396 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 397 | reader.skip(4) |
| 398 | return obj |
| 399 | |
| 400 | def __eq__(self, other): |
| 401 | if type(self) != type(other): return False |
| 402 | return True |
| 403 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 404 | def pretty_print(self, q): |
| 405 | q.text("copy_ttl_in {") |
| 406 | with q.group(): |
| 407 | with q.indent(2): |
| 408 | q.breakable() |
| 409 | q.breakable() |
| 410 | q.text('}') |
| 411 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 412 | action.subtypes[12] = copy_ttl_in |
| 413 | |
| 414 | class copy_ttl_out(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 415 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 416 | |
| 417 | def __init__(self): |
| 418 | return |
| 419 | |
| 420 | def pack(self): |
| 421 | packed = [] |
| 422 | packed.append(struct.pack("!H", self.type)) |
| 423 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 424 | packed.append('\x00' * 4) |
| 425 | length = sum([len(x) for x in packed]) |
| 426 | packed[1] = struct.pack("!H", length) |
| 427 | return ''.join(packed) |
| 428 | |
| 429 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 430 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 431 | obj = copy_ttl_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 432 | _type = reader.read("!H")[0] |
| 433 | assert(_type == 11) |
| 434 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 435 | orig_reader = reader |
| 436 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 437 | reader.skip(4) |
| 438 | return obj |
| 439 | |
| 440 | def __eq__(self, other): |
| 441 | if type(self) != type(other): return False |
| 442 | return True |
| 443 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 444 | def pretty_print(self, q): |
| 445 | q.text("copy_ttl_out {") |
| 446 | with q.group(): |
| 447 | with q.indent(2): |
| 448 | q.breakable() |
| 449 | q.breakable() |
| 450 | q.text('}') |
| 451 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 452 | action.subtypes[11] = copy_ttl_out |
| 453 | |
| 454 | class dec_mpls_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 455 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 456 | |
| 457 | def __init__(self): |
| 458 | return |
| 459 | |
| 460 | def pack(self): |
| 461 | packed = [] |
| 462 | packed.append(struct.pack("!H", self.type)) |
| 463 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 464 | packed.append('\x00' * 4) |
| 465 | length = sum([len(x) for x in packed]) |
| 466 | packed[1] = struct.pack("!H", length) |
| 467 | return ''.join(packed) |
| 468 | |
| 469 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 470 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 471 | obj = dec_mpls_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 472 | _type = reader.read("!H")[0] |
| 473 | assert(_type == 16) |
| 474 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 475 | orig_reader = reader |
| 476 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 477 | reader.skip(4) |
| 478 | return obj |
| 479 | |
| 480 | def __eq__(self, other): |
| 481 | if type(self) != type(other): return False |
| 482 | return True |
| 483 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 484 | def pretty_print(self, q): |
| 485 | q.text("dec_mpls_ttl {") |
| 486 | with q.group(): |
| 487 | with q.indent(2): |
| 488 | q.breakable() |
| 489 | q.breakable() |
| 490 | q.text('}') |
| 491 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 492 | action.subtypes[16] = dec_mpls_ttl |
| 493 | |
| 494 | class dec_nw_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 495 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 496 | |
| 497 | def __init__(self): |
| 498 | return |
| 499 | |
| 500 | def pack(self): |
| 501 | packed = [] |
| 502 | packed.append(struct.pack("!H", self.type)) |
| 503 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 504 | packed.append('\x00' * 4) |
| 505 | length = sum([len(x) for x in packed]) |
| 506 | packed[1] = struct.pack("!H", length) |
| 507 | return ''.join(packed) |
| 508 | |
| 509 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 510 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 511 | obj = dec_nw_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 512 | _type = reader.read("!H")[0] |
| 513 | assert(_type == 24) |
| 514 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 515 | orig_reader = reader |
| 516 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 517 | reader.skip(4) |
| 518 | return obj |
| 519 | |
| 520 | def __eq__(self, other): |
| 521 | if type(self) != type(other): return False |
| 522 | return True |
| 523 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 524 | def pretty_print(self, q): |
| 525 | q.text("dec_nw_ttl {") |
| 526 | with q.group(): |
| 527 | with q.indent(2): |
| 528 | q.breakable() |
| 529 | q.breakable() |
| 530 | q.text('}') |
| 531 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 532 | action.subtypes[24] = dec_nw_ttl |
| 533 | |
| 534 | class group(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 535 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 536 | |
| 537 | def __init__(self, group_id=None): |
| 538 | if group_id != None: |
| 539 | self.group_id = group_id |
| 540 | else: |
| 541 | self.group_id = 0 |
| 542 | return |
| 543 | |
| 544 | def pack(self): |
| 545 | packed = [] |
| 546 | packed.append(struct.pack("!H", self.type)) |
| 547 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 548 | packed.append(struct.pack("!L", self.group_id)) |
| 549 | length = sum([len(x) for x in packed]) |
| 550 | packed[1] = struct.pack("!H", length) |
| 551 | return ''.join(packed) |
| 552 | |
| 553 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 554 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 555 | obj = group() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 556 | _type = reader.read("!H")[0] |
| 557 | assert(_type == 22) |
| 558 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 559 | orig_reader = reader |
| 560 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 561 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 562 | return obj |
| 563 | |
| 564 | def __eq__(self, other): |
| 565 | if type(self) != type(other): return False |
| 566 | if self.group_id != other.group_id: return False |
| 567 | return True |
| 568 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 569 | def pretty_print(self, q): |
| 570 | q.text("group {") |
| 571 | with q.group(): |
| 572 | with q.indent(2): |
| 573 | q.breakable() |
| 574 | q.text("group_id = "); |
| 575 | q.text("%#x" % self.group_id) |
| 576 | q.breakable() |
| 577 | q.text('}') |
| 578 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 579 | action.subtypes[22] = group |
| 580 | |
| 581 | class nicira(experimenter): |
| 582 | subtypes = {} |
| 583 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 584 | type = 65535 |
| 585 | experimenter = 8992 |
| 586 | |
| 587 | def __init__(self, subtype=None): |
| 588 | if subtype != None: |
| 589 | self.subtype = subtype |
| 590 | else: |
| 591 | self.subtype = 0 |
| 592 | return |
| 593 | |
| 594 | def pack(self): |
| 595 | packed = [] |
| 596 | packed.append(struct.pack("!H", self.type)) |
| 597 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 598 | packed.append(struct.pack("!L", self.experimenter)) |
| 599 | packed.append(struct.pack("!H", self.subtype)) |
| 600 | packed.append('\x00' * 2) |
| 601 | packed.append('\x00' * 4) |
| 602 | length = sum([len(x) for x in packed]) |
| 603 | packed[1] = struct.pack("!H", length) |
| 604 | return ''.join(packed) |
| 605 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 606 | @staticmethod |
| 607 | def unpack(reader): |
| 608 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 609 | subclass = nicira.subtypes.get(subtype) |
| 610 | if subclass: |
| 611 | return subclass.unpack(reader) |
| 612 | |
| 613 | obj = nicira() |
| 614 | _type = reader.read("!H")[0] |
| 615 | assert(_type == 65535) |
| 616 | _len = reader.read("!H")[0] |
| 617 | orig_reader = reader |
| 618 | reader = orig_reader.slice(_len - (2 + 2)) |
| 619 | _experimenter = reader.read("!L")[0] |
| 620 | assert(_experimenter == 8992) |
| 621 | obj.subtype = reader.read("!H")[0] |
| 622 | reader.skip(2) |
| 623 | reader.skip(4) |
| 624 | return obj |
| 625 | |
| 626 | def __eq__(self, other): |
| 627 | if type(self) != type(other): return False |
| 628 | if self.subtype != other.subtype: return False |
| 629 | return True |
| 630 | |
| 631 | def pretty_print(self, q): |
| 632 | q.text("nicira {") |
| 633 | with q.group(): |
| 634 | with q.indent(2): |
| 635 | q.breakable() |
| 636 | q.breakable() |
| 637 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 638 | |
| 639 | experimenter.subtypes[8992] = nicira |
| 640 | |
| 641 | class nicira_dec_ttl(nicira): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 642 | type = 65535 |
| 643 | experimenter = 8992 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 644 | subtype = 18 |
| 645 | |
| 646 | def __init__(self): |
| 647 | return |
| 648 | |
| 649 | def pack(self): |
| 650 | packed = [] |
| 651 | packed.append(struct.pack("!H", self.type)) |
| 652 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 653 | packed.append(struct.pack("!L", self.experimenter)) |
| 654 | packed.append(struct.pack("!H", self.subtype)) |
| 655 | packed.append('\x00' * 2) |
| 656 | packed.append('\x00' * 4) |
| 657 | length = sum([len(x) for x in packed]) |
| 658 | packed[1] = struct.pack("!H", length) |
| 659 | return ''.join(packed) |
| 660 | |
| 661 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 662 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 663 | obj = nicira_dec_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 664 | _type = reader.read("!H")[0] |
| 665 | assert(_type == 65535) |
| 666 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 667 | orig_reader = reader |
| 668 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 669 | _experimenter = reader.read("!L")[0] |
| 670 | assert(_experimenter == 8992) |
| 671 | _subtype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 672 | assert(_subtype == 18) |
| 673 | reader.skip(2) |
| 674 | reader.skip(4) |
| 675 | return obj |
| 676 | |
| 677 | def __eq__(self, other): |
| 678 | if type(self) != type(other): return False |
| 679 | return True |
| 680 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 681 | def pretty_print(self, q): |
| 682 | q.text("nicira_dec_ttl {") |
| 683 | with q.group(): |
| 684 | with q.indent(2): |
| 685 | q.breakable() |
| 686 | q.breakable() |
| 687 | q.text('}') |
| 688 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 689 | nicira.subtypes[18] = nicira_dec_ttl |
| 690 | |
| 691 | class output(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 692 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 693 | |
| 694 | def __init__(self, port=None, max_len=None): |
| 695 | if port != None: |
| 696 | self.port = port |
| 697 | else: |
| 698 | self.port = 0 |
| 699 | if max_len != None: |
| 700 | self.max_len = max_len |
| 701 | else: |
| 702 | self.max_len = 0 |
| 703 | return |
| 704 | |
| 705 | def pack(self): |
| 706 | packed = [] |
| 707 | packed.append(struct.pack("!H", self.type)) |
| 708 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 709 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 710 | packed.append(struct.pack("!H", self.max_len)) |
| 711 | packed.append('\x00' * 6) |
| 712 | length = sum([len(x) for x in packed]) |
| 713 | packed[1] = struct.pack("!H", length) |
| 714 | return ''.join(packed) |
| 715 | |
| 716 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 717 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 718 | obj = output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 719 | _type = reader.read("!H")[0] |
| 720 | assert(_type == 0) |
| 721 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 722 | orig_reader = reader |
| 723 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 724 | obj.port = util.unpack_port_no(reader) |
| 725 | obj.max_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 726 | reader.skip(6) |
| 727 | return obj |
| 728 | |
| 729 | def __eq__(self, other): |
| 730 | if type(self) != type(other): return False |
| 731 | if self.port != other.port: return False |
| 732 | if self.max_len != other.max_len: return False |
| 733 | return True |
| 734 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 735 | def pretty_print(self, q): |
| 736 | q.text("output {") |
| 737 | with q.group(): |
| 738 | with q.indent(2): |
| 739 | q.breakable() |
| 740 | q.text("port = "); |
| 741 | q.text(util.pretty_port(self.port)) |
| 742 | q.text(","); q.breakable() |
| 743 | q.text("max_len = "); |
| 744 | q.text("%#x" % self.max_len) |
| 745 | q.breakable() |
| 746 | q.text('}') |
| 747 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 748 | action.subtypes[0] = output |
| 749 | |
| 750 | class pop_mpls(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 751 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 752 | |
| 753 | def __init__(self, ethertype=None): |
| 754 | if ethertype != None: |
| 755 | self.ethertype = ethertype |
| 756 | else: |
| 757 | self.ethertype = 0 |
| 758 | return |
| 759 | |
| 760 | def pack(self): |
| 761 | packed = [] |
| 762 | packed.append(struct.pack("!H", self.type)) |
| 763 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 764 | packed.append(struct.pack("!H", self.ethertype)) |
| 765 | packed.append('\x00' * 2) |
| 766 | length = sum([len(x) for x in packed]) |
| 767 | packed[1] = struct.pack("!H", length) |
| 768 | return ''.join(packed) |
| 769 | |
| 770 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 771 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 772 | obj = pop_mpls() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 773 | _type = reader.read("!H")[0] |
| 774 | assert(_type == 20) |
| 775 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 776 | orig_reader = reader |
| 777 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 778 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 779 | reader.skip(2) |
| 780 | return obj |
| 781 | |
| 782 | def __eq__(self, other): |
| 783 | if type(self) != type(other): return False |
| 784 | if self.ethertype != other.ethertype: return False |
| 785 | return True |
| 786 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 787 | def pretty_print(self, q): |
| 788 | q.text("pop_mpls {") |
| 789 | with q.group(): |
| 790 | with q.indent(2): |
| 791 | q.breakable() |
| 792 | q.text("ethertype = "); |
| 793 | q.text("%#x" % self.ethertype) |
| 794 | q.breakable() |
| 795 | q.text('}') |
| 796 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 797 | action.subtypes[20] = pop_mpls |
| 798 | |
| 799 | class pop_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 800 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 801 | |
| 802 | def __init__(self): |
| 803 | return |
| 804 | |
| 805 | def pack(self): |
| 806 | packed = [] |
| 807 | packed.append(struct.pack("!H", self.type)) |
| 808 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 809 | packed.append('\x00' * 4) |
| 810 | length = sum([len(x) for x in packed]) |
| 811 | packed[1] = struct.pack("!H", length) |
| 812 | return ''.join(packed) |
| 813 | |
| 814 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 815 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 816 | obj = pop_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 817 | _type = reader.read("!H")[0] |
| 818 | assert(_type == 18) |
| 819 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 820 | orig_reader = reader |
| 821 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 822 | reader.skip(4) |
| 823 | return obj |
| 824 | |
| 825 | def __eq__(self, other): |
| 826 | if type(self) != type(other): return False |
| 827 | return True |
| 828 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 829 | def pretty_print(self, q): |
| 830 | q.text("pop_vlan {") |
| 831 | with q.group(): |
| 832 | with q.indent(2): |
| 833 | q.breakable() |
| 834 | q.breakable() |
| 835 | q.text('}') |
| 836 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 837 | action.subtypes[18] = pop_vlan |
| 838 | |
| 839 | class push_mpls(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 840 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 841 | |
| 842 | def __init__(self, ethertype=None): |
| 843 | if ethertype != None: |
| 844 | self.ethertype = ethertype |
| 845 | else: |
| 846 | self.ethertype = 0 |
| 847 | return |
| 848 | |
| 849 | def pack(self): |
| 850 | packed = [] |
| 851 | packed.append(struct.pack("!H", self.type)) |
| 852 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 853 | packed.append(struct.pack("!H", self.ethertype)) |
| 854 | packed.append('\x00' * 2) |
| 855 | length = sum([len(x) for x in packed]) |
| 856 | packed[1] = struct.pack("!H", length) |
| 857 | return ''.join(packed) |
| 858 | |
| 859 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 860 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 861 | obj = push_mpls() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 862 | _type = reader.read("!H")[0] |
| 863 | assert(_type == 19) |
| 864 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 865 | orig_reader = reader |
| 866 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 867 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 868 | reader.skip(2) |
| 869 | return obj |
| 870 | |
| 871 | def __eq__(self, other): |
| 872 | if type(self) != type(other): return False |
| 873 | if self.ethertype != other.ethertype: return False |
| 874 | return True |
| 875 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 876 | def pretty_print(self, q): |
| 877 | q.text("push_mpls {") |
| 878 | with q.group(): |
| 879 | with q.indent(2): |
| 880 | q.breakable() |
| 881 | q.text("ethertype = "); |
| 882 | q.text("%#x" % self.ethertype) |
| 883 | q.breakable() |
| 884 | q.text('}') |
| 885 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 886 | action.subtypes[19] = push_mpls |
| 887 | |
| 888 | class push_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 889 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 890 | |
| 891 | def __init__(self, ethertype=None): |
| 892 | if ethertype != None: |
| 893 | self.ethertype = ethertype |
| 894 | else: |
| 895 | self.ethertype = 0 |
| 896 | return |
| 897 | |
| 898 | def pack(self): |
| 899 | packed = [] |
| 900 | packed.append(struct.pack("!H", self.type)) |
| 901 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 902 | packed.append(struct.pack("!H", self.ethertype)) |
| 903 | packed.append('\x00' * 2) |
| 904 | length = sum([len(x) for x in packed]) |
| 905 | packed[1] = struct.pack("!H", length) |
| 906 | return ''.join(packed) |
| 907 | |
| 908 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 909 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 910 | obj = push_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 911 | _type = reader.read("!H")[0] |
| 912 | assert(_type == 17) |
| 913 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 914 | orig_reader = reader |
| 915 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 916 | obj.ethertype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 917 | reader.skip(2) |
| 918 | return obj |
| 919 | |
| 920 | def __eq__(self, other): |
| 921 | if type(self) != type(other): return False |
| 922 | if self.ethertype != other.ethertype: return False |
| 923 | return True |
| 924 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 925 | def pretty_print(self, q): |
| 926 | q.text("push_vlan {") |
| 927 | with q.group(): |
| 928 | with q.indent(2): |
| 929 | q.breakable() |
| 930 | q.text("ethertype = "); |
| 931 | q.text("%#x" % self.ethertype) |
| 932 | q.breakable() |
| 933 | q.text('}') |
| 934 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 935 | action.subtypes[17] = push_vlan |
| 936 | |
| 937 | class set_dl_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 938 | type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 939 | |
| 940 | def __init__(self, dl_addr=None): |
| 941 | if dl_addr != None: |
| 942 | self.dl_addr = dl_addr |
| 943 | else: |
| 944 | self.dl_addr = [0,0,0,0,0,0] |
| 945 | return |
| 946 | |
| 947 | def pack(self): |
| 948 | packed = [] |
| 949 | packed.append(struct.pack("!H", self.type)) |
| 950 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 951 | packed.append(struct.pack("!6B", *self.dl_addr)) |
| 952 | packed.append('\x00' * 6) |
| 953 | length = sum([len(x) for x in packed]) |
| 954 | packed[1] = struct.pack("!H", length) |
| 955 | return ''.join(packed) |
| 956 | |
| 957 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 958 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 959 | obj = set_dl_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 960 | _type = reader.read("!H")[0] |
| 961 | assert(_type == 4) |
| 962 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 963 | orig_reader = reader |
| 964 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 965 | obj.dl_addr = list(reader.read('!6B')) |
| 966 | reader.skip(6) |
| 967 | return obj |
| 968 | |
| 969 | def __eq__(self, other): |
| 970 | if type(self) != type(other): return False |
| 971 | if self.dl_addr != other.dl_addr: return False |
| 972 | return True |
| 973 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 974 | def pretty_print(self, q): |
| 975 | q.text("set_dl_dst {") |
| 976 | with q.group(): |
| 977 | with q.indent(2): |
| 978 | q.breakable() |
| 979 | q.text("dl_addr = "); |
| 980 | q.text(util.pretty_mac(self.dl_addr)) |
| 981 | q.breakable() |
| 982 | q.text('}') |
| 983 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 984 | action.subtypes[4] = set_dl_dst |
| 985 | |
| 986 | class set_dl_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 987 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 988 | |
| 989 | def __init__(self, dl_addr=None): |
| 990 | if dl_addr != None: |
| 991 | self.dl_addr = dl_addr |
| 992 | else: |
| 993 | self.dl_addr = [0,0,0,0,0,0] |
| 994 | return |
| 995 | |
| 996 | def pack(self): |
| 997 | packed = [] |
| 998 | packed.append(struct.pack("!H", self.type)) |
| 999 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1000 | packed.append(struct.pack("!6B", *self.dl_addr)) |
| 1001 | packed.append('\x00' * 6) |
| 1002 | length = sum([len(x) for x in packed]) |
| 1003 | packed[1] = struct.pack("!H", length) |
| 1004 | return ''.join(packed) |
| 1005 | |
| 1006 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1007 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1008 | obj = set_dl_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1009 | _type = reader.read("!H")[0] |
| 1010 | assert(_type == 3) |
| 1011 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1012 | orig_reader = reader |
| 1013 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1014 | obj.dl_addr = list(reader.read('!6B')) |
| 1015 | reader.skip(6) |
| 1016 | return obj |
| 1017 | |
| 1018 | def __eq__(self, other): |
| 1019 | if type(self) != type(other): return False |
| 1020 | if self.dl_addr != other.dl_addr: return False |
| 1021 | return True |
| 1022 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1023 | def pretty_print(self, q): |
| 1024 | q.text("set_dl_src {") |
| 1025 | with q.group(): |
| 1026 | with q.indent(2): |
| 1027 | q.breakable() |
| 1028 | q.text("dl_addr = "); |
| 1029 | q.text(util.pretty_mac(self.dl_addr)) |
| 1030 | q.breakable() |
| 1031 | q.text('}') |
| 1032 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1033 | action.subtypes[3] = set_dl_src |
| 1034 | |
| 1035 | class set_mpls_label(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1036 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1037 | |
| 1038 | def __init__(self, mpls_label=None): |
| 1039 | if mpls_label != None: |
| 1040 | self.mpls_label = mpls_label |
| 1041 | else: |
| 1042 | self.mpls_label = 0 |
| 1043 | return |
| 1044 | |
| 1045 | def pack(self): |
| 1046 | packed = [] |
| 1047 | packed.append(struct.pack("!H", self.type)) |
| 1048 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1049 | packed.append(struct.pack("!L", self.mpls_label)) |
| 1050 | length = sum([len(x) for x in packed]) |
| 1051 | packed[1] = struct.pack("!H", length) |
| 1052 | return ''.join(packed) |
| 1053 | |
| 1054 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1055 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1056 | obj = set_mpls_label() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1057 | _type = reader.read("!H")[0] |
| 1058 | assert(_type == 13) |
| 1059 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1060 | orig_reader = reader |
| 1061 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1062 | obj.mpls_label = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1063 | return obj |
| 1064 | |
| 1065 | def __eq__(self, other): |
| 1066 | if type(self) != type(other): return False |
| 1067 | if self.mpls_label != other.mpls_label: return False |
| 1068 | return True |
| 1069 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1070 | def pretty_print(self, q): |
| 1071 | q.text("set_mpls_label {") |
| 1072 | with q.group(): |
| 1073 | with q.indent(2): |
| 1074 | q.breakable() |
| 1075 | q.text("mpls_label = "); |
| 1076 | q.text("%#x" % self.mpls_label) |
| 1077 | q.breakable() |
| 1078 | q.text('}') |
| 1079 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1080 | action.subtypes[13] = set_mpls_label |
| 1081 | |
| 1082 | class set_mpls_tc(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1083 | type = 14 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1084 | |
| 1085 | def __init__(self, mpls_tc=None): |
| 1086 | if mpls_tc != None: |
| 1087 | self.mpls_tc = mpls_tc |
| 1088 | else: |
| 1089 | self.mpls_tc = 0 |
| 1090 | return |
| 1091 | |
| 1092 | def pack(self): |
| 1093 | packed = [] |
| 1094 | packed.append(struct.pack("!H", self.type)) |
| 1095 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1096 | packed.append(struct.pack("!B", self.mpls_tc)) |
| 1097 | packed.append('\x00' * 3) |
| 1098 | length = sum([len(x) for x in packed]) |
| 1099 | packed[1] = struct.pack("!H", length) |
| 1100 | return ''.join(packed) |
| 1101 | |
| 1102 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1103 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1104 | obj = set_mpls_tc() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1105 | _type = reader.read("!H")[0] |
| 1106 | assert(_type == 14) |
| 1107 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1108 | orig_reader = reader |
| 1109 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1110 | obj.mpls_tc = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1111 | reader.skip(3) |
| 1112 | return obj |
| 1113 | |
| 1114 | def __eq__(self, other): |
| 1115 | if type(self) != type(other): return False |
| 1116 | if self.mpls_tc != other.mpls_tc: return False |
| 1117 | return True |
| 1118 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1119 | def pretty_print(self, q): |
| 1120 | q.text("set_mpls_tc {") |
| 1121 | with q.group(): |
| 1122 | with q.indent(2): |
| 1123 | q.breakable() |
| 1124 | q.text("mpls_tc = "); |
| 1125 | q.text("%#x" % self.mpls_tc) |
| 1126 | q.breakable() |
| 1127 | q.text('}') |
| 1128 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1129 | action.subtypes[14] = set_mpls_tc |
| 1130 | |
| 1131 | class set_mpls_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1132 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1133 | |
| 1134 | def __init__(self, mpls_ttl=None): |
| 1135 | if mpls_ttl != None: |
| 1136 | self.mpls_ttl = mpls_ttl |
| 1137 | else: |
| 1138 | self.mpls_ttl = 0 |
| 1139 | return |
| 1140 | |
| 1141 | def pack(self): |
| 1142 | packed = [] |
| 1143 | packed.append(struct.pack("!H", self.type)) |
| 1144 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1145 | packed.append(struct.pack("!B", self.mpls_ttl)) |
| 1146 | packed.append('\x00' * 3) |
| 1147 | length = sum([len(x) for x in packed]) |
| 1148 | packed[1] = struct.pack("!H", length) |
| 1149 | return ''.join(packed) |
| 1150 | |
| 1151 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1152 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1153 | obj = set_mpls_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1154 | _type = reader.read("!H")[0] |
| 1155 | assert(_type == 15) |
| 1156 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1157 | orig_reader = reader |
| 1158 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1159 | obj.mpls_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1160 | reader.skip(3) |
| 1161 | return obj |
| 1162 | |
| 1163 | def __eq__(self, other): |
| 1164 | if type(self) != type(other): return False |
| 1165 | if self.mpls_ttl != other.mpls_ttl: return False |
| 1166 | return True |
| 1167 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1168 | def pretty_print(self, q): |
| 1169 | q.text("set_mpls_ttl {") |
| 1170 | with q.group(): |
| 1171 | with q.indent(2): |
| 1172 | q.breakable() |
| 1173 | q.text("mpls_ttl = "); |
| 1174 | q.text("%#x" % self.mpls_ttl) |
| 1175 | q.breakable() |
| 1176 | q.text('}') |
| 1177 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1178 | action.subtypes[15] = set_mpls_ttl |
| 1179 | |
| 1180 | class set_nw_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1181 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1182 | |
| 1183 | def __init__(self, nw_addr=None): |
| 1184 | if nw_addr != None: |
| 1185 | self.nw_addr = nw_addr |
| 1186 | else: |
| 1187 | self.nw_addr = 0 |
| 1188 | return |
| 1189 | |
| 1190 | def pack(self): |
| 1191 | packed = [] |
| 1192 | packed.append(struct.pack("!H", self.type)) |
| 1193 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1194 | packed.append(struct.pack("!L", self.nw_addr)) |
| 1195 | length = sum([len(x) for x in packed]) |
| 1196 | packed[1] = struct.pack("!H", length) |
| 1197 | return ''.join(packed) |
| 1198 | |
| 1199 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1200 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1201 | obj = set_nw_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1202 | _type = reader.read("!H")[0] |
| 1203 | assert(_type == 6) |
| 1204 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1205 | orig_reader = reader |
| 1206 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1207 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1208 | return obj |
| 1209 | |
| 1210 | def __eq__(self, other): |
| 1211 | if type(self) != type(other): return False |
| 1212 | if self.nw_addr != other.nw_addr: return False |
| 1213 | return True |
| 1214 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1215 | def pretty_print(self, q): |
| 1216 | q.text("set_nw_dst {") |
| 1217 | with q.group(): |
| 1218 | with q.indent(2): |
| 1219 | q.breakable() |
| 1220 | q.text("nw_addr = "); |
| 1221 | q.text("%#x" % self.nw_addr) |
| 1222 | q.breakable() |
| 1223 | q.text('}') |
| 1224 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1225 | action.subtypes[6] = set_nw_dst |
| 1226 | |
| 1227 | class set_nw_ecn(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1228 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1229 | |
| 1230 | def __init__(self, nw_ecn=None): |
| 1231 | if nw_ecn != None: |
| 1232 | self.nw_ecn = nw_ecn |
| 1233 | else: |
| 1234 | self.nw_ecn = 0 |
| 1235 | return |
| 1236 | |
| 1237 | def pack(self): |
| 1238 | packed = [] |
| 1239 | packed.append(struct.pack("!H", self.type)) |
| 1240 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1241 | packed.append(struct.pack("!B", self.nw_ecn)) |
| 1242 | packed.append('\x00' * 3) |
| 1243 | length = sum([len(x) for x in packed]) |
| 1244 | packed[1] = struct.pack("!H", length) |
| 1245 | return ''.join(packed) |
| 1246 | |
| 1247 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1248 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1249 | obj = set_nw_ecn() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1250 | _type = reader.read("!H")[0] |
| 1251 | assert(_type == 8) |
| 1252 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1253 | orig_reader = reader |
| 1254 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1255 | obj.nw_ecn = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1256 | reader.skip(3) |
| 1257 | return obj |
| 1258 | |
| 1259 | def __eq__(self, other): |
| 1260 | if type(self) != type(other): return False |
| 1261 | if self.nw_ecn != other.nw_ecn: return False |
| 1262 | return True |
| 1263 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1264 | def pretty_print(self, q): |
| 1265 | q.text("set_nw_ecn {") |
| 1266 | with q.group(): |
| 1267 | with q.indent(2): |
| 1268 | q.breakable() |
| 1269 | q.text("nw_ecn = "); |
| 1270 | q.text("%#x" % self.nw_ecn) |
| 1271 | q.breakable() |
| 1272 | q.text('}') |
| 1273 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1274 | action.subtypes[8] = set_nw_ecn |
| 1275 | |
| 1276 | class set_nw_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1277 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1278 | |
| 1279 | def __init__(self, nw_addr=None): |
| 1280 | if nw_addr != None: |
| 1281 | self.nw_addr = nw_addr |
| 1282 | else: |
| 1283 | self.nw_addr = 0 |
| 1284 | return |
| 1285 | |
| 1286 | def pack(self): |
| 1287 | packed = [] |
| 1288 | packed.append(struct.pack("!H", self.type)) |
| 1289 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1290 | packed.append(struct.pack("!L", self.nw_addr)) |
| 1291 | length = sum([len(x) for x in packed]) |
| 1292 | packed[1] = struct.pack("!H", length) |
| 1293 | return ''.join(packed) |
| 1294 | |
| 1295 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1296 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1297 | obj = set_nw_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1298 | _type = reader.read("!H")[0] |
| 1299 | assert(_type == 5) |
| 1300 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1301 | orig_reader = reader |
| 1302 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1303 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1304 | return obj |
| 1305 | |
| 1306 | def __eq__(self, other): |
| 1307 | if type(self) != type(other): return False |
| 1308 | if self.nw_addr != other.nw_addr: return False |
| 1309 | return True |
| 1310 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1311 | def pretty_print(self, q): |
| 1312 | q.text("set_nw_src {") |
| 1313 | with q.group(): |
| 1314 | with q.indent(2): |
| 1315 | q.breakable() |
| 1316 | q.text("nw_addr = "); |
| 1317 | q.text("%#x" % self.nw_addr) |
| 1318 | q.breakable() |
| 1319 | q.text('}') |
| 1320 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1321 | action.subtypes[5] = set_nw_src |
| 1322 | |
| 1323 | class set_nw_tos(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1324 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1325 | |
| 1326 | def __init__(self, nw_tos=None): |
| 1327 | if nw_tos != None: |
| 1328 | self.nw_tos = nw_tos |
| 1329 | else: |
| 1330 | self.nw_tos = 0 |
| 1331 | return |
| 1332 | |
| 1333 | def pack(self): |
| 1334 | packed = [] |
| 1335 | packed.append(struct.pack("!H", self.type)) |
| 1336 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1337 | packed.append(struct.pack("!B", self.nw_tos)) |
| 1338 | packed.append('\x00' * 3) |
| 1339 | length = sum([len(x) for x in packed]) |
| 1340 | packed[1] = struct.pack("!H", length) |
| 1341 | return ''.join(packed) |
| 1342 | |
| 1343 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1344 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1345 | obj = set_nw_tos() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1346 | _type = reader.read("!H")[0] |
| 1347 | assert(_type == 7) |
| 1348 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1349 | orig_reader = reader |
| 1350 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1351 | obj.nw_tos = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1352 | reader.skip(3) |
| 1353 | return obj |
| 1354 | |
| 1355 | def __eq__(self, other): |
| 1356 | if type(self) != type(other): return False |
| 1357 | if self.nw_tos != other.nw_tos: return False |
| 1358 | return True |
| 1359 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1360 | def pretty_print(self, q): |
| 1361 | q.text("set_nw_tos {") |
| 1362 | with q.group(): |
| 1363 | with q.indent(2): |
| 1364 | q.breakable() |
| 1365 | q.text("nw_tos = "); |
| 1366 | q.text("%#x" % self.nw_tos) |
| 1367 | q.breakable() |
| 1368 | q.text('}') |
| 1369 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1370 | action.subtypes[7] = set_nw_tos |
| 1371 | |
| 1372 | class set_nw_ttl(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1373 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1374 | |
| 1375 | def __init__(self, nw_ttl=None): |
| 1376 | if nw_ttl != None: |
| 1377 | self.nw_ttl = nw_ttl |
| 1378 | else: |
| 1379 | self.nw_ttl = 0 |
| 1380 | return |
| 1381 | |
| 1382 | def pack(self): |
| 1383 | packed = [] |
| 1384 | packed.append(struct.pack("!H", self.type)) |
| 1385 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1386 | packed.append(struct.pack("!B", self.nw_ttl)) |
| 1387 | packed.append('\x00' * 3) |
| 1388 | length = sum([len(x) for x in packed]) |
| 1389 | packed[1] = struct.pack("!H", length) |
| 1390 | return ''.join(packed) |
| 1391 | |
| 1392 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1393 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1394 | obj = set_nw_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1395 | _type = reader.read("!H")[0] |
| 1396 | assert(_type == 23) |
| 1397 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1398 | orig_reader = reader |
| 1399 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1400 | obj.nw_ttl = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1401 | reader.skip(3) |
| 1402 | return obj |
| 1403 | |
| 1404 | def __eq__(self, other): |
| 1405 | if type(self) != type(other): return False |
| 1406 | if self.nw_ttl != other.nw_ttl: return False |
| 1407 | return True |
| 1408 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1409 | def pretty_print(self, q): |
| 1410 | q.text("set_nw_ttl {") |
| 1411 | with q.group(): |
| 1412 | with q.indent(2): |
| 1413 | q.breakable() |
| 1414 | q.text("nw_ttl = "); |
| 1415 | q.text("%#x" % self.nw_ttl) |
| 1416 | q.breakable() |
| 1417 | q.text('}') |
| 1418 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1419 | action.subtypes[23] = set_nw_ttl |
| 1420 | |
| 1421 | class set_queue(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1422 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1423 | |
| 1424 | def __init__(self, queue_id=None): |
| 1425 | if queue_id != None: |
| 1426 | self.queue_id = queue_id |
| 1427 | else: |
| 1428 | self.queue_id = 0 |
| 1429 | return |
| 1430 | |
| 1431 | def pack(self): |
| 1432 | packed = [] |
| 1433 | packed.append(struct.pack("!H", self.type)) |
| 1434 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1435 | packed.append(struct.pack("!L", self.queue_id)) |
| 1436 | length = sum([len(x) for x in packed]) |
| 1437 | packed[1] = struct.pack("!H", length) |
| 1438 | return ''.join(packed) |
| 1439 | |
| 1440 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1441 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1442 | obj = set_queue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1443 | _type = reader.read("!H")[0] |
| 1444 | assert(_type == 21) |
| 1445 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1446 | orig_reader = reader |
| 1447 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1448 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1449 | return obj |
| 1450 | |
| 1451 | def __eq__(self, other): |
| 1452 | if type(self) != type(other): return False |
| 1453 | if self.queue_id != other.queue_id: return False |
| 1454 | return True |
| 1455 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1456 | def pretty_print(self, q): |
| 1457 | q.text("set_queue {") |
| 1458 | with q.group(): |
| 1459 | with q.indent(2): |
| 1460 | q.breakable() |
| 1461 | q.text("queue_id = "); |
| 1462 | q.text("%#x" % self.queue_id) |
| 1463 | q.breakable() |
| 1464 | q.text('}') |
| 1465 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1466 | action.subtypes[21] = set_queue |
| 1467 | |
| 1468 | class set_tp_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1469 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1470 | |
| 1471 | def __init__(self, tp_port=None): |
| 1472 | if tp_port != None: |
| 1473 | self.tp_port = tp_port |
| 1474 | else: |
| 1475 | self.tp_port = 0 |
| 1476 | return |
| 1477 | |
| 1478 | def pack(self): |
| 1479 | packed = [] |
| 1480 | packed.append(struct.pack("!H", self.type)) |
| 1481 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1482 | packed.append(struct.pack("!H", self.tp_port)) |
| 1483 | packed.append('\x00' * 2) |
| 1484 | length = sum([len(x) for x in packed]) |
| 1485 | packed[1] = struct.pack("!H", length) |
| 1486 | return ''.join(packed) |
| 1487 | |
| 1488 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1489 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1490 | obj = set_tp_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1491 | _type = reader.read("!H")[0] |
| 1492 | assert(_type == 10) |
| 1493 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1494 | orig_reader = reader |
| 1495 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1496 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1497 | reader.skip(2) |
| 1498 | return obj |
| 1499 | |
| 1500 | def __eq__(self, other): |
| 1501 | if type(self) != type(other): return False |
| 1502 | if self.tp_port != other.tp_port: return False |
| 1503 | return True |
| 1504 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1505 | def pretty_print(self, q): |
| 1506 | q.text("set_tp_dst {") |
| 1507 | with q.group(): |
| 1508 | with q.indent(2): |
| 1509 | q.breakable() |
| 1510 | q.text("tp_port = "); |
| 1511 | q.text("%#x" % self.tp_port) |
| 1512 | q.breakable() |
| 1513 | q.text('}') |
| 1514 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1515 | action.subtypes[10] = set_tp_dst |
| 1516 | |
| 1517 | class set_tp_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1518 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1519 | |
| 1520 | def __init__(self, tp_port=None): |
| 1521 | if tp_port != None: |
| 1522 | self.tp_port = tp_port |
| 1523 | else: |
| 1524 | self.tp_port = 0 |
| 1525 | return |
| 1526 | |
| 1527 | def pack(self): |
| 1528 | packed = [] |
| 1529 | packed.append(struct.pack("!H", self.type)) |
| 1530 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1531 | packed.append(struct.pack("!H", self.tp_port)) |
| 1532 | packed.append('\x00' * 2) |
| 1533 | length = sum([len(x) for x in packed]) |
| 1534 | packed[1] = struct.pack("!H", length) |
| 1535 | return ''.join(packed) |
| 1536 | |
| 1537 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1538 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1539 | obj = set_tp_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1540 | _type = reader.read("!H")[0] |
| 1541 | assert(_type == 9) |
| 1542 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1543 | orig_reader = reader |
| 1544 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1545 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1546 | reader.skip(2) |
| 1547 | return obj |
| 1548 | |
| 1549 | def __eq__(self, other): |
| 1550 | if type(self) != type(other): return False |
| 1551 | if self.tp_port != other.tp_port: return False |
| 1552 | return True |
| 1553 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1554 | def pretty_print(self, q): |
| 1555 | q.text("set_tp_src {") |
| 1556 | with q.group(): |
| 1557 | with q.indent(2): |
| 1558 | q.breakable() |
| 1559 | q.text("tp_port = "); |
| 1560 | q.text("%#x" % self.tp_port) |
| 1561 | q.breakable() |
| 1562 | q.text('}') |
| 1563 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1564 | action.subtypes[9] = set_tp_src |
| 1565 | |
| 1566 | class set_vlan_pcp(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1567 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1568 | |
| 1569 | def __init__(self, vlan_pcp=None): |
| 1570 | if vlan_pcp != None: |
| 1571 | self.vlan_pcp = vlan_pcp |
| 1572 | else: |
| 1573 | self.vlan_pcp = 0 |
| 1574 | return |
| 1575 | |
| 1576 | def pack(self): |
| 1577 | packed = [] |
| 1578 | packed.append(struct.pack("!H", self.type)) |
| 1579 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1580 | packed.append(struct.pack("!B", self.vlan_pcp)) |
| 1581 | packed.append('\x00' * 3) |
| 1582 | length = sum([len(x) for x in packed]) |
| 1583 | packed[1] = struct.pack("!H", length) |
| 1584 | return ''.join(packed) |
| 1585 | |
| 1586 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1587 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1588 | obj = set_vlan_pcp() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1589 | _type = reader.read("!H")[0] |
| 1590 | assert(_type == 2) |
| 1591 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1592 | orig_reader = reader |
| 1593 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1594 | obj.vlan_pcp = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1595 | reader.skip(3) |
| 1596 | return obj |
| 1597 | |
| 1598 | def __eq__(self, other): |
| 1599 | if type(self) != type(other): return False |
| 1600 | if self.vlan_pcp != other.vlan_pcp: return False |
| 1601 | return True |
| 1602 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1603 | def pretty_print(self, q): |
| 1604 | q.text("set_vlan_pcp {") |
| 1605 | with q.group(): |
| 1606 | with q.indent(2): |
| 1607 | q.breakable() |
| 1608 | q.text("vlan_pcp = "); |
| 1609 | q.text("%#x" % self.vlan_pcp) |
| 1610 | q.breakable() |
| 1611 | q.text('}') |
| 1612 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1613 | action.subtypes[2] = set_vlan_pcp |
| 1614 | |
| 1615 | class set_vlan_vid(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1616 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1617 | |
| 1618 | def __init__(self, vlan_vid=None): |
| 1619 | if vlan_vid != None: |
| 1620 | self.vlan_vid = vlan_vid |
| 1621 | else: |
| 1622 | self.vlan_vid = 0 |
| 1623 | return |
| 1624 | |
| 1625 | def pack(self): |
| 1626 | packed = [] |
| 1627 | packed.append(struct.pack("!H", self.type)) |
| 1628 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1629 | packed.append(struct.pack("!H", self.vlan_vid)) |
| 1630 | packed.append('\x00' * 2) |
| 1631 | length = sum([len(x) for x in packed]) |
| 1632 | packed[1] = struct.pack("!H", length) |
| 1633 | return ''.join(packed) |
| 1634 | |
| 1635 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1636 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1637 | obj = set_vlan_vid() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1638 | _type = reader.read("!H")[0] |
| 1639 | assert(_type == 1) |
| 1640 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1641 | orig_reader = reader |
| 1642 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1643 | obj.vlan_vid = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1644 | reader.skip(2) |
| 1645 | return obj |
| 1646 | |
| 1647 | def __eq__(self, other): |
| 1648 | if type(self) != type(other): return False |
| 1649 | if self.vlan_vid != other.vlan_vid: return False |
| 1650 | return True |
| 1651 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1652 | def pretty_print(self, q): |
| 1653 | q.text("set_vlan_vid {") |
| 1654 | with q.group(): |
| 1655 | with q.indent(2): |
| 1656 | q.breakable() |
| 1657 | q.text("vlan_vid = "); |
| 1658 | q.text("%#x" % self.vlan_vid) |
| 1659 | q.breakable() |
| 1660 | q.text('}') |
| 1661 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1662 | action.subtypes[1] = set_vlan_vid |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1663 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1664 | |