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 | |
| 971 | def __init__(self, xid=None, experimenter=None, subtype=None, data=None): |
| 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 |
| 980 | if subtype != None: |
| 981 | self.subtype = subtype |
| 982 | else: |
| 983 | self.subtype = 0 |
| 984 | if data != None: |
| 985 | self.data = data |
| 986 | else: |
| 987 | self.data = '' |
| 988 | return |
| 989 | |
| 990 | def pack(self): |
| 991 | packed = [] |
| 992 | packed.append(struct.pack("!B", self.version)) |
| 993 | packed.append(struct.pack("!B", self.type)) |
| 994 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 995 | packed.append(struct.pack("!L", self.xid)) |
| 996 | packed.append(struct.pack("!L", self.experimenter)) |
| 997 | packed.append(struct.pack("!L", self.subtype)) |
| 998 | packed.append(self.data) |
| 999 | length = sum([len(x) for x in packed]) |
| 1000 | packed[2] = struct.pack("!H", length) |
| 1001 | return ''.join(packed) |
| 1002 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1003 | @staticmethod |
| 1004 | def unpack(reader): |
| 1005 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1006 | subclass = experimenter.subtypes.get(subtype) |
| 1007 | if subclass: |
| 1008 | return subclass.unpack(reader) |
| 1009 | |
| 1010 | obj = experimenter() |
| 1011 | _version = reader.read("!B")[0] |
| 1012 | assert(_version == 2) |
| 1013 | _type = reader.read("!B")[0] |
| 1014 | assert(_type == 4) |
| 1015 | _length = reader.read("!H")[0] |
| 1016 | orig_reader = reader |
| 1017 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1018 | obj.xid = reader.read("!L")[0] |
| 1019 | obj.experimenter = reader.read("!L")[0] |
| 1020 | obj.subtype = reader.read("!L")[0] |
| 1021 | obj.data = str(reader.read_all()) |
| 1022 | return obj |
| 1023 | |
| 1024 | def __eq__(self, other): |
| 1025 | if type(self) != type(other): return False |
| 1026 | if self.xid != other.xid: return False |
| 1027 | if self.experimenter != other.experimenter: return False |
| 1028 | if self.subtype != other.subtype: return False |
| 1029 | if self.data != other.data: return False |
| 1030 | return True |
| 1031 | |
| 1032 | def pretty_print(self, q): |
| 1033 | q.text("experimenter {") |
| 1034 | with q.group(): |
| 1035 | with q.indent(2): |
| 1036 | q.breakable() |
| 1037 | q.text("xid = "); |
| 1038 | if self.xid != None: |
| 1039 | q.text("%#x" % self.xid) |
| 1040 | else: |
| 1041 | q.text('None') |
| 1042 | q.text(","); q.breakable() |
| 1043 | q.text("subtype = "); |
| 1044 | q.text("%#x" % self.subtype) |
| 1045 | q.text(","); q.breakable() |
| 1046 | q.text("data = "); |
| 1047 | q.pp(self.data) |
| 1048 | q.breakable() |
| 1049 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1050 | |
| 1051 | message.subtypes[4] = experimenter |
| 1052 | |
| 1053 | class bsn_header(experimenter): |
| 1054 | subtypes = {} |
| 1055 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1056 | version = 2 |
| 1057 | type = 4 |
| 1058 | experimenter = 6035143 |
| 1059 | |
| 1060 | def __init__(self, xid=None, subtype=None): |
| 1061 | if xid != None: |
| 1062 | self.xid = xid |
| 1063 | else: |
| 1064 | self.xid = None |
| 1065 | if subtype != None: |
| 1066 | self.subtype = subtype |
| 1067 | else: |
| 1068 | self.subtype = 0 |
| 1069 | return |
| 1070 | |
| 1071 | def pack(self): |
| 1072 | packed = [] |
| 1073 | packed.append(struct.pack("!B", self.version)) |
| 1074 | packed.append(struct.pack("!B", self.type)) |
| 1075 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1076 | packed.append(struct.pack("!L", self.xid)) |
| 1077 | packed.append(struct.pack("!L", self.experimenter)) |
| 1078 | packed.append(struct.pack("!L", self.subtype)) |
| 1079 | length = sum([len(x) for x in packed]) |
| 1080 | packed[2] = struct.pack("!H", length) |
| 1081 | return ''.join(packed) |
| 1082 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1083 | @staticmethod |
| 1084 | def unpack(reader): |
| 1085 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1086 | subclass = bsn_header.subtypes.get(subtype) |
| 1087 | if subclass: |
| 1088 | return subclass.unpack(reader) |
| 1089 | |
| 1090 | obj = bsn_header() |
| 1091 | _version = reader.read("!B")[0] |
| 1092 | assert(_version == 2) |
| 1093 | _type = reader.read("!B")[0] |
| 1094 | assert(_type == 4) |
| 1095 | _length = reader.read("!H")[0] |
| 1096 | orig_reader = reader |
| 1097 | reader = orig_reader.slice(_length - (2 + 2)) |
| 1098 | obj.xid = reader.read("!L")[0] |
| 1099 | _experimenter = reader.read("!L")[0] |
| 1100 | assert(_experimenter == 6035143) |
| 1101 | obj.subtype = reader.read("!L")[0] |
| 1102 | return obj |
| 1103 | |
| 1104 | def __eq__(self, other): |
| 1105 | if type(self) != type(other): return False |
| 1106 | if self.xid != other.xid: return False |
| 1107 | if self.subtype != other.subtype: return False |
| 1108 | return True |
| 1109 | |
| 1110 | def pretty_print(self, q): |
| 1111 | q.text("bsn_header {") |
| 1112 | with q.group(): |
| 1113 | with q.indent(2): |
| 1114 | q.breakable() |
| 1115 | q.text("xid = "); |
| 1116 | if self.xid != None: |
| 1117 | q.text("%#x" % self.xid) |
| 1118 | else: |
| 1119 | q.text('None') |
| 1120 | q.breakable() |
| 1121 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1122 | |
| 1123 | experimenter.subtypes[6035143] = bsn_header |
| 1124 | |
| 1125 | class bsn_bw_clear_data_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1126 | version = 2 |
| 1127 | type = 4 |
| 1128 | experimenter = 6035143 |
| 1129 | subtype = 22 |
| 1130 | |
| 1131 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1132 | if xid != None: |
| 1133 | self.xid = xid |
| 1134 | else: |
| 1135 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1136 | if status != None: |
| 1137 | self.status = status |
| 1138 | else: |
| 1139 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1140 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1141 | |
| 1142 | def pack(self): |
| 1143 | packed = [] |
| 1144 | packed.append(struct.pack("!B", self.version)) |
| 1145 | packed.append(struct.pack("!B", self.type)) |
| 1146 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1147 | packed.append(struct.pack("!L", self.xid)) |
| 1148 | packed.append(struct.pack("!L", self.experimenter)) |
| 1149 | packed.append(struct.pack("!L", self.subtype)) |
| 1150 | packed.append(struct.pack("!L", self.status)) |
| 1151 | length = sum([len(x) for x in packed]) |
| 1152 | packed[2] = struct.pack("!H", length) |
| 1153 | return ''.join(packed) |
| 1154 | |
| 1155 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1156 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1157 | obj = bsn_bw_clear_data_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1158 | _version = reader.read("!B")[0] |
| 1159 | assert(_version == 2) |
| 1160 | _type = reader.read("!B")[0] |
| 1161 | assert(_type == 4) |
| 1162 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1163 | orig_reader = reader |
| 1164 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1165 | obj.xid = reader.read("!L")[0] |
| 1166 | _experimenter = reader.read("!L")[0] |
| 1167 | assert(_experimenter == 6035143) |
| 1168 | _subtype = reader.read("!L")[0] |
| 1169 | assert(_subtype == 22) |
| 1170 | obj.status = reader.read("!L")[0] |
| 1171 | return obj |
| 1172 | |
| 1173 | def __eq__(self, other): |
| 1174 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1175 | if self.xid != other.xid: return False |
| 1176 | if self.status != other.status: return False |
| 1177 | return True |
| 1178 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1179 | def pretty_print(self, q): |
| 1180 | q.text("bsn_bw_clear_data_reply {") |
| 1181 | with q.group(): |
| 1182 | with q.indent(2): |
| 1183 | q.breakable() |
| 1184 | q.text("xid = "); |
| 1185 | if self.xid != None: |
| 1186 | q.text("%#x" % self.xid) |
| 1187 | else: |
| 1188 | q.text('None') |
| 1189 | q.text(","); q.breakable() |
| 1190 | q.text("status = "); |
| 1191 | q.text("%#x" % self.status) |
| 1192 | q.breakable() |
| 1193 | q.text('}') |
| 1194 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1195 | bsn_header.subtypes[22] = bsn_bw_clear_data_reply |
| 1196 | |
| 1197 | class bsn_bw_clear_data_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1198 | version = 2 |
| 1199 | type = 4 |
| 1200 | experimenter = 6035143 |
| 1201 | subtype = 21 |
| 1202 | |
| 1203 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1204 | if xid != None: |
| 1205 | self.xid = xid |
| 1206 | else: |
| 1207 | self.xid = None |
| 1208 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1209 | |
| 1210 | def pack(self): |
| 1211 | packed = [] |
| 1212 | packed.append(struct.pack("!B", self.version)) |
| 1213 | packed.append(struct.pack("!B", self.type)) |
| 1214 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1215 | packed.append(struct.pack("!L", self.xid)) |
| 1216 | packed.append(struct.pack("!L", self.experimenter)) |
| 1217 | packed.append(struct.pack("!L", self.subtype)) |
| 1218 | length = sum([len(x) for x in packed]) |
| 1219 | packed[2] = struct.pack("!H", length) |
| 1220 | return ''.join(packed) |
| 1221 | |
| 1222 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1223 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1224 | obj = bsn_bw_clear_data_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1225 | _version = reader.read("!B")[0] |
| 1226 | assert(_version == 2) |
| 1227 | _type = reader.read("!B")[0] |
| 1228 | assert(_type == 4) |
| 1229 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1230 | orig_reader = reader |
| 1231 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1232 | obj.xid = reader.read("!L")[0] |
| 1233 | _experimenter = reader.read("!L")[0] |
| 1234 | assert(_experimenter == 6035143) |
| 1235 | _subtype = reader.read("!L")[0] |
| 1236 | assert(_subtype == 21) |
| 1237 | return obj |
| 1238 | |
| 1239 | def __eq__(self, other): |
| 1240 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1241 | if self.xid != other.xid: return False |
| 1242 | return True |
| 1243 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1244 | def pretty_print(self, q): |
| 1245 | q.text("bsn_bw_clear_data_request {") |
| 1246 | with q.group(): |
| 1247 | with q.indent(2): |
| 1248 | q.breakable() |
| 1249 | q.text("xid = "); |
| 1250 | if self.xid != None: |
| 1251 | q.text("%#x" % self.xid) |
| 1252 | else: |
| 1253 | q.text('None') |
| 1254 | q.breakable() |
| 1255 | q.text('}') |
| 1256 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1257 | bsn_header.subtypes[21] = bsn_bw_clear_data_request |
| 1258 | |
| 1259 | class bsn_bw_enable_get_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1260 | version = 2 |
| 1261 | type = 4 |
| 1262 | experimenter = 6035143 |
| 1263 | subtype = 20 |
| 1264 | |
| 1265 | def __init__(self, xid=None, enabled=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1266 | if xid != None: |
| 1267 | self.xid = xid |
| 1268 | else: |
| 1269 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1270 | if enabled != None: |
| 1271 | self.enabled = enabled |
| 1272 | else: |
| 1273 | self.enabled = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1274 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1275 | |
| 1276 | def pack(self): |
| 1277 | packed = [] |
| 1278 | packed.append(struct.pack("!B", self.version)) |
| 1279 | packed.append(struct.pack("!B", self.type)) |
| 1280 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1281 | packed.append(struct.pack("!L", self.xid)) |
| 1282 | packed.append(struct.pack("!L", self.experimenter)) |
| 1283 | packed.append(struct.pack("!L", self.subtype)) |
| 1284 | packed.append(struct.pack("!L", self.enabled)) |
| 1285 | length = sum([len(x) for x in packed]) |
| 1286 | packed[2] = struct.pack("!H", length) |
| 1287 | return ''.join(packed) |
| 1288 | |
| 1289 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1290 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1291 | obj = bsn_bw_enable_get_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1292 | _version = reader.read("!B")[0] |
| 1293 | assert(_version == 2) |
| 1294 | _type = reader.read("!B")[0] |
| 1295 | assert(_type == 4) |
| 1296 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1297 | orig_reader = reader |
| 1298 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1299 | obj.xid = reader.read("!L")[0] |
| 1300 | _experimenter = reader.read("!L")[0] |
| 1301 | assert(_experimenter == 6035143) |
| 1302 | _subtype = reader.read("!L")[0] |
| 1303 | assert(_subtype == 20) |
| 1304 | obj.enabled = reader.read("!L")[0] |
| 1305 | return obj |
| 1306 | |
| 1307 | def __eq__(self, other): |
| 1308 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1309 | if self.xid != other.xid: return False |
| 1310 | if self.enabled != other.enabled: return False |
| 1311 | return True |
| 1312 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1313 | def pretty_print(self, q): |
| 1314 | q.text("bsn_bw_enable_get_reply {") |
| 1315 | with q.group(): |
| 1316 | with q.indent(2): |
| 1317 | q.breakable() |
| 1318 | q.text("xid = "); |
| 1319 | if self.xid != None: |
| 1320 | q.text("%#x" % self.xid) |
| 1321 | else: |
| 1322 | q.text('None') |
| 1323 | q.text(","); q.breakable() |
| 1324 | q.text("enabled = "); |
| 1325 | q.text("%#x" % self.enabled) |
| 1326 | q.breakable() |
| 1327 | q.text('}') |
| 1328 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1329 | bsn_header.subtypes[20] = bsn_bw_enable_get_reply |
| 1330 | |
| 1331 | class bsn_bw_enable_get_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1332 | version = 2 |
| 1333 | type = 4 |
| 1334 | experimenter = 6035143 |
| 1335 | subtype = 19 |
| 1336 | |
| 1337 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1338 | if xid != None: |
| 1339 | self.xid = xid |
| 1340 | else: |
| 1341 | self.xid = None |
| 1342 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1343 | |
| 1344 | def pack(self): |
| 1345 | packed = [] |
| 1346 | packed.append(struct.pack("!B", self.version)) |
| 1347 | packed.append(struct.pack("!B", self.type)) |
| 1348 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1349 | packed.append(struct.pack("!L", self.xid)) |
| 1350 | packed.append(struct.pack("!L", self.experimenter)) |
| 1351 | packed.append(struct.pack("!L", self.subtype)) |
| 1352 | length = sum([len(x) for x in packed]) |
| 1353 | packed[2] = struct.pack("!H", length) |
| 1354 | return ''.join(packed) |
| 1355 | |
| 1356 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1357 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1358 | obj = bsn_bw_enable_get_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1359 | _version = reader.read("!B")[0] |
| 1360 | assert(_version == 2) |
| 1361 | _type = reader.read("!B")[0] |
| 1362 | assert(_type == 4) |
| 1363 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1364 | orig_reader = reader |
| 1365 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1366 | obj.xid = reader.read("!L")[0] |
| 1367 | _experimenter = reader.read("!L")[0] |
| 1368 | assert(_experimenter == 6035143) |
| 1369 | _subtype = reader.read("!L")[0] |
| 1370 | assert(_subtype == 19) |
| 1371 | return obj |
| 1372 | |
| 1373 | def __eq__(self, other): |
| 1374 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1375 | if self.xid != other.xid: return False |
| 1376 | return True |
| 1377 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1378 | def pretty_print(self, q): |
| 1379 | q.text("bsn_bw_enable_get_request {") |
| 1380 | with q.group(): |
| 1381 | with q.indent(2): |
| 1382 | q.breakable() |
| 1383 | q.text("xid = "); |
| 1384 | if self.xid != None: |
| 1385 | q.text("%#x" % self.xid) |
| 1386 | else: |
| 1387 | q.text('None') |
| 1388 | q.breakable() |
| 1389 | q.text('}') |
| 1390 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1391 | bsn_header.subtypes[19] = bsn_bw_enable_get_request |
| 1392 | |
| 1393 | class bsn_bw_enable_set_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1394 | version = 2 |
| 1395 | type = 4 |
| 1396 | experimenter = 6035143 |
| 1397 | subtype = 23 |
| 1398 | |
| 1399 | def __init__(self, xid=None, enable=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1400 | if xid != None: |
| 1401 | self.xid = xid |
| 1402 | else: |
| 1403 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1404 | if enable != None: |
| 1405 | self.enable = enable |
| 1406 | else: |
| 1407 | self.enable = 0 |
| 1408 | if status != None: |
| 1409 | self.status = status |
| 1410 | else: |
| 1411 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1412 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1413 | |
| 1414 | def pack(self): |
| 1415 | packed = [] |
| 1416 | packed.append(struct.pack("!B", self.version)) |
| 1417 | packed.append(struct.pack("!B", self.type)) |
| 1418 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1419 | packed.append(struct.pack("!L", self.xid)) |
| 1420 | packed.append(struct.pack("!L", self.experimenter)) |
| 1421 | packed.append(struct.pack("!L", self.subtype)) |
| 1422 | packed.append(struct.pack("!L", self.enable)) |
| 1423 | packed.append(struct.pack("!L", self.status)) |
| 1424 | length = sum([len(x) for x in packed]) |
| 1425 | packed[2] = struct.pack("!H", length) |
| 1426 | return ''.join(packed) |
| 1427 | |
| 1428 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1429 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1430 | obj = bsn_bw_enable_set_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1431 | _version = reader.read("!B")[0] |
| 1432 | assert(_version == 2) |
| 1433 | _type = reader.read("!B")[0] |
| 1434 | assert(_type == 4) |
| 1435 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1436 | orig_reader = reader |
| 1437 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1438 | obj.xid = reader.read("!L")[0] |
| 1439 | _experimenter = reader.read("!L")[0] |
| 1440 | assert(_experimenter == 6035143) |
| 1441 | _subtype = reader.read("!L")[0] |
| 1442 | assert(_subtype == 23) |
| 1443 | obj.enable = reader.read("!L")[0] |
| 1444 | obj.status = reader.read("!L")[0] |
| 1445 | return obj |
| 1446 | |
| 1447 | def __eq__(self, other): |
| 1448 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1449 | if self.xid != other.xid: return False |
| 1450 | if self.enable != other.enable: return False |
| 1451 | if self.status != other.status: return False |
| 1452 | return True |
| 1453 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1454 | def pretty_print(self, q): |
| 1455 | q.text("bsn_bw_enable_set_reply {") |
| 1456 | with q.group(): |
| 1457 | with q.indent(2): |
| 1458 | q.breakable() |
| 1459 | q.text("xid = "); |
| 1460 | if self.xid != None: |
| 1461 | q.text("%#x" % self.xid) |
| 1462 | else: |
| 1463 | q.text('None') |
| 1464 | q.text(","); q.breakable() |
| 1465 | q.text("enable = "); |
| 1466 | q.text("%#x" % self.enable) |
| 1467 | q.text(","); q.breakable() |
| 1468 | q.text("status = "); |
| 1469 | q.text("%#x" % self.status) |
| 1470 | q.breakable() |
| 1471 | q.text('}') |
| 1472 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1473 | bsn_header.subtypes[23] = bsn_bw_enable_set_reply |
| 1474 | |
| 1475 | class bsn_bw_enable_set_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1476 | version = 2 |
| 1477 | type = 4 |
| 1478 | experimenter = 6035143 |
| 1479 | subtype = 18 |
| 1480 | |
| 1481 | def __init__(self, xid=None, enable=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1482 | if xid != None: |
| 1483 | self.xid = xid |
| 1484 | else: |
| 1485 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1486 | if enable != None: |
| 1487 | self.enable = enable |
| 1488 | else: |
| 1489 | self.enable = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1490 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1491 | |
| 1492 | def pack(self): |
| 1493 | packed = [] |
| 1494 | packed.append(struct.pack("!B", self.version)) |
| 1495 | packed.append(struct.pack("!B", self.type)) |
| 1496 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1497 | packed.append(struct.pack("!L", self.xid)) |
| 1498 | packed.append(struct.pack("!L", self.experimenter)) |
| 1499 | packed.append(struct.pack("!L", self.subtype)) |
| 1500 | packed.append(struct.pack("!L", self.enable)) |
| 1501 | length = sum([len(x) for x in packed]) |
| 1502 | packed[2] = struct.pack("!H", length) |
| 1503 | return ''.join(packed) |
| 1504 | |
| 1505 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1506 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1507 | obj = bsn_bw_enable_set_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1508 | _version = reader.read("!B")[0] |
| 1509 | assert(_version == 2) |
| 1510 | _type = reader.read("!B")[0] |
| 1511 | assert(_type == 4) |
| 1512 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1513 | orig_reader = reader |
| 1514 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1515 | obj.xid = reader.read("!L")[0] |
| 1516 | _experimenter = reader.read("!L")[0] |
| 1517 | assert(_experimenter == 6035143) |
| 1518 | _subtype = reader.read("!L")[0] |
| 1519 | assert(_subtype == 18) |
| 1520 | obj.enable = reader.read("!L")[0] |
| 1521 | return obj |
| 1522 | |
| 1523 | def __eq__(self, other): |
| 1524 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1525 | if self.xid != other.xid: return False |
| 1526 | if self.enable != other.enable: return False |
| 1527 | return True |
| 1528 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1529 | def pretty_print(self, q): |
| 1530 | q.text("bsn_bw_enable_set_request {") |
| 1531 | with q.group(): |
| 1532 | with q.indent(2): |
| 1533 | q.breakable() |
| 1534 | q.text("xid = "); |
| 1535 | if self.xid != None: |
| 1536 | q.text("%#x" % self.xid) |
| 1537 | else: |
| 1538 | q.text('None') |
| 1539 | q.text(","); q.breakable() |
| 1540 | q.text("enable = "); |
| 1541 | q.text("%#x" % self.enable) |
| 1542 | q.breakable() |
| 1543 | q.text('}') |
| 1544 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1545 | bsn_header.subtypes[18] = bsn_bw_enable_set_request |
| 1546 | |
| 1547 | class bsn_get_interfaces_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1548 | version = 2 |
| 1549 | type = 4 |
| 1550 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1551 | subtype = 10 |
| 1552 | |
| 1553 | def __init__(self, xid=None, interfaces=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1554 | if xid != None: |
| 1555 | self.xid = xid |
| 1556 | else: |
| 1557 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1558 | if interfaces != None: |
| 1559 | self.interfaces = interfaces |
| 1560 | else: |
| 1561 | self.interfaces = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1562 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1563 | |
| 1564 | def pack(self): |
| 1565 | packed = [] |
| 1566 | packed.append(struct.pack("!B", self.version)) |
| 1567 | packed.append(struct.pack("!B", self.type)) |
| 1568 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1569 | packed.append(struct.pack("!L", self.xid)) |
| 1570 | packed.append(struct.pack("!L", self.experimenter)) |
| 1571 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1572 | packed.append(loxi.generic_util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1573 | length = sum([len(x) for x in packed]) |
| 1574 | packed[2] = struct.pack("!H", length) |
| 1575 | return ''.join(packed) |
| 1576 | |
| 1577 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1578 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1579 | obj = bsn_get_interfaces_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1580 | _version = reader.read("!B")[0] |
| 1581 | assert(_version == 2) |
| 1582 | _type = reader.read("!B")[0] |
| 1583 | assert(_type == 4) |
| 1584 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1585 | orig_reader = reader |
| 1586 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1587 | obj.xid = reader.read("!L")[0] |
| 1588 | _experimenter = reader.read("!L")[0] |
| 1589 | assert(_experimenter == 6035143) |
| 1590 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1591 | assert(_subtype == 10) |
| 1592 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
| 1593 | return obj |
| 1594 | |
| 1595 | def __eq__(self, other): |
| 1596 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1597 | if self.xid != other.xid: return False |
| 1598 | if self.interfaces != other.interfaces: return False |
| 1599 | return True |
| 1600 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1601 | def pretty_print(self, q): |
| 1602 | q.text("bsn_get_interfaces_reply {") |
| 1603 | with q.group(): |
| 1604 | with q.indent(2): |
| 1605 | q.breakable() |
| 1606 | q.text("xid = "); |
| 1607 | if self.xid != None: |
| 1608 | q.text("%#x" % self.xid) |
| 1609 | else: |
| 1610 | q.text('None') |
| 1611 | q.text(","); q.breakable() |
| 1612 | q.text("interfaces = "); |
| 1613 | q.pp(self.interfaces) |
| 1614 | q.breakable() |
| 1615 | q.text('}') |
| 1616 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1617 | bsn_header.subtypes[10] = bsn_get_interfaces_reply |
| 1618 | |
| 1619 | class bsn_get_interfaces_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1620 | version = 2 |
| 1621 | type = 4 |
| 1622 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1623 | subtype = 9 |
| 1624 | |
| 1625 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1626 | if xid != None: |
| 1627 | self.xid = xid |
| 1628 | else: |
| 1629 | self.xid = None |
| 1630 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1631 | |
| 1632 | def pack(self): |
| 1633 | packed = [] |
| 1634 | packed.append(struct.pack("!B", self.version)) |
| 1635 | packed.append(struct.pack("!B", self.type)) |
| 1636 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1637 | packed.append(struct.pack("!L", self.xid)) |
| 1638 | packed.append(struct.pack("!L", self.experimenter)) |
| 1639 | packed.append(struct.pack("!L", self.subtype)) |
| 1640 | length = sum([len(x) for x in packed]) |
| 1641 | packed[2] = struct.pack("!H", length) |
| 1642 | return ''.join(packed) |
| 1643 | |
| 1644 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1645 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1646 | obj = bsn_get_interfaces_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1647 | _version = reader.read("!B")[0] |
| 1648 | assert(_version == 2) |
| 1649 | _type = reader.read("!B")[0] |
| 1650 | assert(_type == 4) |
| 1651 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1652 | orig_reader = reader |
| 1653 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1654 | obj.xid = reader.read("!L")[0] |
| 1655 | _experimenter = reader.read("!L")[0] |
| 1656 | assert(_experimenter == 6035143) |
| 1657 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1658 | assert(_subtype == 9) |
| 1659 | return obj |
| 1660 | |
| 1661 | def __eq__(self, other): |
| 1662 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1663 | if self.xid != other.xid: return False |
| 1664 | return True |
| 1665 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1666 | def pretty_print(self, q): |
| 1667 | q.text("bsn_get_interfaces_request {") |
| 1668 | with q.group(): |
| 1669 | with q.indent(2): |
| 1670 | q.breakable() |
| 1671 | q.text("xid = "); |
| 1672 | if self.xid != None: |
| 1673 | q.text("%#x" % self.xid) |
| 1674 | else: |
| 1675 | q.text('None') |
| 1676 | q.breakable() |
| 1677 | q.text('}') |
| 1678 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1679 | bsn_header.subtypes[9] = bsn_get_interfaces_request |
| 1680 | |
| 1681 | class bsn_get_mirroring_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1682 | version = 2 |
| 1683 | type = 4 |
| 1684 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1685 | subtype = 5 |
| 1686 | |
| 1687 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1688 | if xid != None: |
| 1689 | self.xid = xid |
| 1690 | else: |
| 1691 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1692 | if report_mirror_ports != None: |
| 1693 | self.report_mirror_ports = report_mirror_ports |
| 1694 | else: |
| 1695 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1696 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1697 | |
| 1698 | def pack(self): |
| 1699 | packed = [] |
| 1700 | packed.append(struct.pack("!B", self.version)) |
| 1701 | packed.append(struct.pack("!B", self.type)) |
| 1702 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1703 | packed.append(struct.pack("!L", self.xid)) |
| 1704 | packed.append(struct.pack("!L", self.experimenter)) |
| 1705 | packed.append(struct.pack("!L", self.subtype)) |
| 1706 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1707 | packed.append('\x00' * 3) |
| 1708 | length = sum([len(x) for x in packed]) |
| 1709 | packed[2] = struct.pack("!H", length) |
| 1710 | return ''.join(packed) |
| 1711 | |
| 1712 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1713 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1714 | obj = bsn_get_mirroring_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1715 | _version = reader.read("!B")[0] |
| 1716 | assert(_version == 2) |
| 1717 | _type = reader.read("!B")[0] |
| 1718 | assert(_type == 4) |
| 1719 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1720 | orig_reader = reader |
| 1721 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1722 | obj.xid = reader.read("!L")[0] |
| 1723 | _experimenter = reader.read("!L")[0] |
| 1724 | assert(_experimenter == 6035143) |
| 1725 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1726 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1727 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1728 | reader.skip(3) |
| 1729 | return obj |
| 1730 | |
| 1731 | def __eq__(self, other): |
| 1732 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1733 | if self.xid != other.xid: return False |
| 1734 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1735 | return True |
| 1736 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1737 | def pretty_print(self, q): |
| 1738 | q.text("bsn_get_mirroring_reply {") |
| 1739 | with q.group(): |
| 1740 | with q.indent(2): |
| 1741 | q.breakable() |
| 1742 | q.text("xid = "); |
| 1743 | if self.xid != None: |
| 1744 | q.text("%#x" % self.xid) |
| 1745 | else: |
| 1746 | q.text('None') |
| 1747 | q.text(","); q.breakable() |
| 1748 | q.text("report_mirror_ports = "); |
| 1749 | q.text("%#x" % self.report_mirror_ports) |
| 1750 | q.breakable() |
| 1751 | q.text('}') |
| 1752 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1753 | bsn_header.subtypes[5] = bsn_get_mirroring_reply |
| 1754 | |
| 1755 | class bsn_get_mirroring_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1756 | version = 2 |
| 1757 | type = 4 |
| 1758 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1759 | subtype = 4 |
| 1760 | |
| 1761 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1762 | if xid != None: |
| 1763 | self.xid = xid |
| 1764 | else: |
| 1765 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1766 | if report_mirror_ports != None: |
| 1767 | self.report_mirror_ports = report_mirror_ports |
| 1768 | else: |
| 1769 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1770 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1771 | |
| 1772 | def pack(self): |
| 1773 | packed = [] |
| 1774 | packed.append(struct.pack("!B", self.version)) |
| 1775 | packed.append(struct.pack("!B", self.type)) |
| 1776 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1777 | packed.append(struct.pack("!L", self.xid)) |
| 1778 | packed.append(struct.pack("!L", self.experimenter)) |
| 1779 | packed.append(struct.pack("!L", self.subtype)) |
| 1780 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1781 | packed.append('\x00' * 3) |
| 1782 | length = sum([len(x) for x in packed]) |
| 1783 | packed[2] = struct.pack("!H", length) |
| 1784 | return ''.join(packed) |
| 1785 | |
| 1786 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1787 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1788 | obj = bsn_get_mirroring_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1789 | _version = reader.read("!B")[0] |
| 1790 | assert(_version == 2) |
| 1791 | _type = reader.read("!B")[0] |
| 1792 | assert(_type == 4) |
| 1793 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1794 | orig_reader = reader |
| 1795 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1796 | obj.xid = reader.read("!L")[0] |
| 1797 | _experimenter = reader.read("!L")[0] |
| 1798 | assert(_experimenter == 6035143) |
| 1799 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1800 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1801 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1802 | reader.skip(3) |
| 1803 | return obj |
| 1804 | |
| 1805 | def __eq__(self, other): |
| 1806 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1807 | if self.xid != other.xid: return False |
| 1808 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1809 | return True |
| 1810 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1811 | def pretty_print(self, q): |
| 1812 | q.text("bsn_get_mirroring_request {") |
| 1813 | with q.group(): |
| 1814 | with q.indent(2): |
| 1815 | q.breakable() |
| 1816 | q.text("xid = "); |
| 1817 | if self.xid != None: |
| 1818 | q.text("%#x" % self.xid) |
| 1819 | else: |
| 1820 | q.text('None') |
| 1821 | q.text(","); q.breakable() |
| 1822 | q.text("report_mirror_ports = "); |
| 1823 | q.text("%#x" % self.report_mirror_ports) |
| 1824 | q.breakable() |
| 1825 | q.text('}') |
| 1826 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1827 | bsn_header.subtypes[4] = bsn_get_mirroring_request |
| 1828 | |
| 1829 | class bsn_pdu_rx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1830 | version = 2 |
| 1831 | type = 4 |
| 1832 | experimenter = 6035143 |
| 1833 | subtype = 34 |
| 1834 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1835 | 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] | 1836 | if xid != None: |
| 1837 | self.xid = xid |
| 1838 | else: |
| 1839 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1840 | if status != None: |
| 1841 | self.status = status |
| 1842 | else: |
| 1843 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1844 | if port_no != None: |
| 1845 | self.port_no = port_no |
| 1846 | else: |
| 1847 | self.port_no = 0 |
| 1848 | if slot_num != None: |
| 1849 | self.slot_num = slot_num |
| 1850 | else: |
| 1851 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1852 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1853 | |
| 1854 | def pack(self): |
| 1855 | packed = [] |
| 1856 | packed.append(struct.pack("!B", self.version)) |
| 1857 | packed.append(struct.pack("!B", self.type)) |
| 1858 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1859 | packed.append(struct.pack("!L", self.xid)) |
| 1860 | packed.append(struct.pack("!L", self.experimenter)) |
| 1861 | packed.append(struct.pack("!L", self.subtype)) |
| 1862 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1863 | packed.append(util.pack_port_no(self.port_no)) |
| 1864 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1865 | length = sum([len(x) for x in packed]) |
| 1866 | packed[2] = struct.pack("!H", length) |
| 1867 | return ''.join(packed) |
| 1868 | |
| 1869 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1870 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1871 | obj = bsn_pdu_rx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1872 | _version = reader.read("!B")[0] |
| 1873 | assert(_version == 2) |
| 1874 | _type = reader.read("!B")[0] |
| 1875 | assert(_type == 4) |
| 1876 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1877 | orig_reader = reader |
| 1878 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1879 | obj.xid = reader.read("!L")[0] |
| 1880 | _experimenter = reader.read("!L")[0] |
| 1881 | assert(_experimenter == 6035143) |
| 1882 | _subtype = reader.read("!L")[0] |
| 1883 | assert(_subtype == 34) |
| 1884 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1885 | obj.port_no = util.unpack_port_no(reader) |
| 1886 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1887 | return obj |
| 1888 | |
| 1889 | def __eq__(self, other): |
| 1890 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1891 | if self.xid != other.xid: return False |
| 1892 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1893 | if self.port_no != other.port_no: return False |
| 1894 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1895 | return True |
| 1896 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1897 | def pretty_print(self, q): |
| 1898 | q.text("bsn_pdu_rx_reply {") |
| 1899 | with q.group(): |
| 1900 | with q.indent(2): |
| 1901 | q.breakable() |
| 1902 | q.text("xid = "); |
| 1903 | if self.xid != None: |
| 1904 | q.text("%#x" % self.xid) |
| 1905 | else: |
| 1906 | q.text('None') |
| 1907 | q.text(","); q.breakable() |
| 1908 | q.text("status = "); |
| 1909 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1910 | q.text(","); q.breakable() |
| 1911 | q.text("port_no = "); |
| 1912 | q.text(util.pretty_port(self.port_no)) |
| 1913 | q.text(","); q.breakable() |
| 1914 | q.text("slot_num = "); |
| 1915 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1916 | q.breakable() |
| 1917 | q.text('}') |
| 1918 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1919 | bsn_header.subtypes[34] = bsn_pdu_rx_reply |
| 1920 | |
| 1921 | class bsn_pdu_rx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1922 | version = 2 |
| 1923 | type = 4 |
| 1924 | experimenter = 6035143 |
| 1925 | subtype = 33 |
| 1926 | |
| 1927 | 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] | 1928 | if xid != None: |
| 1929 | self.xid = xid |
| 1930 | else: |
| 1931 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1932 | if timeout_ms != None: |
| 1933 | self.timeout_ms = timeout_ms |
| 1934 | else: |
| 1935 | self.timeout_ms = 0 |
| 1936 | if port_no != None: |
| 1937 | self.port_no = port_no |
| 1938 | else: |
| 1939 | self.port_no = 0 |
| 1940 | if slot_num != None: |
| 1941 | self.slot_num = slot_num |
| 1942 | else: |
| 1943 | self.slot_num = 0 |
| 1944 | if data != None: |
| 1945 | self.data = data |
| 1946 | else: |
| 1947 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1948 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1949 | |
| 1950 | def pack(self): |
| 1951 | packed = [] |
| 1952 | packed.append(struct.pack("!B", self.version)) |
| 1953 | packed.append(struct.pack("!B", self.type)) |
| 1954 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1955 | packed.append(struct.pack("!L", self.xid)) |
| 1956 | packed.append(struct.pack("!L", self.experimenter)) |
| 1957 | packed.append(struct.pack("!L", self.subtype)) |
| 1958 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 1959 | packed.append(util.pack_port_no(self.port_no)) |
| 1960 | packed.append(struct.pack("!B", self.slot_num)) |
| 1961 | packed.append('\x00' * 3) |
| 1962 | packed.append(self.data) |
| 1963 | length = sum([len(x) for x in packed]) |
| 1964 | packed[2] = struct.pack("!H", length) |
| 1965 | return ''.join(packed) |
| 1966 | |
| 1967 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1968 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1969 | obj = bsn_pdu_rx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1970 | _version = reader.read("!B")[0] |
| 1971 | assert(_version == 2) |
| 1972 | _type = reader.read("!B")[0] |
| 1973 | assert(_type == 4) |
| 1974 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1975 | orig_reader = reader |
| 1976 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1977 | obj.xid = reader.read("!L")[0] |
| 1978 | _experimenter = reader.read("!L")[0] |
| 1979 | assert(_experimenter == 6035143) |
| 1980 | _subtype = reader.read("!L")[0] |
| 1981 | assert(_subtype == 33) |
| 1982 | obj.timeout_ms = reader.read("!L")[0] |
| 1983 | obj.port_no = util.unpack_port_no(reader) |
| 1984 | obj.slot_num = reader.read("!B")[0] |
| 1985 | reader.skip(3) |
| 1986 | obj.data = str(reader.read_all()) |
| 1987 | return obj |
| 1988 | |
| 1989 | def __eq__(self, other): |
| 1990 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1991 | if self.xid != other.xid: return False |
| 1992 | if self.timeout_ms != other.timeout_ms: return False |
| 1993 | if self.port_no != other.port_no: return False |
| 1994 | if self.slot_num != other.slot_num: return False |
| 1995 | if self.data != other.data: return False |
| 1996 | return True |
| 1997 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1998 | def pretty_print(self, q): |
| 1999 | q.text("bsn_pdu_rx_request {") |
| 2000 | with q.group(): |
| 2001 | with q.indent(2): |
| 2002 | q.breakable() |
| 2003 | q.text("xid = "); |
| 2004 | if self.xid != None: |
| 2005 | q.text("%#x" % self.xid) |
| 2006 | else: |
| 2007 | q.text('None') |
| 2008 | q.text(","); q.breakable() |
| 2009 | q.text("timeout_ms = "); |
| 2010 | q.text("%#x" % self.timeout_ms) |
| 2011 | q.text(","); q.breakable() |
| 2012 | q.text("port_no = "); |
| 2013 | q.text(util.pretty_port(self.port_no)) |
| 2014 | q.text(","); q.breakable() |
| 2015 | q.text("slot_num = "); |
| 2016 | q.text("%#x" % self.slot_num) |
| 2017 | q.text(","); q.breakable() |
| 2018 | q.text("data = "); |
| 2019 | q.pp(self.data) |
| 2020 | q.breakable() |
| 2021 | q.text('}') |
| 2022 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2023 | bsn_header.subtypes[33] = bsn_pdu_rx_request |
| 2024 | |
| 2025 | class bsn_pdu_rx_timeout(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2026 | version = 2 |
| 2027 | type = 4 |
| 2028 | experimenter = 6035143 |
| 2029 | subtype = 35 |
| 2030 | |
| 2031 | def __init__(self, xid=None, port_no=None, slot_num=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2032 | if xid != None: |
| 2033 | self.xid = xid |
| 2034 | else: |
| 2035 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2036 | if port_no != None: |
| 2037 | self.port_no = port_no |
| 2038 | else: |
| 2039 | self.port_no = 0 |
| 2040 | if slot_num != None: |
| 2041 | self.slot_num = slot_num |
| 2042 | else: |
| 2043 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2044 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2045 | |
| 2046 | def pack(self): |
| 2047 | packed = [] |
| 2048 | packed.append(struct.pack("!B", self.version)) |
| 2049 | packed.append(struct.pack("!B", self.type)) |
| 2050 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2051 | packed.append(struct.pack("!L", self.xid)) |
| 2052 | packed.append(struct.pack("!L", self.experimenter)) |
| 2053 | packed.append(struct.pack("!L", self.subtype)) |
| 2054 | packed.append(util.pack_port_no(self.port_no)) |
| 2055 | packed.append(struct.pack("!B", self.slot_num)) |
| 2056 | length = sum([len(x) for x in packed]) |
| 2057 | packed[2] = struct.pack("!H", length) |
| 2058 | return ''.join(packed) |
| 2059 | |
| 2060 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2061 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2062 | obj = bsn_pdu_rx_timeout() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2063 | _version = reader.read("!B")[0] |
| 2064 | assert(_version == 2) |
| 2065 | _type = reader.read("!B")[0] |
| 2066 | assert(_type == 4) |
| 2067 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2068 | orig_reader = reader |
| 2069 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2070 | obj.xid = reader.read("!L")[0] |
| 2071 | _experimenter = reader.read("!L")[0] |
| 2072 | assert(_experimenter == 6035143) |
| 2073 | _subtype = reader.read("!L")[0] |
| 2074 | assert(_subtype == 35) |
| 2075 | obj.port_no = util.unpack_port_no(reader) |
| 2076 | obj.slot_num = reader.read("!B")[0] |
| 2077 | return obj |
| 2078 | |
| 2079 | def __eq__(self, other): |
| 2080 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2081 | if self.xid != other.xid: return False |
| 2082 | if self.port_no != other.port_no: return False |
| 2083 | if self.slot_num != other.slot_num: return False |
| 2084 | return True |
| 2085 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2086 | def pretty_print(self, q): |
| 2087 | q.text("bsn_pdu_rx_timeout {") |
| 2088 | with q.group(): |
| 2089 | with q.indent(2): |
| 2090 | q.breakable() |
| 2091 | q.text("xid = "); |
| 2092 | if self.xid != None: |
| 2093 | q.text("%#x" % self.xid) |
| 2094 | else: |
| 2095 | q.text('None') |
| 2096 | q.text(","); q.breakable() |
| 2097 | q.text("port_no = "); |
| 2098 | q.text(util.pretty_port(self.port_no)) |
| 2099 | q.text(","); q.breakable() |
| 2100 | q.text("slot_num = "); |
| 2101 | q.text("%#x" % self.slot_num) |
| 2102 | q.breakable() |
| 2103 | q.text('}') |
| 2104 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2105 | bsn_header.subtypes[35] = bsn_pdu_rx_timeout |
| 2106 | |
| 2107 | class bsn_pdu_tx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2108 | version = 2 |
| 2109 | type = 4 |
| 2110 | experimenter = 6035143 |
| 2111 | subtype = 32 |
| 2112 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2113 | 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] | 2114 | if xid != None: |
| 2115 | self.xid = xid |
| 2116 | else: |
| 2117 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2118 | if status != None: |
| 2119 | self.status = status |
| 2120 | else: |
| 2121 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2122 | if port_no != None: |
| 2123 | self.port_no = port_no |
| 2124 | else: |
| 2125 | self.port_no = 0 |
| 2126 | if slot_num != None: |
| 2127 | self.slot_num = slot_num |
| 2128 | else: |
| 2129 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2130 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2131 | |
| 2132 | def pack(self): |
| 2133 | packed = [] |
| 2134 | packed.append(struct.pack("!B", self.version)) |
| 2135 | packed.append(struct.pack("!B", self.type)) |
| 2136 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2137 | packed.append(struct.pack("!L", self.xid)) |
| 2138 | packed.append(struct.pack("!L", self.experimenter)) |
| 2139 | packed.append(struct.pack("!L", self.subtype)) |
| 2140 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2141 | packed.append(util.pack_port_no(self.port_no)) |
| 2142 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2143 | length = sum([len(x) for x in packed]) |
| 2144 | packed[2] = struct.pack("!H", length) |
| 2145 | return ''.join(packed) |
| 2146 | |
| 2147 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2148 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2149 | obj = bsn_pdu_tx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2150 | _version = reader.read("!B")[0] |
| 2151 | assert(_version == 2) |
| 2152 | _type = reader.read("!B")[0] |
| 2153 | assert(_type == 4) |
| 2154 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2155 | orig_reader = reader |
| 2156 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2157 | obj.xid = reader.read("!L")[0] |
| 2158 | _experimenter = reader.read("!L")[0] |
| 2159 | assert(_experimenter == 6035143) |
| 2160 | _subtype = reader.read("!L")[0] |
| 2161 | assert(_subtype == 32) |
| 2162 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2163 | obj.port_no = util.unpack_port_no(reader) |
| 2164 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2165 | return obj |
| 2166 | |
| 2167 | def __eq__(self, other): |
| 2168 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2169 | if self.xid != other.xid: return False |
| 2170 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2171 | if self.port_no != other.port_no: return False |
| 2172 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2173 | return True |
| 2174 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2175 | def pretty_print(self, q): |
| 2176 | q.text("bsn_pdu_tx_reply {") |
| 2177 | with q.group(): |
| 2178 | with q.indent(2): |
| 2179 | q.breakable() |
| 2180 | q.text("xid = "); |
| 2181 | if self.xid != None: |
| 2182 | q.text("%#x" % self.xid) |
| 2183 | else: |
| 2184 | q.text('None') |
| 2185 | q.text(","); q.breakable() |
| 2186 | q.text("status = "); |
| 2187 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2188 | q.text(","); q.breakable() |
| 2189 | q.text("port_no = "); |
| 2190 | q.text(util.pretty_port(self.port_no)) |
| 2191 | q.text(","); q.breakable() |
| 2192 | q.text("slot_num = "); |
| 2193 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2194 | q.breakable() |
| 2195 | q.text('}') |
| 2196 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2197 | bsn_header.subtypes[32] = bsn_pdu_tx_reply |
| 2198 | |
| 2199 | class bsn_pdu_tx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2200 | version = 2 |
| 2201 | type = 4 |
| 2202 | experimenter = 6035143 |
| 2203 | subtype = 31 |
| 2204 | |
| 2205 | 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] | 2206 | if xid != None: |
| 2207 | self.xid = xid |
| 2208 | else: |
| 2209 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2210 | if tx_interval_ms != None: |
| 2211 | self.tx_interval_ms = tx_interval_ms |
| 2212 | else: |
| 2213 | self.tx_interval_ms = 0 |
| 2214 | if port_no != None: |
| 2215 | self.port_no = port_no |
| 2216 | else: |
| 2217 | self.port_no = 0 |
| 2218 | if slot_num != None: |
| 2219 | self.slot_num = slot_num |
| 2220 | else: |
| 2221 | self.slot_num = 0 |
| 2222 | if data != None: |
| 2223 | self.data = data |
| 2224 | else: |
| 2225 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2226 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2227 | |
| 2228 | def pack(self): |
| 2229 | packed = [] |
| 2230 | packed.append(struct.pack("!B", self.version)) |
| 2231 | packed.append(struct.pack("!B", self.type)) |
| 2232 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2233 | packed.append(struct.pack("!L", self.xid)) |
| 2234 | packed.append(struct.pack("!L", self.experimenter)) |
| 2235 | packed.append(struct.pack("!L", self.subtype)) |
| 2236 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 2237 | packed.append(util.pack_port_no(self.port_no)) |
| 2238 | packed.append(struct.pack("!B", self.slot_num)) |
| 2239 | packed.append('\x00' * 3) |
| 2240 | packed.append(self.data) |
| 2241 | length = sum([len(x) for x in packed]) |
| 2242 | packed[2] = struct.pack("!H", length) |
| 2243 | return ''.join(packed) |
| 2244 | |
| 2245 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2246 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2247 | obj = bsn_pdu_tx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2248 | _version = reader.read("!B")[0] |
| 2249 | assert(_version == 2) |
| 2250 | _type = reader.read("!B")[0] |
| 2251 | assert(_type == 4) |
| 2252 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2253 | orig_reader = reader |
| 2254 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2255 | obj.xid = reader.read("!L")[0] |
| 2256 | _experimenter = reader.read("!L")[0] |
| 2257 | assert(_experimenter == 6035143) |
| 2258 | _subtype = reader.read("!L")[0] |
| 2259 | assert(_subtype == 31) |
| 2260 | obj.tx_interval_ms = reader.read("!L")[0] |
| 2261 | obj.port_no = util.unpack_port_no(reader) |
| 2262 | obj.slot_num = reader.read("!B")[0] |
| 2263 | reader.skip(3) |
| 2264 | obj.data = str(reader.read_all()) |
| 2265 | return obj |
| 2266 | |
| 2267 | def __eq__(self, other): |
| 2268 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2269 | if self.xid != other.xid: return False |
| 2270 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 2271 | if self.port_no != other.port_no: return False |
| 2272 | if self.slot_num != other.slot_num: return False |
| 2273 | if self.data != other.data: return False |
| 2274 | return True |
| 2275 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2276 | def pretty_print(self, q): |
| 2277 | q.text("bsn_pdu_tx_request {") |
| 2278 | with q.group(): |
| 2279 | with q.indent(2): |
| 2280 | q.breakable() |
| 2281 | q.text("xid = "); |
| 2282 | if self.xid != None: |
| 2283 | q.text("%#x" % self.xid) |
| 2284 | else: |
| 2285 | q.text('None') |
| 2286 | q.text(","); q.breakable() |
| 2287 | q.text("tx_interval_ms = "); |
| 2288 | q.text("%#x" % self.tx_interval_ms) |
| 2289 | q.text(","); q.breakable() |
| 2290 | q.text("port_no = "); |
| 2291 | q.text(util.pretty_port(self.port_no)) |
| 2292 | q.text(","); q.breakable() |
| 2293 | q.text("slot_num = "); |
| 2294 | q.text("%#x" % self.slot_num) |
| 2295 | q.text(","); q.breakable() |
| 2296 | q.text("data = "); |
| 2297 | q.pp(self.data) |
| 2298 | q.breakable() |
| 2299 | q.text('}') |
| 2300 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2301 | bsn_header.subtypes[31] = bsn_pdu_tx_request |
| 2302 | |
| 2303 | class bsn_set_mirroring(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2304 | version = 2 |
| 2305 | type = 4 |
| 2306 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2307 | subtype = 3 |
| 2308 | |
| 2309 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2310 | if xid != None: |
| 2311 | self.xid = xid |
| 2312 | else: |
| 2313 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2314 | if report_mirror_ports != None: |
| 2315 | self.report_mirror_ports = report_mirror_ports |
| 2316 | else: |
| 2317 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2318 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2319 | |
| 2320 | def pack(self): |
| 2321 | packed = [] |
| 2322 | packed.append(struct.pack("!B", self.version)) |
| 2323 | packed.append(struct.pack("!B", self.type)) |
| 2324 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2325 | packed.append(struct.pack("!L", self.xid)) |
| 2326 | packed.append(struct.pack("!L", self.experimenter)) |
| 2327 | packed.append(struct.pack("!L", self.subtype)) |
| 2328 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2329 | packed.append('\x00' * 3) |
| 2330 | length = sum([len(x) for x in packed]) |
| 2331 | packed[2] = struct.pack("!H", length) |
| 2332 | return ''.join(packed) |
| 2333 | |
| 2334 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2335 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2336 | obj = bsn_set_mirroring() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2337 | _version = reader.read("!B")[0] |
| 2338 | assert(_version == 2) |
| 2339 | _type = reader.read("!B")[0] |
| 2340 | assert(_type == 4) |
| 2341 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2342 | orig_reader = reader |
| 2343 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2344 | obj.xid = reader.read("!L")[0] |
| 2345 | _experimenter = reader.read("!L")[0] |
| 2346 | assert(_experimenter == 6035143) |
| 2347 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2348 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2349 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2350 | reader.skip(3) |
| 2351 | return obj |
| 2352 | |
| 2353 | def __eq__(self, other): |
| 2354 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2355 | if self.xid != other.xid: return False |
| 2356 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2357 | return True |
| 2358 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2359 | def pretty_print(self, q): |
| 2360 | q.text("bsn_set_mirroring {") |
| 2361 | with q.group(): |
| 2362 | with q.indent(2): |
| 2363 | q.breakable() |
| 2364 | q.text("xid = "); |
| 2365 | if self.xid != None: |
| 2366 | q.text("%#x" % self.xid) |
| 2367 | else: |
| 2368 | q.text('None') |
| 2369 | q.text(","); q.breakable() |
| 2370 | q.text("report_mirror_ports = "); |
| 2371 | q.text("%#x" % self.report_mirror_ports) |
| 2372 | q.breakable() |
| 2373 | q.text('}') |
| 2374 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2375 | bsn_header.subtypes[3] = bsn_set_mirroring |
| 2376 | |
| 2377 | class bsn_set_pktin_suppression_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2378 | version = 2 |
| 2379 | type = 4 |
| 2380 | experimenter = 6035143 |
| 2381 | subtype = 25 |
| 2382 | |
| 2383 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2384 | if xid != None: |
| 2385 | self.xid = xid |
| 2386 | else: |
| 2387 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2388 | if status != None: |
| 2389 | self.status = status |
| 2390 | else: |
| 2391 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2392 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2393 | |
| 2394 | def pack(self): |
| 2395 | packed = [] |
| 2396 | packed.append(struct.pack("!B", self.version)) |
| 2397 | packed.append(struct.pack("!B", self.type)) |
| 2398 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2399 | packed.append(struct.pack("!L", self.xid)) |
| 2400 | packed.append(struct.pack("!L", self.experimenter)) |
| 2401 | packed.append(struct.pack("!L", self.subtype)) |
| 2402 | packed.append(struct.pack("!L", self.status)) |
| 2403 | length = sum([len(x) for x in packed]) |
| 2404 | packed[2] = struct.pack("!H", length) |
| 2405 | return ''.join(packed) |
| 2406 | |
| 2407 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2408 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2409 | obj = bsn_set_pktin_suppression_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2410 | _version = reader.read("!B")[0] |
| 2411 | assert(_version == 2) |
| 2412 | _type = reader.read("!B")[0] |
| 2413 | assert(_type == 4) |
| 2414 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2415 | orig_reader = reader |
| 2416 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2417 | obj.xid = reader.read("!L")[0] |
| 2418 | _experimenter = reader.read("!L")[0] |
| 2419 | assert(_experimenter == 6035143) |
| 2420 | _subtype = reader.read("!L")[0] |
| 2421 | assert(_subtype == 25) |
| 2422 | obj.status = reader.read("!L")[0] |
| 2423 | return obj |
| 2424 | |
| 2425 | def __eq__(self, other): |
| 2426 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2427 | if self.xid != other.xid: return False |
| 2428 | if self.status != other.status: return False |
| 2429 | return True |
| 2430 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2431 | def pretty_print(self, q): |
| 2432 | q.text("bsn_set_pktin_suppression_reply {") |
| 2433 | with q.group(): |
| 2434 | with q.indent(2): |
| 2435 | q.breakable() |
| 2436 | q.text("xid = "); |
| 2437 | if self.xid != None: |
| 2438 | q.text("%#x" % self.xid) |
| 2439 | else: |
| 2440 | q.text('None') |
| 2441 | q.text(","); q.breakable() |
| 2442 | q.text("status = "); |
| 2443 | q.text("%#x" % self.status) |
| 2444 | q.breakable() |
| 2445 | q.text('}') |
| 2446 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2447 | bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply |
| 2448 | |
| 2449 | class bsn_set_pktin_suppression_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2450 | version = 2 |
| 2451 | type = 4 |
| 2452 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2453 | subtype = 11 |
| 2454 | |
| 2455 | 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] | 2456 | if xid != None: |
| 2457 | self.xid = xid |
| 2458 | else: |
| 2459 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2460 | if enabled != None: |
| 2461 | self.enabled = enabled |
| 2462 | else: |
| 2463 | self.enabled = 0 |
| 2464 | if idle_timeout != None: |
| 2465 | self.idle_timeout = idle_timeout |
| 2466 | else: |
| 2467 | self.idle_timeout = 0 |
| 2468 | if hard_timeout != None: |
| 2469 | self.hard_timeout = hard_timeout |
| 2470 | else: |
| 2471 | self.hard_timeout = 0 |
| 2472 | if priority != None: |
| 2473 | self.priority = priority |
| 2474 | else: |
| 2475 | self.priority = 0 |
| 2476 | if cookie != None: |
| 2477 | self.cookie = cookie |
| 2478 | else: |
| 2479 | self.cookie = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2480 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2481 | |
| 2482 | def pack(self): |
| 2483 | packed = [] |
| 2484 | packed.append(struct.pack("!B", self.version)) |
| 2485 | packed.append(struct.pack("!B", self.type)) |
| 2486 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2487 | packed.append(struct.pack("!L", self.xid)) |
| 2488 | packed.append(struct.pack("!L", self.experimenter)) |
| 2489 | packed.append(struct.pack("!L", self.subtype)) |
| 2490 | packed.append(struct.pack("!B", self.enabled)) |
| 2491 | packed.append('\x00' * 1) |
| 2492 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2493 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2494 | packed.append(struct.pack("!H", self.priority)) |
| 2495 | packed.append(struct.pack("!Q", self.cookie)) |
| 2496 | length = sum([len(x) for x in packed]) |
| 2497 | packed[2] = struct.pack("!H", length) |
| 2498 | return ''.join(packed) |
| 2499 | |
| 2500 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2501 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2502 | obj = bsn_set_pktin_suppression_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2503 | _version = reader.read("!B")[0] |
| 2504 | assert(_version == 2) |
| 2505 | _type = reader.read("!B")[0] |
| 2506 | assert(_type == 4) |
| 2507 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2508 | orig_reader = reader |
| 2509 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2510 | obj.xid = reader.read("!L")[0] |
| 2511 | _experimenter = reader.read("!L")[0] |
| 2512 | assert(_experimenter == 6035143) |
| 2513 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2514 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2515 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2516 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2517 | obj.idle_timeout = reader.read("!H")[0] |
| 2518 | obj.hard_timeout = reader.read("!H")[0] |
| 2519 | obj.priority = reader.read("!H")[0] |
| 2520 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2521 | return obj |
| 2522 | |
| 2523 | def __eq__(self, other): |
| 2524 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2525 | if self.xid != other.xid: return False |
| 2526 | if self.enabled != other.enabled: return False |
| 2527 | if self.idle_timeout != other.idle_timeout: return False |
| 2528 | if self.hard_timeout != other.hard_timeout: return False |
| 2529 | if self.priority != other.priority: return False |
| 2530 | if self.cookie != other.cookie: return False |
| 2531 | return True |
| 2532 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2533 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2534 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2535 | with q.group(): |
| 2536 | with q.indent(2): |
| 2537 | q.breakable() |
| 2538 | q.text("xid = "); |
| 2539 | if self.xid != None: |
| 2540 | q.text("%#x" % self.xid) |
| 2541 | else: |
| 2542 | q.text('None') |
| 2543 | q.text(","); q.breakable() |
| 2544 | q.text("enabled = "); |
| 2545 | q.text("%#x" % self.enabled) |
| 2546 | q.text(","); q.breakable() |
| 2547 | q.text("idle_timeout = "); |
| 2548 | q.text("%#x" % self.idle_timeout) |
| 2549 | q.text(","); q.breakable() |
| 2550 | q.text("hard_timeout = "); |
| 2551 | q.text("%#x" % self.hard_timeout) |
| 2552 | q.text(","); q.breakable() |
| 2553 | q.text("priority = "); |
| 2554 | q.text("%#x" % self.priority) |
| 2555 | q.text(","); q.breakable() |
| 2556 | q.text("cookie = "); |
| 2557 | q.text("%#x" % self.cookie) |
| 2558 | q.breakable() |
| 2559 | q.text('}') |
| 2560 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2561 | bsn_header.subtypes[11] = bsn_set_pktin_suppression_request |
| 2562 | |
| 2563 | class experimenter_stats_reply(stats_reply): |
| 2564 | subtypes = {} |
| 2565 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2566 | version = 2 |
| 2567 | type = 19 |
| 2568 | stats_type = 65535 |
| 2569 | |
| 2570 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 2571 | if xid != None: |
| 2572 | self.xid = xid |
| 2573 | else: |
| 2574 | self.xid = None |
| 2575 | if flags != None: |
| 2576 | self.flags = flags |
| 2577 | else: |
| 2578 | self.flags = 0 |
| 2579 | if experimenter != None: |
| 2580 | self.experimenter = experimenter |
| 2581 | else: |
| 2582 | self.experimenter = 0 |
| 2583 | if data != None: |
| 2584 | self.data = data |
| 2585 | else: |
| 2586 | self.data = '' |
| 2587 | return |
| 2588 | |
| 2589 | def pack(self): |
| 2590 | packed = [] |
| 2591 | packed.append(struct.pack("!B", self.version)) |
| 2592 | packed.append(struct.pack("!B", self.type)) |
| 2593 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2594 | packed.append(struct.pack("!L", self.xid)) |
| 2595 | packed.append(struct.pack("!H", self.stats_type)) |
| 2596 | packed.append(struct.pack("!H", self.flags)) |
| 2597 | packed.append('\x00' * 4) |
| 2598 | packed.append(struct.pack("!L", self.experimenter)) |
| 2599 | packed.append('\x00' * 4) |
| 2600 | packed.append(self.data) |
| 2601 | length = sum([len(x) for x in packed]) |
| 2602 | packed[2] = struct.pack("!H", length) |
| 2603 | return ''.join(packed) |
| 2604 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2605 | @staticmethod |
| 2606 | def unpack(reader): |
| 2607 | subtype, = reader.peek('!L', 16) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2608 | subclass = experimenter_stats_reply.subtypes.get(subtype) |
| 2609 | if subclass: |
| 2610 | return subclass.unpack(reader) |
| 2611 | |
| 2612 | obj = experimenter_stats_reply() |
| 2613 | _version = reader.read("!B")[0] |
| 2614 | assert(_version == 2) |
| 2615 | _type = reader.read("!B")[0] |
| 2616 | assert(_type == 19) |
| 2617 | _length = reader.read("!H")[0] |
| 2618 | orig_reader = reader |
| 2619 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2620 | obj.xid = reader.read("!L")[0] |
| 2621 | _stats_type = reader.read("!H")[0] |
| 2622 | assert(_stats_type == 65535) |
| 2623 | obj.flags = reader.read("!H")[0] |
| 2624 | reader.skip(4) |
| 2625 | obj.experimenter = reader.read("!L")[0] |
| 2626 | reader.skip(4) |
| 2627 | obj.data = str(reader.read_all()) |
| 2628 | return obj |
| 2629 | |
| 2630 | def __eq__(self, other): |
| 2631 | if type(self) != type(other): return False |
| 2632 | if self.xid != other.xid: return False |
| 2633 | if self.flags != other.flags: return False |
| 2634 | if self.experimenter != other.experimenter: return False |
| 2635 | if self.data != other.data: return False |
| 2636 | return True |
| 2637 | |
| 2638 | def pretty_print(self, q): |
| 2639 | q.text("experimenter_stats_reply {") |
| 2640 | with q.group(): |
| 2641 | with q.indent(2): |
| 2642 | q.breakable() |
| 2643 | q.text("xid = "); |
| 2644 | if self.xid != None: |
| 2645 | q.text("%#x" % self.xid) |
| 2646 | else: |
| 2647 | q.text('None') |
| 2648 | q.text(","); q.breakable() |
| 2649 | q.text("flags = "); |
| 2650 | q.text("%#x" % self.flags) |
| 2651 | q.text(","); q.breakable() |
| 2652 | q.text("data = "); |
| 2653 | q.pp(self.data) |
| 2654 | q.breakable() |
| 2655 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2656 | |
| 2657 | stats_reply.subtypes[65535] = experimenter_stats_reply |
| 2658 | |
| 2659 | class bsn_stats_reply(experimenter_stats_reply): |
| 2660 | subtypes = {} |
| 2661 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2662 | version = 2 |
| 2663 | type = 19 |
| 2664 | stats_type = 65535 |
| 2665 | experimenter = 6035143 |
| 2666 | |
| 2667 | def __init__(self, xid=None, flags=None, subtype=None): |
| 2668 | if xid != None: |
| 2669 | self.xid = xid |
| 2670 | else: |
| 2671 | self.xid = None |
| 2672 | if flags != None: |
| 2673 | self.flags = flags |
| 2674 | else: |
| 2675 | self.flags = 0 |
| 2676 | if subtype != None: |
| 2677 | self.subtype = subtype |
| 2678 | else: |
| 2679 | self.subtype = 0 |
| 2680 | return |
| 2681 | |
| 2682 | def pack(self): |
| 2683 | packed = [] |
| 2684 | packed.append(struct.pack("!B", self.version)) |
| 2685 | packed.append(struct.pack("!B", self.type)) |
| 2686 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2687 | packed.append(struct.pack("!L", self.xid)) |
| 2688 | packed.append(struct.pack("!H", self.stats_type)) |
| 2689 | packed.append(struct.pack("!H", self.flags)) |
| 2690 | packed.append('\x00' * 4) |
| 2691 | packed.append(struct.pack("!L", self.experimenter)) |
| 2692 | packed.append(struct.pack("!L", self.subtype)) |
| 2693 | length = sum([len(x) for x in packed]) |
| 2694 | packed[2] = struct.pack("!H", length) |
| 2695 | return ''.join(packed) |
| 2696 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2697 | @staticmethod |
| 2698 | def unpack(reader): |
| 2699 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2700 | subclass = bsn_stats_reply.subtypes.get(subtype) |
| 2701 | if subclass: |
| 2702 | return subclass.unpack(reader) |
| 2703 | |
| 2704 | obj = bsn_stats_reply() |
| 2705 | _version = reader.read("!B")[0] |
| 2706 | assert(_version == 2) |
| 2707 | _type = reader.read("!B")[0] |
| 2708 | assert(_type == 19) |
| 2709 | _length = reader.read("!H")[0] |
| 2710 | orig_reader = reader |
| 2711 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2712 | obj.xid = reader.read("!L")[0] |
| 2713 | _stats_type = reader.read("!H")[0] |
| 2714 | assert(_stats_type == 65535) |
| 2715 | obj.flags = reader.read("!H")[0] |
| 2716 | reader.skip(4) |
| 2717 | _experimenter = reader.read("!L")[0] |
| 2718 | assert(_experimenter == 6035143) |
| 2719 | obj.subtype = reader.read("!L")[0] |
| 2720 | return obj |
| 2721 | |
| 2722 | def __eq__(self, other): |
| 2723 | if type(self) != type(other): return False |
| 2724 | if self.xid != other.xid: return False |
| 2725 | if self.flags != other.flags: return False |
| 2726 | if self.subtype != other.subtype: return False |
| 2727 | return True |
| 2728 | |
| 2729 | def pretty_print(self, q): |
| 2730 | q.text("bsn_stats_reply {") |
| 2731 | with q.group(): |
| 2732 | with q.indent(2): |
| 2733 | q.breakable() |
| 2734 | q.text("xid = "); |
| 2735 | if self.xid != None: |
| 2736 | q.text("%#x" % self.xid) |
| 2737 | else: |
| 2738 | q.text('None') |
| 2739 | q.text(","); q.breakable() |
| 2740 | q.text("flags = "); |
| 2741 | q.text("%#x" % self.flags) |
| 2742 | q.breakable() |
| 2743 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2744 | |
| 2745 | experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply |
| 2746 | |
| 2747 | class experimenter_stats_request(stats_request): |
| 2748 | subtypes = {} |
| 2749 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2750 | version = 2 |
| 2751 | type = 18 |
| 2752 | stats_type = 65535 |
| 2753 | |
| 2754 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 2755 | if xid != None: |
| 2756 | self.xid = xid |
| 2757 | else: |
| 2758 | self.xid = None |
| 2759 | if flags != None: |
| 2760 | self.flags = flags |
| 2761 | else: |
| 2762 | self.flags = 0 |
| 2763 | if experimenter != None: |
| 2764 | self.experimenter = experimenter |
| 2765 | else: |
| 2766 | self.experimenter = 0 |
| 2767 | if data != None: |
| 2768 | self.data = data |
| 2769 | else: |
| 2770 | self.data = '' |
| 2771 | return |
| 2772 | |
| 2773 | def pack(self): |
| 2774 | packed = [] |
| 2775 | packed.append(struct.pack("!B", self.version)) |
| 2776 | packed.append(struct.pack("!B", self.type)) |
| 2777 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2778 | packed.append(struct.pack("!L", self.xid)) |
| 2779 | packed.append(struct.pack("!H", self.stats_type)) |
| 2780 | packed.append(struct.pack("!H", self.flags)) |
| 2781 | packed.append('\x00' * 4) |
| 2782 | packed.append(struct.pack("!L", self.experimenter)) |
| 2783 | packed.append('\x00' * 4) |
| 2784 | packed.append(self.data) |
| 2785 | length = sum([len(x) for x in packed]) |
| 2786 | packed[2] = struct.pack("!H", length) |
| 2787 | return ''.join(packed) |
| 2788 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2789 | @staticmethod |
| 2790 | def unpack(reader): |
| 2791 | subtype, = reader.peek('!L', 16) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2792 | subclass = experimenter_stats_request.subtypes.get(subtype) |
| 2793 | if subclass: |
| 2794 | return subclass.unpack(reader) |
| 2795 | |
| 2796 | obj = experimenter_stats_request() |
| 2797 | _version = reader.read("!B")[0] |
| 2798 | assert(_version == 2) |
| 2799 | _type = reader.read("!B")[0] |
| 2800 | assert(_type == 18) |
| 2801 | _length = reader.read("!H")[0] |
| 2802 | orig_reader = reader |
| 2803 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2804 | obj.xid = reader.read("!L")[0] |
| 2805 | _stats_type = reader.read("!H")[0] |
| 2806 | assert(_stats_type == 65535) |
| 2807 | obj.flags = reader.read("!H")[0] |
| 2808 | reader.skip(4) |
| 2809 | obj.experimenter = reader.read("!L")[0] |
| 2810 | reader.skip(4) |
| 2811 | obj.data = str(reader.read_all()) |
| 2812 | return obj |
| 2813 | |
| 2814 | def __eq__(self, other): |
| 2815 | if type(self) != type(other): return False |
| 2816 | if self.xid != other.xid: return False |
| 2817 | if self.flags != other.flags: return False |
| 2818 | if self.experimenter != other.experimenter: return False |
| 2819 | if self.data != other.data: return False |
| 2820 | return True |
| 2821 | |
| 2822 | def pretty_print(self, q): |
| 2823 | q.text("experimenter_stats_request {") |
| 2824 | with q.group(): |
| 2825 | with q.indent(2): |
| 2826 | q.breakable() |
| 2827 | q.text("xid = "); |
| 2828 | if self.xid != None: |
| 2829 | q.text("%#x" % self.xid) |
| 2830 | else: |
| 2831 | q.text('None') |
| 2832 | q.text(","); q.breakable() |
| 2833 | q.text("flags = "); |
| 2834 | q.text("%#x" % self.flags) |
| 2835 | q.text(","); q.breakable() |
| 2836 | q.text("data = "); |
| 2837 | q.pp(self.data) |
| 2838 | q.breakable() |
| 2839 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2840 | |
| 2841 | stats_request.subtypes[65535] = experimenter_stats_request |
| 2842 | |
| 2843 | class bsn_stats_request(experimenter_stats_request): |
| 2844 | subtypes = {} |
| 2845 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2846 | version = 2 |
| 2847 | type = 18 |
| 2848 | stats_type = 65535 |
| 2849 | experimenter = 6035143 |
| 2850 | |
| 2851 | def __init__(self, xid=None, flags=None, subtype=None): |
| 2852 | if xid != None: |
| 2853 | self.xid = xid |
| 2854 | else: |
| 2855 | self.xid = None |
| 2856 | if flags != None: |
| 2857 | self.flags = flags |
| 2858 | else: |
| 2859 | self.flags = 0 |
| 2860 | if subtype != None: |
| 2861 | self.subtype = subtype |
| 2862 | else: |
| 2863 | self.subtype = 0 |
| 2864 | return |
| 2865 | |
| 2866 | def pack(self): |
| 2867 | packed = [] |
| 2868 | packed.append(struct.pack("!B", self.version)) |
| 2869 | packed.append(struct.pack("!B", self.type)) |
| 2870 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2871 | packed.append(struct.pack("!L", self.xid)) |
| 2872 | packed.append(struct.pack("!H", self.stats_type)) |
| 2873 | packed.append(struct.pack("!H", self.flags)) |
| 2874 | packed.append('\x00' * 4) |
| 2875 | packed.append(struct.pack("!L", self.experimenter)) |
| 2876 | packed.append(struct.pack("!L", self.subtype)) |
| 2877 | length = sum([len(x) for x in packed]) |
| 2878 | packed[2] = struct.pack("!H", length) |
| 2879 | return ''.join(packed) |
| 2880 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2881 | @staticmethod |
| 2882 | def unpack(reader): |
| 2883 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2884 | subclass = bsn_stats_request.subtypes.get(subtype) |
| 2885 | if subclass: |
| 2886 | return subclass.unpack(reader) |
| 2887 | |
| 2888 | obj = bsn_stats_request() |
| 2889 | _version = reader.read("!B")[0] |
| 2890 | assert(_version == 2) |
| 2891 | _type = reader.read("!B")[0] |
| 2892 | assert(_type == 18) |
| 2893 | _length = reader.read("!H")[0] |
| 2894 | orig_reader = reader |
| 2895 | reader = orig_reader.slice(_length - (2 + 2)) |
| 2896 | obj.xid = reader.read("!L")[0] |
| 2897 | _stats_type = reader.read("!H")[0] |
| 2898 | assert(_stats_type == 65535) |
| 2899 | obj.flags = reader.read("!H")[0] |
| 2900 | reader.skip(4) |
| 2901 | _experimenter = reader.read("!L")[0] |
| 2902 | assert(_experimenter == 6035143) |
| 2903 | obj.subtype = reader.read("!L")[0] |
| 2904 | return obj |
| 2905 | |
| 2906 | def __eq__(self, other): |
| 2907 | if type(self) != type(other): return False |
| 2908 | if self.xid != other.xid: return False |
| 2909 | if self.flags != other.flags: return False |
| 2910 | if self.subtype != other.subtype: return False |
| 2911 | return True |
| 2912 | |
| 2913 | def pretty_print(self, q): |
| 2914 | q.text("bsn_stats_request {") |
| 2915 | with q.group(): |
| 2916 | with q.indent(2): |
| 2917 | q.breakable() |
| 2918 | q.text("xid = "); |
| 2919 | if self.xid != None: |
| 2920 | q.text("%#x" % self.xid) |
| 2921 | else: |
| 2922 | q.text('None') |
| 2923 | q.text(","); q.breakable() |
| 2924 | q.text("flags = "); |
| 2925 | q.text("%#x" % self.flags) |
| 2926 | q.breakable() |
| 2927 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2928 | |
| 2929 | experimenter_stats_request.subtypes[6035143] = bsn_stats_request |
| 2930 | |
| 2931 | class bsn_virtual_port_create_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2932 | version = 2 |
| 2933 | type = 4 |
| 2934 | experimenter = 6035143 |
| 2935 | subtype = 16 |
| 2936 | |
| 2937 | def __init__(self, xid=None, status=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2938 | if xid != None: |
| 2939 | self.xid = xid |
| 2940 | else: |
| 2941 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2942 | if status != None: |
| 2943 | self.status = status |
| 2944 | else: |
| 2945 | self.status = 0 |
| 2946 | if vport_no != None: |
| 2947 | self.vport_no = vport_no |
| 2948 | else: |
| 2949 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2950 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2951 | |
| 2952 | def pack(self): |
| 2953 | packed = [] |
| 2954 | packed.append(struct.pack("!B", self.version)) |
| 2955 | packed.append(struct.pack("!B", self.type)) |
| 2956 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2957 | packed.append(struct.pack("!L", self.xid)) |
| 2958 | packed.append(struct.pack("!L", self.experimenter)) |
| 2959 | packed.append(struct.pack("!L", self.subtype)) |
| 2960 | packed.append(struct.pack("!L", self.status)) |
| 2961 | packed.append(struct.pack("!L", self.vport_no)) |
| 2962 | length = sum([len(x) for x in packed]) |
| 2963 | packed[2] = struct.pack("!H", length) |
| 2964 | return ''.join(packed) |
| 2965 | |
| 2966 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2967 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2968 | obj = bsn_virtual_port_create_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2969 | _version = reader.read("!B")[0] |
| 2970 | assert(_version == 2) |
| 2971 | _type = reader.read("!B")[0] |
| 2972 | assert(_type == 4) |
| 2973 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2974 | orig_reader = reader |
| 2975 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2976 | obj.xid = reader.read("!L")[0] |
| 2977 | _experimenter = reader.read("!L")[0] |
| 2978 | assert(_experimenter == 6035143) |
| 2979 | _subtype = reader.read("!L")[0] |
| 2980 | assert(_subtype == 16) |
| 2981 | obj.status = reader.read("!L")[0] |
| 2982 | obj.vport_no = reader.read("!L")[0] |
| 2983 | return obj |
| 2984 | |
| 2985 | def __eq__(self, other): |
| 2986 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2987 | if self.xid != other.xid: return False |
| 2988 | if self.status != other.status: return False |
| 2989 | if self.vport_no != other.vport_no: return False |
| 2990 | return True |
| 2991 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2992 | def pretty_print(self, q): |
| 2993 | q.text("bsn_virtual_port_create_reply {") |
| 2994 | with q.group(): |
| 2995 | with q.indent(2): |
| 2996 | q.breakable() |
| 2997 | q.text("xid = "); |
| 2998 | if self.xid != None: |
| 2999 | q.text("%#x" % self.xid) |
| 3000 | else: |
| 3001 | q.text('None') |
| 3002 | q.text(","); q.breakable() |
| 3003 | q.text("status = "); |
| 3004 | q.text("%#x" % self.status) |
| 3005 | q.text(","); q.breakable() |
| 3006 | q.text("vport_no = "); |
| 3007 | q.text("%#x" % self.vport_no) |
| 3008 | q.breakable() |
| 3009 | q.text('}') |
| 3010 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3011 | bsn_header.subtypes[16] = bsn_virtual_port_create_reply |
| 3012 | |
| 3013 | class bsn_virtual_port_create_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3014 | version = 2 |
| 3015 | type = 4 |
| 3016 | experimenter = 6035143 |
| 3017 | subtype = 15 |
| 3018 | |
| 3019 | def __init__(self, xid=None, vport=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3020 | if xid != None: |
| 3021 | self.xid = xid |
| 3022 | else: |
| 3023 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3024 | if vport != None: |
| 3025 | self.vport = vport |
| 3026 | else: |
| 3027 | self.vport = common.bsn_vport_q_in_q() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3028 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3029 | |
| 3030 | def pack(self): |
| 3031 | packed = [] |
| 3032 | packed.append(struct.pack("!B", self.version)) |
| 3033 | packed.append(struct.pack("!B", self.type)) |
| 3034 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3035 | packed.append(struct.pack("!L", self.xid)) |
| 3036 | packed.append(struct.pack("!L", self.experimenter)) |
| 3037 | packed.append(struct.pack("!L", self.subtype)) |
| 3038 | packed.append(self.vport.pack()) |
| 3039 | length = sum([len(x) for x in packed]) |
| 3040 | packed[2] = struct.pack("!H", length) |
| 3041 | return ''.join(packed) |
| 3042 | |
| 3043 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3044 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3045 | obj = bsn_virtual_port_create_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3046 | _version = reader.read("!B")[0] |
| 3047 | assert(_version == 2) |
| 3048 | _type = reader.read("!B")[0] |
| 3049 | assert(_type == 4) |
| 3050 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3051 | orig_reader = reader |
| 3052 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3053 | obj.xid = reader.read("!L")[0] |
| 3054 | _experimenter = reader.read("!L")[0] |
| 3055 | assert(_experimenter == 6035143) |
| 3056 | _subtype = reader.read("!L")[0] |
| 3057 | assert(_subtype == 15) |
| 3058 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 3059 | return obj |
| 3060 | |
| 3061 | def __eq__(self, other): |
| 3062 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3063 | if self.xid != other.xid: return False |
| 3064 | if self.vport != other.vport: return False |
| 3065 | return True |
| 3066 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3067 | def pretty_print(self, q): |
| 3068 | q.text("bsn_virtual_port_create_request {") |
| 3069 | with q.group(): |
| 3070 | with q.indent(2): |
| 3071 | q.breakable() |
| 3072 | q.text("xid = "); |
| 3073 | if self.xid != None: |
| 3074 | q.text("%#x" % self.xid) |
| 3075 | else: |
| 3076 | q.text('None') |
| 3077 | q.text(","); q.breakable() |
| 3078 | q.text("vport = "); |
| 3079 | q.pp(self.vport) |
| 3080 | q.breakable() |
| 3081 | q.text('}') |
| 3082 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3083 | bsn_header.subtypes[15] = bsn_virtual_port_create_request |
| 3084 | |
| 3085 | class bsn_virtual_port_remove_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3086 | version = 2 |
| 3087 | type = 4 |
| 3088 | experimenter = 6035143 |
| 3089 | subtype = 26 |
| 3090 | |
| 3091 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3092 | if xid != None: |
| 3093 | self.xid = xid |
| 3094 | else: |
| 3095 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3096 | if status != None: |
| 3097 | self.status = status |
| 3098 | else: |
| 3099 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3100 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3101 | |
| 3102 | def pack(self): |
| 3103 | packed = [] |
| 3104 | packed.append(struct.pack("!B", self.version)) |
| 3105 | packed.append(struct.pack("!B", self.type)) |
| 3106 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3107 | packed.append(struct.pack("!L", self.xid)) |
| 3108 | packed.append(struct.pack("!L", self.experimenter)) |
| 3109 | packed.append(struct.pack("!L", self.subtype)) |
| 3110 | packed.append(struct.pack("!L", self.status)) |
| 3111 | length = sum([len(x) for x in packed]) |
| 3112 | packed[2] = struct.pack("!H", length) |
| 3113 | return ''.join(packed) |
| 3114 | |
| 3115 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3116 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3117 | obj = bsn_virtual_port_remove_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3118 | _version = reader.read("!B")[0] |
| 3119 | assert(_version == 2) |
| 3120 | _type = reader.read("!B")[0] |
| 3121 | assert(_type == 4) |
| 3122 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3123 | orig_reader = reader |
| 3124 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3125 | obj.xid = reader.read("!L")[0] |
| 3126 | _experimenter = reader.read("!L")[0] |
| 3127 | assert(_experimenter == 6035143) |
| 3128 | _subtype = reader.read("!L")[0] |
| 3129 | assert(_subtype == 26) |
| 3130 | obj.status = reader.read("!L")[0] |
| 3131 | return obj |
| 3132 | |
| 3133 | def __eq__(self, other): |
| 3134 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3135 | if self.xid != other.xid: return False |
| 3136 | if self.status != other.status: return False |
| 3137 | return True |
| 3138 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3139 | def pretty_print(self, q): |
| 3140 | q.text("bsn_virtual_port_remove_reply {") |
| 3141 | with q.group(): |
| 3142 | with q.indent(2): |
| 3143 | q.breakable() |
| 3144 | q.text("xid = "); |
| 3145 | if self.xid != None: |
| 3146 | q.text("%#x" % self.xid) |
| 3147 | else: |
| 3148 | q.text('None') |
| 3149 | q.text(","); q.breakable() |
| 3150 | q.text("status = "); |
| 3151 | q.text("%#x" % self.status) |
| 3152 | q.breakable() |
| 3153 | q.text('}') |
| 3154 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3155 | bsn_header.subtypes[26] = bsn_virtual_port_remove_reply |
| 3156 | |
| 3157 | class bsn_virtual_port_remove_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3158 | version = 2 |
| 3159 | type = 4 |
| 3160 | experimenter = 6035143 |
| 3161 | subtype = 17 |
| 3162 | |
| 3163 | def __init__(self, xid=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3164 | if xid != None: |
| 3165 | self.xid = xid |
| 3166 | else: |
| 3167 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3168 | if vport_no != None: |
| 3169 | self.vport_no = vport_no |
| 3170 | else: |
| 3171 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3172 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3173 | |
| 3174 | def pack(self): |
| 3175 | packed = [] |
| 3176 | packed.append(struct.pack("!B", self.version)) |
| 3177 | packed.append(struct.pack("!B", self.type)) |
| 3178 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3179 | packed.append(struct.pack("!L", self.xid)) |
| 3180 | packed.append(struct.pack("!L", self.experimenter)) |
| 3181 | packed.append(struct.pack("!L", self.subtype)) |
| 3182 | packed.append(struct.pack("!L", self.vport_no)) |
| 3183 | length = sum([len(x) for x in packed]) |
| 3184 | packed[2] = struct.pack("!H", length) |
| 3185 | return ''.join(packed) |
| 3186 | |
| 3187 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3188 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3189 | obj = bsn_virtual_port_remove_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3190 | _version = reader.read("!B")[0] |
| 3191 | assert(_version == 2) |
| 3192 | _type = reader.read("!B")[0] |
| 3193 | assert(_type == 4) |
| 3194 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3195 | orig_reader = reader |
| 3196 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3197 | obj.xid = reader.read("!L")[0] |
| 3198 | _experimenter = reader.read("!L")[0] |
| 3199 | assert(_experimenter == 6035143) |
| 3200 | _subtype = reader.read("!L")[0] |
| 3201 | assert(_subtype == 17) |
| 3202 | obj.vport_no = reader.read("!L")[0] |
| 3203 | return obj |
| 3204 | |
| 3205 | def __eq__(self, other): |
| 3206 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3207 | if self.xid != other.xid: return False |
| 3208 | if self.vport_no != other.vport_no: return False |
| 3209 | return True |
| 3210 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3211 | def pretty_print(self, q): |
| 3212 | q.text("bsn_virtual_port_remove_request {") |
| 3213 | with q.group(): |
| 3214 | with q.indent(2): |
| 3215 | q.breakable() |
| 3216 | q.text("xid = "); |
| 3217 | if self.xid != None: |
| 3218 | q.text("%#x" % self.xid) |
| 3219 | else: |
| 3220 | q.text('None') |
| 3221 | q.text(","); q.breakable() |
| 3222 | q.text("vport_no = "); |
| 3223 | q.text("%#x" % self.vport_no) |
| 3224 | q.breakable() |
| 3225 | q.text('}') |
| 3226 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3227 | bsn_header.subtypes[17] = bsn_virtual_port_remove_request |
| 3228 | |
| 3229 | class desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3230 | version = 2 |
| 3231 | type = 19 |
| 3232 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3233 | |
| 3234 | 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] | 3235 | if xid != None: |
| 3236 | self.xid = xid |
| 3237 | else: |
| 3238 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3239 | if flags != None: |
| 3240 | self.flags = flags |
| 3241 | else: |
| 3242 | self.flags = 0 |
| 3243 | if mfr_desc != None: |
| 3244 | self.mfr_desc = mfr_desc |
| 3245 | else: |
| 3246 | self.mfr_desc = "" |
| 3247 | if hw_desc != None: |
| 3248 | self.hw_desc = hw_desc |
| 3249 | else: |
| 3250 | self.hw_desc = "" |
| 3251 | if sw_desc != None: |
| 3252 | self.sw_desc = sw_desc |
| 3253 | else: |
| 3254 | self.sw_desc = "" |
| 3255 | if serial_num != None: |
| 3256 | self.serial_num = serial_num |
| 3257 | else: |
| 3258 | self.serial_num = "" |
| 3259 | if dp_desc != None: |
| 3260 | self.dp_desc = dp_desc |
| 3261 | else: |
| 3262 | self.dp_desc = "" |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3263 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3264 | |
| 3265 | def pack(self): |
| 3266 | packed = [] |
| 3267 | packed.append(struct.pack("!B", self.version)) |
| 3268 | packed.append(struct.pack("!B", self.type)) |
| 3269 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3270 | packed.append(struct.pack("!L", self.xid)) |
| 3271 | packed.append(struct.pack("!H", self.stats_type)) |
| 3272 | packed.append(struct.pack("!H", self.flags)) |
| 3273 | packed.append('\x00' * 4) |
| 3274 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 3275 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 3276 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 3277 | packed.append(struct.pack("!32s", self.serial_num)) |
| 3278 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 3279 | length = sum([len(x) for x in packed]) |
| 3280 | packed[2] = struct.pack("!H", length) |
| 3281 | return ''.join(packed) |
| 3282 | |
| 3283 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3284 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3285 | obj = desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3286 | _version = reader.read("!B")[0] |
| 3287 | assert(_version == 2) |
| 3288 | _type = reader.read("!B")[0] |
| 3289 | assert(_type == 19) |
| 3290 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3291 | orig_reader = reader |
| 3292 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3293 | obj.xid = reader.read("!L")[0] |
| 3294 | _stats_type = reader.read("!H")[0] |
| 3295 | assert(_stats_type == 0) |
| 3296 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3297 | reader.skip(4) |
| 3298 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3299 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3300 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3301 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 3302 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3303 | return obj |
| 3304 | |
| 3305 | def __eq__(self, other): |
| 3306 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3307 | if self.xid != other.xid: return False |
| 3308 | if self.flags != other.flags: return False |
| 3309 | if self.mfr_desc != other.mfr_desc: return False |
| 3310 | if self.hw_desc != other.hw_desc: return False |
| 3311 | if self.sw_desc != other.sw_desc: return False |
| 3312 | if self.serial_num != other.serial_num: return False |
| 3313 | if self.dp_desc != other.dp_desc: return False |
| 3314 | return True |
| 3315 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3316 | def pretty_print(self, q): |
| 3317 | q.text("desc_stats_reply {") |
| 3318 | with q.group(): |
| 3319 | with q.indent(2): |
| 3320 | q.breakable() |
| 3321 | q.text("xid = "); |
| 3322 | if self.xid != None: |
| 3323 | q.text("%#x" % self.xid) |
| 3324 | else: |
| 3325 | q.text('None') |
| 3326 | q.text(","); q.breakable() |
| 3327 | q.text("flags = "); |
| 3328 | q.text("%#x" % self.flags) |
| 3329 | q.text(","); q.breakable() |
| 3330 | q.text("mfr_desc = "); |
| 3331 | q.pp(self.mfr_desc) |
| 3332 | q.text(","); q.breakable() |
| 3333 | q.text("hw_desc = "); |
| 3334 | q.pp(self.hw_desc) |
| 3335 | q.text(","); q.breakable() |
| 3336 | q.text("sw_desc = "); |
| 3337 | q.pp(self.sw_desc) |
| 3338 | q.text(","); q.breakable() |
| 3339 | q.text("serial_num = "); |
| 3340 | q.pp(self.serial_num) |
| 3341 | q.text(","); q.breakable() |
| 3342 | q.text("dp_desc = "); |
| 3343 | q.pp(self.dp_desc) |
| 3344 | q.breakable() |
| 3345 | q.text('}') |
| 3346 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3347 | stats_reply.subtypes[0] = desc_stats_reply |
| 3348 | |
| 3349 | class desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3350 | version = 2 |
| 3351 | type = 18 |
| 3352 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3353 | |
| 3354 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3355 | if xid != None: |
| 3356 | self.xid = xid |
| 3357 | else: |
| 3358 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3359 | if flags != None: |
| 3360 | self.flags = flags |
| 3361 | else: |
| 3362 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3363 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3364 | |
| 3365 | def pack(self): |
| 3366 | packed = [] |
| 3367 | packed.append(struct.pack("!B", self.version)) |
| 3368 | packed.append(struct.pack("!B", self.type)) |
| 3369 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3370 | packed.append(struct.pack("!L", self.xid)) |
| 3371 | packed.append(struct.pack("!H", self.stats_type)) |
| 3372 | packed.append(struct.pack("!H", self.flags)) |
| 3373 | packed.append('\x00' * 4) |
| 3374 | length = sum([len(x) for x in packed]) |
| 3375 | packed[2] = struct.pack("!H", length) |
| 3376 | return ''.join(packed) |
| 3377 | |
| 3378 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3379 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3380 | obj = desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3381 | _version = reader.read("!B")[0] |
| 3382 | assert(_version == 2) |
| 3383 | _type = reader.read("!B")[0] |
| 3384 | assert(_type == 18) |
| 3385 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3386 | orig_reader = reader |
| 3387 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3388 | obj.xid = reader.read("!L")[0] |
| 3389 | _stats_type = reader.read("!H")[0] |
| 3390 | assert(_stats_type == 0) |
| 3391 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3392 | reader.skip(4) |
| 3393 | return obj |
| 3394 | |
| 3395 | def __eq__(self, other): |
| 3396 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3397 | if self.xid != other.xid: return False |
| 3398 | if self.flags != other.flags: return False |
| 3399 | return True |
| 3400 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3401 | def pretty_print(self, q): |
| 3402 | q.text("desc_stats_request {") |
| 3403 | with q.group(): |
| 3404 | with q.indent(2): |
| 3405 | q.breakable() |
| 3406 | q.text("xid = "); |
| 3407 | if self.xid != None: |
| 3408 | q.text("%#x" % self.xid) |
| 3409 | else: |
| 3410 | q.text('None') |
| 3411 | q.text(","); q.breakable() |
| 3412 | q.text("flags = "); |
| 3413 | q.text("%#x" % self.flags) |
| 3414 | q.breakable() |
| 3415 | q.text('}') |
| 3416 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3417 | stats_request.subtypes[0] = desc_stats_request |
| 3418 | |
| 3419 | class echo_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3420 | version = 2 |
| 3421 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3422 | |
| 3423 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3424 | if xid != None: |
| 3425 | self.xid = xid |
| 3426 | else: |
| 3427 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3428 | if data != None: |
| 3429 | self.data = data |
| 3430 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3431 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3432 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3433 | |
| 3434 | def pack(self): |
| 3435 | packed = [] |
| 3436 | packed.append(struct.pack("!B", self.version)) |
| 3437 | packed.append(struct.pack("!B", self.type)) |
| 3438 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3439 | packed.append(struct.pack("!L", self.xid)) |
| 3440 | packed.append(self.data) |
| 3441 | length = sum([len(x) for x in packed]) |
| 3442 | packed[2] = struct.pack("!H", length) |
| 3443 | return ''.join(packed) |
| 3444 | |
| 3445 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3446 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3447 | obj = echo_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3448 | _version = reader.read("!B")[0] |
| 3449 | assert(_version == 2) |
| 3450 | _type = reader.read("!B")[0] |
| 3451 | assert(_type == 3) |
| 3452 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3453 | orig_reader = reader |
| 3454 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3455 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3456 | obj.data = str(reader.read_all()) |
| 3457 | return obj |
| 3458 | |
| 3459 | def __eq__(self, other): |
| 3460 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3461 | if self.xid != other.xid: return False |
| 3462 | if self.data != other.data: return False |
| 3463 | return True |
| 3464 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3465 | def pretty_print(self, q): |
| 3466 | q.text("echo_reply {") |
| 3467 | with q.group(): |
| 3468 | with q.indent(2): |
| 3469 | q.breakable() |
| 3470 | q.text("xid = "); |
| 3471 | if self.xid != None: |
| 3472 | q.text("%#x" % self.xid) |
| 3473 | else: |
| 3474 | q.text('None') |
| 3475 | q.text(","); q.breakable() |
| 3476 | q.text("data = "); |
| 3477 | q.pp(self.data) |
| 3478 | q.breakable() |
| 3479 | q.text('}') |
| 3480 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3481 | message.subtypes[3] = echo_reply |
| 3482 | |
| 3483 | class echo_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3484 | version = 2 |
| 3485 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3486 | |
| 3487 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3488 | if xid != None: |
| 3489 | self.xid = xid |
| 3490 | else: |
| 3491 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3492 | if data != None: |
| 3493 | self.data = data |
| 3494 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3495 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3496 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3497 | |
| 3498 | def pack(self): |
| 3499 | packed = [] |
| 3500 | packed.append(struct.pack("!B", self.version)) |
| 3501 | packed.append(struct.pack("!B", self.type)) |
| 3502 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3503 | packed.append(struct.pack("!L", self.xid)) |
| 3504 | packed.append(self.data) |
| 3505 | length = sum([len(x) for x in packed]) |
| 3506 | packed[2] = struct.pack("!H", length) |
| 3507 | return ''.join(packed) |
| 3508 | |
| 3509 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3510 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3511 | obj = echo_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3512 | _version = reader.read("!B")[0] |
| 3513 | assert(_version == 2) |
| 3514 | _type = reader.read("!B")[0] |
| 3515 | assert(_type == 2) |
| 3516 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3517 | orig_reader = reader |
| 3518 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3519 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3520 | obj.data = str(reader.read_all()) |
| 3521 | return obj |
| 3522 | |
| 3523 | def __eq__(self, other): |
| 3524 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3525 | if self.xid != other.xid: return False |
| 3526 | if self.data != other.data: return False |
| 3527 | return True |
| 3528 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3529 | def pretty_print(self, q): |
| 3530 | q.text("echo_request {") |
| 3531 | with q.group(): |
| 3532 | with q.indent(2): |
| 3533 | q.breakable() |
| 3534 | q.text("xid = "); |
| 3535 | if self.xid != None: |
| 3536 | q.text("%#x" % self.xid) |
| 3537 | else: |
| 3538 | q.text('None') |
| 3539 | q.text(","); q.breakable() |
| 3540 | q.text("data = "); |
| 3541 | q.pp(self.data) |
| 3542 | q.breakable() |
| 3543 | q.text('}') |
| 3544 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3545 | message.subtypes[2] = echo_request |
| 3546 | |
| 3547 | class features_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3548 | version = 2 |
| 3549 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3550 | |
| 3551 | 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] | 3552 | if xid != None: |
| 3553 | self.xid = xid |
| 3554 | else: |
| 3555 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3556 | if datapath_id != None: |
| 3557 | self.datapath_id = datapath_id |
| 3558 | else: |
| 3559 | self.datapath_id = 0 |
| 3560 | if n_buffers != None: |
| 3561 | self.n_buffers = n_buffers |
| 3562 | else: |
| 3563 | self.n_buffers = 0 |
| 3564 | if n_tables != None: |
| 3565 | self.n_tables = n_tables |
| 3566 | else: |
| 3567 | self.n_tables = 0 |
| 3568 | if capabilities != None: |
| 3569 | self.capabilities = capabilities |
| 3570 | else: |
| 3571 | self.capabilities = 0 |
| 3572 | if reserved != None: |
| 3573 | self.reserved = reserved |
| 3574 | else: |
| 3575 | self.reserved = 0 |
| 3576 | if ports != None: |
| 3577 | self.ports = ports |
| 3578 | else: |
| 3579 | self.ports = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3580 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3581 | |
| 3582 | def pack(self): |
| 3583 | packed = [] |
| 3584 | packed.append(struct.pack("!B", self.version)) |
| 3585 | packed.append(struct.pack("!B", self.type)) |
| 3586 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3587 | packed.append(struct.pack("!L", self.xid)) |
| 3588 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 3589 | packed.append(struct.pack("!L", self.n_buffers)) |
| 3590 | packed.append(struct.pack("!B", self.n_tables)) |
| 3591 | packed.append('\x00' * 3) |
| 3592 | packed.append(struct.pack("!L", self.capabilities)) |
| 3593 | packed.append(struct.pack("!L", self.reserved)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3594 | packed.append(loxi.generic_util.pack_list(self.ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3595 | length = sum([len(x) for x in packed]) |
| 3596 | packed[2] = struct.pack("!H", length) |
| 3597 | return ''.join(packed) |
| 3598 | |
| 3599 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3600 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3601 | obj = features_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3602 | _version = reader.read("!B")[0] |
| 3603 | assert(_version == 2) |
| 3604 | _type = reader.read("!B")[0] |
| 3605 | assert(_type == 6) |
| 3606 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3607 | orig_reader = reader |
| 3608 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3609 | obj.xid = reader.read("!L")[0] |
| 3610 | obj.datapath_id = reader.read("!Q")[0] |
| 3611 | obj.n_buffers = reader.read("!L")[0] |
| 3612 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3613 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3614 | obj.capabilities = reader.read("!L")[0] |
| 3615 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3616 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 3617 | return obj |
| 3618 | |
| 3619 | def __eq__(self, other): |
| 3620 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3621 | if self.xid != other.xid: return False |
| 3622 | if self.datapath_id != other.datapath_id: return False |
| 3623 | if self.n_buffers != other.n_buffers: return False |
| 3624 | if self.n_tables != other.n_tables: return False |
| 3625 | if self.capabilities != other.capabilities: return False |
| 3626 | if self.reserved != other.reserved: return False |
| 3627 | if self.ports != other.ports: return False |
| 3628 | return True |
| 3629 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3630 | def pretty_print(self, q): |
| 3631 | q.text("features_reply {") |
| 3632 | with q.group(): |
| 3633 | with q.indent(2): |
| 3634 | q.breakable() |
| 3635 | q.text("xid = "); |
| 3636 | if self.xid != None: |
| 3637 | q.text("%#x" % self.xid) |
| 3638 | else: |
| 3639 | q.text('None') |
| 3640 | q.text(","); q.breakable() |
| 3641 | q.text("datapath_id = "); |
| 3642 | q.text("%#x" % self.datapath_id) |
| 3643 | q.text(","); q.breakable() |
| 3644 | q.text("n_buffers = "); |
| 3645 | q.text("%#x" % self.n_buffers) |
| 3646 | q.text(","); q.breakable() |
| 3647 | q.text("n_tables = "); |
| 3648 | q.text("%#x" % self.n_tables) |
| 3649 | q.text(","); q.breakable() |
| 3650 | q.text("capabilities = "); |
| 3651 | q.text("%#x" % self.capabilities) |
| 3652 | q.text(","); q.breakable() |
| 3653 | q.text("reserved = "); |
| 3654 | q.text("%#x" % self.reserved) |
| 3655 | q.text(","); q.breakable() |
| 3656 | q.text("ports = "); |
| 3657 | q.pp(self.ports) |
| 3658 | q.breakable() |
| 3659 | q.text('}') |
| 3660 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3661 | message.subtypes[6] = features_reply |
| 3662 | |
| 3663 | class features_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3664 | version = 2 |
| 3665 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3666 | |
| 3667 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3668 | if xid != None: |
| 3669 | self.xid = xid |
| 3670 | else: |
| 3671 | self.xid = None |
| 3672 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3673 | |
| 3674 | def pack(self): |
| 3675 | packed = [] |
| 3676 | packed.append(struct.pack("!B", self.version)) |
| 3677 | packed.append(struct.pack("!B", self.type)) |
| 3678 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3679 | packed.append(struct.pack("!L", self.xid)) |
| 3680 | length = sum([len(x) for x in packed]) |
| 3681 | packed[2] = struct.pack("!H", length) |
| 3682 | return ''.join(packed) |
| 3683 | |
| 3684 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3685 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3686 | obj = features_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3687 | _version = reader.read("!B")[0] |
| 3688 | assert(_version == 2) |
| 3689 | _type = reader.read("!B")[0] |
| 3690 | assert(_type == 5) |
| 3691 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3692 | orig_reader = reader |
| 3693 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3694 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3695 | return obj |
| 3696 | |
| 3697 | def __eq__(self, other): |
| 3698 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3699 | if self.xid != other.xid: return False |
| 3700 | return True |
| 3701 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3702 | def pretty_print(self, q): |
| 3703 | q.text("features_request {") |
| 3704 | with q.group(): |
| 3705 | with q.indent(2): |
| 3706 | q.breakable() |
| 3707 | q.text("xid = "); |
| 3708 | if self.xid != None: |
| 3709 | q.text("%#x" % self.xid) |
| 3710 | else: |
| 3711 | q.text('None') |
| 3712 | q.breakable() |
| 3713 | q.text('}') |
| 3714 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3715 | message.subtypes[5] = features_request |
| 3716 | |
| 3717 | class flow_mod(message): |
| 3718 | subtypes = {} |
| 3719 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3720 | version = 2 |
| 3721 | type = 14 |
| 3722 | |
| 3723 | 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): |
| 3724 | if xid != None: |
| 3725 | self.xid = xid |
| 3726 | else: |
| 3727 | self.xid = None |
| 3728 | if cookie != None: |
| 3729 | self.cookie = cookie |
| 3730 | else: |
| 3731 | self.cookie = 0 |
| 3732 | if cookie_mask != None: |
| 3733 | self.cookie_mask = cookie_mask |
| 3734 | else: |
| 3735 | self.cookie_mask = 0 |
| 3736 | if table_id != None: |
| 3737 | self.table_id = table_id |
| 3738 | else: |
| 3739 | self.table_id = 0 |
| 3740 | if _command != None: |
| 3741 | self._command = _command |
| 3742 | else: |
| 3743 | self._command = 0 |
| 3744 | if idle_timeout != None: |
| 3745 | self.idle_timeout = idle_timeout |
| 3746 | else: |
| 3747 | self.idle_timeout = 0 |
| 3748 | if hard_timeout != None: |
| 3749 | self.hard_timeout = hard_timeout |
| 3750 | else: |
| 3751 | self.hard_timeout = 0 |
| 3752 | if priority != None: |
| 3753 | self.priority = priority |
| 3754 | else: |
| 3755 | self.priority = 0 |
| 3756 | if buffer_id != None: |
| 3757 | self.buffer_id = buffer_id |
| 3758 | else: |
| 3759 | self.buffer_id = 0 |
| 3760 | if out_port != None: |
| 3761 | self.out_port = out_port |
| 3762 | else: |
| 3763 | self.out_port = 0 |
| 3764 | if out_group != None: |
| 3765 | self.out_group = out_group |
| 3766 | else: |
| 3767 | self.out_group = 0 |
| 3768 | if flags != None: |
| 3769 | self.flags = flags |
| 3770 | else: |
| 3771 | self.flags = 0 |
| 3772 | if match != None: |
| 3773 | self.match = match |
| 3774 | else: |
| 3775 | self.match = common.match() |
| 3776 | if instructions != None: |
| 3777 | self.instructions = instructions |
| 3778 | else: |
| 3779 | self.instructions = [] |
| 3780 | return |
| 3781 | |
| 3782 | def pack(self): |
| 3783 | packed = [] |
| 3784 | packed.append(struct.pack("!B", self.version)) |
| 3785 | packed.append(struct.pack("!B", self.type)) |
| 3786 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3787 | packed.append(struct.pack("!L", self.xid)) |
| 3788 | packed.append(struct.pack("!Q", self.cookie)) |
| 3789 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3790 | packed.append(struct.pack("!B", self.table_id)) |
| 3791 | packed.append(util.pack_fm_cmd(self._command)) |
| 3792 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3793 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3794 | packed.append(struct.pack("!H", self.priority)) |
| 3795 | packed.append(struct.pack("!L", self.buffer_id)) |
| 3796 | packed.append(util.pack_port_no(self.out_port)) |
| 3797 | packed.append(struct.pack("!L", self.out_group)) |
| 3798 | packed.append(struct.pack("!H", self.flags)) |
| 3799 | packed.append('\x00' * 2) |
| 3800 | packed.append(self.match.pack()) |
| 3801 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
| 3802 | length = sum([len(x) for x in packed]) |
| 3803 | packed[2] = struct.pack("!H", length) |
| 3804 | return ''.join(packed) |
| 3805 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3806 | @staticmethod |
| 3807 | def unpack(reader): |
| 3808 | subtype, = reader.peek('B', 25) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3809 | subclass = flow_mod.subtypes.get(subtype) |
| 3810 | if subclass: |
| 3811 | return subclass.unpack(reader) |
| 3812 | |
| 3813 | obj = flow_mod() |
| 3814 | _version = reader.read("!B")[0] |
| 3815 | assert(_version == 2) |
| 3816 | _type = reader.read("!B")[0] |
| 3817 | assert(_type == 14) |
| 3818 | _length = reader.read("!H")[0] |
| 3819 | orig_reader = reader |
| 3820 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3821 | obj.xid = reader.read("!L")[0] |
| 3822 | obj.cookie = reader.read("!Q")[0] |
| 3823 | obj.cookie_mask = reader.read("!Q")[0] |
| 3824 | obj.table_id = reader.read("!B")[0] |
| 3825 | obj._command = util.unpack_fm_cmd(reader) |
| 3826 | obj.idle_timeout = reader.read("!H")[0] |
| 3827 | obj.hard_timeout = reader.read("!H")[0] |
| 3828 | obj.priority = reader.read("!H")[0] |
| 3829 | obj.buffer_id = reader.read("!L")[0] |
| 3830 | obj.out_port = util.unpack_port_no(reader) |
| 3831 | obj.out_group = reader.read("!L")[0] |
| 3832 | obj.flags = reader.read("!H")[0] |
| 3833 | reader.skip(2) |
| 3834 | obj.match = common.match.unpack(reader) |
| 3835 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
| 3836 | return obj |
| 3837 | |
| 3838 | def __eq__(self, other): |
| 3839 | if type(self) != type(other): return False |
| 3840 | if self.xid != other.xid: return False |
| 3841 | if self.cookie != other.cookie: return False |
| 3842 | if self.cookie_mask != other.cookie_mask: return False |
| 3843 | if self.table_id != other.table_id: return False |
| 3844 | if self._command != other._command: return False |
| 3845 | if self.idle_timeout != other.idle_timeout: return False |
| 3846 | if self.hard_timeout != other.hard_timeout: return False |
| 3847 | if self.priority != other.priority: return False |
| 3848 | if self.buffer_id != other.buffer_id: return False |
| 3849 | if self.out_port != other.out_port: return False |
| 3850 | if self.out_group != other.out_group: return False |
| 3851 | if self.flags != other.flags: return False |
| 3852 | if self.match != other.match: return False |
| 3853 | if self.instructions != other.instructions: return False |
| 3854 | return True |
| 3855 | |
| 3856 | def pretty_print(self, q): |
| 3857 | q.text("flow_mod {") |
| 3858 | with q.group(): |
| 3859 | with q.indent(2): |
| 3860 | q.breakable() |
| 3861 | q.text("xid = "); |
| 3862 | if self.xid != None: |
| 3863 | q.text("%#x" % self.xid) |
| 3864 | else: |
| 3865 | q.text('None') |
| 3866 | q.text(","); q.breakable() |
| 3867 | q.text("cookie = "); |
| 3868 | q.text("%#x" % self.cookie) |
| 3869 | q.text(","); q.breakable() |
| 3870 | q.text("cookie_mask = "); |
| 3871 | q.text("%#x" % self.cookie_mask) |
| 3872 | q.text(","); q.breakable() |
| 3873 | q.text("table_id = "); |
| 3874 | q.text("%#x" % self.table_id) |
| 3875 | q.text(","); q.breakable() |
| 3876 | q.text("idle_timeout = "); |
| 3877 | q.text("%#x" % self.idle_timeout) |
| 3878 | q.text(","); q.breakable() |
| 3879 | q.text("hard_timeout = "); |
| 3880 | q.text("%#x" % self.hard_timeout) |
| 3881 | q.text(","); q.breakable() |
| 3882 | q.text("priority = "); |
| 3883 | q.text("%#x" % self.priority) |
| 3884 | q.text(","); q.breakable() |
| 3885 | q.text("buffer_id = "); |
| 3886 | q.text("%#x" % self.buffer_id) |
| 3887 | q.text(","); q.breakable() |
| 3888 | q.text("out_port = "); |
| 3889 | q.text(util.pretty_port(self.out_port)) |
| 3890 | q.text(","); q.breakable() |
| 3891 | q.text("out_group = "); |
| 3892 | q.text("%#x" % self.out_group) |
| 3893 | q.text(","); q.breakable() |
| 3894 | q.text("flags = "); |
| 3895 | q.text("%#x" % self.flags) |
| 3896 | q.text(","); q.breakable() |
| 3897 | q.text("match = "); |
| 3898 | q.pp(self.match) |
| 3899 | q.text(","); q.breakable() |
| 3900 | q.text("instructions = "); |
| 3901 | q.pp(self.instructions) |
| 3902 | q.breakable() |
| 3903 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3904 | |
| 3905 | message.subtypes[14] = flow_mod |
| 3906 | |
| 3907 | class flow_add(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3908 | version = 2 |
| 3909 | type = 14 |
| 3910 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3911 | |
| 3912 | 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] | 3913 | if xid != None: |
| 3914 | self.xid = xid |
| 3915 | else: |
| 3916 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3917 | if cookie != None: |
| 3918 | self.cookie = cookie |
| 3919 | else: |
| 3920 | self.cookie = 0 |
| 3921 | if cookie_mask != None: |
| 3922 | self.cookie_mask = cookie_mask |
| 3923 | else: |
| 3924 | self.cookie_mask = 0 |
| 3925 | if table_id != None: |
| 3926 | self.table_id = table_id |
| 3927 | else: |
| 3928 | self.table_id = 0 |
| 3929 | if idle_timeout != None: |
| 3930 | self.idle_timeout = idle_timeout |
| 3931 | else: |
| 3932 | self.idle_timeout = 0 |
| 3933 | if hard_timeout != None: |
| 3934 | self.hard_timeout = hard_timeout |
| 3935 | else: |
| 3936 | self.hard_timeout = 0 |
| 3937 | if priority != None: |
| 3938 | self.priority = priority |
| 3939 | else: |
| 3940 | self.priority = 0 |
| 3941 | if buffer_id != None: |
| 3942 | self.buffer_id = buffer_id |
| 3943 | else: |
| 3944 | self.buffer_id = 0 |
| 3945 | if out_port != None: |
| 3946 | self.out_port = out_port |
| 3947 | else: |
| 3948 | self.out_port = 0 |
| 3949 | if out_group != None: |
| 3950 | self.out_group = out_group |
| 3951 | else: |
| 3952 | self.out_group = 0 |
| 3953 | if flags != None: |
| 3954 | self.flags = flags |
| 3955 | else: |
| 3956 | self.flags = 0 |
| 3957 | if match != None: |
| 3958 | self.match = match |
| 3959 | else: |
| 3960 | self.match = common.match() |
| 3961 | if instructions != None: |
| 3962 | self.instructions = instructions |
| 3963 | else: |
| 3964 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3965 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3966 | |
| 3967 | def pack(self): |
| 3968 | packed = [] |
| 3969 | packed.append(struct.pack("!B", self.version)) |
| 3970 | packed.append(struct.pack("!B", self.type)) |
| 3971 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3972 | packed.append(struct.pack("!L", self.xid)) |
| 3973 | packed.append(struct.pack("!Q", self.cookie)) |
| 3974 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3975 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3976 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3977 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3978 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3979 | packed.append(struct.pack("!H", self.priority)) |
| 3980 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3981 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3982 | packed.append(struct.pack("!L", self.out_group)) |
| 3983 | packed.append(struct.pack("!H", self.flags)) |
| 3984 | packed.append('\x00' * 2) |
| 3985 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3986 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3987 | length = sum([len(x) for x in packed]) |
| 3988 | packed[2] = struct.pack("!H", length) |
| 3989 | return ''.join(packed) |
| 3990 | |
| 3991 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3992 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3993 | obj = flow_add() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3994 | _version = reader.read("!B")[0] |
| 3995 | assert(_version == 2) |
| 3996 | _type = reader.read("!B")[0] |
| 3997 | assert(_type == 14) |
| 3998 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3999 | orig_reader = reader |
| 4000 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4001 | obj.xid = reader.read("!L")[0] |
| 4002 | obj.cookie = reader.read("!Q")[0] |
| 4003 | obj.cookie_mask = reader.read("!Q")[0] |
| 4004 | obj.table_id = reader.read("!B")[0] |
| 4005 | __command = util.unpack_fm_cmd(reader) |
| 4006 | assert(__command == 0) |
| 4007 | obj.idle_timeout = reader.read("!H")[0] |
| 4008 | obj.hard_timeout = reader.read("!H")[0] |
| 4009 | obj.priority = reader.read("!H")[0] |
| 4010 | obj.buffer_id = reader.read("!L")[0] |
| 4011 | obj.out_port = util.unpack_port_no(reader) |
| 4012 | obj.out_group = reader.read("!L")[0] |
| 4013 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4014 | reader.skip(2) |
| 4015 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4016 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4017 | return obj |
| 4018 | |
| 4019 | def __eq__(self, other): |
| 4020 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4021 | if self.xid != other.xid: return False |
| 4022 | if self.cookie != other.cookie: return False |
| 4023 | if self.cookie_mask != other.cookie_mask: return False |
| 4024 | if self.table_id != other.table_id: return False |
| 4025 | if self.idle_timeout != other.idle_timeout: return False |
| 4026 | if self.hard_timeout != other.hard_timeout: return False |
| 4027 | if self.priority != other.priority: return False |
| 4028 | if self.buffer_id != other.buffer_id: return False |
| 4029 | if self.out_port != other.out_port: return False |
| 4030 | if self.out_group != other.out_group: return False |
| 4031 | if self.flags != other.flags: return False |
| 4032 | if self.match != other.match: return False |
| 4033 | if self.instructions != other.instructions: return False |
| 4034 | return True |
| 4035 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4036 | def pretty_print(self, q): |
| 4037 | q.text("flow_add {") |
| 4038 | with q.group(): |
| 4039 | with q.indent(2): |
| 4040 | q.breakable() |
| 4041 | q.text("xid = "); |
| 4042 | if self.xid != None: |
| 4043 | q.text("%#x" % self.xid) |
| 4044 | else: |
| 4045 | q.text('None') |
| 4046 | q.text(","); q.breakable() |
| 4047 | q.text("cookie = "); |
| 4048 | q.text("%#x" % self.cookie) |
| 4049 | q.text(","); q.breakable() |
| 4050 | q.text("cookie_mask = "); |
| 4051 | q.text("%#x" % self.cookie_mask) |
| 4052 | q.text(","); q.breakable() |
| 4053 | q.text("table_id = "); |
| 4054 | q.text("%#x" % self.table_id) |
| 4055 | q.text(","); q.breakable() |
| 4056 | q.text("idle_timeout = "); |
| 4057 | q.text("%#x" % self.idle_timeout) |
| 4058 | q.text(","); q.breakable() |
| 4059 | q.text("hard_timeout = "); |
| 4060 | q.text("%#x" % self.hard_timeout) |
| 4061 | q.text(","); q.breakable() |
| 4062 | q.text("priority = "); |
| 4063 | q.text("%#x" % self.priority) |
| 4064 | q.text(","); q.breakable() |
| 4065 | q.text("buffer_id = "); |
| 4066 | q.text("%#x" % self.buffer_id) |
| 4067 | q.text(","); q.breakable() |
| 4068 | q.text("out_port = "); |
| 4069 | q.text(util.pretty_port(self.out_port)) |
| 4070 | q.text(","); q.breakable() |
| 4071 | q.text("out_group = "); |
| 4072 | q.text("%#x" % self.out_group) |
| 4073 | q.text(","); q.breakable() |
| 4074 | q.text("flags = "); |
| 4075 | q.text("%#x" % self.flags) |
| 4076 | q.text(","); q.breakable() |
| 4077 | q.text("match = "); |
| 4078 | q.pp(self.match) |
| 4079 | q.text(","); q.breakable() |
| 4080 | q.text("instructions = "); |
| 4081 | q.pp(self.instructions) |
| 4082 | q.breakable() |
| 4083 | q.text('}') |
| 4084 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4085 | flow_mod.subtypes[0] = flow_add |
| 4086 | |
| 4087 | class flow_delete(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4088 | version = 2 |
| 4089 | type = 14 |
| 4090 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4091 | |
| 4092 | 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] | 4093 | if xid != None: |
| 4094 | self.xid = xid |
| 4095 | else: |
| 4096 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4097 | if cookie != None: |
| 4098 | self.cookie = cookie |
| 4099 | else: |
| 4100 | self.cookie = 0 |
| 4101 | if cookie_mask != None: |
| 4102 | self.cookie_mask = cookie_mask |
| 4103 | else: |
| 4104 | self.cookie_mask = 0 |
| 4105 | if table_id != None: |
| 4106 | self.table_id = table_id |
| 4107 | else: |
| 4108 | self.table_id = 0 |
| 4109 | if idle_timeout != None: |
| 4110 | self.idle_timeout = idle_timeout |
| 4111 | else: |
| 4112 | self.idle_timeout = 0 |
| 4113 | if hard_timeout != None: |
| 4114 | self.hard_timeout = hard_timeout |
| 4115 | else: |
| 4116 | self.hard_timeout = 0 |
| 4117 | if priority != None: |
| 4118 | self.priority = priority |
| 4119 | else: |
| 4120 | self.priority = 0 |
| 4121 | if buffer_id != None: |
| 4122 | self.buffer_id = buffer_id |
| 4123 | else: |
| 4124 | self.buffer_id = 0 |
| 4125 | if out_port != None: |
| 4126 | self.out_port = out_port |
| 4127 | else: |
| 4128 | self.out_port = 0 |
| 4129 | if out_group != None: |
| 4130 | self.out_group = out_group |
| 4131 | else: |
| 4132 | self.out_group = 0 |
| 4133 | if flags != None: |
| 4134 | self.flags = flags |
| 4135 | else: |
| 4136 | self.flags = 0 |
| 4137 | if match != None: |
| 4138 | self.match = match |
| 4139 | else: |
| 4140 | self.match = common.match() |
| 4141 | if instructions != None: |
| 4142 | self.instructions = instructions |
| 4143 | else: |
| 4144 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4145 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4146 | |
| 4147 | def pack(self): |
| 4148 | packed = [] |
| 4149 | packed.append(struct.pack("!B", self.version)) |
| 4150 | packed.append(struct.pack("!B", self.type)) |
| 4151 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4152 | packed.append(struct.pack("!L", self.xid)) |
| 4153 | packed.append(struct.pack("!Q", self.cookie)) |
| 4154 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4155 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4156 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4157 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4158 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4159 | packed.append(struct.pack("!H", self.priority)) |
| 4160 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4161 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4162 | packed.append(struct.pack("!L", self.out_group)) |
| 4163 | packed.append(struct.pack("!H", self.flags)) |
| 4164 | packed.append('\x00' * 2) |
| 4165 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4166 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4167 | length = sum([len(x) for x in packed]) |
| 4168 | packed[2] = struct.pack("!H", length) |
| 4169 | return ''.join(packed) |
| 4170 | |
| 4171 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4172 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4173 | obj = flow_delete() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4174 | _version = reader.read("!B")[0] |
| 4175 | assert(_version == 2) |
| 4176 | _type = reader.read("!B")[0] |
| 4177 | assert(_type == 14) |
| 4178 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4179 | orig_reader = reader |
| 4180 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4181 | obj.xid = reader.read("!L")[0] |
| 4182 | obj.cookie = reader.read("!Q")[0] |
| 4183 | obj.cookie_mask = reader.read("!Q")[0] |
| 4184 | obj.table_id = reader.read("!B")[0] |
| 4185 | __command = util.unpack_fm_cmd(reader) |
| 4186 | assert(__command == 3) |
| 4187 | obj.idle_timeout = reader.read("!H")[0] |
| 4188 | obj.hard_timeout = reader.read("!H")[0] |
| 4189 | obj.priority = reader.read("!H")[0] |
| 4190 | obj.buffer_id = reader.read("!L")[0] |
| 4191 | obj.out_port = util.unpack_port_no(reader) |
| 4192 | obj.out_group = reader.read("!L")[0] |
| 4193 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4194 | reader.skip(2) |
| 4195 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4196 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4197 | return obj |
| 4198 | |
| 4199 | def __eq__(self, other): |
| 4200 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4201 | if self.xid != other.xid: return False |
| 4202 | if self.cookie != other.cookie: return False |
| 4203 | if self.cookie_mask != other.cookie_mask: return False |
| 4204 | if self.table_id != other.table_id: return False |
| 4205 | if self.idle_timeout != other.idle_timeout: return False |
| 4206 | if self.hard_timeout != other.hard_timeout: return False |
| 4207 | if self.priority != other.priority: return False |
| 4208 | if self.buffer_id != other.buffer_id: return False |
| 4209 | if self.out_port != other.out_port: return False |
| 4210 | if self.out_group != other.out_group: return False |
| 4211 | if self.flags != other.flags: return False |
| 4212 | if self.match != other.match: return False |
| 4213 | if self.instructions != other.instructions: return False |
| 4214 | return True |
| 4215 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4216 | def pretty_print(self, q): |
| 4217 | q.text("flow_delete {") |
| 4218 | with q.group(): |
| 4219 | with q.indent(2): |
| 4220 | q.breakable() |
| 4221 | q.text("xid = "); |
| 4222 | if self.xid != None: |
| 4223 | q.text("%#x" % self.xid) |
| 4224 | else: |
| 4225 | q.text('None') |
| 4226 | q.text(","); q.breakable() |
| 4227 | q.text("cookie = "); |
| 4228 | q.text("%#x" % self.cookie) |
| 4229 | q.text(","); q.breakable() |
| 4230 | q.text("cookie_mask = "); |
| 4231 | q.text("%#x" % self.cookie_mask) |
| 4232 | q.text(","); q.breakable() |
| 4233 | q.text("table_id = "); |
| 4234 | q.text("%#x" % self.table_id) |
| 4235 | q.text(","); q.breakable() |
| 4236 | q.text("idle_timeout = "); |
| 4237 | q.text("%#x" % self.idle_timeout) |
| 4238 | q.text(","); q.breakable() |
| 4239 | q.text("hard_timeout = "); |
| 4240 | q.text("%#x" % self.hard_timeout) |
| 4241 | q.text(","); q.breakable() |
| 4242 | q.text("priority = "); |
| 4243 | q.text("%#x" % self.priority) |
| 4244 | q.text(","); q.breakable() |
| 4245 | q.text("buffer_id = "); |
| 4246 | q.text("%#x" % self.buffer_id) |
| 4247 | q.text(","); q.breakable() |
| 4248 | q.text("out_port = "); |
| 4249 | q.text(util.pretty_port(self.out_port)) |
| 4250 | q.text(","); q.breakable() |
| 4251 | q.text("out_group = "); |
| 4252 | q.text("%#x" % self.out_group) |
| 4253 | q.text(","); q.breakable() |
| 4254 | q.text("flags = "); |
| 4255 | q.text("%#x" % self.flags) |
| 4256 | q.text(","); q.breakable() |
| 4257 | q.text("match = "); |
| 4258 | q.pp(self.match) |
| 4259 | q.text(","); q.breakable() |
| 4260 | q.text("instructions = "); |
| 4261 | q.pp(self.instructions) |
| 4262 | q.breakable() |
| 4263 | q.text('}') |
| 4264 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4265 | flow_mod.subtypes[3] = flow_delete |
| 4266 | |
| 4267 | class flow_delete_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4268 | version = 2 |
| 4269 | type = 14 |
| 4270 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4271 | |
| 4272 | 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] | 4273 | if xid != None: |
| 4274 | self.xid = xid |
| 4275 | else: |
| 4276 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4277 | if cookie != None: |
| 4278 | self.cookie = cookie |
| 4279 | else: |
| 4280 | self.cookie = 0 |
| 4281 | if cookie_mask != None: |
| 4282 | self.cookie_mask = cookie_mask |
| 4283 | else: |
| 4284 | self.cookie_mask = 0 |
| 4285 | if table_id != None: |
| 4286 | self.table_id = table_id |
| 4287 | else: |
| 4288 | self.table_id = 0 |
| 4289 | if idle_timeout != None: |
| 4290 | self.idle_timeout = idle_timeout |
| 4291 | else: |
| 4292 | self.idle_timeout = 0 |
| 4293 | if hard_timeout != None: |
| 4294 | self.hard_timeout = hard_timeout |
| 4295 | else: |
| 4296 | self.hard_timeout = 0 |
| 4297 | if priority != None: |
| 4298 | self.priority = priority |
| 4299 | else: |
| 4300 | self.priority = 0 |
| 4301 | if buffer_id != None: |
| 4302 | self.buffer_id = buffer_id |
| 4303 | else: |
| 4304 | self.buffer_id = 0 |
| 4305 | if out_port != None: |
| 4306 | self.out_port = out_port |
| 4307 | else: |
| 4308 | self.out_port = 0 |
| 4309 | if out_group != None: |
| 4310 | self.out_group = out_group |
| 4311 | else: |
| 4312 | self.out_group = 0 |
| 4313 | if flags != None: |
| 4314 | self.flags = flags |
| 4315 | else: |
| 4316 | self.flags = 0 |
| 4317 | if match != None: |
| 4318 | self.match = match |
| 4319 | else: |
| 4320 | self.match = common.match() |
| 4321 | if instructions != None: |
| 4322 | self.instructions = instructions |
| 4323 | else: |
| 4324 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4325 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4326 | |
| 4327 | def pack(self): |
| 4328 | packed = [] |
| 4329 | packed.append(struct.pack("!B", self.version)) |
| 4330 | packed.append(struct.pack("!B", self.type)) |
| 4331 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4332 | packed.append(struct.pack("!L", self.xid)) |
| 4333 | packed.append(struct.pack("!Q", self.cookie)) |
| 4334 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4335 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4336 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4337 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4338 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4339 | packed.append(struct.pack("!H", self.priority)) |
| 4340 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4341 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4342 | packed.append(struct.pack("!L", self.out_group)) |
| 4343 | packed.append(struct.pack("!H", self.flags)) |
| 4344 | packed.append('\x00' * 2) |
| 4345 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4346 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4347 | length = sum([len(x) for x in packed]) |
| 4348 | packed[2] = struct.pack("!H", length) |
| 4349 | return ''.join(packed) |
| 4350 | |
| 4351 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4352 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4353 | obj = flow_delete_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4354 | _version = reader.read("!B")[0] |
| 4355 | assert(_version == 2) |
| 4356 | _type = reader.read("!B")[0] |
| 4357 | assert(_type == 14) |
| 4358 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4359 | orig_reader = reader |
| 4360 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4361 | obj.xid = reader.read("!L")[0] |
| 4362 | obj.cookie = reader.read("!Q")[0] |
| 4363 | obj.cookie_mask = reader.read("!Q")[0] |
| 4364 | obj.table_id = reader.read("!B")[0] |
| 4365 | __command = util.unpack_fm_cmd(reader) |
| 4366 | assert(__command == 4) |
| 4367 | obj.idle_timeout = reader.read("!H")[0] |
| 4368 | obj.hard_timeout = reader.read("!H")[0] |
| 4369 | obj.priority = reader.read("!H")[0] |
| 4370 | obj.buffer_id = reader.read("!L")[0] |
| 4371 | obj.out_port = util.unpack_port_no(reader) |
| 4372 | obj.out_group = reader.read("!L")[0] |
| 4373 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4374 | reader.skip(2) |
| 4375 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4376 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4377 | return obj |
| 4378 | |
| 4379 | def __eq__(self, other): |
| 4380 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4381 | if self.xid != other.xid: return False |
| 4382 | if self.cookie != other.cookie: return False |
| 4383 | if self.cookie_mask != other.cookie_mask: return False |
| 4384 | if self.table_id != other.table_id: return False |
| 4385 | if self.idle_timeout != other.idle_timeout: return False |
| 4386 | if self.hard_timeout != other.hard_timeout: return False |
| 4387 | if self.priority != other.priority: return False |
| 4388 | if self.buffer_id != other.buffer_id: return False |
| 4389 | if self.out_port != other.out_port: return False |
| 4390 | if self.out_group != other.out_group: return False |
| 4391 | if self.flags != other.flags: return False |
| 4392 | if self.match != other.match: return False |
| 4393 | if self.instructions != other.instructions: return False |
| 4394 | return True |
| 4395 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4396 | def pretty_print(self, q): |
| 4397 | q.text("flow_delete_strict {") |
| 4398 | with q.group(): |
| 4399 | with q.indent(2): |
| 4400 | q.breakable() |
| 4401 | q.text("xid = "); |
| 4402 | if self.xid != None: |
| 4403 | q.text("%#x" % self.xid) |
| 4404 | else: |
| 4405 | q.text('None') |
| 4406 | q.text(","); q.breakable() |
| 4407 | q.text("cookie = "); |
| 4408 | q.text("%#x" % self.cookie) |
| 4409 | q.text(","); q.breakable() |
| 4410 | q.text("cookie_mask = "); |
| 4411 | q.text("%#x" % self.cookie_mask) |
| 4412 | q.text(","); q.breakable() |
| 4413 | q.text("table_id = "); |
| 4414 | q.text("%#x" % self.table_id) |
| 4415 | q.text(","); q.breakable() |
| 4416 | q.text("idle_timeout = "); |
| 4417 | q.text("%#x" % self.idle_timeout) |
| 4418 | q.text(","); q.breakable() |
| 4419 | q.text("hard_timeout = "); |
| 4420 | q.text("%#x" % self.hard_timeout) |
| 4421 | q.text(","); q.breakable() |
| 4422 | q.text("priority = "); |
| 4423 | q.text("%#x" % self.priority) |
| 4424 | q.text(","); q.breakable() |
| 4425 | q.text("buffer_id = "); |
| 4426 | q.text("%#x" % self.buffer_id) |
| 4427 | q.text(","); q.breakable() |
| 4428 | q.text("out_port = "); |
| 4429 | q.text(util.pretty_port(self.out_port)) |
| 4430 | q.text(","); q.breakable() |
| 4431 | q.text("out_group = "); |
| 4432 | q.text("%#x" % self.out_group) |
| 4433 | q.text(","); q.breakable() |
| 4434 | q.text("flags = "); |
| 4435 | q.text("%#x" % self.flags) |
| 4436 | q.text(","); q.breakable() |
| 4437 | q.text("match = "); |
| 4438 | q.pp(self.match) |
| 4439 | q.text(","); q.breakable() |
| 4440 | q.text("instructions = "); |
| 4441 | q.pp(self.instructions) |
| 4442 | q.breakable() |
| 4443 | q.text('}') |
| 4444 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4445 | flow_mod.subtypes[4] = flow_delete_strict |
| 4446 | |
| 4447 | class flow_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4448 | version = 2 |
| 4449 | type = 1 |
| 4450 | err_type = 5 |
| 4451 | |
| 4452 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4453 | if xid != None: |
| 4454 | self.xid = xid |
| 4455 | else: |
| 4456 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4457 | if code != None: |
| 4458 | self.code = code |
| 4459 | else: |
| 4460 | self.code = 0 |
| 4461 | if data != None: |
| 4462 | self.data = data |
| 4463 | else: |
| 4464 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4465 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4466 | |
| 4467 | def pack(self): |
| 4468 | packed = [] |
| 4469 | packed.append(struct.pack("!B", self.version)) |
| 4470 | packed.append(struct.pack("!B", self.type)) |
| 4471 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4472 | packed.append(struct.pack("!L", self.xid)) |
| 4473 | packed.append(struct.pack("!H", self.err_type)) |
| 4474 | packed.append(struct.pack("!H", self.code)) |
| 4475 | packed.append(self.data) |
| 4476 | length = sum([len(x) for x in packed]) |
| 4477 | packed[2] = struct.pack("!H", length) |
| 4478 | return ''.join(packed) |
| 4479 | |
| 4480 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4481 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4482 | obj = flow_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4483 | _version = reader.read("!B")[0] |
| 4484 | assert(_version == 2) |
| 4485 | _type = reader.read("!B")[0] |
| 4486 | assert(_type == 1) |
| 4487 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4488 | orig_reader = reader |
| 4489 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4490 | obj.xid = reader.read("!L")[0] |
| 4491 | _err_type = reader.read("!H")[0] |
| 4492 | assert(_err_type == 5) |
| 4493 | obj.code = reader.read("!H")[0] |
| 4494 | obj.data = str(reader.read_all()) |
| 4495 | return obj |
| 4496 | |
| 4497 | def __eq__(self, other): |
| 4498 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4499 | if self.xid != other.xid: return False |
| 4500 | if self.code != other.code: return False |
| 4501 | if self.data != other.data: return False |
| 4502 | return True |
| 4503 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4504 | def pretty_print(self, q): |
| 4505 | q.text("flow_mod_failed_error_msg {") |
| 4506 | with q.group(): |
| 4507 | with q.indent(2): |
| 4508 | q.breakable() |
| 4509 | q.text("xid = "); |
| 4510 | if self.xid != None: |
| 4511 | q.text("%#x" % self.xid) |
| 4512 | else: |
| 4513 | q.text('None') |
| 4514 | q.text(","); q.breakable() |
| 4515 | q.text("code = "); |
| 4516 | q.text("%#x" % self.code) |
| 4517 | q.text(","); q.breakable() |
| 4518 | q.text("data = "); |
| 4519 | q.pp(self.data) |
| 4520 | q.breakable() |
| 4521 | q.text('}') |
| 4522 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4523 | error_msg.subtypes[5] = flow_mod_failed_error_msg |
| 4524 | |
| 4525 | class flow_modify(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4526 | version = 2 |
| 4527 | type = 14 |
| 4528 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4529 | |
| 4530 | 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] | 4531 | if xid != None: |
| 4532 | self.xid = xid |
| 4533 | else: |
| 4534 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4535 | if cookie != None: |
| 4536 | self.cookie = cookie |
| 4537 | else: |
| 4538 | self.cookie = 0 |
| 4539 | if cookie_mask != None: |
| 4540 | self.cookie_mask = cookie_mask |
| 4541 | else: |
| 4542 | self.cookie_mask = 0 |
| 4543 | if table_id != None: |
| 4544 | self.table_id = table_id |
| 4545 | else: |
| 4546 | self.table_id = 0 |
| 4547 | if idle_timeout != None: |
| 4548 | self.idle_timeout = idle_timeout |
| 4549 | else: |
| 4550 | self.idle_timeout = 0 |
| 4551 | if hard_timeout != None: |
| 4552 | self.hard_timeout = hard_timeout |
| 4553 | else: |
| 4554 | self.hard_timeout = 0 |
| 4555 | if priority != None: |
| 4556 | self.priority = priority |
| 4557 | else: |
| 4558 | self.priority = 0 |
| 4559 | if buffer_id != None: |
| 4560 | self.buffer_id = buffer_id |
| 4561 | else: |
| 4562 | self.buffer_id = 0 |
| 4563 | if out_port != None: |
| 4564 | self.out_port = out_port |
| 4565 | else: |
| 4566 | self.out_port = 0 |
| 4567 | if out_group != None: |
| 4568 | self.out_group = out_group |
| 4569 | else: |
| 4570 | self.out_group = 0 |
| 4571 | if flags != None: |
| 4572 | self.flags = flags |
| 4573 | else: |
| 4574 | self.flags = 0 |
| 4575 | if match != None: |
| 4576 | self.match = match |
| 4577 | else: |
| 4578 | self.match = common.match() |
| 4579 | if instructions != None: |
| 4580 | self.instructions = instructions |
| 4581 | else: |
| 4582 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4583 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4584 | |
| 4585 | def pack(self): |
| 4586 | packed = [] |
| 4587 | packed.append(struct.pack("!B", self.version)) |
| 4588 | packed.append(struct.pack("!B", self.type)) |
| 4589 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4590 | packed.append(struct.pack("!L", self.xid)) |
| 4591 | packed.append(struct.pack("!Q", self.cookie)) |
| 4592 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4593 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4594 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4595 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4596 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4597 | packed.append(struct.pack("!H", self.priority)) |
| 4598 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4599 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4600 | packed.append(struct.pack("!L", self.out_group)) |
| 4601 | packed.append(struct.pack("!H", self.flags)) |
| 4602 | packed.append('\x00' * 2) |
| 4603 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4604 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4605 | length = sum([len(x) for x in packed]) |
| 4606 | packed[2] = struct.pack("!H", length) |
| 4607 | return ''.join(packed) |
| 4608 | |
| 4609 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4610 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4611 | obj = flow_modify() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4612 | _version = reader.read("!B")[0] |
| 4613 | assert(_version == 2) |
| 4614 | _type = reader.read("!B")[0] |
| 4615 | assert(_type == 14) |
| 4616 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4617 | orig_reader = reader |
| 4618 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4619 | obj.xid = reader.read("!L")[0] |
| 4620 | obj.cookie = reader.read("!Q")[0] |
| 4621 | obj.cookie_mask = reader.read("!Q")[0] |
| 4622 | obj.table_id = reader.read("!B")[0] |
| 4623 | __command = util.unpack_fm_cmd(reader) |
| 4624 | assert(__command == 1) |
| 4625 | obj.idle_timeout = reader.read("!H")[0] |
| 4626 | obj.hard_timeout = reader.read("!H")[0] |
| 4627 | obj.priority = reader.read("!H")[0] |
| 4628 | obj.buffer_id = reader.read("!L")[0] |
| 4629 | obj.out_port = util.unpack_port_no(reader) |
| 4630 | obj.out_group = reader.read("!L")[0] |
| 4631 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4632 | reader.skip(2) |
| 4633 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4634 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4635 | return obj |
| 4636 | |
| 4637 | def __eq__(self, other): |
| 4638 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4639 | if self.xid != other.xid: return False |
| 4640 | if self.cookie != other.cookie: return False |
| 4641 | if self.cookie_mask != other.cookie_mask: return False |
| 4642 | if self.table_id != other.table_id: return False |
| 4643 | if self.idle_timeout != other.idle_timeout: return False |
| 4644 | if self.hard_timeout != other.hard_timeout: return False |
| 4645 | if self.priority != other.priority: return False |
| 4646 | if self.buffer_id != other.buffer_id: return False |
| 4647 | if self.out_port != other.out_port: return False |
| 4648 | if self.out_group != other.out_group: return False |
| 4649 | if self.flags != other.flags: return False |
| 4650 | if self.match != other.match: return False |
| 4651 | if self.instructions != other.instructions: return False |
| 4652 | return True |
| 4653 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4654 | def pretty_print(self, q): |
| 4655 | q.text("flow_modify {") |
| 4656 | with q.group(): |
| 4657 | with q.indent(2): |
| 4658 | q.breakable() |
| 4659 | q.text("xid = "); |
| 4660 | if self.xid != None: |
| 4661 | q.text("%#x" % self.xid) |
| 4662 | else: |
| 4663 | q.text('None') |
| 4664 | q.text(","); q.breakable() |
| 4665 | q.text("cookie = "); |
| 4666 | q.text("%#x" % self.cookie) |
| 4667 | q.text(","); q.breakable() |
| 4668 | q.text("cookie_mask = "); |
| 4669 | q.text("%#x" % self.cookie_mask) |
| 4670 | q.text(","); q.breakable() |
| 4671 | q.text("table_id = "); |
| 4672 | q.text("%#x" % self.table_id) |
| 4673 | q.text(","); q.breakable() |
| 4674 | q.text("idle_timeout = "); |
| 4675 | q.text("%#x" % self.idle_timeout) |
| 4676 | q.text(","); q.breakable() |
| 4677 | q.text("hard_timeout = "); |
| 4678 | q.text("%#x" % self.hard_timeout) |
| 4679 | q.text(","); q.breakable() |
| 4680 | q.text("priority = "); |
| 4681 | q.text("%#x" % self.priority) |
| 4682 | q.text(","); q.breakable() |
| 4683 | q.text("buffer_id = "); |
| 4684 | q.text("%#x" % self.buffer_id) |
| 4685 | q.text(","); q.breakable() |
| 4686 | q.text("out_port = "); |
| 4687 | q.text(util.pretty_port(self.out_port)) |
| 4688 | q.text(","); q.breakable() |
| 4689 | q.text("out_group = "); |
| 4690 | q.text("%#x" % self.out_group) |
| 4691 | q.text(","); q.breakable() |
| 4692 | q.text("flags = "); |
| 4693 | q.text("%#x" % self.flags) |
| 4694 | q.text(","); q.breakable() |
| 4695 | q.text("match = "); |
| 4696 | q.pp(self.match) |
| 4697 | q.text(","); q.breakable() |
| 4698 | q.text("instructions = "); |
| 4699 | q.pp(self.instructions) |
| 4700 | q.breakable() |
| 4701 | q.text('}') |
| 4702 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4703 | flow_mod.subtypes[1] = flow_modify |
| 4704 | |
| 4705 | class flow_modify_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4706 | version = 2 |
| 4707 | type = 14 |
| 4708 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4709 | |
| 4710 | 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] | 4711 | if xid != None: |
| 4712 | self.xid = xid |
| 4713 | else: |
| 4714 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4715 | if cookie != None: |
| 4716 | self.cookie = cookie |
| 4717 | else: |
| 4718 | self.cookie = 0 |
| 4719 | if cookie_mask != None: |
| 4720 | self.cookie_mask = cookie_mask |
| 4721 | else: |
| 4722 | self.cookie_mask = 0 |
| 4723 | if table_id != None: |
| 4724 | self.table_id = table_id |
| 4725 | else: |
| 4726 | self.table_id = 0 |
| 4727 | if idle_timeout != None: |
| 4728 | self.idle_timeout = idle_timeout |
| 4729 | else: |
| 4730 | self.idle_timeout = 0 |
| 4731 | if hard_timeout != None: |
| 4732 | self.hard_timeout = hard_timeout |
| 4733 | else: |
| 4734 | self.hard_timeout = 0 |
| 4735 | if priority != None: |
| 4736 | self.priority = priority |
| 4737 | else: |
| 4738 | self.priority = 0 |
| 4739 | if buffer_id != None: |
| 4740 | self.buffer_id = buffer_id |
| 4741 | else: |
| 4742 | self.buffer_id = 0 |
| 4743 | if out_port != None: |
| 4744 | self.out_port = out_port |
| 4745 | else: |
| 4746 | self.out_port = 0 |
| 4747 | if out_group != None: |
| 4748 | self.out_group = out_group |
| 4749 | else: |
| 4750 | self.out_group = 0 |
| 4751 | if flags != None: |
| 4752 | self.flags = flags |
| 4753 | else: |
| 4754 | self.flags = 0 |
| 4755 | if match != None: |
| 4756 | self.match = match |
| 4757 | else: |
| 4758 | self.match = common.match() |
| 4759 | if instructions != None: |
| 4760 | self.instructions = instructions |
| 4761 | else: |
| 4762 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4763 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4764 | |
| 4765 | def pack(self): |
| 4766 | packed = [] |
| 4767 | packed.append(struct.pack("!B", self.version)) |
| 4768 | packed.append(struct.pack("!B", self.type)) |
| 4769 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4770 | packed.append(struct.pack("!L", self.xid)) |
| 4771 | packed.append(struct.pack("!Q", self.cookie)) |
| 4772 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4773 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4774 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4775 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4776 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4777 | packed.append(struct.pack("!H", self.priority)) |
| 4778 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4779 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4780 | packed.append(struct.pack("!L", self.out_group)) |
| 4781 | packed.append(struct.pack("!H", self.flags)) |
| 4782 | packed.append('\x00' * 2) |
| 4783 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4784 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4785 | length = sum([len(x) for x in packed]) |
| 4786 | packed[2] = struct.pack("!H", length) |
| 4787 | return ''.join(packed) |
| 4788 | |
| 4789 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4790 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4791 | obj = flow_modify_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4792 | _version = reader.read("!B")[0] |
| 4793 | assert(_version == 2) |
| 4794 | _type = reader.read("!B")[0] |
| 4795 | assert(_type == 14) |
| 4796 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4797 | orig_reader = reader |
| 4798 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4799 | obj.xid = reader.read("!L")[0] |
| 4800 | obj.cookie = reader.read("!Q")[0] |
| 4801 | obj.cookie_mask = reader.read("!Q")[0] |
| 4802 | obj.table_id = reader.read("!B")[0] |
| 4803 | __command = util.unpack_fm_cmd(reader) |
| 4804 | assert(__command == 2) |
| 4805 | obj.idle_timeout = reader.read("!H")[0] |
| 4806 | obj.hard_timeout = reader.read("!H")[0] |
| 4807 | obj.priority = reader.read("!H")[0] |
| 4808 | obj.buffer_id = reader.read("!L")[0] |
| 4809 | obj.out_port = util.unpack_port_no(reader) |
| 4810 | obj.out_group = reader.read("!L")[0] |
| 4811 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4812 | reader.skip(2) |
| 4813 | obj.match = common.match.unpack(reader) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4814 | obj.instructions = loxi.generic_util.unpack_list(reader, instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4815 | return obj |
| 4816 | |
| 4817 | def __eq__(self, other): |
| 4818 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4819 | if self.xid != other.xid: return False |
| 4820 | if self.cookie != other.cookie: return False |
| 4821 | if self.cookie_mask != other.cookie_mask: return False |
| 4822 | if self.table_id != other.table_id: return False |
| 4823 | if self.idle_timeout != other.idle_timeout: return False |
| 4824 | if self.hard_timeout != other.hard_timeout: return False |
| 4825 | if self.priority != other.priority: return False |
| 4826 | if self.buffer_id != other.buffer_id: return False |
| 4827 | if self.out_port != other.out_port: return False |
| 4828 | if self.out_group != other.out_group: return False |
| 4829 | if self.flags != other.flags: return False |
| 4830 | if self.match != other.match: return False |
| 4831 | if self.instructions != other.instructions: return False |
| 4832 | return True |
| 4833 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4834 | def pretty_print(self, q): |
| 4835 | q.text("flow_modify_strict {") |
| 4836 | with q.group(): |
| 4837 | with q.indent(2): |
| 4838 | q.breakable() |
| 4839 | q.text("xid = "); |
| 4840 | if self.xid != None: |
| 4841 | q.text("%#x" % self.xid) |
| 4842 | else: |
| 4843 | q.text('None') |
| 4844 | q.text(","); q.breakable() |
| 4845 | q.text("cookie = "); |
| 4846 | q.text("%#x" % self.cookie) |
| 4847 | q.text(","); q.breakable() |
| 4848 | q.text("cookie_mask = "); |
| 4849 | q.text("%#x" % self.cookie_mask) |
| 4850 | q.text(","); q.breakable() |
| 4851 | q.text("table_id = "); |
| 4852 | q.text("%#x" % self.table_id) |
| 4853 | q.text(","); q.breakable() |
| 4854 | q.text("idle_timeout = "); |
| 4855 | q.text("%#x" % self.idle_timeout) |
| 4856 | q.text(","); q.breakable() |
| 4857 | q.text("hard_timeout = "); |
| 4858 | q.text("%#x" % self.hard_timeout) |
| 4859 | q.text(","); q.breakable() |
| 4860 | q.text("priority = "); |
| 4861 | q.text("%#x" % self.priority) |
| 4862 | q.text(","); q.breakable() |
| 4863 | q.text("buffer_id = "); |
| 4864 | q.text("%#x" % self.buffer_id) |
| 4865 | q.text(","); q.breakable() |
| 4866 | q.text("out_port = "); |
| 4867 | q.text(util.pretty_port(self.out_port)) |
| 4868 | q.text(","); q.breakable() |
| 4869 | q.text("out_group = "); |
| 4870 | q.text("%#x" % self.out_group) |
| 4871 | q.text(","); q.breakable() |
| 4872 | q.text("flags = "); |
| 4873 | q.text("%#x" % self.flags) |
| 4874 | q.text(","); q.breakable() |
| 4875 | q.text("match = "); |
| 4876 | q.pp(self.match) |
| 4877 | q.text(","); q.breakable() |
| 4878 | q.text("instructions = "); |
| 4879 | q.pp(self.instructions) |
| 4880 | q.breakable() |
| 4881 | q.text('}') |
| 4882 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4883 | flow_mod.subtypes[2] = flow_modify_strict |
| 4884 | |
| 4885 | class flow_removed(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4886 | version = 2 |
| 4887 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4888 | |
| 4889 | 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] | 4890 | if xid != None: |
| 4891 | self.xid = xid |
| 4892 | else: |
| 4893 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4894 | if cookie != None: |
| 4895 | self.cookie = cookie |
| 4896 | else: |
| 4897 | self.cookie = 0 |
| 4898 | if priority != None: |
| 4899 | self.priority = priority |
| 4900 | else: |
| 4901 | self.priority = 0 |
| 4902 | if reason != None: |
| 4903 | self.reason = reason |
| 4904 | else: |
| 4905 | self.reason = 0 |
| 4906 | if table_id != None: |
| 4907 | self.table_id = table_id |
| 4908 | else: |
| 4909 | self.table_id = 0 |
| 4910 | if duration_sec != None: |
| 4911 | self.duration_sec = duration_sec |
| 4912 | else: |
| 4913 | self.duration_sec = 0 |
| 4914 | if duration_nsec != None: |
| 4915 | self.duration_nsec = duration_nsec |
| 4916 | else: |
| 4917 | self.duration_nsec = 0 |
| 4918 | if idle_timeout != None: |
| 4919 | self.idle_timeout = idle_timeout |
| 4920 | else: |
| 4921 | self.idle_timeout = 0 |
| 4922 | if packet_count != None: |
| 4923 | self.packet_count = packet_count |
| 4924 | else: |
| 4925 | self.packet_count = 0 |
| 4926 | if byte_count != None: |
| 4927 | self.byte_count = byte_count |
| 4928 | else: |
| 4929 | self.byte_count = 0 |
| 4930 | if match != None: |
| 4931 | self.match = match |
| 4932 | else: |
| 4933 | self.match = common.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4934 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4935 | |
| 4936 | def pack(self): |
| 4937 | packed = [] |
| 4938 | packed.append(struct.pack("!B", self.version)) |
| 4939 | packed.append(struct.pack("!B", self.type)) |
| 4940 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4941 | packed.append(struct.pack("!L", self.xid)) |
| 4942 | packed.append(struct.pack("!Q", self.cookie)) |
| 4943 | packed.append(struct.pack("!H", self.priority)) |
| 4944 | packed.append(struct.pack("!B", self.reason)) |
| 4945 | packed.append(struct.pack("!B", self.table_id)) |
| 4946 | packed.append(struct.pack("!L", self.duration_sec)) |
| 4947 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 4948 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4949 | packed.append('\x00' * 2) |
| 4950 | packed.append(struct.pack("!Q", self.packet_count)) |
| 4951 | packed.append(struct.pack("!Q", self.byte_count)) |
| 4952 | packed.append(self.match.pack()) |
| 4953 | length = sum([len(x) for x in packed]) |
| 4954 | packed[2] = struct.pack("!H", length) |
| 4955 | return ''.join(packed) |
| 4956 | |
| 4957 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4958 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4959 | obj = flow_removed() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4960 | _version = reader.read("!B")[0] |
| 4961 | assert(_version == 2) |
| 4962 | _type = reader.read("!B")[0] |
| 4963 | assert(_type == 11) |
| 4964 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4965 | orig_reader = reader |
| 4966 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4967 | obj.xid = reader.read("!L")[0] |
| 4968 | obj.cookie = reader.read("!Q")[0] |
| 4969 | obj.priority = reader.read("!H")[0] |
| 4970 | obj.reason = reader.read("!B")[0] |
| 4971 | obj.table_id = reader.read("!B")[0] |
| 4972 | obj.duration_sec = reader.read("!L")[0] |
| 4973 | obj.duration_nsec = reader.read("!L")[0] |
| 4974 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4975 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4976 | obj.packet_count = reader.read("!Q")[0] |
| 4977 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4978 | obj.match = common.match.unpack(reader) |
| 4979 | return obj |
| 4980 | |
| 4981 | def __eq__(self, other): |
| 4982 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4983 | if self.xid != other.xid: return False |
| 4984 | if self.cookie != other.cookie: return False |
| 4985 | if self.priority != other.priority: return False |
| 4986 | if self.reason != other.reason: return False |
| 4987 | if self.table_id != other.table_id: return False |
| 4988 | if self.duration_sec != other.duration_sec: return False |
| 4989 | if self.duration_nsec != other.duration_nsec: return False |
| 4990 | if self.idle_timeout != other.idle_timeout: return False |
| 4991 | if self.packet_count != other.packet_count: return False |
| 4992 | if self.byte_count != other.byte_count: return False |
| 4993 | if self.match != other.match: return False |
| 4994 | return True |
| 4995 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4996 | def pretty_print(self, q): |
| 4997 | q.text("flow_removed {") |
| 4998 | with q.group(): |
| 4999 | with q.indent(2): |
| 5000 | q.breakable() |
| 5001 | q.text("xid = "); |
| 5002 | if self.xid != None: |
| 5003 | q.text("%#x" % self.xid) |
| 5004 | else: |
| 5005 | q.text('None') |
| 5006 | q.text(","); q.breakable() |
| 5007 | q.text("cookie = "); |
| 5008 | q.text("%#x" % self.cookie) |
| 5009 | q.text(","); q.breakable() |
| 5010 | q.text("priority = "); |
| 5011 | q.text("%#x" % self.priority) |
| 5012 | q.text(","); q.breakable() |
| 5013 | q.text("reason = "); |
| 5014 | q.text("%#x" % self.reason) |
| 5015 | q.text(","); q.breakable() |
| 5016 | q.text("table_id = "); |
| 5017 | q.text("%#x" % self.table_id) |
| 5018 | q.text(","); q.breakable() |
| 5019 | q.text("duration_sec = "); |
| 5020 | q.text("%#x" % self.duration_sec) |
| 5021 | q.text(","); q.breakable() |
| 5022 | q.text("duration_nsec = "); |
| 5023 | q.text("%#x" % self.duration_nsec) |
| 5024 | q.text(","); q.breakable() |
| 5025 | q.text("idle_timeout = "); |
| 5026 | q.text("%#x" % self.idle_timeout) |
| 5027 | q.text(","); q.breakable() |
| 5028 | q.text("packet_count = "); |
| 5029 | q.text("%#x" % self.packet_count) |
| 5030 | q.text(","); q.breakable() |
| 5031 | q.text("byte_count = "); |
| 5032 | q.text("%#x" % self.byte_count) |
| 5033 | q.text(","); q.breakable() |
| 5034 | q.text("match = "); |
| 5035 | q.pp(self.match) |
| 5036 | q.breakable() |
| 5037 | q.text('}') |
| 5038 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5039 | message.subtypes[11] = flow_removed |
| 5040 | |
| 5041 | class flow_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5042 | version = 2 |
| 5043 | type = 19 |
| 5044 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5045 | |
| 5046 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5047 | if xid != None: |
| 5048 | self.xid = xid |
| 5049 | else: |
| 5050 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5051 | if flags != None: |
| 5052 | self.flags = flags |
| 5053 | else: |
| 5054 | self.flags = 0 |
| 5055 | if entries != None: |
| 5056 | self.entries = entries |
| 5057 | else: |
| 5058 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5059 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5060 | |
| 5061 | def pack(self): |
| 5062 | packed = [] |
| 5063 | packed.append(struct.pack("!B", self.version)) |
| 5064 | packed.append(struct.pack("!B", self.type)) |
| 5065 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5066 | packed.append(struct.pack("!L", self.xid)) |
| 5067 | packed.append(struct.pack("!H", self.stats_type)) |
| 5068 | packed.append(struct.pack("!H", self.flags)) |
| 5069 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5070 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5071 | length = sum([len(x) for x in packed]) |
| 5072 | packed[2] = struct.pack("!H", length) |
| 5073 | return ''.join(packed) |
| 5074 | |
| 5075 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5076 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5077 | obj = flow_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5078 | _version = reader.read("!B")[0] |
| 5079 | assert(_version == 2) |
| 5080 | _type = reader.read("!B")[0] |
| 5081 | assert(_type == 19) |
| 5082 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5083 | orig_reader = reader |
| 5084 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5085 | obj.xid = reader.read("!L")[0] |
| 5086 | _stats_type = reader.read("!H")[0] |
| 5087 | assert(_stats_type == 1) |
| 5088 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5089 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5090 | 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] | 5091 | return obj |
| 5092 | |
| 5093 | def __eq__(self, other): |
| 5094 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5095 | if self.xid != other.xid: return False |
| 5096 | if self.flags != other.flags: return False |
| 5097 | if self.entries != other.entries: return False |
| 5098 | return True |
| 5099 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5100 | def pretty_print(self, q): |
| 5101 | q.text("flow_stats_reply {") |
| 5102 | with q.group(): |
| 5103 | with q.indent(2): |
| 5104 | q.breakable() |
| 5105 | q.text("xid = "); |
| 5106 | if self.xid != None: |
| 5107 | q.text("%#x" % self.xid) |
| 5108 | else: |
| 5109 | q.text('None') |
| 5110 | q.text(","); q.breakable() |
| 5111 | q.text("flags = "); |
| 5112 | q.text("%#x" % self.flags) |
| 5113 | q.text(","); q.breakable() |
| 5114 | q.text("entries = "); |
| 5115 | q.pp(self.entries) |
| 5116 | q.breakable() |
| 5117 | q.text('}') |
| 5118 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5119 | stats_reply.subtypes[1] = flow_stats_reply |
| 5120 | |
| 5121 | class flow_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5122 | version = 2 |
| 5123 | type = 18 |
| 5124 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5125 | |
| 5126 | 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] | 5127 | if xid != None: |
| 5128 | self.xid = xid |
| 5129 | else: |
| 5130 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5131 | if flags != None: |
| 5132 | self.flags = flags |
| 5133 | else: |
| 5134 | self.flags = 0 |
| 5135 | if table_id != None: |
| 5136 | self.table_id = table_id |
| 5137 | else: |
| 5138 | self.table_id = 0 |
| 5139 | if out_port != None: |
| 5140 | self.out_port = out_port |
| 5141 | else: |
| 5142 | self.out_port = 0 |
| 5143 | if out_group != None: |
| 5144 | self.out_group = out_group |
| 5145 | else: |
| 5146 | self.out_group = 0 |
| 5147 | if cookie != None: |
| 5148 | self.cookie = cookie |
| 5149 | else: |
| 5150 | self.cookie = 0 |
| 5151 | if cookie_mask != None: |
| 5152 | self.cookie_mask = cookie_mask |
| 5153 | else: |
| 5154 | self.cookie_mask = 0 |
| 5155 | if match != None: |
| 5156 | self.match = match |
| 5157 | else: |
| 5158 | self.match = common.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5159 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5160 | |
| 5161 | def pack(self): |
| 5162 | packed = [] |
| 5163 | packed.append(struct.pack("!B", self.version)) |
| 5164 | packed.append(struct.pack("!B", self.type)) |
| 5165 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5166 | packed.append(struct.pack("!L", self.xid)) |
| 5167 | packed.append(struct.pack("!H", self.stats_type)) |
| 5168 | packed.append(struct.pack("!H", self.flags)) |
| 5169 | packed.append('\x00' * 4) |
| 5170 | packed.append(struct.pack("!B", self.table_id)) |
| 5171 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5172 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5173 | packed.append(struct.pack("!L", self.out_group)) |
| 5174 | packed.append('\x00' * 4) |
| 5175 | packed.append(struct.pack("!Q", self.cookie)) |
| 5176 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5177 | packed.append(self.match.pack()) |
| 5178 | length = sum([len(x) for x in packed]) |
| 5179 | packed[2] = struct.pack("!H", length) |
| 5180 | return ''.join(packed) |
| 5181 | |
| 5182 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5183 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5184 | obj = flow_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5185 | _version = reader.read("!B")[0] |
| 5186 | assert(_version == 2) |
| 5187 | _type = reader.read("!B")[0] |
| 5188 | assert(_type == 18) |
| 5189 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5190 | orig_reader = reader |
| 5191 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5192 | obj.xid = reader.read("!L")[0] |
| 5193 | _stats_type = reader.read("!H")[0] |
| 5194 | assert(_stats_type == 1) |
| 5195 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5196 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5197 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5198 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5199 | obj.out_port = util.unpack_port_no(reader) |
| 5200 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5201 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5202 | obj.cookie = reader.read("!Q")[0] |
| 5203 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5204 | obj.match = common.match.unpack(reader) |
| 5205 | return obj |
| 5206 | |
| 5207 | def __eq__(self, other): |
| 5208 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5209 | if self.xid != other.xid: return False |
| 5210 | if self.flags != other.flags: return False |
| 5211 | if self.table_id != other.table_id: return False |
| 5212 | if self.out_port != other.out_port: return False |
| 5213 | if self.out_group != other.out_group: return False |
| 5214 | if self.cookie != other.cookie: return False |
| 5215 | if self.cookie_mask != other.cookie_mask: return False |
| 5216 | if self.match != other.match: return False |
| 5217 | return True |
| 5218 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5219 | def pretty_print(self, q): |
| 5220 | q.text("flow_stats_request {") |
| 5221 | with q.group(): |
| 5222 | with q.indent(2): |
| 5223 | q.breakable() |
| 5224 | q.text("xid = "); |
| 5225 | if self.xid != None: |
| 5226 | q.text("%#x" % self.xid) |
| 5227 | else: |
| 5228 | q.text('None') |
| 5229 | q.text(","); q.breakable() |
| 5230 | q.text("flags = "); |
| 5231 | q.text("%#x" % self.flags) |
| 5232 | q.text(","); q.breakable() |
| 5233 | q.text("table_id = "); |
| 5234 | q.text("%#x" % self.table_id) |
| 5235 | q.text(","); q.breakable() |
| 5236 | q.text("out_port = "); |
| 5237 | q.text(util.pretty_port(self.out_port)) |
| 5238 | q.text(","); q.breakable() |
| 5239 | q.text("out_group = "); |
| 5240 | q.text("%#x" % self.out_group) |
| 5241 | q.text(","); q.breakable() |
| 5242 | q.text("cookie = "); |
| 5243 | q.text("%#x" % self.cookie) |
| 5244 | q.text(","); q.breakable() |
| 5245 | q.text("cookie_mask = "); |
| 5246 | q.text("%#x" % self.cookie_mask) |
| 5247 | q.text(","); q.breakable() |
| 5248 | q.text("match = "); |
| 5249 | q.pp(self.match) |
| 5250 | q.breakable() |
| 5251 | q.text('}') |
| 5252 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5253 | stats_request.subtypes[1] = flow_stats_request |
| 5254 | |
| 5255 | class get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5256 | version = 2 |
| 5257 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5258 | |
| 5259 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5260 | if xid != None: |
| 5261 | self.xid = xid |
| 5262 | else: |
| 5263 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5264 | if flags != None: |
| 5265 | self.flags = flags |
| 5266 | else: |
| 5267 | self.flags = 0 |
| 5268 | if miss_send_len != None: |
| 5269 | self.miss_send_len = miss_send_len |
| 5270 | else: |
| 5271 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5272 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5273 | |
| 5274 | def pack(self): |
| 5275 | packed = [] |
| 5276 | packed.append(struct.pack("!B", self.version)) |
| 5277 | packed.append(struct.pack("!B", self.type)) |
| 5278 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5279 | packed.append(struct.pack("!L", self.xid)) |
| 5280 | packed.append(struct.pack("!H", self.flags)) |
| 5281 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5282 | length = sum([len(x) for x in packed]) |
| 5283 | packed[2] = struct.pack("!H", length) |
| 5284 | return ''.join(packed) |
| 5285 | |
| 5286 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5287 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5288 | obj = get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5289 | _version = reader.read("!B")[0] |
| 5290 | assert(_version == 2) |
| 5291 | _type = reader.read("!B")[0] |
| 5292 | assert(_type == 8) |
| 5293 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5294 | orig_reader = reader |
| 5295 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5296 | obj.xid = reader.read("!L")[0] |
| 5297 | obj.flags = reader.read("!H")[0] |
| 5298 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5299 | return obj |
| 5300 | |
| 5301 | def __eq__(self, other): |
| 5302 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5303 | if self.xid != other.xid: return False |
| 5304 | if self.flags != other.flags: return False |
| 5305 | if self.miss_send_len != other.miss_send_len: return False |
| 5306 | return True |
| 5307 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5308 | def pretty_print(self, q): |
| 5309 | q.text("get_config_reply {") |
| 5310 | with q.group(): |
| 5311 | with q.indent(2): |
| 5312 | q.breakable() |
| 5313 | q.text("xid = "); |
| 5314 | if self.xid != None: |
| 5315 | q.text("%#x" % self.xid) |
| 5316 | else: |
| 5317 | q.text('None') |
| 5318 | q.text(","); q.breakable() |
| 5319 | q.text("flags = "); |
| 5320 | q.text("%#x" % self.flags) |
| 5321 | q.text(","); q.breakable() |
| 5322 | q.text("miss_send_len = "); |
| 5323 | q.text("%#x" % self.miss_send_len) |
| 5324 | q.breakable() |
| 5325 | q.text('}') |
| 5326 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5327 | message.subtypes[8] = get_config_reply |
| 5328 | |
| 5329 | class get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5330 | version = 2 |
| 5331 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5332 | |
| 5333 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5334 | if xid != None: |
| 5335 | self.xid = xid |
| 5336 | else: |
| 5337 | self.xid = None |
| 5338 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5339 | |
| 5340 | def pack(self): |
| 5341 | packed = [] |
| 5342 | packed.append(struct.pack("!B", self.version)) |
| 5343 | packed.append(struct.pack("!B", self.type)) |
| 5344 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5345 | packed.append(struct.pack("!L", self.xid)) |
| 5346 | length = sum([len(x) for x in packed]) |
| 5347 | packed[2] = struct.pack("!H", length) |
| 5348 | return ''.join(packed) |
| 5349 | |
| 5350 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5351 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5352 | obj = get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5353 | _version = reader.read("!B")[0] |
| 5354 | assert(_version == 2) |
| 5355 | _type = reader.read("!B")[0] |
| 5356 | assert(_type == 7) |
| 5357 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5358 | orig_reader = reader |
| 5359 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5360 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5361 | return obj |
| 5362 | |
| 5363 | def __eq__(self, other): |
| 5364 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5365 | if self.xid != other.xid: return False |
| 5366 | return True |
| 5367 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5368 | def pretty_print(self, q): |
| 5369 | q.text("get_config_request {") |
| 5370 | with q.group(): |
| 5371 | with q.indent(2): |
| 5372 | q.breakable() |
| 5373 | q.text("xid = "); |
| 5374 | if self.xid != None: |
| 5375 | q.text("%#x" % self.xid) |
| 5376 | else: |
| 5377 | q.text('None') |
| 5378 | q.breakable() |
| 5379 | q.text('}') |
| 5380 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5381 | message.subtypes[7] = get_config_request |
| 5382 | |
| 5383 | class group_mod(message): |
| 5384 | subtypes = {} |
| 5385 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5386 | version = 2 |
| 5387 | type = 15 |
| 5388 | |
| 5389 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 5390 | if xid != None: |
| 5391 | self.xid = xid |
| 5392 | else: |
| 5393 | self.xid = None |
| 5394 | if command != None: |
| 5395 | self.command = command |
| 5396 | else: |
| 5397 | self.command = 0 |
| 5398 | if group_type != None: |
| 5399 | self.group_type = group_type |
| 5400 | else: |
| 5401 | self.group_type = 0 |
| 5402 | if group_id != None: |
| 5403 | self.group_id = group_id |
| 5404 | else: |
| 5405 | self.group_id = 0 |
| 5406 | if buckets != None: |
| 5407 | self.buckets = buckets |
| 5408 | else: |
| 5409 | self.buckets = [] |
| 5410 | return |
| 5411 | |
| 5412 | def pack(self): |
| 5413 | packed = [] |
| 5414 | packed.append(struct.pack("!B", self.version)) |
| 5415 | packed.append(struct.pack("!B", self.type)) |
| 5416 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5417 | packed.append(struct.pack("!L", self.xid)) |
| 5418 | packed.append(struct.pack("!H", self.command)) |
| 5419 | packed.append(struct.pack("!B", self.group_type)) |
| 5420 | packed.append('\x00' * 1) |
| 5421 | packed.append(struct.pack("!L", self.group_id)) |
| 5422 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
| 5423 | length = sum([len(x) for x in packed]) |
| 5424 | packed[2] = struct.pack("!H", length) |
| 5425 | return ''.join(packed) |
| 5426 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5427 | @staticmethod |
| 5428 | def unpack(reader): |
| 5429 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5430 | subclass = group_mod.subtypes.get(subtype) |
| 5431 | if subclass: |
| 5432 | return subclass.unpack(reader) |
| 5433 | |
| 5434 | obj = group_mod() |
| 5435 | _version = reader.read("!B")[0] |
| 5436 | assert(_version == 2) |
| 5437 | _type = reader.read("!B")[0] |
| 5438 | assert(_type == 15) |
| 5439 | _length = reader.read("!H")[0] |
| 5440 | orig_reader = reader |
| 5441 | reader = orig_reader.slice(_length - (2 + 2)) |
| 5442 | obj.xid = reader.read("!L")[0] |
| 5443 | obj.command = reader.read("!H")[0] |
| 5444 | obj.group_type = reader.read("!B")[0] |
| 5445 | reader.skip(1) |
| 5446 | obj.group_id = reader.read("!L")[0] |
| 5447 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
| 5448 | return obj |
| 5449 | |
| 5450 | def __eq__(self, other): |
| 5451 | if type(self) != type(other): return False |
| 5452 | if self.xid != other.xid: return False |
| 5453 | if self.command != other.command: return False |
| 5454 | if self.group_type != other.group_type: return False |
| 5455 | if self.group_id != other.group_id: return False |
| 5456 | if self.buckets != other.buckets: return False |
| 5457 | return True |
| 5458 | |
| 5459 | def pretty_print(self, q): |
| 5460 | q.text("group_mod {") |
| 5461 | with q.group(): |
| 5462 | with q.indent(2): |
| 5463 | q.breakable() |
| 5464 | q.text("xid = "); |
| 5465 | if self.xid != None: |
| 5466 | q.text("%#x" % self.xid) |
| 5467 | else: |
| 5468 | q.text('None') |
| 5469 | q.text(","); q.breakable() |
| 5470 | q.text("group_type = "); |
| 5471 | q.text("%#x" % self.group_type) |
| 5472 | q.text(","); q.breakable() |
| 5473 | q.text("group_id = "); |
| 5474 | q.text("%#x" % self.group_id) |
| 5475 | q.text(","); q.breakable() |
| 5476 | q.text("buckets = "); |
| 5477 | q.pp(self.buckets) |
| 5478 | q.breakable() |
| 5479 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5480 | |
| 5481 | message.subtypes[15] = group_mod |
| 5482 | |
| 5483 | class group_add(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5484 | version = 2 |
| 5485 | type = 15 |
| 5486 | command = 0 |
| 5487 | |
| 5488 | 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] | 5489 | if xid != None: |
| 5490 | self.xid = xid |
| 5491 | else: |
| 5492 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5493 | if group_type != None: |
| 5494 | self.group_type = group_type |
| 5495 | else: |
| 5496 | self.group_type = 0 |
| 5497 | if group_id != None: |
| 5498 | self.group_id = group_id |
| 5499 | else: |
| 5500 | self.group_id = 0 |
| 5501 | if buckets != None: |
| 5502 | self.buckets = buckets |
| 5503 | else: |
| 5504 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5505 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5506 | |
| 5507 | def pack(self): |
| 5508 | packed = [] |
| 5509 | packed.append(struct.pack("!B", self.version)) |
| 5510 | packed.append(struct.pack("!B", self.type)) |
| 5511 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5512 | packed.append(struct.pack("!L", self.xid)) |
| 5513 | packed.append(struct.pack("!H", self.command)) |
| 5514 | packed.append(struct.pack("!B", self.group_type)) |
| 5515 | packed.append('\x00' * 1) |
| 5516 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5517 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5518 | length = sum([len(x) for x in packed]) |
| 5519 | packed[2] = struct.pack("!H", length) |
| 5520 | return ''.join(packed) |
| 5521 | |
| 5522 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5523 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5524 | obj = group_add() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5525 | _version = reader.read("!B")[0] |
| 5526 | assert(_version == 2) |
| 5527 | _type = reader.read("!B")[0] |
| 5528 | assert(_type == 15) |
| 5529 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5530 | orig_reader = reader |
| 5531 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5532 | obj.xid = reader.read("!L")[0] |
| 5533 | _command = reader.read("!H")[0] |
| 5534 | assert(_command == 0) |
| 5535 | obj.group_type = reader.read("!B")[0] |
| 5536 | reader.skip(1) |
| 5537 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5538 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5539 | return obj |
| 5540 | |
| 5541 | def __eq__(self, other): |
| 5542 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5543 | if self.xid != other.xid: return False |
| 5544 | if self.group_type != other.group_type: return False |
| 5545 | if self.group_id != other.group_id: return False |
| 5546 | if self.buckets != other.buckets: return False |
| 5547 | return True |
| 5548 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5549 | def pretty_print(self, q): |
| 5550 | q.text("group_add {") |
| 5551 | with q.group(): |
| 5552 | with q.indent(2): |
| 5553 | q.breakable() |
| 5554 | q.text("xid = "); |
| 5555 | if self.xid != None: |
| 5556 | q.text("%#x" % self.xid) |
| 5557 | else: |
| 5558 | q.text('None') |
| 5559 | q.text(","); q.breakable() |
| 5560 | q.text("group_type = "); |
| 5561 | q.text("%#x" % self.group_type) |
| 5562 | q.text(","); q.breakable() |
| 5563 | q.text("group_id = "); |
| 5564 | q.text("%#x" % self.group_id) |
| 5565 | q.text(","); q.breakable() |
| 5566 | q.text("buckets = "); |
| 5567 | q.pp(self.buckets) |
| 5568 | q.breakable() |
| 5569 | q.text('}') |
| 5570 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5571 | group_mod.subtypes[0] = group_add |
| 5572 | |
| 5573 | class group_delete(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5574 | version = 2 |
| 5575 | type = 15 |
| 5576 | command = 2 |
| 5577 | |
| 5578 | 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] | 5579 | if xid != None: |
| 5580 | self.xid = xid |
| 5581 | else: |
| 5582 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5583 | if group_type != None: |
| 5584 | self.group_type = group_type |
| 5585 | else: |
| 5586 | self.group_type = 0 |
| 5587 | if group_id != None: |
| 5588 | self.group_id = group_id |
| 5589 | else: |
| 5590 | self.group_id = 0 |
| 5591 | if buckets != None: |
| 5592 | self.buckets = buckets |
| 5593 | else: |
| 5594 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5595 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5596 | |
| 5597 | def pack(self): |
| 5598 | packed = [] |
| 5599 | packed.append(struct.pack("!B", self.version)) |
| 5600 | packed.append(struct.pack("!B", self.type)) |
| 5601 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5602 | packed.append(struct.pack("!L", self.xid)) |
| 5603 | packed.append(struct.pack("!H", self.command)) |
| 5604 | packed.append(struct.pack("!B", self.group_type)) |
| 5605 | packed.append('\x00' * 1) |
| 5606 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5607 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5608 | length = sum([len(x) for x in packed]) |
| 5609 | packed[2] = struct.pack("!H", length) |
| 5610 | return ''.join(packed) |
| 5611 | |
| 5612 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5613 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5614 | obj = group_delete() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5615 | _version = reader.read("!B")[0] |
| 5616 | assert(_version == 2) |
| 5617 | _type = reader.read("!B")[0] |
| 5618 | assert(_type == 15) |
| 5619 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5620 | orig_reader = reader |
| 5621 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5622 | obj.xid = reader.read("!L")[0] |
| 5623 | _command = reader.read("!H")[0] |
| 5624 | assert(_command == 2) |
| 5625 | obj.group_type = reader.read("!B")[0] |
| 5626 | reader.skip(1) |
| 5627 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5628 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5629 | return obj |
| 5630 | |
| 5631 | def __eq__(self, other): |
| 5632 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5633 | if self.xid != other.xid: return False |
| 5634 | if self.group_type != other.group_type: return False |
| 5635 | if self.group_id != other.group_id: return False |
| 5636 | if self.buckets != other.buckets: return False |
| 5637 | return True |
| 5638 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5639 | def pretty_print(self, q): |
| 5640 | q.text("group_delete {") |
| 5641 | with q.group(): |
| 5642 | with q.indent(2): |
| 5643 | q.breakable() |
| 5644 | q.text("xid = "); |
| 5645 | if self.xid != None: |
| 5646 | q.text("%#x" % self.xid) |
| 5647 | else: |
| 5648 | q.text('None') |
| 5649 | q.text(","); q.breakable() |
| 5650 | q.text("group_type = "); |
| 5651 | q.text("%#x" % self.group_type) |
| 5652 | q.text(","); q.breakable() |
| 5653 | q.text("group_id = "); |
| 5654 | q.text("%#x" % self.group_id) |
| 5655 | q.text(","); q.breakable() |
| 5656 | q.text("buckets = "); |
| 5657 | q.pp(self.buckets) |
| 5658 | q.breakable() |
| 5659 | q.text('}') |
| 5660 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5661 | group_mod.subtypes[2] = group_delete |
| 5662 | |
| 5663 | class group_desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5664 | version = 2 |
| 5665 | type = 19 |
| 5666 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5667 | |
| 5668 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5669 | if xid != None: |
| 5670 | self.xid = xid |
| 5671 | else: |
| 5672 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5673 | if flags != None: |
| 5674 | self.flags = flags |
| 5675 | else: |
| 5676 | self.flags = 0 |
| 5677 | if entries != None: |
| 5678 | self.entries = entries |
| 5679 | else: |
| 5680 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5681 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5682 | |
| 5683 | def pack(self): |
| 5684 | packed = [] |
| 5685 | packed.append(struct.pack("!B", self.version)) |
| 5686 | packed.append(struct.pack("!B", self.type)) |
| 5687 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5688 | packed.append(struct.pack("!L", self.xid)) |
| 5689 | packed.append(struct.pack("!H", self.stats_type)) |
| 5690 | packed.append(struct.pack("!H", self.flags)) |
| 5691 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5692 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5693 | length = sum([len(x) for x in packed]) |
| 5694 | packed[2] = struct.pack("!H", length) |
| 5695 | return ''.join(packed) |
| 5696 | |
| 5697 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5698 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5699 | obj = group_desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5700 | _version = reader.read("!B")[0] |
| 5701 | assert(_version == 2) |
| 5702 | _type = reader.read("!B")[0] |
| 5703 | assert(_type == 19) |
| 5704 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5705 | orig_reader = reader |
| 5706 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5707 | obj.xid = reader.read("!L")[0] |
| 5708 | _stats_type = reader.read("!H")[0] |
| 5709 | assert(_stats_type == 7) |
| 5710 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5711 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5712 | 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] | 5713 | return obj |
| 5714 | |
| 5715 | def __eq__(self, other): |
| 5716 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5717 | if self.xid != other.xid: return False |
| 5718 | if self.flags != other.flags: return False |
| 5719 | if self.entries != other.entries: return False |
| 5720 | return True |
| 5721 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5722 | def pretty_print(self, q): |
| 5723 | q.text("group_desc_stats_reply {") |
| 5724 | with q.group(): |
| 5725 | with q.indent(2): |
| 5726 | q.breakable() |
| 5727 | q.text("xid = "); |
| 5728 | if self.xid != None: |
| 5729 | q.text("%#x" % self.xid) |
| 5730 | else: |
| 5731 | q.text('None') |
| 5732 | q.text(","); q.breakable() |
| 5733 | q.text("flags = "); |
| 5734 | q.text("%#x" % self.flags) |
| 5735 | q.text(","); q.breakable() |
| 5736 | q.text("entries = "); |
| 5737 | q.pp(self.entries) |
| 5738 | q.breakable() |
| 5739 | q.text('}') |
| 5740 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5741 | stats_reply.subtypes[7] = group_desc_stats_reply |
| 5742 | |
| 5743 | class group_desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5744 | version = 2 |
| 5745 | type = 18 |
| 5746 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5747 | |
| 5748 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5749 | if xid != None: |
| 5750 | self.xid = xid |
| 5751 | else: |
| 5752 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5753 | if flags != None: |
| 5754 | self.flags = flags |
| 5755 | else: |
| 5756 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5757 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5758 | |
| 5759 | def pack(self): |
| 5760 | packed = [] |
| 5761 | packed.append(struct.pack("!B", self.version)) |
| 5762 | packed.append(struct.pack("!B", self.type)) |
| 5763 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5764 | packed.append(struct.pack("!L", self.xid)) |
| 5765 | packed.append(struct.pack("!H", self.stats_type)) |
| 5766 | packed.append(struct.pack("!H", self.flags)) |
| 5767 | packed.append('\x00' * 4) |
| 5768 | length = sum([len(x) for x in packed]) |
| 5769 | packed[2] = struct.pack("!H", length) |
| 5770 | return ''.join(packed) |
| 5771 | |
| 5772 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5773 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5774 | obj = group_desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5775 | _version = reader.read("!B")[0] |
| 5776 | assert(_version == 2) |
| 5777 | _type = reader.read("!B")[0] |
| 5778 | assert(_type == 18) |
| 5779 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5780 | orig_reader = reader |
| 5781 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5782 | obj.xid = reader.read("!L")[0] |
| 5783 | _stats_type = reader.read("!H")[0] |
| 5784 | assert(_stats_type == 7) |
| 5785 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5786 | reader.skip(4) |
| 5787 | return obj |
| 5788 | |
| 5789 | def __eq__(self, other): |
| 5790 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5791 | if self.xid != other.xid: return False |
| 5792 | if self.flags != other.flags: return False |
| 5793 | return True |
| 5794 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5795 | def pretty_print(self, q): |
| 5796 | q.text("group_desc_stats_request {") |
| 5797 | with q.group(): |
| 5798 | with q.indent(2): |
| 5799 | q.breakable() |
| 5800 | q.text("xid = "); |
| 5801 | if self.xid != None: |
| 5802 | q.text("%#x" % self.xid) |
| 5803 | else: |
| 5804 | q.text('None') |
| 5805 | q.text(","); q.breakable() |
| 5806 | q.text("flags = "); |
| 5807 | q.text("%#x" % self.flags) |
| 5808 | q.breakable() |
| 5809 | q.text('}') |
| 5810 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5811 | stats_request.subtypes[7] = group_desc_stats_request |
| 5812 | |
| 5813 | class group_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5814 | version = 2 |
| 5815 | type = 1 |
| 5816 | err_type = 6 |
| 5817 | |
| 5818 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5819 | if xid != None: |
| 5820 | self.xid = xid |
| 5821 | else: |
| 5822 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5823 | if code != None: |
| 5824 | self.code = code |
| 5825 | else: |
| 5826 | self.code = 0 |
| 5827 | if data != None: |
| 5828 | self.data = data |
| 5829 | else: |
| 5830 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5831 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5832 | |
| 5833 | def pack(self): |
| 5834 | packed = [] |
| 5835 | packed.append(struct.pack("!B", self.version)) |
| 5836 | packed.append(struct.pack("!B", self.type)) |
| 5837 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5838 | packed.append(struct.pack("!L", self.xid)) |
| 5839 | packed.append(struct.pack("!H", self.err_type)) |
| 5840 | packed.append(struct.pack("!H", self.code)) |
| 5841 | packed.append(self.data) |
| 5842 | length = sum([len(x) for x in packed]) |
| 5843 | packed[2] = struct.pack("!H", length) |
| 5844 | return ''.join(packed) |
| 5845 | |
| 5846 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5847 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5848 | obj = group_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5849 | _version = reader.read("!B")[0] |
| 5850 | assert(_version == 2) |
| 5851 | _type = reader.read("!B")[0] |
| 5852 | assert(_type == 1) |
| 5853 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5854 | orig_reader = reader |
| 5855 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5856 | obj.xid = reader.read("!L")[0] |
| 5857 | _err_type = reader.read("!H")[0] |
| 5858 | assert(_err_type == 6) |
| 5859 | obj.code = reader.read("!H")[0] |
| 5860 | obj.data = str(reader.read_all()) |
| 5861 | return obj |
| 5862 | |
| 5863 | def __eq__(self, other): |
| 5864 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5865 | if self.xid != other.xid: return False |
| 5866 | if self.code != other.code: return False |
| 5867 | if self.data != other.data: return False |
| 5868 | return True |
| 5869 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5870 | def pretty_print(self, q): |
| 5871 | q.text("group_mod_failed_error_msg {") |
| 5872 | with q.group(): |
| 5873 | with q.indent(2): |
| 5874 | q.breakable() |
| 5875 | q.text("xid = "); |
| 5876 | if self.xid != None: |
| 5877 | q.text("%#x" % self.xid) |
| 5878 | else: |
| 5879 | q.text('None') |
| 5880 | q.text(","); q.breakable() |
| 5881 | q.text("code = "); |
| 5882 | q.text("%#x" % self.code) |
| 5883 | q.text(","); q.breakable() |
| 5884 | q.text("data = "); |
| 5885 | q.pp(self.data) |
| 5886 | q.breakable() |
| 5887 | q.text('}') |
| 5888 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5889 | error_msg.subtypes[6] = group_mod_failed_error_msg |
| 5890 | |
| 5891 | class group_modify(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5892 | version = 2 |
| 5893 | type = 15 |
| 5894 | command = 1 |
| 5895 | |
| 5896 | 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] | 5897 | if xid != None: |
| 5898 | self.xid = xid |
| 5899 | else: |
| 5900 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5901 | if group_type != None: |
| 5902 | self.group_type = group_type |
| 5903 | else: |
| 5904 | self.group_type = 0 |
| 5905 | if group_id != None: |
| 5906 | self.group_id = group_id |
| 5907 | else: |
| 5908 | self.group_id = 0 |
| 5909 | if buckets != None: |
| 5910 | self.buckets = buckets |
| 5911 | else: |
| 5912 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5913 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5914 | |
| 5915 | def pack(self): |
| 5916 | packed = [] |
| 5917 | packed.append(struct.pack("!B", self.version)) |
| 5918 | packed.append(struct.pack("!B", self.type)) |
| 5919 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5920 | packed.append(struct.pack("!L", self.xid)) |
| 5921 | packed.append(struct.pack("!H", self.command)) |
| 5922 | packed.append(struct.pack("!B", self.group_type)) |
| 5923 | packed.append('\x00' * 1) |
| 5924 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5925 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5926 | length = sum([len(x) for x in packed]) |
| 5927 | packed[2] = struct.pack("!H", length) |
| 5928 | return ''.join(packed) |
| 5929 | |
| 5930 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5931 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5932 | obj = group_modify() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5933 | _version = reader.read("!B")[0] |
| 5934 | assert(_version == 2) |
| 5935 | _type = reader.read("!B")[0] |
| 5936 | assert(_type == 15) |
| 5937 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5938 | orig_reader = reader |
| 5939 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5940 | obj.xid = reader.read("!L")[0] |
| 5941 | _command = reader.read("!H")[0] |
| 5942 | assert(_command == 1) |
| 5943 | obj.group_type = reader.read("!B")[0] |
| 5944 | reader.skip(1) |
| 5945 | obj.group_id = reader.read("!L")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5946 | obj.buckets = loxi.generic_util.unpack_list(reader, common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5947 | return obj |
| 5948 | |
| 5949 | def __eq__(self, other): |
| 5950 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5951 | if self.xid != other.xid: return False |
| 5952 | if self.group_type != other.group_type: return False |
| 5953 | if self.group_id != other.group_id: return False |
| 5954 | if self.buckets != other.buckets: return False |
| 5955 | return True |
| 5956 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5957 | def pretty_print(self, q): |
| 5958 | q.text("group_modify {") |
| 5959 | with q.group(): |
| 5960 | with q.indent(2): |
| 5961 | q.breakable() |
| 5962 | q.text("xid = "); |
| 5963 | if self.xid != None: |
| 5964 | q.text("%#x" % self.xid) |
| 5965 | else: |
| 5966 | q.text('None') |
| 5967 | q.text(","); q.breakable() |
| 5968 | q.text("group_type = "); |
| 5969 | q.text("%#x" % self.group_type) |
| 5970 | q.text(","); q.breakable() |
| 5971 | q.text("group_id = "); |
| 5972 | q.text("%#x" % self.group_id) |
| 5973 | q.text(","); q.breakable() |
| 5974 | q.text("buckets = "); |
| 5975 | q.pp(self.buckets) |
| 5976 | q.breakable() |
| 5977 | q.text('}') |
| 5978 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5979 | group_mod.subtypes[1] = group_modify |
| 5980 | |
| 5981 | class group_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5982 | version = 2 |
| 5983 | type = 19 |
| 5984 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5985 | |
| 5986 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5987 | if xid != None: |
| 5988 | self.xid = xid |
| 5989 | else: |
| 5990 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5991 | if flags != None: |
| 5992 | self.flags = flags |
| 5993 | else: |
| 5994 | self.flags = 0 |
| 5995 | if entries != None: |
| 5996 | self.entries = entries |
| 5997 | else: |
| 5998 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5999 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6000 | |
| 6001 | def pack(self): |
| 6002 | packed = [] |
| 6003 | packed.append(struct.pack("!B", self.version)) |
| 6004 | packed.append(struct.pack("!B", self.type)) |
| 6005 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6006 | packed.append(struct.pack("!L", self.xid)) |
| 6007 | packed.append(struct.pack("!H", self.stats_type)) |
| 6008 | packed.append(struct.pack("!H", self.flags)) |
| 6009 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6010 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6011 | length = sum([len(x) for x in packed]) |
| 6012 | packed[2] = struct.pack("!H", length) |
| 6013 | return ''.join(packed) |
| 6014 | |
| 6015 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6016 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6017 | obj = group_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6018 | _version = reader.read("!B")[0] |
| 6019 | assert(_version == 2) |
| 6020 | _type = reader.read("!B")[0] |
| 6021 | assert(_type == 19) |
| 6022 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6023 | orig_reader = reader |
| 6024 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6025 | obj.xid = reader.read("!L")[0] |
| 6026 | _stats_type = reader.read("!H")[0] |
| 6027 | assert(_stats_type == 6) |
| 6028 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6029 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6030 | 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] | 6031 | return obj |
| 6032 | |
| 6033 | def __eq__(self, other): |
| 6034 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6035 | if self.xid != other.xid: return False |
| 6036 | if self.flags != other.flags: return False |
| 6037 | if self.entries != other.entries: return False |
| 6038 | return True |
| 6039 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6040 | def pretty_print(self, q): |
| 6041 | q.text("group_stats_reply {") |
| 6042 | with q.group(): |
| 6043 | with q.indent(2): |
| 6044 | q.breakable() |
| 6045 | q.text("xid = "); |
| 6046 | if self.xid != None: |
| 6047 | q.text("%#x" % self.xid) |
| 6048 | else: |
| 6049 | q.text('None') |
| 6050 | q.text(","); q.breakable() |
| 6051 | q.text("flags = "); |
| 6052 | q.text("%#x" % self.flags) |
| 6053 | q.text(","); q.breakable() |
| 6054 | q.text("entries = "); |
| 6055 | q.pp(self.entries) |
| 6056 | q.breakable() |
| 6057 | q.text('}') |
| 6058 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6059 | stats_reply.subtypes[6] = group_stats_reply |
| 6060 | |
| 6061 | class group_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6062 | version = 2 |
| 6063 | type = 18 |
| 6064 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6065 | |
| 6066 | def __init__(self, xid=None, flags=None, group_id=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6067 | if xid != None: |
| 6068 | self.xid = xid |
| 6069 | else: |
| 6070 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6071 | if flags != None: |
| 6072 | self.flags = flags |
| 6073 | else: |
| 6074 | self.flags = 0 |
| 6075 | if group_id != None: |
| 6076 | self.group_id = group_id |
| 6077 | else: |
| 6078 | self.group_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6079 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6080 | |
| 6081 | def pack(self): |
| 6082 | packed = [] |
| 6083 | packed.append(struct.pack("!B", self.version)) |
| 6084 | packed.append(struct.pack("!B", self.type)) |
| 6085 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6086 | packed.append(struct.pack("!L", self.xid)) |
| 6087 | packed.append(struct.pack("!H", self.stats_type)) |
| 6088 | packed.append(struct.pack("!H", self.flags)) |
| 6089 | packed.append('\x00' * 4) |
| 6090 | packed.append(struct.pack("!L", self.group_id)) |
| 6091 | packed.append('\x00' * 4) |
| 6092 | length = sum([len(x) for x in packed]) |
| 6093 | packed[2] = struct.pack("!H", length) |
| 6094 | return ''.join(packed) |
| 6095 | |
| 6096 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6097 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6098 | obj = group_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6099 | _version = reader.read("!B")[0] |
| 6100 | assert(_version == 2) |
| 6101 | _type = reader.read("!B")[0] |
| 6102 | assert(_type == 18) |
| 6103 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6104 | orig_reader = reader |
| 6105 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6106 | obj.xid = reader.read("!L")[0] |
| 6107 | _stats_type = reader.read("!H")[0] |
| 6108 | assert(_stats_type == 6) |
| 6109 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6110 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6111 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6112 | reader.skip(4) |
| 6113 | return obj |
| 6114 | |
| 6115 | def __eq__(self, other): |
| 6116 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6117 | if self.xid != other.xid: return False |
| 6118 | if self.flags != other.flags: return False |
| 6119 | if self.group_id != other.group_id: return False |
| 6120 | return True |
| 6121 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6122 | def pretty_print(self, q): |
| 6123 | q.text("group_stats_request {") |
| 6124 | with q.group(): |
| 6125 | with q.indent(2): |
| 6126 | q.breakable() |
| 6127 | q.text("xid = "); |
| 6128 | if self.xid != None: |
| 6129 | q.text("%#x" % self.xid) |
| 6130 | else: |
| 6131 | q.text('None') |
| 6132 | q.text(","); q.breakable() |
| 6133 | q.text("flags = "); |
| 6134 | q.text("%#x" % self.flags) |
| 6135 | q.text(","); q.breakable() |
| 6136 | q.text("group_id = "); |
| 6137 | q.text("%#x" % self.group_id) |
| 6138 | q.breakable() |
| 6139 | q.text('}') |
| 6140 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6141 | stats_request.subtypes[6] = group_stats_request |
| 6142 | |
| 6143 | class hello(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6144 | version = 2 |
| 6145 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6146 | |
| 6147 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6148 | if xid != None: |
| 6149 | self.xid = xid |
| 6150 | else: |
| 6151 | self.xid = None |
| 6152 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6153 | |
| 6154 | def pack(self): |
| 6155 | packed = [] |
| 6156 | packed.append(struct.pack("!B", self.version)) |
| 6157 | packed.append(struct.pack("!B", self.type)) |
| 6158 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6159 | packed.append(struct.pack("!L", self.xid)) |
| 6160 | length = sum([len(x) for x in packed]) |
| 6161 | packed[2] = struct.pack("!H", length) |
| 6162 | return ''.join(packed) |
| 6163 | |
| 6164 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6165 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6166 | obj = hello() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6167 | _version = reader.read("!B")[0] |
| 6168 | assert(_version == 2) |
| 6169 | _type = reader.read("!B")[0] |
| 6170 | assert(_type == 0) |
| 6171 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6172 | orig_reader = reader |
| 6173 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6174 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6175 | return obj |
| 6176 | |
| 6177 | def __eq__(self, other): |
| 6178 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6179 | if self.xid != other.xid: return False |
| 6180 | return True |
| 6181 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6182 | def pretty_print(self, q): |
| 6183 | q.text("hello {") |
| 6184 | with q.group(): |
| 6185 | with q.indent(2): |
| 6186 | q.breakable() |
| 6187 | q.text("xid = "); |
| 6188 | if self.xid != None: |
| 6189 | q.text("%#x" % self.xid) |
| 6190 | else: |
| 6191 | q.text('None') |
| 6192 | q.breakable() |
| 6193 | q.text('}') |
| 6194 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6195 | message.subtypes[0] = hello |
| 6196 | |
| 6197 | class hello_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6198 | version = 2 |
| 6199 | type = 1 |
| 6200 | err_type = 0 |
| 6201 | |
| 6202 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6203 | if xid != None: |
| 6204 | self.xid = xid |
| 6205 | else: |
| 6206 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6207 | if code != None: |
| 6208 | self.code = code |
| 6209 | else: |
| 6210 | self.code = 0 |
| 6211 | if data != None: |
| 6212 | self.data = data |
| 6213 | else: |
| 6214 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6215 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6216 | |
| 6217 | def pack(self): |
| 6218 | packed = [] |
| 6219 | packed.append(struct.pack("!B", self.version)) |
| 6220 | packed.append(struct.pack("!B", self.type)) |
| 6221 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6222 | packed.append(struct.pack("!L", self.xid)) |
| 6223 | packed.append(struct.pack("!H", self.err_type)) |
| 6224 | packed.append(struct.pack("!H", self.code)) |
| 6225 | packed.append(self.data) |
| 6226 | length = sum([len(x) for x in packed]) |
| 6227 | packed[2] = struct.pack("!H", length) |
| 6228 | return ''.join(packed) |
| 6229 | |
| 6230 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6231 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6232 | obj = hello_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6233 | _version = reader.read("!B")[0] |
| 6234 | assert(_version == 2) |
| 6235 | _type = reader.read("!B")[0] |
| 6236 | assert(_type == 1) |
| 6237 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6238 | orig_reader = reader |
| 6239 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6240 | obj.xid = reader.read("!L")[0] |
| 6241 | _err_type = reader.read("!H")[0] |
| 6242 | assert(_err_type == 0) |
| 6243 | obj.code = reader.read("!H")[0] |
| 6244 | obj.data = str(reader.read_all()) |
| 6245 | return obj |
| 6246 | |
| 6247 | def __eq__(self, other): |
| 6248 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6249 | if self.xid != other.xid: return False |
| 6250 | if self.code != other.code: return False |
| 6251 | if self.data != other.data: return False |
| 6252 | return True |
| 6253 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6254 | def pretty_print(self, q): |
| 6255 | q.text("hello_failed_error_msg {") |
| 6256 | with q.group(): |
| 6257 | with q.indent(2): |
| 6258 | q.breakable() |
| 6259 | q.text("xid = "); |
| 6260 | if self.xid != None: |
| 6261 | q.text("%#x" % self.xid) |
| 6262 | else: |
| 6263 | q.text('None') |
| 6264 | q.text(","); q.breakable() |
| 6265 | q.text("code = "); |
| 6266 | q.text("%#x" % self.code) |
| 6267 | q.text(","); q.breakable() |
| 6268 | q.text("data = "); |
| 6269 | q.pp(self.data) |
| 6270 | q.breakable() |
| 6271 | q.text('}') |
| 6272 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6273 | error_msg.subtypes[0] = hello_failed_error_msg |
| 6274 | |
| 6275 | class nicira_header(experimenter): |
| 6276 | subtypes = {} |
| 6277 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6278 | version = 2 |
| 6279 | type = 4 |
| 6280 | experimenter = 8992 |
| 6281 | |
| 6282 | def __init__(self, xid=None, subtype=None): |
| 6283 | if xid != None: |
| 6284 | self.xid = xid |
| 6285 | else: |
| 6286 | self.xid = None |
| 6287 | if subtype != None: |
| 6288 | self.subtype = subtype |
| 6289 | else: |
| 6290 | self.subtype = 0 |
| 6291 | return |
| 6292 | |
| 6293 | def pack(self): |
| 6294 | packed = [] |
| 6295 | packed.append(struct.pack("!B", self.version)) |
| 6296 | packed.append(struct.pack("!B", self.type)) |
| 6297 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6298 | packed.append(struct.pack("!L", self.xid)) |
| 6299 | packed.append(struct.pack("!L", self.experimenter)) |
| 6300 | packed.append(struct.pack("!L", self.subtype)) |
| 6301 | length = sum([len(x) for x in packed]) |
| 6302 | packed[2] = struct.pack("!H", length) |
| 6303 | return ''.join(packed) |
| 6304 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6305 | @staticmethod |
| 6306 | def unpack(reader): |
| 6307 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6308 | subclass = nicira_header.subtypes.get(subtype) |
| 6309 | if subclass: |
| 6310 | return subclass.unpack(reader) |
| 6311 | |
| 6312 | obj = nicira_header() |
| 6313 | _version = reader.read("!B")[0] |
| 6314 | assert(_version == 2) |
| 6315 | _type = reader.read("!B")[0] |
| 6316 | assert(_type == 4) |
| 6317 | _length = reader.read("!H")[0] |
| 6318 | orig_reader = reader |
| 6319 | reader = orig_reader.slice(_length - (2 + 2)) |
| 6320 | obj.xid = reader.read("!L")[0] |
| 6321 | _experimenter = reader.read("!L")[0] |
| 6322 | assert(_experimenter == 8992) |
| 6323 | obj.subtype = reader.read("!L")[0] |
| 6324 | return obj |
| 6325 | |
| 6326 | def __eq__(self, other): |
| 6327 | if type(self) != type(other): return False |
| 6328 | if self.xid != other.xid: return False |
| 6329 | if self.subtype != other.subtype: return False |
| 6330 | return True |
| 6331 | |
| 6332 | def pretty_print(self, q): |
| 6333 | q.text("nicira_header {") |
| 6334 | with q.group(): |
| 6335 | with q.indent(2): |
| 6336 | q.breakable() |
| 6337 | q.text("xid = "); |
| 6338 | if self.xid != None: |
| 6339 | q.text("%#x" % self.xid) |
| 6340 | else: |
| 6341 | q.text('None') |
| 6342 | q.breakable() |
| 6343 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6344 | |
| 6345 | experimenter.subtypes[8992] = nicira_header |
| 6346 | |
| 6347 | class packet_in(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6348 | version = 2 |
| 6349 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6350 | |
| 6351 | 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] | 6352 | if xid != None: |
| 6353 | self.xid = xid |
| 6354 | else: |
| 6355 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6356 | if buffer_id != None: |
| 6357 | self.buffer_id = buffer_id |
| 6358 | else: |
| 6359 | self.buffer_id = 0 |
| 6360 | if in_port != None: |
| 6361 | self.in_port = in_port |
| 6362 | else: |
| 6363 | self.in_port = 0 |
| 6364 | if in_phy_port != None: |
| 6365 | self.in_phy_port = in_phy_port |
| 6366 | else: |
| 6367 | self.in_phy_port = 0 |
| 6368 | if total_len != None: |
| 6369 | self.total_len = total_len |
| 6370 | else: |
| 6371 | self.total_len = 0 |
| 6372 | if reason != None: |
| 6373 | self.reason = reason |
| 6374 | else: |
| 6375 | self.reason = 0 |
| 6376 | if table_id != None: |
| 6377 | self.table_id = table_id |
| 6378 | else: |
| 6379 | self.table_id = 0 |
| 6380 | if data != None: |
| 6381 | self.data = data |
| 6382 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6383 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6384 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6385 | |
| 6386 | def pack(self): |
| 6387 | packed = [] |
| 6388 | packed.append(struct.pack("!B", self.version)) |
| 6389 | packed.append(struct.pack("!B", self.type)) |
| 6390 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6391 | packed.append(struct.pack("!L", self.xid)) |
| 6392 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6393 | packed.append(util.pack_port_no(self.in_port)) |
| 6394 | packed.append(util.pack_port_no(self.in_phy_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6395 | packed.append(struct.pack("!H", self.total_len)) |
| 6396 | packed.append(struct.pack("!B", self.reason)) |
| 6397 | packed.append(struct.pack("!B", self.table_id)) |
| 6398 | packed.append(self.data) |
| 6399 | length = sum([len(x) for x in packed]) |
| 6400 | packed[2] = struct.pack("!H", length) |
| 6401 | return ''.join(packed) |
| 6402 | |
| 6403 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6404 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6405 | obj = packet_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6406 | _version = reader.read("!B")[0] |
| 6407 | assert(_version == 2) |
| 6408 | _type = reader.read("!B")[0] |
| 6409 | assert(_type == 10) |
| 6410 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6411 | orig_reader = reader |
| 6412 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6413 | obj.xid = reader.read("!L")[0] |
| 6414 | obj.buffer_id = reader.read("!L")[0] |
| 6415 | obj.in_port = util.unpack_port_no(reader) |
| 6416 | obj.in_phy_port = util.unpack_port_no(reader) |
| 6417 | obj.total_len = reader.read("!H")[0] |
| 6418 | obj.reason = reader.read("!B")[0] |
| 6419 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6420 | obj.data = str(reader.read_all()) |
| 6421 | return obj |
| 6422 | |
| 6423 | def __eq__(self, other): |
| 6424 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6425 | if self.xid != other.xid: return False |
| 6426 | if self.buffer_id != other.buffer_id: return False |
| 6427 | if self.in_port != other.in_port: return False |
| 6428 | if self.in_phy_port != other.in_phy_port: return False |
| 6429 | if self.total_len != other.total_len: return False |
| 6430 | if self.reason != other.reason: return False |
| 6431 | if self.table_id != other.table_id: return False |
| 6432 | if self.data != other.data: return False |
| 6433 | return True |
| 6434 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6435 | def pretty_print(self, q): |
| 6436 | q.text("packet_in {") |
| 6437 | with q.group(): |
| 6438 | with q.indent(2): |
| 6439 | q.breakable() |
| 6440 | q.text("xid = "); |
| 6441 | if self.xid != None: |
| 6442 | q.text("%#x" % self.xid) |
| 6443 | else: |
| 6444 | q.text('None') |
| 6445 | q.text(","); q.breakable() |
| 6446 | q.text("buffer_id = "); |
| 6447 | q.text("%#x" % self.buffer_id) |
| 6448 | q.text(","); q.breakable() |
| 6449 | q.text("in_port = "); |
| 6450 | q.text(util.pretty_port(self.in_port)) |
| 6451 | q.text(","); q.breakable() |
| 6452 | q.text("in_phy_port = "); |
| 6453 | q.text(util.pretty_port(self.in_phy_port)) |
| 6454 | q.text(","); q.breakable() |
| 6455 | q.text("total_len = "); |
| 6456 | q.text("%#x" % self.total_len) |
| 6457 | q.text(","); q.breakable() |
| 6458 | q.text("reason = "); |
| 6459 | q.text("%#x" % self.reason) |
| 6460 | q.text(","); q.breakable() |
| 6461 | q.text("table_id = "); |
| 6462 | q.text("%#x" % self.table_id) |
| 6463 | q.text(","); q.breakable() |
| 6464 | q.text("data = "); |
| 6465 | q.pp(self.data) |
| 6466 | q.breakable() |
| 6467 | q.text('}') |
| 6468 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6469 | message.subtypes[10] = packet_in |
| 6470 | |
| 6471 | class packet_out(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6472 | version = 2 |
| 6473 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6474 | |
| 6475 | 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] | 6476 | if xid != None: |
| 6477 | self.xid = xid |
| 6478 | else: |
| 6479 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6480 | if buffer_id != None: |
| 6481 | self.buffer_id = buffer_id |
| 6482 | else: |
| 6483 | self.buffer_id = 0 |
| 6484 | if in_port != None: |
| 6485 | self.in_port = in_port |
| 6486 | else: |
| 6487 | self.in_port = 0 |
| 6488 | if actions != None: |
| 6489 | self.actions = actions |
| 6490 | else: |
| 6491 | self.actions = [] |
| 6492 | if data != None: |
| 6493 | self.data = data |
| 6494 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6495 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6496 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6497 | |
| 6498 | def pack(self): |
| 6499 | packed = [] |
| 6500 | packed.append(struct.pack("!B", self.version)) |
| 6501 | packed.append(struct.pack("!B", self.type)) |
| 6502 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6503 | packed.append(struct.pack("!L", self.xid)) |
| 6504 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6505 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6506 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 6507 | packed.append('\x00' * 6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6508 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6509 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 6510 | packed.append(self.data) |
| 6511 | length = sum([len(x) for x in packed]) |
| 6512 | packed[2] = struct.pack("!H", length) |
| 6513 | return ''.join(packed) |
| 6514 | |
| 6515 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6516 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6517 | obj = packet_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6518 | _version = reader.read("!B")[0] |
| 6519 | assert(_version == 2) |
| 6520 | _type = reader.read("!B")[0] |
| 6521 | assert(_type == 13) |
| 6522 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6523 | orig_reader = reader |
| 6524 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6525 | obj.xid = reader.read("!L")[0] |
| 6526 | obj.buffer_id = reader.read("!L")[0] |
| 6527 | obj.in_port = util.unpack_port_no(reader) |
| 6528 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6529 | reader.skip(6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6530 | 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] | 6531 | obj.data = str(reader.read_all()) |
| 6532 | return obj |
| 6533 | |
| 6534 | def __eq__(self, other): |
| 6535 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6536 | if self.xid != other.xid: return False |
| 6537 | if self.buffer_id != other.buffer_id: return False |
| 6538 | if self.in_port != other.in_port: return False |
| 6539 | if self.actions != other.actions: return False |
| 6540 | if self.data != other.data: return False |
| 6541 | return True |
| 6542 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6543 | def pretty_print(self, q): |
| 6544 | q.text("packet_out {") |
| 6545 | with q.group(): |
| 6546 | with q.indent(2): |
| 6547 | q.breakable() |
| 6548 | q.text("xid = "); |
| 6549 | if self.xid != None: |
| 6550 | q.text("%#x" % self.xid) |
| 6551 | else: |
| 6552 | q.text('None') |
| 6553 | q.text(","); q.breakable() |
| 6554 | q.text("buffer_id = "); |
| 6555 | q.text("%#x" % self.buffer_id) |
| 6556 | q.text(","); q.breakable() |
| 6557 | q.text("in_port = "); |
| 6558 | q.text(util.pretty_port(self.in_port)) |
| 6559 | q.text(","); q.breakable() |
| 6560 | q.text("actions = "); |
| 6561 | q.pp(self.actions) |
| 6562 | q.text(","); q.breakable() |
| 6563 | q.text("data = "); |
| 6564 | q.pp(self.data) |
| 6565 | q.breakable() |
| 6566 | q.text('}') |
| 6567 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6568 | message.subtypes[13] = packet_out |
| 6569 | |
| 6570 | class port_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6571 | version = 2 |
| 6572 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6573 | |
| 6574 | 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] | 6575 | if xid != None: |
| 6576 | self.xid = xid |
| 6577 | else: |
| 6578 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6579 | if port_no != None: |
| 6580 | self.port_no = port_no |
| 6581 | else: |
| 6582 | self.port_no = 0 |
| 6583 | if hw_addr != None: |
| 6584 | self.hw_addr = hw_addr |
| 6585 | else: |
| 6586 | self.hw_addr = [0,0,0,0,0,0] |
| 6587 | if config != None: |
| 6588 | self.config = config |
| 6589 | else: |
| 6590 | self.config = 0 |
| 6591 | if mask != None: |
| 6592 | self.mask = mask |
| 6593 | else: |
| 6594 | self.mask = 0 |
| 6595 | if advertise != None: |
| 6596 | self.advertise = advertise |
| 6597 | else: |
| 6598 | self.advertise = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6599 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6600 | |
| 6601 | def pack(self): |
| 6602 | packed = [] |
| 6603 | packed.append(struct.pack("!B", self.version)) |
| 6604 | packed.append(struct.pack("!B", self.type)) |
| 6605 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6606 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6607 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6608 | packed.append('\x00' * 4) |
| 6609 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 6610 | packed.append('\x00' * 2) |
| 6611 | packed.append(struct.pack("!L", self.config)) |
| 6612 | packed.append(struct.pack("!L", self.mask)) |
| 6613 | packed.append(struct.pack("!L", self.advertise)) |
| 6614 | packed.append('\x00' * 4) |
| 6615 | length = sum([len(x) for x in packed]) |
| 6616 | packed[2] = struct.pack("!H", length) |
| 6617 | return ''.join(packed) |
| 6618 | |
| 6619 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6620 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6621 | obj = port_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6622 | _version = reader.read("!B")[0] |
| 6623 | assert(_version == 2) |
| 6624 | _type = reader.read("!B")[0] |
| 6625 | assert(_type == 16) |
| 6626 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6627 | orig_reader = reader |
| 6628 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6629 | obj.xid = reader.read("!L")[0] |
| 6630 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6631 | reader.skip(4) |
| 6632 | obj.hw_addr = list(reader.read('!6B')) |
| 6633 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6634 | obj.config = reader.read("!L")[0] |
| 6635 | obj.mask = reader.read("!L")[0] |
| 6636 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6637 | reader.skip(4) |
| 6638 | return obj |
| 6639 | |
| 6640 | def __eq__(self, other): |
| 6641 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6642 | if self.xid != other.xid: return False |
| 6643 | if self.port_no != other.port_no: return False |
| 6644 | if self.hw_addr != other.hw_addr: return False |
| 6645 | if self.config != other.config: return False |
| 6646 | if self.mask != other.mask: return False |
| 6647 | if self.advertise != other.advertise: return False |
| 6648 | return True |
| 6649 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6650 | def pretty_print(self, q): |
| 6651 | q.text("port_mod {") |
| 6652 | with q.group(): |
| 6653 | with q.indent(2): |
| 6654 | q.breakable() |
| 6655 | q.text("xid = "); |
| 6656 | if self.xid != None: |
| 6657 | q.text("%#x" % self.xid) |
| 6658 | else: |
| 6659 | q.text('None') |
| 6660 | q.text(","); q.breakable() |
| 6661 | q.text("port_no = "); |
| 6662 | q.text(util.pretty_port(self.port_no)) |
| 6663 | q.text(","); q.breakable() |
| 6664 | q.text("hw_addr = "); |
| 6665 | q.text(util.pretty_mac(self.hw_addr)) |
| 6666 | q.text(","); q.breakable() |
| 6667 | q.text("config = "); |
| 6668 | q.text("%#x" % self.config) |
| 6669 | q.text(","); q.breakable() |
| 6670 | q.text("mask = "); |
| 6671 | q.text("%#x" % self.mask) |
| 6672 | q.text(","); q.breakable() |
| 6673 | q.text("advertise = "); |
| 6674 | q.text("%#x" % self.advertise) |
| 6675 | q.breakable() |
| 6676 | q.text('}') |
| 6677 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6678 | message.subtypes[16] = port_mod |
| 6679 | |
| 6680 | class port_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6681 | version = 2 |
| 6682 | type = 1 |
| 6683 | err_type = 7 |
| 6684 | |
| 6685 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6686 | if xid != None: |
| 6687 | self.xid = xid |
| 6688 | else: |
| 6689 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6690 | if code != None: |
| 6691 | self.code = code |
| 6692 | else: |
| 6693 | self.code = 0 |
| 6694 | if data != None: |
| 6695 | self.data = data |
| 6696 | else: |
| 6697 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6698 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6699 | |
| 6700 | def pack(self): |
| 6701 | packed = [] |
| 6702 | packed.append(struct.pack("!B", self.version)) |
| 6703 | packed.append(struct.pack("!B", self.type)) |
| 6704 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6705 | packed.append(struct.pack("!L", self.xid)) |
| 6706 | packed.append(struct.pack("!H", self.err_type)) |
| 6707 | packed.append(struct.pack("!H", self.code)) |
| 6708 | packed.append(self.data) |
| 6709 | length = sum([len(x) for x in packed]) |
| 6710 | packed[2] = struct.pack("!H", length) |
| 6711 | return ''.join(packed) |
| 6712 | |
| 6713 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6714 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6715 | obj = port_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6716 | _version = reader.read("!B")[0] |
| 6717 | assert(_version == 2) |
| 6718 | _type = reader.read("!B")[0] |
| 6719 | assert(_type == 1) |
| 6720 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6721 | orig_reader = reader |
| 6722 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6723 | obj.xid = reader.read("!L")[0] |
| 6724 | _err_type = reader.read("!H")[0] |
| 6725 | assert(_err_type == 7) |
| 6726 | obj.code = reader.read("!H")[0] |
| 6727 | obj.data = str(reader.read_all()) |
| 6728 | return obj |
| 6729 | |
| 6730 | def __eq__(self, other): |
| 6731 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6732 | if self.xid != other.xid: return False |
| 6733 | if self.code != other.code: return False |
| 6734 | if self.data != other.data: return False |
| 6735 | return True |
| 6736 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6737 | def pretty_print(self, q): |
| 6738 | q.text("port_mod_failed_error_msg {") |
| 6739 | with q.group(): |
| 6740 | with q.indent(2): |
| 6741 | q.breakable() |
| 6742 | q.text("xid = "); |
| 6743 | if self.xid != None: |
| 6744 | q.text("%#x" % self.xid) |
| 6745 | else: |
| 6746 | q.text('None') |
| 6747 | q.text(","); q.breakable() |
| 6748 | q.text("code = "); |
| 6749 | q.text("%#x" % self.code) |
| 6750 | q.text(","); q.breakable() |
| 6751 | q.text("data = "); |
| 6752 | q.pp(self.data) |
| 6753 | q.breakable() |
| 6754 | q.text('}') |
| 6755 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6756 | error_msg.subtypes[7] = port_mod_failed_error_msg |
| 6757 | |
| 6758 | class port_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6759 | version = 2 |
| 6760 | type = 19 |
| 6761 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6762 | |
| 6763 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6764 | if xid != None: |
| 6765 | self.xid = xid |
| 6766 | else: |
| 6767 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6768 | if flags != None: |
| 6769 | self.flags = flags |
| 6770 | else: |
| 6771 | self.flags = 0 |
| 6772 | if entries != None: |
| 6773 | self.entries = entries |
| 6774 | else: |
| 6775 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6776 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6777 | |
| 6778 | def pack(self): |
| 6779 | packed = [] |
| 6780 | packed.append(struct.pack("!B", self.version)) |
| 6781 | packed.append(struct.pack("!B", self.type)) |
| 6782 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6783 | packed.append(struct.pack("!L", self.xid)) |
| 6784 | packed.append(struct.pack("!H", self.stats_type)) |
| 6785 | packed.append(struct.pack("!H", self.flags)) |
| 6786 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6787 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6788 | length = sum([len(x) for x in packed]) |
| 6789 | packed[2] = struct.pack("!H", length) |
| 6790 | return ''.join(packed) |
| 6791 | |
| 6792 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6793 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6794 | obj = port_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6795 | _version = reader.read("!B")[0] |
| 6796 | assert(_version == 2) |
| 6797 | _type = reader.read("!B")[0] |
| 6798 | assert(_type == 19) |
| 6799 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6800 | orig_reader = reader |
| 6801 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6802 | obj.xid = reader.read("!L")[0] |
| 6803 | _stats_type = reader.read("!H")[0] |
| 6804 | assert(_stats_type == 4) |
| 6805 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6806 | reader.skip(4) |
| 6807 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 6808 | return obj |
| 6809 | |
| 6810 | def __eq__(self, other): |
| 6811 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6812 | if self.xid != other.xid: return False |
| 6813 | if self.flags != other.flags: return False |
| 6814 | if self.entries != other.entries: return False |
| 6815 | return True |
| 6816 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6817 | def pretty_print(self, q): |
| 6818 | q.text("port_stats_reply {") |
| 6819 | with q.group(): |
| 6820 | with q.indent(2): |
| 6821 | q.breakable() |
| 6822 | q.text("xid = "); |
| 6823 | if self.xid != None: |
| 6824 | q.text("%#x" % self.xid) |
| 6825 | else: |
| 6826 | q.text('None') |
| 6827 | q.text(","); q.breakable() |
| 6828 | q.text("flags = "); |
| 6829 | q.text("%#x" % self.flags) |
| 6830 | q.text(","); q.breakable() |
| 6831 | q.text("entries = "); |
| 6832 | q.pp(self.entries) |
| 6833 | q.breakable() |
| 6834 | q.text('}') |
| 6835 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6836 | stats_reply.subtypes[4] = port_stats_reply |
| 6837 | |
| 6838 | class port_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6839 | version = 2 |
| 6840 | type = 18 |
| 6841 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6842 | |
| 6843 | def __init__(self, xid=None, flags=None, port_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6844 | if xid != None: |
| 6845 | self.xid = xid |
| 6846 | else: |
| 6847 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6848 | if flags != None: |
| 6849 | self.flags = flags |
| 6850 | else: |
| 6851 | self.flags = 0 |
| 6852 | if port_no != None: |
| 6853 | self.port_no = port_no |
| 6854 | else: |
| 6855 | self.port_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6856 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6857 | |
| 6858 | def pack(self): |
| 6859 | packed = [] |
| 6860 | packed.append(struct.pack("!B", self.version)) |
| 6861 | packed.append(struct.pack("!B", self.type)) |
| 6862 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6863 | packed.append(struct.pack("!L", self.xid)) |
| 6864 | packed.append(struct.pack("!H", self.stats_type)) |
| 6865 | packed.append(struct.pack("!H", self.flags)) |
| 6866 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6867 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6868 | packed.append('\x00' * 4) |
| 6869 | length = sum([len(x) for x in packed]) |
| 6870 | packed[2] = struct.pack("!H", length) |
| 6871 | return ''.join(packed) |
| 6872 | |
| 6873 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6874 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6875 | obj = port_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6876 | _version = reader.read("!B")[0] |
| 6877 | assert(_version == 2) |
| 6878 | _type = reader.read("!B")[0] |
| 6879 | assert(_type == 18) |
| 6880 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6881 | orig_reader = reader |
| 6882 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6883 | obj.xid = reader.read("!L")[0] |
| 6884 | _stats_type = reader.read("!H")[0] |
| 6885 | assert(_stats_type == 4) |
| 6886 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6887 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6888 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6889 | reader.skip(4) |
| 6890 | return obj |
| 6891 | |
| 6892 | def __eq__(self, other): |
| 6893 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6894 | if self.xid != other.xid: return False |
| 6895 | if self.flags != other.flags: return False |
| 6896 | if self.port_no != other.port_no: return False |
| 6897 | return True |
| 6898 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6899 | def pretty_print(self, q): |
| 6900 | q.text("port_stats_request {") |
| 6901 | with q.group(): |
| 6902 | with q.indent(2): |
| 6903 | q.breakable() |
| 6904 | q.text("xid = "); |
| 6905 | if self.xid != None: |
| 6906 | q.text("%#x" % self.xid) |
| 6907 | else: |
| 6908 | q.text('None') |
| 6909 | q.text(","); q.breakable() |
| 6910 | q.text("flags = "); |
| 6911 | q.text("%#x" % self.flags) |
| 6912 | q.text(","); q.breakable() |
| 6913 | q.text("port_no = "); |
| 6914 | q.text(util.pretty_port(self.port_no)) |
| 6915 | q.breakable() |
| 6916 | q.text('}') |
| 6917 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6918 | stats_request.subtypes[4] = port_stats_request |
| 6919 | |
| 6920 | class port_status(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6921 | version = 2 |
| 6922 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6923 | |
| 6924 | def __init__(self, xid=None, reason=None, desc=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6925 | if xid != None: |
| 6926 | self.xid = xid |
| 6927 | else: |
| 6928 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6929 | if reason != None: |
| 6930 | self.reason = reason |
| 6931 | else: |
| 6932 | self.reason = 0 |
| 6933 | if desc != None: |
| 6934 | self.desc = desc |
| 6935 | else: |
| 6936 | self.desc = common.port_desc() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6937 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6938 | |
| 6939 | def pack(self): |
| 6940 | packed = [] |
| 6941 | packed.append(struct.pack("!B", self.version)) |
| 6942 | packed.append(struct.pack("!B", self.type)) |
| 6943 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6944 | packed.append(struct.pack("!L", self.xid)) |
| 6945 | packed.append(struct.pack("!B", self.reason)) |
| 6946 | packed.append('\x00' * 7) |
| 6947 | packed.append(self.desc.pack()) |
| 6948 | length = sum([len(x) for x in packed]) |
| 6949 | packed[2] = struct.pack("!H", length) |
| 6950 | return ''.join(packed) |
| 6951 | |
| 6952 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6953 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6954 | obj = port_status() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6955 | _version = reader.read("!B")[0] |
| 6956 | assert(_version == 2) |
| 6957 | _type = reader.read("!B")[0] |
| 6958 | assert(_type == 12) |
| 6959 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6960 | orig_reader = reader |
| 6961 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6962 | obj.xid = reader.read("!L")[0] |
| 6963 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6964 | reader.skip(7) |
| 6965 | obj.desc = common.port_desc.unpack(reader) |
| 6966 | return obj |
| 6967 | |
| 6968 | def __eq__(self, other): |
| 6969 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6970 | if self.xid != other.xid: return False |
| 6971 | if self.reason != other.reason: return False |
| 6972 | if self.desc != other.desc: return False |
| 6973 | return True |
| 6974 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6975 | def pretty_print(self, q): |
| 6976 | q.text("port_status {") |
| 6977 | with q.group(): |
| 6978 | with q.indent(2): |
| 6979 | q.breakable() |
| 6980 | q.text("xid = "); |
| 6981 | if self.xid != None: |
| 6982 | q.text("%#x" % self.xid) |
| 6983 | else: |
| 6984 | q.text('None') |
| 6985 | q.text(","); q.breakable() |
| 6986 | q.text("reason = "); |
| 6987 | q.text("%#x" % self.reason) |
| 6988 | q.text(","); q.breakable() |
| 6989 | q.text("desc = "); |
| 6990 | q.pp(self.desc) |
| 6991 | q.breakable() |
| 6992 | q.text('}') |
| 6993 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6994 | message.subtypes[12] = port_status |
| 6995 | |
| 6996 | class queue_get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6997 | version = 2 |
| 6998 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6999 | |
| 7000 | def __init__(self, xid=None, port=None, queues=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7001 | if xid != None: |
| 7002 | self.xid = xid |
| 7003 | else: |
| 7004 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7005 | if port != None: |
| 7006 | self.port = port |
| 7007 | else: |
| 7008 | self.port = 0 |
| 7009 | if queues != None: |
| 7010 | self.queues = queues |
| 7011 | else: |
| 7012 | self.queues = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7013 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7014 | |
| 7015 | def pack(self): |
| 7016 | packed = [] |
| 7017 | packed.append(struct.pack("!B", self.version)) |
| 7018 | packed.append(struct.pack("!B", self.type)) |
| 7019 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7020 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7021 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7022 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7023 | packed.append(loxi.generic_util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7024 | length = sum([len(x) for x in packed]) |
| 7025 | packed[2] = struct.pack("!H", length) |
| 7026 | return ''.join(packed) |
| 7027 | |
| 7028 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7029 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7030 | obj = queue_get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7031 | _version = reader.read("!B")[0] |
| 7032 | assert(_version == 2) |
| 7033 | _type = reader.read("!B")[0] |
| 7034 | assert(_type == 23) |
| 7035 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7036 | orig_reader = reader |
| 7037 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7038 | obj.xid = reader.read("!L")[0] |
| 7039 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7040 | reader.skip(4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7041 | obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7042 | return obj |
| 7043 | |
| 7044 | def __eq__(self, other): |
| 7045 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7046 | if self.xid != other.xid: return False |
| 7047 | if self.port != other.port: return False |
| 7048 | if self.queues != other.queues: return False |
| 7049 | return True |
| 7050 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7051 | def pretty_print(self, q): |
| 7052 | q.text("queue_get_config_reply {") |
| 7053 | with q.group(): |
| 7054 | with q.indent(2): |
| 7055 | q.breakable() |
| 7056 | q.text("xid = "); |
| 7057 | if self.xid != None: |
| 7058 | q.text("%#x" % self.xid) |
| 7059 | else: |
| 7060 | q.text('None') |
| 7061 | q.text(","); q.breakable() |
| 7062 | q.text("port = "); |
| 7063 | q.text(util.pretty_port(self.port)) |
| 7064 | q.text(","); q.breakable() |
| 7065 | q.text("queues = "); |
| 7066 | q.pp(self.queues) |
| 7067 | q.breakable() |
| 7068 | q.text('}') |
| 7069 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7070 | message.subtypes[23] = queue_get_config_reply |
| 7071 | |
| 7072 | class queue_get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7073 | version = 2 |
| 7074 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7075 | |
| 7076 | def __init__(self, xid=None, port=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7077 | if xid != None: |
| 7078 | self.xid = xid |
| 7079 | else: |
| 7080 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7081 | if port != None: |
| 7082 | self.port = port |
| 7083 | else: |
| 7084 | self.port = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7085 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7086 | |
| 7087 | def pack(self): |
| 7088 | packed = [] |
| 7089 | packed.append(struct.pack("!B", self.version)) |
| 7090 | packed.append(struct.pack("!B", self.type)) |
| 7091 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7092 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7093 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7094 | packed.append('\x00' * 4) |
| 7095 | length = sum([len(x) for x in packed]) |
| 7096 | packed[2] = struct.pack("!H", length) |
| 7097 | return ''.join(packed) |
| 7098 | |
| 7099 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7100 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7101 | obj = queue_get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7102 | _version = reader.read("!B")[0] |
| 7103 | assert(_version == 2) |
| 7104 | _type = reader.read("!B")[0] |
| 7105 | assert(_type == 22) |
| 7106 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7107 | orig_reader = reader |
| 7108 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7109 | obj.xid = reader.read("!L")[0] |
| 7110 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7111 | reader.skip(4) |
| 7112 | return obj |
| 7113 | |
| 7114 | def __eq__(self, other): |
| 7115 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7116 | if self.xid != other.xid: return False |
| 7117 | if self.port != other.port: return False |
| 7118 | return True |
| 7119 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7120 | def pretty_print(self, q): |
| 7121 | q.text("queue_get_config_request {") |
| 7122 | with q.group(): |
| 7123 | with q.indent(2): |
| 7124 | q.breakable() |
| 7125 | q.text("xid = "); |
| 7126 | if self.xid != None: |
| 7127 | q.text("%#x" % self.xid) |
| 7128 | else: |
| 7129 | q.text('None') |
| 7130 | q.text(","); q.breakable() |
| 7131 | q.text("port = "); |
| 7132 | q.text(util.pretty_port(self.port)) |
| 7133 | q.breakable() |
| 7134 | q.text('}') |
| 7135 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7136 | message.subtypes[22] = queue_get_config_request |
| 7137 | |
| 7138 | class queue_op_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7139 | version = 2 |
| 7140 | type = 1 |
| 7141 | err_type = 9 |
| 7142 | |
| 7143 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7144 | if xid != None: |
| 7145 | self.xid = xid |
| 7146 | else: |
| 7147 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7148 | if code != None: |
| 7149 | self.code = code |
| 7150 | else: |
| 7151 | self.code = 0 |
| 7152 | if data != None: |
| 7153 | self.data = data |
| 7154 | else: |
| 7155 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7156 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7157 | |
| 7158 | def pack(self): |
| 7159 | packed = [] |
| 7160 | packed.append(struct.pack("!B", self.version)) |
| 7161 | packed.append(struct.pack("!B", self.type)) |
| 7162 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7163 | packed.append(struct.pack("!L", self.xid)) |
| 7164 | packed.append(struct.pack("!H", self.err_type)) |
| 7165 | packed.append(struct.pack("!H", self.code)) |
| 7166 | packed.append(self.data) |
| 7167 | length = sum([len(x) for x in packed]) |
| 7168 | packed[2] = struct.pack("!H", length) |
| 7169 | return ''.join(packed) |
| 7170 | |
| 7171 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7172 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7173 | obj = queue_op_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7174 | _version = reader.read("!B")[0] |
| 7175 | assert(_version == 2) |
| 7176 | _type = reader.read("!B")[0] |
| 7177 | assert(_type == 1) |
| 7178 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7179 | orig_reader = reader |
| 7180 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7181 | obj.xid = reader.read("!L")[0] |
| 7182 | _err_type = reader.read("!H")[0] |
| 7183 | assert(_err_type == 9) |
| 7184 | obj.code = reader.read("!H")[0] |
| 7185 | obj.data = str(reader.read_all()) |
| 7186 | return obj |
| 7187 | |
| 7188 | def __eq__(self, other): |
| 7189 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7190 | if self.xid != other.xid: return False |
| 7191 | if self.code != other.code: return False |
| 7192 | if self.data != other.data: return False |
| 7193 | return True |
| 7194 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7195 | def pretty_print(self, q): |
| 7196 | q.text("queue_op_failed_error_msg {") |
| 7197 | with q.group(): |
| 7198 | with q.indent(2): |
| 7199 | q.breakable() |
| 7200 | q.text("xid = "); |
| 7201 | if self.xid != None: |
| 7202 | q.text("%#x" % self.xid) |
| 7203 | else: |
| 7204 | q.text('None') |
| 7205 | q.text(","); q.breakable() |
| 7206 | q.text("code = "); |
| 7207 | q.text("%#x" % self.code) |
| 7208 | q.text(","); q.breakable() |
| 7209 | q.text("data = "); |
| 7210 | q.pp(self.data) |
| 7211 | q.breakable() |
| 7212 | q.text('}') |
| 7213 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7214 | error_msg.subtypes[9] = queue_op_failed_error_msg |
| 7215 | |
| 7216 | class queue_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7217 | version = 2 |
| 7218 | type = 19 |
| 7219 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7220 | |
| 7221 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7222 | if xid != None: |
| 7223 | self.xid = xid |
| 7224 | else: |
| 7225 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7226 | if flags != None: |
| 7227 | self.flags = flags |
| 7228 | else: |
| 7229 | self.flags = 0 |
| 7230 | if entries != None: |
| 7231 | self.entries = entries |
| 7232 | else: |
| 7233 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7234 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7235 | |
| 7236 | def pack(self): |
| 7237 | packed = [] |
| 7238 | packed.append(struct.pack("!B", self.version)) |
| 7239 | packed.append(struct.pack("!B", self.type)) |
| 7240 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7241 | packed.append(struct.pack("!L", self.xid)) |
| 7242 | packed.append(struct.pack("!H", self.stats_type)) |
| 7243 | packed.append(struct.pack("!H", self.flags)) |
| 7244 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7245 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7246 | length = sum([len(x) for x in packed]) |
| 7247 | packed[2] = struct.pack("!H", length) |
| 7248 | return ''.join(packed) |
| 7249 | |
| 7250 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7251 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7252 | obj = queue_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7253 | _version = reader.read("!B")[0] |
| 7254 | assert(_version == 2) |
| 7255 | _type = reader.read("!B")[0] |
| 7256 | assert(_type == 19) |
| 7257 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7258 | orig_reader = reader |
| 7259 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7260 | obj.xid = reader.read("!L")[0] |
| 7261 | _stats_type = reader.read("!H")[0] |
| 7262 | assert(_stats_type == 5) |
| 7263 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7264 | reader.skip(4) |
| 7265 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 7266 | return obj |
| 7267 | |
| 7268 | def __eq__(self, other): |
| 7269 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7270 | if self.xid != other.xid: return False |
| 7271 | if self.flags != other.flags: return False |
| 7272 | if self.entries != other.entries: return False |
| 7273 | return True |
| 7274 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7275 | def pretty_print(self, q): |
| 7276 | q.text("queue_stats_reply {") |
| 7277 | with q.group(): |
| 7278 | with q.indent(2): |
| 7279 | q.breakable() |
| 7280 | q.text("xid = "); |
| 7281 | if self.xid != None: |
| 7282 | q.text("%#x" % self.xid) |
| 7283 | else: |
| 7284 | q.text('None') |
| 7285 | q.text(","); q.breakable() |
| 7286 | q.text("flags = "); |
| 7287 | q.text("%#x" % self.flags) |
| 7288 | q.text(","); q.breakable() |
| 7289 | q.text("entries = "); |
| 7290 | q.pp(self.entries) |
| 7291 | q.breakable() |
| 7292 | q.text('}') |
| 7293 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7294 | stats_reply.subtypes[5] = queue_stats_reply |
| 7295 | |
| 7296 | class queue_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7297 | version = 2 |
| 7298 | type = 18 |
| 7299 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7300 | |
| 7301 | 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] | 7302 | if xid != None: |
| 7303 | self.xid = xid |
| 7304 | else: |
| 7305 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7306 | if flags != None: |
| 7307 | self.flags = flags |
| 7308 | else: |
| 7309 | self.flags = 0 |
| 7310 | if port_no != None: |
| 7311 | self.port_no = port_no |
| 7312 | else: |
| 7313 | self.port_no = 0 |
| 7314 | if queue_id != None: |
| 7315 | self.queue_id = queue_id |
| 7316 | else: |
| 7317 | self.queue_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7318 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7319 | |
| 7320 | def pack(self): |
| 7321 | packed = [] |
| 7322 | packed.append(struct.pack("!B", self.version)) |
| 7323 | packed.append(struct.pack("!B", self.type)) |
| 7324 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7325 | packed.append(struct.pack("!L", self.xid)) |
| 7326 | packed.append(struct.pack("!H", self.stats_type)) |
| 7327 | packed.append(struct.pack("!H", self.flags)) |
| 7328 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7329 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7330 | packed.append(struct.pack("!L", self.queue_id)) |
| 7331 | length = sum([len(x) for x in packed]) |
| 7332 | packed[2] = struct.pack("!H", length) |
| 7333 | return ''.join(packed) |
| 7334 | |
| 7335 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7336 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7337 | obj = queue_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7338 | _version = reader.read("!B")[0] |
| 7339 | assert(_version == 2) |
| 7340 | _type = reader.read("!B")[0] |
| 7341 | assert(_type == 18) |
| 7342 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7343 | orig_reader = reader |
| 7344 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7345 | obj.xid = reader.read("!L")[0] |
| 7346 | _stats_type = reader.read("!H")[0] |
| 7347 | assert(_stats_type == 5) |
| 7348 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7349 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7350 | obj.port_no = util.unpack_port_no(reader) |
| 7351 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7352 | return obj |
| 7353 | |
| 7354 | def __eq__(self, other): |
| 7355 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7356 | if self.xid != other.xid: return False |
| 7357 | if self.flags != other.flags: return False |
| 7358 | if self.port_no != other.port_no: return False |
| 7359 | if self.queue_id != other.queue_id: return False |
| 7360 | return True |
| 7361 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7362 | def pretty_print(self, q): |
| 7363 | q.text("queue_stats_request {") |
| 7364 | with q.group(): |
| 7365 | with q.indent(2): |
| 7366 | q.breakable() |
| 7367 | q.text("xid = "); |
| 7368 | if self.xid != None: |
| 7369 | q.text("%#x" % self.xid) |
| 7370 | else: |
| 7371 | q.text('None') |
| 7372 | q.text(","); q.breakable() |
| 7373 | q.text("flags = "); |
| 7374 | q.text("%#x" % self.flags) |
| 7375 | q.text(","); q.breakable() |
| 7376 | q.text("port_no = "); |
| 7377 | q.text(util.pretty_port(self.port_no)) |
| 7378 | q.text(","); q.breakable() |
| 7379 | q.text("queue_id = "); |
| 7380 | q.text("%#x" % self.queue_id) |
| 7381 | q.breakable() |
| 7382 | q.text('}') |
| 7383 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7384 | stats_request.subtypes[5] = queue_stats_request |
| 7385 | |
| 7386 | class set_config(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7387 | version = 2 |
| 7388 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7389 | |
| 7390 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7391 | if xid != None: |
| 7392 | self.xid = xid |
| 7393 | else: |
| 7394 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7395 | if flags != None: |
| 7396 | self.flags = flags |
| 7397 | else: |
| 7398 | self.flags = 0 |
| 7399 | if miss_send_len != None: |
| 7400 | self.miss_send_len = miss_send_len |
| 7401 | else: |
| 7402 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7403 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7404 | |
| 7405 | def pack(self): |
| 7406 | packed = [] |
| 7407 | packed.append(struct.pack("!B", self.version)) |
| 7408 | packed.append(struct.pack("!B", self.type)) |
| 7409 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7410 | packed.append(struct.pack("!L", self.xid)) |
| 7411 | packed.append(struct.pack("!H", self.flags)) |
| 7412 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 7413 | length = sum([len(x) for x in packed]) |
| 7414 | packed[2] = struct.pack("!H", length) |
| 7415 | return ''.join(packed) |
| 7416 | |
| 7417 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7418 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7419 | obj = set_config() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7420 | _version = reader.read("!B")[0] |
| 7421 | assert(_version == 2) |
| 7422 | _type = reader.read("!B")[0] |
| 7423 | assert(_type == 9) |
| 7424 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7425 | orig_reader = reader |
| 7426 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7427 | obj.xid = reader.read("!L")[0] |
| 7428 | obj.flags = reader.read("!H")[0] |
| 7429 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7430 | return obj |
| 7431 | |
| 7432 | def __eq__(self, other): |
| 7433 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7434 | if self.xid != other.xid: return False |
| 7435 | if self.flags != other.flags: return False |
| 7436 | if self.miss_send_len != other.miss_send_len: return False |
| 7437 | return True |
| 7438 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7439 | def pretty_print(self, q): |
| 7440 | q.text("set_config {") |
| 7441 | with q.group(): |
| 7442 | with q.indent(2): |
| 7443 | q.breakable() |
| 7444 | q.text("xid = "); |
| 7445 | if self.xid != None: |
| 7446 | q.text("%#x" % self.xid) |
| 7447 | else: |
| 7448 | q.text('None') |
| 7449 | q.text(","); q.breakable() |
| 7450 | q.text("flags = "); |
| 7451 | q.text("%#x" % self.flags) |
| 7452 | q.text(","); q.breakable() |
| 7453 | q.text("miss_send_len = "); |
| 7454 | q.text("%#x" % self.miss_send_len) |
| 7455 | q.breakable() |
| 7456 | q.text('}') |
| 7457 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7458 | message.subtypes[9] = set_config |
| 7459 | |
| 7460 | class switch_config_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7461 | version = 2 |
| 7462 | type = 1 |
| 7463 | err_type = 10 |
| 7464 | |
| 7465 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7466 | if xid != None: |
| 7467 | self.xid = xid |
| 7468 | else: |
| 7469 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7470 | if code != None: |
| 7471 | self.code = code |
| 7472 | else: |
| 7473 | self.code = 0 |
| 7474 | if data != None: |
| 7475 | self.data = data |
| 7476 | else: |
| 7477 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7478 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7479 | |
| 7480 | def pack(self): |
| 7481 | packed = [] |
| 7482 | packed.append(struct.pack("!B", self.version)) |
| 7483 | packed.append(struct.pack("!B", self.type)) |
| 7484 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7485 | packed.append(struct.pack("!L", self.xid)) |
| 7486 | packed.append(struct.pack("!H", self.err_type)) |
| 7487 | packed.append(struct.pack("!H", self.code)) |
| 7488 | packed.append(self.data) |
| 7489 | length = sum([len(x) for x in packed]) |
| 7490 | packed[2] = struct.pack("!H", length) |
| 7491 | return ''.join(packed) |
| 7492 | |
| 7493 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7494 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7495 | obj = switch_config_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7496 | _version = reader.read("!B")[0] |
| 7497 | assert(_version == 2) |
| 7498 | _type = reader.read("!B")[0] |
| 7499 | assert(_type == 1) |
| 7500 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7501 | orig_reader = reader |
| 7502 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7503 | obj.xid = reader.read("!L")[0] |
| 7504 | _err_type = reader.read("!H")[0] |
| 7505 | assert(_err_type == 10) |
| 7506 | obj.code = reader.read("!H")[0] |
| 7507 | obj.data = str(reader.read_all()) |
| 7508 | return obj |
| 7509 | |
| 7510 | def __eq__(self, other): |
| 7511 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7512 | if self.xid != other.xid: return False |
| 7513 | if self.code != other.code: return False |
| 7514 | if self.data != other.data: return False |
| 7515 | return True |
| 7516 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7517 | def pretty_print(self, q): |
| 7518 | q.text("switch_config_failed_error_msg {") |
| 7519 | with q.group(): |
| 7520 | with q.indent(2): |
| 7521 | q.breakable() |
| 7522 | q.text("xid = "); |
| 7523 | if self.xid != None: |
| 7524 | q.text("%#x" % self.xid) |
| 7525 | else: |
| 7526 | q.text('None') |
| 7527 | q.text(","); q.breakable() |
| 7528 | q.text("code = "); |
| 7529 | q.text("%#x" % self.code) |
| 7530 | q.text(","); q.breakable() |
| 7531 | q.text("data = "); |
| 7532 | q.pp(self.data) |
| 7533 | q.breakable() |
| 7534 | q.text('}') |
| 7535 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7536 | error_msg.subtypes[10] = switch_config_failed_error_msg |
| 7537 | |
| 7538 | class table_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7539 | version = 2 |
| 7540 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7541 | |
| 7542 | def __init__(self, xid=None, table_id=None, config=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7543 | if xid != None: |
| 7544 | self.xid = xid |
| 7545 | else: |
| 7546 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7547 | if table_id != None: |
| 7548 | self.table_id = table_id |
| 7549 | else: |
| 7550 | self.table_id = 0 |
| 7551 | if config != None: |
| 7552 | self.config = config |
| 7553 | else: |
| 7554 | self.config = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7555 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7556 | |
| 7557 | def pack(self): |
| 7558 | packed = [] |
| 7559 | packed.append(struct.pack("!B", self.version)) |
| 7560 | packed.append(struct.pack("!B", self.type)) |
| 7561 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7562 | packed.append(struct.pack("!L", self.xid)) |
| 7563 | packed.append(struct.pack("!B", self.table_id)) |
| 7564 | packed.append('\x00' * 3) |
| 7565 | packed.append(struct.pack("!L", self.config)) |
| 7566 | length = sum([len(x) for x in packed]) |
| 7567 | packed[2] = struct.pack("!H", length) |
| 7568 | return ''.join(packed) |
| 7569 | |
| 7570 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7571 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7572 | obj = table_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7573 | _version = reader.read("!B")[0] |
| 7574 | assert(_version == 2) |
| 7575 | _type = reader.read("!B")[0] |
| 7576 | assert(_type == 17) |
| 7577 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7578 | orig_reader = reader |
| 7579 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7580 | obj.xid = reader.read("!L")[0] |
| 7581 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7582 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7583 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7584 | return obj |
| 7585 | |
| 7586 | def __eq__(self, other): |
| 7587 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7588 | if self.xid != other.xid: return False |
| 7589 | if self.table_id != other.table_id: return False |
| 7590 | if self.config != other.config: return False |
| 7591 | return True |
| 7592 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7593 | def pretty_print(self, q): |
| 7594 | q.text("table_mod {") |
| 7595 | with q.group(): |
| 7596 | with q.indent(2): |
| 7597 | q.breakable() |
| 7598 | q.text("xid = "); |
| 7599 | if self.xid != None: |
| 7600 | q.text("%#x" % self.xid) |
| 7601 | else: |
| 7602 | q.text('None') |
| 7603 | q.text(","); q.breakable() |
| 7604 | q.text("table_id = "); |
| 7605 | q.text("%#x" % self.table_id) |
| 7606 | q.text(","); q.breakable() |
| 7607 | q.text("config = "); |
| 7608 | q.text("%#x" % self.config) |
| 7609 | q.breakable() |
| 7610 | q.text('}') |
| 7611 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7612 | message.subtypes[17] = table_mod |
| 7613 | |
| 7614 | class table_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7615 | version = 2 |
| 7616 | type = 1 |
| 7617 | err_type = 8 |
| 7618 | |
| 7619 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7620 | if xid != None: |
| 7621 | self.xid = xid |
| 7622 | else: |
| 7623 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7624 | if code != None: |
| 7625 | self.code = code |
| 7626 | else: |
| 7627 | self.code = 0 |
| 7628 | if data != None: |
| 7629 | self.data = data |
| 7630 | else: |
| 7631 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7632 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7633 | |
| 7634 | def pack(self): |
| 7635 | packed = [] |
| 7636 | packed.append(struct.pack("!B", self.version)) |
| 7637 | packed.append(struct.pack("!B", self.type)) |
| 7638 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7639 | packed.append(struct.pack("!L", self.xid)) |
| 7640 | packed.append(struct.pack("!H", self.err_type)) |
| 7641 | packed.append(struct.pack("!H", self.code)) |
| 7642 | packed.append(self.data) |
| 7643 | length = sum([len(x) for x in packed]) |
| 7644 | packed[2] = struct.pack("!H", length) |
| 7645 | return ''.join(packed) |
| 7646 | |
| 7647 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7648 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7649 | obj = table_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7650 | _version = reader.read("!B")[0] |
| 7651 | assert(_version == 2) |
| 7652 | _type = reader.read("!B")[0] |
| 7653 | assert(_type == 1) |
| 7654 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7655 | orig_reader = reader |
| 7656 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7657 | obj.xid = reader.read("!L")[0] |
| 7658 | _err_type = reader.read("!H")[0] |
| 7659 | assert(_err_type == 8) |
| 7660 | obj.code = reader.read("!H")[0] |
| 7661 | obj.data = str(reader.read_all()) |
| 7662 | return obj |
| 7663 | |
| 7664 | def __eq__(self, other): |
| 7665 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7666 | if self.xid != other.xid: return False |
| 7667 | if self.code != other.code: return False |
| 7668 | if self.data != other.data: return False |
| 7669 | return True |
| 7670 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7671 | def pretty_print(self, q): |
| 7672 | q.text("table_mod_failed_error_msg {") |
| 7673 | with q.group(): |
| 7674 | with q.indent(2): |
| 7675 | q.breakable() |
| 7676 | q.text("xid = "); |
| 7677 | if self.xid != None: |
| 7678 | q.text("%#x" % self.xid) |
| 7679 | else: |
| 7680 | q.text('None') |
| 7681 | q.text(","); q.breakable() |
| 7682 | q.text("code = "); |
| 7683 | q.text("%#x" % self.code) |
| 7684 | q.text(","); q.breakable() |
| 7685 | q.text("data = "); |
| 7686 | q.pp(self.data) |
| 7687 | q.breakable() |
| 7688 | q.text('}') |
| 7689 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7690 | error_msg.subtypes[8] = table_mod_failed_error_msg |
| 7691 | |
| 7692 | class table_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7693 | version = 2 |
| 7694 | type = 19 |
| 7695 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7696 | |
| 7697 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7698 | if xid != None: |
| 7699 | self.xid = xid |
| 7700 | else: |
| 7701 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7702 | if flags != None: |
| 7703 | self.flags = flags |
| 7704 | else: |
| 7705 | self.flags = 0 |
| 7706 | if entries != None: |
| 7707 | self.entries = entries |
| 7708 | else: |
| 7709 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7710 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7711 | |
| 7712 | def pack(self): |
| 7713 | packed = [] |
| 7714 | packed.append(struct.pack("!B", self.version)) |
| 7715 | packed.append(struct.pack("!B", self.type)) |
| 7716 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7717 | packed.append(struct.pack("!L", self.xid)) |
| 7718 | packed.append(struct.pack("!H", self.stats_type)) |
| 7719 | packed.append(struct.pack("!H", self.flags)) |
| 7720 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7721 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7722 | length = sum([len(x) for x in packed]) |
| 7723 | packed[2] = struct.pack("!H", length) |
| 7724 | return ''.join(packed) |
| 7725 | |
| 7726 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7727 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7728 | obj = table_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7729 | _version = reader.read("!B")[0] |
| 7730 | assert(_version == 2) |
| 7731 | _type = reader.read("!B")[0] |
| 7732 | assert(_type == 19) |
| 7733 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7734 | orig_reader = reader |
| 7735 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7736 | obj.xid = reader.read("!L")[0] |
| 7737 | _stats_type = reader.read("!H")[0] |
| 7738 | assert(_stats_type == 3) |
| 7739 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7740 | reader.skip(4) |
| 7741 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 7742 | return obj |
| 7743 | |
| 7744 | def __eq__(self, other): |
| 7745 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7746 | if self.xid != other.xid: return False |
| 7747 | if self.flags != other.flags: return False |
| 7748 | if self.entries != other.entries: return False |
| 7749 | return True |
| 7750 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7751 | def pretty_print(self, q): |
| 7752 | q.text("table_stats_reply {") |
| 7753 | with q.group(): |
| 7754 | with q.indent(2): |
| 7755 | q.breakable() |
| 7756 | q.text("xid = "); |
| 7757 | if self.xid != None: |
| 7758 | q.text("%#x" % self.xid) |
| 7759 | else: |
| 7760 | q.text('None') |
| 7761 | q.text(","); q.breakable() |
| 7762 | q.text("flags = "); |
| 7763 | q.text("%#x" % self.flags) |
| 7764 | q.text(","); q.breakable() |
| 7765 | q.text("entries = "); |
| 7766 | q.pp(self.entries) |
| 7767 | q.breakable() |
| 7768 | q.text('}') |
| 7769 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7770 | stats_reply.subtypes[3] = table_stats_reply |
| 7771 | |
| 7772 | class table_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7773 | version = 2 |
| 7774 | type = 18 |
| 7775 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7776 | |
| 7777 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7778 | if xid != None: |
| 7779 | self.xid = xid |
| 7780 | else: |
| 7781 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7782 | if flags != None: |
| 7783 | self.flags = flags |
| 7784 | else: |
| 7785 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7786 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7787 | |
| 7788 | def pack(self): |
| 7789 | packed = [] |
| 7790 | packed.append(struct.pack("!B", self.version)) |
| 7791 | packed.append(struct.pack("!B", self.type)) |
| 7792 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7793 | packed.append(struct.pack("!L", self.xid)) |
| 7794 | packed.append(struct.pack("!H", self.stats_type)) |
| 7795 | packed.append(struct.pack("!H", self.flags)) |
| 7796 | packed.append('\x00' * 4) |
| 7797 | length = sum([len(x) for x in packed]) |
| 7798 | packed[2] = struct.pack("!H", length) |
| 7799 | return ''.join(packed) |
| 7800 | |
| 7801 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7802 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7803 | obj = table_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7804 | _version = reader.read("!B")[0] |
| 7805 | assert(_version == 2) |
| 7806 | _type = reader.read("!B")[0] |
| 7807 | assert(_type == 18) |
| 7808 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7809 | orig_reader = reader |
| 7810 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7811 | obj.xid = reader.read("!L")[0] |
| 7812 | _stats_type = reader.read("!H")[0] |
| 7813 | assert(_stats_type == 3) |
| 7814 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7815 | reader.skip(4) |
| 7816 | return obj |
| 7817 | |
| 7818 | def __eq__(self, other): |
| 7819 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7820 | if self.xid != other.xid: return False |
| 7821 | if self.flags != other.flags: return False |
| 7822 | return True |
| 7823 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7824 | def pretty_print(self, q): |
| 7825 | q.text("table_stats_request {") |
| 7826 | with q.group(): |
| 7827 | with q.indent(2): |
| 7828 | q.breakable() |
| 7829 | q.text("xid = "); |
| 7830 | if self.xid != None: |
| 7831 | q.text("%#x" % self.xid) |
| 7832 | else: |
| 7833 | q.text('None') |
| 7834 | q.text(","); q.breakable() |
| 7835 | q.text("flags = "); |
| 7836 | q.text("%#x" % self.flags) |
| 7837 | q.breakable() |
| 7838 | q.text('}') |
| 7839 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7840 | stats_request.subtypes[3] = table_stats_request |
| 7841 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7842 | |
| 7843 | def parse_header(buf): |
| 7844 | if len(buf) < 8: |
| 7845 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 7846 | return struct.unpack_from("!BBHL", buf) |
| 7847 | |
| 7848 | def parse_message(buf): |
| 7849 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 7850 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 7851 | 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] | 7852 | if len(buf) != msg_len: |
| 7853 | raise loxi.ProtocolError("incorrect message size") |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7854 | return message.unpack(loxi.generic_util.OFReader(buf)) |