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 common |
| 13 | import action |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 14 | import util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 15 | import loxi.generic_util |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 16 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 17 | class action(loxi.OFObject): |
| 18 | subtypes = {} |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 19 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 20 | @staticmethod |
| 21 | def unpack(reader): |
| 22 | subtype, = reader.peek('!H', 0) |
| 23 | try: |
| 24 | subclass = action.subtypes[subtype] |
| 25 | except KeyError: |
| 26 | raise loxi.ProtocolError("unknown action subtype %#x" % subtype) |
| 27 | return subclass.unpack(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 28 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 29 | |
| 30 | class experimenter(action): |
| 31 | subtypes = {} |
| 32 | |
| 33 | @staticmethod |
| 34 | def unpack(reader): |
| 35 | subtype, = reader.peek('!L', 4) |
| 36 | try: |
| 37 | subclass = experimenter.subtypes[subtype] |
| 38 | except KeyError: |
| 39 | raise loxi.ProtocolError("unknown experimenter action subtype %#x" % subtype) |
| 40 | return subclass.unpack(reader) |
| 41 | |
| 42 | action.subtypes[65535] = experimenter |
| 43 | |
| 44 | class bsn(experimenter): |
| 45 | subtypes = {} |
| 46 | |
| 47 | @staticmethod |
| 48 | def unpack(reader): |
| 49 | subtype, = reader.peek('!L', 8) |
| 50 | try: |
| 51 | subclass = bsn.subtypes[subtype] |
| 52 | except KeyError: |
| 53 | raise loxi.ProtocolError("unknown bsn experimenter action subtype %#x" % subtype) |
| 54 | return subclass.unpack(reader) |
| 55 | |
| 56 | experimenter.subtypes[6035143] = bsn |
| 57 | |
| 58 | class bsn_mirror(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 59 | type = 65535 |
| 60 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 61 | subtype = 1 |
| 62 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 63 | def __init__(self, dest_port=None, vlan_tag=None, copy_stage=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 64 | if dest_port != None: |
| 65 | self.dest_port = dest_port |
| 66 | else: |
| 67 | self.dest_port = 0 |
| 68 | if vlan_tag != None: |
| 69 | self.vlan_tag = vlan_tag |
| 70 | else: |
| 71 | self.vlan_tag = 0 |
| 72 | if copy_stage != None: |
| 73 | self.copy_stage = copy_stage |
| 74 | else: |
| 75 | self.copy_stage = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 76 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 77 | |
| 78 | def pack(self): |
| 79 | packed = [] |
| 80 | packed.append(struct.pack("!H", self.type)) |
| 81 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 82 | packed.append(struct.pack("!L", self.experimenter)) |
| 83 | packed.append(struct.pack("!L", self.subtype)) |
| 84 | packed.append(struct.pack("!L", self.dest_port)) |
| 85 | packed.append(struct.pack("!L", self.vlan_tag)) |
| 86 | packed.append(struct.pack("!B", self.copy_stage)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 87 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 88 | length = sum([len(x) for x in packed]) |
| 89 | packed[1] = struct.pack("!H", length) |
| 90 | return ''.join(packed) |
| 91 | |
| 92 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 93 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 94 | obj = bsn_mirror() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 95 | _type = reader.read("!H")[0] |
| 96 | assert(_type == 65535) |
| 97 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 98 | orig_reader = reader |
| 99 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 100 | _experimenter = reader.read("!L")[0] |
| 101 | assert(_experimenter == 6035143) |
| 102 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 103 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 104 | obj.dest_port = reader.read("!L")[0] |
| 105 | obj.vlan_tag = reader.read("!L")[0] |
| 106 | obj.copy_stage = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 107 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 108 | return obj |
| 109 | |
| 110 | def __eq__(self, other): |
| 111 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 112 | if self.dest_port != other.dest_port: return False |
| 113 | if self.vlan_tag != other.vlan_tag: return False |
| 114 | if self.copy_stage != other.copy_stage: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 115 | return True |
| 116 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 117 | def pretty_print(self, q): |
| 118 | q.text("bsn_mirror {") |
| 119 | with q.group(): |
| 120 | with q.indent(2): |
| 121 | q.breakable() |
| 122 | q.text("dest_port = "); |
| 123 | q.text("%#x" % self.dest_port) |
| 124 | q.text(","); q.breakable() |
| 125 | q.text("vlan_tag = "); |
| 126 | q.text("%#x" % self.vlan_tag) |
| 127 | q.text(","); q.breakable() |
| 128 | q.text("copy_stage = "); |
| 129 | q.text("%#x" % self.copy_stage) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 130 | q.breakable() |
| 131 | q.text('}') |
| 132 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 133 | bsn.subtypes[1] = bsn_mirror |
| 134 | |
| 135 | class bsn_set_tunnel_dst(bsn): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 136 | type = 65535 |
| 137 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 138 | subtype = 2 |
| 139 | |
| 140 | def __init__(self, dst=None): |
| 141 | if dst != None: |
| 142 | self.dst = dst |
| 143 | else: |
| 144 | self.dst = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 145 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 146 | |
| 147 | def pack(self): |
| 148 | packed = [] |
| 149 | packed.append(struct.pack("!H", self.type)) |
| 150 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 151 | packed.append(struct.pack("!L", self.experimenter)) |
| 152 | packed.append(struct.pack("!L", self.subtype)) |
| 153 | packed.append(struct.pack("!L", self.dst)) |
| 154 | length = sum([len(x) for x in packed]) |
| 155 | packed[1] = struct.pack("!H", length) |
| 156 | return ''.join(packed) |
| 157 | |
| 158 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 159 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 160 | obj = bsn_set_tunnel_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 161 | _type = reader.read("!H")[0] |
| 162 | assert(_type == 65535) |
| 163 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 164 | orig_reader = reader |
| 165 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 166 | _experimenter = reader.read("!L")[0] |
| 167 | assert(_experimenter == 6035143) |
| 168 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 169 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 170 | obj.dst = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 171 | return obj |
| 172 | |
| 173 | def __eq__(self, other): |
| 174 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 175 | if self.dst != other.dst: return False |
| 176 | return True |
| 177 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 178 | def pretty_print(self, q): |
| 179 | q.text("bsn_set_tunnel_dst {") |
| 180 | with q.group(): |
| 181 | with q.indent(2): |
| 182 | q.breakable() |
| 183 | q.text("dst = "); |
| 184 | q.text("%#x" % self.dst) |
| 185 | q.breakable() |
| 186 | q.text('}') |
| 187 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 188 | bsn.subtypes[2] = bsn_set_tunnel_dst |
| 189 | |
| 190 | class enqueue(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 191 | type = 11 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 192 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 193 | def __init__(self, port=None, queue_id=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 194 | if port != None: |
| 195 | self.port = port |
| 196 | else: |
| 197 | self.port = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 198 | if queue_id != None: |
| 199 | self.queue_id = queue_id |
| 200 | else: |
| 201 | self.queue_id = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 202 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 203 | |
| 204 | def pack(self): |
| 205 | packed = [] |
| 206 | packed.append(struct.pack("!H", self.type)) |
| 207 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 208 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 209 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 210 | packed.append(struct.pack("!L", self.queue_id)) |
| 211 | length = sum([len(x) for x in packed]) |
| 212 | packed[1] = struct.pack("!H", length) |
| 213 | return ''.join(packed) |
| 214 | |
| 215 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 216 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 217 | obj = enqueue() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 218 | _type = reader.read("!H")[0] |
| 219 | assert(_type == 11) |
| 220 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 221 | orig_reader = reader |
| 222 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 223 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 224 | reader.skip(6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 225 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 226 | return obj |
| 227 | |
| 228 | def __eq__(self, other): |
| 229 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 230 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 231 | if self.queue_id != other.queue_id: return False |
| 232 | return True |
| 233 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 234 | def pretty_print(self, q): |
| 235 | q.text("enqueue {") |
| 236 | with q.group(): |
| 237 | with q.indent(2): |
| 238 | q.breakable() |
| 239 | q.text("port = "); |
| 240 | q.text(util.pretty_port(self.port)) |
| 241 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 242 | q.text("queue_id = "); |
| 243 | q.text("%#x" % self.queue_id) |
| 244 | q.breakable() |
| 245 | q.text('}') |
| 246 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 247 | action.subtypes[11] = enqueue |
| 248 | |
| 249 | class nicira(experimenter): |
| 250 | subtypes = {} |
| 251 | |
| 252 | @staticmethod |
| 253 | def unpack(reader): |
| 254 | subtype, = reader.peek('!H', 8) |
| 255 | try: |
| 256 | subclass = nicira.subtypes[subtype] |
| 257 | except KeyError: |
| 258 | raise loxi.ProtocolError("unknown nicira experimenter action subtype %#x" % subtype) |
| 259 | return subclass.unpack(reader) |
| 260 | |
| 261 | experimenter.subtypes[8992] = nicira |
| 262 | |
| 263 | class nicira_dec_ttl(nicira): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 264 | type = 65535 |
| 265 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 266 | subtype = 18 |
| 267 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 268 | def __init__(self): |
| 269 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 270 | |
| 271 | def pack(self): |
| 272 | packed = [] |
| 273 | packed.append(struct.pack("!H", self.type)) |
| 274 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 275 | packed.append(struct.pack("!L", self.experimenter)) |
| 276 | packed.append(struct.pack("!H", self.subtype)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 277 | packed.append('\x00' * 2) |
| 278 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 279 | length = sum([len(x) for x in packed]) |
| 280 | packed[1] = struct.pack("!H", length) |
| 281 | return ''.join(packed) |
| 282 | |
| 283 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 284 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 285 | obj = nicira_dec_ttl() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 286 | _type = reader.read("!H")[0] |
| 287 | assert(_type == 65535) |
| 288 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 289 | orig_reader = reader |
| 290 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 291 | _experimenter = reader.read("!L")[0] |
| 292 | assert(_experimenter == 8992) |
| 293 | _subtype = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 294 | assert(_subtype == 18) |
| 295 | reader.skip(2) |
| 296 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 297 | return obj |
| 298 | |
| 299 | def __eq__(self, other): |
| 300 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 301 | return True |
| 302 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 303 | def pretty_print(self, q): |
| 304 | q.text("nicira_dec_ttl {") |
| 305 | with q.group(): |
| 306 | with q.indent(2): |
| 307 | q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 308 | q.breakable() |
| 309 | q.text('}') |
| 310 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 311 | nicira.subtypes[18] = nicira_dec_ttl |
| 312 | |
| 313 | class output(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 314 | type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 315 | |
| 316 | def __init__(self, port=None, max_len=None): |
| 317 | if port != None: |
| 318 | self.port = port |
| 319 | else: |
| 320 | self.port = 0 |
| 321 | if max_len != None: |
| 322 | self.max_len = max_len |
| 323 | else: |
| 324 | self.max_len = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 325 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 326 | |
| 327 | def pack(self): |
| 328 | packed = [] |
| 329 | packed.append(struct.pack("!H", self.type)) |
| 330 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 331 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 332 | packed.append(struct.pack("!H", self.max_len)) |
| 333 | length = sum([len(x) for x in packed]) |
| 334 | packed[1] = struct.pack("!H", length) |
| 335 | return ''.join(packed) |
| 336 | |
| 337 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 338 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 339 | obj = output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 340 | _type = reader.read("!H")[0] |
| 341 | assert(_type == 0) |
| 342 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 343 | orig_reader = reader |
| 344 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 345 | obj.port = util.unpack_port_no(reader) |
| 346 | obj.max_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 347 | return obj |
| 348 | |
| 349 | def __eq__(self, other): |
| 350 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 351 | if self.port != other.port: return False |
| 352 | if self.max_len != other.max_len: return False |
| 353 | return True |
| 354 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 355 | def pretty_print(self, q): |
| 356 | q.text("output {") |
| 357 | with q.group(): |
| 358 | with q.indent(2): |
| 359 | q.breakable() |
| 360 | q.text("port = "); |
| 361 | q.text(util.pretty_port(self.port)) |
| 362 | q.text(","); q.breakable() |
| 363 | q.text("max_len = "); |
| 364 | q.text("%#x" % self.max_len) |
| 365 | q.breakable() |
| 366 | q.text('}') |
| 367 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 368 | action.subtypes[0] = output |
| 369 | |
| 370 | class set_dl_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 371 | type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 372 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 373 | def __init__(self, dl_addr=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 374 | if dl_addr != None: |
| 375 | self.dl_addr = dl_addr |
| 376 | else: |
| 377 | self.dl_addr = [0,0,0,0,0,0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 378 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 379 | |
| 380 | def pack(self): |
| 381 | packed = [] |
| 382 | packed.append(struct.pack("!H", self.type)) |
| 383 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 384 | packed.append(struct.pack("!6B", *self.dl_addr)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 385 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 386 | length = sum([len(x) for x in packed]) |
| 387 | packed[1] = struct.pack("!H", length) |
| 388 | return ''.join(packed) |
| 389 | |
| 390 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 391 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 392 | obj = set_dl_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 393 | _type = reader.read("!H")[0] |
| 394 | assert(_type == 5) |
| 395 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 396 | orig_reader = reader |
| 397 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 398 | obj.dl_addr = list(reader.read('!6B')) |
| 399 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 400 | return obj |
| 401 | |
| 402 | def __eq__(self, other): |
| 403 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 404 | if self.dl_addr != other.dl_addr: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 405 | return True |
| 406 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 407 | def pretty_print(self, q): |
| 408 | q.text("set_dl_dst {") |
| 409 | with q.group(): |
| 410 | with q.indent(2): |
| 411 | q.breakable() |
| 412 | q.text("dl_addr = "); |
| 413 | q.text(util.pretty_mac(self.dl_addr)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 414 | q.breakable() |
| 415 | q.text('}') |
| 416 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 417 | action.subtypes[5] = set_dl_dst |
| 418 | |
| 419 | class set_dl_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 420 | type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 421 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 422 | def __init__(self, dl_addr=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 423 | if dl_addr != None: |
| 424 | self.dl_addr = dl_addr |
| 425 | else: |
| 426 | self.dl_addr = [0,0,0,0,0,0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 427 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 428 | |
| 429 | def pack(self): |
| 430 | packed = [] |
| 431 | packed.append(struct.pack("!H", self.type)) |
| 432 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 433 | packed.append(struct.pack("!6B", *self.dl_addr)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 434 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 435 | length = sum([len(x) for x in packed]) |
| 436 | packed[1] = struct.pack("!H", length) |
| 437 | return ''.join(packed) |
| 438 | |
| 439 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 440 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 441 | obj = set_dl_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 442 | _type = reader.read("!H")[0] |
| 443 | assert(_type == 4) |
| 444 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 445 | orig_reader = reader |
| 446 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 447 | obj.dl_addr = list(reader.read('!6B')) |
| 448 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 449 | return obj |
| 450 | |
| 451 | def __eq__(self, other): |
| 452 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 453 | if self.dl_addr != other.dl_addr: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 454 | return True |
| 455 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 456 | def pretty_print(self, q): |
| 457 | q.text("set_dl_src {") |
| 458 | with q.group(): |
| 459 | with q.indent(2): |
| 460 | q.breakable() |
| 461 | q.text("dl_addr = "); |
| 462 | q.text(util.pretty_mac(self.dl_addr)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 463 | q.breakable() |
| 464 | q.text('}') |
| 465 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 466 | action.subtypes[4] = set_dl_src |
| 467 | |
| 468 | class set_nw_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 469 | type = 7 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 470 | |
| 471 | def __init__(self, nw_addr=None): |
| 472 | if nw_addr != None: |
| 473 | self.nw_addr = nw_addr |
| 474 | else: |
| 475 | self.nw_addr = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 476 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 477 | |
| 478 | def pack(self): |
| 479 | packed = [] |
| 480 | packed.append(struct.pack("!H", self.type)) |
| 481 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 482 | packed.append(struct.pack("!L", self.nw_addr)) |
| 483 | length = sum([len(x) for x in packed]) |
| 484 | packed[1] = struct.pack("!H", length) |
| 485 | return ''.join(packed) |
| 486 | |
| 487 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 488 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 489 | obj = set_nw_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 490 | _type = reader.read("!H")[0] |
| 491 | assert(_type == 7) |
| 492 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 493 | orig_reader = reader |
| 494 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 495 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 496 | return obj |
| 497 | |
| 498 | def __eq__(self, other): |
| 499 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 500 | if self.nw_addr != other.nw_addr: return False |
| 501 | return True |
| 502 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 503 | def pretty_print(self, q): |
| 504 | q.text("set_nw_dst {") |
| 505 | with q.group(): |
| 506 | with q.indent(2): |
| 507 | q.breakable() |
| 508 | q.text("nw_addr = "); |
| 509 | q.text("%#x" % self.nw_addr) |
| 510 | q.breakable() |
| 511 | q.text('}') |
| 512 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 513 | action.subtypes[7] = set_nw_dst |
| 514 | |
| 515 | class set_nw_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 516 | type = 6 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 517 | |
| 518 | def __init__(self, nw_addr=None): |
| 519 | if nw_addr != None: |
| 520 | self.nw_addr = nw_addr |
| 521 | else: |
| 522 | self.nw_addr = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 523 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 524 | |
| 525 | def pack(self): |
| 526 | packed = [] |
| 527 | packed.append(struct.pack("!H", self.type)) |
| 528 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 529 | packed.append(struct.pack("!L", self.nw_addr)) |
| 530 | length = sum([len(x) for x in packed]) |
| 531 | packed[1] = struct.pack("!H", length) |
| 532 | return ''.join(packed) |
| 533 | |
| 534 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 535 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 536 | obj = set_nw_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 537 | _type = reader.read("!H")[0] |
| 538 | assert(_type == 6) |
| 539 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 540 | orig_reader = reader |
| 541 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 542 | obj.nw_addr = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 543 | return obj |
| 544 | |
| 545 | def __eq__(self, other): |
| 546 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 547 | if self.nw_addr != other.nw_addr: return False |
| 548 | return True |
| 549 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 550 | def pretty_print(self, q): |
| 551 | q.text("set_nw_src {") |
| 552 | with q.group(): |
| 553 | with q.indent(2): |
| 554 | q.breakable() |
| 555 | q.text("nw_addr = "); |
| 556 | q.text("%#x" % self.nw_addr) |
| 557 | q.breakable() |
| 558 | q.text('}') |
| 559 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 560 | action.subtypes[6] = set_nw_src |
| 561 | |
| 562 | class set_nw_tos(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 563 | type = 8 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 564 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 565 | def __init__(self, nw_tos=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 566 | if nw_tos != None: |
| 567 | self.nw_tos = nw_tos |
| 568 | else: |
| 569 | self.nw_tos = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 570 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 571 | |
| 572 | def pack(self): |
| 573 | packed = [] |
| 574 | packed.append(struct.pack("!H", self.type)) |
| 575 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 576 | packed.append(struct.pack("!B", self.nw_tos)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 577 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 578 | length = sum([len(x) for x in packed]) |
| 579 | packed[1] = struct.pack("!H", length) |
| 580 | return ''.join(packed) |
| 581 | |
| 582 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 583 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 584 | obj = set_nw_tos() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 585 | _type = reader.read("!H")[0] |
| 586 | assert(_type == 8) |
| 587 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 588 | orig_reader = reader |
| 589 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 590 | obj.nw_tos = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 591 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 592 | return obj |
| 593 | |
| 594 | def __eq__(self, other): |
| 595 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 596 | if self.nw_tos != other.nw_tos: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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("set_nw_tos {") |
| 601 | with q.group(): |
| 602 | with q.indent(2): |
| 603 | q.breakable() |
| 604 | q.text("nw_tos = "); |
| 605 | q.text("%#x" % self.nw_tos) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 606 | q.breakable() |
| 607 | q.text('}') |
| 608 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 609 | action.subtypes[8] = set_nw_tos |
| 610 | |
| 611 | class set_tp_dst(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 612 | type = 10 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 613 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 614 | def __init__(self, tp_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 615 | if tp_port != None: |
| 616 | self.tp_port = tp_port |
| 617 | else: |
| 618 | self.tp_port = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 619 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 620 | |
| 621 | def pack(self): |
| 622 | packed = [] |
| 623 | packed.append(struct.pack("!H", self.type)) |
| 624 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 625 | packed.append(struct.pack("!H", self.tp_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 626 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 627 | length = sum([len(x) for x in packed]) |
| 628 | packed[1] = struct.pack("!H", length) |
| 629 | return ''.join(packed) |
| 630 | |
| 631 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 632 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 633 | obj = set_tp_dst() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 634 | _type = reader.read("!H")[0] |
| 635 | assert(_type == 10) |
| 636 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 637 | orig_reader = reader |
| 638 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 639 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 640 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 641 | return obj |
| 642 | |
| 643 | def __eq__(self, other): |
| 644 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 645 | if self.tp_port != other.tp_port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 646 | return True |
| 647 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 648 | def pretty_print(self, q): |
| 649 | q.text("set_tp_dst {") |
| 650 | with q.group(): |
| 651 | with q.indent(2): |
| 652 | q.breakable() |
| 653 | q.text("tp_port = "); |
| 654 | q.text("%#x" % self.tp_port) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 655 | q.breakable() |
| 656 | q.text('}') |
| 657 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 658 | action.subtypes[10] = set_tp_dst |
| 659 | |
| 660 | class set_tp_src(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 661 | type = 9 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 662 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 663 | def __init__(self, tp_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 664 | if tp_port != None: |
| 665 | self.tp_port = tp_port |
| 666 | else: |
| 667 | self.tp_port = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 668 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 669 | |
| 670 | def pack(self): |
| 671 | packed = [] |
| 672 | packed.append(struct.pack("!H", self.type)) |
| 673 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 674 | packed.append(struct.pack("!H", self.tp_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 675 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 676 | length = sum([len(x) for x in packed]) |
| 677 | packed[1] = struct.pack("!H", length) |
| 678 | return ''.join(packed) |
| 679 | |
| 680 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 681 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 682 | obj = set_tp_src() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 683 | _type = reader.read("!H")[0] |
| 684 | assert(_type == 9) |
| 685 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 686 | orig_reader = reader |
| 687 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 688 | obj.tp_port = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 689 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 690 | return obj |
| 691 | |
| 692 | def __eq__(self, other): |
| 693 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 694 | if self.tp_port != other.tp_port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 695 | return True |
| 696 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 697 | def pretty_print(self, q): |
| 698 | q.text("set_tp_src {") |
| 699 | with q.group(): |
| 700 | with q.indent(2): |
| 701 | q.breakable() |
| 702 | q.text("tp_port = "); |
| 703 | q.text("%#x" % self.tp_port) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 704 | q.breakable() |
| 705 | q.text('}') |
| 706 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 707 | action.subtypes[9] = set_tp_src |
| 708 | |
| 709 | class set_vlan_pcp(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 710 | type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 711 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 712 | def __init__(self, vlan_pcp=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 713 | if vlan_pcp != None: |
| 714 | self.vlan_pcp = vlan_pcp |
| 715 | else: |
| 716 | self.vlan_pcp = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 717 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 718 | |
| 719 | def pack(self): |
| 720 | packed = [] |
| 721 | packed.append(struct.pack("!H", self.type)) |
| 722 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 723 | packed.append(struct.pack("!B", self.vlan_pcp)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 724 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 725 | length = sum([len(x) for x in packed]) |
| 726 | packed[1] = struct.pack("!H", length) |
| 727 | return ''.join(packed) |
| 728 | |
| 729 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 730 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 731 | obj = set_vlan_pcp() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 732 | _type = reader.read("!H")[0] |
| 733 | assert(_type == 2) |
| 734 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 735 | orig_reader = reader |
| 736 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 737 | obj.vlan_pcp = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 738 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 739 | return obj |
| 740 | |
| 741 | def __eq__(self, other): |
| 742 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 743 | if self.vlan_pcp != other.vlan_pcp: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 744 | return True |
| 745 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 746 | def pretty_print(self, q): |
| 747 | q.text("set_vlan_pcp {") |
| 748 | with q.group(): |
| 749 | with q.indent(2): |
| 750 | q.breakable() |
| 751 | q.text("vlan_pcp = "); |
| 752 | q.text("%#x" % self.vlan_pcp) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 753 | q.breakable() |
| 754 | q.text('}') |
| 755 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 756 | action.subtypes[2] = set_vlan_pcp |
| 757 | |
| 758 | class set_vlan_vid(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 759 | type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 760 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 761 | def __init__(self, vlan_vid=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 762 | if vlan_vid != None: |
| 763 | self.vlan_vid = vlan_vid |
| 764 | else: |
| 765 | self.vlan_vid = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 766 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 767 | |
| 768 | def pack(self): |
| 769 | packed = [] |
| 770 | packed.append(struct.pack("!H", self.type)) |
| 771 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
| 772 | packed.append(struct.pack("!H", self.vlan_vid)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 773 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 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_vlan_vid() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 781 | _type = reader.read("!H")[0] |
| 782 | assert(_type == 1) |
| 783 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 784 | orig_reader = reader |
| 785 | reader = orig_reader.slice(_len - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 786 | obj.vlan_vid = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 787 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 788 | return obj |
| 789 | |
| 790 | def __eq__(self, other): |
| 791 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 792 | if self.vlan_vid != other.vlan_vid: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 793 | return True |
| 794 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 795 | def pretty_print(self, q): |
| 796 | q.text("set_vlan_vid {") |
| 797 | with q.group(): |
| 798 | with q.indent(2): |
| 799 | q.breakable() |
| 800 | q.text("vlan_vid = "); |
| 801 | q.text("%#x" % self.vlan_vid) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 802 | q.breakable() |
| 803 | q.text('}') |
| 804 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 805 | action.subtypes[1] = set_vlan_vid |
| 806 | |
| 807 | class strip_vlan(action): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 808 | type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 809 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 810 | def __init__(self): |
| 811 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 812 | |
| 813 | def pack(self): |
| 814 | packed = [] |
| 815 | packed.append(struct.pack("!H", self.type)) |
| 816 | packed.append(struct.pack("!H", 0)) # placeholder for len at index 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 817 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 818 | length = sum([len(x) for x in packed]) |
| 819 | packed[1] = struct.pack("!H", length) |
| 820 | return ''.join(packed) |
| 821 | |
| 822 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 823 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 824 | obj = strip_vlan() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 825 | _type = reader.read("!H")[0] |
| 826 | assert(_type == 3) |
| 827 | _len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 828 | orig_reader = reader |
| 829 | reader = orig_reader.slice(_len - (2 + 2)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 830 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 831 | return obj |
| 832 | |
| 833 | def __eq__(self, other): |
| 834 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 835 | return True |
| 836 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 837 | def pretty_print(self, q): |
| 838 | q.text("strip_vlan {") |
| 839 | with q.group(): |
| 840 | with q.indent(2): |
| 841 | q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 842 | q.breakable() |
| 843 | q.text('}') |
| 844 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame^] | 845 | action.subtypes[3] = strip_vlan |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 846 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 847 | |