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