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