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