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 | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 27 | import util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 28 | import loxi.generic_util |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 29 | |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 30 | import sys |
| 31 | ofp = sys.modules['loxi.of10'] |
| 32 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 33 | class action(loxi.OFObject): |
| 34 | subtypes = {} |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 259 | subtype = 1 |
| 260 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 261 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 274 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 285 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 | b658ddd | 2013-03-12 10:15:10 -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) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 306 | return obj |
| 307 | |
| 308 | def __eq__(self, other): |
| 309 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 313 | return True |
| 314 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -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) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 | b658ddd | 2013-03-12 10:15:10 -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 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 343 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 | b658ddd | 2013-03-12 10:15:10 -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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 369 | return obj |
| 370 | |
| 371 | def __eq__(self, other): |
| 372 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 373 | if self.dst != other.dst: return False |
| 374 | return True |
| 375 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -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 enqueue(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 389 | type = 11 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 390 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 391 | def __init__(self, port=None, queue_id=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 392 | if port != None: |
| 393 | self.port = port |
| 394 | else: |
| 395 | self.port = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 396 | if queue_id != None: |
| 397 | self.queue_id = queue_id |
| 398 | else: |
| 399 | self.queue_id = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 400 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 401 | |
| 402 | def pack(self): |
| 403 | packed = [] |
| 404 | packed.append(struct.pack("!H", self.type)) |
| 405 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 406 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 407 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 408 | packed.append(struct.pack("!L", self.queue_id)) |
| 409 | length = sum([len(x) for x in packed]) |
| 410 | packed[1] = struct.pack("!H", length) |
| 411 | return ''.join(packed) |
| 412 | |
| 413 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 414 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 415 | obj = enqueue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 416 | _type = reader.read("!H")[0] |
| 417 | assert(_type == 11) |
| 418 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 419 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 420 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 421 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 422 | reader.skip(6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 423 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 424 | return obj |
| 425 | |
| 426 | def __eq__(self, other): |
| 427 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 428 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 429 | if self.queue_id != other.queue_id: return False |
| 430 | return True |
| 431 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 432 | def pretty_print(self, q): |
| 433 | q.text("enqueue {") |
| 434 | with q.group(): |
| 435 | with q.indent(2): |
| 436 | q.breakable() |
| 437 | q.text("port = "); |
| 438 | q.text(util.pretty_port(self.port)) |
| 439 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 440 | q.text("queue_id = "); |
| 441 | q.text("%#x" % self.queue_id) |
| 442 | q.breakable() |
| 443 | q.text('}') |
| 444 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 445 | action.subtypes[11] = enqueue |
| 446 | |
| 447 | class nicira(experimenter): |
| 448 | subtypes = {} |
| 449 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 450 | type = 65535 |
| 451 | experimenter = 8992 |
| 452 | |
| 453 | def __init__(self, subtype=None): |
| 454 | if subtype != None: |
| 455 | self.subtype = subtype |
| 456 | else: |
| 457 | self.subtype = 0 |
| 458 | return |
| 459 | |
| 460 | def pack(self): |
| 461 | packed = [] |
| 462 | packed.append(struct.pack("!H", self.type)) |
| 463 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 464 | packed.append(struct.pack("!L", self.experimenter)) |
| 465 | packed.append(struct.pack("!H", self.subtype)) |
| 466 | packed.append('\x00' * 2) |
| 467 | packed.append('\x00' * 4) |
| 468 | length = sum([len(x) for x in packed]) |
| 469 | packed[1] = struct.pack("!H", length) |
| 470 | return ''.join(packed) |
| 471 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 472 | @staticmethod |
| 473 | def unpack(reader): |
| 474 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 475 | subclass = nicira.subtypes.get(subtype) |
| 476 | if subclass: |
| 477 | return subclass.unpack(reader) |
| 478 | |
| 479 | obj = nicira() |
| 480 | _type = reader.read("!H")[0] |
| 481 | assert(_type == 65535) |
| 482 | _len = reader.read("!H")[0] |
| 483 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 484 | reader = orig_reader.slice(_len, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 485 | _experimenter = reader.read("!L")[0] |
| 486 | assert(_experimenter == 8992) |
| 487 | obj.subtype = reader.read("!H")[0] |
| 488 | reader.skip(2) |
| 489 | reader.skip(4) |
| 490 | return obj |
| 491 | |
| 492 | def __eq__(self, other): |
| 493 | if type(self) != type(other): return False |
| 494 | if self.subtype != other.subtype: return False |
| 495 | return True |
| 496 | |
| 497 | def pretty_print(self, q): |
| 498 | q.text("nicira {") |
| 499 | with q.group(): |
| 500 | with q.indent(2): |
| 501 | q.breakable() |
| 502 | q.breakable() |
| 503 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 504 | |
| 505 | experimenter.subtypes[8992] = nicira |
| 506 | |
| 507 | class nicira_dec_ttl(nicira): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 508 | type = 65535 |
| 509 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 510 | subtype = 18 |
| 511 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 512 | def __init__(self): |
| 513 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 514 | |
| 515 | def pack(self): |
| 516 | packed = [] |
| 517 | packed.append(struct.pack("!H", self.type)) |
| 518 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 519 | packed.append(struct.pack("!L", self.experimenter)) |
| 520 | packed.append(struct.pack("!H", self.subtype)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 521 | packed.append('\x00' * 2) |
| 522 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 523 | length = sum([len(x) for x in packed]) |
| 524 | packed[1] = struct.pack("!H", length) |
| 525 | return ''.join(packed) |
| 526 | |
| 527 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 528 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 529 | obj = nicira_dec_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 530 | _type = reader.read("!H")[0] |
| 531 | assert(_type == 65535) |
| 532 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 533 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 534 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 535 | _experimenter = reader.read("!L")[0] |
| 536 | assert(_experimenter == 8992) |
| 537 | _subtype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 538 | assert(_subtype == 18) |
| 539 | reader.skip(2) |
| 540 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 541 | return obj |
| 542 | |
| 543 | def __eq__(self, other): |
| 544 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 545 | return True |
| 546 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 547 | def pretty_print(self, q): |
| 548 | q.text("nicira_dec_ttl {") |
| 549 | with q.group(): |
| 550 | with q.indent(2): |
| 551 | q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 552 | q.breakable() |
| 553 | q.text('}') |
| 554 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 555 | nicira.subtypes[18] = nicira_dec_ttl |
| 556 | |
| 557 | class output(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 558 | type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 559 | |
| 560 | def __init__(self, port=None, max_len=None): |
| 561 | if port != None: |
| 562 | self.port = port |
| 563 | else: |
| 564 | self.port = 0 |
| 565 | if max_len != None: |
| 566 | self.max_len = max_len |
| 567 | else: |
| 568 | self.max_len = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 569 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 570 | |
| 571 | def pack(self): |
| 572 | packed = [] |
| 573 | packed.append(struct.pack("!H", self.type)) |
| 574 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 575 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 576 | packed.append(struct.pack("!H", self.max_len)) |
| 577 | length = sum([len(x) for x in packed]) |
| 578 | packed[1] = struct.pack("!H", length) |
| 579 | return ''.join(packed) |
| 580 | |
| 581 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 582 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 583 | obj = output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 584 | _type = reader.read("!H")[0] |
| 585 | assert(_type == 0) |
| 586 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 587 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 588 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 589 | obj.port = util.unpack_port_no(reader) |
| 590 | obj.max_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 591 | return obj |
| 592 | |
| 593 | def __eq__(self, other): |
| 594 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 595 | if self.port != other.port: return False |
| 596 | if self.max_len != other.max_len: return False |
| 597 | return True |
| 598 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 599 | def pretty_print(self, q): |
| 600 | q.text("output {") |
| 601 | with q.group(): |
| 602 | with q.indent(2): |
| 603 | q.breakable() |
| 604 | q.text("port = "); |
| 605 | q.text(util.pretty_port(self.port)) |
| 606 | q.text(","); q.breakable() |
| 607 | q.text("max_len = "); |
| 608 | q.text("%#x" % self.max_len) |
| 609 | q.breakable() |
| 610 | q.text('}') |
| 611 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 612 | action.subtypes[0] = output |
| 613 | |
| 614 | class set_dl_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 615 | type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 616 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 617 | def __init__(self, dl_addr=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 618 | if dl_addr != None: |
| 619 | self.dl_addr = dl_addr |
| 620 | else: |
| 621 | self.dl_addr = [0,0,0,0,0,0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 622 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 623 | |
| 624 | def pack(self): |
| 625 | packed = [] |
| 626 | packed.append(struct.pack("!H", self.type)) |
| 627 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 628 | packed.append(struct.pack("!6B", *self.dl_addr)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 629 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 630 | length = sum([len(x) for x in packed]) |
| 631 | packed[1] = struct.pack("!H", length) |
| 632 | return ''.join(packed) |
| 633 | |
| 634 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 635 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 636 | obj = set_dl_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 637 | _type = reader.read("!H")[0] |
| 638 | assert(_type == 5) |
| 639 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 640 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 641 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 642 | obj.dl_addr = list(reader.read('!6B')) |
| 643 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 644 | return obj |
| 645 | |
| 646 | def __eq__(self, other): |
| 647 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 648 | if self.dl_addr != other.dl_addr: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 649 | return True |
| 650 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 651 | def pretty_print(self, q): |
| 652 | q.text("set_dl_dst {") |
| 653 | with q.group(): |
| 654 | with q.indent(2): |
| 655 | q.breakable() |
| 656 | q.text("dl_addr = "); |
| 657 | q.text(util.pretty_mac(self.dl_addr)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 658 | q.breakable() |
| 659 | q.text('}') |
| 660 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 661 | action.subtypes[5] = set_dl_dst |
| 662 | |
| 663 | class set_dl_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 664 | type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 665 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 666 | def __init__(self, dl_addr=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 667 | if dl_addr != None: |
| 668 | self.dl_addr = dl_addr |
| 669 | else: |
| 670 | self.dl_addr = [0,0,0,0,0,0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 671 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 672 | |
| 673 | def pack(self): |
| 674 | packed = [] |
| 675 | packed.append(struct.pack("!H", self.type)) |
| 676 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 677 | packed.append(struct.pack("!6B", *self.dl_addr)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 678 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 679 | length = sum([len(x) for x in packed]) |
| 680 | packed[1] = struct.pack("!H", length) |
| 681 | return ''.join(packed) |
| 682 | |
| 683 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 684 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 685 | obj = set_dl_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 686 | _type = reader.read("!H")[0] |
| 687 | assert(_type == 4) |
| 688 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 689 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 690 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 691 | obj.dl_addr = list(reader.read('!6B')) |
| 692 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 693 | return obj |
| 694 | |
| 695 | def __eq__(self, other): |
| 696 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 697 | if self.dl_addr != other.dl_addr: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 698 | return True |
| 699 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 700 | def pretty_print(self, q): |
| 701 | q.text("set_dl_src {") |
| 702 | with q.group(): |
| 703 | with q.indent(2): |
| 704 | q.breakable() |
| 705 | q.text("dl_addr = "); |
| 706 | q.text(util.pretty_mac(self.dl_addr)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 707 | q.breakable() |
| 708 | q.text('}') |
| 709 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 710 | action.subtypes[4] = set_dl_src |
| 711 | |
| 712 | class set_nw_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 713 | type = 7 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 714 | |
| 715 | def __init__(self, nw_addr=None): |
| 716 | if nw_addr != None: |
| 717 | self.nw_addr = nw_addr |
| 718 | else: |
| 719 | self.nw_addr = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 720 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 721 | |
| 722 | def pack(self): |
| 723 | packed = [] |
| 724 | packed.append(struct.pack("!H", self.type)) |
| 725 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 726 | packed.append(struct.pack("!L", self.nw_addr)) |
| 727 | length = sum([len(x) for x in packed]) |
| 728 | packed[1] = struct.pack("!H", length) |
| 729 | return ''.join(packed) |
| 730 | |
| 731 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 732 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 733 | obj = set_nw_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 734 | _type = reader.read("!H")[0] |
| 735 | assert(_type == 7) |
| 736 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 737 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 738 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 739 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 740 | return obj |
| 741 | |
| 742 | def __eq__(self, other): |
| 743 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 744 | if self.nw_addr != other.nw_addr: return False |
| 745 | return True |
| 746 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 747 | def pretty_print(self, q): |
| 748 | q.text("set_nw_dst {") |
| 749 | with q.group(): |
| 750 | with q.indent(2): |
| 751 | q.breakable() |
| 752 | q.text("nw_addr = "); |
| 753 | q.text("%#x" % self.nw_addr) |
| 754 | q.breakable() |
| 755 | q.text('}') |
| 756 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 757 | action.subtypes[7] = set_nw_dst |
| 758 | |
| 759 | class set_nw_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 760 | type = 6 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 761 | |
| 762 | def __init__(self, nw_addr=None): |
| 763 | if nw_addr != None: |
| 764 | self.nw_addr = nw_addr |
| 765 | else: |
| 766 | self.nw_addr = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 767 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 768 | |
| 769 | def pack(self): |
| 770 | packed = [] |
| 771 | packed.append(struct.pack("!H", self.type)) |
| 772 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 773 | packed.append(struct.pack("!L", self.nw_addr)) |
| 774 | length = sum([len(x) for x in packed]) |
| 775 | packed[1] = struct.pack("!H", length) |
| 776 | return ''.join(packed) |
| 777 | |
| 778 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 779 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 780 | obj = set_nw_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 781 | _type = reader.read("!H")[0] |
| 782 | assert(_type == 6) |
| 783 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 784 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 785 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 786 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 787 | return obj |
| 788 | |
| 789 | def __eq__(self, other): |
| 790 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 791 | if self.nw_addr != other.nw_addr: return False |
| 792 | return True |
| 793 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 794 | def pretty_print(self, q): |
| 795 | q.text("set_nw_src {") |
| 796 | with q.group(): |
| 797 | with q.indent(2): |
| 798 | q.breakable() |
| 799 | q.text("nw_addr = "); |
| 800 | q.text("%#x" % self.nw_addr) |
| 801 | q.breakable() |
| 802 | q.text('}') |
| 803 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 804 | action.subtypes[6] = set_nw_src |
| 805 | |
| 806 | class set_nw_tos(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 807 | type = 8 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 808 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 809 | def __init__(self, nw_tos=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 810 | if nw_tos != None: |
| 811 | self.nw_tos = nw_tos |
| 812 | else: |
| 813 | self.nw_tos = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 814 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 815 | |
| 816 | def pack(self): |
| 817 | packed = [] |
| 818 | packed.append(struct.pack("!H", self.type)) |
| 819 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 820 | packed.append(struct.pack("!B", self.nw_tos)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 821 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 822 | length = sum([len(x) for x in packed]) |
| 823 | packed[1] = struct.pack("!H", length) |
| 824 | return ''.join(packed) |
| 825 | |
| 826 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 827 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 828 | obj = set_nw_tos() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 829 | _type = reader.read("!H")[0] |
| 830 | assert(_type == 8) |
| 831 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 832 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 833 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 834 | obj.nw_tos = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 835 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 836 | return obj |
| 837 | |
| 838 | def __eq__(self, other): |
| 839 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 840 | if self.nw_tos != other.nw_tos: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 841 | return True |
| 842 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 843 | def pretty_print(self, q): |
| 844 | q.text("set_nw_tos {") |
| 845 | with q.group(): |
| 846 | with q.indent(2): |
| 847 | q.breakable() |
| 848 | q.text("nw_tos = "); |
| 849 | q.text("%#x" % self.nw_tos) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 850 | q.breakable() |
| 851 | q.text('}') |
| 852 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 853 | action.subtypes[8] = set_nw_tos |
| 854 | |
| 855 | class set_tp_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 856 | type = 10 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 857 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 858 | def __init__(self, tp_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 859 | if tp_port != None: |
| 860 | self.tp_port = tp_port |
| 861 | else: |
| 862 | self.tp_port = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 863 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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.tp_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 870 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 877 | obj = set_tp_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 878 | _type = reader.read("!H")[0] |
| 879 | assert(_type == 10) |
| 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.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 884 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 885 | return obj |
| 886 | |
| 887 | def __eq__(self, other): |
| 888 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 889 | if self.tp_port != other.tp_port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 890 | return True |
| 891 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 892 | def pretty_print(self, q): |
| 893 | q.text("set_tp_dst {") |
| 894 | with q.group(): |
| 895 | with q.indent(2): |
| 896 | q.breakable() |
| 897 | q.text("tp_port = "); |
| 898 | q.text("%#x" % self.tp_port) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 899 | q.breakable() |
| 900 | q.text('}') |
| 901 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 902 | action.subtypes[10] = set_tp_dst |
| 903 | |
| 904 | class set_tp_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 905 | type = 9 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 906 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 907 | def __init__(self, tp_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 908 | if tp_port != None: |
| 909 | self.tp_port = tp_port |
| 910 | else: |
| 911 | self.tp_port = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 912 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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.tp_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 919 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 926 | obj = set_tp_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 927 | _type = reader.read("!H")[0] |
| 928 | assert(_type == 9) |
| 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.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 933 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 934 | return obj |
| 935 | |
| 936 | def __eq__(self, other): |
| 937 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 938 | if self.tp_port != other.tp_port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 939 | return True |
| 940 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 941 | def pretty_print(self, q): |
| 942 | q.text("set_tp_src {") |
| 943 | with q.group(): |
| 944 | with q.indent(2): |
| 945 | q.breakable() |
| 946 | q.text("tp_port = "); |
| 947 | q.text("%#x" % self.tp_port) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 948 | q.breakable() |
| 949 | q.text('}') |
| 950 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 951 | action.subtypes[9] = set_tp_src |
| 952 | |
| 953 | class set_vlan_pcp(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 954 | type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 955 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 956 | def __init__(self, vlan_pcp=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 957 | if vlan_pcp != None: |
| 958 | self.vlan_pcp = vlan_pcp |
| 959 | else: |
| 960 | self.vlan_pcp = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 961 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 |
| 967 | packed.append(struct.pack("!B", self.vlan_pcp)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 968 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 969 | length = sum([len(x) for x in packed]) |
| 970 | packed[1] = struct.pack("!H", length) |
| 971 | return ''.join(packed) |
| 972 | |
| 973 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 974 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 975 | obj = set_vlan_pcp() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 976 | _type = reader.read("!H")[0] |
| 977 | assert(_type == 2) |
| 978 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 979 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 980 | reader = orig_reader.slice(_len, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 981 | obj.vlan_pcp = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 982 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 983 | return obj |
| 984 | |
| 985 | def __eq__(self, other): |
| 986 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 987 | if self.vlan_pcp != other.vlan_pcp: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 988 | return True |
| 989 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 990 | def pretty_print(self, q): |
| 991 | q.text("set_vlan_pcp {") |
| 992 | with q.group(): |
| 993 | with q.indent(2): |
| 994 | q.breakable() |
| 995 | q.text("vlan_pcp = "); |
| 996 | q.text("%#x" % self.vlan_pcp) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 997 | q.breakable() |
| 998 | q.text('}') |
| 999 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1000 | action.subtypes[2] = set_vlan_pcp |
| 1001 | |
| 1002 | class set_vlan_vid(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1003 | type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1004 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1005 | def __init__(self, vlan_vid=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1006 | if vlan_vid != None: |
| 1007 | self.vlan_vid = vlan_vid |
| 1008 | else: |
| 1009 | self.vlan_vid = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1010 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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("!H", self.vlan_vid)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1017 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1024 | obj = set_vlan_vid() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1025 | _type = reader.read("!H")[0] |
| 1026 | assert(_type == 1) |
| 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.vlan_vid = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1031 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1032 | return obj |
| 1033 | |
| 1034 | def __eq__(self, other): |
| 1035 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1036 | if self.vlan_vid != other.vlan_vid: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1037 | return True |
| 1038 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1039 | def pretty_print(self, q): |
| 1040 | q.text("set_vlan_vid {") |
| 1041 | with q.group(): |
| 1042 | with q.indent(2): |
| 1043 | q.breakable() |
| 1044 | q.text("vlan_vid = "); |
| 1045 | q.text("%#x" % self.vlan_vid) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1046 | q.breakable() |
| 1047 | q.text('}') |
| 1048 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1049 | action.subtypes[1] = set_vlan_vid |
| 1050 | |
| 1051 | class strip_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1052 | type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1053 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1054 | def __init__(self): |
| 1055 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1056 | |
| 1057 | def pack(self): |
| 1058 | packed = [] |
| 1059 | packed.append(struct.pack("!H", self.type)) |
| 1060 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1061 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1062 | length = sum([len(x) for x in packed]) |
| 1063 | packed[1] = struct.pack("!H", length) |
| 1064 | return ''.join(packed) |
| 1065 | |
| 1066 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1067 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1068 | obj = strip_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1069 | _type = reader.read("!H")[0] |
| 1070 | assert(_type == 3) |
| 1071 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1072 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1073 | reader = orig_reader.slice(_len, 4) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1074 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1075 | return obj |
| 1076 | |
| 1077 | def __eq__(self, other): |
| 1078 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1079 | return True |
| 1080 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1081 | def pretty_print(self, q): |
| 1082 | q.text("strip_vlan {") |
| 1083 | with q.group(): |
| 1084 | with q.indent(2): |
| 1085 | q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1086 | q.breakable() |
| 1087 | q.text('}') |
| 1088 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1089 | action.subtypes[3] = strip_vlan |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1090 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1091 | |