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