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 | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 11 | import util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 12 | import loxi.generic_util |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 13 | |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 14 | import sys |
| 15 | ofp = sys.modules['loxi.of10'] |
| 16 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 17 | class action(loxi.OFObject): |
| 18 | subtypes = {} |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 19 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 20 | |
| 21 | def __init__(self, type=None): |
| 22 | if type != None: |
| 23 | self.type = type |
| 24 | else: |
| 25 | self.type = 0 |
| 26 | return |
| 27 | |
| 28 | def pack(self): |
| 29 | packed = [] |
| 30 | packed.append(struct.pack("!H", self.type)) |
| 31 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 32 | packed.append('\x00' * 4) |
| 33 | length = sum([len(x) for x in packed]) |
| 34 | packed[1] = struct.pack("!H", length) |
| 35 | return ''.join(packed) |
| 36 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 37 | @staticmethod |
| 38 | def unpack(reader): |
| 39 | subtype, = reader.peek('!H', 0) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 40 | subclass = action.subtypes.get(subtype) |
| 41 | if subclass: |
| 42 | return subclass.unpack(reader) |
| 43 | |
| 44 | obj = action() |
| 45 | obj.type = reader.read("!H")[0] |
| 46 | _len = reader.read("!H")[0] |
| 47 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 48 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 49 | reader.skip(4) |
| 50 | return obj |
| 51 | |
| 52 | def __eq__(self, other): |
| 53 | if type(self) != type(other): return False |
| 54 | if self.type != other.type: return False |
| 55 | return True |
| 56 | |
| 57 | def pretty_print(self, q): |
| 58 | q.text("action {") |
| 59 | with q.group(): |
| 60 | with q.indent(2): |
| 61 | q.breakable() |
| 62 | q.breakable() |
| 63 | q.text('}') |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 64 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 65 | |
| 66 | class experimenter(action): |
| 67 | subtypes = {} |
| 68 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 69 | type = 65535 |
| 70 | |
| 71 | def __init__(self, experimenter=None, data=None): |
| 72 | if experimenter != None: |
| 73 | self.experimenter = experimenter |
| 74 | else: |
| 75 | self.experimenter = 0 |
| 76 | if data != None: |
| 77 | self.data = data |
| 78 | else: |
| 79 | self.data = '' |
| 80 | return |
| 81 | |
| 82 | def pack(self): |
| 83 | packed = [] |
| 84 | packed.append(struct.pack("!H", self.type)) |
| 85 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 86 | packed.append(struct.pack("!L", self.experimenter)) |
| 87 | packed.append(self.data) |
| 88 | length = sum([len(x) for x in packed]) |
| 89 | packed[1] = struct.pack("!H", length) |
| 90 | return ''.join(packed) |
| 91 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 92 | @staticmethod |
| 93 | def unpack(reader): |
| 94 | subtype, = reader.peek('!L', 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 95 | subclass = experimenter.subtypes.get(subtype) |
| 96 | if subclass: |
| 97 | return subclass.unpack(reader) |
| 98 | |
| 99 | obj = experimenter() |
| 100 | _type = reader.read("!H")[0] |
| 101 | assert(_type == 65535) |
| 102 | _len = reader.read("!H")[0] |
| 103 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 104 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 105 | obj.experimenter = reader.read("!L")[0] |
| 106 | obj.data = str(reader.read_all()) |
| 107 | return obj |
| 108 | |
| 109 | def __eq__(self, other): |
| 110 | if type(self) != type(other): return False |
| 111 | if self.experimenter != other.experimenter: return False |
| 112 | if self.data != other.data: return False |
| 113 | return True |
| 114 | |
| 115 | def pretty_print(self, q): |
| 116 | q.text("experimenter {") |
| 117 | with q.group(): |
| 118 | with q.indent(2): |
| 119 | q.breakable() |
| 120 | q.text("data = "); |
| 121 | q.pp(self.data) |
| 122 | q.breakable() |
| 123 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 124 | |
| 125 | action.subtypes[65535] = experimenter |
| 126 | |
| 127 | class bsn(experimenter): |
| 128 | subtypes = {} |
| 129 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 130 | type = 65535 |
| 131 | experimenter = 6035143 |
| 132 | |
| 133 | def __init__(self, subtype=None): |
| 134 | if subtype != None: |
| 135 | self.subtype = subtype |
| 136 | else: |
| 137 | self.subtype = 0 |
| 138 | return |
| 139 | |
| 140 | def pack(self): |
| 141 | packed = [] |
| 142 | packed.append(struct.pack("!H", self.type)) |
| 143 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 144 | packed.append(struct.pack("!L", self.experimenter)) |
| 145 | packed.append(struct.pack("!L", self.subtype)) |
| 146 | packed.append('\x00' * 4) |
| 147 | length = sum([len(x) for x in packed]) |
| 148 | packed[1] = struct.pack("!H", length) |
| 149 | return ''.join(packed) |
| 150 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 151 | @staticmethod |
| 152 | def unpack(reader): |
| 153 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 154 | subclass = bsn.subtypes.get(subtype) |
| 155 | if subclass: |
| 156 | return subclass.unpack(reader) |
| 157 | |
| 158 | obj = bsn() |
| 159 | _type = reader.read("!H")[0] |
| 160 | assert(_type == 65535) |
| 161 | _len = reader.read("!H")[0] |
| 162 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 163 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 164 | _experimenter = reader.read("!L")[0] |
| 165 | assert(_experimenter == 6035143) |
| 166 | obj.subtype = reader.read("!L")[0] |
| 167 | reader.skip(4) |
| 168 | return obj |
| 169 | |
| 170 | def __eq__(self, other): |
| 171 | if type(self) != type(other): return False |
| 172 | if self.subtype != other.subtype: return False |
| 173 | return True |
| 174 | |
| 175 | def pretty_print(self, q): |
| 176 | q.text("bsn {") |
| 177 | with q.group(): |
| 178 | with q.indent(2): |
| 179 | q.breakable() |
| 180 | q.breakable() |
| 181 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 182 | |
| 183 | experimenter.subtypes[6035143] = bsn |
| 184 | |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 185 | class bsn_checksum(bsn): |
| 186 | type = 65535 |
| 187 | experimenter = 6035143 |
| 188 | subtype = 4 |
| 189 | |
| 190 | def __init__(self, checksum=None): |
| 191 | if checksum != None: |
| 192 | self.checksum = checksum |
| 193 | else: |
| 194 | self.checksum = 0 |
| 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(struct.pack("!L", self.experimenter)) |
| 202 | packed.append(struct.pack("!L", self.subtype)) |
| 203 | packed.append(util.pack_checksum_128(self.checksum)) |
| 204 | length = sum([len(x) for x in packed]) |
| 205 | packed[1] = struct.pack("!H", length) |
| 206 | return ''.join(packed) |
| 207 | |
| 208 | @staticmethod |
| 209 | def unpack(reader): |
| 210 | obj = bsn_checksum() |
| 211 | _type = reader.read("!H")[0] |
| 212 | assert(_type == 65535) |
| 213 | _len = reader.read("!H")[0] |
| 214 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 215 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 5587ab1 | 2014-06-30 11:19:09 -0700 | [diff] [blame] | 216 | _experimenter = reader.read("!L")[0] |
| 217 | assert(_experimenter == 6035143) |
| 218 | _subtype = reader.read("!L")[0] |
| 219 | assert(_subtype == 4) |
| 220 | obj.checksum = util.unpack_checksum_128(reader) |
| 221 | return obj |
| 222 | |
| 223 | def __eq__(self, other): |
| 224 | if type(self) != type(other): return False |
| 225 | if self.checksum != other.checksum: return False |
| 226 | return True |
| 227 | |
| 228 | def pretty_print(self, q): |
| 229 | q.text("bsn_checksum {") |
| 230 | with q.group(): |
| 231 | with q.indent(2): |
| 232 | q.breakable() |
| 233 | q.text("checksum = "); |
| 234 | q.pp(self.checksum) |
| 235 | q.breakable() |
| 236 | q.text('}') |
| 237 | |
| 238 | bsn.subtypes[4] = bsn_checksum |
| 239 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 240 | class bsn_mirror(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 241 | type = 65535 |
| 242 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 243 | subtype = 1 |
| 244 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 245 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 246 | if dest_port != None: |
| 247 | self.dest_port = dest_port |
| 248 | else: |
| 249 | self.dest_port = 0 |
| 250 | if vlan_tag != None: |
| 251 | self.vlan_tag = vlan_tag |
| 252 | else: |
| 253 | self.vlan_tag = 0 |
| 254 | if copy_stage != None: |
| 255 | self.copy_stage = copy_stage |
| 256 | else: |
| 257 | self.copy_stage = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 258 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 259 | |
| 260 | def pack(self): |
| 261 | packed = [] |
| 262 | packed.append(struct.pack("!H", self.type)) |
| 263 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 264 | packed.append(struct.pack("!L", self.experimenter)) |
| 265 | packed.append(struct.pack("!L", self.subtype)) |
| 266 | packed.append(struct.pack("!L", self.dest_port)) |
| 267 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 268 | packed.append(struct.pack("!B", self.copy_stage)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 269 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 270 | length = sum([len(x) for x in packed]) |
| 271 | packed[1] = struct.pack("!H", length) |
| 272 | return ''.join(packed) |
| 273 | |
| 274 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 275 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 276 | obj = bsn_mirror() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 277 | _type = reader.read("!H")[0] |
| 278 | assert(_type == 65535) |
| 279 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 280 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 281 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 282 | _experimenter = reader.read("!L")[0] |
| 283 | assert(_experimenter == 6035143) |
| 284 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 285 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 286 | obj.dest_port = reader.read("!L")[0] |
| 287 | obj.vlan_tag = reader.read("!L")[0] |
| 288 | obj.copy_stage = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 289 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 290 | return obj |
| 291 | |
| 292 | def __eq__(self, other): |
| 293 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 294 | if self.dest_port != other.dest_port: return False |
| 295 | if self.vlan_tag != other.vlan_tag: return False |
| 296 | if self.copy_stage != other.copy_stage: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 297 | return True |
| 298 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 299 | def pretty_print(self, q): |
| 300 | q.text("bsn_mirror {") |
| 301 | with q.group(): |
| 302 | with q.indent(2): |
| 303 | q.breakable() |
| 304 | q.text("dest_port = "); |
| 305 | q.text("%#x" % self.dest_port) |
| 306 | q.text(","); q.breakable() |
| 307 | q.text("vlan_tag = "); |
| 308 | q.text("%#x" % self.vlan_tag) |
| 309 | q.text(","); q.breakable() |
| 310 | q.text("copy_stage = "); |
| 311 | q.text("%#x" % self.copy_stage) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 312 | q.breakable() |
| 313 | q.text('}') |
| 314 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 315 | bsn.subtypes[1] = bsn_mirror |
| 316 | |
| 317 | class bsn_set_tunnel_dst(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 318 | type = 65535 |
| 319 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 320 | subtype = 2 |
| 321 | |
| 322 | def __init__(self, dst=None): |
| 323 | if dst != None: |
| 324 | self.dst = dst |
| 325 | else: |
| 326 | self.dst = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 327 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 328 | |
| 329 | def pack(self): |
| 330 | packed = [] |
| 331 | packed.append(struct.pack("!H", self.type)) |
| 332 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 333 | packed.append(struct.pack("!L", self.experimenter)) |
| 334 | packed.append(struct.pack("!L", self.subtype)) |
| 335 | packed.append(struct.pack("!L", self.dst)) |
| 336 | length = sum([len(x) for x in packed]) |
| 337 | packed[1] = struct.pack("!H", length) |
| 338 | return ''.join(packed) |
| 339 | |
| 340 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 341 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 342 | obj = bsn_set_tunnel_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 343 | _type = reader.read("!H")[0] |
| 344 | assert(_type == 65535) |
| 345 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 346 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 347 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 348 | _experimenter = reader.read("!L")[0] |
| 349 | assert(_experimenter == 6035143) |
| 350 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 351 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 352 | obj.dst = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 353 | return obj |
| 354 | |
| 355 | def __eq__(self, other): |
| 356 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 357 | if self.dst != other.dst: return False |
| 358 | return True |
| 359 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 360 | def pretty_print(self, q): |
| 361 | q.text("bsn_set_tunnel_dst {") |
| 362 | with q.group(): |
| 363 | with q.indent(2): |
| 364 | q.breakable() |
| 365 | q.text("dst = "); |
| 366 | q.text("%#x" % self.dst) |
| 367 | q.breakable() |
| 368 | q.text('}') |
| 369 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 370 | bsn.subtypes[2] = bsn_set_tunnel_dst |
| 371 | |
| 372 | class enqueue(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 373 | type = 11 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 374 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 375 | def __init__(self, port=None, queue_id=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 376 | if port != None: |
| 377 | self.port = port |
| 378 | else: |
| 379 | self.port = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 380 | if queue_id != None: |
| 381 | self.queue_id = queue_id |
| 382 | else: |
| 383 | self.queue_id = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 384 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 385 | |
| 386 | def pack(self): |
| 387 | packed = [] |
| 388 | packed.append(struct.pack("!H", self.type)) |
| 389 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 390 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 391 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 392 | packed.append(struct.pack("!L", self.queue_id)) |
| 393 | length = sum([len(x) for x in packed]) |
| 394 | packed[1] = struct.pack("!H", length) |
| 395 | return ''.join(packed) |
| 396 | |
| 397 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 398 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 399 | obj = enqueue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 400 | _type = reader.read("!H")[0] |
| 401 | assert(_type == 11) |
| 402 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 403 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 404 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 405 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 406 | reader.skip(6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 407 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 408 | return obj |
| 409 | |
| 410 | def __eq__(self, other): |
| 411 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 412 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 413 | if self.queue_id != other.queue_id: return False |
| 414 | return True |
| 415 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 416 | def pretty_print(self, q): |
| 417 | q.text("enqueue {") |
| 418 | with q.group(): |
| 419 | with q.indent(2): |
| 420 | q.breakable() |
| 421 | q.text("port = "); |
| 422 | q.text(util.pretty_port(self.port)) |
| 423 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 424 | q.text("queue_id = "); |
| 425 | q.text("%#x" % self.queue_id) |
| 426 | q.breakable() |
| 427 | q.text('}') |
| 428 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 429 | action.subtypes[11] = enqueue |
| 430 | |
| 431 | class nicira(experimenter): |
| 432 | subtypes = {} |
| 433 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 434 | type = 65535 |
| 435 | experimenter = 8992 |
| 436 | |
| 437 | def __init__(self, subtype=None): |
| 438 | if subtype != None: |
| 439 | self.subtype = subtype |
| 440 | else: |
| 441 | self.subtype = 0 |
| 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(struct.pack("!L", self.experimenter)) |
| 449 | packed.append(struct.pack("!H", self.subtype)) |
| 450 | packed.append('\x00' * 2) |
| 451 | packed.append('\x00' * 4) |
| 452 | length = sum([len(x) for x in packed]) |
| 453 | packed[1] = struct.pack("!H", length) |
| 454 | return ''.join(packed) |
| 455 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 456 | @staticmethod |
| 457 | def unpack(reader): |
| 458 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 459 | subclass = nicira.subtypes.get(subtype) |
| 460 | if subclass: |
| 461 | return subclass.unpack(reader) |
| 462 | |
| 463 | obj = nicira() |
| 464 | _type = reader.read("!H")[0] |
| 465 | assert(_type == 65535) |
| 466 | _len = reader.read("!H")[0] |
| 467 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 468 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 469 | _experimenter = reader.read("!L")[0] |
| 470 | assert(_experimenter == 8992) |
| 471 | obj.subtype = reader.read("!H")[0] |
| 472 | reader.skip(2) |
| 473 | reader.skip(4) |
| 474 | return obj |
| 475 | |
| 476 | def __eq__(self, other): |
| 477 | if type(self) != type(other): return False |
| 478 | if self.subtype != other.subtype: return False |
| 479 | return True |
| 480 | |
| 481 | def pretty_print(self, q): |
| 482 | q.text("nicira {") |
| 483 | with q.group(): |
| 484 | with q.indent(2): |
| 485 | q.breakable() |
| 486 | q.breakable() |
| 487 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 488 | |
| 489 | experimenter.subtypes[8992] = nicira |
| 490 | |
| 491 | class nicira_dec_ttl(nicira): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 492 | type = 65535 |
| 493 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 494 | subtype = 18 |
| 495 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 496 | def __init__(self): |
| 497 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 498 | |
| 499 | def pack(self): |
| 500 | packed = [] |
| 501 | packed.append(struct.pack("!H", self.type)) |
| 502 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 503 | packed.append(struct.pack("!L", self.experimenter)) |
| 504 | packed.append(struct.pack("!H", self.subtype)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 505 | packed.append('\x00' * 2) |
| 506 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 507 | length = sum([len(x) for x in packed]) |
| 508 | packed[1] = struct.pack("!H", length) |
| 509 | return ''.join(packed) |
| 510 | |
| 511 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 512 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 513 | obj = nicira_dec_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 514 | _type = reader.read("!H")[0] |
| 515 | assert(_type == 65535) |
| 516 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 517 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 518 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 519 | _experimenter = reader.read("!L")[0] |
| 520 | assert(_experimenter == 8992) |
| 521 | _subtype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 522 | assert(_subtype == 18) |
| 523 | reader.skip(2) |
| 524 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 525 | return obj |
| 526 | |
| 527 | def __eq__(self, other): |
| 528 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 529 | return True |
| 530 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 531 | def pretty_print(self, q): |
| 532 | q.text("nicira_dec_ttl {") |
| 533 | with q.group(): |
| 534 | with q.indent(2): |
| 535 | q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 536 | q.breakable() |
| 537 | q.text('}') |
| 538 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 539 | nicira.subtypes[18] = nicira_dec_ttl |
| 540 | |
| 541 | class output(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 542 | type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 543 | |
| 544 | def __init__(self, port=None, max_len=None): |
| 545 | if port != None: |
| 546 | self.port = port |
| 547 | else: |
| 548 | self.port = 0 |
| 549 | if max_len != None: |
| 550 | self.max_len = max_len |
| 551 | else: |
| 552 | self.max_len = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 553 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 554 | |
| 555 | def pack(self): |
| 556 | packed = [] |
| 557 | packed.append(struct.pack("!H", self.type)) |
| 558 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 559 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 560 | packed.append(struct.pack("!H", self.max_len)) |
| 561 | length = sum([len(x) for x in packed]) |
| 562 | packed[1] = struct.pack("!H", length) |
| 563 | return ''.join(packed) |
| 564 | |
| 565 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 566 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 567 | obj = output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 568 | _type = reader.read("!H")[0] |
| 569 | assert(_type == 0) |
| 570 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 571 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 572 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 573 | obj.port = util.unpack_port_no(reader) |
| 574 | obj.max_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 575 | return obj |
| 576 | |
| 577 | def __eq__(self, other): |
| 578 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 579 | if self.port != other.port: return False |
| 580 | if self.max_len != other.max_len: return False |
| 581 | return True |
| 582 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 583 | def pretty_print(self, q): |
| 584 | q.text("output {") |
| 585 | with q.group(): |
| 586 | with q.indent(2): |
| 587 | q.breakable() |
| 588 | q.text("port = "); |
| 589 | q.text(util.pretty_port(self.port)) |
| 590 | q.text(","); q.breakable() |
| 591 | q.text("max_len = "); |
| 592 | q.text("%#x" % self.max_len) |
| 593 | q.breakable() |
| 594 | q.text('}') |
| 595 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 596 | action.subtypes[0] = output |
| 597 | |
| 598 | class set_dl_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 599 | type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 600 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 601 | def __init__(self, dl_addr=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 602 | if dl_addr != None: |
| 603 | self.dl_addr = dl_addr |
| 604 | else: |
| 605 | self.dl_addr = [0,0,0,0,0,0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 606 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 607 | |
| 608 | def pack(self): |
| 609 | packed = [] |
| 610 | packed.append(struct.pack("!H", self.type)) |
| 611 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 612 | packed.append(struct.pack("!6B", *self.dl_addr)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 613 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 614 | length = sum([len(x) for x in packed]) |
| 615 | packed[1] = struct.pack("!H", length) |
| 616 | return ''.join(packed) |
| 617 | |
| 618 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 619 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 620 | obj = set_dl_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 621 | _type = reader.read("!H")[0] |
| 622 | assert(_type == 5) |
| 623 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 624 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 625 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 626 | obj.dl_addr = list(reader.read('!6B')) |
| 627 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 628 | return obj |
| 629 | |
| 630 | def __eq__(self, other): |
| 631 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 632 | if self.dl_addr != other.dl_addr: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 633 | return True |
| 634 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 635 | def pretty_print(self, q): |
| 636 | q.text("set_dl_dst {") |
| 637 | with q.group(): |
| 638 | with q.indent(2): |
| 639 | q.breakable() |
| 640 | q.text("dl_addr = "); |
| 641 | q.text(util.pretty_mac(self.dl_addr)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 642 | q.breakable() |
| 643 | q.text('}') |
| 644 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 645 | action.subtypes[5] = set_dl_dst |
| 646 | |
| 647 | class set_dl_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 648 | type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 649 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 650 | def __init__(self, dl_addr=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 651 | if dl_addr != None: |
| 652 | self.dl_addr = dl_addr |
| 653 | else: |
| 654 | self.dl_addr = [0,0,0,0,0,0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 655 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 656 | |
| 657 | def pack(self): |
| 658 | packed = [] |
| 659 | packed.append(struct.pack("!H", self.type)) |
| 660 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 661 | packed.append(struct.pack("!6B", *self.dl_addr)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 662 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 663 | length = sum([len(x) for x in packed]) |
| 664 | packed[1] = struct.pack("!H", length) |
| 665 | return ''.join(packed) |
| 666 | |
| 667 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 668 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 669 | obj = set_dl_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 670 | _type = reader.read("!H")[0] |
| 671 | assert(_type == 4) |
| 672 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 673 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 674 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 675 | obj.dl_addr = list(reader.read('!6B')) |
| 676 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 677 | return obj |
| 678 | |
| 679 | def __eq__(self, other): |
| 680 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 681 | if self.dl_addr != other.dl_addr: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 682 | return True |
| 683 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 684 | def pretty_print(self, q): |
| 685 | q.text("set_dl_src {") |
| 686 | with q.group(): |
| 687 | with q.indent(2): |
| 688 | q.breakable() |
| 689 | q.text("dl_addr = "); |
| 690 | q.text(util.pretty_mac(self.dl_addr)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 691 | q.breakable() |
| 692 | q.text('}') |
| 693 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 694 | action.subtypes[4] = set_dl_src |
| 695 | |
| 696 | class set_nw_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 697 | type = 7 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 698 | |
| 699 | def __init__(self, nw_addr=None): |
| 700 | if nw_addr != None: |
| 701 | self.nw_addr = nw_addr |
| 702 | else: |
| 703 | self.nw_addr = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 704 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 705 | |
| 706 | def pack(self): |
| 707 | packed = [] |
| 708 | packed.append(struct.pack("!H", self.type)) |
| 709 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 710 | packed.append(struct.pack("!L", self.nw_addr)) |
| 711 | length = sum([len(x) for x in packed]) |
| 712 | packed[1] = struct.pack("!H", length) |
| 713 | return ''.join(packed) |
| 714 | |
| 715 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 716 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 717 | obj = set_nw_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 718 | _type = reader.read("!H")[0] |
| 719 | assert(_type == 7) |
| 720 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 721 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 722 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 723 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 724 | return obj |
| 725 | |
| 726 | def __eq__(self, other): |
| 727 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 728 | if self.nw_addr != other.nw_addr: return False |
| 729 | return True |
| 730 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 731 | def pretty_print(self, q): |
| 732 | q.text("set_nw_dst {") |
| 733 | with q.group(): |
| 734 | with q.indent(2): |
| 735 | q.breakable() |
| 736 | q.text("nw_addr = "); |
| 737 | q.text("%#x" % self.nw_addr) |
| 738 | q.breakable() |
| 739 | q.text('}') |
| 740 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 741 | action.subtypes[7] = set_nw_dst |
| 742 | |
| 743 | class set_nw_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 744 | type = 6 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 745 | |
| 746 | def __init__(self, nw_addr=None): |
| 747 | if nw_addr != None: |
| 748 | self.nw_addr = nw_addr |
| 749 | else: |
| 750 | self.nw_addr = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 751 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 752 | |
| 753 | def pack(self): |
| 754 | packed = [] |
| 755 | packed.append(struct.pack("!H", self.type)) |
| 756 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 757 | packed.append(struct.pack("!L", self.nw_addr)) |
| 758 | length = sum([len(x) for x in packed]) |
| 759 | packed[1] = struct.pack("!H", length) |
| 760 | return ''.join(packed) |
| 761 | |
| 762 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 763 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 764 | obj = set_nw_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 765 | _type = reader.read("!H")[0] |
| 766 | assert(_type == 6) |
| 767 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 768 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 769 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 770 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 771 | return obj |
| 772 | |
| 773 | def __eq__(self, other): |
| 774 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 775 | if self.nw_addr != other.nw_addr: return False |
| 776 | return True |
| 777 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 778 | def pretty_print(self, q): |
| 779 | q.text("set_nw_src {") |
| 780 | with q.group(): |
| 781 | with q.indent(2): |
| 782 | q.breakable() |
| 783 | q.text("nw_addr = "); |
| 784 | q.text("%#x" % self.nw_addr) |
| 785 | q.breakable() |
| 786 | q.text('}') |
| 787 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 788 | action.subtypes[6] = set_nw_src |
| 789 | |
| 790 | class set_nw_tos(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 791 | type = 8 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 792 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 793 | def __init__(self, nw_tos=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 794 | if nw_tos != None: |
| 795 | self.nw_tos = nw_tos |
| 796 | else: |
| 797 | self.nw_tos = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 798 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 799 | |
| 800 | def pack(self): |
| 801 | packed = [] |
| 802 | packed.append(struct.pack("!H", self.type)) |
| 803 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 804 | packed.append(struct.pack("!B", self.nw_tos)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 805 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 806 | length = sum([len(x) for x in packed]) |
| 807 | packed[1] = struct.pack("!H", length) |
| 808 | return ''.join(packed) |
| 809 | |
| 810 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 811 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 812 | obj = set_nw_tos() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 813 | _type = reader.read("!H")[0] |
| 814 | assert(_type == 8) |
| 815 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 816 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 817 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 818 | obj.nw_tos = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 819 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 820 | return obj |
| 821 | |
| 822 | def __eq__(self, other): |
| 823 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 824 | if self.nw_tos != other.nw_tos: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 825 | return True |
| 826 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 827 | def pretty_print(self, q): |
| 828 | q.text("set_nw_tos {") |
| 829 | with q.group(): |
| 830 | with q.indent(2): |
| 831 | q.breakable() |
| 832 | q.text("nw_tos = "); |
| 833 | q.text("%#x" % self.nw_tos) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 834 | q.breakable() |
| 835 | q.text('}') |
| 836 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 837 | action.subtypes[8] = set_nw_tos |
| 838 | |
| 839 | class set_tp_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 840 | type = 10 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 841 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 842 | def __init__(self, tp_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 843 | if tp_port != None: |
| 844 | self.tp_port = tp_port |
| 845 | else: |
| 846 | self.tp_port = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 847 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 848 | |
| 849 | def pack(self): |
| 850 | packed = [] |
| 851 | packed.append(struct.pack("!H", self.type)) |
| 852 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 853 | packed.append(struct.pack("!H", self.tp_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 854 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 855 | length = sum([len(x) for x in packed]) |
| 856 | packed[1] = struct.pack("!H", length) |
| 857 | return ''.join(packed) |
| 858 | |
| 859 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 860 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 861 | obj = set_tp_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 862 | _type = reader.read("!H")[0] |
| 863 | assert(_type == 10) |
| 864 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 865 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 866 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 867 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 868 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 869 | return obj |
| 870 | |
| 871 | def __eq__(self, other): |
| 872 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 873 | if self.tp_port != other.tp_port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 874 | return True |
| 875 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 876 | def pretty_print(self, q): |
| 877 | q.text("set_tp_dst {") |
| 878 | with q.group(): |
| 879 | with q.indent(2): |
| 880 | q.breakable() |
| 881 | q.text("tp_port = "); |
| 882 | q.text("%#x" % self.tp_port) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 883 | q.breakable() |
| 884 | q.text('}') |
| 885 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 886 | action.subtypes[10] = set_tp_dst |
| 887 | |
| 888 | class set_tp_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 889 | type = 9 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 890 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 891 | def __init__(self, tp_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 892 | if tp_port != None: |
| 893 | self.tp_port = tp_port |
| 894 | else: |
| 895 | self.tp_port = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 896 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 897 | |
| 898 | def pack(self): |
| 899 | packed = [] |
| 900 | packed.append(struct.pack("!H", self.type)) |
| 901 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 902 | packed.append(struct.pack("!H", self.tp_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 903 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 904 | length = sum([len(x) for x in packed]) |
| 905 | packed[1] = struct.pack("!H", length) |
| 906 | return ''.join(packed) |
| 907 | |
| 908 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 909 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 910 | obj = set_tp_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 911 | _type = reader.read("!H")[0] |
| 912 | assert(_type == 9) |
| 913 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 914 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 915 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 916 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 917 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 918 | return obj |
| 919 | |
| 920 | def __eq__(self, other): |
| 921 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 922 | if self.tp_port != other.tp_port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 923 | return True |
| 924 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 925 | def pretty_print(self, q): |
| 926 | q.text("set_tp_src {") |
| 927 | with q.group(): |
| 928 | with q.indent(2): |
| 929 | q.breakable() |
| 930 | q.text("tp_port = "); |
| 931 | q.text("%#x" % self.tp_port) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 932 | q.breakable() |
| 933 | q.text('}') |
| 934 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 935 | action.subtypes[9] = set_tp_src |
| 936 | |
| 937 | class set_vlan_pcp(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 938 | type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 939 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 940 | def __init__(self, vlan_pcp=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 941 | if vlan_pcp != None: |
| 942 | self.vlan_pcp = vlan_pcp |
| 943 | else: |
| 944 | self.vlan_pcp = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 945 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 946 | |
| 947 | def pack(self): |
| 948 | packed = [] |
| 949 | packed.append(struct.pack("!H", self.type)) |
| 950 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 951 | packed.append(struct.pack("!B", self.vlan_pcp)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 952 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 953 | length = sum([len(x) for x in packed]) |
| 954 | packed[1] = struct.pack("!H", length) |
| 955 | return ''.join(packed) |
| 956 | |
| 957 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 958 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 959 | obj = set_vlan_pcp() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 960 | _type = reader.read("!H")[0] |
| 961 | assert(_type == 2) |
| 962 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 963 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 964 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 965 | obj.vlan_pcp = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 966 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 967 | return obj |
| 968 | |
| 969 | def __eq__(self, other): |
| 970 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 971 | if self.vlan_pcp != other.vlan_pcp: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 972 | return True |
| 973 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 974 | def pretty_print(self, q): |
| 975 | q.text("set_vlan_pcp {") |
| 976 | with q.group(): |
| 977 | with q.indent(2): |
| 978 | q.breakable() |
| 979 | q.text("vlan_pcp = "); |
| 980 | q.text("%#x" % self.vlan_pcp) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 981 | q.breakable() |
| 982 | q.text('}') |
| 983 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 984 | action.subtypes[2] = set_vlan_pcp |
| 985 | |
| 986 | class set_vlan_vid(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 987 | type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 988 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 989 | def __init__(self, vlan_vid=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 990 | if vlan_vid != None: |
| 991 | self.vlan_vid = vlan_vid |
| 992 | else: |
| 993 | self.vlan_vid = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 994 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 995 | |
| 996 | def pack(self): |
| 997 | packed = [] |
| 998 | packed.append(struct.pack("!H", self.type)) |
| 999 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 1000 | packed.append(struct.pack("!H", self.vlan_vid)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1001 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1002 | length = sum([len(x) for x in packed]) |
| 1003 | packed[1] = struct.pack("!H", length) |
| 1004 | return ''.join(packed) |
| 1005 | |
| 1006 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1007 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1008 | obj = set_vlan_vid() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1009 | _type = reader.read("!H")[0] |
| 1010 | assert(_type == 1) |
| 1011 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1012 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1013 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1014 | obj.vlan_vid = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1015 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1016 | return obj |
| 1017 | |
| 1018 | def __eq__(self, other): |
| 1019 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1020 | if self.vlan_vid != other.vlan_vid: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1021 | return True |
| 1022 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1023 | def pretty_print(self, q): |
| 1024 | q.text("set_vlan_vid {") |
| 1025 | with q.group(): |
| 1026 | with q.indent(2): |
| 1027 | q.breakable() |
| 1028 | q.text("vlan_vid = "); |
| 1029 | q.text("%#x" % self.vlan_vid) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1030 | q.breakable() |
| 1031 | q.text('}') |
| 1032 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1033 | action.subtypes[1] = set_vlan_vid |
| 1034 | |
| 1035 | class strip_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1036 | type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1037 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1038 | def __init__(self): |
| 1039 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1040 | |
| 1041 | def pack(self): |
| 1042 | packed = [] |
| 1043 | packed.append(struct.pack("!H", self.type)) |
| 1044 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1045 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1046 | length = sum([len(x) for x in packed]) |
| 1047 | packed[1] = struct.pack("!H", length) |
| 1048 | return ''.join(packed) |
| 1049 | |
| 1050 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1051 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1052 | obj = strip_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1053 | _type = reader.read("!H")[0] |
| 1054 | assert(_type == 3) |
| 1055 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1056 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1057 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1058 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1059 | return obj |
| 1060 | |
| 1061 | def __eq__(self, other): |
| 1062 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1063 | return True |
| 1064 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1065 | def pretty_print(self, q): |
| 1066 | q.text("strip_vlan {") |
| 1067 | with q.group(): |
| 1068 | with q.indent(2): |
| 1069 | q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1070 | q.breakable() |
| 1071 | q.text('}') |
| 1072 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1073 | action.subtypes[3] = strip_vlan |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1074 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1075 | |