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 | c2ee4b8 | 2013-04-24 17:12:38 -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 | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7 | # Do not modify |
| 8 | |
| 9 | import struct |
| 10 | import loxi |
| 11 | import const |
| 12 | import common |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 13 | import action |
| 14 | import instruction |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 15 | import util |
| 16 | import loxi.generic_util |
| 17 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 18 | class message(loxi.OFObject): |
| 19 | subtypes = {} |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 20 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 21 | version = 2 |
| 22 | |
| 23 | def __init__(self, type=None, xid=None): |
| 24 | if type != None: |
| 25 | self.type = type |
| 26 | else: |
| 27 | self.type = 0 |
| 28 | if xid != None: |
| 29 | self.xid = xid |
| 30 | else: |
| 31 | self.xid = None |
| 32 | return |
| 33 | |
| 34 | def pack(self): |
| 35 | packed = [] |
| 36 | packed.append(struct.pack("!B", self.version)) |
| 37 | packed.append(struct.pack("!B", self.type)) |
| 38 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 39 | packed.append(struct.pack("!L", self.xid)) |
| 40 | length = sum([len(x) for x in packed]) |
| 41 | packed[2] = struct.pack("!H", length) |
| 42 | return ''.join(packed) |
| 43 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 44 | @staticmethod |
| 45 | def unpack(reader): |
| 46 | subtype, = reader.peek('B', 1) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 47 | subclass = message.subtypes.get(subtype) |
| 48 | if subclass: |
| 49 | return subclass.unpack(reader) |
| 50 | |
| 51 | obj = message() |
| 52 | _version = reader.read("!B")[0] |
| 53 | assert(_version == 2) |
| 54 | obj.type = reader.read("!B")[0] |
| 55 | _length = reader.read("!H")[0] |
| 56 | orig_reader = reader |
| 57 | reader = orig_reader.slice(_length - (2 + 2)) |
| 58 | obj.xid = reader.read("!L")[0] |
| 59 | return obj |
| 60 | |
| 61 | def __eq__(self, other): |
| 62 | if type(self) != type(other): return False |
| 63 | if self.type != other.type: return False |
| 64 | if self.xid != other.xid: return False |
| 65 | return True |
| 66 | |
| 67 | def pretty_print(self, q): |
| 68 | q.text("message {") |
| 69 | with q.group(): |
| 70 | with q.indent(2): |
| 71 | q.breakable() |
| 72 | q.text("xid = "); |
| 73 | if self.xid != None: |
| 74 | q.text("%#x" % self.xid) |
| 75 | else: |
| 76 | q.text('None') |
| 77 | q.breakable() |
| 78 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 79 | |
| 80 | |
| 81 | class stats_reply(message): |
| 82 | subtypes = {} |
| 83 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 84 | version = 2 |
| 85 | type = 19 |
| 86 | |
| 87 | def __init__(self, xid=None, stats_type=None, flags=None): |
| 88 | if xid != None: |
| 89 | self.xid = xid |
| 90 | else: |
| 91 | self.xid = None |
| 92 | if stats_type != None: |
| 93 | self.stats_type = stats_type |
| 94 | else: |
| 95 | self.stats_type = 0 |
| 96 | if flags != None: |
| 97 | self.flags = flags |
| 98 | else: |
| 99 | self.flags = 0 |
| 100 | return |
| 101 | |
| 102 | def pack(self): |
| 103 | packed = [] |
| 104 | packed.append(struct.pack("!B", self.version)) |
| 105 | packed.append(struct.pack("!B", self.type)) |
| 106 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 107 | packed.append(struct.pack("!L", self.xid)) |
| 108 | packed.append(struct.pack("!H", self.stats_type)) |
| 109 | packed.append(struct.pack("!H", self.flags)) |
| 110 | packed.append('\x00' * 4) |
| 111 | length = sum([len(x) for x in packed]) |
| 112 | packed[2] = struct.pack("!H", length) |
| 113 | return ''.join(packed) |
| 114 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 115 | @staticmethod |
| 116 | def unpack(reader): |
| 117 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 118 | subclass = stats_reply.subtypes.get(subtype) |
| 119 | if subclass: |
| 120 | return subclass.unpack(reader) |
| 121 | |
| 122 | obj = stats_reply() |
| 123 | _version = reader.read("!B")[0] |
| 124 | assert(_version == 2) |
| 125 | _type = reader.read("!B")[0] |
| 126 | assert(_type == 19) |
| 127 | _length = reader.read("!H")[0] |
| 128 | orig_reader = reader |
| 129 | reader = orig_reader.slice(_length - (2 + 2)) |
| 130 | obj.xid = reader.read("!L")[0] |
| 131 | obj.stats_type = reader.read("!H")[0] |
| 132 | obj.flags = reader.read("!H")[0] |
| 133 | reader.skip(4) |
| 134 | return obj |
| 135 | |
| 136 | def __eq__(self, other): |
| 137 | if type(self) != type(other): return False |
| 138 | if self.xid != other.xid: return False |
| 139 | if self.stats_type != other.stats_type: return False |
| 140 | if self.flags != other.flags: return False |
| 141 | return True |
| 142 | |
| 143 | def pretty_print(self, q): |
| 144 | q.text("stats_reply {") |
| 145 | with q.group(): |
| 146 | with q.indent(2): |
| 147 | q.breakable() |
| 148 | q.text("xid = "); |
| 149 | if self.xid != None: |
| 150 | q.text("%#x" % self.xid) |
| 151 | else: |
| 152 | q.text('None') |
| 153 | q.text(","); q.breakable() |
| 154 | q.text("flags = "); |
| 155 | q.text("%#x" % self.flags) |
| 156 | q.breakable() |
| 157 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 158 | |
| 159 | message.subtypes[19] = stats_reply |
| 160 | |
| 161 | class aggregate_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 162 | version = 2 |
| 163 | type = 19 |
| 164 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 165 | |
| 166 | def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 167 | if xid != None: |
| 168 | self.xid = xid |
| 169 | else: |
| 170 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 171 | if flags != None: |
| 172 | self.flags = flags |
| 173 | else: |
| 174 | self.flags = 0 |
| 175 | if packet_count != None: |
| 176 | self.packet_count = packet_count |
| 177 | else: |
| 178 | self.packet_count = 0 |
| 179 | if byte_count != None: |
| 180 | self.byte_count = byte_count |
| 181 | else: |
| 182 | self.byte_count = 0 |
| 183 | if flow_count != None: |
| 184 | self.flow_count = flow_count |
| 185 | else: |
| 186 | self.flow_count = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 187 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 188 | |
| 189 | def pack(self): |
| 190 | packed = [] |
| 191 | packed.append(struct.pack("!B", self.version)) |
| 192 | packed.append(struct.pack("!B", self.type)) |
| 193 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 194 | packed.append(struct.pack("!L", self.xid)) |
| 195 | packed.append(struct.pack("!H", self.stats_type)) |
| 196 | packed.append(struct.pack("!H", self.flags)) |
| 197 | packed.append('\x00' * 4) |
| 198 | packed.append(struct.pack("!Q", self.packet_count)) |
| 199 | packed.append(struct.pack("!Q", self.byte_count)) |
| 200 | packed.append(struct.pack("!L", self.flow_count)) |
| 201 | packed.append('\x00' * 4) |
| 202 | length = sum([len(x) for x in packed]) |
| 203 | packed[2] = struct.pack("!H", length) |
| 204 | return ''.join(packed) |
| 205 | |
| 206 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 207 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 208 | obj = aggregate_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 209 | _version = reader.read("!B")[0] |
| 210 | assert(_version == 2) |
| 211 | _type = reader.read("!B")[0] |
| 212 | assert(_type == 19) |
| 213 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 214 | orig_reader = reader |
| 215 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 216 | obj.xid = reader.read("!L")[0] |
| 217 | _stats_type = reader.read("!H")[0] |
| 218 | assert(_stats_type == 2) |
| 219 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 220 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 221 | obj.packet_count = reader.read("!Q")[0] |
| 222 | obj.byte_count = reader.read("!Q")[0] |
| 223 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 224 | reader.skip(4) |
| 225 | return obj |
| 226 | |
| 227 | def __eq__(self, other): |
| 228 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 229 | if self.xid != other.xid: return False |
| 230 | if self.flags != other.flags: return False |
| 231 | if self.packet_count != other.packet_count: return False |
| 232 | if self.byte_count != other.byte_count: return False |
| 233 | if self.flow_count != other.flow_count: return False |
| 234 | return True |
| 235 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 236 | def pretty_print(self, q): |
| 237 | q.text("aggregate_stats_reply {") |
| 238 | with q.group(): |
| 239 | with q.indent(2): |
| 240 | q.breakable() |
| 241 | q.text("xid = "); |
| 242 | if self.xid != None: |
| 243 | q.text("%#x" % self.xid) |
| 244 | else: |
| 245 | q.text('None') |
| 246 | q.text(","); q.breakable() |
| 247 | q.text("flags = "); |
| 248 | q.text("%#x" % self.flags) |
| 249 | q.text(","); q.breakable() |
| 250 | q.text("packet_count = "); |
| 251 | q.text("%#x" % self.packet_count) |
| 252 | q.text(","); q.breakable() |
| 253 | q.text("byte_count = "); |
| 254 | q.text("%#x" % self.byte_count) |
| 255 | q.text(","); q.breakable() |
| 256 | q.text("flow_count = "); |
| 257 | q.text("%#x" % self.flow_count) |
| 258 | q.breakable() |
| 259 | q.text('}') |
| 260 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 261 | stats_reply.subtypes[2] = aggregate_stats_reply |
| 262 | |
| 263 | class stats_request(message): |
| 264 | subtypes = {} |
| 265 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 266 | version = 2 |
| 267 | type = 18 |
| 268 | |
| 269 | def __init__(self, xid=None, stats_type=None, flags=None): |
| 270 | if xid != None: |
| 271 | self.xid = xid |
| 272 | else: |
| 273 | self.xid = None |
| 274 | if stats_type != None: |
| 275 | self.stats_type = stats_type |
| 276 | else: |
| 277 | self.stats_type = 0 |
| 278 | if flags != None: |
| 279 | self.flags = flags |
| 280 | else: |
| 281 | self.flags = 0 |
| 282 | return |
| 283 | |
| 284 | def pack(self): |
| 285 | packed = [] |
| 286 | packed.append(struct.pack("!B", self.version)) |
| 287 | packed.append(struct.pack("!B", self.type)) |
| 288 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 289 | packed.append(struct.pack("!L", self.xid)) |
| 290 | packed.append(struct.pack("!H", self.stats_type)) |
| 291 | packed.append(struct.pack("!H", self.flags)) |
| 292 | packed.append('\x00' * 4) |
| 293 | length = sum([len(x) for x in packed]) |
| 294 | packed[2] = struct.pack("!H", length) |
| 295 | return ''.join(packed) |
| 296 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 297 | @staticmethod |
| 298 | def unpack(reader): |
| 299 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 300 | subclass = stats_request.subtypes.get(subtype) |
| 301 | if subclass: |
| 302 | return subclass.unpack(reader) |
| 303 | |
| 304 | obj = stats_request() |
| 305 | _version = reader.read("!B")[0] |
| 306 | assert(_version == 2) |
| 307 | _type = reader.read("!B")[0] |
| 308 | assert(_type == 18) |
| 309 | _length = reader.read("!H")[0] |
| 310 | orig_reader = reader |
| 311 | reader = orig_reader.slice(_length - (2 + 2)) |
| 312 | obj.xid = reader.read("!L")[0] |
| 313 | obj.stats_type = reader.read("!H")[0] |
| 314 | obj.flags = reader.read("!H")[0] |
| 315 | reader.skip(4) |
| 316 | return obj |
| 317 | |
| 318 | def __eq__(self, other): |
| 319 | if type(self) != type(other): return False |
| 320 | if self.xid != other.xid: return False |
| 321 | if self.stats_type != other.stats_type: return False |
| 322 | if self.flags != other.flags: return False |
| 323 | return True |
| 324 | |
| 325 | def pretty_print(self, q): |
| 326 | q.text("stats_request {") |
| 327 | with q.group(): |
| 328 | with q.indent(2): |
| 329 | q.breakable() |
| 330 | q.text("xid = "); |
| 331 | if self.xid != None: |
| 332 | q.text("%#x" % self.xid) |
| 333 | else: |
| 334 | q.text('None') |
| 335 | q.text(","); q.breakable() |
| 336 | q.text("flags = "); |
| 337 | q.text("%#x" % self.flags) |
| 338 | q.breakable() |
| 339 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 340 | |
| 341 | message.subtypes[18] = stats_request |
| 342 | |
| 343 | class aggregate_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 344 | version = 2 |
| 345 | type = 18 |
| 346 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 347 | |
| 348 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 349 | if xid != None: |
| 350 | self.xid = xid |
| 351 | else: |
| 352 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 353 | if flags != None: |
| 354 | self.flags = flags |
| 355 | else: |
| 356 | self.flags = 0 |
| 357 | if table_id != None: |
| 358 | self.table_id = table_id |
| 359 | else: |
| 360 | self.table_id = 0 |
| 361 | if out_port != None: |
| 362 | self.out_port = out_port |
| 363 | else: |
| 364 | self.out_port = 0 |
| 365 | if out_group != None: |
| 366 | self.out_group = out_group |
| 367 | else: |
| 368 | self.out_group = 0 |
| 369 | if cookie != None: |
| 370 | self.cookie = cookie |
| 371 | else: |
| 372 | self.cookie = 0 |
| 373 | if cookie_mask != None: |
| 374 | self.cookie_mask = cookie_mask |
| 375 | else: |
| 376 | self.cookie_mask = 0 |
| 377 | if match != None: |
| 378 | self.match = match |
| 379 | else: |
| 380 | self.match = common.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 381 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 382 | |
| 383 | def pack(self): |
| 384 | packed = [] |
| 385 | packed.append(struct.pack("!B", self.version)) |
| 386 | packed.append(struct.pack("!B", self.type)) |
| 387 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 388 | packed.append(struct.pack("!L", self.xid)) |
| 389 | packed.append(struct.pack("!H", self.stats_type)) |
| 390 | packed.append(struct.pack("!H", self.flags)) |
| 391 | packed.append('\x00' * 4) |
| 392 | packed.append(struct.pack("!B", self.table_id)) |
| 393 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 394 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 395 | packed.append(struct.pack("!L", self.out_group)) |
| 396 | packed.append('\x00' * 4) |
| 397 | packed.append(struct.pack("!Q", self.cookie)) |
| 398 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 399 | packed.append(self.match.pack()) |
| 400 | length = sum([len(x) for x in packed]) |
| 401 | packed[2] = struct.pack("!H", length) |
| 402 | return ''.join(packed) |
| 403 | |
| 404 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 405 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 406 | obj = aggregate_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 407 | _version = reader.read("!B")[0] |
| 408 | assert(_version == 2) |
| 409 | _type = reader.read("!B")[0] |
| 410 | assert(_type == 18) |
| 411 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 412 | orig_reader = reader |
| 413 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 414 | obj.xid = reader.read("!L")[0] |
| 415 | _stats_type = reader.read("!H")[0] |
| 416 | assert(_stats_type == 2) |
| 417 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 418 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 419 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 420 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 421 | obj.out_port = util.unpack_port_no(reader) |
| 422 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 423 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 424 | obj.cookie = reader.read("!Q")[0] |
| 425 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 426 | obj.match = common.match.unpack(reader) |
| 427 | return obj |
| 428 | |
| 429 | def __eq__(self, other): |
| 430 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 431 | if self.xid != other.xid: return False |
| 432 | if self.flags != other.flags: return False |
| 433 | if self.table_id != other.table_id: return False |
| 434 | if self.out_port != other.out_port: return False |
| 435 | if self.out_group != other.out_group: return False |
| 436 | if self.cookie != other.cookie: return False |
| 437 | if self.cookie_mask != other.cookie_mask: return False |
| 438 | if self.match != other.match: return False |
| 439 | return True |
| 440 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 441 | def pretty_print(self, q): |
| 442 | q.text("aggregate_stats_request {") |
| 443 | with q.group(): |
| 444 | with q.indent(2): |
| 445 | q.breakable() |
| 446 | q.text("xid = "); |
| 447 | if self.xid != None: |
| 448 | q.text("%#x" % self.xid) |
| 449 | else: |
| 450 | q.text('None') |
| 451 | q.text(","); q.breakable() |
| 452 | q.text("flags = "); |
| 453 | q.text("%#x" % self.flags) |
| 454 | q.text(","); q.breakable() |
| 455 | q.text("table_id = "); |
| 456 | q.text("%#x" % self.table_id) |
| 457 | q.text(","); q.breakable() |
| 458 | q.text("out_port = "); |
| 459 | q.text(util.pretty_port(self.out_port)) |
| 460 | q.text(","); q.breakable() |
| 461 | q.text("out_group = "); |
| 462 | q.text("%#x" % self.out_group) |
| 463 | q.text(","); q.breakable() |
| 464 | q.text("cookie = "); |
| 465 | q.text("%#x" % self.cookie) |
| 466 | q.text(","); q.breakable() |
| 467 | q.text("cookie_mask = "); |
| 468 | q.text("%#x" % self.cookie_mask) |
| 469 | q.text(","); q.breakable() |
| 470 | q.text("match = "); |
| 471 | q.pp(self.match) |
| 472 | q.breakable() |
| 473 | q.text('}') |
| 474 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 475 | stats_request.subtypes[2] = aggregate_stats_request |
| 476 | |
| 477 | class error_msg(message): |
| 478 | subtypes = {} |
| 479 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 480 | version = 2 |
| 481 | type = 1 |
| 482 | |
| 483 | def __init__(self, xid=None, err_type=None): |
| 484 | if xid != None: |
| 485 | self.xid = xid |
| 486 | else: |
| 487 | self.xid = None |
| 488 | if err_type != None: |
| 489 | self.err_type = err_type |
| 490 | else: |
| 491 | self.err_type = 0 |
| 492 | return |
| 493 | |
| 494 | def pack(self): |
| 495 | packed = [] |
| 496 | packed.append(struct.pack("!B", self.version)) |
| 497 | packed.append(struct.pack("!B", self.type)) |
| 498 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 499 | packed.append(struct.pack("!L", self.xid)) |
| 500 | packed.append(struct.pack("!H", self.err_type)) |
| 501 | length = sum([len(x) for x in packed]) |
| 502 | packed[2] = struct.pack("!H", length) |
| 503 | return ''.join(packed) |
| 504 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 505 | @staticmethod |
| 506 | def unpack(reader): |
| 507 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 508 | subclass = error_msg.subtypes.get(subtype) |
| 509 | if subclass: |
| 510 | return subclass.unpack(reader) |
| 511 | |
| 512 | obj = error_msg() |
| 513 | _version = reader.read("!B")[0] |
| 514 | assert(_version == 2) |
| 515 | _type = reader.read("!B")[0] |
| 516 | assert(_type == 1) |
| 517 | _length = reader.read("!H")[0] |
| 518 | orig_reader = reader |
| 519 | reader = orig_reader.slice(_length - (2 + 2)) |
| 520 | obj.xid = reader.read("!L")[0] |
| 521 | obj.err_type = reader.read("!H")[0] |
| 522 | return obj |
| 523 | |
| 524 | def __eq__(self, other): |
| 525 | if type(self) != type(other): return False |
| 526 | if self.xid != other.xid: return False |
| 527 | if self.err_type != other.err_type: return False |
| 528 | return True |
| 529 | |
| 530 | def pretty_print(self, q): |
| 531 | q.text("error_msg {") |
| 532 | with q.group(): |
| 533 | with q.indent(2): |
| 534 | q.breakable() |
| 535 | q.text("xid = "); |
| 536 | if self.xid != None: |
| 537 | q.text("%#x" % self.xid) |
| 538 | else: |
| 539 | q.text('None') |
| 540 | q.breakable() |
| 541 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 542 | |
| 543 | message.subtypes[1] = error_msg |
| 544 | |
| 545 | class bad_action_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 546 | version = 2 |
| 547 | type = 1 |
| 548 | err_type = 2 |
| 549 | |
| 550 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 551 | if xid != None: |
| 552 | self.xid = xid |
| 553 | else: |
| 554 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 555 | if code != None: |
| 556 | self.code = code |
| 557 | else: |
| 558 | self.code = 0 |
| 559 | if data != None: |
| 560 | self.data = data |
| 561 | else: |
| 562 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 563 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 564 | |
| 565 | def pack(self): |
| 566 | packed = [] |
| 567 | packed.append(struct.pack("!B", self.version)) |
| 568 | packed.append(struct.pack("!B", self.type)) |
| 569 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 570 | packed.append(struct.pack("!L", self.xid)) |
| 571 | packed.append(struct.pack("!H", self.err_type)) |
| 572 | packed.append(struct.pack("!H", self.code)) |
| 573 | packed.append(self.data) |
| 574 | length = sum([len(x) for x in packed]) |
| 575 | packed[2] = struct.pack("!H", length) |
| 576 | return ''.join(packed) |
| 577 | |
| 578 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 579 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 580 | obj = bad_action_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 581 | _version = reader.read("!B")[0] |
| 582 | assert(_version == 2) |
| 583 | _type = reader.read("!B")[0] |
| 584 | assert(_type == 1) |
| 585 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 586 | orig_reader = reader |
| 587 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 588 | obj.xid = reader.read("!L")[0] |
| 589 | _err_type = reader.read("!H")[0] |
| 590 | assert(_err_type == 2) |
| 591 | obj.code = reader.read("!H")[0] |
| 592 | obj.data = str(reader.read_all()) |
| 593 | return obj |
| 594 | |
| 595 | def __eq__(self, other): |
| 596 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 597 | if self.xid != other.xid: return False |
| 598 | if self.code != other.code: return False |
| 599 | if self.data != other.data: return False |
| 600 | return True |
| 601 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 602 | def pretty_print(self, q): |
| 603 | q.text("bad_action_error_msg {") |
| 604 | with q.group(): |
| 605 | with q.indent(2): |
| 606 | q.breakable() |
| 607 | q.text("xid = "); |
| 608 | if self.xid != None: |
| 609 | q.text("%#x" % self.xid) |
| 610 | else: |
| 611 | q.text('None') |
| 612 | q.text(","); q.breakable() |
| 613 | q.text("code = "); |
| 614 | q.text("%#x" % self.code) |
| 615 | q.text(","); q.breakable() |
| 616 | q.text("data = "); |
| 617 | q.pp(self.data) |
| 618 | q.breakable() |
| 619 | q.text('}') |
| 620 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 621 | error_msg.subtypes[2] = bad_action_error_msg |
| 622 | |
| 623 | class bad_instruction_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 624 | version = 2 |
| 625 | type = 1 |
| 626 | err_type = 3 |
| 627 | |
| 628 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 629 | if xid != None: |
| 630 | self.xid = xid |
| 631 | else: |
| 632 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 633 | if code != None: |
| 634 | self.code = code |
| 635 | else: |
| 636 | self.code = 0 |
| 637 | if data != None: |
| 638 | self.data = data |
| 639 | else: |
| 640 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 641 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 642 | |
| 643 | def pack(self): |
| 644 | packed = [] |
| 645 | packed.append(struct.pack("!B", self.version)) |
| 646 | packed.append(struct.pack("!B", self.type)) |
| 647 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 648 | packed.append(struct.pack("!L", self.xid)) |
| 649 | packed.append(struct.pack("!H", self.err_type)) |
| 650 | packed.append(struct.pack("!H", self.code)) |
| 651 | packed.append(self.data) |
| 652 | length = sum([len(x) for x in packed]) |
| 653 | packed[2] = struct.pack("!H", length) |
| 654 | return ''.join(packed) |
| 655 | |
| 656 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 657 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 658 | obj = bad_instruction_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 659 | _version = reader.read("!B")[0] |
| 660 | assert(_version == 2) |
| 661 | _type = reader.read("!B")[0] |
| 662 | assert(_type == 1) |
| 663 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 664 | orig_reader = reader |
| 665 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 666 | obj.xid = reader.read("!L")[0] |
| 667 | _err_type = reader.read("!H")[0] |
| 668 | assert(_err_type == 3) |
| 669 | obj.code = reader.read("!H")[0] |
| 670 | obj.data = str(reader.read_all()) |
| 671 | return obj |
| 672 | |
| 673 | def __eq__(self, other): |
| 674 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 675 | if self.xid != other.xid: return False |
| 676 | if self.code != other.code: return False |
| 677 | if self.data != other.data: return False |
| 678 | return True |
| 679 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 680 | def pretty_print(self, q): |
| 681 | q.text("bad_instruction_error_msg {") |
| 682 | with q.group(): |
| 683 | with q.indent(2): |
| 684 | q.breakable() |
| 685 | q.text("xid = "); |
| 686 | if self.xid != None: |
| 687 | q.text("%#x" % self.xid) |
| 688 | else: |
| 689 | q.text('None') |
| 690 | q.text(","); q.breakable() |
| 691 | q.text("code = "); |
| 692 | q.text("%#x" % self.code) |
| 693 | q.text(","); q.breakable() |
| 694 | q.text("data = "); |
| 695 | q.pp(self.data) |
| 696 | q.breakable() |
| 697 | q.text('}') |
| 698 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 699 | error_msg.subtypes[3] = bad_instruction_error_msg |
| 700 | |
| 701 | class bad_match_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 702 | version = 2 |
| 703 | type = 1 |
| 704 | err_type = 4 |
| 705 | |
| 706 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 707 | if xid != None: |
| 708 | self.xid = xid |
| 709 | else: |
| 710 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 711 | if code != None: |
| 712 | self.code = code |
| 713 | else: |
| 714 | self.code = 0 |
| 715 | if data != None: |
| 716 | self.data = data |
| 717 | else: |
| 718 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 719 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 720 | |
| 721 | def pack(self): |
| 722 | packed = [] |
| 723 | packed.append(struct.pack("!B", self.version)) |
| 724 | packed.append(struct.pack("!B", self.type)) |
| 725 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 726 | packed.append(struct.pack("!L", self.xid)) |
| 727 | packed.append(struct.pack("!H", self.err_type)) |
| 728 | packed.append(struct.pack("!H", self.code)) |
| 729 | packed.append(self.data) |
| 730 | length = sum([len(x) for x in packed]) |
| 731 | packed[2] = struct.pack("!H", length) |
| 732 | return ''.join(packed) |
| 733 | |
| 734 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 735 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 736 | obj = bad_match_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 737 | _version = reader.read("!B")[0] |
| 738 | assert(_version == 2) |
| 739 | _type = reader.read("!B")[0] |
| 740 | assert(_type == 1) |
| 741 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 742 | orig_reader = reader |
| 743 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 744 | obj.xid = reader.read("!L")[0] |
| 745 | _err_type = reader.read("!H")[0] |
| 746 | assert(_err_type == 4) |
| 747 | obj.code = reader.read("!H")[0] |
| 748 | obj.data = str(reader.read_all()) |
| 749 | return obj |
| 750 | |
| 751 | def __eq__(self, other): |
| 752 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 753 | if self.xid != other.xid: return False |
| 754 | if self.code != other.code: return False |
| 755 | if self.data != other.data: return False |
| 756 | return True |
| 757 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 758 | def pretty_print(self, q): |
| 759 | q.text("bad_match_error_msg {") |
| 760 | with q.group(): |
| 761 | with q.indent(2): |
| 762 | q.breakable() |
| 763 | q.text("xid = "); |
| 764 | if self.xid != None: |
| 765 | q.text("%#x" % self.xid) |
| 766 | else: |
| 767 | q.text('None') |
| 768 | q.text(","); q.breakable() |
| 769 | q.text("code = "); |
| 770 | q.text("%#x" % self.code) |
| 771 | q.text(","); q.breakable() |
| 772 | q.text("data = "); |
| 773 | q.pp(self.data) |
| 774 | q.breakable() |
| 775 | q.text('}') |
| 776 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 777 | error_msg.subtypes[4] = bad_match_error_msg |
| 778 | |
| 779 | class bad_request_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 780 | version = 2 |
| 781 | type = 1 |
| 782 | err_type = 1 |
| 783 | |
| 784 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 785 | if xid != None: |
| 786 | self.xid = xid |
| 787 | else: |
| 788 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 789 | if code != None: |
| 790 | self.code = code |
| 791 | else: |
| 792 | self.code = 0 |
| 793 | if data != None: |
| 794 | self.data = data |
| 795 | else: |
| 796 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 797 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 798 | |
| 799 | def pack(self): |
| 800 | packed = [] |
| 801 | packed.append(struct.pack("!B", self.version)) |
| 802 | packed.append(struct.pack("!B", self.type)) |
| 803 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 804 | packed.append(struct.pack("!L", self.xid)) |
| 805 | packed.append(struct.pack("!H", self.err_type)) |
| 806 | packed.append(struct.pack("!H", self.code)) |
| 807 | packed.append(self.data) |
| 808 | length = sum([len(x) for x in packed]) |
| 809 | packed[2] = struct.pack("!H", length) |
| 810 | return ''.join(packed) |
| 811 | |
| 812 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 813 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 814 | obj = bad_request_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 815 | _version = reader.read("!B")[0] |
| 816 | assert(_version == 2) |
| 817 | _type = reader.read("!B")[0] |
| 818 | assert(_type == 1) |
| 819 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 820 | orig_reader = reader |
| 821 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 822 | obj.xid = reader.read("!L")[0] |
| 823 | _err_type = reader.read("!H")[0] |
| 824 | assert(_err_type == 1) |
| 825 | obj.code = reader.read("!H")[0] |
| 826 | obj.data = str(reader.read_all()) |
| 827 | return obj |
| 828 | |
| 829 | def __eq__(self, other): |
| 830 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 831 | if self.xid != other.xid: return False |
| 832 | if self.code != other.code: return False |
| 833 | if self.data != other.data: return False |
| 834 | return True |
| 835 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 836 | def pretty_print(self, q): |
| 837 | q.text("bad_request_error_msg {") |
| 838 | with q.group(): |
| 839 | with q.indent(2): |
| 840 | q.breakable() |
| 841 | q.text("xid = "); |
| 842 | if self.xid != None: |
| 843 | q.text("%#x" % self.xid) |
| 844 | else: |
| 845 | q.text('None') |
| 846 | q.text(","); q.breakable() |
| 847 | q.text("code = "); |
| 848 | q.text("%#x" % self.code) |
| 849 | q.text(","); q.breakable() |
| 850 | q.text("data = "); |
| 851 | q.pp(self.data) |
| 852 | q.breakable() |
| 853 | q.text('}') |
| 854 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 855 | error_msg.subtypes[1] = bad_request_error_msg |
| 856 | |
| 857 | class barrier_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 858 | version = 2 |
| 859 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 860 | |
| 861 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 862 | if xid != None: |
| 863 | self.xid = xid |
| 864 | else: |
| 865 | self.xid = None |
| 866 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 867 | |
| 868 | def pack(self): |
| 869 | packed = [] |
| 870 | packed.append(struct.pack("!B", self.version)) |
| 871 | packed.append(struct.pack("!B", self.type)) |
| 872 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 873 | packed.append(struct.pack("!L", self.xid)) |
| 874 | length = sum([len(x) for x in packed]) |
| 875 | packed[2] = struct.pack("!H", length) |
| 876 | return ''.join(packed) |
| 877 | |
| 878 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 879 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 880 | obj = barrier_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 881 | _version = reader.read("!B")[0] |
| 882 | assert(_version == 2) |
| 883 | _type = reader.read("!B")[0] |
| 884 | assert(_type == 21) |
| 885 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 886 | orig_reader = reader |
| 887 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 888 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 889 | return obj |
| 890 | |
| 891 | def __eq__(self, other): |
| 892 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 893 | if self.xid != other.xid: return False |
| 894 | return True |
| 895 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 896 | def pretty_print(self, q): |
| 897 | q.text("barrier_reply {") |
| 898 | with q.group(): |
| 899 | with q.indent(2): |
| 900 | q.breakable() |
| 901 | q.text("xid = "); |
| 902 | if self.xid != None: |
| 903 | q.text("%#x" % self.xid) |
| 904 | else: |
| 905 | q.text('None') |
| 906 | q.breakable() |
| 907 | q.text('}') |
| 908 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 909 | message.subtypes[21] = barrier_reply |
| 910 | |
| 911 | class barrier_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 912 | version = 2 |
| 913 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 914 | |
| 915 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 916 | if xid != None: |
| 917 | self.xid = xid |
| 918 | else: |
| 919 | self.xid = None |
| 920 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 921 | |
| 922 | def pack(self): |
| 923 | packed = [] |
| 924 | packed.append(struct.pack("!B", self.version)) |
| 925 | packed.append(struct.pack("!B", self.type)) |
| 926 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 927 | packed.append(struct.pack("!L", self.xid)) |
| 928 | length = sum([len(x) for x in packed]) |
| 929 | packed[2] = struct.pack("!H", length) |
| 930 | return ''.join(packed) |
| 931 | |
| 932 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 933 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 934 | obj = barrier_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 935 | _version = reader.read("!B")[0] |
| 936 | assert(_version == 2) |
| 937 | _type = reader.read("!B")[0] |
| 938 | assert(_type == 20) |
| 939 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 940 | orig_reader = reader |
| 941 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 942 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 943 | return obj |
| 944 | |
| 945 | def __eq__(self, other): |
| 946 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 947 | if self.xid != other.xid: return False |
| 948 | return True |
| 949 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 950 | def pretty_print(self, q): |
| 951 | q.text("barrier_request {") |
| 952 | with q.group(): |
| 953 | with q.indent(2): |
| 954 | q.breakable() |
| 955 | q.text("xid = "); |
| 956 | if self.xid != None: |
| 957 | q.text("%#x" % self.xid) |
| 958 | else: |
| 959 | q.text('None') |
| 960 | q.breakable() |
| 961 | q.text('}') |
| 962 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 963 | message.subtypes[20] = barrier_request |
| 964 | |
| 965 | class experimenter(message): |
| 966 | subtypes = {} |
| 967 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 968 | version = 2 |
| 969 | type = 4 |
| 970 | |
Harshmeet Singh | c0378a9 | 2014-07-22 17:09:36 -0700 | [diff] [blame^] | 971 | def __init__(self, xid=None, experimenter=None, data=None): |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 972 | if xid != None: |
| 973 | self.xid = xid |
| 974 | else: |
| 975 | self.xid = None |
| 976 | if experimenter != None: |
| 977 | self.experimenter = experimenter |
| 978 | else: |
| 979 | self.experimenter = 0 |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 980 | if data != None: |
| 981 | self.data = data |
| 982 | else: |
| 983 | self.data = '' |
| 984 | return |
| 985 | |
| 986 | def pack(self): |
| 987 | packed = [] |
| 988 | packed.append(struct.pack("!B", self.version)) |
| 989 | packed.append(struct.pack("!B", self.type)) |
| 990 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 991 | packed.append(struct.pack("!L", self.xid)) |
| 992 | packed.append(struct.pack("!L", self.experimenter)) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 993 | packed.append(self.data) |
| 994 | length = sum([len(x) for x in packed]) |
| 995 | packed[2] = struct.pack("!H", length) |
| 996 | return ''.join(packed) |
| 997 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 998 | @staticmethod |
| 999 | def unpack(reader): |
| 1000 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1001 | subclass = experimenter.subtypes.get(subtype) |
| 1002 | if subclass: |
| 1003 | return subclass.unpack(reader) |
| 1004 | |
| 1005 | obj = experimenter() |
| 1006 | _version = reader.read("!B")[0] |
| 1007 | assert(_version == 2) |
| 1008 | _type = reader.read("!B")[0] |
| 1009 | assert(_type == 4) |
| 1010 | _length = reader.read("!H")[0] |
| 1011 | orig_reader = reader |
| 1012 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1013 | obj.xid = reader.read("!L")[0] |
| 1014 | obj.experimenter = reader.read("!L")[0] |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1015 | obj.data = str(reader.read_all()) |
| 1016 | return obj |
| 1017 | |
| 1018 | def __eq__(self, other): |
| 1019 | if type(self) != type(other): return False |
| 1020 | if self.xid != other.xid: return False |
| 1021 | if self.experimenter != other.experimenter: return False |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1022 | if self.data != other.data: return False |
| 1023 | return True |
| 1024 | |
| 1025 | def pretty_print(self, q): |
| 1026 | q.text("experimenter {") |
| 1027 | with q.group(): |
| 1028 | with q.indent(2): |
| 1029 | q.breakable() |
| 1030 | q.text("xid = "); |
| 1031 | if self.xid != None: |
| 1032 | q.text("%#x" % self.xid) |
| 1033 | else: |
| 1034 | q.text('None') |
| 1035 | q.text(","); q.breakable() |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1036 | q.text("data = "); |
| 1037 | q.pp(self.data) |
| 1038 | q.breakable() |
| 1039 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1040 | |
| 1041 | message.subtypes[4] = experimenter |
| 1042 | |
| 1043 | class bsn_header(experimenter): |
| 1044 | subtypes = {} |
| 1045 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1046 | version = 2 |
| 1047 | type = 4 |
| 1048 | experimenter = 6035143 |
| 1049 | |
| 1050 | def __init__(self, xid=None, subtype=None): |
| 1051 | if xid != None: |
| 1052 | self.xid = xid |
| 1053 | else: |
| 1054 | self.xid = None |
| 1055 | if subtype != None: |
| 1056 | self.subtype = subtype |
| 1057 | else: |
| 1058 | self.subtype = 0 |
| 1059 | return |
| 1060 | |
| 1061 | def pack(self): |
| 1062 | packed = [] |
| 1063 | packed.append(struct.pack("!B", self.version)) |
| 1064 | packed.append(struct.pack("!B", self.type)) |
| 1065 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1066 | packed.append(struct.pack("!L", self.xid)) |
| 1067 | packed.append(struct.pack("!L", self.experimenter)) |
| 1068 | packed.append(struct.pack("!L", self.subtype)) |
| 1069 | length = sum([len(x) for x in packed]) |
| 1070 | packed[2] = struct.pack("!H", length) |
| 1071 | return ''.join(packed) |
| 1072 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1073 | @staticmethod |
| 1074 | def unpack(reader): |
| 1075 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1076 | subclass = bsn_header.subtypes.get(subtype) |
| 1077 | if subclass: |
| 1078 | return subclass.unpack(reader) |
| 1079 | |
| 1080 | obj = bsn_header() |
| 1081 | _version = reader.read("!B")[0] |
| 1082 | assert(_version == 2) |
| 1083 | _type = reader.read("!B")[0] |
| 1084 | assert(_type == 4) |
| 1085 | _length = reader.read("!H")[0] |
| 1086 | orig_reader = reader |
| 1087 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1088 | obj.xid = reader.read("!L")[0] |
| 1089 | _experimenter = reader.read("!L")[0] |
| 1090 | assert(_experimenter == 6035143) |
| 1091 | obj.subtype = reader.read("!L")[0] |
| 1092 | return obj |
| 1093 | |
| 1094 | def __eq__(self, other): |
| 1095 | if type(self) != type(other): return False |
| 1096 | if self.xid != other.xid: return False |
| 1097 | if self.subtype != other.subtype: return False |
| 1098 | return True |
| 1099 | |
| 1100 | def pretty_print(self, q): |
| 1101 | q.text("bsn_header {") |
| 1102 | with q.group(): |
| 1103 | with q.indent(2): |
| 1104 | q.breakable() |
| 1105 | q.text("xid = "); |
| 1106 | if self.xid != None: |
| 1107 | q.text("%#x" % self.xid) |
| 1108 | else: |
| 1109 | q.text('None') |
| 1110 | q.breakable() |
| 1111 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1112 | |
| 1113 | experimenter.subtypes[6035143] = bsn_header |
| 1114 | |
| 1115 | class bsn_bw_clear_data_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1116 | version = 2 |
| 1117 | type = 4 |
| 1118 | experimenter = 6035143 |
| 1119 | subtype = 22 |
| 1120 | |
| 1121 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1122 | if xid != None: |
| 1123 | self.xid = xid |
| 1124 | else: |
| 1125 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1126 | if status != None: |
| 1127 | self.status = status |
| 1128 | else: |
| 1129 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1130 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1131 | |
| 1132 | def pack(self): |
| 1133 | packed = [] |
| 1134 | packed.append(struct.pack("!B", self.version)) |
| 1135 | packed.append(struct.pack("!B", self.type)) |
| 1136 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1137 | packed.append(struct.pack("!L", self.xid)) |
| 1138 | packed.append(struct.pack("!L", self.experimenter)) |
| 1139 | packed.append(struct.pack("!L", self.subtype)) |
| 1140 | packed.append(struct.pack("!L", self.status)) |
| 1141 | length = sum([len(x) for x in packed]) |
| 1142 | packed[2] = struct.pack("!H", length) |
| 1143 | return ''.join(packed) |
| 1144 | |
| 1145 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1146 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1147 | obj = bsn_bw_clear_data_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1148 | _version = reader.read("!B")[0] |
| 1149 | assert(_version == 2) |
| 1150 | _type = reader.read("!B")[0] |
| 1151 | assert(_type == 4) |
| 1152 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1153 | orig_reader = reader |
| 1154 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1155 | obj.xid = reader.read("!L")[0] |
| 1156 | _experimenter = reader.read("!L")[0] |
| 1157 | assert(_experimenter == 6035143) |
| 1158 | _subtype = reader.read("!L")[0] |
| 1159 | assert(_subtype == 22) |
| 1160 | obj.status = reader.read("!L")[0] |
| 1161 | return obj |
| 1162 | |
| 1163 | def __eq__(self, other): |
| 1164 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1165 | if self.xid != other.xid: return False |
| 1166 | if self.status != other.status: return False |
| 1167 | return True |
| 1168 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1169 | def pretty_print(self, q): |
| 1170 | q.text("bsn_bw_clear_data_reply {") |
| 1171 | with q.group(): |
| 1172 | with q.indent(2): |
| 1173 | q.breakable() |
| 1174 | q.text("xid = "); |
| 1175 | if self.xid != None: |
| 1176 | q.text("%#x" % self.xid) |
| 1177 | else: |
| 1178 | q.text('None') |
| 1179 | q.text(","); q.breakable() |
| 1180 | q.text("status = "); |
| 1181 | q.text("%#x" % self.status) |
| 1182 | q.breakable() |
| 1183 | q.text('}') |
| 1184 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1185 | bsn_header.subtypes[22] = bsn_bw_clear_data_reply |
| 1186 | |
| 1187 | class bsn_bw_clear_data_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1188 | version = 2 |
| 1189 | type = 4 |
| 1190 | experimenter = 6035143 |
| 1191 | subtype = 21 |
| 1192 | |
| 1193 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1194 | if xid != None: |
| 1195 | self.xid = xid |
| 1196 | else: |
| 1197 | self.xid = None |
| 1198 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1199 | |
| 1200 | def pack(self): |
| 1201 | packed = [] |
| 1202 | packed.append(struct.pack("!B", self.version)) |
| 1203 | packed.append(struct.pack("!B", self.type)) |
| 1204 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1205 | packed.append(struct.pack("!L", self.xid)) |
| 1206 | packed.append(struct.pack("!L", self.experimenter)) |
| 1207 | packed.append(struct.pack("!L", self.subtype)) |
| 1208 | length = sum([len(x) for x in packed]) |
| 1209 | packed[2] = struct.pack("!H", length) |
| 1210 | return ''.join(packed) |
| 1211 | |
| 1212 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1213 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1214 | obj = bsn_bw_clear_data_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1215 | _version = reader.read("!B")[0] |
| 1216 | assert(_version == 2) |
| 1217 | _type = reader.read("!B")[0] |
| 1218 | assert(_type == 4) |
| 1219 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1220 | orig_reader = reader |
| 1221 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1222 | obj.xid = reader.read("!L")[0] |
| 1223 | _experimenter = reader.read("!L")[0] |
| 1224 | assert(_experimenter == 6035143) |
| 1225 | _subtype = reader.read("!L")[0] |
| 1226 | assert(_subtype == 21) |
| 1227 | return obj |
| 1228 | |
| 1229 | def __eq__(self, other): |
| 1230 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1231 | if self.xid != other.xid: return False |
| 1232 | return True |
| 1233 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1234 | def pretty_print(self, q): |
| 1235 | q.text("bsn_bw_clear_data_request {") |
| 1236 | with q.group(): |
| 1237 | with q.indent(2): |
| 1238 | q.breakable() |
| 1239 | q.text("xid = "); |
| 1240 | if self.xid != None: |
| 1241 | q.text("%#x" % self.xid) |
| 1242 | else: |
| 1243 | q.text('None') |
| 1244 | q.breakable() |
| 1245 | q.text('}') |
| 1246 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1247 | bsn_header.subtypes[21] = bsn_bw_clear_data_request |
| 1248 | |
| 1249 | class bsn_bw_enable_get_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1250 | version = 2 |
| 1251 | type = 4 |
| 1252 | experimenter = 6035143 |
| 1253 | subtype = 20 |
| 1254 | |
| 1255 | def __init__(self, xid=None, enabled=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1256 | if xid != None: |
| 1257 | self.xid = xid |
| 1258 | else: |
| 1259 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1260 | if enabled != None: |
| 1261 | self.enabled = enabled |
| 1262 | else: |
| 1263 | self.enabled = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1264 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1265 | |
| 1266 | def pack(self): |
| 1267 | packed = [] |
| 1268 | packed.append(struct.pack("!B", self.version)) |
| 1269 | packed.append(struct.pack("!B", self.type)) |
| 1270 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1271 | packed.append(struct.pack("!L", self.xid)) |
| 1272 | packed.append(struct.pack("!L", self.experimenter)) |
| 1273 | packed.append(struct.pack("!L", self.subtype)) |
| 1274 | packed.append(struct.pack("!L", self.enabled)) |
| 1275 | length = sum([len(x) for x in packed]) |
| 1276 | packed[2] = struct.pack("!H", length) |
| 1277 | return ''.join(packed) |
| 1278 | |
| 1279 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1280 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1281 | obj = bsn_bw_enable_get_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1282 | _version = reader.read("!B")[0] |
| 1283 | assert(_version == 2) |
| 1284 | _type = reader.read("!B")[0] |
| 1285 | assert(_type == 4) |
| 1286 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1287 | orig_reader = reader |
| 1288 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1289 | obj.xid = reader.read("!L")[0] |
| 1290 | _experimenter = reader.read("!L")[0] |
| 1291 | assert(_experimenter == 6035143) |
| 1292 | _subtype = reader.read("!L")[0] |
| 1293 | assert(_subtype == 20) |
| 1294 | obj.enabled = reader.read("!L")[0] |
| 1295 | return obj |
| 1296 | |
| 1297 | def __eq__(self, other): |
| 1298 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1299 | if self.xid != other.xid: return False |
| 1300 | if self.enabled != other.enabled: return False |
| 1301 | return True |
| 1302 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1303 | def pretty_print(self, q): |
| 1304 | q.text("bsn_bw_enable_get_reply {") |
| 1305 | with q.group(): |
| 1306 | with q.indent(2): |
| 1307 | q.breakable() |
| 1308 | q.text("xid = "); |
| 1309 | if self.xid != None: |
| 1310 | q.text("%#x" % self.xid) |
| 1311 | else: |
| 1312 | q.text('None') |
| 1313 | q.text(","); q.breakable() |
| 1314 | q.text("enabled = "); |
| 1315 | q.text("%#x" % self.enabled) |
| 1316 | q.breakable() |
| 1317 | q.text('}') |
| 1318 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1319 | bsn_header.subtypes[20] = bsn_bw_enable_get_reply |
| 1320 | |
| 1321 | class bsn_bw_enable_get_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1322 | version = 2 |
| 1323 | type = 4 |
| 1324 | experimenter = 6035143 |
| 1325 | subtype = 19 |
| 1326 | |
| 1327 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1328 | if xid != None: |
| 1329 | self.xid = xid |
| 1330 | else: |
| 1331 | self.xid = None |
| 1332 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1333 | |
| 1334 | def pack(self): |
| 1335 | packed = [] |
| 1336 | packed.append(struct.pack("!B", self.version)) |
| 1337 | packed.append(struct.pack("!B", self.type)) |
| 1338 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1339 | packed.append(struct.pack("!L", self.xid)) |
| 1340 | packed.append(struct.pack("!L", self.experimenter)) |
| 1341 | packed.append(struct.pack("!L", self.subtype)) |
| 1342 | length = sum([len(x) for x in packed]) |
| 1343 | packed[2] = struct.pack("!H", length) |
| 1344 | return ''.join(packed) |
| 1345 | |
| 1346 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1347 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1348 | obj = bsn_bw_enable_get_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1349 | _version = reader.read("!B")[0] |
| 1350 | assert(_version == 2) |
| 1351 | _type = reader.read("!B")[0] |
| 1352 | assert(_type == 4) |
| 1353 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1354 | orig_reader = reader |
| 1355 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1356 | obj.xid = reader.read("!L")[0] |
| 1357 | _experimenter = reader.read("!L")[0] |
| 1358 | assert(_experimenter == 6035143) |
| 1359 | _subtype = reader.read("!L")[0] |
| 1360 | assert(_subtype == 19) |
| 1361 | return obj |
| 1362 | |
| 1363 | def __eq__(self, other): |
| 1364 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1365 | if self.xid != other.xid: return False |
| 1366 | return True |
| 1367 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1368 | def pretty_print(self, q): |
| 1369 | q.text("bsn_bw_enable_get_request {") |
| 1370 | with q.group(): |
| 1371 | with q.indent(2): |
| 1372 | q.breakable() |
| 1373 | q.text("xid = "); |
| 1374 | if self.xid != None: |
| 1375 | q.text("%#x" % self.xid) |
| 1376 | else: |
| 1377 | q.text('None') |
| 1378 | q.breakable() |
| 1379 | q.text('}') |
| 1380 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1381 | bsn_header.subtypes[19] = bsn_bw_enable_get_request |
| 1382 | |
| 1383 | class bsn_bw_enable_set_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1384 | version = 2 |
| 1385 | type = 4 |
| 1386 | experimenter = 6035143 |
| 1387 | subtype = 23 |
| 1388 | |
| 1389 | def __init__(self, xid=None, enable=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1390 | if xid != None: |
| 1391 | self.xid = xid |
| 1392 | else: |
| 1393 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1394 | if enable != None: |
| 1395 | self.enable = enable |
| 1396 | else: |
| 1397 | self.enable = 0 |
| 1398 | if status != None: |
| 1399 | self.status = status |
| 1400 | else: |
| 1401 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1402 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1403 | |
| 1404 | def pack(self): |
| 1405 | packed = [] |
| 1406 | packed.append(struct.pack("!B", self.version)) |
| 1407 | packed.append(struct.pack("!B", self.type)) |
| 1408 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1409 | packed.append(struct.pack("!L", self.xid)) |
| 1410 | packed.append(struct.pack("!L", self.experimenter)) |
| 1411 | packed.append(struct.pack("!L", self.subtype)) |
| 1412 | packed.append(struct.pack("!L", self.enable)) |
| 1413 | packed.append(struct.pack("!L", self.status)) |
| 1414 | length = sum([len(x) for x in packed]) |
| 1415 | packed[2] = struct.pack("!H", length) |
| 1416 | return ''.join(packed) |
| 1417 | |
| 1418 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1419 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1420 | obj = bsn_bw_enable_set_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1421 | _version = reader.read("!B")[0] |
| 1422 | assert(_version == 2) |
| 1423 | _type = reader.read("!B")[0] |
| 1424 | assert(_type == 4) |
| 1425 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1426 | orig_reader = reader |
| 1427 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1428 | obj.xid = reader.read("!L")[0] |
| 1429 | _experimenter = reader.read("!L")[0] |
| 1430 | assert(_experimenter == 6035143) |
| 1431 | _subtype = reader.read("!L")[0] |
| 1432 | assert(_subtype == 23) |
| 1433 | obj.enable = reader.read("!L")[0] |
| 1434 | obj.status = reader.read("!L")[0] |
| 1435 | return obj |
| 1436 | |
| 1437 | def __eq__(self, other): |
| 1438 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1439 | if self.xid != other.xid: return False |
| 1440 | if self.enable != other.enable: return False |
| 1441 | if self.status != other.status: return False |
| 1442 | return True |
| 1443 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1444 | def pretty_print(self, q): |
| 1445 | q.text("bsn_bw_enable_set_reply {") |
| 1446 | with q.group(): |
| 1447 | with q.indent(2): |
| 1448 | q.breakable() |
| 1449 | q.text("xid = "); |
| 1450 | if self.xid != None: |
| 1451 | q.text("%#x" % self.xid) |
| 1452 | else: |
| 1453 | q.text('None') |
| 1454 | q.text(","); q.breakable() |
| 1455 | q.text("enable = "); |
| 1456 | q.text("%#x" % self.enable) |
| 1457 | q.text(","); q.breakable() |
| 1458 | q.text("status = "); |
| 1459 | q.text("%#x" % self.status) |
| 1460 | q.breakable() |
| 1461 | q.text('}') |
| 1462 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1463 | bsn_header.subtypes[23] = bsn_bw_enable_set_reply |
| 1464 | |
| 1465 | class bsn_bw_enable_set_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1466 | version = 2 |
| 1467 | type = 4 |
| 1468 | experimenter = 6035143 |
| 1469 | subtype = 18 |
| 1470 | |
| 1471 | def __init__(self, xid=None, enable=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1472 | if xid != None: |
| 1473 | self.xid = xid |
| 1474 | else: |
| 1475 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1476 | if enable != None: |
| 1477 | self.enable = enable |
| 1478 | else: |
| 1479 | self.enable = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1480 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1481 | |
| 1482 | def pack(self): |
| 1483 | packed = [] |
| 1484 | packed.append(struct.pack("!B", self.version)) |
| 1485 | packed.append(struct.pack("!B", self.type)) |
| 1486 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1487 | packed.append(struct.pack("!L", self.xid)) |
| 1488 | packed.append(struct.pack("!L", self.experimenter)) |
| 1489 | packed.append(struct.pack("!L", self.subtype)) |
| 1490 | packed.append(struct.pack("!L", self.enable)) |
| 1491 | length = sum([len(x) for x in packed]) |
| 1492 | packed[2] = struct.pack("!H", length) |
| 1493 | return ''.join(packed) |
| 1494 | |
| 1495 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1496 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1497 | obj = bsn_bw_enable_set_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1498 | _version = reader.read("!B")[0] |
| 1499 | assert(_version == 2) |
| 1500 | _type = reader.read("!B")[0] |
| 1501 | assert(_type == 4) |
| 1502 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1503 | orig_reader = reader |
| 1504 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1505 | obj.xid = reader.read("!L")[0] |
| 1506 | _experimenter = reader.read("!L")[0] |
| 1507 | assert(_experimenter == 6035143) |
| 1508 | _subtype = reader.read("!L")[0] |
| 1509 | assert(_subtype == 18) |
| 1510 | obj.enable = reader.read("!L")[0] |
| 1511 | return obj |
| 1512 | |
| 1513 | def __eq__(self, other): |
| 1514 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1515 | if self.xid != other.xid: return False |
| 1516 | if self.enable != other.enable: return False |
| 1517 | return True |
| 1518 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1519 | def pretty_print(self, q): |
| 1520 | q.text("bsn_bw_enable_set_request {") |
| 1521 | with q.group(): |
| 1522 | with q.indent(2): |
| 1523 | q.breakable() |
| 1524 | q.text("xid = "); |
| 1525 | if self.xid != None: |
| 1526 | q.text("%#x" % self.xid) |
| 1527 | else: |
| 1528 | q.text('None') |
| 1529 | q.text(","); q.breakable() |
| 1530 | q.text("enable = "); |
| 1531 | q.text("%#x" % self.enable) |
| 1532 | q.breakable() |
| 1533 | q.text('}') |
| 1534 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1535 | bsn_header.subtypes[18] = bsn_bw_enable_set_request |
| 1536 | |
| 1537 | class bsn_get_interfaces_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1538 | version = 2 |
| 1539 | type = 4 |
| 1540 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1541 | subtype = 10 |
| 1542 | |
| 1543 | def __init__(self, xid=None, interfaces=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1544 | if xid != None: |
| 1545 | self.xid = xid |
| 1546 | else: |
| 1547 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1548 | if interfaces != None: |
| 1549 | self.interfaces = interfaces |
| 1550 | else: |
| 1551 | self.interfaces = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1552 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1553 | |
| 1554 | def pack(self): |
| 1555 | packed = [] |
| 1556 | packed.append(struct.pack("!B", self.version)) |
| 1557 | packed.append(struct.pack("!B", self.type)) |
| 1558 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1559 | packed.append(struct.pack("!L", self.xid)) |
| 1560 | packed.append(struct.pack("!L", self.experimenter)) |
| 1561 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1562 | packed.append(loxi.generic_util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1563 | length = sum([len(x) for x in packed]) |
| 1564 | packed[2] = struct.pack("!H", length) |
| 1565 | return ''.join(packed) |
| 1566 | |
| 1567 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1568 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1569 | obj = bsn_get_interfaces_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1570 | _version = reader.read("!B")[0] |
| 1571 | assert(_version == 2) |
| 1572 | _type = reader.read("!B")[0] |
| 1573 | assert(_type == 4) |
| 1574 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1575 | orig_reader = reader |
| 1576 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1577 | obj.xid = reader.read("!L")[0] |
| 1578 | _experimenter = reader.read("!L")[0] |
| 1579 | assert(_experimenter == 6035143) |
| 1580 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1581 | assert(_subtype == 10) |
| 1582 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
| 1583 | return obj |
| 1584 | |
| 1585 | def __eq__(self, other): |
| 1586 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1587 | if self.xid != other.xid: return False |
| 1588 | if self.interfaces != other.interfaces: return False |
| 1589 | return True |
| 1590 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1591 | def pretty_print(self, q): |
| 1592 | q.text("bsn_get_interfaces_reply {") |
| 1593 | with q.group(): |
| 1594 | with q.indent(2): |
| 1595 | q.breakable() |
| 1596 | q.text("xid = "); |
| 1597 | if self.xid != None: |
| 1598 | q.text("%#x" % self.xid) |
| 1599 | else: |
| 1600 | q.text('None') |
| 1601 | q.text(","); q.breakable() |
| 1602 | q.text("interfaces = "); |
| 1603 | q.pp(self.interfaces) |
| 1604 | q.breakable() |
| 1605 | q.text('}') |
| 1606 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1607 | bsn_header.subtypes[10] = bsn_get_interfaces_reply |
| 1608 | |
| 1609 | class bsn_get_interfaces_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1610 | version = 2 |
| 1611 | type = 4 |
| 1612 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1613 | subtype = 9 |
| 1614 | |
| 1615 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1616 | if xid != None: |
| 1617 | self.xid = xid |
| 1618 | else: |
| 1619 | self.xid = None |
| 1620 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1621 | |
| 1622 | def pack(self): |
| 1623 | packed = [] |
| 1624 | packed.append(struct.pack("!B", self.version)) |
| 1625 | packed.append(struct.pack("!B", self.type)) |
| 1626 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1627 | packed.append(struct.pack("!L", self.xid)) |
| 1628 | packed.append(struct.pack("!L", self.experimenter)) |
| 1629 | packed.append(struct.pack("!L", self.subtype)) |
| 1630 | length = sum([len(x) for x in packed]) |
| 1631 | packed[2] = struct.pack("!H", length) |
| 1632 | return ''.join(packed) |
| 1633 | |
| 1634 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1635 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1636 | obj = bsn_get_interfaces_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1637 | _version = reader.read("!B")[0] |
| 1638 | assert(_version == 2) |
| 1639 | _type = reader.read("!B")[0] |
| 1640 | assert(_type == 4) |
| 1641 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1642 | orig_reader = reader |
| 1643 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1644 | obj.xid = reader.read("!L")[0] |
| 1645 | _experimenter = reader.read("!L")[0] |
| 1646 | assert(_experimenter == 6035143) |
| 1647 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1648 | assert(_subtype == 9) |
| 1649 | return obj |
| 1650 | |
| 1651 | def __eq__(self, other): |
| 1652 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1653 | if self.xid != other.xid: return False |
| 1654 | return True |
| 1655 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1656 | def pretty_print(self, q): |
| 1657 | q.text("bsn_get_interfaces_request {") |
| 1658 | with q.group(): |
| 1659 | with q.indent(2): |
| 1660 | q.breakable() |
| 1661 | q.text("xid = "); |
| 1662 | if self.xid != None: |
| 1663 | q.text("%#x" % self.xid) |
| 1664 | else: |
| 1665 | q.text('None') |
| 1666 | q.breakable() |
| 1667 | q.text('}') |
| 1668 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1669 | bsn_header.subtypes[9] = bsn_get_interfaces_request |
| 1670 | |
| 1671 | class bsn_get_mirroring_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1672 | version = 2 |
| 1673 | type = 4 |
| 1674 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1675 | subtype = 5 |
| 1676 | |
| 1677 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1678 | if xid != None: |
| 1679 | self.xid = xid |
| 1680 | else: |
| 1681 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1682 | if report_mirror_ports != None: |
| 1683 | self.report_mirror_ports = report_mirror_ports |
| 1684 | else: |
| 1685 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1686 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1687 | |
| 1688 | def pack(self): |
| 1689 | packed = [] |
| 1690 | packed.append(struct.pack("!B", self.version)) |
| 1691 | packed.append(struct.pack("!B", self.type)) |
| 1692 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1693 | packed.append(struct.pack("!L", self.xid)) |
| 1694 | packed.append(struct.pack("!L", self.experimenter)) |
| 1695 | packed.append(struct.pack("!L", self.subtype)) |
| 1696 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1697 | packed.append('\x00' * 3) |
| 1698 | length = sum([len(x) for x in packed]) |
| 1699 | packed[2] = struct.pack("!H", length) |
| 1700 | return ''.join(packed) |
| 1701 | |
| 1702 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1703 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1704 | obj = bsn_get_mirroring_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1705 | _version = reader.read("!B")[0] |
| 1706 | assert(_version == 2) |
| 1707 | _type = reader.read("!B")[0] |
| 1708 | assert(_type == 4) |
| 1709 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1710 | orig_reader = reader |
| 1711 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1712 | obj.xid = reader.read("!L")[0] |
| 1713 | _experimenter = reader.read("!L")[0] |
| 1714 | assert(_experimenter == 6035143) |
| 1715 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1716 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1717 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1718 | reader.skip(3) |
| 1719 | return obj |
| 1720 | |
| 1721 | def __eq__(self, other): |
| 1722 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1723 | if self.xid != other.xid: return False |
| 1724 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1725 | return True |
| 1726 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1727 | def pretty_print(self, q): |
| 1728 | q.text("bsn_get_mirroring_reply {") |
| 1729 | with q.group(): |
| 1730 | with q.indent(2): |
| 1731 | q.breakable() |
| 1732 | q.text("xid = "); |
| 1733 | if self.xid != None: |
| 1734 | q.text("%#x" % self.xid) |
| 1735 | else: |
| 1736 | q.text('None') |
| 1737 | q.text(","); q.breakable() |
| 1738 | q.text("report_mirror_ports = "); |
| 1739 | q.text("%#x" % self.report_mirror_ports) |
| 1740 | q.breakable() |
| 1741 | q.text('}') |
| 1742 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1743 | bsn_header.subtypes[5] = bsn_get_mirroring_reply |
| 1744 | |
| 1745 | class bsn_get_mirroring_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1746 | version = 2 |
| 1747 | type = 4 |
| 1748 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1749 | subtype = 4 |
| 1750 | |
| 1751 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1752 | if xid != None: |
| 1753 | self.xid = xid |
| 1754 | else: |
| 1755 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1756 | if report_mirror_ports != None: |
| 1757 | self.report_mirror_ports = report_mirror_ports |
| 1758 | else: |
| 1759 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1760 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1761 | |
| 1762 | def pack(self): |
| 1763 | packed = [] |
| 1764 | packed.append(struct.pack("!B", self.version)) |
| 1765 | packed.append(struct.pack("!B", self.type)) |
| 1766 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1767 | packed.append(struct.pack("!L", self.xid)) |
| 1768 | packed.append(struct.pack("!L", self.experimenter)) |
| 1769 | packed.append(struct.pack("!L", self.subtype)) |
| 1770 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1771 | packed.append('\x00' * 3) |
| 1772 | length = sum([len(x) for x in packed]) |
| 1773 | packed[2] = struct.pack("!H", length) |
| 1774 | return ''.join(packed) |
| 1775 | |
| 1776 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1777 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1778 | obj = bsn_get_mirroring_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1779 | _version = reader.read("!B")[0] |
| 1780 | assert(_version == 2) |
| 1781 | _type = reader.read("!B")[0] |
| 1782 | assert(_type == 4) |
| 1783 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1784 | orig_reader = reader |
| 1785 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1786 | obj.xid = reader.read("!L")[0] |
| 1787 | _experimenter = reader.read("!L")[0] |
| 1788 | assert(_experimenter == 6035143) |
| 1789 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1790 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1791 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1792 | reader.skip(3) |
| 1793 | return obj |
| 1794 | |
| 1795 | def __eq__(self, other): |
| 1796 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1797 | if self.xid != other.xid: return False |
| 1798 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1799 | return True |
| 1800 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1801 | def pretty_print(self, q): |
| 1802 | q.text("bsn_get_mirroring_request {") |
| 1803 | with q.group(): |
| 1804 | with q.indent(2): |
| 1805 | q.breakable() |
| 1806 | q.text("xid = "); |
| 1807 | if self.xid != None: |
| 1808 | q.text("%#x" % self.xid) |
| 1809 | else: |
| 1810 | q.text('None') |
| 1811 | q.text(","); q.breakable() |
| 1812 | q.text("report_mirror_ports = "); |
| 1813 | q.text("%#x" % self.report_mirror_ports) |
| 1814 | q.breakable() |
| 1815 | q.text('}') |
| 1816 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1817 | bsn_header.subtypes[4] = bsn_get_mirroring_request |
| 1818 | |
| 1819 | class bsn_pdu_rx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1820 | version = 2 |
| 1821 | type = 4 |
| 1822 | experimenter = 6035143 |
| 1823 | subtype = 34 |
| 1824 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1825 | def __init__(self, xid=None, status=None, port_no=None, slot_num=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1826 | if xid != None: |
| 1827 | self.xid = xid |
| 1828 | else: |
| 1829 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1830 | if status != None: |
| 1831 | self.status = status |
| 1832 | else: |
| 1833 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1834 | if port_no != None: |
| 1835 | self.port_no = port_no |
| 1836 | else: |
| 1837 | self.port_no = 0 |
| 1838 | if slot_num != None: |
| 1839 | self.slot_num = slot_num |
| 1840 | else: |
| 1841 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1842 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1843 | |
| 1844 | def pack(self): |
| 1845 | packed = [] |
| 1846 | packed.append(struct.pack("!B", self.version)) |
| 1847 | packed.append(struct.pack("!B", self.type)) |
| 1848 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1849 | packed.append(struct.pack("!L", self.xid)) |
| 1850 | packed.append(struct.pack("!L", self.experimenter)) |
| 1851 | packed.append(struct.pack("!L", self.subtype)) |
| 1852 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1853 | packed.append(util.pack_port_no(self.port_no)) |
| 1854 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1855 | length = sum([len(x) for x in packed]) |
| 1856 | packed[2] = struct.pack("!H", length) |
| 1857 | return ''.join(packed) |
| 1858 | |
| 1859 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1860 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1861 | obj = bsn_pdu_rx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1862 | _version = reader.read("!B")[0] |
| 1863 | assert(_version == 2) |
| 1864 | _type = reader.read("!B")[0] |
| 1865 | assert(_type == 4) |
| 1866 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1867 | orig_reader = reader |
| 1868 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1869 | obj.xid = reader.read("!L")[0] |
| 1870 | _experimenter = reader.read("!L")[0] |
| 1871 | assert(_experimenter == 6035143) |
| 1872 | _subtype = reader.read("!L")[0] |
| 1873 | assert(_subtype == 34) |
| 1874 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1875 | obj.port_no = util.unpack_port_no(reader) |
| 1876 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1877 | return obj |
| 1878 | |
| 1879 | def __eq__(self, other): |
| 1880 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1881 | if self.xid != other.xid: return False |
| 1882 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1883 | if self.port_no != other.port_no: return False |
| 1884 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1885 | return True |
| 1886 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1887 | def pretty_print(self, q): |
| 1888 | q.text("bsn_pdu_rx_reply {") |
| 1889 | with q.group(): |
| 1890 | with q.indent(2): |
| 1891 | q.breakable() |
| 1892 | q.text("xid = "); |
| 1893 | if self.xid != None: |
| 1894 | q.text("%#x" % self.xid) |
| 1895 | else: |
| 1896 | q.text('None') |
| 1897 | q.text(","); q.breakable() |
| 1898 | q.text("status = "); |
| 1899 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1900 | q.text(","); q.breakable() |
| 1901 | q.text("port_no = "); |
| 1902 | q.text(util.pretty_port(self.port_no)) |
| 1903 | q.text(","); q.breakable() |
| 1904 | q.text("slot_num = "); |
| 1905 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1906 | q.breakable() |
| 1907 | q.text('}') |
| 1908 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1909 | bsn_header.subtypes[34] = bsn_pdu_rx_reply |
| 1910 | |
| 1911 | class bsn_pdu_rx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1912 | version = 2 |
| 1913 | type = 4 |
| 1914 | experimenter = 6035143 |
| 1915 | subtype = 33 |
| 1916 | |
| 1917 | def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1918 | if xid != None: |
| 1919 | self.xid = xid |
| 1920 | else: |
| 1921 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1922 | if timeout_ms != None: |
| 1923 | self.timeout_ms = timeout_ms |
| 1924 | else: |
| 1925 | self.timeout_ms = 0 |
| 1926 | if port_no != None: |
| 1927 | self.port_no = port_no |
| 1928 | else: |
| 1929 | self.port_no = 0 |
| 1930 | if slot_num != None: |
| 1931 | self.slot_num = slot_num |
| 1932 | else: |
| 1933 | self.slot_num = 0 |
| 1934 | if data != None: |
| 1935 | self.data = data |
| 1936 | else: |
| 1937 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1938 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1939 | |
| 1940 | def pack(self): |
| 1941 | packed = [] |
| 1942 | packed.append(struct.pack("!B", self.version)) |
| 1943 | packed.append(struct.pack("!B", self.type)) |
| 1944 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1945 | packed.append(struct.pack("!L", self.xid)) |
| 1946 | packed.append(struct.pack("!L", self.experimenter)) |
| 1947 | packed.append(struct.pack("!L", self.subtype)) |
| 1948 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 1949 | packed.append(util.pack_port_no(self.port_no)) |
| 1950 | packed.append(struct.pack("!B", self.slot_num)) |
| 1951 | packed.append('\x00' * 3) |
| 1952 | packed.append(self.data) |
| 1953 | length = sum([len(x) for x in packed]) |
| 1954 | packed[2] = struct.pack("!H", length) |
| 1955 | return ''.join(packed) |
| 1956 | |
| 1957 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1958 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1959 | obj = bsn_pdu_rx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1960 | _version = reader.read("!B")[0] |
| 1961 | assert(_version == 2) |
| 1962 | _type = reader.read("!B")[0] |
| 1963 | assert(_type == 4) |
| 1964 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1965 | orig_reader = reader |
| 1966 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1967 | obj.xid = reader.read("!L")[0] |
| 1968 | _experimenter = reader.read("!L")[0] |
| 1969 | assert(_experimenter == 6035143) |
| 1970 | _subtype = reader.read("!L")[0] |
| 1971 | assert(_subtype == 33) |
| 1972 | obj.timeout_ms = reader.read("!L")[0] |
| 1973 | obj.port_no = util.unpack_port_no(reader) |
| 1974 | obj.slot_num = reader.read("!B")[0] |
| 1975 | reader.skip(3) |
| 1976 | obj.data = str(reader.read_all()) |
| 1977 | return obj |
| 1978 | |
| 1979 | def __eq__(self, other): |
| 1980 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1981 | if self.xid != other.xid: return False |
| 1982 | if self.timeout_ms != other.timeout_ms: return False |
| 1983 | if self.port_no != other.port_no: return False |
| 1984 | if self.slot_num != other.slot_num: return False |
| 1985 | if self.data != other.data: return False |
| 1986 | return True |
| 1987 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1988 | def pretty_print(self, q): |
| 1989 | q.text("bsn_pdu_rx_request {") |
| 1990 | with q.group(): |
| 1991 | with q.indent(2): |
| 1992 | q.breakable() |
| 1993 | q.text("xid = "); |
| 1994 | if self.xid != None: |
| 1995 | q.text("%#x" % self.xid) |
| 1996 | else: |
| 1997 | q.text('None') |
| 1998 | q.text(","); q.breakable() |
| 1999 | q.text("timeout_ms = "); |
| 2000 | q.text("%#x" % self.timeout_ms) |
| 2001 | q.text(","); q.breakable() |
| 2002 | q.text("port_no = "); |
| 2003 | q.text(util.pretty_port(self.port_no)) |
| 2004 | q.text(","); q.breakable() |
| 2005 | q.text("slot_num = "); |
| 2006 | q.text("%#x" % self.slot_num) |
| 2007 | q.text(","); q.breakable() |
| 2008 | q.text("data = "); |
| 2009 | q.pp(self.data) |
| 2010 | q.breakable() |
| 2011 | q.text('}') |
| 2012 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2013 | bsn_header.subtypes[33] = bsn_pdu_rx_request |
| 2014 | |
| 2015 | class bsn_pdu_rx_timeout(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2016 | version = 2 |
| 2017 | type = 4 |
| 2018 | experimenter = 6035143 |
| 2019 | subtype = 35 |
| 2020 | |
| 2021 | def __init__(self, xid=None, port_no=None, slot_num=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2022 | if xid != None: |
| 2023 | self.xid = xid |
| 2024 | else: |
| 2025 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2026 | if port_no != None: |
| 2027 | self.port_no = port_no |
| 2028 | else: |
| 2029 | self.port_no = 0 |
| 2030 | if slot_num != None: |
| 2031 | self.slot_num = slot_num |
| 2032 | else: |
| 2033 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2034 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2035 | |
| 2036 | def pack(self): |
| 2037 | packed = [] |
| 2038 | packed.append(struct.pack("!B", self.version)) |
| 2039 | packed.append(struct.pack("!B", self.type)) |
| 2040 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2041 | packed.append(struct.pack("!L", self.xid)) |
| 2042 | packed.append(struct.pack("!L", self.experimenter)) |
| 2043 | packed.append(struct.pack("!L", self.subtype)) |
| 2044 | packed.append(util.pack_port_no(self.port_no)) |
| 2045 | packed.append(struct.pack("!B", self.slot_num)) |
| 2046 | length = sum([len(x) for x in packed]) |
| 2047 | packed[2] = struct.pack("!H", length) |
| 2048 | return ''.join(packed) |
| 2049 | |
| 2050 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2051 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2052 | obj = bsn_pdu_rx_timeout() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2053 | _version = reader.read("!B")[0] |
| 2054 | assert(_version == 2) |
| 2055 | _type = reader.read("!B")[0] |
| 2056 | assert(_type == 4) |
| 2057 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2058 | orig_reader = reader |
| 2059 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2060 | obj.xid = reader.read("!L")[0] |
| 2061 | _experimenter = reader.read("!L")[0] |
| 2062 | assert(_experimenter == 6035143) |
| 2063 | _subtype = reader.read("!L")[0] |
| 2064 | assert(_subtype == 35) |
| 2065 | obj.port_no = util.unpack_port_no(reader) |
| 2066 | obj.slot_num = reader.read("!B")[0] |
| 2067 | return obj |
| 2068 | |
| 2069 | def __eq__(self, other): |
| 2070 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2071 | if self.xid != other.xid: return False |
| 2072 | if self.port_no != other.port_no: return False |
| 2073 | if self.slot_num != other.slot_num: return False |
| 2074 | return True |
| 2075 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2076 | def pretty_print(self, q): |
| 2077 | q.text("bsn_pdu_rx_timeout {") |
| 2078 | with q.group(): |
| 2079 | with q.indent(2): |
| 2080 | q.breakable() |
| 2081 | q.text("xid = "); |
| 2082 | if self.xid != None: |
| 2083 | q.text("%#x" % self.xid) |
| 2084 | else: |
| 2085 | q.text('None') |
| 2086 | q.text(","); q.breakable() |
| 2087 | q.text("port_no = "); |
| 2088 | q.text(util.pretty_port(self.port_no)) |
| 2089 | q.text(","); q.breakable() |
| 2090 | q.text("slot_num = "); |
| 2091 | q.text("%#x" % self.slot_num) |
| 2092 | q.breakable() |
| 2093 | q.text('}') |
| 2094 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2095 | bsn_header.subtypes[35] = bsn_pdu_rx_timeout |
| 2096 | |
| 2097 | class bsn_pdu_tx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2098 | version = 2 |
| 2099 | type = 4 |
| 2100 | experimenter = 6035143 |
| 2101 | subtype = 32 |
| 2102 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2103 | def __init__(self, xid=None, status=None, port_no=None, slot_num=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2104 | if xid != None: |
| 2105 | self.xid = xid |
| 2106 | else: |
| 2107 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2108 | if status != None: |
| 2109 | self.status = status |
| 2110 | else: |
| 2111 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2112 | if port_no != None: |
| 2113 | self.port_no = port_no |
| 2114 | else: |
| 2115 | self.port_no = 0 |
| 2116 | if slot_num != None: |
| 2117 | self.slot_num = slot_num |
| 2118 | else: |
| 2119 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2120 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2121 | |
| 2122 | def pack(self): |
| 2123 | packed = [] |
| 2124 | packed.append(struct.pack("!B", self.version)) |
| 2125 | packed.append(struct.pack("!B", self.type)) |
| 2126 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2127 | packed.append(struct.pack("!L", self.xid)) |
| 2128 | packed.append(struct.pack("!L", self.experimenter)) |
| 2129 | packed.append(struct.pack("!L", self.subtype)) |
| 2130 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2131 | packed.append(util.pack_port_no(self.port_no)) |
| 2132 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2133 | length = sum([len(x) for x in packed]) |
| 2134 | packed[2] = struct.pack("!H", length) |
| 2135 | return ''.join(packed) |
| 2136 | |
| 2137 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2138 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2139 | obj = bsn_pdu_tx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2140 | _version = reader.read("!B")[0] |
| 2141 | assert(_version == 2) |
| 2142 | _type = reader.read("!B")[0] |
| 2143 | assert(_type == 4) |
| 2144 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2145 | orig_reader = reader |
| 2146 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2147 | obj.xid = reader.read("!L")[0] |
| 2148 | _experimenter = reader.read("!L")[0] |
| 2149 | assert(_experimenter == 6035143) |
| 2150 | _subtype = reader.read("!L")[0] |
| 2151 | assert(_subtype == 32) |
| 2152 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2153 | obj.port_no = util.unpack_port_no(reader) |
| 2154 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2155 | return obj |
| 2156 | |
| 2157 | def __eq__(self, other): |
| 2158 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2159 | if self.xid != other.xid: return False |
| 2160 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2161 | if self.port_no != other.port_no: return False |
| 2162 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2163 | return True |
| 2164 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2165 | def pretty_print(self, q): |
| 2166 | q.text("bsn_pdu_tx_reply {") |
| 2167 | with q.group(): |
| 2168 | with q.indent(2): |
| 2169 | q.breakable() |
| 2170 | q.text("xid = "); |
| 2171 | if self.xid != None: |
| 2172 | q.text("%#x" % self.xid) |
| 2173 | else: |
| 2174 | q.text('None') |
| 2175 | q.text(","); q.breakable() |
| 2176 | q.text("status = "); |
| 2177 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2178 | q.text(","); q.breakable() |
| 2179 | q.text("port_no = "); |
| 2180 | q.text(util.pretty_port(self.port_no)) |
| 2181 | q.text(","); q.breakable() |
| 2182 | q.text("slot_num = "); |
| 2183 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2184 | q.breakable() |
| 2185 | q.text('}') |
| 2186 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2187 | bsn_header.subtypes[32] = bsn_pdu_tx_reply |
| 2188 | |
| 2189 | class bsn_pdu_tx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2190 | version = 2 |
| 2191 | type = 4 |
| 2192 | experimenter = 6035143 |
| 2193 | subtype = 31 |
| 2194 | |
| 2195 | def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2196 | if xid != None: |
| 2197 | self.xid = xid |
| 2198 | else: |
| 2199 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2200 | if tx_interval_ms != None: |
| 2201 | self.tx_interval_ms = tx_interval_ms |
| 2202 | else: |
| 2203 | self.tx_interval_ms = 0 |
| 2204 | if port_no != None: |
| 2205 | self.port_no = port_no |
| 2206 | else: |
| 2207 | self.port_no = 0 |
| 2208 | if slot_num != None: |
| 2209 | self.slot_num = slot_num |
| 2210 | else: |
| 2211 | self.slot_num = 0 |
| 2212 | if data != None: |
| 2213 | self.data = data |
| 2214 | else: |
| 2215 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2216 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2217 | |
| 2218 | def pack(self): |
| 2219 | packed = [] |
| 2220 | packed.append(struct.pack("!B", self.version)) |
| 2221 | packed.append(struct.pack("!B", self.type)) |
| 2222 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2223 | packed.append(struct.pack("!L", self.xid)) |
| 2224 | packed.append(struct.pack("!L", self.experimenter)) |
| 2225 | packed.append(struct.pack("!L", self.subtype)) |
| 2226 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 2227 | packed.append(util.pack_port_no(self.port_no)) |
| 2228 | packed.append(struct.pack("!B", self.slot_num)) |
| 2229 | packed.append('\x00' * 3) |
| 2230 | packed.append(self.data) |
| 2231 | length = sum([len(x) for x in packed]) |
| 2232 | packed[2] = struct.pack("!H", length) |
| 2233 | return ''.join(packed) |
| 2234 | |
| 2235 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2236 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2237 | obj = bsn_pdu_tx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2238 | _version = reader.read("!B")[0] |
| 2239 | assert(_version == 2) |
| 2240 | _type = reader.read("!B")[0] |
| 2241 | assert(_type == 4) |
| 2242 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2243 | orig_reader = reader |
| 2244 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2245 | obj.xid = reader.read("!L")[0] |
| 2246 | _experimenter = reader.read("!L")[0] |
| 2247 | assert(_experimenter == 6035143) |
| 2248 | _subtype = reader.read("!L")[0] |
| 2249 | assert(_subtype == 31) |
| 2250 | obj.tx_interval_ms = reader.read("!L")[0] |
| 2251 | obj.port_no = util.unpack_port_no(reader) |
| 2252 | obj.slot_num = reader.read("!B")[0] |
| 2253 | reader.skip(3) |
| 2254 | obj.data = str(reader.read_all()) |
| 2255 | return obj |
| 2256 | |
| 2257 | def __eq__(self, other): |
| 2258 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2259 | if self.xid != other.xid: return False |
| 2260 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 2261 | if self.port_no != other.port_no: return False |
| 2262 | if self.slot_num != other.slot_num: return False |
| 2263 | if self.data != other.data: return False |
| 2264 | return True |
| 2265 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2266 | def pretty_print(self, q): |
| 2267 | q.text("bsn_pdu_tx_request {") |
| 2268 | with q.group(): |
| 2269 | with q.indent(2): |
| 2270 | q.breakable() |
| 2271 | q.text("xid = "); |
| 2272 | if self.xid != None: |
| 2273 | q.text("%#x" % self.xid) |
| 2274 | else: |
| 2275 | q.text('None') |
| 2276 | q.text(","); q.breakable() |
| 2277 | q.text("tx_interval_ms = "); |
| 2278 | q.text("%#x" % self.tx_interval_ms) |
| 2279 | q.text(","); q.breakable() |
| 2280 | q.text("port_no = "); |
| 2281 | q.text(util.pretty_port(self.port_no)) |
| 2282 | q.text(","); q.breakable() |
| 2283 | q.text("slot_num = "); |
| 2284 | q.text("%#x" % self.slot_num) |
| 2285 | q.text(","); q.breakable() |
| 2286 | q.text("data = "); |
| 2287 | q.pp(self.data) |
| 2288 | q.breakable() |
| 2289 | q.text('}') |
| 2290 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2291 | bsn_header.subtypes[31] = bsn_pdu_tx_request |
| 2292 | |
| 2293 | class bsn_set_mirroring(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2294 | version = 2 |
| 2295 | type = 4 |
| 2296 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2297 | subtype = 3 |
| 2298 | |
| 2299 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2300 | if xid != None: |
| 2301 | self.xid = xid |
| 2302 | else: |
| 2303 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2304 | if report_mirror_ports != None: |
| 2305 | self.report_mirror_ports = report_mirror_ports |
| 2306 | else: |
| 2307 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2308 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2309 | |
| 2310 | def pack(self): |
| 2311 | packed = [] |
| 2312 | packed.append(struct.pack("!B", self.version)) |
| 2313 | packed.append(struct.pack("!B", self.type)) |
| 2314 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2315 | packed.append(struct.pack("!L", self.xid)) |
| 2316 | packed.append(struct.pack("!L", self.experimenter)) |
| 2317 | packed.append(struct.pack("!L", self.subtype)) |
| 2318 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2319 | packed.append('\x00' * 3) |
| 2320 | length = sum([len(x) for x in packed]) |
| 2321 | packed[2] = struct.pack("!H", length) |
| 2322 | return ''.join(packed) |
| 2323 | |
| 2324 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2325 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2326 | obj = bsn_set_mirroring() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2327 | _version = reader.read("!B")[0] |
| 2328 | assert(_version == 2) |
| 2329 | _type = reader.read("!B")[0] |
| 2330 | assert(_type == 4) |
| 2331 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2332 | orig_reader = reader |
| 2333 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2334 | obj.xid = reader.read("!L")[0] |
| 2335 | _experimenter = reader.read("!L")[0] |
| 2336 | assert(_experimenter == 6035143) |
| 2337 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2338 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2339 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2340 | reader.skip(3) |
| 2341 | return obj |
| 2342 | |
| 2343 | def __eq__(self, other): |
| 2344 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2345 | if self.xid != other.xid: return False |
| 2346 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2347 | return True |
| 2348 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2349 | def pretty_print(self, q): |
| 2350 | q.text("bsn_set_mirroring {") |
| 2351 | with q.group(): |
| 2352 | with q.indent(2): |
| 2353 | q.breakable() |
| 2354 | q.text("xid = "); |
| 2355 | if self.xid != None: |
| 2356 | q.text("%#x" % self.xid) |
| 2357 | else: |
| 2358 | q.text('None') |
| 2359 | q.text(","); q.breakable() |
| 2360 | q.text("report_mirror_ports = "); |
| 2361 | q.text("%#x" % self.report_mirror_ports) |
| 2362 | q.breakable() |
| 2363 | q.text('}') |
| 2364 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2365 | bsn_header.subtypes[3] = bsn_set_mirroring |
| 2366 | |
| 2367 | class bsn_set_pktin_suppression_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2368 | version = 2 |
| 2369 | type = 4 |
| 2370 | experimenter = 6035143 |
| 2371 | subtype = 25 |
| 2372 | |
| 2373 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2374 | if xid != None: |
| 2375 | self.xid = xid |
| 2376 | else: |
| 2377 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2378 | if status != None: |
| 2379 | self.status = status |
| 2380 | else: |
| 2381 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2382 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2383 | |
| 2384 | def pack(self): |
| 2385 | packed = [] |
| 2386 | packed.append(struct.pack("!B", self.version)) |
| 2387 | packed.append(struct.pack("!B", self.type)) |
| 2388 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2389 | packed.append(struct.pack("!L", self.xid)) |
| 2390 | packed.append(struct.pack("!L", self.experimenter)) |
| 2391 | packed.append(struct.pack("!L", self.subtype)) |
| 2392 | packed.append(struct.pack("!L", self.status)) |
| 2393 | length = sum([len(x) for x in packed]) |
| 2394 | packed[2] = struct.pack("!H", length) |
| 2395 | return ''.join(packed) |
| 2396 | |
| 2397 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2398 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2399 | obj = bsn_set_pktin_suppression_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2400 | _version = reader.read("!B")[0] |
| 2401 | assert(_version == 2) |
| 2402 | _type = reader.read("!B")[0] |
| 2403 | assert(_type == 4) |
| 2404 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2405 | orig_reader = reader |
| 2406 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2407 | obj.xid = reader.read("!L")[0] |
| 2408 | _experimenter = reader.read("!L")[0] |
| 2409 | assert(_experimenter == 6035143) |
| 2410 | _subtype = reader.read("!L")[0] |
| 2411 | assert(_subtype == 25) |
| 2412 | obj.status = reader.read("!L")[0] |
| 2413 | return obj |
| 2414 | |
| 2415 | def __eq__(self, other): |
| 2416 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2417 | if self.xid != other.xid: return False |
| 2418 | if self.status != other.status: return False |
| 2419 | return True |
| 2420 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2421 | def pretty_print(self, q): |
| 2422 | q.text("bsn_set_pktin_suppression_reply {") |
| 2423 | with q.group(): |
| 2424 | with q.indent(2): |
| 2425 | q.breakable() |
| 2426 | q.text("xid = "); |
| 2427 | if self.xid != None: |
| 2428 | q.text("%#x" % self.xid) |
| 2429 | else: |
| 2430 | q.text('None') |
| 2431 | q.text(","); q.breakable() |
| 2432 | q.text("status = "); |
| 2433 | q.text("%#x" % self.status) |
| 2434 | q.breakable() |
| 2435 | q.text('}') |
| 2436 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2437 | bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply |
| 2438 | |
| 2439 | class bsn_set_pktin_suppression_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2440 | version = 2 |
| 2441 | type = 4 |
| 2442 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2443 | subtype = 11 |
| 2444 | |
| 2445 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2446 | if xid != None: |
| 2447 | self.xid = xid |
| 2448 | else: |
| 2449 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2450 | if enabled != None: |
| 2451 | self.enabled = enabled |
| 2452 | else: |
| 2453 | self.enabled = 0 |
| 2454 | if idle_timeout != None: |
| 2455 | self.idle_timeout = idle_timeout |
| 2456 | else: |
| 2457 | self.idle_timeout = 0 |
| 2458 | if hard_timeout != None: |
| 2459 | self.hard_timeout = hard_timeout |
| 2460 | else: |
| 2461 | self.hard_timeout = 0 |
| 2462 | if priority != None: |
| 2463 | self.priority = priority |
| 2464 | else: |
| 2465 | self.priority = 0 |
| 2466 | if cookie != None: |
| 2467 | self.cookie = cookie |
| 2468 | else: |
| 2469 | self.cookie = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2470 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2471 | |
| 2472 | def pack(self): |
| 2473 | packed = [] |
| 2474 | packed.append(struct.pack("!B", self.version)) |
| 2475 | packed.append(struct.pack("!B", self.type)) |
| 2476 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2477 | packed.append(struct.pack("!L", self.xid)) |
| 2478 | packed.append(struct.pack("!L", self.experimenter)) |
| 2479 | packed.append(struct.pack("!L", self.subtype)) |
| 2480 | packed.append(struct.pack("!B", self.enabled)) |
| 2481 | packed.append('\x00' * 1) |
| 2482 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2483 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2484 | packed.append(struct.pack("!H", self.priority)) |
| 2485 | packed.append(struct.pack("!Q", self.cookie)) |
| 2486 | length = sum([len(x) for x in packed]) |
| 2487 | packed[2] = struct.pack("!H", length) |
| 2488 | return ''.join(packed) |
| 2489 | |
| 2490 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2491 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2492 | obj = bsn_set_pktin_suppression_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2493 | _version = reader.read("!B")[0] |
| 2494 | assert(_version == 2) |
| 2495 | _type = reader.read("!B")[0] |
| 2496 | assert(_type == 4) |
| 2497 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2498 | orig_reader = reader |
| 2499 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2500 | obj.xid = reader.read("!L")[0] |
| 2501 | _experimenter = reader.read("!L")[0] |
| 2502 | assert(_experimenter == 6035143) |
| 2503 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2504 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2505 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2506 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2507 | obj.idle_timeout = reader.read("!H")[0] |
| 2508 | obj.hard_timeout = reader.read("!H")[0] |
| 2509 | obj.priority = reader.read("!H")[0] |
| 2510 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2511 | return obj |
| 2512 | |
| 2513 | def __eq__(self, other): |
| 2514 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2515 | if self.xid != other.xid: return False |
| 2516 | if self.enabled != other.enabled: return False |
| 2517 | if self.idle_timeout != other.idle_timeout: return False |
| 2518 | if self.hard_timeout != other.hard_timeout: return False |
| 2519 | if self.priority != other.priority: return False |
| 2520 | if self.cookie != other.cookie: return False |
| 2521 | return True |
| 2522 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2523 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2524 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2525 | with q.group(): |
| 2526 | with q.indent(2): |
| 2527 | q.breakable() |
| 2528 | q.text("xid = "); |
| 2529 | if self.xid != None: |
| 2530 | q.text("%#x" % self.xid) |
| 2531 | else: |
| 2532 | q.text('None') |
| 2533 | q.text(","); q.breakable() |
| 2534 | q.text("enabled = "); |
| 2535 | q.text("%#x" % self.enabled) |
| 2536 | q.text(","); q.breakable() |
| 2537 | q.text("idle_timeout = "); |
| 2538 | q.text("%#x" % self.idle_timeout) |
| 2539 | q.text(","); q.breakable() |
| 2540 | q.text("hard_timeout = "); |
| 2541 | q.text("%#x" % self.hard_timeout) |
| 2542 | q.text(","); q.breakable() |
| 2543 | q.text("priority = "); |
| 2544 | q.text("%#x" % self.priority) |
| 2545 | q.text(","); q.breakable() |
| 2546 | q.text("cookie = "); |
| 2547 | q.text("%#x" % self.cookie) |
| 2548 | q.breakable() |
| 2549 | q.text('}') |
| 2550 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2551 | bsn_header.subtypes[11] = bsn_set_pktin_suppression_request |
| 2552 | |
| 2553 | class experimenter_stats_reply(stats_reply): |
| 2554 | subtypes = {} |
| 2555 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2556 | version = 2 |
| 2557 | type = 19 |
| 2558 | stats_type = 65535 |
| 2559 | |
| 2560 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 2561 | if xid != None: |
| 2562 | self.xid = xid |
| 2563 | else: |
| 2564 | self.xid = None |
| 2565 | if flags != None: |
| 2566 | self.flags = flags |
| 2567 | else: |
| 2568 | self.flags = 0 |
| 2569 | if experimenter != None: |
| 2570 | self.experimenter = experimenter |
| 2571 | else: |
| 2572 | self.experimenter = 0 |
| 2573 | if data != None: |
| 2574 | self.data = data |
| 2575 | else: |
| 2576 | self.data = '' |
| 2577 | return |
| 2578 | |
| 2579 | def pack(self): |
| 2580 | packed = [] |
| 2581 | packed.append(struct.pack("!B", self.version)) |
| 2582 | packed.append(struct.pack("!B", self.type)) |
| 2583 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2584 | packed.append(struct.pack("!L", self.xid)) |
| 2585 | packed.append(struct.pack("!H", self.stats_type)) |
| 2586 | packed.append(struct.pack("!H", self.flags)) |
| 2587 | packed.append('\x00' * 4) |
| 2588 | packed.append(struct.pack("!L", self.experimenter)) |
| 2589 | packed.append('\x00' * 4) |
| 2590 | packed.append(self.data) |
| 2591 | length = sum([len(x) for x in packed]) |
| 2592 | packed[2] = struct.pack("!H", length) |
| 2593 | return ''.join(packed) |
| 2594 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2595 | @staticmethod |
| 2596 | def unpack(reader): |
| 2597 | subtype, = reader.peek('!L', 16) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2598 | subclass = experimenter_stats_reply.subtypes.get(subtype) |
| 2599 | if subclass: |
| 2600 | return subclass.unpack(reader) |
| 2601 | |
| 2602 | obj = experimenter_stats_reply() |
| 2603 | _version = reader.read("!B")[0] |
| 2604 | assert(_version == 2) |
| 2605 | _type = reader.read("!B")[0] |
| 2606 | assert(_type == 19) |
| 2607 | _length = reader.read("!H")[0] |
| 2608 | orig_reader = reader |
| 2609 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2610 | obj.xid = reader.read("!L")[0] |
| 2611 | _stats_type = reader.read("!H")[0] |
| 2612 | assert(_stats_type == 65535) |
| 2613 | obj.flags = reader.read("!H")[0] |
| 2614 | reader.skip(4) |
| 2615 | obj.experimenter = reader.read("!L")[0] |
| 2616 | reader.skip(4) |
| 2617 | obj.data = str(reader.read_all()) |
| 2618 | return obj |
| 2619 | |
| 2620 | def __eq__(self, other): |
| 2621 | if type(self) != type(other): return False |
| 2622 | if self.xid != other.xid: return False |
| 2623 | if self.flags != other.flags: return False |
| 2624 | if self.experimenter != other.experimenter: return False |
| 2625 | if self.data != other.data: return False |
| 2626 | return True |
| 2627 | |
| 2628 | def pretty_print(self, q): |
| 2629 | q.text("experimenter_stats_reply {") |
| 2630 | with q.group(): |
| 2631 | with q.indent(2): |
| 2632 | q.breakable() |
| 2633 | q.text("xid = "); |
| 2634 | if self.xid != None: |
| 2635 | q.text("%#x" % self.xid) |
| 2636 | else: |
| 2637 | q.text('None') |
| 2638 | q.text(","); q.breakable() |
| 2639 | q.text("flags = "); |
| 2640 | q.text("%#x" % self.flags) |
| 2641 | q.text(","); q.breakable() |
| 2642 | q.text("data = "); |
| 2643 | q.pp(self.data) |
| 2644 | q.breakable() |
| 2645 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2646 | |
| 2647 | stats_reply.subtypes[65535] = experimenter_stats_reply |
| 2648 | |
| 2649 | class bsn_stats_reply(experimenter_stats_reply): |
| 2650 | subtypes = {} |
| 2651 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2652 | version = 2 |
| 2653 | type = 19 |
| 2654 | stats_type = 65535 |
| 2655 | experimenter = 6035143 |
| 2656 | |
| 2657 | def __init__(self, xid=None, flags=None, subtype=None): |
| 2658 | if xid != None: |
| 2659 | self.xid = xid |
| 2660 | else: |
| 2661 | self.xid = None |
| 2662 | if flags != None: |
| 2663 | self.flags = flags |
| 2664 | else: |
| 2665 | self.flags = 0 |
| 2666 | if subtype != None: |
| 2667 | self.subtype = subtype |
| 2668 | else: |
| 2669 | self.subtype = 0 |
| 2670 | return |
| 2671 | |
| 2672 | def pack(self): |
| 2673 | packed = [] |
| 2674 | packed.append(struct.pack("!B", self.version)) |
| 2675 | packed.append(struct.pack("!B", self.type)) |
| 2676 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2677 | packed.append(struct.pack("!L", self.xid)) |
| 2678 | packed.append(struct.pack("!H", self.stats_type)) |
| 2679 | packed.append(struct.pack("!H", self.flags)) |
| 2680 | packed.append('\x00' * 4) |
| 2681 | packed.append(struct.pack("!L", self.experimenter)) |
| 2682 | packed.append(struct.pack("!L", self.subtype)) |
| 2683 | length = sum([len(x) for x in packed]) |
| 2684 | packed[2] = struct.pack("!H", length) |
| 2685 | return ''.join(packed) |
| 2686 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2687 | @staticmethod |
| 2688 | def unpack(reader): |
| 2689 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2690 | subclass = bsn_stats_reply.subtypes.get(subtype) |
| 2691 | if subclass: |
| 2692 | return subclass.unpack(reader) |
| 2693 | |
| 2694 | obj = bsn_stats_reply() |
| 2695 | _version = reader.read("!B")[0] |
| 2696 | assert(_version == 2) |
| 2697 | _type = reader.read("!B")[0] |
| 2698 | assert(_type == 19) |
| 2699 | _length = reader.read("!H")[0] |
| 2700 | orig_reader = reader |
| 2701 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2702 | obj.xid = reader.read("!L")[0] |
| 2703 | _stats_type = reader.read("!H")[0] |
| 2704 | assert(_stats_type == 65535) |
| 2705 | obj.flags = reader.read("!H")[0] |
| 2706 | reader.skip(4) |
| 2707 | _experimenter = reader.read("!L")[0] |
| 2708 | assert(_experimenter == 6035143) |
| 2709 | obj.subtype = reader.read("!L")[0] |
| 2710 | return obj |
| 2711 | |
| 2712 | def __eq__(self, other): |
| 2713 | if type(self) != type(other): return False |
| 2714 | if self.xid != other.xid: return False |
| 2715 | if self.flags != other.flags: return False |
| 2716 | if self.subtype != other.subtype: return False |
| 2717 | return True |
| 2718 | |
| 2719 | def pretty_print(self, q): |
| 2720 | q.text("bsn_stats_reply {") |
| 2721 | with q.group(): |
| 2722 | with q.indent(2): |
| 2723 | q.breakable() |
| 2724 | q.text("xid = "); |
| 2725 | if self.xid != None: |
| 2726 | q.text("%#x" % self.xid) |
| 2727 | else: |
| 2728 | q.text('None') |
| 2729 | q.text(","); q.breakable() |
| 2730 | q.text("flags = "); |
| 2731 | q.text("%#x" % self.flags) |
| 2732 | q.breakable() |
| 2733 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2734 | |
| 2735 | experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply |
| 2736 | |
| 2737 | class experimenter_stats_request(stats_request): |
| 2738 | subtypes = {} |
| 2739 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2740 | version = 2 |
| 2741 | type = 18 |
| 2742 | stats_type = 65535 |
| 2743 | |
| 2744 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 2745 | if xid != None: |
| 2746 | self.xid = xid |
| 2747 | else: |
| 2748 | self.xid = None |
| 2749 | if flags != None: |
| 2750 | self.flags = flags |
| 2751 | else: |
| 2752 | self.flags = 0 |
| 2753 | if experimenter != None: |
| 2754 | self.experimenter = experimenter |
| 2755 | else: |
| 2756 | self.experimenter = 0 |
| 2757 | if data != None: |
| 2758 | self.data = data |
| 2759 | else: |
| 2760 | self.data = '' |
| 2761 | return |
| 2762 | |
| 2763 | def pack(self): |
| 2764 | packed = [] |
| 2765 | packed.append(struct.pack("!B", self.version)) |
| 2766 | packed.append(struct.pack("!B", self.type)) |
| 2767 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2768 | packed.append(struct.pack("!L", self.xid)) |
| 2769 | packed.append(struct.pack("!H", self.stats_type)) |
| 2770 | packed.append(struct.pack("!H", self.flags)) |
| 2771 | packed.append('\x00' * 4) |
| 2772 | packed.append(struct.pack("!L", self.experimenter)) |
| 2773 | packed.append('\x00' * 4) |
| 2774 | packed.append(self.data) |
| 2775 | length = sum([len(x) for x in packed]) |
| 2776 | packed[2] = struct.pack("!H", length) |
| 2777 | return ''.join(packed) |
| 2778 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2779 | @staticmethod |
| 2780 | def unpack(reader): |
| 2781 | subtype, = reader.peek('!L', 16) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2782 | subclass = experimenter_stats_request.subtypes.get(subtype) |
| 2783 | if subclass: |
| 2784 | return subclass.unpack(reader) |
| 2785 | |
| 2786 | obj = experimenter_stats_request() |
| 2787 | _version = reader.read("!B")[0] |
| 2788 | assert(_version == 2) |
| 2789 | _type = reader.read("!B")[0] |
| 2790 | assert(_type == 18) |
| 2791 | _length = reader.read("!H")[0] |
| 2792 | orig_reader = reader |
| 2793 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2794 | obj.xid = reader.read("!L")[0] |
| 2795 | _stats_type = reader.read("!H")[0] |
| 2796 | assert(_stats_type == 65535) |
| 2797 | obj.flags = reader.read("!H")[0] |
| 2798 | reader.skip(4) |
| 2799 | obj.experimenter = reader.read("!L")[0] |
| 2800 | reader.skip(4) |
| 2801 | obj.data = str(reader.read_all()) |
| 2802 | return obj |
| 2803 | |
| 2804 | def __eq__(self, other): |
| 2805 | if type(self) != type(other): return False |
| 2806 | if self.xid != other.xid: return False |
| 2807 | if self.flags != other.flags: return False |
| 2808 | if self.experimenter != other.experimenter: return False |
| 2809 | if self.data != other.data: return False |
| 2810 | return True |
| 2811 | |
| 2812 | def pretty_print(self, q): |
| 2813 | q.text("experimenter_stats_request {") |
| 2814 | with q.group(): |
| 2815 | with q.indent(2): |
| 2816 | q.breakable() |
| 2817 | q.text("xid = "); |
| 2818 | if self.xid != None: |
| 2819 | q.text("%#x" % self.xid) |
| 2820 | else: |
| 2821 | q.text('None') |
| 2822 | q.text(","); q.breakable() |
| 2823 | q.text("flags = "); |
| 2824 | q.text("%#x" % self.flags) |
| 2825 | q.text(","); q.breakable() |
| 2826 | q.text("data = "); |
| 2827 | q.pp(self.data) |
| 2828 | q.breakable() |
| 2829 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2830 | |
| 2831 | stats_request.subtypes[65535] = experimenter_stats_request |
| 2832 | |
| 2833 | class bsn_stats_request(experimenter_stats_request): |
| 2834 | subtypes = {} |
| 2835 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2836 | version = 2 |
| 2837 | type = 18 |
| 2838 | stats_type = 65535 |
| 2839 | experimenter = 6035143 |
| 2840 | |
| 2841 | def __init__(self, xid=None, flags=None, subtype=None): |
| 2842 | if xid != None: |
| 2843 | self.xid = xid |
| 2844 | else: |
| 2845 | self.xid = None |
| 2846 | if flags != None: |
| 2847 | self.flags = flags |
| 2848 | else: |
| 2849 | self.flags = 0 |
| 2850 | if subtype != None: |
| 2851 | self.subtype = subtype |
| 2852 | else: |
| 2853 | self.subtype = 0 |
| 2854 | return |
| 2855 | |
| 2856 | def pack(self): |
| 2857 | packed = [] |
| 2858 | packed.append(struct.pack("!B", self.version)) |
| 2859 | packed.append(struct.pack("!B", self.type)) |
| 2860 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2861 | packed.append(struct.pack("!L", self.xid)) |
| 2862 | packed.append(struct.pack("!H", self.stats_type)) |
| 2863 | packed.append(struct.pack("!H", self.flags)) |
| 2864 | packed.append('\x00' * 4) |
| 2865 | packed.append(struct.pack("!L", self.experimenter)) |
| 2866 | packed.append(struct.pack("!L", self.subtype)) |
| 2867 | length = sum([len(x) for x in packed]) |
| 2868 | packed[2] = struct.pack("!H", length) |
| 2869 | return ''.join(packed) |
| 2870 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2871 | @staticmethod |
| 2872 | def unpack(reader): |
| 2873 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2874 | subclass = bsn_stats_request.subtypes.get(subtype) |
| 2875 | if subclass: |
| 2876 | return subclass.unpack(reader) |
| 2877 | |
| 2878 | obj = bsn_stats_request() |
| 2879 | _version = reader.read("!B")[0] |
| 2880 | assert(_version == 2) |
| 2881 | _type = reader.read("!B")[0] |
| 2882 | assert(_type == 18) |
| 2883 | _length = reader.read("!H")[0] |
| 2884 | orig_reader = reader |
| 2885 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2886 | obj.xid = reader.read("!L")[0] |
| 2887 | _stats_type = reader.read("!H")[0] |
| 2888 | assert(_stats_type == 65535) |
| 2889 | obj.flags = reader.read("!H")[0] |
| 2890 | reader.skip(4) |
| 2891 | _experimenter = reader.read("!L")[0] |
| 2892 | assert(_experimenter == 6035143) |
| 2893 | obj.subtype = reader.read("!L")[0] |
| 2894 | return obj |
| 2895 | |
| 2896 | def __eq__(self, other): |
| 2897 | if type(self) != type(other): return False |
| 2898 | if self.xid != other.xid: return False |
| 2899 | if self.flags != other.flags: return False |
| 2900 | if self.subtype != other.subtype: return False |
| 2901 | return True |
| 2902 | |
| 2903 | def pretty_print(self, q): |
| 2904 | q.text("bsn_stats_request {") |
| 2905 | with q.group(): |
| 2906 | with q.indent(2): |
| 2907 | q.breakable() |
| 2908 | q.text("xid = "); |
| 2909 | if self.xid != None: |
| 2910 | q.text("%#x" % self.xid) |
| 2911 | else: |
| 2912 | q.text('None') |
| 2913 | q.text(","); q.breakable() |
| 2914 | q.text("flags = "); |
| 2915 | q.text("%#x" % self.flags) |
| 2916 | q.breakable() |
| 2917 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2918 | |
| 2919 | experimenter_stats_request.subtypes[6035143] = bsn_stats_request |
| 2920 | |
| 2921 | class bsn_virtual_port_create_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2922 | version = 2 |
| 2923 | type = 4 |
| 2924 | experimenter = 6035143 |
| 2925 | subtype = 16 |
| 2926 | |
| 2927 | def __init__(self, xid=None, status=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2928 | if xid != None: |
| 2929 | self.xid = xid |
| 2930 | else: |
| 2931 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2932 | if status != None: |
| 2933 | self.status = status |
| 2934 | else: |
| 2935 | self.status = 0 |
| 2936 | if vport_no != None: |
| 2937 | self.vport_no = vport_no |
| 2938 | else: |
| 2939 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2940 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2941 | |
| 2942 | def pack(self): |
| 2943 | packed = [] |
| 2944 | packed.append(struct.pack("!B", self.version)) |
| 2945 | packed.append(struct.pack("!B", self.type)) |
| 2946 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2947 | packed.append(struct.pack("!L", self.xid)) |
| 2948 | packed.append(struct.pack("!L", self.experimenter)) |
| 2949 | packed.append(struct.pack("!L", self.subtype)) |
| 2950 | packed.append(struct.pack("!L", self.status)) |
| 2951 | packed.append(struct.pack("!L", self.vport_no)) |
| 2952 | length = sum([len(x) for x in packed]) |
| 2953 | packed[2] = struct.pack("!H", length) |
| 2954 | return ''.join(packed) |
| 2955 | |
| 2956 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2957 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2958 | obj = bsn_virtual_port_create_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2959 | _version = reader.read("!B")[0] |
| 2960 | assert(_version == 2) |
| 2961 | _type = reader.read("!B")[0] |
| 2962 | assert(_type == 4) |
| 2963 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2964 | orig_reader = reader |
| 2965 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2966 | obj.xid = reader.read("!L")[0] |
| 2967 | _experimenter = reader.read("!L")[0] |
| 2968 | assert(_experimenter == 6035143) |
| 2969 | _subtype = reader.read("!L")[0] |
| 2970 | assert(_subtype == 16) |
| 2971 | obj.status = reader.read("!L")[0] |
| 2972 | obj.vport_no = reader.read("!L")[0] |
| 2973 | return obj |
| 2974 | |
| 2975 | def __eq__(self, other): |
| 2976 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2977 | if self.xid != other.xid: return False |
| 2978 | if self.status != other.status: return False |
| 2979 | if self.vport_no != other.vport_no: return False |
| 2980 | return True |
| 2981 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2982 | def pretty_print(self, q): |
| 2983 | q.text("bsn_virtual_port_create_reply {") |
| 2984 | with q.group(): |
| 2985 | with q.indent(2): |
| 2986 | q.breakable() |
| 2987 | q.text("xid = "); |
| 2988 | if self.xid != None: |
| 2989 | q.text("%#x" % self.xid) |
| 2990 | else: |
| 2991 | q.text('None') |
| 2992 | q.text(","); q.breakable() |
| 2993 | q.text("status = "); |
| 2994 | q.text("%#x" % self.status) |
| 2995 | q.text(","); q.breakable() |
| 2996 | q.text("vport_no = "); |
| 2997 | q.text("%#x" % self.vport_no) |
| 2998 | q.breakable() |
| 2999 | q.text('}') |
| 3000 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3001 | bsn_header.subtypes[16] = bsn_virtual_port_create_reply |
| 3002 | |
| 3003 | class bsn_virtual_port_create_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3004 | version = 2 |
| 3005 | type = 4 |
| 3006 | experimenter = 6035143 |
| 3007 | subtype = 15 |
| 3008 | |
| 3009 | def __init__(self, xid=None, vport=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3010 | if xid != None: |
| 3011 | self.xid = xid |
| 3012 | else: |
| 3013 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3014 | if vport != None: |
| 3015 | self.vport = vport |
| 3016 | else: |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 3017 | self.vport = common.bsn_vport() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3018 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3019 | |
| 3020 | def pack(self): |
| 3021 | packed = [] |
| 3022 | packed.append(struct.pack("!B", self.version)) |
| 3023 | packed.append(struct.pack("!B", self.type)) |
| 3024 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3025 | packed.append(struct.pack("!L", self.xid)) |
| 3026 | packed.append(struct.pack("!L", self.experimenter)) |
| 3027 | packed.append(struct.pack("!L", self.subtype)) |
| 3028 | packed.append(self.vport.pack()) |
| 3029 | length = sum([len(x) for x in packed]) |
| 3030 | packed[2] = struct.pack("!H", length) |
| 3031 | return ''.join(packed) |
| 3032 | |
| 3033 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3034 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3035 | obj = bsn_virtual_port_create_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3036 | _version = reader.read("!B")[0] |
| 3037 | assert(_version == 2) |
| 3038 | _type = reader.read("!B")[0] |
| 3039 | assert(_type == 4) |
| 3040 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3041 | orig_reader = reader |
| 3042 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3043 | obj.xid = reader.read("!L")[0] |
| 3044 | _experimenter = reader.read("!L")[0] |
| 3045 | assert(_experimenter == 6035143) |
| 3046 | _subtype = reader.read("!L")[0] |
| 3047 | assert(_subtype == 15) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame] | 3048 | obj.vport = common.bsn_vport.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3049 | return obj |
| 3050 | |
| 3051 | def __eq__(self, other): |
| 3052 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3053 | if self.xid != other.xid: return False |
| 3054 | if self.vport != other.vport: return False |
| 3055 | return True |
| 3056 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3057 | def pretty_print(self, q): |
| 3058 | q.text("bsn_virtual_port_create_request {") |
| 3059 | with q.group(): |
| 3060 | with q.indent(2): |
| 3061 | q.breakable() |
| 3062 | q.text("xid = "); |
| 3063 | if self.xid != None: |
| 3064 | q.text("%#x" % self.xid) |
| 3065 | else: |
| 3066 | q.text('None') |
| 3067 | q.text(","); q.breakable() |
| 3068 | q.text("vport = "); |
| 3069 | q.pp(self.vport) |
| 3070 | q.breakable() |
| 3071 | q.text('}') |
| 3072 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3073 | bsn_header.subtypes[15] = bsn_virtual_port_create_request |
| 3074 | |
| 3075 | class bsn_virtual_port_remove_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3076 | version = 2 |
| 3077 | type = 4 |
| 3078 | experimenter = 6035143 |
| 3079 | subtype = 26 |
| 3080 | |
| 3081 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3082 | if xid != None: |
| 3083 | self.xid = xid |
| 3084 | else: |
| 3085 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3086 | if status != None: |
| 3087 | self.status = status |
| 3088 | else: |
| 3089 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3090 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3091 | |
| 3092 | def pack(self): |
| 3093 | packed = [] |
| 3094 | packed.append(struct.pack("!B", self.version)) |
| 3095 | packed.append(struct.pack("!B", self.type)) |
| 3096 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3097 | packed.append(struct.pack("!L", self.xid)) |
| 3098 | packed.append(struct.pack("!L", self.experimenter)) |
| 3099 | packed.append(struct.pack("!L", self.subtype)) |
| 3100 | packed.append(struct.pack("!L", self.status)) |
| 3101 | length = sum([len(x) for x in packed]) |
| 3102 | packed[2] = struct.pack("!H", length) |
| 3103 | return ''.join(packed) |
| 3104 | |
| 3105 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3106 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3107 | obj = bsn_virtual_port_remove_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3108 | _version = reader.read("!B")[0] |
| 3109 | assert(_version == 2) |
| 3110 | _type = reader.read("!B")[0] |
| 3111 | assert(_type == 4) |
| 3112 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3113 | orig_reader = reader |
| 3114 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3115 | obj.xid = reader.read("!L")[0] |
| 3116 | _experimenter = reader.read("!L")[0] |
| 3117 | assert(_experimenter == 6035143) |
| 3118 | _subtype = reader.read("!L")[0] |
| 3119 | assert(_subtype == 26) |
| 3120 | obj.status = reader.read("!L")[0] |
| 3121 | return obj |
| 3122 | |
| 3123 | def __eq__(self, other): |
| 3124 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3125 | if self.xid != other.xid: return False |
| 3126 | if self.status != other.status: return False |
| 3127 | return True |
| 3128 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3129 | def pretty_print(self, q): |
| 3130 | q.text("bsn_virtual_port_remove_reply {") |
| 3131 | with q.group(): |
| 3132 | with q.indent(2): |
| 3133 | q.breakable() |
| 3134 | q.text("xid = "); |
| 3135 | if self.xid != None: |
| 3136 | q.text("%#x" % self.xid) |
| 3137 | else: |
| 3138 | q.text('None') |
| 3139 | q.text(","); q.breakable() |
| 3140 | q.text("status = "); |
| 3141 | q.text("%#x" % self.status) |
| 3142 | q.breakable() |
| 3143 | q.text('}') |
| 3144 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3145 | bsn_header.subtypes[26] = bsn_virtual_port_remove_reply |
| 3146 | |
| 3147 | class bsn_virtual_port_remove_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3148 | version = 2 |
| 3149 | type = 4 |
| 3150 | experimenter = 6035143 |
| 3151 | subtype = 17 |
| 3152 | |
| 3153 | def __init__(self, xid=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3154 | if xid != None: |
| 3155 | self.xid = xid |
| 3156 | else: |
| 3157 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3158 | if vport_no != None: |
| 3159 | self.vport_no = vport_no |
| 3160 | else: |
| 3161 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3162 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3163 | |
| 3164 | def pack(self): |
| 3165 | packed = [] |
| 3166 | packed.append(struct.pack("!B", self.version)) |
| 3167 | packed.append(struct.pack("!B", self.type)) |
| 3168 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3169 | packed.append(struct.pack("!L", self.xid)) |
| 3170 | packed.append(struct.pack("!L", self.experimenter)) |
| 3171 | packed.append(struct.pack("!L", self.subtype)) |
| 3172 | packed.append(struct.pack("!L", self.vport_no)) |
| 3173 | length = sum([len(x) for x in packed]) |
| 3174 | packed[2] = struct.pack("!H", length) |
| 3175 | return ''.join(packed) |
| 3176 | |
| 3177 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3178 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3179 | obj = bsn_virtual_port_remove_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3180 | _version = reader.read("!B")[0] |
| 3181 | assert(_version == 2) |
| 3182 | _type = reader.read("!B")[0] |
| 3183 | assert(_type == 4) |
| 3184 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3185 | orig_reader = reader |
| 3186 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3187 | obj.xid = reader.read("!L")[0] |
| 3188 | _experimenter = reader.read("!L")[0] |
| 3189 | assert(_experimenter == 6035143) |
| 3190 | _subtype = reader.read("!L")[0] |
| 3191 | assert(_subtype == 17) |
| 3192 | obj.vport_no = reader.read("!L")[0] |
| 3193 | return obj |
| 3194 | |
| 3195 | def __eq__(self, other): |
| 3196 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3197 | if self.xid != other.xid: return False |
| 3198 | if self.vport_no != other.vport_no: return False |
| 3199 | return True |
| 3200 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3201 | def pretty_print(self, q): |
| 3202 | q.text("bsn_virtual_port_remove_request {") |
| 3203 | with q.group(): |
| 3204 | with q.indent(2): |
| 3205 | q.breakable() |
| 3206 | q.text("xid = "); |
| 3207 | if self.xid != None: |
| 3208 | q.text("%#x" % self.xid) |
| 3209 | else: |
| 3210 | q.text('None') |
| 3211 | q.text(","); q.breakable() |
| 3212 | q.text("vport_no = "); |
| 3213 | q.text("%#x" % self.vport_no) |
| 3214 | q.breakable() |
| 3215 | q.text('}') |
| 3216 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3217 | bsn_header.subtypes[17] = bsn_virtual_port_remove_request |
| 3218 | |
| 3219 | class desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3220 | version = 2 |
| 3221 | type = 19 |
| 3222 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3223 | |
| 3224 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3225 | if xid != None: |
| 3226 | self.xid = xid |
| 3227 | else: |
| 3228 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3229 | if flags != None: |
| 3230 | self.flags = flags |
| 3231 | else: |
| 3232 | self.flags = 0 |
| 3233 | if mfr_desc != None: |
| 3234 | self.mfr_desc = mfr_desc |
| 3235 | else: |
| 3236 | self.mfr_desc = "" |
| 3237 | if hw_desc != None: |
| 3238 | self.hw_desc = hw_desc |
| 3239 | else: |
| 3240 | self.hw_desc = "" |
| 3241 | if sw_desc != None: |
| 3242 | self.sw_desc = sw_desc |
| 3243 | else: |
| 3244 | self.sw_desc = "" |
| 3245 | if serial_num != None: |
| 3246 | self.serial_num = serial_num |
| 3247 | else: |
| 3248 | self.serial_num = "" |
| 3249 | if dp_desc != None: |
| 3250 | self.dp_desc = dp_desc |
| 3251 | else: |
| 3252 | self.dp_desc = "" |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3253 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3254 | |
| 3255 | def pack(self): |
| 3256 | packed = [] |
| 3257 | packed.append(struct.pack("!B", self.version)) |
| 3258 | packed.append(struct.pack("!B", self.type)) |
| 3259 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3260 | packed.append(struct.pack("!L", self.xid)) |
| 3261 | packed.append(struct.pack("!H", self.stats_type)) |
| 3262 | packed.append(struct.pack("!H", self.flags)) |
| 3263 | packed.append('\x00' * 4) |
| 3264 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 3265 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 3266 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 3267 | packed.append(struct.pack("!32s", self.serial_num)) |
| 3268 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 3269 | length = sum([len(x) for x in packed]) |
| 3270 | packed[2] = struct.pack("!H", length) |
| 3271 | return ''.join(packed) |
| 3272 | |
| 3273 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3274 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3275 | obj = desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3276 | _version = reader.read("!B")[0] |
| 3277 | assert(_version == 2) |
| 3278 | _type = reader.read("!B")[0] |
| 3279 | assert(_type == 19) |
| 3280 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3281 | orig_reader = reader |
| 3282 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3283 | obj.xid = reader.read("!L")[0] |
| 3284 | _stats_type = reader.read("!H")[0] |
| 3285 | assert(_stats_type == 0) |
| 3286 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3287 | reader.skip(4) |
| 3288 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3289 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3290 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3291 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 3292 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3293 | return obj |
| 3294 | |
| 3295 | def __eq__(self, other): |
| 3296 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3297 | if self.xid != other.xid: return False |
| 3298 | if self.flags != other.flags: return False |
| 3299 | if self.mfr_desc != other.mfr_desc: return False |
| 3300 | if self.hw_desc != other.hw_desc: return False |
| 3301 | if self.sw_desc != other.sw_desc: return False |
| 3302 | if self.serial_num != other.serial_num: return False |
| 3303 | if self.dp_desc != other.dp_desc: return False |
| 3304 | return True |
| 3305 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3306 | def pretty_print(self, q): |
| 3307 | q.text("desc_stats_reply {") |
| 3308 | with q.group(): |
| 3309 | with q.indent(2): |
| 3310 | q.breakable() |
| 3311 | q.text("xid = "); |
| 3312 | if self.xid != None: |
| 3313 | q.text("%#x" % self.xid) |
| 3314 | else: |
| 3315 | q.text('None') |
| 3316 | q.text(","); q.breakable() |
| 3317 | q.text("flags = "); |
| 3318 | q.text("%#x" % self.flags) |
| 3319 | q.text(","); q.breakable() |
| 3320 | q.text("mfr_desc = "); |
| 3321 | q.pp(self.mfr_desc) |
| 3322 | q.text(","); q.breakable() |
| 3323 | q.text("hw_desc = "); |
| 3324 | q.pp(self.hw_desc) |
| 3325 | q.text(","); q.breakable() |
| 3326 | q.text("sw_desc = "); |
| 3327 | q.pp(self.sw_desc) |
| 3328 | q.text(","); q.breakable() |
| 3329 | q.text("serial_num = "); |
| 3330 | q.pp(self.serial_num) |
| 3331 | q.text(","); q.breakable() |
| 3332 | q.text("dp_desc = "); |
| 3333 | q.pp(self.dp_desc) |
| 3334 | q.breakable() |
| 3335 | q.text('}') |
| 3336 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3337 | stats_reply.subtypes[0] = desc_stats_reply |
| 3338 | |
| 3339 | class desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3340 | version = 2 |
| 3341 | type = 18 |
| 3342 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3343 | |
| 3344 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3345 | if xid != None: |
| 3346 | self.xid = xid |
| 3347 | else: |
| 3348 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3349 | if flags != None: |
| 3350 | self.flags = flags |
| 3351 | else: |
| 3352 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3353 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3354 | |
| 3355 | def pack(self): |
| 3356 | packed = [] |
| 3357 | packed.append(struct.pack("!B", self.version)) |
| 3358 | packed.append(struct.pack("!B", self.type)) |
| 3359 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3360 | packed.append(struct.pack("!L", self.xid)) |
| 3361 | packed.append(struct.pack("!H", self.stats_type)) |
| 3362 | packed.append(struct.pack("!H", self.flags)) |
| 3363 | packed.append('\x00' * 4) |
| 3364 | length = sum([len(x) for x in packed]) |
| 3365 | packed[2] = struct.pack("!H", length) |
| 3366 | return ''.join(packed) |
| 3367 | |
| 3368 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3369 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3370 | obj = desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3371 | _version = reader.read("!B")[0] |
| 3372 | assert(_version == 2) |
| 3373 | _type = reader.read("!B")[0] |
| 3374 | assert(_type == 18) |
| 3375 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3376 | orig_reader = reader |
| 3377 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3378 | obj.xid = reader.read("!L")[0] |
| 3379 | _stats_type = reader.read("!H")[0] |
| 3380 | assert(_stats_type == 0) |
| 3381 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3382 | reader.skip(4) |
| 3383 | return obj |
| 3384 | |
| 3385 | def __eq__(self, other): |
| 3386 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3387 | if self.xid != other.xid: return False |
| 3388 | if self.flags != other.flags: return False |
| 3389 | return True |
| 3390 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3391 | def pretty_print(self, q): |
| 3392 | q.text("desc_stats_request {") |
| 3393 | with q.group(): |
| 3394 | with q.indent(2): |
| 3395 | q.breakable() |
| 3396 | q.text("xid = "); |
| 3397 | if self.xid != None: |
| 3398 | q.text("%#x" % self.xid) |
| 3399 | else: |
| 3400 | q.text('None') |
| 3401 | q.text(","); q.breakable() |
| 3402 | q.text("flags = "); |
| 3403 | q.text("%#x" % self.flags) |
| 3404 | q.breakable() |
| 3405 | q.text('}') |
| 3406 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3407 | stats_request.subtypes[0] = desc_stats_request |
| 3408 | |
| 3409 | class echo_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3410 | version = 2 |
| 3411 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3412 | |
| 3413 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3414 | if xid != None: |
| 3415 | self.xid = xid |
| 3416 | else: |
| 3417 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3418 | if data != None: |
| 3419 | self.data = data |
| 3420 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3421 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3422 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3423 | |
| 3424 | def pack(self): |
| 3425 | packed = [] |
| 3426 | packed.append(struct.pack("!B", self.version)) |
| 3427 | packed.append(struct.pack("!B", self.type)) |
| 3428 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3429 | packed.append(struct.pack("!L", self.xid)) |
| 3430 | packed.append(self.data) |
| 3431 | length = sum([len(x) for x in packed]) |
| 3432 | packed[2] = struct.pack("!H", length) |
| 3433 | return ''.join(packed) |
| 3434 | |
| 3435 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3436 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3437 | obj = echo_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3438 | _version = reader.read("!B")[0] |
| 3439 | assert(_version == 2) |
| 3440 | _type = reader.read("!B")[0] |
| 3441 | assert(_type == 3) |
| 3442 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3443 | orig_reader = reader |
| 3444 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3445 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3446 | obj.data = str(reader.read_all()) |
| 3447 | return obj |
| 3448 | |
| 3449 | def __eq__(self, other): |
| 3450 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3451 | if self.xid != other.xid: return False |
| 3452 | if self.data != other.data: return False |
| 3453 | return True |
| 3454 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3455 | def pretty_print(self, q): |
| 3456 | q.text("echo_reply {") |
| 3457 | with q.group(): |
| 3458 | with q.indent(2): |
| 3459 | q.breakable() |
| 3460 | q.text("xid = "); |
| 3461 | if self.xid != None: |
| 3462 | q.text("%#x" % self.xid) |
| 3463 | else: |
| 3464 | q.text('None') |
| 3465 | q.text(","); q.breakable() |
| 3466 | q.text("data = "); |
| 3467 | q.pp(self.data) |
| 3468 | q.breakable() |
| 3469 | q.text('}') |
| 3470 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3471 | message.subtypes[3] = echo_reply |
| 3472 | |
| 3473 | class echo_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3474 | version = 2 |
| 3475 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3476 | |
| 3477 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3478 | if xid != None: |
| 3479 | self.xid = xid |
| 3480 | else: |
| 3481 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3482 | if data != None: |
| 3483 | self.data = data |
| 3484 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3485 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3486 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3487 | |
| 3488 | def pack(self): |
| 3489 | packed = [] |
| 3490 | packed.append(struct.pack("!B", self.version)) |
| 3491 | packed.append(struct.pack("!B", self.type)) |
| 3492 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3493 | packed.append(struct.pack("!L", self.xid)) |
| 3494 | packed.append(self.data) |
| 3495 | length = sum([len(x) for x in packed]) |
| 3496 | packed[2] = struct.pack("!H", length) |
| 3497 | return ''.join(packed) |
| 3498 | |
| 3499 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3500 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3501 | obj = echo_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3502 | _version = reader.read("!B")[0] |
| 3503 | assert(_version == 2) |
| 3504 | _type = reader.read("!B")[0] |
| 3505 | assert(_type == 2) |
| 3506 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3507 | orig_reader = reader |
| 3508 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3509 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3510 | obj.data = str(reader.read_all()) |
| 3511 | return obj |
| 3512 | |
| 3513 | def __eq__(self, other): |
| 3514 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3515 | if self.xid != other.xid: return False |
| 3516 | if self.data != other.data: return False |
| 3517 | return True |
| 3518 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3519 | def pretty_print(self, q): |
| 3520 | q.text("echo_request {") |
| 3521 | with q.group(): |
| 3522 | with q.indent(2): |
| 3523 | q.breakable() |
| 3524 | q.text("xid = "); |
| 3525 | if self.xid != None: |
| 3526 | q.text("%#x" % self.xid) |
| 3527 | else: |
| 3528 | q.text('None') |
| 3529 | q.text(","); q.breakable() |
| 3530 | q.text("data = "); |
| 3531 | q.pp(self.data) |
| 3532 | q.breakable() |
| 3533 | q.text('}') |
| 3534 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3535 | message.subtypes[2] = echo_request |
| 3536 | |
| 3537 | class features_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3538 | version = 2 |
| 3539 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3540 | |
| 3541 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3542 | if xid != None: |
| 3543 | self.xid = xid |
| 3544 | else: |
| 3545 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3546 | if datapath_id != None: |
| 3547 | self.datapath_id = datapath_id |
| 3548 | else: |
| 3549 | self.datapath_id = 0 |
| 3550 | if n_buffers != None: |
| 3551 | self.n_buffers = n_buffers |
| 3552 | else: |
| 3553 | self.n_buffers = 0 |
| 3554 | if n_tables != None: |
| 3555 | self.n_tables = n_tables |
| 3556 | else: |
| 3557 | self.n_tables = 0 |
| 3558 | if capabilities != None: |
| 3559 | self.capabilities = capabilities |
| 3560 | else: |
| 3561 | self.capabilities = 0 |
| 3562 | if reserved != None: |
| 3563 | self.reserved = reserved |
| 3564 | else: |
| 3565 | self.reserved = 0 |
| 3566 | if ports != None: |
| 3567 | self.ports = ports |
| 3568 | else: |
| 3569 | self.ports = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3570 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3571 | |
| 3572 | def pack(self): |
| 3573 | packed = [] |
| 3574 | packed.append(struct.pack("!B", self.version)) |
| 3575 | packed.append(struct.pack("!B", self.type)) |
| 3576 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3577 | packed.append(struct.pack("!L", self.xid)) |
| 3578 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 3579 | packed.append(struct.pack("!L", self.n_buffers)) |
| 3580 | packed.append(struct.pack("!B", self.n_tables)) |
| 3581 | packed.append('\x00' * 3) |
| 3582 | packed.append(struct.pack("!L", self.capabilities)) |
| 3583 | packed.append(struct.pack("!L", self.reserved)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3584 | packed.append(loxi.generic_util.pack_list(self.ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3585 | length = sum([len(x) for x in packed]) |
| 3586 | packed[2] = struct.pack("!H", length) |
| 3587 | return ''.join(packed) |
| 3588 | |
| 3589 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3590 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3591 | obj = features_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3592 | _version = reader.read("!B")[0] |
| 3593 | assert(_version == 2) |
| 3594 | _type = reader.read("!B")[0] |
| 3595 | assert(_type == 6) |
| 3596 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3597 | orig_reader = reader |
| 3598 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3599 | obj.xid = reader.read("!L")[0] |
| 3600 | obj.datapath_id = reader.read("!Q")[0] |
| 3601 | obj.n_buffers = reader.read("!L")[0] |
| 3602 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3603 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3604 | obj.capabilities = reader.read("!L")[0] |
| 3605 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3606 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 3607 | return obj |
| 3608 | |
| 3609 | def __eq__(self, other): |
| 3610 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3611 | if self.xid != other.xid: return False |
| 3612 | if self.datapath_id != other.datapath_id: return False |
| 3613 | if self.n_buffers != other.n_buffers: return False |
| 3614 | if self.n_tables != other.n_tables: return False |
| 3615 | if self.capabilities != other.capabilities: return False |
| 3616 | if self.reserved != other.reserved: return False |
| 3617 | if self.ports != other.ports: return False |
| 3618 | return True |
| 3619 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3620 | def pretty_print(self, q): |
| 3621 | q.text("features_reply {") |
| 3622 | with q.group(): |
| 3623 | with q.indent(2): |
| 3624 | q.breakable() |
| 3625 | q.text("xid = "); |
| 3626 | if self.xid != None: |
| 3627 | q.text("%#x" % self.xid) |
| 3628 | else: |
| 3629 | q.text('None') |
| 3630 | q.text(","); q.breakable() |
| 3631 | q.text("datapath_id = "); |
| 3632 | q.text("%#x" % self.datapath_id) |
| 3633 | q.text(","); q.breakable() |
| 3634 | q.text("n_buffers = "); |
| 3635 | q.text("%#x" % self.n_buffers) |
| 3636 | q.text(","); q.breakable() |
| 3637 | q.text("n_tables = "); |
| 3638 | q.text("%#x" % self.n_tables) |
| 3639 | q.text(","); q.breakable() |
| 3640 | q.text("capabilities = "); |
| 3641 | q.text("%#x" % self.capabilities) |
| 3642 | q.text(","); q.breakable() |
| 3643 | q.text("reserved = "); |
| 3644 | q.text("%#x" % self.reserved) |
| 3645 | q.text(","); q.breakable() |
| 3646 | q.text("ports = "); |
| 3647 | q.pp(self.ports) |
| 3648 | q.breakable() |
| 3649 | q.text('}') |
| 3650 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3651 | message.subtypes[6] = features_reply |
| 3652 | |
| 3653 | class features_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3654 | version = 2 |
| 3655 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3656 | |
| 3657 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3658 | if xid != None: |
| 3659 | self.xid = xid |
| 3660 | else: |
| 3661 | self.xid = None |
| 3662 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3663 | |
| 3664 | def pack(self): |
| 3665 | packed = [] |
| 3666 | packed.append(struct.pack("!B", self.version)) |
| 3667 | packed.append(struct.pack("!B", self.type)) |
| 3668 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3669 | packed.append(struct.pack("!L", self.xid)) |
| 3670 | length = sum([len(x) for x in packed]) |
| 3671 | packed[2] = struct.pack("!H", length) |
| 3672 | return ''.join(packed) |
| 3673 | |
| 3674 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3675 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3676 | obj = features_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3677 | _version = reader.read("!B")[0] |
| 3678 | assert(_version == 2) |
| 3679 | _type = reader.read("!B")[0] |
| 3680 | assert(_type == 5) |
| 3681 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3682 | orig_reader = reader |
| 3683 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3684 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3685 | return obj |
| 3686 | |
| 3687 | def __eq__(self, other): |
| 3688 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3689 | if self.xid != other.xid: return False |
| 3690 | return True |
| 3691 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3692 | def pretty_print(self, q): |
| 3693 | q.text("features_request {") |
| 3694 | with q.group(): |
| 3695 | with q.indent(2): |
| 3696 | q.breakable() |
| 3697 | q.text("xid = "); |
| 3698 | if self.xid != None: |
| 3699 | q.text("%#x" % self.xid) |
| 3700 | else: |
| 3701 | q.text('None') |
| 3702 | q.breakable() |
| 3703 | q.text('}') |
| 3704 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3705 | message.subtypes[5] = features_request |
| 3706 | |
| 3707 | class flow_mod(message): |
| 3708 | subtypes = {} |
| 3709 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3710 | version = 2 |
| 3711 | type = 14 |
| 3712 | |
| 3713 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, _command=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
| 3714 | if xid != None: |
| 3715 | self.xid = xid |
| 3716 | else: |
| 3717 | self.xid = None |
| 3718 | if cookie != None: |
| 3719 | self.cookie = cookie |
| 3720 | else: |
| 3721 | self.cookie = 0 |
| 3722 | if cookie_mask != None: |
| 3723 | self.cookie_mask = cookie_mask |
| 3724 | else: |
| 3725 | self.cookie_mask = 0 |
| 3726 | if table_id != None: |
| 3727 | self.table_id = table_id |
| 3728 | else: |
| 3729 | self.table_id = 0 |
| 3730 | if _command != None: |
| 3731 | self._command = _command |
| 3732 | else: |
| 3733 | self._command = 0 |
| 3734 | if idle_timeout != None: |
| 3735 | self.idle_timeout = idle_timeout |
| 3736 | else: |
| 3737 | self.idle_timeout = 0 |
| 3738 | if hard_timeout != None: |
| 3739 | self.hard_timeout = hard_timeout |
| 3740 | else: |
| 3741 | self.hard_timeout = 0 |
| 3742 | if priority != None: |
| 3743 | self.priority = priority |
| 3744 | else: |
| 3745 | self.priority = 0 |
| 3746 | if buffer_id != None: |
| 3747 | self.buffer_id = buffer_id |
| 3748 | else: |
| 3749 | self.buffer_id = 0 |
| 3750 | if out_port != None: |
| 3751 | self.out_port = out_port |
| 3752 | else: |
| 3753 | self.out_port = 0 |
| 3754 | if out_group != None: |
| 3755 | self.out_group = out_group |
| 3756 | else: |
| 3757 | self.out_group = 0 |
| 3758 | if flags != None: |
| 3759 | self.flags = flags |
| 3760 | else: |
| 3761 | self.flags = 0 |
| 3762 | if match != None: |
| 3763 | self.match = match |
| 3764 | else: |
| 3765 | self.match = common.match() |
| 3766 | if instructions != None: |
| 3767 | self.instructions = instructions |
| 3768 | else: |
| 3769 | self.instructions = [] |
| 3770 | return |
| 3771 | |
| 3772 | def pack(self): |
| 3773 | packed = [] |
| 3774 | packed.append(struct.pack("!B", self.version)) |
| 3775 | packed.append(struct.pack("!B", self.type)) |
| 3776 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3777 | packed.append(struct.pack("!L", self.xid)) |
| 3778 | packed.append(struct.pack("!Q", self.cookie)) |
| 3779 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3780 | packed.append(struct.pack("!B", self.table_id)) |
| 3781 | packed.append(util.pack_fm_cmd(self._command)) |
| 3782 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3783 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3784 | packed.append(struct.pack("!H", self.priority)) |
| 3785 | packed.append(struct.pack("!L", self.buffer_id)) |
| 3786 | packed.append(util.pack_port_no(self.out_port)) |
| 3787 | packed.append(struct.pack("!L", self.out_group)) |
| 3788 | packed.append(struct.pack("!H", self.flags)) |
| 3789 | packed.append('\x00' * 2) |
| 3790 | packed.append(self.match.pack()) |
| 3791 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
| 3792 | length = sum([len(x) for x in packed]) |
| 3793 | packed[2] = struct.pack("!H", length) |
| 3794 | return ''.join(packed) |
| 3795 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3796 | @staticmethod |
| 3797 | def unpack(reader): |
| 3798 | subtype, = reader.peek('B', 25) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3799 | subclass = flow_mod.subtypes.get(subtype) |
| 3800 | if subclass: |
| 3801 | return subclass.unpack(reader) |
| 3802 | |
| 3803 | obj = flow_mod() |
| 3804 | _version = reader.read("!B")[0] |
| 3805 | assert(_version == 2) |
| 3806 | _type = reader.read("!B")[0] |
| 3807 | assert(_type == 14) |
| 3808 | _length = reader.read("!H")[0] |
| 3809 | orig_reader = reader |
| 3810 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3811 | obj.xid = reader.read("!L")[0] |
| 3812 | obj.cookie = reader.read("!Q")[0] |
| 3813 | obj.cookie_mask = reader.read("!Q")[0] |
| 3814 | obj.table_id = reader.read("!B")[0] |
| 3815 | obj._command = util.unpack_fm_cmd(reader) |
| 3816 | obj.idle_timeout = reader.read("!H")[0] |
| 3817 | obj.hard_timeout = reader.read("!H")[0] |
| 3818 | obj.priority = reader.read("!H")[0] |
| 3819 | obj.buffer_id = reader.read("!L")[0] |
| 3820 | obj.out_port = util.unpack_port_no(reader) |
| 3821 | obj.out_group = reader.read("!L")[0] |
| 3822 | obj.flags = reader.read("!H")[0] |
| 3823 | reader.skip(2) |
| 3824 | obj.match = common.match.unpack(reader) |
| 3825 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
| 3826 | return obj |
| 3827 | |
| 3828 | def __eq__(self, other): |
| 3829 | if type(self) != type(other): return False |
| 3830 | if self.xid != other.xid: return False |
| 3831 | if self.cookie != other.cookie: return False |
| 3832 | if self.cookie_mask != other.cookie_mask: return False |
| 3833 | if self.table_id != other.table_id: return False |
| 3834 | if self._command != other._command: return False |
| 3835 | if self.idle_timeout != other.idle_timeout: return False |
| 3836 | if self.hard_timeout != other.hard_timeout: return False |
| 3837 | if self.priority != other.priority: return False |
| 3838 | if self.buffer_id != other.buffer_id: return False |
| 3839 | if self.out_port != other.out_port: return False |
| 3840 | if self.out_group != other.out_group: return False |
| 3841 | if self.flags != other.flags: return False |
| 3842 | if self.match != other.match: return False |
| 3843 | if self.instructions != other.instructions: return False |
| 3844 | return True |
| 3845 | |
| 3846 | def pretty_print(self, q): |
| 3847 | q.text("flow_mod {") |
| 3848 | with q.group(): |
| 3849 | with q.indent(2): |
| 3850 | q.breakable() |
| 3851 | q.text("xid = "); |
| 3852 | if self.xid != None: |
| 3853 | q.text("%#x" % self.xid) |
| 3854 | else: |
| 3855 | q.text('None') |
| 3856 | q.text(","); q.breakable() |
| 3857 | q.text("cookie = "); |
| 3858 | q.text("%#x" % self.cookie) |
| 3859 | q.text(","); q.breakable() |
| 3860 | q.text("cookie_mask = "); |
| 3861 | q.text("%#x" % self.cookie_mask) |
| 3862 | q.text(","); q.breakable() |
| 3863 | q.text("table_id = "); |
| 3864 | q.text("%#x" % self.table_id) |
| 3865 | q.text(","); q.breakable() |
| 3866 | q.text("idle_timeout = "); |
| 3867 | q.text("%#x" % self.idle_timeout) |
| 3868 | q.text(","); q.breakable() |
| 3869 | q.text("hard_timeout = "); |
| 3870 | q.text("%#x" % self.hard_timeout) |
| 3871 | q.text(","); q.breakable() |
| 3872 | q.text("priority = "); |
| 3873 | q.text("%#x" % self.priority) |
| 3874 | q.text(","); q.breakable() |
| 3875 | q.text("buffer_id = "); |
| 3876 | q.text("%#x" % self.buffer_id) |
| 3877 | q.text(","); q.breakable() |
| 3878 | q.text("out_port = "); |
| 3879 | q.text(util.pretty_port(self.out_port)) |
| 3880 | q.text(","); q.breakable() |
| 3881 | q.text("out_group = "); |
| 3882 | q.text("%#x" % self.out_group) |
| 3883 | q.text(","); q.breakable() |
| 3884 | q.text("flags = "); |
| 3885 | q.text("%#x" % self.flags) |
| 3886 | q.text(","); q.breakable() |
| 3887 | q.text("match = "); |
| 3888 | q.pp(self.match) |
| 3889 | q.text(","); q.breakable() |
| 3890 | q.text("instructions = "); |
| 3891 | q.pp(self.instructions) |
| 3892 | q.breakable() |
| 3893 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3894 | |
| 3895 | message.subtypes[14] = flow_mod |
| 3896 | |
| 3897 | class flow_add(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3898 | version = 2 |
| 3899 | type = 14 |
| 3900 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3901 | |
| 3902 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3903 | if xid != None: |
| 3904 | self.xid = xid |
| 3905 | else: |
| 3906 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3907 | if cookie != None: |
| 3908 | self.cookie = cookie |
| 3909 | else: |
| 3910 | self.cookie = 0 |
| 3911 | if cookie_mask != None: |
| 3912 | self.cookie_mask = cookie_mask |
| 3913 | else: |
| 3914 | self.cookie_mask = 0 |
| 3915 | if table_id != None: |
| 3916 | self.table_id = table_id |
| 3917 | else: |
| 3918 | self.table_id = 0 |
| 3919 | if idle_timeout != None: |
| 3920 | self.idle_timeout = idle_timeout |
| 3921 | else: |
| 3922 | self.idle_timeout = 0 |
| 3923 | if hard_timeout != None: |
| 3924 | self.hard_timeout = hard_timeout |
| 3925 | else: |
| 3926 | self.hard_timeout = 0 |
| 3927 | if priority != None: |
| 3928 | self.priority = priority |
| 3929 | else: |
| 3930 | self.priority = 0 |
| 3931 | if buffer_id != None: |
| 3932 | self.buffer_id = buffer_id |
| 3933 | else: |
| 3934 | self.buffer_id = 0 |
| 3935 | if out_port != None: |
| 3936 | self.out_port = out_port |
| 3937 | else: |
| 3938 | self.out_port = 0 |
| 3939 | if out_group != None: |
| 3940 | self.out_group = out_group |
| 3941 | else: |
| 3942 | self.out_group = 0 |
| 3943 | if flags != None: |
| 3944 | self.flags = flags |
| 3945 | else: |
| 3946 | self.flags = 0 |
| 3947 | if match != None: |
| 3948 | self.match = match |
| 3949 | else: |
| 3950 | self.match = common.match() |
| 3951 | if instructions != None: |
| 3952 | self.instructions = instructions |
| 3953 | else: |
| 3954 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3955 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3956 | |
| 3957 | def pack(self): |
| 3958 | packed = [] |
| 3959 | packed.append(struct.pack("!B", self.version)) |
| 3960 | packed.append(struct.pack("!B", self.type)) |
| 3961 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3962 | packed.append(struct.pack("!L", self.xid)) |
| 3963 | packed.append(struct.pack("!Q", self.cookie)) |
| 3964 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3965 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3966 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3967 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3968 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3969 | packed.append(struct.pack("!H", self.priority)) |
| 3970 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3971 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3972 | packed.append(struct.pack("!L", self.out_group)) |
| 3973 | packed.append(struct.pack("!H", self.flags)) |
| 3974 | packed.append('\x00' * 2) |
| 3975 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3976 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3977 | length = sum([len(x) for x in packed]) |
| 3978 | packed[2] = struct.pack("!H", length) |
| 3979 | return ''.join(packed) |
| 3980 | |
| 3981 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3982 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3983 | obj = flow_add() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3984 | _version = reader.read("!B")[0] |
| 3985 | assert(_version == 2) |
| 3986 | _type = reader.read("!B")[0] |
| 3987 | assert(_type == 14) |
| 3988 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3989 | orig_reader = reader |
| 3990 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3991 | obj.xid = reader.read("!L")[0] |
| 3992 | obj.cookie = reader.read("!Q")[0] |
| 3993 | obj.cookie_mask = reader.read("!Q")[0] |
| 3994 | obj.table_id = reader.read("!B")[0] |
| 3995 | __command = util.unpack_fm_cmd(reader) |
| 3996 | assert(__command == 0) |
| 3997 | obj.idle_timeout = reader.read("!H")[0] |
| 3998 | obj.hard_timeout = reader.read("!H")[0] |
| 3999 | obj.priority = reader.read("!H")[0] |
| 4000 | obj.buffer_id = reader.read("!L")[0] |
| 4001 | obj.out_port = util.unpack_port_no(reader) |
| 4002 | obj.out_group = reader.read("!L")[0] |
| 4003 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4004 | reader.skip(2) |
| 4005 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4006 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4007 | return obj |
| 4008 | |
| 4009 | def __eq__(self, other): |
| 4010 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4011 | if self.xid != other.xid: return False |
| 4012 | if self.cookie != other.cookie: return False |
| 4013 | if self.cookie_mask != other.cookie_mask: return False |
| 4014 | if self.table_id != other.table_id: return False |
| 4015 | if self.idle_timeout != other.idle_timeout: return False |
| 4016 | if self.hard_timeout != other.hard_timeout: return False |
| 4017 | if self.priority != other.priority: return False |
| 4018 | if self.buffer_id != other.buffer_id: return False |
| 4019 | if self.out_port != other.out_port: return False |
| 4020 | if self.out_group != other.out_group: return False |
| 4021 | if self.flags != other.flags: return False |
| 4022 | if self.match != other.match: return False |
| 4023 | if self.instructions != other.instructions: return False |
| 4024 | return True |
| 4025 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4026 | def pretty_print(self, q): |
| 4027 | q.text("flow_add {") |
| 4028 | with q.group(): |
| 4029 | with q.indent(2): |
| 4030 | q.breakable() |
| 4031 | q.text("xid = "); |
| 4032 | if self.xid != None: |
| 4033 | q.text("%#x" % self.xid) |
| 4034 | else: |
| 4035 | q.text('None') |
| 4036 | q.text(","); q.breakable() |
| 4037 | q.text("cookie = "); |
| 4038 | q.text("%#x" % self.cookie) |
| 4039 | q.text(","); q.breakable() |
| 4040 | q.text("cookie_mask = "); |
| 4041 | q.text("%#x" % self.cookie_mask) |
| 4042 | q.text(","); q.breakable() |
| 4043 | q.text("table_id = "); |
| 4044 | q.text("%#x" % self.table_id) |
| 4045 | q.text(","); q.breakable() |
| 4046 | q.text("idle_timeout = "); |
| 4047 | q.text("%#x" % self.idle_timeout) |
| 4048 | q.text(","); q.breakable() |
| 4049 | q.text("hard_timeout = "); |
| 4050 | q.text("%#x" % self.hard_timeout) |
| 4051 | q.text(","); q.breakable() |
| 4052 | q.text("priority = "); |
| 4053 | q.text("%#x" % self.priority) |
| 4054 | q.text(","); q.breakable() |
| 4055 | q.text("buffer_id = "); |
| 4056 | q.text("%#x" % self.buffer_id) |
| 4057 | q.text(","); q.breakable() |
| 4058 | q.text("out_port = "); |
| 4059 | q.text(util.pretty_port(self.out_port)) |
| 4060 | q.text(","); q.breakable() |
| 4061 | q.text("out_group = "); |
| 4062 | q.text("%#x" % self.out_group) |
| 4063 | q.text(","); q.breakable() |
| 4064 | q.text("flags = "); |
| 4065 | q.text("%#x" % self.flags) |
| 4066 | q.text(","); q.breakable() |
| 4067 | q.text("match = "); |
| 4068 | q.pp(self.match) |
| 4069 | q.text(","); q.breakable() |
| 4070 | q.text("instructions = "); |
| 4071 | q.pp(self.instructions) |
| 4072 | q.breakable() |
| 4073 | q.text('}') |
| 4074 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4075 | flow_mod.subtypes[0] = flow_add |
| 4076 | |
| 4077 | class flow_delete(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4078 | version = 2 |
| 4079 | type = 14 |
| 4080 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4081 | |
| 4082 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4083 | if xid != None: |
| 4084 | self.xid = xid |
| 4085 | else: |
| 4086 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4087 | if cookie != None: |
| 4088 | self.cookie = cookie |
| 4089 | else: |
| 4090 | self.cookie = 0 |
| 4091 | if cookie_mask != None: |
| 4092 | self.cookie_mask = cookie_mask |
| 4093 | else: |
| 4094 | self.cookie_mask = 0 |
| 4095 | if table_id != None: |
| 4096 | self.table_id = table_id |
| 4097 | else: |
| 4098 | self.table_id = 0 |
| 4099 | if idle_timeout != None: |
| 4100 | self.idle_timeout = idle_timeout |
| 4101 | else: |
| 4102 | self.idle_timeout = 0 |
| 4103 | if hard_timeout != None: |
| 4104 | self.hard_timeout = hard_timeout |
| 4105 | else: |
| 4106 | self.hard_timeout = 0 |
| 4107 | if priority != None: |
| 4108 | self.priority = priority |
| 4109 | else: |
| 4110 | self.priority = 0 |
| 4111 | if buffer_id != None: |
| 4112 | self.buffer_id = buffer_id |
| 4113 | else: |
| 4114 | self.buffer_id = 0 |
| 4115 | if out_port != None: |
| 4116 | self.out_port = out_port |
| 4117 | else: |
| 4118 | self.out_port = 0 |
| 4119 | if out_group != None: |
| 4120 | self.out_group = out_group |
| 4121 | else: |
| 4122 | self.out_group = 0 |
| 4123 | if flags != None: |
| 4124 | self.flags = flags |
| 4125 | else: |
| 4126 | self.flags = 0 |
| 4127 | if match != None: |
| 4128 | self.match = match |
| 4129 | else: |
| 4130 | self.match = common.match() |
| 4131 | if instructions != None: |
| 4132 | self.instructions = instructions |
| 4133 | else: |
| 4134 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4135 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4136 | |
| 4137 | def pack(self): |
| 4138 | packed = [] |
| 4139 | packed.append(struct.pack("!B", self.version)) |
| 4140 | packed.append(struct.pack("!B", self.type)) |
| 4141 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4142 | packed.append(struct.pack("!L", self.xid)) |
| 4143 | packed.append(struct.pack("!Q", self.cookie)) |
| 4144 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4145 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4146 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4147 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4148 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4149 | packed.append(struct.pack("!H", self.priority)) |
| 4150 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4151 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4152 | packed.append(struct.pack("!L", self.out_group)) |
| 4153 | packed.append(struct.pack("!H", self.flags)) |
| 4154 | packed.append('\x00' * 2) |
| 4155 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4156 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4157 | length = sum([len(x) for x in packed]) |
| 4158 | packed[2] = struct.pack("!H", length) |
| 4159 | return ''.join(packed) |
| 4160 | |
| 4161 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4162 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4163 | obj = flow_delete() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4164 | _version = reader.read("!B")[0] |
| 4165 | assert(_version == 2) |
| 4166 | _type = reader.read("!B")[0] |
| 4167 | assert(_type == 14) |
| 4168 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4169 | orig_reader = reader |
| 4170 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4171 | obj.xid = reader.read("!L")[0] |
| 4172 | obj.cookie = reader.read("!Q")[0] |
| 4173 | obj.cookie_mask = reader.read("!Q")[0] |
| 4174 | obj.table_id = reader.read("!B")[0] |
| 4175 | __command = util.unpack_fm_cmd(reader) |
| 4176 | assert(__command == 3) |
| 4177 | obj.idle_timeout = reader.read("!H")[0] |
| 4178 | obj.hard_timeout = reader.read("!H")[0] |
| 4179 | obj.priority = reader.read("!H")[0] |
| 4180 | obj.buffer_id = reader.read("!L")[0] |
| 4181 | obj.out_port = util.unpack_port_no(reader) |
| 4182 | obj.out_group = reader.read("!L")[0] |
| 4183 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4184 | reader.skip(2) |
| 4185 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4186 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4187 | return obj |
| 4188 | |
| 4189 | def __eq__(self, other): |
| 4190 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4191 | if self.xid != other.xid: return False |
| 4192 | if self.cookie != other.cookie: return False |
| 4193 | if self.cookie_mask != other.cookie_mask: return False |
| 4194 | if self.table_id != other.table_id: return False |
| 4195 | if self.idle_timeout != other.idle_timeout: return False |
| 4196 | if self.hard_timeout != other.hard_timeout: return False |
| 4197 | if self.priority != other.priority: return False |
| 4198 | if self.buffer_id != other.buffer_id: return False |
| 4199 | if self.out_port != other.out_port: return False |
| 4200 | if self.out_group != other.out_group: return False |
| 4201 | if self.flags != other.flags: return False |
| 4202 | if self.match != other.match: return False |
| 4203 | if self.instructions != other.instructions: return False |
| 4204 | return True |
| 4205 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4206 | def pretty_print(self, q): |
| 4207 | q.text("flow_delete {") |
| 4208 | with q.group(): |
| 4209 | with q.indent(2): |
| 4210 | q.breakable() |
| 4211 | q.text("xid = "); |
| 4212 | if self.xid != None: |
| 4213 | q.text("%#x" % self.xid) |
| 4214 | else: |
| 4215 | q.text('None') |
| 4216 | q.text(","); q.breakable() |
| 4217 | q.text("cookie = "); |
| 4218 | q.text("%#x" % self.cookie) |
| 4219 | q.text(","); q.breakable() |
| 4220 | q.text("cookie_mask = "); |
| 4221 | q.text("%#x" % self.cookie_mask) |
| 4222 | q.text(","); q.breakable() |
| 4223 | q.text("table_id = "); |
| 4224 | q.text("%#x" % self.table_id) |
| 4225 | q.text(","); q.breakable() |
| 4226 | q.text("idle_timeout = "); |
| 4227 | q.text("%#x" % self.idle_timeout) |
| 4228 | q.text(","); q.breakable() |
| 4229 | q.text("hard_timeout = "); |
| 4230 | q.text("%#x" % self.hard_timeout) |
| 4231 | q.text(","); q.breakable() |
| 4232 | q.text("priority = "); |
| 4233 | q.text("%#x" % self.priority) |
| 4234 | q.text(","); q.breakable() |
| 4235 | q.text("buffer_id = "); |
| 4236 | q.text("%#x" % self.buffer_id) |
| 4237 | q.text(","); q.breakable() |
| 4238 | q.text("out_port = "); |
| 4239 | q.text(util.pretty_port(self.out_port)) |
| 4240 | q.text(","); q.breakable() |
| 4241 | q.text("out_group = "); |
| 4242 | q.text("%#x" % self.out_group) |
| 4243 | q.text(","); q.breakable() |
| 4244 | q.text("flags = "); |
| 4245 | q.text("%#x" % self.flags) |
| 4246 | q.text(","); q.breakable() |
| 4247 | q.text("match = "); |
| 4248 | q.pp(self.match) |
| 4249 | q.text(","); q.breakable() |
| 4250 | q.text("instructions = "); |
| 4251 | q.pp(self.instructions) |
| 4252 | q.breakable() |
| 4253 | q.text('}') |
| 4254 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4255 | flow_mod.subtypes[3] = flow_delete |
| 4256 | |
| 4257 | class flow_delete_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4258 | version = 2 |
| 4259 | type = 14 |
| 4260 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4261 | |
| 4262 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4263 | if xid != None: |
| 4264 | self.xid = xid |
| 4265 | else: |
| 4266 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4267 | if cookie != None: |
| 4268 | self.cookie = cookie |
| 4269 | else: |
| 4270 | self.cookie = 0 |
| 4271 | if cookie_mask != None: |
| 4272 | self.cookie_mask = cookie_mask |
| 4273 | else: |
| 4274 | self.cookie_mask = 0 |
| 4275 | if table_id != None: |
| 4276 | self.table_id = table_id |
| 4277 | else: |
| 4278 | self.table_id = 0 |
| 4279 | if idle_timeout != None: |
| 4280 | self.idle_timeout = idle_timeout |
| 4281 | else: |
| 4282 | self.idle_timeout = 0 |
| 4283 | if hard_timeout != None: |
| 4284 | self.hard_timeout = hard_timeout |
| 4285 | else: |
| 4286 | self.hard_timeout = 0 |
| 4287 | if priority != None: |
| 4288 | self.priority = priority |
| 4289 | else: |
| 4290 | self.priority = 0 |
| 4291 | if buffer_id != None: |
| 4292 | self.buffer_id = buffer_id |
| 4293 | else: |
| 4294 | self.buffer_id = 0 |
| 4295 | if out_port != None: |
| 4296 | self.out_port = out_port |
| 4297 | else: |
| 4298 | self.out_port = 0 |
| 4299 | if out_group != None: |
| 4300 | self.out_group = out_group |
| 4301 | else: |
| 4302 | self.out_group = 0 |
| 4303 | if flags != None: |
| 4304 | self.flags = flags |
| 4305 | else: |
| 4306 | self.flags = 0 |
| 4307 | if match != None: |
| 4308 | self.match = match |
| 4309 | else: |
| 4310 | self.match = common.match() |
| 4311 | if instructions != None: |
| 4312 | self.instructions = instructions |
| 4313 | else: |
| 4314 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4315 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4316 | |
| 4317 | def pack(self): |
| 4318 | packed = [] |
| 4319 | packed.append(struct.pack("!B", self.version)) |
| 4320 | packed.append(struct.pack("!B", self.type)) |
| 4321 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4322 | packed.append(struct.pack("!L", self.xid)) |
| 4323 | packed.append(struct.pack("!Q", self.cookie)) |
| 4324 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4325 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4326 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4327 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4328 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4329 | packed.append(struct.pack("!H", self.priority)) |
| 4330 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4331 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4332 | packed.append(struct.pack("!L", self.out_group)) |
| 4333 | packed.append(struct.pack("!H", self.flags)) |
| 4334 | packed.append('\x00' * 2) |
| 4335 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4336 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4337 | length = sum([len(x) for x in packed]) |
| 4338 | packed[2] = struct.pack("!H", length) |
| 4339 | return ''.join(packed) |
| 4340 | |
| 4341 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4342 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4343 | obj = flow_delete_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4344 | _version = reader.read("!B")[0] |
| 4345 | assert(_version == 2) |
| 4346 | _type = reader.read("!B")[0] |
| 4347 | assert(_type == 14) |
| 4348 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4349 | orig_reader = reader |
| 4350 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4351 | obj.xid = reader.read("!L")[0] |
| 4352 | obj.cookie = reader.read("!Q")[0] |
| 4353 | obj.cookie_mask = reader.read("!Q")[0] |
| 4354 | obj.table_id = reader.read("!B")[0] |
| 4355 | __command = util.unpack_fm_cmd(reader) |
| 4356 | assert(__command == 4) |
| 4357 | obj.idle_timeout = reader.read("!H")[0] |
| 4358 | obj.hard_timeout = reader.read("!H")[0] |
| 4359 | obj.priority = reader.read("!H")[0] |
| 4360 | obj.buffer_id = reader.read("!L")[0] |
| 4361 | obj.out_port = util.unpack_port_no(reader) |
| 4362 | obj.out_group = reader.read("!L")[0] |
| 4363 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4364 | reader.skip(2) |
| 4365 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4366 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4367 | return obj |
| 4368 | |
| 4369 | def __eq__(self, other): |
| 4370 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4371 | if self.xid != other.xid: return False |
| 4372 | if self.cookie != other.cookie: return False |
| 4373 | if self.cookie_mask != other.cookie_mask: return False |
| 4374 | if self.table_id != other.table_id: return False |
| 4375 | if self.idle_timeout != other.idle_timeout: return False |
| 4376 | if self.hard_timeout != other.hard_timeout: return False |
| 4377 | if self.priority != other.priority: return False |
| 4378 | if self.buffer_id != other.buffer_id: return False |
| 4379 | if self.out_port != other.out_port: return False |
| 4380 | if self.out_group != other.out_group: return False |
| 4381 | if self.flags != other.flags: return False |
| 4382 | if self.match != other.match: return False |
| 4383 | if self.instructions != other.instructions: return False |
| 4384 | return True |
| 4385 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4386 | def pretty_print(self, q): |
| 4387 | q.text("flow_delete_strict {") |
| 4388 | with q.group(): |
| 4389 | with q.indent(2): |
| 4390 | q.breakable() |
| 4391 | q.text("xid = "); |
| 4392 | if self.xid != None: |
| 4393 | q.text("%#x" % self.xid) |
| 4394 | else: |
| 4395 | q.text('None') |
| 4396 | q.text(","); q.breakable() |
| 4397 | q.text("cookie = "); |
| 4398 | q.text("%#x" % self.cookie) |
| 4399 | q.text(","); q.breakable() |
| 4400 | q.text("cookie_mask = "); |
| 4401 | q.text("%#x" % self.cookie_mask) |
| 4402 | q.text(","); q.breakable() |
| 4403 | q.text("table_id = "); |
| 4404 | q.text("%#x" % self.table_id) |
| 4405 | q.text(","); q.breakable() |
| 4406 | q.text("idle_timeout = "); |
| 4407 | q.text("%#x" % self.idle_timeout) |
| 4408 | q.text(","); q.breakable() |
| 4409 | q.text("hard_timeout = "); |
| 4410 | q.text("%#x" % self.hard_timeout) |
| 4411 | q.text(","); q.breakable() |
| 4412 | q.text("priority = "); |
| 4413 | q.text("%#x" % self.priority) |
| 4414 | q.text(","); q.breakable() |
| 4415 | q.text("buffer_id = "); |
| 4416 | q.text("%#x" % self.buffer_id) |
| 4417 | q.text(","); q.breakable() |
| 4418 | q.text("out_port = "); |
| 4419 | q.text(util.pretty_port(self.out_port)) |
| 4420 | q.text(","); q.breakable() |
| 4421 | q.text("out_group = "); |
| 4422 | q.text("%#x" % self.out_group) |
| 4423 | q.text(","); q.breakable() |
| 4424 | q.text("flags = "); |
| 4425 | q.text("%#x" % self.flags) |
| 4426 | q.text(","); q.breakable() |
| 4427 | q.text("match = "); |
| 4428 | q.pp(self.match) |
| 4429 | q.text(","); q.breakable() |
| 4430 | q.text("instructions = "); |
| 4431 | q.pp(self.instructions) |
| 4432 | q.breakable() |
| 4433 | q.text('}') |
| 4434 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4435 | flow_mod.subtypes[4] = flow_delete_strict |
| 4436 | |
| 4437 | class flow_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4438 | version = 2 |
| 4439 | type = 1 |
| 4440 | err_type = 5 |
| 4441 | |
| 4442 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4443 | if xid != None: |
| 4444 | self.xid = xid |
| 4445 | else: |
| 4446 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4447 | if code != None: |
| 4448 | self.code = code |
| 4449 | else: |
| 4450 | self.code = 0 |
| 4451 | if data != None: |
| 4452 | self.data = data |
| 4453 | else: |
| 4454 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4455 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4456 | |
| 4457 | def pack(self): |
| 4458 | packed = [] |
| 4459 | packed.append(struct.pack("!B", self.version)) |
| 4460 | packed.append(struct.pack("!B", self.type)) |
| 4461 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4462 | packed.append(struct.pack("!L", self.xid)) |
| 4463 | packed.append(struct.pack("!H", self.err_type)) |
| 4464 | packed.append(struct.pack("!H", self.code)) |
| 4465 | packed.append(self.data) |
| 4466 | length = sum([len(x) for x in packed]) |
| 4467 | packed[2] = struct.pack("!H", length) |
| 4468 | return ''.join(packed) |
| 4469 | |
| 4470 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4471 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4472 | obj = flow_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4473 | _version = reader.read("!B")[0] |
| 4474 | assert(_version == 2) |
| 4475 | _type = reader.read("!B")[0] |
| 4476 | assert(_type == 1) |
| 4477 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4478 | orig_reader = reader |
| 4479 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4480 | obj.xid = reader.read("!L")[0] |
| 4481 | _err_type = reader.read("!H")[0] |
| 4482 | assert(_err_type == 5) |
| 4483 | obj.code = reader.read("!H")[0] |
| 4484 | obj.data = str(reader.read_all()) |
| 4485 | return obj |
| 4486 | |
| 4487 | def __eq__(self, other): |
| 4488 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4489 | if self.xid != other.xid: return False |
| 4490 | if self.code != other.code: return False |
| 4491 | if self.data != other.data: return False |
| 4492 | return True |
| 4493 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4494 | def pretty_print(self, q): |
| 4495 | q.text("flow_mod_failed_error_msg {") |
| 4496 | with q.group(): |
| 4497 | with q.indent(2): |
| 4498 | q.breakable() |
| 4499 | q.text("xid = "); |
| 4500 | if self.xid != None: |
| 4501 | q.text("%#x" % self.xid) |
| 4502 | else: |
| 4503 | q.text('None') |
| 4504 | q.text(","); q.breakable() |
| 4505 | q.text("code = "); |
| 4506 | q.text("%#x" % self.code) |
| 4507 | q.text(","); q.breakable() |
| 4508 | q.text("data = "); |
| 4509 | q.pp(self.data) |
| 4510 | q.breakable() |
| 4511 | q.text('}') |
| 4512 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4513 | error_msg.subtypes[5] = flow_mod_failed_error_msg |
| 4514 | |
| 4515 | class flow_modify(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4516 | version = 2 |
| 4517 | type = 14 |
| 4518 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4519 | |
| 4520 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4521 | if xid != None: |
| 4522 | self.xid = xid |
| 4523 | else: |
| 4524 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4525 | if cookie != None: |
| 4526 | self.cookie = cookie |
| 4527 | else: |
| 4528 | self.cookie = 0 |
| 4529 | if cookie_mask != None: |
| 4530 | self.cookie_mask = cookie_mask |
| 4531 | else: |
| 4532 | self.cookie_mask = 0 |
| 4533 | if table_id != None: |
| 4534 | self.table_id = table_id |
| 4535 | else: |
| 4536 | self.table_id = 0 |
| 4537 | if idle_timeout != None: |
| 4538 | self.idle_timeout = idle_timeout |
| 4539 | else: |
| 4540 | self.idle_timeout = 0 |
| 4541 | if hard_timeout != None: |
| 4542 | self.hard_timeout = hard_timeout |
| 4543 | else: |
| 4544 | self.hard_timeout = 0 |
| 4545 | if priority != None: |
| 4546 | self.priority = priority |
| 4547 | else: |
| 4548 | self.priority = 0 |
| 4549 | if buffer_id != None: |
| 4550 | self.buffer_id = buffer_id |
| 4551 | else: |
| 4552 | self.buffer_id = 0 |
| 4553 | if out_port != None: |
| 4554 | self.out_port = out_port |
| 4555 | else: |
| 4556 | self.out_port = 0 |
| 4557 | if out_group != None: |
| 4558 | self.out_group = out_group |
| 4559 | else: |
| 4560 | self.out_group = 0 |
| 4561 | if flags != None: |
| 4562 | self.flags = flags |
| 4563 | else: |
| 4564 | self.flags = 0 |
| 4565 | if match != None: |
| 4566 | self.match = match |
| 4567 | else: |
| 4568 | self.match = common.match() |
| 4569 | if instructions != None: |
| 4570 | self.instructions = instructions |
| 4571 | else: |
| 4572 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4573 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4574 | |
| 4575 | def pack(self): |
| 4576 | packed = [] |
| 4577 | packed.append(struct.pack("!B", self.version)) |
| 4578 | packed.append(struct.pack("!B", self.type)) |
| 4579 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4580 | packed.append(struct.pack("!L", self.xid)) |
| 4581 | packed.append(struct.pack("!Q", self.cookie)) |
| 4582 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4583 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4584 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4585 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4586 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4587 | packed.append(struct.pack("!H", self.priority)) |
| 4588 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4589 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4590 | packed.append(struct.pack("!L", self.out_group)) |
| 4591 | packed.append(struct.pack("!H", self.flags)) |
| 4592 | packed.append('\x00' * 2) |
| 4593 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4594 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4595 | length = sum([len(x) for x in packed]) |
| 4596 | packed[2] = struct.pack("!H", length) |
| 4597 | return ''.join(packed) |
| 4598 | |
| 4599 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4600 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4601 | obj = flow_modify() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4602 | _version = reader.read("!B")[0] |
| 4603 | assert(_version == 2) |
| 4604 | _type = reader.read("!B")[0] |
| 4605 | assert(_type == 14) |
| 4606 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4607 | orig_reader = reader |
| 4608 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4609 | obj.xid = reader.read("!L")[0] |
| 4610 | obj.cookie = reader.read("!Q")[0] |
| 4611 | obj.cookie_mask = reader.read("!Q")[0] |
| 4612 | obj.table_id = reader.read("!B")[0] |
| 4613 | __command = util.unpack_fm_cmd(reader) |
| 4614 | assert(__command == 1) |
| 4615 | obj.idle_timeout = reader.read("!H")[0] |
| 4616 | obj.hard_timeout = reader.read("!H")[0] |
| 4617 | obj.priority = reader.read("!H")[0] |
| 4618 | obj.buffer_id = reader.read("!L")[0] |
| 4619 | obj.out_port = util.unpack_port_no(reader) |
| 4620 | obj.out_group = reader.read("!L")[0] |
| 4621 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4622 | reader.skip(2) |
| 4623 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4624 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4625 | return obj |
| 4626 | |
| 4627 | def __eq__(self, other): |
| 4628 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4629 | if self.xid != other.xid: return False |
| 4630 | if self.cookie != other.cookie: return False |
| 4631 | if self.cookie_mask != other.cookie_mask: return False |
| 4632 | if self.table_id != other.table_id: return False |
| 4633 | if self.idle_timeout != other.idle_timeout: return False |
| 4634 | if self.hard_timeout != other.hard_timeout: return False |
| 4635 | if self.priority != other.priority: return False |
| 4636 | if self.buffer_id != other.buffer_id: return False |
| 4637 | if self.out_port != other.out_port: return False |
| 4638 | if self.out_group != other.out_group: return False |
| 4639 | if self.flags != other.flags: return False |
| 4640 | if self.match != other.match: return False |
| 4641 | if self.instructions != other.instructions: return False |
| 4642 | return True |
| 4643 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4644 | def pretty_print(self, q): |
| 4645 | q.text("flow_modify {") |
| 4646 | with q.group(): |
| 4647 | with q.indent(2): |
| 4648 | q.breakable() |
| 4649 | q.text("xid = "); |
| 4650 | if self.xid != None: |
| 4651 | q.text("%#x" % self.xid) |
| 4652 | else: |
| 4653 | q.text('None') |
| 4654 | q.text(","); q.breakable() |
| 4655 | q.text("cookie = "); |
| 4656 | q.text("%#x" % self.cookie) |
| 4657 | q.text(","); q.breakable() |
| 4658 | q.text("cookie_mask = "); |
| 4659 | q.text("%#x" % self.cookie_mask) |
| 4660 | q.text(","); q.breakable() |
| 4661 | q.text("table_id = "); |
| 4662 | q.text("%#x" % self.table_id) |
| 4663 | q.text(","); q.breakable() |
| 4664 | q.text("idle_timeout = "); |
| 4665 | q.text("%#x" % self.idle_timeout) |
| 4666 | q.text(","); q.breakable() |
| 4667 | q.text("hard_timeout = "); |
| 4668 | q.text("%#x" % self.hard_timeout) |
| 4669 | q.text(","); q.breakable() |
| 4670 | q.text("priority = "); |
| 4671 | q.text("%#x" % self.priority) |
| 4672 | q.text(","); q.breakable() |
| 4673 | q.text("buffer_id = "); |
| 4674 | q.text("%#x" % self.buffer_id) |
| 4675 | q.text(","); q.breakable() |
| 4676 | q.text("out_port = "); |
| 4677 | q.text(util.pretty_port(self.out_port)) |
| 4678 | q.text(","); q.breakable() |
| 4679 | q.text("out_group = "); |
| 4680 | q.text("%#x" % self.out_group) |
| 4681 | q.text(","); q.breakable() |
| 4682 | q.text("flags = "); |
| 4683 | q.text("%#x" % self.flags) |
| 4684 | q.text(","); q.breakable() |
| 4685 | q.text("match = "); |
| 4686 | q.pp(self.match) |
| 4687 | q.text(","); q.breakable() |
| 4688 | q.text("instructions = "); |
| 4689 | q.pp(self.instructions) |
| 4690 | q.breakable() |
| 4691 | q.text('}') |
| 4692 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4693 | flow_mod.subtypes[1] = flow_modify |
| 4694 | |
| 4695 | class flow_modify_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4696 | version = 2 |
| 4697 | type = 14 |
| 4698 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4699 | |
| 4700 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4701 | if xid != None: |
| 4702 | self.xid = xid |
| 4703 | else: |
| 4704 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4705 | if cookie != None: |
| 4706 | self.cookie = cookie |
| 4707 | else: |
| 4708 | self.cookie = 0 |
| 4709 | if cookie_mask != None: |
| 4710 | self.cookie_mask = cookie_mask |
| 4711 | else: |
| 4712 | self.cookie_mask = 0 |
| 4713 | if table_id != None: |
| 4714 | self.table_id = table_id |
| 4715 | else: |
| 4716 | self.table_id = 0 |
| 4717 | if idle_timeout != None: |
| 4718 | self.idle_timeout = idle_timeout |
| 4719 | else: |
| 4720 | self.idle_timeout = 0 |
| 4721 | if hard_timeout != None: |
| 4722 | self.hard_timeout = hard_timeout |
| 4723 | else: |
| 4724 | self.hard_timeout = 0 |
| 4725 | if priority != None: |
| 4726 | self.priority = priority |
| 4727 | else: |
| 4728 | self.priority = 0 |
| 4729 | if buffer_id != None: |
| 4730 | self.buffer_id = buffer_id |
| 4731 | else: |
| 4732 | self.buffer_id = 0 |
| 4733 | if out_port != None: |
| 4734 | self.out_port = out_port |
| 4735 | else: |
| 4736 | self.out_port = 0 |
| 4737 | if out_group != None: |
| 4738 | self.out_group = out_group |
| 4739 | else: |
| 4740 | self.out_group = 0 |
| 4741 | if flags != None: |
| 4742 | self.flags = flags |
| 4743 | else: |
| 4744 | self.flags = 0 |
| 4745 | if match != None: |
| 4746 | self.match = match |
| 4747 | else: |
| 4748 | self.match = common.match() |
| 4749 | if instructions != None: |
| 4750 | self.instructions = instructions |
| 4751 | else: |
| 4752 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4753 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4754 | |
| 4755 | def pack(self): |
| 4756 | packed = [] |
| 4757 | packed.append(struct.pack("!B", self.version)) |
| 4758 | packed.append(struct.pack("!B", self.type)) |
| 4759 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4760 | packed.append(struct.pack("!L", self.xid)) |
| 4761 | packed.append(struct.pack("!Q", self.cookie)) |
| 4762 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4763 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4764 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4765 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4766 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4767 | packed.append(struct.pack("!H", self.priority)) |
| 4768 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4769 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4770 | packed.append(struct.pack("!L", self.out_group)) |
| 4771 | packed.append(struct.pack("!H", self.flags)) |
| 4772 | packed.append('\x00' * 2) |
| 4773 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4774 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4775 | length = sum([len(x) for x in packed]) |
| 4776 | packed[2] = struct.pack("!H", length) |
| 4777 | return ''.join(packed) |
| 4778 | |
| 4779 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4780 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4781 | obj = flow_modify_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4782 | _version = reader.read("!B")[0] |
| 4783 | assert(_version == 2) |
| 4784 | _type = reader.read("!B")[0] |
| 4785 | assert(_type == 14) |
| 4786 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4787 | orig_reader = reader |
| 4788 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4789 | obj.xid = reader.read("!L")[0] |
| 4790 | obj.cookie = reader.read("!Q")[0] |
| 4791 | obj.cookie_mask = reader.read("!Q")[0] |
| 4792 | obj.table_id = reader.read("!B")[0] |
| 4793 | __command = util.unpack_fm_cmd(reader) |
| 4794 | assert(__command == 2) |
| 4795 | obj.idle_timeout = reader.read("!H")[0] |
| 4796 | obj.hard_timeout = reader.read("!H")[0] |
| 4797 | obj.priority = reader.read("!H")[0] |
| 4798 | obj.buffer_id = reader.read("!L")[0] |
| 4799 | obj.out_port = util.unpack_port_no(reader) |
| 4800 | obj.out_group = reader.read("!L")[0] |
| 4801 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4802 | reader.skip(2) |
| 4803 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4804 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4805 | return obj |
| 4806 | |
| 4807 | def __eq__(self, other): |
| 4808 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4809 | if self.xid != other.xid: return False |
| 4810 | if self.cookie != other.cookie: return False |
| 4811 | if self.cookie_mask != other.cookie_mask: return False |
| 4812 | if self.table_id != other.table_id: return False |
| 4813 | if self.idle_timeout != other.idle_timeout: return False |
| 4814 | if self.hard_timeout != other.hard_timeout: return False |
| 4815 | if self.priority != other.priority: return False |
| 4816 | if self.buffer_id != other.buffer_id: return False |
| 4817 | if self.out_port != other.out_port: return False |
| 4818 | if self.out_group != other.out_group: return False |
| 4819 | if self.flags != other.flags: return False |
| 4820 | if self.match != other.match: return False |
| 4821 | if self.instructions != other.instructions: return False |
| 4822 | return True |
| 4823 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4824 | def pretty_print(self, q): |
| 4825 | q.text("flow_modify_strict {") |
| 4826 | with q.group(): |
| 4827 | with q.indent(2): |
| 4828 | q.breakable() |
| 4829 | q.text("xid = "); |
| 4830 | if self.xid != None: |
| 4831 | q.text("%#x" % self.xid) |
| 4832 | else: |
| 4833 | q.text('None') |
| 4834 | q.text(","); q.breakable() |
| 4835 | q.text("cookie = "); |
| 4836 | q.text("%#x" % self.cookie) |
| 4837 | q.text(","); q.breakable() |
| 4838 | q.text("cookie_mask = "); |
| 4839 | q.text("%#x" % self.cookie_mask) |
| 4840 | q.text(","); q.breakable() |
| 4841 | q.text("table_id = "); |
| 4842 | q.text("%#x" % self.table_id) |
| 4843 | q.text(","); q.breakable() |
| 4844 | q.text("idle_timeout = "); |
| 4845 | q.text("%#x" % self.idle_timeout) |
| 4846 | q.text(","); q.breakable() |
| 4847 | q.text("hard_timeout = "); |
| 4848 | q.text("%#x" % self.hard_timeout) |
| 4849 | q.text(","); q.breakable() |
| 4850 | q.text("priority = "); |
| 4851 | q.text("%#x" % self.priority) |
| 4852 | q.text(","); q.breakable() |
| 4853 | q.text("buffer_id = "); |
| 4854 | q.text("%#x" % self.buffer_id) |
| 4855 | q.text(","); q.breakable() |
| 4856 | q.text("out_port = "); |
| 4857 | q.text(util.pretty_port(self.out_port)) |
| 4858 | q.text(","); q.breakable() |
| 4859 | q.text("out_group = "); |
| 4860 | q.text("%#x" % self.out_group) |
| 4861 | q.text(","); q.breakable() |
| 4862 | q.text("flags = "); |
| 4863 | q.text("%#x" % self.flags) |
| 4864 | q.text(","); q.breakable() |
| 4865 | q.text("match = "); |
| 4866 | q.pp(self.match) |
| 4867 | q.text(","); q.breakable() |
| 4868 | q.text("instructions = "); |
| 4869 | q.pp(self.instructions) |
| 4870 | q.breakable() |
| 4871 | q.text('}') |
| 4872 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4873 | flow_mod.subtypes[2] = flow_modify_strict |
| 4874 | |
| 4875 | class flow_removed(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4876 | version = 2 |
| 4877 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4878 | |
| 4879 | def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None, match=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4880 | if xid != None: |
| 4881 | self.xid = xid |
| 4882 | else: |
| 4883 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4884 | if cookie != None: |
| 4885 | self.cookie = cookie |
| 4886 | else: |
| 4887 | self.cookie = 0 |
| 4888 | if priority != None: |
| 4889 | self.priority = priority |
| 4890 | else: |
| 4891 | self.priority = 0 |
| 4892 | if reason != None: |
| 4893 | self.reason = reason |
| 4894 | else: |
| 4895 | self.reason = 0 |
| 4896 | if table_id != None: |
| 4897 | self.table_id = table_id |
| 4898 | else: |
| 4899 | self.table_id = 0 |
| 4900 | if duration_sec != None: |
| 4901 | self.duration_sec = duration_sec |
| 4902 | else: |
| 4903 | self.duration_sec = 0 |
| 4904 | if duration_nsec != None: |
| 4905 | self.duration_nsec = duration_nsec |
| 4906 | else: |
| 4907 | self.duration_nsec = 0 |
| 4908 | if idle_timeout != None: |
| 4909 | self.idle_timeout = idle_timeout |
| 4910 | else: |
| 4911 | self.idle_timeout = 0 |
| 4912 | if packet_count != None: |
| 4913 | self.packet_count = packet_count |
| 4914 | else: |
| 4915 | self.packet_count = 0 |
| 4916 | if byte_count != None: |
| 4917 | self.byte_count = byte_count |
| 4918 | else: |
| 4919 | self.byte_count = 0 |
| 4920 | if match != None: |
| 4921 | self.match = match |
| 4922 | else: |
| 4923 | self.match = common.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4924 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4925 | |
| 4926 | def pack(self): |
| 4927 | packed = [] |
| 4928 | packed.append(struct.pack("!B", self.version)) |
| 4929 | packed.append(struct.pack("!B", self.type)) |
| 4930 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4931 | packed.append(struct.pack("!L", self.xid)) |
| 4932 | packed.append(struct.pack("!Q", self.cookie)) |
| 4933 | packed.append(struct.pack("!H", self.priority)) |
| 4934 | packed.append(struct.pack("!B", self.reason)) |
| 4935 | packed.append(struct.pack("!B", self.table_id)) |
| 4936 | packed.append(struct.pack("!L", self.duration_sec)) |
| 4937 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 4938 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4939 | packed.append('\x00' * 2) |
| 4940 | packed.append(struct.pack("!Q", self.packet_count)) |
| 4941 | packed.append(struct.pack("!Q", self.byte_count)) |
| 4942 | packed.append(self.match.pack()) |
| 4943 | length = sum([len(x) for x in packed]) |
| 4944 | packed[2] = struct.pack("!H", length) |
| 4945 | return ''.join(packed) |
| 4946 | |
| 4947 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4948 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4949 | obj = flow_removed() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4950 | _version = reader.read("!B")[0] |
| 4951 | assert(_version == 2) |
| 4952 | _type = reader.read("!B")[0] |
| 4953 | assert(_type == 11) |
| 4954 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4955 | orig_reader = reader |
| 4956 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4957 | obj.xid = reader.read("!L")[0] |
| 4958 | obj.cookie = reader.read("!Q")[0] |
| 4959 | obj.priority = reader.read("!H")[0] |
| 4960 | obj.reason = reader.read("!B")[0] |
| 4961 | obj.table_id = reader.read("!B")[0] |
| 4962 | obj.duration_sec = reader.read("!L")[0] |
| 4963 | obj.duration_nsec = reader.read("!L")[0] |
| 4964 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4965 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4966 | obj.packet_count = reader.read("!Q")[0] |
| 4967 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4968 | obj.match = common.match.unpack(reader) |
| 4969 | return obj |
| 4970 | |
| 4971 | def __eq__(self, other): |
| 4972 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4973 | if self.xid != other.xid: return False |
| 4974 | if self.cookie != other.cookie: return False |
| 4975 | if self.priority != other.priority: return False |
| 4976 | if self.reason != other.reason: return False |
| 4977 | if self.table_id != other.table_id: return False |
| 4978 | if self.duration_sec != other.duration_sec: return False |
| 4979 | if self.duration_nsec != other.duration_nsec: return False |
| 4980 | if self.idle_timeout != other.idle_timeout: return False |
| 4981 | if self.packet_count != other.packet_count: return False |
| 4982 | if self.byte_count != other.byte_count: return False |
| 4983 | if self.match != other.match: return False |
| 4984 | return True |
| 4985 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4986 | def pretty_print(self, q): |
| 4987 | q.text("flow_removed {") |
| 4988 | with q.group(): |
| 4989 | with q.indent(2): |
| 4990 | q.breakable() |
| 4991 | q.text("xid = "); |
| 4992 | if self.xid != None: |
| 4993 | q.text("%#x" % self.xid) |
| 4994 | else: |
| 4995 | q.text('None') |
| 4996 | q.text(","); q.breakable() |
| 4997 | q.text("cookie = "); |
| 4998 | q.text("%#x" % self.cookie) |
| 4999 | q.text(","); q.breakable() |
| 5000 | q.text("priority = "); |
| 5001 | q.text("%#x" % self.priority) |
| 5002 | q.text(","); q.breakable() |
| 5003 | q.text("reason = "); |
| 5004 | q.text("%#x" % self.reason) |
| 5005 | q.text(","); q.breakable() |
| 5006 | q.text("table_id = "); |
| 5007 | q.text("%#x" % self.table_id) |
| 5008 | q.text(","); q.breakable() |
| 5009 | q.text("duration_sec = "); |
| 5010 | q.text("%#x" % self.duration_sec) |
| 5011 | q.text(","); q.breakable() |
| 5012 | q.text("duration_nsec = "); |
| 5013 | q.text("%#x" % self.duration_nsec) |
| 5014 | q.text(","); q.breakable() |
| 5015 | q.text("idle_timeout = "); |
| 5016 | q.text("%#x" % self.idle_timeout) |
| 5017 | q.text(","); q.breakable() |
| 5018 | q.text("packet_count = "); |
| 5019 | q.text("%#x" % self.packet_count) |
| 5020 | q.text(","); q.breakable() |
| 5021 | q.text("byte_count = "); |
| 5022 | q.text("%#x" % self.byte_count) |
| 5023 | q.text(","); q.breakable() |
| 5024 | q.text("match = "); |
| 5025 | q.pp(self.match) |
| 5026 | q.breakable() |
| 5027 | q.text('}') |
| 5028 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5029 | message.subtypes[11] = flow_removed |
| 5030 | |
| 5031 | class flow_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5032 | version = 2 |
| 5033 | type = 19 |
| 5034 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5035 | |
| 5036 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5037 | if xid != None: |
| 5038 | self.xid = xid |
| 5039 | else: |
| 5040 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5041 | if flags != None: |
| 5042 | self.flags = flags |
| 5043 | else: |
| 5044 | self.flags = 0 |
| 5045 | if entries != None: |
| 5046 | self.entries = entries |
| 5047 | else: |
| 5048 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5049 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5050 | |
| 5051 | def pack(self): |
| 5052 | packed = [] |
| 5053 | packed.append(struct.pack("!B", self.version)) |
| 5054 | packed.append(struct.pack("!B", self.type)) |
| 5055 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5056 | packed.append(struct.pack("!L", self.xid)) |
| 5057 | packed.append(struct.pack("!H", self.stats_type)) |
| 5058 | packed.append(struct.pack("!H", self.flags)) |
| 5059 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5060 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5061 | length = sum([len(x) for x in packed]) |
| 5062 | packed[2] = struct.pack("!H", length) |
| 5063 | return ''.join(packed) |
| 5064 | |
| 5065 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5066 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5067 | obj = flow_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5068 | _version = reader.read("!B")[0] |
| 5069 | assert(_version == 2) |
| 5070 | _type = reader.read("!B")[0] |
| 5071 | assert(_type == 19) |
| 5072 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5073 | orig_reader = reader |
| 5074 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5075 | obj.xid = reader.read("!L")[0] |
| 5076 | _stats_type = reader.read("!H")[0] |
| 5077 | assert(_stats_type == 1) |
| 5078 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5079 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5080 | obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5081 | return obj |
| 5082 | |
| 5083 | def __eq__(self, other): |
| 5084 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5085 | if self.xid != other.xid: return False |
| 5086 | if self.flags != other.flags: return False |
| 5087 | if self.entries != other.entries: return False |
| 5088 | return True |
| 5089 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5090 | def pretty_print(self, q): |
| 5091 | q.text("flow_stats_reply {") |
| 5092 | with q.group(): |
| 5093 | with q.indent(2): |
| 5094 | q.breakable() |
| 5095 | q.text("xid = "); |
| 5096 | if self.xid != None: |
| 5097 | q.text("%#x" % self.xid) |
| 5098 | else: |
| 5099 | q.text('None') |
| 5100 | q.text(","); q.breakable() |
| 5101 | q.text("flags = "); |
| 5102 | q.text("%#x" % self.flags) |
| 5103 | q.text(","); q.breakable() |
| 5104 | q.text("entries = "); |
| 5105 | q.pp(self.entries) |
| 5106 | q.breakable() |
| 5107 | q.text('}') |
| 5108 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5109 | stats_reply.subtypes[1] = flow_stats_reply |
| 5110 | |
| 5111 | class flow_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5112 | version = 2 |
| 5113 | type = 18 |
| 5114 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5115 | |
| 5116 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5117 | if xid != None: |
| 5118 | self.xid = xid |
| 5119 | else: |
| 5120 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5121 | if flags != None: |
| 5122 | self.flags = flags |
| 5123 | else: |
| 5124 | self.flags = 0 |
| 5125 | if table_id != None: |
| 5126 | self.table_id = table_id |
| 5127 | else: |
| 5128 | self.table_id = 0 |
| 5129 | if out_port != None: |
| 5130 | self.out_port = out_port |
| 5131 | else: |
| 5132 | self.out_port = 0 |
| 5133 | if out_group != None: |
| 5134 | self.out_group = out_group |
| 5135 | else: |
| 5136 | self.out_group = 0 |
| 5137 | if cookie != None: |
| 5138 | self.cookie = cookie |
| 5139 | else: |
| 5140 | self.cookie = 0 |
| 5141 | if cookie_mask != None: |
| 5142 | self.cookie_mask = cookie_mask |
| 5143 | else: |
| 5144 | self.cookie_mask = 0 |
| 5145 | if match != None: |
| 5146 | self.match = match |
| 5147 | else: |
| 5148 | self.match = common.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5149 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5150 | |
| 5151 | def pack(self): |
| 5152 | packed = [] |
| 5153 | packed.append(struct.pack("!B", self.version)) |
| 5154 | packed.append(struct.pack("!B", self.type)) |
| 5155 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5156 | packed.append(struct.pack("!L", self.xid)) |
| 5157 | packed.append(struct.pack("!H", self.stats_type)) |
| 5158 | packed.append(struct.pack("!H", self.flags)) |
| 5159 | packed.append('\x00' * 4) |
| 5160 | packed.append(struct.pack("!B", self.table_id)) |
| 5161 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5162 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5163 | packed.append(struct.pack("!L", self.out_group)) |
| 5164 | packed.append('\x00' * 4) |
| 5165 | packed.append(struct.pack("!Q", self.cookie)) |
| 5166 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5167 | packed.append(self.match.pack()) |
| 5168 | length = sum([len(x) for x in packed]) |
| 5169 | packed[2] = struct.pack("!H", length) |
| 5170 | return ''.join(packed) |
| 5171 | |
| 5172 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5173 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5174 | obj = flow_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5175 | _version = reader.read("!B")[0] |
| 5176 | assert(_version == 2) |
| 5177 | _type = reader.read("!B")[0] |
| 5178 | assert(_type == 18) |
| 5179 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5180 | orig_reader = reader |
| 5181 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5182 | obj.xid = reader.read("!L")[0] |
| 5183 | _stats_type = reader.read("!H")[0] |
| 5184 | assert(_stats_type == 1) |
| 5185 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5186 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5187 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5188 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5189 | obj.out_port = util.unpack_port_no(reader) |
| 5190 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5191 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5192 | obj.cookie = reader.read("!Q")[0] |
| 5193 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5194 | obj.match = common.match.unpack(reader) |
| 5195 | return obj |
| 5196 | |
| 5197 | def __eq__(self, other): |
| 5198 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5199 | if self.xid != other.xid: return False |
| 5200 | if self.flags != other.flags: return False |
| 5201 | if self.table_id != other.table_id: return False |
| 5202 | if self.out_port != other.out_port: return False |
| 5203 | if self.out_group != other.out_group: return False |
| 5204 | if self.cookie != other.cookie: return False |
| 5205 | if self.cookie_mask != other.cookie_mask: return False |
| 5206 | if self.match != other.match: return False |
| 5207 | return True |
| 5208 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5209 | def pretty_print(self, q): |
| 5210 | q.text("flow_stats_request {") |
| 5211 | with q.group(): |
| 5212 | with q.indent(2): |
| 5213 | q.breakable() |
| 5214 | q.text("xid = "); |
| 5215 | if self.xid != None: |
| 5216 | q.text("%#x" % self.xid) |
| 5217 | else: |
| 5218 | q.text('None') |
| 5219 | q.text(","); q.breakable() |
| 5220 | q.text("flags = "); |
| 5221 | q.text("%#x" % self.flags) |
| 5222 | q.text(","); q.breakable() |
| 5223 | q.text("table_id = "); |
| 5224 | q.text("%#x" % self.table_id) |
| 5225 | q.text(","); q.breakable() |
| 5226 | q.text("out_port = "); |
| 5227 | q.text(util.pretty_port(self.out_port)) |
| 5228 | q.text(","); q.breakable() |
| 5229 | q.text("out_group = "); |
| 5230 | q.text("%#x" % self.out_group) |
| 5231 | q.text(","); q.breakable() |
| 5232 | q.text("cookie = "); |
| 5233 | q.text("%#x" % self.cookie) |
| 5234 | q.text(","); q.breakable() |
| 5235 | q.text("cookie_mask = "); |
| 5236 | q.text("%#x" % self.cookie_mask) |
| 5237 | q.text(","); q.breakable() |
| 5238 | q.text("match = "); |
| 5239 | q.pp(self.match) |
| 5240 | q.breakable() |
| 5241 | q.text('}') |
| 5242 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5243 | stats_request.subtypes[1] = flow_stats_request |
| 5244 | |
| 5245 | class get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5246 | version = 2 |
| 5247 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5248 | |
| 5249 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5250 | if xid != None: |
| 5251 | self.xid = xid |
| 5252 | else: |
| 5253 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5254 | if flags != None: |
| 5255 | self.flags = flags |
| 5256 | else: |
| 5257 | self.flags = 0 |
| 5258 | if miss_send_len != None: |
| 5259 | self.miss_send_len = miss_send_len |
| 5260 | else: |
| 5261 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5262 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5263 | |
| 5264 | def pack(self): |
| 5265 | packed = [] |
| 5266 | packed.append(struct.pack("!B", self.version)) |
| 5267 | packed.append(struct.pack("!B", self.type)) |
| 5268 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5269 | packed.append(struct.pack("!L", self.xid)) |
| 5270 | packed.append(struct.pack("!H", self.flags)) |
| 5271 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5272 | length = sum([len(x) for x in packed]) |
| 5273 | packed[2] = struct.pack("!H", length) |
| 5274 | return ''.join(packed) |
| 5275 | |
| 5276 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5277 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5278 | obj = get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5279 | _version = reader.read("!B")[0] |
| 5280 | assert(_version == 2) |
| 5281 | _type = reader.read("!B")[0] |
| 5282 | assert(_type == 8) |
| 5283 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5284 | orig_reader = reader |
| 5285 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5286 | obj.xid = reader.read("!L")[0] |
| 5287 | obj.flags = reader.read("!H")[0] |
| 5288 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5289 | return obj |
| 5290 | |
| 5291 | def __eq__(self, other): |
| 5292 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5293 | if self.xid != other.xid: return False |
| 5294 | if self.flags != other.flags: return False |
| 5295 | if self.miss_send_len != other.miss_send_len: return False |
| 5296 | return True |
| 5297 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5298 | def pretty_print(self, q): |
| 5299 | q.text("get_config_reply {") |
| 5300 | with q.group(): |
| 5301 | with q.indent(2): |
| 5302 | q.breakable() |
| 5303 | q.text("xid = "); |
| 5304 | if self.xid != None: |
| 5305 | q.text("%#x" % self.xid) |
| 5306 | else: |
| 5307 | q.text('None') |
| 5308 | q.text(","); q.breakable() |
| 5309 | q.text("flags = "); |
| 5310 | q.text("%#x" % self.flags) |
| 5311 | q.text(","); q.breakable() |
| 5312 | q.text("miss_send_len = "); |
| 5313 | q.text("%#x" % self.miss_send_len) |
| 5314 | q.breakable() |
| 5315 | q.text('}') |
| 5316 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5317 | message.subtypes[8] = get_config_reply |
| 5318 | |
| 5319 | class get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5320 | version = 2 |
| 5321 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5322 | |
| 5323 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5324 | if xid != None: |
| 5325 | self.xid = xid |
| 5326 | else: |
| 5327 | self.xid = None |
| 5328 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5329 | |
| 5330 | def pack(self): |
| 5331 | packed = [] |
| 5332 | packed.append(struct.pack("!B", self.version)) |
| 5333 | packed.append(struct.pack("!B", self.type)) |
| 5334 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5335 | packed.append(struct.pack("!L", self.xid)) |
| 5336 | length = sum([len(x) for x in packed]) |
| 5337 | packed[2] = struct.pack("!H", length) |
| 5338 | return ''.join(packed) |
| 5339 | |
| 5340 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5341 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5342 | obj = get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5343 | _version = reader.read("!B")[0] |
| 5344 | assert(_version == 2) |
| 5345 | _type = reader.read("!B")[0] |
| 5346 | assert(_type == 7) |
| 5347 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5348 | orig_reader = reader |
| 5349 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5350 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5351 | return obj |
| 5352 | |
| 5353 | def __eq__(self, other): |
| 5354 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5355 | if self.xid != other.xid: return False |
| 5356 | return True |
| 5357 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5358 | def pretty_print(self, q): |
| 5359 | q.text("get_config_request {") |
| 5360 | with q.group(): |
| 5361 | with q.indent(2): |
| 5362 | q.breakable() |
| 5363 | q.text("xid = "); |
| 5364 | if self.xid != None: |
| 5365 | q.text("%#x" % self.xid) |
| 5366 | else: |
| 5367 | q.text('None') |
| 5368 | q.breakable() |
| 5369 | q.text('}') |
| 5370 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5371 | message.subtypes[7] = get_config_request |
| 5372 | |
| 5373 | class group_mod(message): |
| 5374 | subtypes = {} |
| 5375 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5376 | version = 2 |
| 5377 | type = 15 |
| 5378 | |
| 5379 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 5380 | if xid != None: |
| 5381 | self.xid = xid |
| 5382 | else: |
| 5383 | self.xid = None |
| 5384 | if command != None: |
| 5385 | self.command = command |
| 5386 | else: |
| 5387 | self.command = 0 |
| 5388 | if group_type != None: |
| 5389 | self.group_type = group_type |
| 5390 | else: |
| 5391 | self.group_type = 0 |
| 5392 | if group_id != None: |
| 5393 | self.group_id = group_id |
| 5394 | else: |
| 5395 | self.group_id = 0 |
| 5396 | if buckets != None: |
| 5397 | self.buckets = buckets |
| 5398 | else: |
| 5399 | self.buckets = [] |
| 5400 | return |
| 5401 | |
| 5402 | def pack(self): |
| 5403 | packed = [] |
| 5404 | packed.append(struct.pack("!B", self.version)) |
| 5405 | packed.append(struct.pack("!B", self.type)) |
| 5406 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5407 | packed.append(struct.pack("!L", self.xid)) |
| 5408 | packed.append(struct.pack("!H", self.command)) |
| 5409 | packed.append(struct.pack("!B", self.group_type)) |
| 5410 | packed.append('\x00' * 1) |
| 5411 | packed.append(struct.pack("!L", self.group_id)) |
| 5412 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
| 5413 | length = sum([len(x) for x in packed]) |
| 5414 | packed[2] = struct.pack("!H", length) |
| 5415 | return ''.join(packed) |
| 5416 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5417 | @staticmethod |
| 5418 | def unpack(reader): |
| 5419 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5420 | subclass = group_mod.subtypes.get(subtype) |
| 5421 | if subclass: |
| 5422 | return subclass.unpack(reader) |
| 5423 | |
| 5424 | obj = group_mod() |
| 5425 | _version = reader.read("!B")[0] |
| 5426 | assert(_version == 2) |
| 5427 | _type = reader.read("!B")[0] |
| 5428 | assert(_type == 15) |
| 5429 | _length = reader.read("!H")[0] |
| 5430 | orig_reader = reader |
| 5431 | reader = orig_reader.slice(_length - (2 + 2)) |
| 5432 | obj.xid = reader.read("!L")[0] |
| 5433 | obj.command = reader.read("!H")[0] |
| 5434 | obj.group_type = reader.read("!B")[0] |
| 5435 | reader.skip(1) |
| 5436 | obj.group_id = reader.read("!L")[0] |
| 5437 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
| 5438 | return obj |
| 5439 | |
| 5440 | def __eq__(self, other): |
| 5441 | if type(self) != type(other): return False |
| 5442 | if self.xid != other.xid: return False |
| 5443 | if self.command != other.command: return False |
| 5444 | if self.group_type != other.group_type: return False |
| 5445 | if self.group_id != other.group_id: return False |
| 5446 | if self.buckets != other.buckets: return False |
| 5447 | return True |
| 5448 | |
| 5449 | def pretty_print(self, q): |
| 5450 | q.text("group_mod {") |
| 5451 | with q.group(): |
| 5452 | with q.indent(2): |
| 5453 | q.breakable() |
| 5454 | q.text("xid = "); |
| 5455 | if self.xid != None: |
| 5456 | q.text("%#x" % self.xid) |
| 5457 | else: |
| 5458 | q.text('None') |
| 5459 | q.text(","); q.breakable() |
| 5460 | q.text("group_type = "); |
| 5461 | q.text("%#x" % self.group_type) |
| 5462 | q.text(","); q.breakable() |
| 5463 | q.text("group_id = "); |
| 5464 | q.text("%#x" % self.group_id) |
| 5465 | q.text(","); q.breakable() |
| 5466 | q.text("buckets = "); |
| 5467 | q.pp(self.buckets) |
| 5468 | q.breakable() |
| 5469 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5470 | |
| 5471 | message.subtypes[15] = group_mod |
| 5472 | |
| 5473 | class group_add(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5474 | version = 2 |
| 5475 | type = 15 |
| 5476 | command = 0 |
| 5477 | |
| 5478 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5479 | if xid != None: |
| 5480 | self.xid = xid |
| 5481 | else: |
| 5482 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5483 | if group_type != None: |
| 5484 | self.group_type = group_type |
| 5485 | else: |
| 5486 | self.group_type = 0 |
| 5487 | if group_id != None: |
| 5488 | self.group_id = group_id |
| 5489 | else: |
| 5490 | self.group_id = 0 |
| 5491 | if buckets != None: |
| 5492 | self.buckets = buckets |
| 5493 | else: |
| 5494 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5495 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5496 | |
| 5497 | def pack(self): |
| 5498 | packed = [] |
| 5499 | packed.append(struct.pack("!B", self.version)) |
| 5500 | packed.append(struct.pack("!B", self.type)) |
| 5501 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5502 | packed.append(struct.pack("!L", self.xid)) |
| 5503 | packed.append(struct.pack("!H", self.command)) |
| 5504 | packed.append(struct.pack("!B", self.group_type)) |
| 5505 | packed.append('\x00' * 1) |
| 5506 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5507 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5508 | length = sum([len(x) for x in packed]) |
| 5509 | packed[2] = struct.pack("!H", length) |
| 5510 | return ''.join(packed) |
| 5511 | |
| 5512 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5513 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5514 | obj = group_add() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5515 | _version = reader.read("!B")[0] |
| 5516 | assert(_version == 2) |
| 5517 | _type = reader.read("!B")[0] |
| 5518 | assert(_type == 15) |
| 5519 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5520 | orig_reader = reader |
| 5521 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5522 | obj.xid = reader.read("!L")[0] |
| 5523 | _command = reader.read("!H")[0] |
| 5524 | assert(_command == 0) |
| 5525 | obj.group_type = reader.read("!B")[0] |
| 5526 | reader.skip(1) |
| 5527 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5528 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5529 | return obj |
| 5530 | |
| 5531 | def __eq__(self, other): |
| 5532 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5533 | if self.xid != other.xid: return False |
| 5534 | if self.group_type != other.group_type: return False |
| 5535 | if self.group_id != other.group_id: return False |
| 5536 | if self.buckets != other.buckets: return False |
| 5537 | return True |
| 5538 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5539 | def pretty_print(self, q): |
| 5540 | q.text("group_add {") |
| 5541 | with q.group(): |
| 5542 | with q.indent(2): |
| 5543 | q.breakable() |
| 5544 | q.text("xid = "); |
| 5545 | if self.xid != None: |
| 5546 | q.text("%#x" % self.xid) |
| 5547 | else: |
| 5548 | q.text('None') |
| 5549 | q.text(","); q.breakable() |
| 5550 | q.text("group_type = "); |
| 5551 | q.text("%#x" % self.group_type) |
| 5552 | q.text(","); q.breakable() |
| 5553 | q.text("group_id = "); |
| 5554 | q.text("%#x" % self.group_id) |
| 5555 | q.text(","); q.breakable() |
| 5556 | q.text("buckets = "); |
| 5557 | q.pp(self.buckets) |
| 5558 | q.breakable() |
| 5559 | q.text('}') |
| 5560 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5561 | group_mod.subtypes[0] = group_add |
| 5562 | |
| 5563 | class group_delete(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5564 | version = 2 |
| 5565 | type = 15 |
| 5566 | command = 2 |
| 5567 | |
| 5568 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5569 | if xid != None: |
| 5570 | self.xid = xid |
| 5571 | else: |
| 5572 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5573 | if group_type != None: |
| 5574 | self.group_type = group_type |
| 5575 | else: |
| 5576 | self.group_type = 0 |
| 5577 | if group_id != None: |
| 5578 | self.group_id = group_id |
| 5579 | else: |
| 5580 | self.group_id = 0 |
| 5581 | if buckets != None: |
| 5582 | self.buckets = buckets |
| 5583 | else: |
| 5584 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5585 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5586 | |
| 5587 | def pack(self): |
| 5588 | packed = [] |
| 5589 | packed.append(struct.pack("!B", self.version)) |
| 5590 | packed.append(struct.pack("!B", self.type)) |
| 5591 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5592 | packed.append(struct.pack("!L", self.xid)) |
| 5593 | packed.append(struct.pack("!H", self.command)) |
| 5594 | packed.append(struct.pack("!B", self.group_type)) |
| 5595 | packed.append('\x00' * 1) |
| 5596 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5597 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5598 | length = sum([len(x) for x in packed]) |
| 5599 | packed[2] = struct.pack("!H", length) |
| 5600 | return ''.join(packed) |
| 5601 | |
| 5602 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5603 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5604 | obj = group_delete() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5605 | _version = reader.read("!B")[0] |
| 5606 | assert(_version == 2) |
| 5607 | _type = reader.read("!B")[0] |
| 5608 | assert(_type == 15) |
| 5609 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5610 | orig_reader = reader |
| 5611 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5612 | obj.xid = reader.read("!L")[0] |
| 5613 | _command = reader.read("!H")[0] |
| 5614 | assert(_command == 2) |
| 5615 | obj.group_type = reader.read("!B")[0] |
| 5616 | reader.skip(1) |
| 5617 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5618 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5619 | return obj |
| 5620 | |
| 5621 | def __eq__(self, other): |
| 5622 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5623 | if self.xid != other.xid: return False |
| 5624 | if self.group_type != other.group_type: return False |
| 5625 | if self.group_id != other.group_id: return False |
| 5626 | if self.buckets != other.buckets: return False |
| 5627 | return True |
| 5628 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5629 | def pretty_print(self, q): |
| 5630 | q.text("group_delete {") |
| 5631 | with q.group(): |
| 5632 | with q.indent(2): |
| 5633 | q.breakable() |
| 5634 | q.text("xid = "); |
| 5635 | if self.xid != None: |
| 5636 | q.text("%#x" % self.xid) |
| 5637 | else: |
| 5638 | q.text('None') |
| 5639 | q.text(","); q.breakable() |
| 5640 | q.text("group_type = "); |
| 5641 | q.text("%#x" % self.group_type) |
| 5642 | q.text(","); q.breakable() |
| 5643 | q.text("group_id = "); |
| 5644 | q.text("%#x" % self.group_id) |
| 5645 | q.text(","); q.breakable() |
| 5646 | q.text("buckets = "); |
| 5647 | q.pp(self.buckets) |
| 5648 | q.breakable() |
| 5649 | q.text('}') |
| 5650 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5651 | group_mod.subtypes[2] = group_delete |
| 5652 | |
| 5653 | class group_desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5654 | version = 2 |
| 5655 | type = 19 |
| 5656 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5657 | |
| 5658 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5659 | if xid != None: |
| 5660 | self.xid = xid |
| 5661 | else: |
| 5662 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5663 | if flags != None: |
| 5664 | self.flags = flags |
| 5665 | else: |
| 5666 | self.flags = 0 |
| 5667 | if entries != None: |
| 5668 | self.entries = entries |
| 5669 | else: |
| 5670 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5671 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5672 | |
| 5673 | def pack(self): |
| 5674 | packed = [] |
| 5675 | packed.append(struct.pack("!B", self.version)) |
| 5676 | packed.append(struct.pack("!B", self.type)) |
| 5677 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5678 | packed.append(struct.pack("!L", self.xid)) |
| 5679 | packed.append(struct.pack("!H", self.stats_type)) |
| 5680 | packed.append(struct.pack("!H", self.flags)) |
| 5681 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5682 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5683 | length = sum([len(x) for x in packed]) |
| 5684 | packed[2] = struct.pack("!H", length) |
| 5685 | return ''.join(packed) |
| 5686 | |
| 5687 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5688 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5689 | obj = group_desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5690 | _version = reader.read("!B")[0] |
| 5691 | assert(_version == 2) |
| 5692 | _type = reader.read("!B")[0] |
| 5693 | assert(_type == 19) |
| 5694 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5695 | orig_reader = reader |
| 5696 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5697 | obj.xid = reader.read("!L")[0] |
| 5698 | _stats_type = reader.read("!H")[0] |
| 5699 | assert(_stats_type == 7) |
| 5700 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5701 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5702 | obj.entries = loxi.generic_util.unpack_list(reader, common.group_desc_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5703 | return obj |
| 5704 | |
| 5705 | def __eq__(self, other): |
| 5706 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5707 | if self.xid != other.xid: return False |
| 5708 | if self.flags != other.flags: return False |
| 5709 | if self.entries != other.entries: return False |
| 5710 | return True |
| 5711 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5712 | def pretty_print(self, q): |
| 5713 | q.text("group_desc_stats_reply {") |
| 5714 | with q.group(): |
| 5715 | with q.indent(2): |
| 5716 | q.breakable() |
| 5717 | q.text("xid = "); |
| 5718 | if self.xid != None: |
| 5719 | q.text("%#x" % self.xid) |
| 5720 | else: |
| 5721 | q.text('None') |
| 5722 | q.text(","); q.breakable() |
| 5723 | q.text("flags = "); |
| 5724 | q.text("%#x" % self.flags) |
| 5725 | q.text(","); q.breakable() |
| 5726 | q.text("entries = "); |
| 5727 | q.pp(self.entries) |
| 5728 | q.breakable() |
| 5729 | q.text('}') |
| 5730 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5731 | stats_reply.subtypes[7] = group_desc_stats_reply |
| 5732 | |
| 5733 | class group_desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5734 | version = 2 |
| 5735 | type = 18 |
| 5736 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5737 | |
| 5738 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5739 | if xid != None: |
| 5740 | self.xid = xid |
| 5741 | else: |
| 5742 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5743 | if flags != None: |
| 5744 | self.flags = flags |
| 5745 | else: |
| 5746 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5747 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5748 | |
| 5749 | def pack(self): |
| 5750 | packed = [] |
| 5751 | packed.append(struct.pack("!B", self.version)) |
| 5752 | packed.append(struct.pack("!B", self.type)) |
| 5753 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5754 | packed.append(struct.pack("!L", self.xid)) |
| 5755 | packed.append(struct.pack("!H", self.stats_type)) |
| 5756 | packed.append(struct.pack("!H", self.flags)) |
| 5757 | packed.append('\x00' * 4) |
| 5758 | length = sum([len(x) for x in packed]) |
| 5759 | packed[2] = struct.pack("!H", length) |
| 5760 | return ''.join(packed) |
| 5761 | |
| 5762 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5763 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5764 | obj = group_desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5765 | _version = reader.read("!B")[0] |
| 5766 | assert(_version == 2) |
| 5767 | _type = reader.read("!B")[0] |
| 5768 | assert(_type == 18) |
| 5769 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5770 | orig_reader = reader |
| 5771 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5772 | obj.xid = reader.read("!L")[0] |
| 5773 | _stats_type = reader.read("!H")[0] |
| 5774 | assert(_stats_type == 7) |
| 5775 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5776 | reader.skip(4) |
| 5777 | return obj |
| 5778 | |
| 5779 | def __eq__(self, other): |
| 5780 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5781 | if self.xid != other.xid: return False |
| 5782 | if self.flags != other.flags: return False |
| 5783 | return True |
| 5784 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5785 | def pretty_print(self, q): |
| 5786 | q.text("group_desc_stats_request {") |
| 5787 | with q.group(): |
| 5788 | with q.indent(2): |
| 5789 | q.breakable() |
| 5790 | q.text("xid = "); |
| 5791 | if self.xid != None: |
| 5792 | q.text("%#x" % self.xid) |
| 5793 | else: |
| 5794 | q.text('None') |
| 5795 | q.text(","); q.breakable() |
| 5796 | q.text("flags = "); |
| 5797 | q.text("%#x" % self.flags) |
| 5798 | q.breakable() |
| 5799 | q.text('}') |
| 5800 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5801 | stats_request.subtypes[7] = group_desc_stats_request |
| 5802 | |
| 5803 | class group_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5804 | version = 2 |
| 5805 | type = 1 |
| 5806 | err_type = 6 |
| 5807 | |
| 5808 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5809 | if xid != None: |
| 5810 | self.xid = xid |
| 5811 | else: |
| 5812 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5813 | if code != None: |
| 5814 | self.code = code |
| 5815 | else: |
| 5816 | self.code = 0 |
| 5817 | if data != None: |
| 5818 | self.data = data |
| 5819 | else: |
| 5820 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5821 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5822 | |
| 5823 | def pack(self): |
| 5824 | packed = [] |
| 5825 | packed.append(struct.pack("!B", self.version)) |
| 5826 | packed.append(struct.pack("!B", self.type)) |
| 5827 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5828 | packed.append(struct.pack("!L", self.xid)) |
| 5829 | packed.append(struct.pack("!H", self.err_type)) |
| 5830 | packed.append(struct.pack("!H", self.code)) |
| 5831 | packed.append(self.data) |
| 5832 | length = sum([len(x) for x in packed]) |
| 5833 | packed[2] = struct.pack("!H", length) |
| 5834 | return ''.join(packed) |
| 5835 | |
| 5836 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5837 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5838 | obj = group_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5839 | _version = reader.read("!B")[0] |
| 5840 | assert(_version == 2) |
| 5841 | _type = reader.read("!B")[0] |
| 5842 | assert(_type == 1) |
| 5843 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5844 | orig_reader = reader |
| 5845 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5846 | obj.xid = reader.read("!L")[0] |
| 5847 | _err_type = reader.read("!H")[0] |
| 5848 | assert(_err_type == 6) |
| 5849 | obj.code = reader.read("!H")[0] |
| 5850 | obj.data = str(reader.read_all()) |
| 5851 | return obj |
| 5852 | |
| 5853 | def __eq__(self, other): |
| 5854 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5855 | if self.xid != other.xid: return False |
| 5856 | if self.code != other.code: return False |
| 5857 | if self.data != other.data: return False |
| 5858 | return True |
| 5859 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5860 | def pretty_print(self, q): |
| 5861 | q.text("group_mod_failed_error_msg {") |
| 5862 | with q.group(): |
| 5863 | with q.indent(2): |
| 5864 | q.breakable() |
| 5865 | q.text("xid = "); |
| 5866 | if self.xid != None: |
| 5867 | q.text("%#x" % self.xid) |
| 5868 | else: |
| 5869 | q.text('None') |
| 5870 | q.text(","); q.breakable() |
| 5871 | q.text("code = "); |
| 5872 | q.text("%#x" % self.code) |
| 5873 | q.text(","); q.breakable() |
| 5874 | q.text("data = "); |
| 5875 | q.pp(self.data) |
| 5876 | q.breakable() |
| 5877 | q.text('}') |
| 5878 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5879 | error_msg.subtypes[6] = group_mod_failed_error_msg |
| 5880 | |
| 5881 | class group_modify(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5882 | version = 2 |
| 5883 | type = 15 |
| 5884 | command = 1 |
| 5885 | |
| 5886 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5887 | if xid != None: |
| 5888 | self.xid = xid |
| 5889 | else: |
| 5890 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5891 | if group_type != None: |
| 5892 | self.group_type = group_type |
| 5893 | else: |
| 5894 | self.group_type = 0 |
| 5895 | if group_id != None: |
| 5896 | self.group_id = group_id |
| 5897 | else: |
| 5898 | self.group_id = 0 |
| 5899 | if buckets != None: |
| 5900 | self.buckets = buckets |
| 5901 | else: |
| 5902 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5903 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5904 | |
| 5905 | def pack(self): |
| 5906 | packed = [] |
| 5907 | packed.append(struct.pack("!B", self.version)) |
| 5908 | packed.append(struct.pack("!B", self.type)) |
| 5909 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5910 | packed.append(struct.pack("!L", self.xid)) |
| 5911 | packed.append(struct.pack("!H", self.command)) |
| 5912 | packed.append(struct.pack("!B", self.group_type)) |
| 5913 | packed.append('\x00' * 1) |
| 5914 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5915 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5916 | length = sum([len(x) for x in packed]) |
| 5917 | packed[2] = struct.pack("!H", length) |
| 5918 | return ''.join(packed) |
| 5919 | |
| 5920 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5921 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5922 | obj = group_modify() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5923 | _version = reader.read("!B")[0] |
| 5924 | assert(_version == 2) |
| 5925 | _type = reader.read("!B")[0] |
| 5926 | assert(_type == 15) |
| 5927 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5928 | orig_reader = reader |
| 5929 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5930 | obj.xid = reader.read("!L")[0] |
| 5931 | _command = reader.read("!H")[0] |
| 5932 | assert(_command == 1) |
| 5933 | obj.group_type = reader.read("!B")[0] |
| 5934 | reader.skip(1) |
| 5935 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5936 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5937 | return obj |
| 5938 | |
| 5939 | def __eq__(self, other): |
| 5940 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5941 | if self.xid != other.xid: return False |
| 5942 | if self.group_type != other.group_type: return False |
| 5943 | if self.group_id != other.group_id: return False |
| 5944 | if self.buckets != other.buckets: return False |
| 5945 | return True |
| 5946 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5947 | def pretty_print(self, q): |
| 5948 | q.text("group_modify {") |
| 5949 | with q.group(): |
| 5950 | with q.indent(2): |
| 5951 | q.breakable() |
| 5952 | q.text("xid = "); |
| 5953 | if self.xid != None: |
| 5954 | q.text("%#x" % self.xid) |
| 5955 | else: |
| 5956 | q.text('None') |
| 5957 | q.text(","); q.breakable() |
| 5958 | q.text("group_type = "); |
| 5959 | q.text("%#x" % self.group_type) |
| 5960 | q.text(","); q.breakable() |
| 5961 | q.text("group_id = "); |
| 5962 | q.text("%#x" % self.group_id) |
| 5963 | q.text(","); q.breakable() |
| 5964 | q.text("buckets = "); |
| 5965 | q.pp(self.buckets) |
| 5966 | q.breakable() |
| 5967 | q.text('}') |
| 5968 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5969 | group_mod.subtypes[1] = group_modify |
| 5970 | |
| 5971 | class group_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5972 | version = 2 |
| 5973 | type = 19 |
| 5974 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5975 | |
| 5976 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5977 | if xid != None: |
| 5978 | self.xid = xid |
| 5979 | else: |
| 5980 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5981 | if flags != None: |
| 5982 | self.flags = flags |
| 5983 | else: |
| 5984 | self.flags = 0 |
| 5985 | if entries != None: |
| 5986 | self.entries = entries |
| 5987 | else: |
| 5988 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5989 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5990 | |
| 5991 | def pack(self): |
| 5992 | packed = [] |
| 5993 | packed.append(struct.pack("!B", self.version)) |
| 5994 | packed.append(struct.pack("!B", self.type)) |
| 5995 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5996 | packed.append(struct.pack("!L", self.xid)) |
| 5997 | packed.append(struct.pack("!H", self.stats_type)) |
| 5998 | packed.append(struct.pack("!H", self.flags)) |
| 5999 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6000 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6001 | length = sum([len(x) for x in packed]) |
| 6002 | packed[2] = struct.pack("!H", length) |
| 6003 | return ''.join(packed) |
| 6004 | |
| 6005 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6006 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6007 | obj = group_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6008 | _version = reader.read("!B")[0] |
| 6009 | assert(_version == 2) |
| 6010 | _type = reader.read("!B")[0] |
| 6011 | assert(_type == 19) |
| 6012 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6013 | orig_reader = reader |
| 6014 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6015 | obj.xid = reader.read("!L")[0] |
| 6016 | _stats_type = reader.read("!H")[0] |
| 6017 | assert(_stats_type == 6) |
| 6018 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6019 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6020 | obj.entries = loxi.generic_util.unpack_list(reader, common.group_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6021 | return obj |
| 6022 | |
| 6023 | def __eq__(self, other): |
| 6024 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6025 | if self.xid != other.xid: return False |
| 6026 | if self.flags != other.flags: return False |
| 6027 | if self.entries != other.entries: return False |
| 6028 | return True |
| 6029 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6030 | def pretty_print(self, q): |
| 6031 | q.text("group_stats_reply {") |
| 6032 | with q.group(): |
| 6033 | with q.indent(2): |
| 6034 | q.breakable() |
| 6035 | q.text("xid = "); |
| 6036 | if self.xid != None: |
| 6037 | q.text("%#x" % self.xid) |
| 6038 | else: |
| 6039 | q.text('None') |
| 6040 | q.text(","); q.breakable() |
| 6041 | q.text("flags = "); |
| 6042 | q.text("%#x" % self.flags) |
| 6043 | q.text(","); q.breakable() |
| 6044 | q.text("entries = "); |
| 6045 | q.pp(self.entries) |
| 6046 | q.breakable() |
| 6047 | q.text('}') |
| 6048 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6049 | stats_reply.subtypes[6] = group_stats_reply |
| 6050 | |
| 6051 | class group_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6052 | version = 2 |
| 6053 | type = 18 |
| 6054 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6055 | |
| 6056 | def __init__(self, xid=None, flags=None, group_id=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6057 | if xid != None: |
| 6058 | self.xid = xid |
| 6059 | else: |
| 6060 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6061 | if flags != None: |
| 6062 | self.flags = flags |
| 6063 | else: |
| 6064 | self.flags = 0 |
| 6065 | if group_id != None: |
| 6066 | self.group_id = group_id |
| 6067 | else: |
| 6068 | self.group_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6069 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6070 | |
| 6071 | def pack(self): |
| 6072 | packed = [] |
| 6073 | packed.append(struct.pack("!B", self.version)) |
| 6074 | packed.append(struct.pack("!B", self.type)) |
| 6075 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6076 | packed.append(struct.pack("!L", self.xid)) |
| 6077 | packed.append(struct.pack("!H", self.stats_type)) |
| 6078 | packed.append(struct.pack("!H", self.flags)) |
| 6079 | packed.append('\x00' * 4) |
| 6080 | packed.append(struct.pack("!L", self.group_id)) |
| 6081 | packed.append('\x00' * 4) |
| 6082 | length = sum([len(x) for x in packed]) |
| 6083 | packed[2] = struct.pack("!H", length) |
| 6084 | return ''.join(packed) |
| 6085 | |
| 6086 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6087 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6088 | obj = group_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6089 | _version = reader.read("!B")[0] |
| 6090 | assert(_version == 2) |
| 6091 | _type = reader.read("!B")[0] |
| 6092 | assert(_type == 18) |
| 6093 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6094 | orig_reader = reader |
| 6095 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6096 | obj.xid = reader.read("!L")[0] |
| 6097 | _stats_type = reader.read("!H")[0] |
| 6098 | assert(_stats_type == 6) |
| 6099 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6100 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6101 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6102 | reader.skip(4) |
| 6103 | return obj |
| 6104 | |
| 6105 | def __eq__(self, other): |
| 6106 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6107 | if self.xid != other.xid: return False |
| 6108 | if self.flags != other.flags: return False |
| 6109 | if self.group_id != other.group_id: return False |
| 6110 | return True |
| 6111 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6112 | def pretty_print(self, q): |
| 6113 | q.text("group_stats_request {") |
| 6114 | with q.group(): |
| 6115 | with q.indent(2): |
| 6116 | q.breakable() |
| 6117 | q.text("xid = "); |
| 6118 | if self.xid != None: |
| 6119 | q.text("%#x" % self.xid) |
| 6120 | else: |
| 6121 | q.text('None') |
| 6122 | q.text(","); q.breakable() |
| 6123 | q.text("flags = "); |
| 6124 | q.text("%#x" % self.flags) |
| 6125 | q.text(","); q.breakable() |
| 6126 | q.text("group_id = "); |
| 6127 | q.text("%#x" % self.group_id) |
| 6128 | q.breakable() |
| 6129 | q.text('}') |
| 6130 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6131 | stats_request.subtypes[6] = group_stats_request |
| 6132 | |
| 6133 | class hello(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6134 | version = 2 |
| 6135 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6136 | |
| 6137 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6138 | if xid != None: |
| 6139 | self.xid = xid |
| 6140 | else: |
| 6141 | self.xid = None |
| 6142 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6143 | |
| 6144 | def pack(self): |
| 6145 | packed = [] |
| 6146 | packed.append(struct.pack("!B", self.version)) |
| 6147 | packed.append(struct.pack("!B", self.type)) |
| 6148 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6149 | packed.append(struct.pack("!L", self.xid)) |
| 6150 | length = sum([len(x) for x in packed]) |
| 6151 | packed[2] = struct.pack("!H", length) |
| 6152 | return ''.join(packed) |
| 6153 | |
| 6154 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6155 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6156 | obj = hello() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6157 | _version = reader.read("!B")[0] |
| 6158 | assert(_version == 2) |
| 6159 | _type = reader.read("!B")[0] |
| 6160 | assert(_type == 0) |
| 6161 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6162 | orig_reader = reader |
| 6163 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6164 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6165 | return obj |
| 6166 | |
| 6167 | def __eq__(self, other): |
| 6168 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6169 | if self.xid != other.xid: return False |
| 6170 | return True |
| 6171 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6172 | def pretty_print(self, q): |
| 6173 | q.text("hello {") |
| 6174 | with q.group(): |
| 6175 | with q.indent(2): |
| 6176 | q.breakable() |
| 6177 | q.text("xid = "); |
| 6178 | if self.xid != None: |
| 6179 | q.text("%#x" % self.xid) |
| 6180 | else: |
| 6181 | q.text('None') |
| 6182 | q.breakable() |
| 6183 | q.text('}') |
| 6184 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6185 | message.subtypes[0] = hello |
| 6186 | |
| 6187 | class hello_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6188 | version = 2 |
| 6189 | type = 1 |
| 6190 | err_type = 0 |
| 6191 | |
| 6192 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6193 | if xid != None: |
| 6194 | self.xid = xid |
| 6195 | else: |
| 6196 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6197 | if code != None: |
| 6198 | self.code = code |
| 6199 | else: |
| 6200 | self.code = 0 |
| 6201 | if data != None: |
| 6202 | self.data = data |
| 6203 | else: |
| 6204 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6205 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6206 | |
| 6207 | def pack(self): |
| 6208 | packed = [] |
| 6209 | packed.append(struct.pack("!B", self.version)) |
| 6210 | packed.append(struct.pack("!B", self.type)) |
| 6211 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6212 | packed.append(struct.pack("!L", self.xid)) |
| 6213 | packed.append(struct.pack("!H", self.err_type)) |
| 6214 | packed.append(struct.pack("!H", self.code)) |
| 6215 | packed.append(self.data) |
| 6216 | length = sum([len(x) for x in packed]) |
| 6217 | packed[2] = struct.pack("!H", length) |
| 6218 | return ''.join(packed) |
| 6219 | |
| 6220 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6221 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6222 | obj = hello_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6223 | _version = reader.read("!B")[0] |
| 6224 | assert(_version == 2) |
| 6225 | _type = reader.read("!B")[0] |
| 6226 | assert(_type == 1) |
| 6227 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6228 | orig_reader = reader |
| 6229 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6230 | obj.xid = reader.read("!L")[0] |
| 6231 | _err_type = reader.read("!H")[0] |
| 6232 | assert(_err_type == 0) |
| 6233 | obj.code = reader.read("!H")[0] |
| 6234 | obj.data = str(reader.read_all()) |
| 6235 | return obj |
| 6236 | |
| 6237 | def __eq__(self, other): |
| 6238 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6239 | if self.xid != other.xid: return False |
| 6240 | if self.code != other.code: return False |
| 6241 | if self.data != other.data: return False |
| 6242 | return True |
| 6243 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6244 | def pretty_print(self, q): |
| 6245 | q.text("hello_failed_error_msg {") |
| 6246 | with q.group(): |
| 6247 | with q.indent(2): |
| 6248 | q.breakable() |
| 6249 | q.text("xid = "); |
| 6250 | if self.xid != None: |
| 6251 | q.text("%#x" % self.xid) |
| 6252 | else: |
| 6253 | q.text('None') |
| 6254 | q.text(","); q.breakable() |
| 6255 | q.text("code = "); |
| 6256 | q.text("%#x" % self.code) |
| 6257 | q.text(","); q.breakable() |
| 6258 | q.text("data = "); |
| 6259 | q.pp(self.data) |
| 6260 | q.breakable() |
| 6261 | q.text('}') |
| 6262 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6263 | error_msg.subtypes[0] = hello_failed_error_msg |
| 6264 | |
| 6265 | class nicira_header(experimenter): |
| 6266 | subtypes = {} |
| 6267 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6268 | version = 2 |
| 6269 | type = 4 |
| 6270 | experimenter = 8992 |
| 6271 | |
| 6272 | def __init__(self, xid=None, subtype=None): |
| 6273 | if xid != None: |
| 6274 | self.xid = xid |
| 6275 | else: |
| 6276 | self.xid = None |
| 6277 | if subtype != None: |
| 6278 | self.subtype = subtype |
| 6279 | else: |
| 6280 | self.subtype = 0 |
| 6281 | return |
| 6282 | |
| 6283 | def pack(self): |
| 6284 | packed = [] |
| 6285 | packed.append(struct.pack("!B", self.version)) |
| 6286 | packed.append(struct.pack("!B", self.type)) |
| 6287 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6288 | packed.append(struct.pack("!L", self.xid)) |
| 6289 | packed.append(struct.pack("!L", self.experimenter)) |
| 6290 | packed.append(struct.pack("!L", self.subtype)) |
| 6291 | length = sum([len(x) for x in packed]) |
| 6292 | packed[2] = struct.pack("!H", length) |
| 6293 | return ''.join(packed) |
| 6294 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6295 | @staticmethod |
| 6296 | def unpack(reader): |
| 6297 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6298 | subclass = nicira_header.subtypes.get(subtype) |
| 6299 | if subclass: |
| 6300 | return subclass.unpack(reader) |
| 6301 | |
| 6302 | obj = nicira_header() |
| 6303 | _version = reader.read("!B")[0] |
| 6304 | assert(_version == 2) |
| 6305 | _type = reader.read("!B")[0] |
| 6306 | assert(_type == 4) |
| 6307 | _length = reader.read("!H")[0] |
| 6308 | orig_reader = reader |
| 6309 | reader = orig_reader.slice(_length - (2 + 2)) |
| 6310 | obj.xid = reader.read("!L")[0] |
| 6311 | _experimenter = reader.read("!L")[0] |
| 6312 | assert(_experimenter == 8992) |
| 6313 | obj.subtype = reader.read("!L")[0] |
| 6314 | return obj |
| 6315 | |
| 6316 | def __eq__(self, other): |
| 6317 | if type(self) != type(other): return False |
| 6318 | if self.xid != other.xid: return False |
| 6319 | if self.subtype != other.subtype: return False |
| 6320 | return True |
| 6321 | |
| 6322 | def pretty_print(self, q): |
| 6323 | q.text("nicira_header {") |
| 6324 | with q.group(): |
| 6325 | with q.indent(2): |
| 6326 | q.breakable() |
| 6327 | q.text("xid = "); |
| 6328 | if self.xid != None: |
| 6329 | q.text("%#x" % self.xid) |
| 6330 | else: |
| 6331 | q.text('None') |
| 6332 | q.breakable() |
| 6333 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6334 | |
| 6335 | experimenter.subtypes[8992] = nicira_header |
| 6336 | |
| 6337 | class packet_in(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6338 | version = 2 |
| 6339 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6340 | |
| 6341 | def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6342 | if xid != None: |
| 6343 | self.xid = xid |
| 6344 | else: |
| 6345 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6346 | if buffer_id != None: |
| 6347 | self.buffer_id = buffer_id |
| 6348 | else: |
| 6349 | self.buffer_id = 0 |
| 6350 | if in_port != None: |
| 6351 | self.in_port = in_port |
| 6352 | else: |
| 6353 | self.in_port = 0 |
| 6354 | if in_phy_port != None: |
| 6355 | self.in_phy_port = in_phy_port |
| 6356 | else: |
| 6357 | self.in_phy_port = 0 |
| 6358 | if total_len != None: |
| 6359 | self.total_len = total_len |
| 6360 | else: |
| 6361 | self.total_len = 0 |
| 6362 | if reason != None: |
| 6363 | self.reason = reason |
| 6364 | else: |
| 6365 | self.reason = 0 |
| 6366 | if table_id != None: |
| 6367 | self.table_id = table_id |
| 6368 | else: |
| 6369 | self.table_id = 0 |
| 6370 | if data != None: |
| 6371 | self.data = data |
| 6372 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6373 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6374 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6375 | |
| 6376 | def pack(self): |
| 6377 | packed = [] |
| 6378 | packed.append(struct.pack("!B", self.version)) |
| 6379 | packed.append(struct.pack("!B", self.type)) |
| 6380 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6381 | packed.append(struct.pack("!L", self.xid)) |
| 6382 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6383 | packed.append(util.pack_port_no(self.in_port)) |
| 6384 | packed.append(util.pack_port_no(self.in_phy_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6385 | packed.append(struct.pack("!H", self.total_len)) |
| 6386 | packed.append(struct.pack("!B", self.reason)) |
| 6387 | packed.append(struct.pack("!B", self.table_id)) |
| 6388 | packed.append(self.data) |
| 6389 | length = sum([len(x) for x in packed]) |
| 6390 | packed[2] = struct.pack("!H", length) |
| 6391 | return ''.join(packed) |
| 6392 | |
| 6393 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6394 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6395 | obj = packet_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6396 | _version = reader.read("!B")[0] |
| 6397 | assert(_version == 2) |
| 6398 | _type = reader.read("!B")[0] |
| 6399 | assert(_type == 10) |
| 6400 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6401 | orig_reader = reader |
| 6402 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6403 | obj.xid = reader.read("!L")[0] |
| 6404 | obj.buffer_id = reader.read("!L")[0] |
| 6405 | obj.in_port = util.unpack_port_no(reader) |
| 6406 | obj.in_phy_port = util.unpack_port_no(reader) |
| 6407 | obj.total_len = reader.read("!H")[0] |
| 6408 | obj.reason = reader.read("!B")[0] |
| 6409 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6410 | obj.data = str(reader.read_all()) |
| 6411 | return obj |
| 6412 | |
| 6413 | def __eq__(self, other): |
| 6414 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6415 | if self.xid != other.xid: return False |
| 6416 | if self.buffer_id != other.buffer_id: return False |
| 6417 | if self.in_port != other.in_port: return False |
| 6418 | if self.in_phy_port != other.in_phy_port: return False |
| 6419 | if self.total_len != other.total_len: return False |
| 6420 | if self.reason != other.reason: return False |
| 6421 | if self.table_id != other.table_id: return False |
| 6422 | if self.data != other.data: return False |
| 6423 | return True |
| 6424 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6425 | def pretty_print(self, q): |
| 6426 | q.text("packet_in {") |
| 6427 | with q.group(): |
| 6428 | with q.indent(2): |
| 6429 | q.breakable() |
| 6430 | q.text("xid = "); |
| 6431 | if self.xid != None: |
| 6432 | q.text("%#x" % self.xid) |
| 6433 | else: |
| 6434 | q.text('None') |
| 6435 | q.text(","); q.breakable() |
| 6436 | q.text("buffer_id = "); |
| 6437 | q.text("%#x" % self.buffer_id) |
| 6438 | q.text(","); q.breakable() |
| 6439 | q.text("in_port = "); |
| 6440 | q.text(util.pretty_port(self.in_port)) |
| 6441 | q.text(","); q.breakable() |
| 6442 | q.text("in_phy_port = "); |
| 6443 | q.text(util.pretty_port(self.in_phy_port)) |
| 6444 | q.text(","); q.breakable() |
| 6445 | q.text("total_len = "); |
| 6446 | q.text("%#x" % self.total_len) |
| 6447 | q.text(","); q.breakable() |
| 6448 | q.text("reason = "); |
| 6449 | q.text("%#x" % self.reason) |
| 6450 | q.text(","); q.breakable() |
| 6451 | q.text("table_id = "); |
| 6452 | q.text("%#x" % self.table_id) |
| 6453 | q.text(","); q.breakable() |
| 6454 | q.text("data = "); |
| 6455 | q.pp(self.data) |
| 6456 | q.breakable() |
| 6457 | q.text('}') |
| 6458 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6459 | message.subtypes[10] = packet_in |
| 6460 | |
| 6461 | class packet_out(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6462 | version = 2 |
| 6463 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6464 | |
| 6465 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6466 | if xid != None: |
| 6467 | self.xid = xid |
| 6468 | else: |
| 6469 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6470 | if buffer_id != None: |
| 6471 | self.buffer_id = buffer_id |
| 6472 | else: |
| 6473 | self.buffer_id = 0 |
| 6474 | if in_port != None: |
| 6475 | self.in_port = in_port |
| 6476 | else: |
| 6477 | self.in_port = 0 |
| 6478 | if actions != None: |
| 6479 | self.actions = actions |
| 6480 | else: |
| 6481 | self.actions = [] |
| 6482 | if data != None: |
| 6483 | self.data = data |
| 6484 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6485 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6486 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6487 | |
| 6488 | def pack(self): |
| 6489 | packed = [] |
| 6490 | packed.append(struct.pack("!B", self.version)) |
| 6491 | packed.append(struct.pack("!B", self.type)) |
| 6492 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6493 | packed.append(struct.pack("!L", self.xid)) |
| 6494 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6495 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6496 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 6497 | packed.append('\x00' * 6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6498 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6499 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 6500 | packed.append(self.data) |
| 6501 | length = sum([len(x) for x in packed]) |
| 6502 | packed[2] = struct.pack("!H", length) |
| 6503 | return ''.join(packed) |
| 6504 | |
| 6505 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6506 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6507 | obj = packet_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6508 | _version = reader.read("!B")[0] |
| 6509 | assert(_version == 2) |
| 6510 | _type = reader.read("!B")[0] |
| 6511 | assert(_type == 13) |
| 6512 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6513 | orig_reader = reader |
| 6514 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6515 | obj.xid = reader.read("!L")[0] |
| 6516 | obj.buffer_id = reader.read("!L")[0] |
| 6517 | obj.in_port = util.unpack_port_no(reader) |
| 6518 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6519 | reader.skip(6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6520 | obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), action.action.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6521 | obj.data = str(reader.read_all()) |
| 6522 | return obj |
| 6523 | |
| 6524 | def __eq__(self, other): |
| 6525 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6526 | if self.xid != other.xid: return False |
| 6527 | if self.buffer_id != other.buffer_id: return False |
| 6528 | if self.in_port != other.in_port: return False |
| 6529 | if self.actions != other.actions: return False |
| 6530 | if self.data != other.data: return False |
| 6531 | return True |
| 6532 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6533 | def pretty_print(self, q): |
| 6534 | q.text("packet_out {") |
| 6535 | with q.group(): |
| 6536 | with q.indent(2): |
| 6537 | q.breakable() |
| 6538 | q.text("xid = "); |
| 6539 | if self.xid != None: |
| 6540 | q.text("%#x" % self.xid) |
| 6541 | else: |
| 6542 | q.text('None') |
| 6543 | q.text(","); q.breakable() |
| 6544 | q.text("buffer_id = "); |
| 6545 | q.text("%#x" % self.buffer_id) |
| 6546 | q.text(","); q.breakable() |
| 6547 | q.text("in_port = "); |
| 6548 | q.text(util.pretty_port(self.in_port)) |
| 6549 | q.text(","); q.breakable() |
| 6550 | q.text("actions = "); |
| 6551 | q.pp(self.actions) |
| 6552 | q.text(","); q.breakable() |
| 6553 | q.text("data = "); |
| 6554 | q.pp(self.data) |
| 6555 | q.breakable() |
| 6556 | q.text('}') |
| 6557 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6558 | message.subtypes[13] = packet_out |
| 6559 | |
| 6560 | class port_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6561 | version = 2 |
| 6562 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6563 | |
| 6564 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6565 | if xid != None: |
| 6566 | self.xid = xid |
| 6567 | else: |
| 6568 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6569 | if port_no != None: |
| 6570 | self.port_no = port_no |
| 6571 | else: |
| 6572 | self.port_no = 0 |
| 6573 | if hw_addr != None: |
| 6574 | self.hw_addr = hw_addr |
| 6575 | else: |
| 6576 | self.hw_addr = [0,0,0,0,0,0] |
| 6577 | if config != None: |
| 6578 | self.config = config |
| 6579 | else: |
| 6580 | self.config = 0 |
| 6581 | if mask != None: |
| 6582 | self.mask = mask |
| 6583 | else: |
| 6584 | self.mask = 0 |
| 6585 | if advertise != None: |
| 6586 | self.advertise = advertise |
| 6587 | else: |
| 6588 | self.advertise = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6589 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6590 | |
| 6591 | def pack(self): |
| 6592 | packed = [] |
| 6593 | packed.append(struct.pack("!B", self.version)) |
| 6594 | packed.append(struct.pack("!B", self.type)) |
| 6595 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6596 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6597 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6598 | packed.append('\x00' * 4) |
| 6599 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 6600 | packed.append('\x00' * 2) |
| 6601 | packed.append(struct.pack("!L", self.config)) |
| 6602 | packed.append(struct.pack("!L", self.mask)) |
| 6603 | packed.append(struct.pack("!L", self.advertise)) |
| 6604 | packed.append('\x00' * 4) |
| 6605 | length = sum([len(x) for x in packed]) |
| 6606 | packed[2] = struct.pack("!H", length) |
| 6607 | return ''.join(packed) |
| 6608 | |
| 6609 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6610 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6611 | obj = port_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6612 | _version = reader.read("!B")[0] |
| 6613 | assert(_version == 2) |
| 6614 | _type = reader.read("!B")[0] |
| 6615 | assert(_type == 16) |
| 6616 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6617 | orig_reader = reader |
| 6618 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6619 | obj.xid = reader.read("!L")[0] |
| 6620 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6621 | reader.skip(4) |
| 6622 | obj.hw_addr = list(reader.read('!6B')) |
| 6623 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6624 | obj.config = reader.read("!L")[0] |
| 6625 | obj.mask = reader.read("!L")[0] |
| 6626 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6627 | reader.skip(4) |
| 6628 | return obj |
| 6629 | |
| 6630 | def __eq__(self, other): |
| 6631 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6632 | if self.xid != other.xid: return False |
| 6633 | if self.port_no != other.port_no: return False |
| 6634 | if self.hw_addr != other.hw_addr: return False |
| 6635 | if self.config != other.config: return False |
| 6636 | if self.mask != other.mask: return False |
| 6637 | if self.advertise != other.advertise: return False |
| 6638 | return True |
| 6639 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6640 | def pretty_print(self, q): |
| 6641 | q.text("port_mod {") |
| 6642 | with q.group(): |
| 6643 | with q.indent(2): |
| 6644 | q.breakable() |
| 6645 | q.text("xid = "); |
| 6646 | if self.xid != None: |
| 6647 | q.text("%#x" % self.xid) |
| 6648 | else: |
| 6649 | q.text('None') |
| 6650 | q.text(","); q.breakable() |
| 6651 | q.text("port_no = "); |
| 6652 | q.text(util.pretty_port(self.port_no)) |
| 6653 | q.text(","); q.breakable() |
| 6654 | q.text("hw_addr = "); |
| 6655 | q.text(util.pretty_mac(self.hw_addr)) |
| 6656 | q.text(","); q.breakable() |
| 6657 | q.text("config = "); |
| 6658 | q.text("%#x" % self.config) |
| 6659 | q.text(","); q.breakable() |
| 6660 | q.text("mask = "); |
| 6661 | q.text("%#x" % self.mask) |
| 6662 | q.text(","); q.breakable() |
| 6663 | q.text("advertise = "); |
| 6664 | q.text("%#x" % self.advertise) |
| 6665 | q.breakable() |
| 6666 | q.text('}') |
| 6667 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6668 | message.subtypes[16] = port_mod |
| 6669 | |
| 6670 | class port_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6671 | version = 2 |
| 6672 | type = 1 |
| 6673 | err_type = 7 |
| 6674 | |
| 6675 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6676 | if xid != None: |
| 6677 | self.xid = xid |
| 6678 | else: |
| 6679 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6680 | if code != None: |
| 6681 | self.code = code |
| 6682 | else: |
| 6683 | self.code = 0 |
| 6684 | if data != None: |
| 6685 | self.data = data |
| 6686 | else: |
| 6687 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6688 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6689 | |
| 6690 | def pack(self): |
| 6691 | packed = [] |
| 6692 | packed.append(struct.pack("!B", self.version)) |
| 6693 | packed.append(struct.pack("!B", self.type)) |
| 6694 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6695 | packed.append(struct.pack("!L", self.xid)) |
| 6696 | packed.append(struct.pack("!H", self.err_type)) |
| 6697 | packed.append(struct.pack("!H", self.code)) |
| 6698 | packed.append(self.data) |
| 6699 | length = sum([len(x) for x in packed]) |
| 6700 | packed[2] = struct.pack("!H", length) |
| 6701 | return ''.join(packed) |
| 6702 | |
| 6703 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6704 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6705 | obj = port_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6706 | _version = reader.read("!B")[0] |
| 6707 | assert(_version == 2) |
| 6708 | _type = reader.read("!B")[0] |
| 6709 | assert(_type == 1) |
| 6710 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6711 | orig_reader = reader |
| 6712 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6713 | obj.xid = reader.read("!L")[0] |
| 6714 | _err_type = reader.read("!H")[0] |
| 6715 | assert(_err_type == 7) |
| 6716 | obj.code = reader.read("!H")[0] |
| 6717 | obj.data = str(reader.read_all()) |
| 6718 | return obj |
| 6719 | |
| 6720 | def __eq__(self, other): |
| 6721 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6722 | if self.xid != other.xid: return False |
| 6723 | if self.code != other.code: return False |
| 6724 | if self.data != other.data: return False |
| 6725 | return True |
| 6726 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6727 | def pretty_print(self, q): |
| 6728 | q.text("port_mod_failed_error_msg {") |
| 6729 | with q.group(): |
| 6730 | with q.indent(2): |
| 6731 | q.breakable() |
| 6732 | q.text("xid = "); |
| 6733 | if self.xid != None: |
| 6734 | q.text("%#x" % self.xid) |
| 6735 | else: |
| 6736 | q.text('None') |
| 6737 | q.text(","); q.breakable() |
| 6738 | q.text("code = "); |
| 6739 | q.text("%#x" % self.code) |
| 6740 | q.text(","); q.breakable() |
| 6741 | q.text("data = "); |
| 6742 | q.pp(self.data) |
| 6743 | q.breakable() |
| 6744 | q.text('}') |
| 6745 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6746 | error_msg.subtypes[7] = port_mod_failed_error_msg |
| 6747 | |
| 6748 | class port_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6749 | version = 2 |
| 6750 | type = 19 |
| 6751 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6752 | |
| 6753 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6754 | if xid != None: |
| 6755 | self.xid = xid |
| 6756 | else: |
| 6757 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6758 | if flags != None: |
| 6759 | self.flags = flags |
| 6760 | else: |
| 6761 | self.flags = 0 |
| 6762 | if entries != None: |
| 6763 | self.entries = entries |
| 6764 | else: |
| 6765 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6766 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6767 | |
| 6768 | def pack(self): |
| 6769 | packed = [] |
| 6770 | packed.append(struct.pack("!B", self.version)) |
| 6771 | packed.append(struct.pack("!B", self.type)) |
| 6772 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6773 | packed.append(struct.pack("!L", self.xid)) |
| 6774 | packed.append(struct.pack("!H", self.stats_type)) |
| 6775 | packed.append(struct.pack("!H", self.flags)) |
| 6776 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6777 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6778 | length = sum([len(x) for x in packed]) |
| 6779 | packed[2] = struct.pack("!H", length) |
| 6780 | return ''.join(packed) |
| 6781 | |
| 6782 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6783 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6784 | obj = port_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6785 | _version = reader.read("!B")[0] |
| 6786 | assert(_version == 2) |
| 6787 | _type = reader.read("!B")[0] |
| 6788 | assert(_type == 19) |
| 6789 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6790 | orig_reader = reader |
| 6791 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6792 | obj.xid = reader.read("!L")[0] |
| 6793 | _stats_type = reader.read("!H")[0] |
| 6794 | assert(_stats_type == 4) |
| 6795 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6796 | reader.skip(4) |
| 6797 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 6798 | return obj |
| 6799 | |
| 6800 | def __eq__(self, other): |
| 6801 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6802 | if self.xid != other.xid: return False |
| 6803 | if self.flags != other.flags: return False |
| 6804 | if self.entries != other.entries: return False |
| 6805 | return True |
| 6806 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6807 | def pretty_print(self, q): |
| 6808 | q.text("port_stats_reply {") |
| 6809 | with q.group(): |
| 6810 | with q.indent(2): |
| 6811 | q.breakable() |
| 6812 | q.text("xid = "); |
| 6813 | if self.xid != None: |
| 6814 | q.text("%#x" % self.xid) |
| 6815 | else: |
| 6816 | q.text('None') |
| 6817 | q.text(","); q.breakable() |
| 6818 | q.text("flags = "); |
| 6819 | q.text("%#x" % self.flags) |
| 6820 | q.text(","); q.breakable() |
| 6821 | q.text("entries = "); |
| 6822 | q.pp(self.entries) |
| 6823 | q.breakable() |
| 6824 | q.text('}') |
| 6825 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6826 | stats_reply.subtypes[4] = port_stats_reply |
| 6827 | |
| 6828 | class port_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6829 | version = 2 |
| 6830 | type = 18 |
| 6831 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6832 | |
| 6833 | def __init__(self, xid=None, flags=None, port_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6834 | if xid != None: |
| 6835 | self.xid = xid |
| 6836 | else: |
| 6837 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6838 | if flags != None: |
| 6839 | self.flags = flags |
| 6840 | else: |
| 6841 | self.flags = 0 |
| 6842 | if port_no != None: |
| 6843 | self.port_no = port_no |
| 6844 | else: |
| 6845 | self.port_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6846 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6847 | |
| 6848 | def pack(self): |
| 6849 | packed = [] |
| 6850 | packed.append(struct.pack("!B", self.version)) |
| 6851 | packed.append(struct.pack("!B", self.type)) |
| 6852 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6853 | packed.append(struct.pack("!L", self.xid)) |
| 6854 | packed.append(struct.pack("!H", self.stats_type)) |
| 6855 | packed.append(struct.pack("!H", self.flags)) |
| 6856 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6857 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6858 | packed.append('\x00' * 4) |
| 6859 | length = sum([len(x) for x in packed]) |
| 6860 | packed[2] = struct.pack("!H", length) |
| 6861 | return ''.join(packed) |
| 6862 | |
| 6863 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6864 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6865 | obj = port_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6866 | _version = reader.read("!B")[0] |
| 6867 | assert(_version == 2) |
| 6868 | _type = reader.read("!B")[0] |
| 6869 | assert(_type == 18) |
| 6870 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6871 | orig_reader = reader |
| 6872 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6873 | obj.xid = reader.read("!L")[0] |
| 6874 | _stats_type = reader.read("!H")[0] |
| 6875 | assert(_stats_type == 4) |
| 6876 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6877 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6878 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6879 | reader.skip(4) |
| 6880 | return obj |
| 6881 | |
| 6882 | def __eq__(self, other): |
| 6883 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6884 | if self.xid != other.xid: return False |
| 6885 | if self.flags != other.flags: return False |
| 6886 | if self.port_no != other.port_no: return False |
| 6887 | return True |
| 6888 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6889 | def pretty_print(self, q): |
| 6890 | q.text("port_stats_request {") |
| 6891 | with q.group(): |
| 6892 | with q.indent(2): |
| 6893 | q.breakable() |
| 6894 | q.text("xid = "); |
| 6895 | if self.xid != None: |
| 6896 | q.text("%#x" % self.xid) |
| 6897 | else: |
| 6898 | q.text('None') |
| 6899 | q.text(","); q.breakable() |
| 6900 | q.text("flags = "); |
| 6901 | q.text("%#x" % self.flags) |
| 6902 | q.text(","); q.breakable() |
| 6903 | q.text("port_no = "); |
| 6904 | q.text(util.pretty_port(self.port_no)) |
| 6905 | q.breakable() |
| 6906 | q.text('}') |
| 6907 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6908 | stats_request.subtypes[4] = port_stats_request |
| 6909 | |
| 6910 | class port_status(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6911 | version = 2 |
| 6912 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6913 | |
| 6914 | def __init__(self, xid=None, reason=None, desc=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6915 | if xid != None: |
| 6916 | self.xid = xid |
| 6917 | else: |
| 6918 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6919 | if reason != None: |
| 6920 | self.reason = reason |
| 6921 | else: |
| 6922 | self.reason = 0 |
| 6923 | if desc != None: |
| 6924 | self.desc = desc |
| 6925 | else: |
| 6926 | self.desc = common.port_desc() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6927 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6928 | |
| 6929 | def pack(self): |
| 6930 | packed = [] |
| 6931 | packed.append(struct.pack("!B", self.version)) |
| 6932 | packed.append(struct.pack("!B", self.type)) |
| 6933 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6934 | packed.append(struct.pack("!L", self.xid)) |
| 6935 | packed.append(struct.pack("!B", self.reason)) |
| 6936 | packed.append('\x00' * 7) |
| 6937 | packed.append(self.desc.pack()) |
| 6938 | length = sum([len(x) for x in packed]) |
| 6939 | packed[2] = struct.pack("!H", length) |
| 6940 | return ''.join(packed) |
| 6941 | |
| 6942 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6943 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6944 | obj = port_status() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6945 | _version = reader.read("!B")[0] |
| 6946 | assert(_version == 2) |
| 6947 | _type = reader.read("!B")[0] |
| 6948 | assert(_type == 12) |
| 6949 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6950 | orig_reader = reader |
| 6951 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6952 | obj.xid = reader.read("!L")[0] |
| 6953 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6954 | reader.skip(7) |
| 6955 | obj.desc = common.port_desc.unpack(reader) |
| 6956 | return obj |
| 6957 | |
| 6958 | def __eq__(self, other): |
| 6959 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6960 | if self.xid != other.xid: return False |
| 6961 | if self.reason != other.reason: return False |
| 6962 | if self.desc != other.desc: return False |
| 6963 | return True |
| 6964 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6965 | def pretty_print(self, q): |
| 6966 | q.text("port_status {") |
| 6967 | with q.group(): |
| 6968 | with q.indent(2): |
| 6969 | q.breakable() |
| 6970 | q.text("xid = "); |
| 6971 | if self.xid != None: |
| 6972 | q.text("%#x" % self.xid) |
| 6973 | else: |
| 6974 | q.text('None') |
| 6975 | q.text(","); q.breakable() |
| 6976 | q.text("reason = "); |
| 6977 | q.text("%#x" % self.reason) |
| 6978 | q.text(","); q.breakable() |
| 6979 | q.text("desc = "); |
| 6980 | q.pp(self.desc) |
| 6981 | q.breakable() |
| 6982 | q.text('}') |
| 6983 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6984 | message.subtypes[12] = port_status |
| 6985 | |
| 6986 | class queue_get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6987 | version = 2 |
| 6988 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6989 | |
| 6990 | def __init__(self, xid=None, port=None, queues=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6991 | if xid != None: |
| 6992 | self.xid = xid |
| 6993 | else: |
| 6994 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6995 | if port != None: |
| 6996 | self.port = port |
| 6997 | else: |
| 6998 | self.port = 0 |
| 6999 | if queues != None: |
| 7000 | self.queues = queues |
| 7001 | else: |
| 7002 | self.queues = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7003 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7004 | |
| 7005 | def pack(self): |
| 7006 | packed = [] |
| 7007 | packed.append(struct.pack("!B", self.version)) |
| 7008 | packed.append(struct.pack("!B", self.type)) |
| 7009 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7010 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7011 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7012 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7013 | packed.append(loxi.generic_util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7014 | length = sum([len(x) for x in packed]) |
| 7015 | packed[2] = struct.pack("!H", length) |
| 7016 | return ''.join(packed) |
| 7017 | |
| 7018 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7019 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7020 | obj = queue_get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7021 | _version = reader.read("!B")[0] |
| 7022 | assert(_version == 2) |
| 7023 | _type = reader.read("!B")[0] |
| 7024 | assert(_type == 23) |
| 7025 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7026 | orig_reader = reader |
| 7027 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7028 | obj.xid = reader.read("!L")[0] |
| 7029 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7030 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7031 | obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7032 | return obj |
| 7033 | |
| 7034 | def __eq__(self, other): |
| 7035 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7036 | if self.xid != other.xid: return False |
| 7037 | if self.port != other.port: return False |
| 7038 | if self.queues != other.queues: return False |
| 7039 | return True |
| 7040 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7041 | def pretty_print(self, q): |
| 7042 | q.text("queue_get_config_reply {") |
| 7043 | with q.group(): |
| 7044 | with q.indent(2): |
| 7045 | q.breakable() |
| 7046 | q.text("xid = "); |
| 7047 | if self.xid != None: |
| 7048 | q.text("%#x" % self.xid) |
| 7049 | else: |
| 7050 | q.text('None') |
| 7051 | q.text(","); q.breakable() |
| 7052 | q.text("port = "); |
| 7053 | q.text(util.pretty_port(self.port)) |
| 7054 | q.text(","); q.breakable() |
| 7055 | q.text("queues = "); |
| 7056 | q.pp(self.queues) |
| 7057 | q.breakable() |
| 7058 | q.text('}') |
| 7059 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7060 | message.subtypes[23] = queue_get_config_reply |
| 7061 | |
| 7062 | class queue_get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7063 | version = 2 |
| 7064 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7065 | |
| 7066 | def __init__(self, xid=None, port=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7067 | if xid != None: |
| 7068 | self.xid = xid |
| 7069 | else: |
| 7070 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7071 | if port != None: |
| 7072 | self.port = port |
| 7073 | else: |
| 7074 | self.port = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7075 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7076 | |
| 7077 | def pack(self): |
| 7078 | packed = [] |
| 7079 | packed.append(struct.pack("!B", self.version)) |
| 7080 | packed.append(struct.pack("!B", self.type)) |
| 7081 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7082 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7083 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7084 | packed.append('\x00' * 4) |
| 7085 | length = sum([len(x) for x in packed]) |
| 7086 | packed[2] = struct.pack("!H", length) |
| 7087 | return ''.join(packed) |
| 7088 | |
| 7089 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7090 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7091 | obj = queue_get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7092 | _version = reader.read("!B")[0] |
| 7093 | assert(_version == 2) |
| 7094 | _type = reader.read("!B")[0] |
| 7095 | assert(_type == 22) |
| 7096 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7097 | orig_reader = reader |
| 7098 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7099 | obj.xid = reader.read("!L")[0] |
| 7100 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7101 | reader.skip(4) |
| 7102 | return obj |
| 7103 | |
| 7104 | def __eq__(self, other): |
| 7105 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7106 | if self.xid != other.xid: return False |
| 7107 | if self.port != other.port: return False |
| 7108 | return True |
| 7109 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7110 | def pretty_print(self, q): |
| 7111 | q.text("queue_get_config_request {") |
| 7112 | with q.group(): |
| 7113 | with q.indent(2): |
| 7114 | q.breakable() |
| 7115 | q.text("xid = "); |
| 7116 | if self.xid != None: |
| 7117 | q.text("%#x" % self.xid) |
| 7118 | else: |
| 7119 | q.text('None') |
| 7120 | q.text(","); q.breakable() |
| 7121 | q.text("port = "); |
| 7122 | q.text(util.pretty_port(self.port)) |
| 7123 | q.breakable() |
| 7124 | q.text('}') |
| 7125 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7126 | message.subtypes[22] = queue_get_config_request |
| 7127 | |
| 7128 | class queue_op_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7129 | version = 2 |
| 7130 | type = 1 |
| 7131 | err_type = 9 |
| 7132 | |
| 7133 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7134 | if xid != None: |
| 7135 | self.xid = xid |
| 7136 | else: |
| 7137 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7138 | if code != None: |
| 7139 | self.code = code |
| 7140 | else: |
| 7141 | self.code = 0 |
| 7142 | if data != None: |
| 7143 | self.data = data |
| 7144 | else: |
| 7145 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7146 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7147 | |
| 7148 | def pack(self): |
| 7149 | packed = [] |
| 7150 | packed.append(struct.pack("!B", self.version)) |
| 7151 | packed.append(struct.pack("!B", self.type)) |
| 7152 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7153 | packed.append(struct.pack("!L", self.xid)) |
| 7154 | packed.append(struct.pack("!H", self.err_type)) |
| 7155 | packed.append(struct.pack("!H", self.code)) |
| 7156 | packed.append(self.data) |
| 7157 | length = sum([len(x) for x in packed]) |
| 7158 | packed[2] = struct.pack("!H", length) |
| 7159 | return ''.join(packed) |
| 7160 | |
| 7161 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7162 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7163 | obj = queue_op_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7164 | _version = reader.read("!B")[0] |
| 7165 | assert(_version == 2) |
| 7166 | _type = reader.read("!B")[0] |
| 7167 | assert(_type == 1) |
| 7168 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7169 | orig_reader = reader |
| 7170 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7171 | obj.xid = reader.read("!L")[0] |
| 7172 | _err_type = reader.read("!H")[0] |
| 7173 | assert(_err_type == 9) |
| 7174 | obj.code = reader.read("!H")[0] |
| 7175 | obj.data = str(reader.read_all()) |
| 7176 | return obj |
| 7177 | |
| 7178 | def __eq__(self, other): |
| 7179 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7180 | if self.xid != other.xid: return False |
| 7181 | if self.code != other.code: return False |
| 7182 | if self.data != other.data: return False |
| 7183 | return True |
| 7184 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7185 | def pretty_print(self, q): |
| 7186 | q.text("queue_op_failed_error_msg {") |
| 7187 | with q.group(): |
| 7188 | with q.indent(2): |
| 7189 | q.breakable() |
| 7190 | q.text("xid = "); |
| 7191 | if self.xid != None: |
| 7192 | q.text("%#x" % self.xid) |
| 7193 | else: |
| 7194 | q.text('None') |
| 7195 | q.text(","); q.breakable() |
| 7196 | q.text("code = "); |
| 7197 | q.text("%#x" % self.code) |
| 7198 | q.text(","); q.breakable() |
| 7199 | q.text("data = "); |
| 7200 | q.pp(self.data) |
| 7201 | q.breakable() |
| 7202 | q.text('}') |
| 7203 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7204 | error_msg.subtypes[9] = queue_op_failed_error_msg |
| 7205 | |
| 7206 | class queue_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7207 | version = 2 |
| 7208 | type = 19 |
| 7209 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7210 | |
| 7211 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7212 | if xid != None: |
| 7213 | self.xid = xid |
| 7214 | else: |
| 7215 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7216 | if flags != None: |
| 7217 | self.flags = flags |
| 7218 | else: |
| 7219 | self.flags = 0 |
| 7220 | if entries != None: |
| 7221 | self.entries = entries |
| 7222 | else: |
| 7223 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7224 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7225 | |
| 7226 | def pack(self): |
| 7227 | packed = [] |
| 7228 | packed.append(struct.pack("!B", self.version)) |
| 7229 | packed.append(struct.pack("!B", self.type)) |
| 7230 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7231 | packed.append(struct.pack("!L", self.xid)) |
| 7232 | packed.append(struct.pack("!H", self.stats_type)) |
| 7233 | packed.append(struct.pack("!H", self.flags)) |
| 7234 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7235 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7236 | length = sum([len(x) for x in packed]) |
| 7237 | packed[2] = struct.pack("!H", length) |
| 7238 | return ''.join(packed) |
| 7239 | |
| 7240 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7241 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7242 | obj = queue_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7243 | _version = reader.read("!B")[0] |
| 7244 | assert(_version == 2) |
| 7245 | _type = reader.read("!B")[0] |
| 7246 | assert(_type == 19) |
| 7247 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7248 | orig_reader = reader |
| 7249 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7250 | obj.xid = reader.read("!L")[0] |
| 7251 | _stats_type = reader.read("!H")[0] |
| 7252 | assert(_stats_type == 5) |
| 7253 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7254 | reader.skip(4) |
| 7255 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 7256 | return obj |
| 7257 | |
| 7258 | def __eq__(self, other): |
| 7259 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7260 | if self.xid != other.xid: return False |
| 7261 | if self.flags != other.flags: return False |
| 7262 | if self.entries != other.entries: return False |
| 7263 | return True |
| 7264 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7265 | def pretty_print(self, q): |
| 7266 | q.text("queue_stats_reply {") |
| 7267 | with q.group(): |
| 7268 | with q.indent(2): |
| 7269 | q.breakable() |
| 7270 | q.text("xid = "); |
| 7271 | if self.xid != None: |
| 7272 | q.text("%#x" % self.xid) |
| 7273 | else: |
| 7274 | q.text('None') |
| 7275 | q.text(","); q.breakable() |
| 7276 | q.text("flags = "); |
| 7277 | q.text("%#x" % self.flags) |
| 7278 | q.text(","); q.breakable() |
| 7279 | q.text("entries = "); |
| 7280 | q.pp(self.entries) |
| 7281 | q.breakable() |
| 7282 | q.text('}') |
| 7283 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7284 | stats_reply.subtypes[5] = queue_stats_reply |
| 7285 | |
| 7286 | class queue_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7287 | version = 2 |
| 7288 | type = 18 |
| 7289 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7290 | |
| 7291 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7292 | if xid != None: |
| 7293 | self.xid = xid |
| 7294 | else: |
| 7295 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7296 | if flags != None: |
| 7297 | self.flags = flags |
| 7298 | else: |
| 7299 | self.flags = 0 |
| 7300 | if port_no != None: |
| 7301 | self.port_no = port_no |
| 7302 | else: |
| 7303 | self.port_no = 0 |
| 7304 | if queue_id != None: |
| 7305 | self.queue_id = queue_id |
| 7306 | else: |
| 7307 | self.queue_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7308 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7309 | |
| 7310 | def pack(self): |
| 7311 | packed = [] |
| 7312 | packed.append(struct.pack("!B", self.version)) |
| 7313 | packed.append(struct.pack("!B", self.type)) |
| 7314 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7315 | packed.append(struct.pack("!L", self.xid)) |
| 7316 | packed.append(struct.pack("!H", self.stats_type)) |
| 7317 | packed.append(struct.pack("!H", self.flags)) |
| 7318 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7319 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7320 | packed.append(struct.pack("!L", self.queue_id)) |
| 7321 | length = sum([len(x) for x in packed]) |
| 7322 | packed[2] = struct.pack("!H", length) |
| 7323 | return ''.join(packed) |
| 7324 | |
| 7325 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7326 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7327 | obj = queue_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7328 | _version = reader.read("!B")[0] |
| 7329 | assert(_version == 2) |
| 7330 | _type = reader.read("!B")[0] |
| 7331 | assert(_type == 18) |
| 7332 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7333 | orig_reader = reader |
| 7334 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7335 | obj.xid = reader.read("!L")[0] |
| 7336 | _stats_type = reader.read("!H")[0] |
| 7337 | assert(_stats_type == 5) |
| 7338 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7339 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7340 | obj.port_no = util.unpack_port_no(reader) |
| 7341 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7342 | return obj |
| 7343 | |
| 7344 | def __eq__(self, other): |
| 7345 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7346 | if self.xid != other.xid: return False |
| 7347 | if self.flags != other.flags: return False |
| 7348 | if self.port_no != other.port_no: return False |
| 7349 | if self.queue_id != other.queue_id: return False |
| 7350 | return True |
| 7351 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7352 | def pretty_print(self, q): |
| 7353 | q.text("queue_stats_request {") |
| 7354 | with q.group(): |
| 7355 | with q.indent(2): |
| 7356 | q.breakable() |
| 7357 | q.text("xid = "); |
| 7358 | if self.xid != None: |
| 7359 | q.text("%#x" % self.xid) |
| 7360 | else: |
| 7361 | q.text('None') |
| 7362 | q.text(","); q.breakable() |
| 7363 | q.text("flags = "); |
| 7364 | q.text("%#x" % self.flags) |
| 7365 | q.text(","); q.breakable() |
| 7366 | q.text("port_no = "); |
| 7367 | q.text(util.pretty_port(self.port_no)) |
| 7368 | q.text(","); q.breakable() |
| 7369 | q.text("queue_id = "); |
| 7370 | q.text("%#x" % self.queue_id) |
| 7371 | q.breakable() |
| 7372 | q.text('}') |
| 7373 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7374 | stats_request.subtypes[5] = queue_stats_request |
| 7375 | |
| 7376 | class set_config(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7377 | version = 2 |
| 7378 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7379 | |
| 7380 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7381 | if xid != None: |
| 7382 | self.xid = xid |
| 7383 | else: |
| 7384 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7385 | if flags != None: |
| 7386 | self.flags = flags |
| 7387 | else: |
| 7388 | self.flags = 0 |
| 7389 | if miss_send_len != None: |
| 7390 | self.miss_send_len = miss_send_len |
| 7391 | else: |
| 7392 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7393 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7394 | |
| 7395 | def pack(self): |
| 7396 | packed = [] |
| 7397 | packed.append(struct.pack("!B", self.version)) |
| 7398 | packed.append(struct.pack("!B", self.type)) |
| 7399 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7400 | packed.append(struct.pack("!L", self.xid)) |
| 7401 | packed.append(struct.pack("!H", self.flags)) |
| 7402 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 7403 | length = sum([len(x) for x in packed]) |
| 7404 | packed[2] = struct.pack("!H", length) |
| 7405 | return ''.join(packed) |
| 7406 | |
| 7407 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7408 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7409 | obj = set_config() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7410 | _version = reader.read("!B")[0] |
| 7411 | assert(_version == 2) |
| 7412 | _type = reader.read("!B")[0] |
| 7413 | assert(_type == 9) |
| 7414 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7415 | orig_reader = reader |
| 7416 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7417 | obj.xid = reader.read("!L")[0] |
| 7418 | obj.flags = reader.read("!H")[0] |
| 7419 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7420 | return obj |
| 7421 | |
| 7422 | def __eq__(self, other): |
| 7423 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7424 | if self.xid != other.xid: return False |
| 7425 | if self.flags != other.flags: return False |
| 7426 | if self.miss_send_len != other.miss_send_len: return False |
| 7427 | return True |
| 7428 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7429 | def pretty_print(self, q): |
| 7430 | q.text("set_config {") |
| 7431 | with q.group(): |
| 7432 | with q.indent(2): |
| 7433 | q.breakable() |
| 7434 | q.text("xid = "); |
| 7435 | if self.xid != None: |
| 7436 | q.text("%#x" % self.xid) |
| 7437 | else: |
| 7438 | q.text('None') |
| 7439 | q.text(","); q.breakable() |
| 7440 | q.text("flags = "); |
| 7441 | q.text("%#x" % self.flags) |
| 7442 | q.text(","); q.breakable() |
| 7443 | q.text("miss_send_len = "); |
| 7444 | q.text("%#x" % self.miss_send_len) |
| 7445 | q.breakable() |
| 7446 | q.text('}') |
| 7447 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7448 | message.subtypes[9] = set_config |
| 7449 | |
| 7450 | class switch_config_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7451 | version = 2 |
| 7452 | type = 1 |
| 7453 | err_type = 10 |
| 7454 | |
| 7455 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7456 | if xid != None: |
| 7457 | self.xid = xid |
| 7458 | else: |
| 7459 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7460 | if code != None: |
| 7461 | self.code = code |
| 7462 | else: |
| 7463 | self.code = 0 |
| 7464 | if data != None: |
| 7465 | self.data = data |
| 7466 | else: |
| 7467 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7468 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7469 | |
| 7470 | def pack(self): |
| 7471 | packed = [] |
| 7472 | packed.append(struct.pack("!B", self.version)) |
| 7473 | packed.append(struct.pack("!B", self.type)) |
| 7474 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7475 | packed.append(struct.pack("!L", self.xid)) |
| 7476 | packed.append(struct.pack("!H", self.err_type)) |
| 7477 | packed.append(struct.pack("!H", self.code)) |
| 7478 | packed.append(self.data) |
| 7479 | length = sum([len(x) for x in packed]) |
| 7480 | packed[2] = struct.pack("!H", length) |
| 7481 | return ''.join(packed) |
| 7482 | |
| 7483 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7484 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7485 | obj = switch_config_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7486 | _version = reader.read("!B")[0] |
| 7487 | assert(_version == 2) |
| 7488 | _type = reader.read("!B")[0] |
| 7489 | assert(_type == 1) |
| 7490 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7491 | orig_reader = reader |
| 7492 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7493 | obj.xid = reader.read("!L")[0] |
| 7494 | _err_type = reader.read("!H")[0] |
| 7495 | assert(_err_type == 10) |
| 7496 | obj.code = reader.read("!H")[0] |
| 7497 | obj.data = str(reader.read_all()) |
| 7498 | return obj |
| 7499 | |
| 7500 | def __eq__(self, other): |
| 7501 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7502 | if self.xid != other.xid: return False |
| 7503 | if self.code != other.code: return False |
| 7504 | if self.data != other.data: return False |
| 7505 | return True |
| 7506 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7507 | def pretty_print(self, q): |
| 7508 | q.text("switch_config_failed_error_msg {") |
| 7509 | with q.group(): |
| 7510 | with q.indent(2): |
| 7511 | q.breakable() |
| 7512 | q.text("xid = "); |
| 7513 | if self.xid != None: |
| 7514 | q.text("%#x" % self.xid) |
| 7515 | else: |
| 7516 | q.text('None') |
| 7517 | q.text(","); q.breakable() |
| 7518 | q.text("code = "); |
| 7519 | q.text("%#x" % self.code) |
| 7520 | q.text(","); q.breakable() |
| 7521 | q.text("data = "); |
| 7522 | q.pp(self.data) |
| 7523 | q.breakable() |
| 7524 | q.text('}') |
| 7525 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7526 | error_msg.subtypes[10] = switch_config_failed_error_msg |
| 7527 | |
| 7528 | class table_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7529 | version = 2 |
| 7530 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7531 | |
| 7532 | def __init__(self, xid=None, table_id=None, config=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7533 | if xid != None: |
| 7534 | self.xid = xid |
| 7535 | else: |
| 7536 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7537 | if table_id != None: |
| 7538 | self.table_id = table_id |
| 7539 | else: |
| 7540 | self.table_id = 0 |
| 7541 | if config != None: |
| 7542 | self.config = config |
| 7543 | else: |
| 7544 | self.config = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7545 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7546 | |
| 7547 | def pack(self): |
| 7548 | packed = [] |
| 7549 | packed.append(struct.pack("!B", self.version)) |
| 7550 | packed.append(struct.pack("!B", self.type)) |
| 7551 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7552 | packed.append(struct.pack("!L", self.xid)) |
| 7553 | packed.append(struct.pack("!B", self.table_id)) |
| 7554 | packed.append('\x00' * 3) |
| 7555 | packed.append(struct.pack("!L", self.config)) |
| 7556 | length = sum([len(x) for x in packed]) |
| 7557 | packed[2] = struct.pack("!H", length) |
| 7558 | return ''.join(packed) |
| 7559 | |
| 7560 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7561 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7562 | obj = table_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7563 | _version = reader.read("!B")[0] |
| 7564 | assert(_version == 2) |
| 7565 | _type = reader.read("!B")[0] |
| 7566 | assert(_type == 17) |
| 7567 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7568 | orig_reader = reader |
| 7569 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7570 | obj.xid = reader.read("!L")[0] |
| 7571 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7572 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7573 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7574 | return obj |
| 7575 | |
| 7576 | def __eq__(self, other): |
| 7577 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7578 | if self.xid != other.xid: return False |
| 7579 | if self.table_id != other.table_id: return False |
| 7580 | if self.config != other.config: return False |
| 7581 | return True |
| 7582 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7583 | def pretty_print(self, q): |
| 7584 | q.text("table_mod {") |
| 7585 | with q.group(): |
| 7586 | with q.indent(2): |
| 7587 | q.breakable() |
| 7588 | q.text("xid = "); |
| 7589 | if self.xid != None: |
| 7590 | q.text("%#x" % self.xid) |
| 7591 | else: |
| 7592 | q.text('None') |
| 7593 | q.text(","); q.breakable() |
| 7594 | q.text("table_id = "); |
| 7595 | q.text("%#x" % self.table_id) |
| 7596 | q.text(","); q.breakable() |
| 7597 | q.text("config = "); |
| 7598 | q.text("%#x" % self.config) |
| 7599 | q.breakable() |
| 7600 | q.text('}') |
| 7601 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7602 | message.subtypes[17] = table_mod |
| 7603 | |
| 7604 | class table_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7605 | version = 2 |
| 7606 | type = 1 |
| 7607 | err_type = 8 |
| 7608 | |
| 7609 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7610 | if xid != None: |
| 7611 | self.xid = xid |
| 7612 | else: |
| 7613 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7614 | if code != None: |
| 7615 | self.code = code |
| 7616 | else: |
| 7617 | self.code = 0 |
| 7618 | if data != None: |
| 7619 | self.data = data |
| 7620 | else: |
| 7621 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7622 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7623 | |
| 7624 | def pack(self): |
| 7625 | packed = [] |
| 7626 | packed.append(struct.pack("!B", self.version)) |
| 7627 | packed.append(struct.pack("!B", self.type)) |
| 7628 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7629 | packed.append(struct.pack("!L", self.xid)) |
| 7630 | packed.append(struct.pack("!H", self.err_type)) |
| 7631 | packed.append(struct.pack("!H", self.code)) |
| 7632 | packed.append(self.data) |
| 7633 | length = sum([len(x) for x in packed]) |
| 7634 | packed[2] = struct.pack("!H", length) |
| 7635 | return ''.join(packed) |
| 7636 | |
| 7637 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7638 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7639 | obj = table_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7640 | _version = reader.read("!B")[0] |
| 7641 | assert(_version == 2) |
| 7642 | _type = reader.read("!B")[0] |
| 7643 | assert(_type == 1) |
| 7644 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7645 | orig_reader = reader |
| 7646 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7647 | obj.xid = reader.read("!L")[0] |
| 7648 | _err_type = reader.read("!H")[0] |
| 7649 | assert(_err_type == 8) |
| 7650 | obj.code = reader.read("!H")[0] |
| 7651 | obj.data = str(reader.read_all()) |
| 7652 | return obj |
| 7653 | |
| 7654 | def __eq__(self, other): |
| 7655 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7656 | if self.xid != other.xid: return False |
| 7657 | if self.code != other.code: return False |
| 7658 | if self.data != other.data: return False |
| 7659 | return True |
| 7660 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7661 | def pretty_print(self, q): |
| 7662 | q.text("table_mod_failed_error_msg {") |
| 7663 | with q.group(): |
| 7664 | with q.indent(2): |
| 7665 | q.breakable() |
| 7666 | q.text("xid = "); |
| 7667 | if self.xid != None: |
| 7668 | q.text("%#x" % self.xid) |
| 7669 | else: |
| 7670 | q.text('None') |
| 7671 | q.text(","); q.breakable() |
| 7672 | q.text("code = "); |
| 7673 | q.text("%#x" % self.code) |
| 7674 | q.text(","); q.breakable() |
| 7675 | q.text("data = "); |
| 7676 | q.pp(self.data) |
| 7677 | q.breakable() |
| 7678 | q.text('}') |
| 7679 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7680 | error_msg.subtypes[8] = table_mod_failed_error_msg |
| 7681 | |
| 7682 | class table_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7683 | version = 2 |
| 7684 | type = 19 |
| 7685 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7686 | |
| 7687 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7688 | if xid != None: |
| 7689 | self.xid = xid |
| 7690 | else: |
| 7691 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7692 | if flags != None: |
| 7693 | self.flags = flags |
| 7694 | else: |
| 7695 | self.flags = 0 |
| 7696 | if entries != None: |
| 7697 | self.entries = entries |
| 7698 | else: |
| 7699 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7700 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7701 | |
| 7702 | def pack(self): |
| 7703 | packed = [] |
| 7704 | packed.append(struct.pack("!B", self.version)) |
| 7705 | packed.append(struct.pack("!B", self.type)) |
| 7706 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7707 | packed.append(struct.pack("!L", self.xid)) |
| 7708 | packed.append(struct.pack("!H", self.stats_type)) |
| 7709 | packed.append(struct.pack("!H", self.flags)) |
| 7710 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7711 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7712 | length = sum([len(x) for x in packed]) |
| 7713 | packed[2] = struct.pack("!H", length) |
| 7714 | return ''.join(packed) |
| 7715 | |
| 7716 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7717 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7718 | obj = table_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7719 | _version = reader.read("!B")[0] |
| 7720 | assert(_version == 2) |
| 7721 | _type = reader.read("!B")[0] |
| 7722 | assert(_type == 19) |
| 7723 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7724 | orig_reader = reader |
| 7725 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7726 | obj.xid = reader.read("!L")[0] |
| 7727 | _stats_type = reader.read("!H")[0] |
| 7728 | assert(_stats_type == 3) |
| 7729 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7730 | reader.skip(4) |
| 7731 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 7732 | return obj |
| 7733 | |
| 7734 | def __eq__(self, other): |
| 7735 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7736 | if self.xid != other.xid: return False |
| 7737 | if self.flags != other.flags: return False |
| 7738 | if self.entries != other.entries: return False |
| 7739 | return True |
| 7740 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7741 | def pretty_print(self, q): |
| 7742 | q.text("table_stats_reply {") |
| 7743 | with q.group(): |
| 7744 | with q.indent(2): |
| 7745 | q.breakable() |
| 7746 | q.text("xid = "); |
| 7747 | if self.xid != None: |
| 7748 | q.text("%#x" % self.xid) |
| 7749 | else: |
| 7750 | q.text('None') |
| 7751 | q.text(","); q.breakable() |
| 7752 | q.text("flags = "); |
| 7753 | q.text("%#x" % self.flags) |
| 7754 | q.text(","); q.breakable() |
| 7755 | q.text("entries = "); |
| 7756 | q.pp(self.entries) |
| 7757 | q.breakable() |
| 7758 | q.text('}') |
| 7759 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7760 | stats_reply.subtypes[3] = table_stats_reply |
| 7761 | |
| 7762 | class table_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7763 | version = 2 |
| 7764 | type = 18 |
| 7765 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7766 | |
| 7767 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7768 | if xid != None: |
| 7769 | self.xid = xid |
| 7770 | else: |
| 7771 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7772 | if flags != None: |
| 7773 | self.flags = flags |
| 7774 | else: |
| 7775 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7776 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7777 | |
| 7778 | def pack(self): |
| 7779 | packed = [] |
| 7780 | packed.append(struct.pack("!B", self.version)) |
| 7781 | packed.append(struct.pack("!B", self.type)) |
| 7782 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7783 | packed.append(struct.pack("!L", self.xid)) |
| 7784 | packed.append(struct.pack("!H", self.stats_type)) |
| 7785 | packed.append(struct.pack("!H", self.flags)) |
| 7786 | packed.append('\x00' * 4) |
| 7787 | length = sum([len(x) for x in packed]) |
| 7788 | packed[2] = struct.pack("!H", length) |
| 7789 | return ''.join(packed) |
| 7790 | |
| 7791 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7792 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7793 | obj = table_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7794 | _version = reader.read("!B")[0] |
| 7795 | assert(_version == 2) |
| 7796 | _type = reader.read("!B")[0] |
| 7797 | assert(_type == 18) |
| 7798 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7799 | orig_reader = reader |
| 7800 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7801 | obj.xid = reader.read("!L")[0] |
| 7802 | _stats_type = reader.read("!H")[0] |
| 7803 | assert(_stats_type == 3) |
| 7804 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7805 | reader.skip(4) |
| 7806 | return obj |
| 7807 | |
| 7808 | def __eq__(self, other): |
| 7809 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7810 | if self.xid != other.xid: return False |
| 7811 | if self.flags != other.flags: return False |
| 7812 | return True |
| 7813 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7814 | def pretty_print(self, q): |
| 7815 | q.text("table_stats_request {") |
| 7816 | with q.group(): |
| 7817 | with q.indent(2): |
| 7818 | q.breakable() |
| 7819 | q.text("xid = "); |
| 7820 | if self.xid != None: |
| 7821 | q.text("%#x" % self.xid) |
| 7822 | else: |
| 7823 | q.text('None') |
| 7824 | q.text(","); q.breakable() |
| 7825 | q.text("flags = "); |
| 7826 | q.text("%#x" % self.flags) |
| 7827 | q.breakable() |
| 7828 | q.text('}') |
| 7829 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7830 | stats_request.subtypes[3] = table_stats_request |
| 7831 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7832 | |
| 7833 | def parse_header(buf): |
| 7834 | if len(buf) < 8: |
| 7835 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 7836 | return struct.unpack_from("!BBHL", buf) |
| 7837 | |
| 7838 | def parse_message(buf): |
| 7839 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 7840 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 7841 | raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7842 | if len(buf) != msg_len: |
| 7843 | raise loxi.ProtocolError("incorrect message size") |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7844 | return message.unpack(loxi.generic_util.OFReader(buf)) |