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