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