Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6 | # Automatically generated by LOXI from template module.py |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7 | # Do not modify |
| 8 | |
| 9 | import struct |
| 10 | import loxi |
| 11 | import const |
| 12 | import common |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 13 | import action |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 14 | import util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 15 | import loxi.generic_util |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 16 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 17 | class message(loxi.OFObject): |
| 18 | subtypes = {} |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 19 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 20 | version = 1 |
| 21 | |
| 22 | def __init__(self, type=None, xid=None): |
| 23 | if type != None: |
| 24 | self.type = type |
| 25 | else: |
| 26 | self.type = 0 |
| 27 | if xid != None: |
| 28 | self.xid = xid |
| 29 | else: |
| 30 | self.xid = None |
| 31 | return |
| 32 | |
| 33 | def pack(self): |
| 34 | packed = [] |
| 35 | packed.append(struct.pack("!B", self.version)) |
| 36 | packed.append(struct.pack("!B", self.type)) |
| 37 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 38 | packed.append(struct.pack("!L", self.xid)) |
| 39 | length = sum([len(x) for x in packed]) |
| 40 | packed[2] = struct.pack("!H", length) |
| 41 | return ''.join(packed) |
| 42 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 43 | @staticmethod |
| 44 | def unpack(reader): |
| 45 | subtype, = reader.peek('B', 1) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 46 | subclass = message.subtypes.get(subtype) |
| 47 | if subclass: |
| 48 | return subclass.unpack(reader) |
| 49 | |
| 50 | obj = message() |
| 51 | _version = reader.read("!B")[0] |
| 52 | assert(_version == 1) |
| 53 | obj.type = reader.read("!B")[0] |
| 54 | _length = reader.read("!H")[0] |
| 55 | orig_reader = reader |
| 56 | reader = orig_reader.slice(_length - (2 + 2)) |
| 57 | obj.xid = reader.read("!L")[0] |
| 58 | return obj |
| 59 | |
| 60 | def __eq__(self, other): |
| 61 | if type(self) != type(other): return False |
| 62 | if self.type != other.type: return False |
| 63 | if self.xid != other.xid: return False |
| 64 | return True |
| 65 | |
| 66 | def pretty_print(self, q): |
| 67 | q.text("message {") |
| 68 | with q.group(): |
| 69 | with q.indent(2): |
| 70 | q.breakable() |
| 71 | q.text("xid = "); |
| 72 | if self.xid != None: |
| 73 | q.text("%#x" % self.xid) |
| 74 | else: |
| 75 | q.text('None') |
| 76 | q.breakable() |
| 77 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 78 | |
| 79 | |
| 80 | class stats_reply(message): |
| 81 | subtypes = {} |
| 82 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 83 | version = 1 |
| 84 | type = 17 |
| 85 | |
| 86 | def __init__(self, xid=None, stats_type=None, flags=None): |
| 87 | if xid != None: |
| 88 | self.xid = xid |
| 89 | else: |
| 90 | self.xid = None |
| 91 | if stats_type != None: |
| 92 | self.stats_type = stats_type |
| 93 | else: |
| 94 | self.stats_type = 0 |
| 95 | if flags != None: |
| 96 | self.flags = flags |
| 97 | else: |
| 98 | self.flags = 0 |
| 99 | return |
| 100 | |
| 101 | def pack(self): |
| 102 | packed = [] |
| 103 | packed.append(struct.pack("!B", self.version)) |
| 104 | packed.append(struct.pack("!B", self.type)) |
| 105 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 106 | packed.append(struct.pack("!L", self.xid)) |
| 107 | packed.append(struct.pack("!H", self.stats_type)) |
| 108 | packed.append(struct.pack("!H", self.flags)) |
| 109 | length = sum([len(x) for x in packed]) |
| 110 | packed[2] = struct.pack("!H", length) |
| 111 | return ''.join(packed) |
| 112 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 113 | @staticmethod |
| 114 | def unpack(reader): |
| 115 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 116 | subclass = stats_reply.subtypes.get(subtype) |
| 117 | if subclass: |
| 118 | return subclass.unpack(reader) |
| 119 | |
| 120 | obj = stats_reply() |
| 121 | _version = reader.read("!B")[0] |
| 122 | assert(_version == 1) |
| 123 | _type = reader.read("!B")[0] |
| 124 | assert(_type == 17) |
| 125 | _length = reader.read("!H")[0] |
| 126 | orig_reader = reader |
| 127 | reader = orig_reader.slice(_length - (2 + 2)) |
| 128 | obj.xid = reader.read("!L")[0] |
| 129 | obj.stats_type = reader.read("!H")[0] |
| 130 | obj.flags = reader.read("!H")[0] |
| 131 | return obj |
| 132 | |
| 133 | def __eq__(self, other): |
| 134 | if type(self) != type(other): return False |
| 135 | if self.xid != other.xid: return False |
| 136 | if self.stats_type != other.stats_type: return False |
| 137 | if self.flags != other.flags: return False |
| 138 | return True |
| 139 | |
| 140 | def pretty_print(self, q): |
| 141 | q.text("stats_reply {") |
| 142 | with q.group(): |
| 143 | with q.indent(2): |
| 144 | q.breakable() |
| 145 | q.text("xid = "); |
| 146 | if self.xid != None: |
| 147 | q.text("%#x" % self.xid) |
| 148 | else: |
| 149 | q.text('None') |
| 150 | q.text(","); q.breakable() |
| 151 | q.text("flags = "); |
| 152 | q.text("%#x" % self.flags) |
| 153 | q.breakable() |
| 154 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 155 | |
| 156 | message.subtypes[17] = stats_reply |
| 157 | |
| 158 | class aggregate_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 159 | version = 1 |
| 160 | type = 17 |
| 161 | stats_type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 162 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 163 | 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] | 164 | if xid != None: |
| 165 | self.xid = xid |
| 166 | else: |
| 167 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 168 | if flags != None: |
| 169 | self.flags = flags |
| 170 | else: |
| 171 | self.flags = 0 |
| 172 | if packet_count != None: |
| 173 | self.packet_count = packet_count |
| 174 | else: |
| 175 | self.packet_count = 0 |
| 176 | if byte_count != None: |
| 177 | self.byte_count = byte_count |
| 178 | else: |
| 179 | self.byte_count = 0 |
| 180 | if flow_count != None: |
| 181 | self.flow_count = flow_count |
| 182 | else: |
| 183 | self.flow_count = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 184 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 185 | |
| 186 | def pack(self): |
| 187 | packed = [] |
| 188 | packed.append(struct.pack("!B", self.version)) |
| 189 | packed.append(struct.pack("!B", self.type)) |
| 190 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 191 | packed.append(struct.pack("!L", self.xid)) |
| 192 | packed.append(struct.pack("!H", self.stats_type)) |
| 193 | packed.append(struct.pack("!H", self.flags)) |
| 194 | packed.append(struct.pack("!Q", self.packet_count)) |
| 195 | packed.append(struct.pack("!Q", self.byte_count)) |
| 196 | packed.append(struct.pack("!L", self.flow_count)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 197 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 198 | length = sum([len(x) for x in packed]) |
| 199 | packed[2] = struct.pack("!H", length) |
| 200 | return ''.join(packed) |
| 201 | |
| 202 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 203 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 204 | obj = aggregate_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 205 | _version = reader.read("!B")[0] |
| 206 | assert(_version == 1) |
| 207 | _type = reader.read("!B")[0] |
| 208 | assert(_type == 17) |
| 209 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 210 | orig_reader = reader |
| 211 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 212 | obj.xid = reader.read("!L")[0] |
| 213 | _stats_type = reader.read("!H")[0] |
| 214 | assert(_stats_type == 2) |
| 215 | obj.flags = reader.read("!H")[0] |
| 216 | obj.packet_count = reader.read("!Q")[0] |
| 217 | obj.byte_count = reader.read("!Q")[0] |
| 218 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 219 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 220 | return obj |
| 221 | |
| 222 | def __eq__(self, other): |
| 223 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 224 | if self.xid != other.xid: return False |
| 225 | if self.flags != other.flags: return False |
| 226 | if self.packet_count != other.packet_count: return False |
| 227 | if self.byte_count != other.byte_count: return False |
| 228 | if self.flow_count != other.flow_count: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 229 | return True |
| 230 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 231 | def pretty_print(self, q): |
| 232 | q.text("aggregate_stats_reply {") |
| 233 | with q.group(): |
| 234 | with q.indent(2): |
| 235 | q.breakable() |
| 236 | q.text("xid = "); |
| 237 | if self.xid != None: |
| 238 | q.text("%#x" % self.xid) |
| 239 | else: |
| 240 | q.text('None') |
| 241 | q.text(","); q.breakable() |
| 242 | q.text("flags = "); |
| 243 | q.text("%#x" % self.flags) |
| 244 | q.text(","); q.breakable() |
| 245 | q.text("packet_count = "); |
| 246 | q.text("%#x" % self.packet_count) |
| 247 | q.text(","); q.breakable() |
| 248 | q.text("byte_count = "); |
| 249 | q.text("%#x" % self.byte_count) |
| 250 | q.text(","); q.breakable() |
| 251 | q.text("flow_count = "); |
| 252 | q.text("%#x" % self.flow_count) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 253 | q.breakable() |
| 254 | q.text('}') |
| 255 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 256 | stats_reply.subtypes[2] = aggregate_stats_reply |
| 257 | |
| 258 | class stats_request(message): |
| 259 | subtypes = {} |
| 260 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 261 | version = 1 |
| 262 | type = 16 |
| 263 | |
| 264 | def __init__(self, xid=None, stats_type=None, flags=None): |
| 265 | if xid != None: |
| 266 | self.xid = xid |
| 267 | else: |
| 268 | self.xid = None |
| 269 | if stats_type != None: |
| 270 | self.stats_type = stats_type |
| 271 | else: |
| 272 | self.stats_type = 0 |
| 273 | if flags != None: |
| 274 | self.flags = flags |
| 275 | else: |
| 276 | self.flags = 0 |
| 277 | return |
| 278 | |
| 279 | def pack(self): |
| 280 | packed = [] |
| 281 | packed.append(struct.pack("!B", self.version)) |
| 282 | packed.append(struct.pack("!B", self.type)) |
| 283 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 284 | packed.append(struct.pack("!L", self.xid)) |
| 285 | packed.append(struct.pack("!H", self.stats_type)) |
| 286 | packed.append(struct.pack("!H", self.flags)) |
| 287 | length = sum([len(x) for x in packed]) |
| 288 | packed[2] = struct.pack("!H", length) |
| 289 | return ''.join(packed) |
| 290 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 291 | @staticmethod |
| 292 | def unpack(reader): |
| 293 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 294 | subclass = stats_request.subtypes.get(subtype) |
| 295 | if subclass: |
| 296 | return subclass.unpack(reader) |
| 297 | |
| 298 | obj = stats_request() |
| 299 | _version = reader.read("!B")[0] |
| 300 | assert(_version == 1) |
| 301 | _type = reader.read("!B")[0] |
| 302 | assert(_type == 16) |
| 303 | _length = reader.read("!H")[0] |
| 304 | orig_reader = reader |
| 305 | reader = orig_reader.slice(_length - (2 + 2)) |
| 306 | obj.xid = reader.read("!L")[0] |
| 307 | obj.stats_type = reader.read("!H")[0] |
| 308 | obj.flags = reader.read("!H")[0] |
| 309 | return obj |
| 310 | |
| 311 | def __eq__(self, other): |
| 312 | if type(self) != type(other): return False |
| 313 | if self.xid != other.xid: return False |
| 314 | if self.stats_type != other.stats_type: return False |
| 315 | if self.flags != other.flags: return False |
| 316 | return True |
| 317 | |
| 318 | def pretty_print(self, q): |
| 319 | q.text("stats_request {") |
| 320 | with q.group(): |
| 321 | with q.indent(2): |
| 322 | q.breakable() |
| 323 | q.text("xid = "); |
| 324 | if self.xid != None: |
| 325 | q.text("%#x" % self.xid) |
| 326 | else: |
| 327 | q.text('None') |
| 328 | q.text(","); q.breakable() |
| 329 | q.text("flags = "); |
| 330 | q.text("%#x" % self.flags) |
| 331 | q.breakable() |
| 332 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 333 | |
| 334 | message.subtypes[16] = stats_request |
| 335 | |
| 336 | class aggregate_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 337 | version = 1 |
| 338 | type = 16 |
| 339 | stats_type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 340 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 341 | def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 342 | if xid != None: |
| 343 | self.xid = xid |
| 344 | else: |
| 345 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 346 | if flags != None: |
| 347 | self.flags = flags |
| 348 | else: |
| 349 | self.flags = 0 |
| 350 | if match != None: |
| 351 | self.match = match |
| 352 | else: |
| 353 | self.match = common.match() |
| 354 | if table_id != None: |
| 355 | self.table_id = table_id |
| 356 | else: |
| 357 | self.table_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 358 | if out_port != None: |
| 359 | self.out_port = out_port |
| 360 | else: |
| 361 | self.out_port = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 362 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 363 | |
| 364 | def pack(self): |
| 365 | packed = [] |
| 366 | packed.append(struct.pack("!B", self.version)) |
| 367 | packed.append(struct.pack("!B", self.type)) |
| 368 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 369 | packed.append(struct.pack("!L", self.xid)) |
| 370 | packed.append(struct.pack("!H", self.stats_type)) |
| 371 | packed.append(struct.pack("!H", self.flags)) |
| 372 | packed.append(self.match.pack()) |
| 373 | packed.append(struct.pack("!B", self.table_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 374 | packed.append('\x00' * 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 375 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 376 | length = sum([len(x) for x in packed]) |
| 377 | packed[2] = struct.pack("!H", length) |
| 378 | return ''.join(packed) |
| 379 | |
| 380 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 381 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 382 | obj = aggregate_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 383 | _version = reader.read("!B")[0] |
| 384 | assert(_version == 1) |
| 385 | _type = reader.read("!B")[0] |
| 386 | assert(_type == 16) |
| 387 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 388 | orig_reader = reader |
| 389 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 390 | obj.xid = reader.read("!L")[0] |
| 391 | _stats_type = reader.read("!H")[0] |
| 392 | assert(_stats_type == 2) |
| 393 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 394 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 395 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 396 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 397 | obj.out_port = util.unpack_port_no(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 398 | return obj |
| 399 | |
| 400 | def __eq__(self, other): |
| 401 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 402 | if self.xid != other.xid: return False |
| 403 | if self.flags != other.flags: return False |
| 404 | if self.match != other.match: return False |
| 405 | if self.table_id != other.table_id: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 406 | if self.out_port != other.out_port: return False |
| 407 | return True |
| 408 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 409 | def pretty_print(self, q): |
| 410 | q.text("aggregate_stats_request {") |
| 411 | with q.group(): |
| 412 | with q.indent(2): |
| 413 | q.breakable() |
| 414 | q.text("xid = "); |
| 415 | if self.xid != None: |
| 416 | q.text("%#x" % self.xid) |
| 417 | else: |
| 418 | q.text('None') |
| 419 | q.text(","); q.breakable() |
| 420 | q.text("flags = "); |
| 421 | q.text("%#x" % self.flags) |
| 422 | q.text(","); q.breakable() |
| 423 | q.text("match = "); |
| 424 | q.pp(self.match) |
| 425 | q.text(","); q.breakable() |
| 426 | q.text("table_id = "); |
| 427 | q.text("%#x" % self.table_id) |
| 428 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 429 | q.text("out_port = "); |
| 430 | q.text(util.pretty_port(self.out_port)) |
| 431 | q.breakable() |
| 432 | q.text('}') |
| 433 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 434 | stats_request.subtypes[2] = aggregate_stats_request |
| 435 | |
| 436 | class error_msg(message): |
| 437 | subtypes = {} |
| 438 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 439 | version = 1 |
| 440 | type = 1 |
| 441 | |
| 442 | def __init__(self, xid=None, err_type=None): |
| 443 | if xid != None: |
| 444 | self.xid = xid |
| 445 | else: |
| 446 | self.xid = None |
| 447 | if err_type != None: |
| 448 | self.err_type = err_type |
| 449 | else: |
| 450 | self.err_type = 0 |
| 451 | return |
| 452 | |
| 453 | def pack(self): |
| 454 | packed = [] |
| 455 | packed.append(struct.pack("!B", self.version)) |
| 456 | packed.append(struct.pack("!B", self.type)) |
| 457 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 458 | packed.append(struct.pack("!L", self.xid)) |
| 459 | packed.append(struct.pack("!H", self.err_type)) |
| 460 | length = sum([len(x) for x in packed]) |
| 461 | packed[2] = struct.pack("!H", length) |
| 462 | return ''.join(packed) |
| 463 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 464 | @staticmethod |
| 465 | def unpack(reader): |
| 466 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 467 | subclass = error_msg.subtypes.get(subtype) |
| 468 | if subclass: |
| 469 | return subclass.unpack(reader) |
| 470 | |
| 471 | obj = error_msg() |
| 472 | _version = reader.read("!B")[0] |
| 473 | assert(_version == 1) |
| 474 | _type = reader.read("!B")[0] |
| 475 | assert(_type == 1) |
| 476 | _length = reader.read("!H")[0] |
| 477 | orig_reader = reader |
| 478 | reader = orig_reader.slice(_length - (2 + 2)) |
| 479 | obj.xid = reader.read("!L")[0] |
| 480 | obj.err_type = reader.read("!H")[0] |
| 481 | return obj |
| 482 | |
| 483 | def __eq__(self, other): |
| 484 | if type(self) != type(other): return False |
| 485 | if self.xid != other.xid: return False |
| 486 | if self.err_type != other.err_type: return False |
| 487 | return True |
| 488 | |
| 489 | def pretty_print(self, q): |
| 490 | q.text("error_msg {") |
| 491 | with q.group(): |
| 492 | with q.indent(2): |
| 493 | q.breakable() |
| 494 | q.text("xid = "); |
| 495 | if self.xid != None: |
| 496 | q.text("%#x" % self.xid) |
| 497 | else: |
| 498 | q.text('None') |
| 499 | q.breakable() |
| 500 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 501 | |
| 502 | message.subtypes[1] = error_msg |
| 503 | |
| 504 | class bad_action_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 505 | version = 1 |
| 506 | type = 1 |
| 507 | err_type = 2 |
| 508 | |
| 509 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 510 | if xid != None: |
| 511 | self.xid = xid |
| 512 | else: |
| 513 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 514 | if code != None: |
| 515 | self.code = code |
| 516 | else: |
| 517 | self.code = 0 |
| 518 | if data != None: |
| 519 | self.data = data |
| 520 | else: |
| 521 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 522 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 523 | |
| 524 | def pack(self): |
| 525 | packed = [] |
| 526 | packed.append(struct.pack("!B", self.version)) |
| 527 | packed.append(struct.pack("!B", self.type)) |
| 528 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 529 | packed.append(struct.pack("!L", self.xid)) |
| 530 | packed.append(struct.pack("!H", self.err_type)) |
| 531 | packed.append(struct.pack("!H", self.code)) |
| 532 | packed.append(self.data) |
| 533 | length = sum([len(x) for x in packed]) |
| 534 | packed[2] = struct.pack("!H", length) |
| 535 | return ''.join(packed) |
| 536 | |
| 537 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 538 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 539 | obj = bad_action_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 540 | _version = reader.read("!B")[0] |
| 541 | assert(_version == 1) |
| 542 | _type = reader.read("!B")[0] |
| 543 | assert(_type == 1) |
| 544 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 545 | orig_reader = reader |
| 546 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 547 | obj.xid = reader.read("!L")[0] |
| 548 | _err_type = reader.read("!H")[0] |
| 549 | assert(_err_type == 2) |
| 550 | obj.code = reader.read("!H")[0] |
| 551 | obj.data = str(reader.read_all()) |
| 552 | return obj |
| 553 | |
| 554 | def __eq__(self, other): |
| 555 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 556 | if self.xid != other.xid: return False |
| 557 | if self.code != other.code: return False |
| 558 | if self.data != other.data: return False |
| 559 | return True |
| 560 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 561 | def pretty_print(self, q): |
| 562 | q.text("bad_action_error_msg {") |
| 563 | with q.group(): |
| 564 | with q.indent(2): |
| 565 | q.breakable() |
| 566 | q.text("xid = "); |
| 567 | if self.xid != None: |
| 568 | q.text("%#x" % self.xid) |
| 569 | else: |
| 570 | q.text('None') |
| 571 | q.text(","); q.breakable() |
| 572 | q.text("code = "); |
| 573 | q.text("%#x" % self.code) |
| 574 | q.text(","); q.breakable() |
| 575 | q.text("data = "); |
| 576 | q.pp(self.data) |
| 577 | q.breakable() |
| 578 | q.text('}') |
| 579 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 580 | error_msg.subtypes[2] = bad_action_error_msg |
| 581 | |
| 582 | class bad_request_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 583 | version = 1 |
| 584 | type = 1 |
| 585 | err_type = 1 |
| 586 | |
| 587 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 588 | if xid != None: |
| 589 | self.xid = xid |
| 590 | else: |
| 591 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 592 | if code != None: |
| 593 | self.code = code |
| 594 | else: |
| 595 | self.code = 0 |
| 596 | if data != None: |
| 597 | self.data = data |
| 598 | else: |
| 599 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 600 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 601 | |
| 602 | def pack(self): |
| 603 | packed = [] |
| 604 | packed.append(struct.pack("!B", self.version)) |
| 605 | packed.append(struct.pack("!B", self.type)) |
| 606 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 607 | packed.append(struct.pack("!L", self.xid)) |
| 608 | packed.append(struct.pack("!H", self.err_type)) |
| 609 | packed.append(struct.pack("!H", self.code)) |
| 610 | packed.append(self.data) |
| 611 | length = sum([len(x) for x in packed]) |
| 612 | packed[2] = struct.pack("!H", length) |
| 613 | return ''.join(packed) |
| 614 | |
| 615 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 616 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 617 | obj = bad_request_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 618 | _version = reader.read("!B")[0] |
| 619 | assert(_version == 1) |
| 620 | _type = reader.read("!B")[0] |
| 621 | assert(_type == 1) |
| 622 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 623 | orig_reader = reader |
| 624 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 625 | obj.xid = reader.read("!L")[0] |
| 626 | _err_type = reader.read("!H")[0] |
| 627 | assert(_err_type == 1) |
| 628 | obj.code = reader.read("!H")[0] |
| 629 | obj.data = str(reader.read_all()) |
| 630 | return obj |
| 631 | |
| 632 | def __eq__(self, other): |
| 633 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 634 | if self.xid != other.xid: return False |
| 635 | if self.code != other.code: return False |
| 636 | if self.data != other.data: return False |
| 637 | return True |
| 638 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 639 | def pretty_print(self, q): |
| 640 | q.text("bad_request_error_msg {") |
| 641 | with q.group(): |
| 642 | with q.indent(2): |
| 643 | q.breakable() |
| 644 | q.text("xid = "); |
| 645 | if self.xid != None: |
| 646 | q.text("%#x" % self.xid) |
| 647 | else: |
| 648 | q.text('None') |
| 649 | q.text(","); q.breakable() |
| 650 | q.text("code = "); |
| 651 | q.text("%#x" % self.code) |
| 652 | q.text(","); q.breakable() |
| 653 | q.text("data = "); |
| 654 | q.pp(self.data) |
| 655 | q.breakable() |
| 656 | q.text('}') |
| 657 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 658 | error_msg.subtypes[1] = bad_request_error_msg |
| 659 | |
| 660 | class barrier_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 661 | version = 1 |
| 662 | type = 19 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 663 | |
| 664 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 665 | if xid != None: |
| 666 | self.xid = xid |
| 667 | else: |
| 668 | self.xid = None |
| 669 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 670 | |
| 671 | def pack(self): |
| 672 | packed = [] |
| 673 | packed.append(struct.pack("!B", self.version)) |
| 674 | packed.append(struct.pack("!B", self.type)) |
| 675 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 676 | packed.append(struct.pack("!L", self.xid)) |
| 677 | length = sum([len(x) for x in packed]) |
| 678 | packed[2] = struct.pack("!H", length) |
| 679 | return ''.join(packed) |
| 680 | |
| 681 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 682 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 683 | obj = barrier_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 684 | _version = reader.read("!B")[0] |
| 685 | assert(_version == 1) |
| 686 | _type = reader.read("!B")[0] |
| 687 | assert(_type == 19) |
| 688 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 689 | orig_reader = reader |
| 690 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 691 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 692 | return obj |
| 693 | |
| 694 | def __eq__(self, other): |
| 695 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 696 | if self.xid != other.xid: return False |
| 697 | return True |
| 698 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 699 | def pretty_print(self, q): |
| 700 | q.text("barrier_reply {") |
| 701 | with q.group(): |
| 702 | with q.indent(2): |
| 703 | q.breakable() |
| 704 | q.text("xid = "); |
| 705 | if self.xid != None: |
| 706 | q.text("%#x" % self.xid) |
| 707 | else: |
| 708 | q.text('None') |
| 709 | q.breakable() |
| 710 | q.text('}') |
| 711 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 712 | message.subtypes[19] = barrier_reply |
| 713 | |
| 714 | class barrier_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 715 | version = 1 |
| 716 | type = 18 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 717 | |
| 718 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 719 | if xid != None: |
| 720 | self.xid = xid |
| 721 | else: |
| 722 | self.xid = None |
| 723 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 724 | |
| 725 | def pack(self): |
| 726 | packed = [] |
| 727 | packed.append(struct.pack("!B", self.version)) |
| 728 | packed.append(struct.pack("!B", self.type)) |
| 729 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 730 | packed.append(struct.pack("!L", self.xid)) |
| 731 | length = sum([len(x) for x in packed]) |
| 732 | packed[2] = struct.pack("!H", length) |
| 733 | return ''.join(packed) |
| 734 | |
| 735 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 736 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 737 | obj = barrier_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 738 | _version = reader.read("!B")[0] |
| 739 | assert(_version == 1) |
| 740 | _type = reader.read("!B")[0] |
| 741 | assert(_type == 18) |
| 742 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 743 | orig_reader = reader |
| 744 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 745 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 746 | return obj |
| 747 | |
| 748 | def __eq__(self, other): |
| 749 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 750 | if self.xid != other.xid: return False |
| 751 | return True |
| 752 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 753 | def pretty_print(self, q): |
| 754 | q.text("barrier_request {") |
| 755 | with q.group(): |
| 756 | with q.indent(2): |
| 757 | q.breakable() |
| 758 | q.text("xid = "); |
| 759 | if self.xid != None: |
| 760 | q.text("%#x" % self.xid) |
| 761 | else: |
| 762 | q.text('None') |
| 763 | q.breakable() |
| 764 | q.text('}') |
| 765 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 766 | message.subtypes[18] = barrier_request |
| 767 | |
| 768 | class experimenter(message): |
| 769 | subtypes = {} |
| 770 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 771 | version = 1 |
| 772 | type = 4 |
| 773 | |
| 774 | def __init__(self, xid=None, experimenter=None, subtype=None, data=None): |
| 775 | if xid != None: |
| 776 | self.xid = xid |
| 777 | else: |
| 778 | self.xid = None |
| 779 | if experimenter != None: |
| 780 | self.experimenter = experimenter |
| 781 | else: |
| 782 | self.experimenter = 0 |
| 783 | if subtype != None: |
| 784 | self.subtype = subtype |
| 785 | else: |
| 786 | self.subtype = 0 |
| 787 | if data != None: |
| 788 | self.data = data |
| 789 | else: |
| 790 | self.data = '' |
| 791 | return |
| 792 | |
| 793 | def pack(self): |
| 794 | packed = [] |
| 795 | packed.append(struct.pack("!B", self.version)) |
| 796 | packed.append(struct.pack("!B", self.type)) |
| 797 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 798 | packed.append(struct.pack("!L", self.xid)) |
| 799 | packed.append(struct.pack("!L", self.experimenter)) |
| 800 | packed.append(struct.pack("!L", self.subtype)) |
| 801 | packed.append(self.data) |
| 802 | length = sum([len(x) for x in packed]) |
| 803 | packed[2] = struct.pack("!H", length) |
| 804 | return ''.join(packed) |
| 805 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 806 | @staticmethod |
| 807 | def unpack(reader): |
| 808 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 809 | subclass = experimenter.subtypes.get(subtype) |
| 810 | if subclass: |
| 811 | return subclass.unpack(reader) |
| 812 | |
| 813 | obj = experimenter() |
| 814 | _version = reader.read("!B")[0] |
| 815 | assert(_version == 1) |
| 816 | _type = reader.read("!B")[0] |
| 817 | assert(_type == 4) |
| 818 | _length = reader.read("!H")[0] |
| 819 | orig_reader = reader |
| 820 | reader = orig_reader.slice(_length - (2 + 2)) |
| 821 | obj.xid = reader.read("!L")[0] |
| 822 | obj.experimenter = reader.read("!L")[0] |
| 823 | obj.subtype = reader.read("!L")[0] |
| 824 | obj.data = str(reader.read_all()) |
| 825 | return obj |
| 826 | |
| 827 | def __eq__(self, other): |
| 828 | if type(self) != type(other): return False |
| 829 | if self.xid != other.xid: return False |
| 830 | if self.experimenter != other.experimenter: return False |
| 831 | if self.subtype != other.subtype: return False |
| 832 | if self.data != other.data: return False |
| 833 | return True |
| 834 | |
| 835 | def pretty_print(self, q): |
| 836 | q.text("experimenter {") |
| 837 | with q.group(): |
| 838 | with q.indent(2): |
| 839 | q.breakable() |
| 840 | q.text("xid = "); |
| 841 | if self.xid != None: |
| 842 | q.text("%#x" % self.xid) |
| 843 | else: |
| 844 | q.text('None') |
| 845 | q.text(","); q.breakable() |
| 846 | q.text("subtype = "); |
| 847 | q.text("%#x" % self.subtype) |
| 848 | q.text(","); q.breakable() |
| 849 | q.text("data = "); |
| 850 | q.pp(self.data) |
| 851 | q.breakable() |
| 852 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 853 | |
| 854 | message.subtypes[4] = experimenter |
| 855 | |
| 856 | class bsn_header(experimenter): |
| 857 | subtypes = {} |
| 858 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 859 | version = 1 |
| 860 | type = 4 |
| 861 | experimenter = 6035143 |
| 862 | |
| 863 | def __init__(self, xid=None, subtype=None): |
| 864 | if xid != None: |
| 865 | self.xid = xid |
| 866 | else: |
| 867 | self.xid = None |
| 868 | if subtype != None: |
| 869 | self.subtype = subtype |
| 870 | else: |
| 871 | self.subtype = 0 |
| 872 | return |
| 873 | |
| 874 | def pack(self): |
| 875 | packed = [] |
| 876 | packed.append(struct.pack("!B", self.version)) |
| 877 | packed.append(struct.pack("!B", self.type)) |
| 878 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 879 | packed.append(struct.pack("!L", self.xid)) |
| 880 | packed.append(struct.pack("!L", self.experimenter)) |
| 881 | packed.append(struct.pack("!L", self.subtype)) |
| 882 | length = sum([len(x) for x in packed]) |
| 883 | packed[2] = struct.pack("!H", length) |
| 884 | return ''.join(packed) |
| 885 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 886 | @staticmethod |
| 887 | def unpack(reader): |
| 888 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 889 | subclass = bsn_header.subtypes.get(subtype) |
| 890 | if subclass: |
| 891 | return subclass.unpack(reader) |
| 892 | |
| 893 | obj = bsn_header() |
| 894 | _version = reader.read("!B")[0] |
| 895 | assert(_version == 1) |
| 896 | _type = reader.read("!B")[0] |
| 897 | assert(_type == 4) |
| 898 | _length = reader.read("!H")[0] |
| 899 | orig_reader = reader |
| 900 | reader = orig_reader.slice(_length - (2 + 2)) |
| 901 | obj.xid = reader.read("!L")[0] |
| 902 | _experimenter = reader.read("!L")[0] |
| 903 | assert(_experimenter == 6035143) |
| 904 | obj.subtype = reader.read("!L")[0] |
| 905 | return obj |
| 906 | |
| 907 | def __eq__(self, other): |
| 908 | if type(self) != type(other): return False |
| 909 | if self.xid != other.xid: return False |
| 910 | if self.subtype != other.subtype: return False |
| 911 | return True |
| 912 | |
| 913 | def pretty_print(self, q): |
| 914 | q.text("bsn_header {") |
| 915 | with q.group(): |
| 916 | with q.indent(2): |
| 917 | q.breakable() |
| 918 | q.text("xid = "); |
| 919 | if self.xid != None: |
| 920 | q.text("%#x" % self.xid) |
| 921 | else: |
| 922 | q.text('None') |
| 923 | q.breakable() |
| 924 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 925 | |
| 926 | experimenter.subtypes[6035143] = bsn_header |
| 927 | |
| 928 | class bsn_bw_clear_data_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 929 | version = 1 |
| 930 | type = 4 |
| 931 | experimenter = 6035143 |
| 932 | subtype = 22 |
| 933 | |
| 934 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 935 | if xid != None: |
| 936 | self.xid = xid |
| 937 | else: |
| 938 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 939 | if status != None: |
| 940 | self.status = status |
| 941 | else: |
| 942 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 943 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 944 | |
| 945 | def pack(self): |
| 946 | packed = [] |
| 947 | packed.append(struct.pack("!B", self.version)) |
| 948 | packed.append(struct.pack("!B", self.type)) |
| 949 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 950 | packed.append(struct.pack("!L", self.xid)) |
| 951 | packed.append(struct.pack("!L", self.experimenter)) |
| 952 | packed.append(struct.pack("!L", self.subtype)) |
| 953 | packed.append(struct.pack("!L", self.status)) |
| 954 | length = sum([len(x) for x in packed]) |
| 955 | packed[2] = struct.pack("!H", length) |
| 956 | return ''.join(packed) |
| 957 | |
| 958 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 959 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 960 | obj = bsn_bw_clear_data_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 961 | _version = reader.read("!B")[0] |
| 962 | assert(_version == 1) |
| 963 | _type = reader.read("!B")[0] |
| 964 | assert(_type == 4) |
| 965 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 966 | orig_reader = reader |
| 967 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 968 | obj.xid = reader.read("!L")[0] |
| 969 | _experimenter = reader.read("!L")[0] |
| 970 | assert(_experimenter == 6035143) |
| 971 | _subtype = reader.read("!L")[0] |
| 972 | assert(_subtype == 22) |
| 973 | obj.status = reader.read("!L")[0] |
| 974 | return obj |
| 975 | |
| 976 | def __eq__(self, other): |
| 977 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 978 | if self.xid != other.xid: return False |
| 979 | if self.status != other.status: return False |
| 980 | return True |
| 981 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 982 | def pretty_print(self, q): |
| 983 | q.text("bsn_bw_clear_data_reply {") |
| 984 | with q.group(): |
| 985 | with q.indent(2): |
| 986 | q.breakable() |
| 987 | q.text("xid = "); |
| 988 | if self.xid != None: |
| 989 | q.text("%#x" % self.xid) |
| 990 | else: |
| 991 | q.text('None') |
| 992 | q.text(","); q.breakable() |
| 993 | q.text("status = "); |
| 994 | q.text("%#x" % self.status) |
| 995 | q.breakable() |
| 996 | q.text('}') |
| 997 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 998 | bsn_header.subtypes[22] = bsn_bw_clear_data_reply |
| 999 | |
| 1000 | class bsn_bw_clear_data_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1001 | version = 1 |
| 1002 | type = 4 |
| 1003 | experimenter = 6035143 |
| 1004 | subtype = 21 |
| 1005 | |
| 1006 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1007 | if xid != None: |
| 1008 | self.xid = xid |
| 1009 | else: |
| 1010 | self.xid = None |
| 1011 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1012 | |
| 1013 | def pack(self): |
| 1014 | packed = [] |
| 1015 | packed.append(struct.pack("!B", self.version)) |
| 1016 | packed.append(struct.pack("!B", self.type)) |
| 1017 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1018 | packed.append(struct.pack("!L", self.xid)) |
| 1019 | packed.append(struct.pack("!L", self.experimenter)) |
| 1020 | packed.append(struct.pack("!L", self.subtype)) |
| 1021 | length = sum([len(x) for x in packed]) |
| 1022 | packed[2] = struct.pack("!H", length) |
| 1023 | return ''.join(packed) |
| 1024 | |
| 1025 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1026 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1027 | obj = bsn_bw_clear_data_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1028 | _version = reader.read("!B")[0] |
| 1029 | assert(_version == 1) |
| 1030 | _type = reader.read("!B")[0] |
| 1031 | assert(_type == 4) |
| 1032 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1033 | orig_reader = reader |
| 1034 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1035 | obj.xid = reader.read("!L")[0] |
| 1036 | _experimenter = reader.read("!L")[0] |
| 1037 | assert(_experimenter == 6035143) |
| 1038 | _subtype = reader.read("!L")[0] |
| 1039 | assert(_subtype == 21) |
| 1040 | return obj |
| 1041 | |
| 1042 | def __eq__(self, other): |
| 1043 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1044 | if self.xid != other.xid: return False |
| 1045 | return True |
| 1046 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1047 | def pretty_print(self, q): |
| 1048 | q.text("bsn_bw_clear_data_request {") |
| 1049 | with q.group(): |
| 1050 | with q.indent(2): |
| 1051 | q.breakable() |
| 1052 | q.text("xid = "); |
| 1053 | if self.xid != None: |
| 1054 | q.text("%#x" % self.xid) |
| 1055 | else: |
| 1056 | q.text('None') |
| 1057 | q.breakable() |
| 1058 | q.text('}') |
| 1059 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1060 | bsn_header.subtypes[21] = bsn_bw_clear_data_request |
| 1061 | |
| 1062 | class bsn_bw_enable_get_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1063 | version = 1 |
| 1064 | type = 4 |
| 1065 | experimenter = 6035143 |
| 1066 | subtype = 20 |
| 1067 | |
| 1068 | def __init__(self, xid=None, enabled=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1069 | if xid != None: |
| 1070 | self.xid = xid |
| 1071 | else: |
| 1072 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1073 | if enabled != None: |
| 1074 | self.enabled = enabled |
| 1075 | else: |
| 1076 | self.enabled = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1077 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1078 | |
| 1079 | def pack(self): |
| 1080 | packed = [] |
| 1081 | packed.append(struct.pack("!B", self.version)) |
| 1082 | packed.append(struct.pack("!B", self.type)) |
| 1083 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1084 | packed.append(struct.pack("!L", self.xid)) |
| 1085 | packed.append(struct.pack("!L", self.experimenter)) |
| 1086 | packed.append(struct.pack("!L", self.subtype)) |
| 1087 | packed.append(struct.pack("!L", self.enabled)) |
| 1088 | length = sum([len(x) for x in packed]) |
| 1089 | packed[2] = struct.pack("!H", length) |
| 1090 | return ''.join(packed) |
| 1091 | |
| 1092 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1093 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1094 | obj = bsn_bw_enable_get_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1095 | _version = reader.read("!B")[0] |
| 1096 | assert(_version == 1) |
| 1097 | _type = reader.read("!B")[0] |
| 1098 | assert(_type == 4) |
| 1099 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1100 | orig_reader = reader |
| 1101 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1102 | obj.xid = reader.read("!L")[0] |
| 1103 | _experimenter = reader.read("!L")[0] |
| 1104 | assert(_experimenter == 6035143) |
| 1105 | _subtype = reader.read("!L")[0] |
| 1106 | assert(_subtype == 20) |
| 1107 | obj.enabled = reader.read("!L")[0] |
| 1108 | return obj |
| 1109 | |
| 1110 | def __eq__(self, other): |
| 1111 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1112 | if self.xid != other.xid: return False |
| 1113 | if self.enabled != other.enabled: return False |
| 1114 | return True |
| 1115 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1116 | def pretty_print(self, q): |
| 1117 | q.text("bsn_bw_enable_get_reply {") |
| 1118 | with q.group(): |
| 1119 | with q.indent(2): |
| 1120 | q.breakable() |
| 1121 | q.text("xid = "); |
| 1122 | if self.xid != None: |
| 1123 | q.text("%#x" % self.xid) |
| 1124 | else: |
| 1125 | q.text('None') |
| 1126 | q.text(","); q.breakable() |
| 1127 | q.text("enabled = "); |
| 1128 | q.text("%#x" % self.enabled) |
| 1129 | q.breakable() |
| 1130 | q.text('}') |
| 1131 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1132 | bsn_header.subtypes[20] = bsn_bw_enable_get_reply |
| 1133 | |
| 1134 | class bsn_bw_enable_get_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1135 | version = 1 |
| 1136 | type = 4 |
| 1137 | experimenter = 6035143 |
| 1138 | subtype = 19 |
| 1139 | |
| 1140 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1141 | if xid != None: |
| 1142 | self.xid = xid |
| 1143 | else: |
| 1144 | self.xid = None |
| 1145 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1146 | |
| 1147 | def pack(self): |
| 1148 | packed = [] |
| 1149 | packed.append(struct.pack("!B", self.version)) |
| 1150 | packed.append(struct.pack("!B", self.type)) |
| 1151 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1152 | packed.append(struct.pack("!L", self.xid)) |
| 1153 | packed.append(struct.pack("!L", self.experimenter)) |
| 1154 | packed.append(struct.pack("!L", self.subtype)) |
| 1155 | length = sum([len(x) for x in packed]) |
| 1156 | packed[2] = struct.pack("!H", length) |
| 1157 | return ''.join(packed) |
| 1158 | |
| 1159 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1160 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1161 | obj = bsn_bw_enable_get_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1162 | _version = reader.read("!B")[0] |
| 1163 | assert(_version == 1) |
| 1164 | _type = reader.read("!B")[0] |
| 1165 | assert(_type == 4) |
| 1166 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1167 | orig_reader = reader |
| 1168 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1169 | obj.xid = reader.read("!L")[0] |
| 1170 | _experimenter = reader.read("!L")[0] |
| 1171 | assert(_experimenter == 6035143) |
| 1172 | _subtype = reader.read("!L")[0] |
| 1173 | assert(_subtype == 19) |
| 1174 | return obj |
| 1175 | |
| 1176 | def __eq__(self, other): |
| 1177 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1178 | if self.xid != other.xid: return False |
| 1179 | return True |
| 1180 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1181 | def pretty_print(self, q): |
| 1182 | q.text("bsn_bw_enable_get_request {") |
| 1183 | with q.group(): |
| 1184 | with q.indent(2): |
| 1185 | q.breakable() |
| 1186 | q.text("xid = "); |
| 1187 | if self.xid != None: |
| 1188 | q.text("%#x" % self.xid) |
| 1189 | else: |
| 1190 | q.text('None') |
| 1191 | q.breakable() |
| 1192 | q.text('}') |
| 1193 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1194 | bsn_header.subtypes[19] = bsn_bw_enable_get_request |
| 1195 | |
| 1196 | class bsn_bw_enable_set_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1197 | version = 1 |
| 1198 | type = 4 |
| 1199 | experimenter = 6035143 |
| 1200 | subtype = 23 |
| 1201 | |
| 1202 | def __init__(self, xid=None, enable=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1203 | if xid != None: |
| 1204 | self.xid = xid |
| 1205 | else: |
| 1206 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1207 | if enable != None: |
| 1208 | self.enable = enable |
| 1209 | else: |
| 1210 | self.enable = 0 |
| 1211 | if status != None: |
| 1212 | self.status = status |
| 1213 | else: |
| 1214 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1215 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1216 | |
| 1217 | def pack(self): |
| 1218 | packed = [] |
| 1219 | packed.append(struct.pack("!B", self.version)) |
| 1220 | packed.append(struct.pack("!B", self.type)) |
| 1221 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1222 | packed.append(struct.pack("!L", self.xid)) |
| 1223 | packed.append(struct.pack("!L", self.experimenter)) |
| 1224 | packed.append(struct.pack("!L", self.subtype)) |
| 1225 | packed.append(struct.pack("!L", self.enable)) |
| 1226 | packed.append(struct.pack("!L", self.status)) |
| 1227 | length = sum([len(x) for x in packed]) |
| 1228 | packed[2] = struct.pack("!H", length) |
| 1229 | return ''.join(packed) |
| 1230 | |
| 1231 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1232 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1233 | obj = bsn_bw_enable_set_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1234 | _version = reader.read("!B")[0] |
| 1235 | assert(_version == 1) |
| 1236 | _type = reader.read("!B")[0] |
| 1237 | assert(_type == 4) |
| 1238 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1239 | orig_reader = reader |
| 1240 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1241 | obj.xid = reader.read("!L")[0] |
| 1242 | _experimenter = reader.read("!L")[0] |
| 1243 | assert(_experimenter == 6035143) |
| 1244 | _subtype = reader.read("!L")[0] |
| 1245 | assert(_subtype == 23) |
| 1246 | obj.enable = reader.read("!L")[0] |
| 1247 | obj.status = reader.read("!L")[0] |
| 1248 | return obj |
| 1249 | |
| 1250 | def __eq__(self, other): |
| 1251 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1252 | if self.xid != other.xid: return False |
| 1253 | if self.enable != other.enable: return False |
| 1254 | if self.status != other.status: return False |
| 1255 | return True |
| 1256 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1257 | def pretty_print(self, q): |
| 1258 | q.text("bsn_bw_enable_set_reply {") |
| 1259 | with q.group(): |
| 1260 | with q.indent(2): |
| 1261 | q.breakable() |
| 1262 | q.text("xid = "); |
| 1263 | if self.xid != None: |
| 1264 | q.text("%#x" % self.xid) |
| 1265 | else: |
| 1266 | q.text('None') |
| 1267 | q.text(","); q.breakable() |
| 1268 | q.text("enable = "); |
| 1269 | q.text("%#x" % self.enable) |
| 1270 | q.text(","); q.breakable() |
| 1271 | q.text("status = "); |
| 1272 | q.text("%#x" % self.status) |
| 1273 | q.breakable() |
| 1274 | q.text('}') |
| 1275 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1276 | bsn_header.subtypes[23] = bsn_bw_enable_set_reply |
| 1277 | |
| 1278 | class bsn_bw_enable_set_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1279 | version = 1 |
| 1280 | type = 4 |
| 1281 | experimenter = 6035143 |
| 1282 | subtype = 18 |
| 1283 | |
| 1284 | def __init__(self, xid=None, enable=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1285 | if xid != None: |
| 1286 | self.xid = xid |
| 1287 | else: |
| 1288 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1289 | if enable != None: |
| 1290 | self.enable = enable |
| 1291 | else: |
| 1292 | self.enable = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1293 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1294 | |
| 1295 | def pack(self): |
| 1296 | packed = [] |
| 1297 | packed.append(struct.pack("!B", self.version)) |
| 1298 | packed.append(struct.pack("!B", self.type)) |
| 1299 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1300 | packed.append(struct.pack("!L", self.xid)) |
| 1301 | packed.append(struct.pack("!L", self.experimenter)) |
| 1302 | packed.append(struct.pack("!L", self.subtype)) |
| 1303 | packed.append(struct.pack("!L", self.enable)) |
| 1304 | length = sum([len(x) for x in packed]) |
| 1305 | packed[2] = struct.pack("!H", length) |
| 1306 | return ''.join(packed) |
| 1307 | |
| 1308 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1309 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1310 | obj = bsn_bw_enable_set_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1311 | _version = reader.read("!B")[0] |
| 1312 | assert(_version == 1) |
| 1313 | _type = reader.read("!B")[0] |
| 1314 | assert(_type == 4) |
| 1315 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1316 | orig_reader = reader |
| 1317 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1318 | obj.xid = reader.read("!L")[0] |
| 1319 | _experimenter = reader.read("!L")[0] |
| 1320 | assert(_experimenter == 6035143) |
| 1321 | _subtype = reader.read("!L")[0] |
| 1322 | assert(_subtype == 18) |
| 1323 | obj.enable = reader.read("!L")[0] |
| 1324 | return obj |
| 1325 | |
| 1326 | def __eq__(self, other): |
| 1327 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1328 | if self.xid != other.xid: return False |
| 1329 | if self.enable != other.enable: return False |
| 1330 | return True |
| 1331 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1332 | def pretty_print(self, q): |
| 1333 | q.text("bsn_bw_enable_set_request {") |
| 1334 | with q.group(): |
| 1335 | with q.indent(2): |
| 1336 | q.breakable() |
| 1337 | q.text("xid = "); |
| 1338 | if self.xid != None: |
| 1339 | q.text("%#x" % self.xid) |
| 1340 | else: |
| 1341 | q.text('None') |
| 1342 | q.text(","); q.breakable() |
| 1343 | q.text("enable = "); |
| 1344 | q.text("%#x" % self.enable) |
| 1345 | q.breakable() |
| 1346 | q.text('}') |
| 1347 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1348 | bsn_header.subtypes[18] = bsn_bw_enable_set_request |
| 1349 | |
| 1350 | class bsn_get_interfaces_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1351 | version = 1 |
| 1352 | type = 4 |
| 1353 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1354 | subtype = 10 |
| 1355 | |
| 1356 | def __init__(self, xid=None, interfaces=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1357 | if xid != None: |
| 1358 | self.xid = xid |
| 1359 | else: |
| 1360 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1361 | if interfaces != None: |
| 1362 | self.interfaces = interfaces |
| 1363 | else: |
| 1364 | self.interfaces = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1365 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1366 | |
| 1367 | def pack(self): |
| 1368 | packed = [] |
| 1369 | packed.append(struct.pack("!B", self.version)) |
| 1370 | packed.append(struct.pack("!B", self.type)) |
| 1371 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1372 | packed.append(struct.pack("!L", self.xid)) |
| 1373 | packed.append(struct.pack("!L", self.experimenter)) |
| 1374 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1375 | packed.append(loxi.generic_util.pack_list(self.interfaces)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1376 | length = sum([len(x) for x in packed]) |
| 1377 | packed[2] = struct.pack("!H", length) |
| 1378 | return ''.join(packed) |
| 1379 | |
| 1380 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1381 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1382 | obj = bsn_get_interfaces_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1383 | _version = reader.read("!B")[0] |
| 1384 | assert(_version == 1) |
| 1385 | _type = reader.read("!B")[0] |
| 1386 | assert(_type == 4) |
| 1387 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1388 | orig_reader = reader |
| 1389 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1390 | obj.xid = reader.read("!L")[0] |
| 1391 | _experimenter = reader.read("!L")[0] |
| 1392 | assert(_experimenter == 6035143) |
| 1393 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1394 | assert(_subtype == 10) |
| 1395 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1396 | return obj |
| 1397 | |
| 1398 | def __eq__(self, other): |
| 1399 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1400 | if self.xid != other.xid: return False |
| 1401 | if self.interfaces != other.interfaces: return False |
| 1402 | return True |
| 1403 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1404 | def pretty_print(self, q): |
| 1405 | q.text("bsn_get_interfaces_reply {") |
| 1406 | with q.group(): |
| 1407 | with q.indent(2): |
| 1408 | q.breakable() |
| 1409 | q.text("xid = "); |
| 1410 | if self.xid != None: |
| 1411 | q.text("%#x" % self.xid) |
| 1412 | else: |
| 1413 | q.text('None') |
| 1414 | q.text(","); q.breakable() |
| 1415 | q.text("interfaces = "); |
| 1416 | q.pp(self.interfaces) |
| 1417 | q.breakable() |
| 1418 | q.text('}') |
| 1419 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1420 | bsn_header.subtypes[10] = bsn_get_interfaces_reply |
| 1421 | |
| 1422 | class bsn_get_interfaces_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1423 | version = 1 |
| 1424 | type = 4 |
| 1425 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1426 | subtype = 9 |
| 1427 | |
| 1428 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1429 | if xid != None: |
| 1430 | self.xid = xid |
| 1431 | else: |
| 1432 | self.xid = None |
| 1433 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1434 | |
| 1435 | def pack(self): |
| 1436 | packed = [] |
| 1437 | packed.append(struct.pack("!B", self.version)) |
| 1438 | packed.append(struct.pack("!B", self.type)) |
| 1439 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1440 | packed.append(struct.pack("!L", self.xid)) |
| 1441 | packed.append(struct.pack("!L", self.experimenter)) |
| 1442 | packed.append(struct.pack("!L", self.subtype)) |
| 1443 | length = sum([len(x) for x in packed]) |
| 1444 | packed[2] = struct.pack("!H", length) |
| 1445 | return ''.join(packed) |
| 1446 | |
| 1447 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1448 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1449 | obj = bsn_get_interfaces_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1450 | _version = reader.read("!B")[0] |
| 1451 | assert(_version == 1) |
| 1452 | _type = reader.read("!B")[0] |
| 1453 | assert(_type == 4) |
| 1454 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1455 | orig_reader = reader |
| 1456 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1457 | obj.xid = reader.read("!L")[0] |
| 1458 | _experimenter = reader.read("!L")[0] |
| 1459 | assert(_experimenter == 6035143) |
| 1460 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1461 | assert(_subtype == 9) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1462 | return obj |
| 1463 | |
| 1464 | def __eq__(self, other): |
| 1465 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1466 | if self.xid != other.xid: return False |
| 1467 | return True |
| 1468 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1469 | def pretty_print(self, q): |
| 1470 | q.text("bsn_get_interfaces_request {") |
| 1471 | with q.group(): |
| 1472 | with q.indent(2): |
| 1473 | q.breakable() |
| 1474 | q.text("xid = "); |
| 1475 | if self.xid != None: |
| 1476 | q.text("%#x" % self.xid) |
| 1477 | else: |
| 1478 | q.text('None') |
| 1479 | q.breakable() |
| 1480 | q.text('}') |
| 1481 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1482 | bsn_header.subtypes[9] = bsn_get_interfaces_request |
| 1483 | |
| 1484 | class bsn_get_ip_mask_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1485 | version = 1 |
| 1486 | type = 4 |
| 1487 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1488 | subtype = 2 |
| 1489 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1490 | def __init__(self, xid=None, index=None, mask=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1491 | if xid != None: |
| 1492 | self.xid = xid |
| 1493 | else: |
| 1494 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1495 | if index != None: |
| 1496 | self.index = index |
| 1497 | else: |
| 1498 | self.index = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1499 | if mask != None: |
| 1500 | self.mask = mask |
| 1501 | else: |
| 1502 | self.mask = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1503 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1504 | |
| 1505 | def pack(self): |
| 1506 | packed = [] |
| 1507 | packed.append(struct.pack("!B", self.version)) |
| 1508 | packed.append(struct.pack("!B", self.type)) |
| 1509 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1510 | packed.append(struct.pack("!L", self.xid)) |
| 1511 | packed.append(struct.pack("!L", self.experimenter)) |
| 1512 | packed.append(struct.pack("!L", self.subtype)) |
| 1513 | packed.append(struct.pack("!B", self.index)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1514 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1515 | packed.append(struct.pack("!L", self.mask)) |
| 1516 | length = sum([len(x) for x in packed]) |
| 1517 | packed[2] = struct.pack("!H", length) |
| 1518 | return ''.join(packed) |
| 1519 | |
| 1520 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1521 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1522 | obj = bsn_get_ip_mask_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1523 | _version = reader.read("!B")[0] |
| 1524 | assert(_version == 1) |
| 1525 | _type = reader.read("!B")[0] |
| 1526 | assert(_type == 4) |
| 1527 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1528 | orig_reader = reader |
| 1529 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1530 | obj.xid = reader.read("!L")[0] |
| 1531 | _experimenter = reader.read("!L")[0] |
| 1532 | assert(_experimenter == 6035143) |
| 1533 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1534 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1535 | obj.index = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1536 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1537 | obj.mask = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1538 | return obj |
| 1539 | |
| 1540 | def __eq__(self, other): |
| 1541 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1542 | if self.xid != other.xid: return False |
| 1543 | if self.index != other.index: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1544 | if self.mask != other.mask: return False |
| 1545 | return True |
| 1546 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1547 | def pretty_print(self, q): |
| 1548 | q.text("bsn_get_ip_mask_reply {") |
| 1549 | with q.group(): |
| 1550 | with q.indent(2): |
| 1551 | q.breakable() |
| 1552 | q.text("xid = "); |
| 1553 | if self.xid != None: |
| 1554 | q.text("%#x" % self.xid) |
| 1555 | else: |
| 1556 | q.text('None') |
| 1557 | q.text(","); q.breakable() |
| 1558 | q.text("index = "); |
| 1559 | q.text("%#x" % self.index) |
| 1560 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1561 | q.text("mask = "); |
| 1562 | q.text("%#x" % self.mask) |
| 1563 | q.breakable() |
| 1564 | q.text('}') |
| 1565 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1566 | bsn_header.subtypes[2] = bsn_get_ip_mask_reply |
| 1567 | |
| 1568 | class bsn_get_ip_mask_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1569 | version = 1 |
| 1570 | type = 4 |
| 1571 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1572 | subtype = 1 |
| 1573 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1574 | def __init__(self, xid=None, index=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1575 | if xid != None: |
| 1576 | self.xid = xid |
| 1577 | else: |
| 1578 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1579 | if index != None: |
| 1580 | self.index = index |
| 1581 | else: |
| 1582 | self.index = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1583 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1584 | |
| 1585 | def pack(self): |
| 1586 | packed = [] |
| 1587 | packed.append(struct.pack("!B", self.version)) |
| 1588 | packed.append(struct.pack("!B", self.type)) |
| 1589 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1590 | packed.append(struct.pack("!L", self.xid)) |
| 1591 | packed.append(struct.pack("!L", self.experimenter)) |
| 1592 | packed.append(struct.pack("!L", self.subtype)) |
| 1593 | packed.append(struct.pack("!B", self.index)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1594 | packed.append('\x00' * 7) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1595 | length = sum([len(x) for x in packed]) |
| 1596 | packed[2] = struct.pack("!H", length) |
| 1597 | return ''.join(packed) |
| 1598 | |
| 1599 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1600 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1601 | obj = bsn_get_ip_mask_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1602 | _version = reader.read("!B")[0] |
| 1603 | assert(_version == 1) |
| 1604 | _type = reader.read("!B")[0] |
| 1605 | assert(_type == 4) |
| 1606 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1607 | orig_reader = reader |
| 1608 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1609 | obj.xid = reader.read("!L")[0] |
| 1610 | _experimenter = reader.read("!L")[0] |
| 1611 | assert(_experimenter == 6035143) |
| 1612 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1613 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1614 | obj.index = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1615 | reader.skip(7) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1616 | return obj |
| 1617 | |
| 1618 | def __eq__(self, other): |
| 1619 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1620 | if self.xid != other.xid: return False |
| 1621 | if self.index != other.index: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1622 | return True |
| 1623 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1624 | def pretty_print(self, q): |
| 1625 | q.text("bsn_get_ip_mask_request {") |
| 1626 | with q.group(): |
| 1627 | with q.indent(2): |
| 1628 | q.breakable() |
| 1629 | q.text("xid = "); |
| 1630 | if self.xid != None: |
| 1631 | q.text("%#x" % self.xid) |
| 1632 | else: |
| 1633 | q.text('None') |
| 1634 | q.text(","); q.breakable() |
| 1635 | q.text("index = "); |
| 1636 | q.text("%#x" % self.index) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1637 | q.breakable() |
| 1638 | q.text('}') |
| 1639 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1640 | bsn_header.subtypes[1] = bsn_get_ip_mask_request |
| 1641 | |
| 1642 | class bsn_get_l2_table_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1643 | version = 1 |
| 1644 | type = 4 |
| 1645 | experimenter = 6035143 |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1646 | subtype = 14 |
| 1647 | |
| 1648 | def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1649 | if xid != None: |
| 1650 | self.xid = xid |
| 1651 | else: |
| 1652 | self.xid = None |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1653 | if l2_table_enable != None: |
| 1654 | self.l2_table_enable = l2_table_enable |
| 1655 | else: |
| 1656 | self.l2_table_enable = 0 |
| 1657 | if l2_table_priority != None: |
| 1658 | self.l2_table_priority = l2_table_priority |
| 1659 | else: |
| 1660 | self.l2_table_priority = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1661 | return |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1662 | |
| 1663 | def pack(self): |
| 1664 | packed = [] |
| 1665 | packed.append(struct.pack("!B", self.version)) |
| 1666 | packed.append(struct.pack("!B", self.type)) |
| 1667 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1668 | packed.append(struct.pack("!L", self.xid)) |
| 1669 | packed.append(struct.pack("!L", self.experimenter)) |
| 1670 | packed.append(struct.pack("!L", self.subtype)) |
| 1671 | packed.append(struct.pack("!B", self.l2_table_enable)) |
| 1672 | packed.append('\x00' * 1) |
| 1673 | packed.append(struct.pack("!H", self.l2_table_priority)) |
| 1674 | packed.append('\x00' * 4) |
| 1675 | length = sum([len(x) for x in packed]) |
| 1676 | packed[2] = struct.pack("!H", length) |
| 1677 | return ''.join(packed) |
| 1678 | |
| 1679 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1680 | def unpack(reader): |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1681 | obj = bsn_get_l2_table_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1682 | _version = reader.read("!B")[0] |
| 1683 | assert(_version == 1) |
| 1684 | _type = reader.read("!B")[0] |
| 1685 | assert(_type == 4) |
| 1686 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1687 | orig_reader = reader |
| 1688 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1689 | obj.xid = reader.read("!L")[0] |
| 1690 | _experimenter = reader.read("!L")[0] |
| 1691 | assert(_experimenter == 6035143) |
| 1692 | _subtype = reader.read("!L")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1693 | assert(_subtype == 14) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1694 | obj.l2_table_enable = reader.read("!B")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1695 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1696 | obj.l2_table_priority = reader.read("!H")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1697 | reader.skip(4) |
| 1698 | return obj |
| 1699 | |
| 1700 | def __eq__(self, other): |
| 1701 | if type(self) != type(other): return False |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1702 | if self.xid != other.xid: return False |
| 1703 | if self.l2_table_enable != other.l2_table_enable: return False |
| 1704 | if self.l2_table_priority != other.l2_table_priority: return False |
| 1705 | return True |
| 1706 | |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1707 | def pretty_print(self, q): |
| 1708 | q.text("bsn_get_l2_table_reply {") |
| 1709 | with q.group(): |
| 1710 | with q.indent(2): |
| 1711 | q.breakable() |
| 1712 | q.text("xid = "); |
| 1713 | if self.xid != None: |
| 1714 | q.text("%#x" % self.xid) |
| 1715 | else: |
| 1716 | q.text('None') |
| 1717 | q.text(","); q.breakable() |
| 1718 | q.text("l2_table_enable = "); |
| 1719 | q.text("%#x" % self.l2_table_enable) |
| 1720 | q.text(","); q.breakable() |
| 1721 | q.text("l2_table_priority = "); |
| 1722 | q.text("%#x" % self.l2_table_priority) |
| 1723 | q.breakable() |
| 1724 | q.text('}') |
| 1725 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1726 | bsn_header.subtypes[14] = bsn_get_l2_table_reply |
| 1727 | |
| 1728 | class bsn_get_l2_table_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1729 | version = 1 |
| 1730 | type = 4 |
| 1731 | experimenter = 6035143 |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1732 | subtype = 13 |
| 1733 | |
| 1734 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1735 | if xid != None: |
| 1736 | self.xid = xid |
| 1737 | else: |
| 1738 | self.xid = None |
| 1739 | return |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1740 | |
| 1741 | def pack(self): |
| 1742 | packed = [] |
| 1743 | packed.append(struct.pack("!B", self.version)) |
| 1744 | packed.append(struct.pack("!B", self.type)) |
| 1745 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1746 | packed.append(struct.pack("!L", self.xid)) |
| 1747 | packed.append(struct.pack("!L", self.experimenter)) |
| 1748 | packed.append(struct.pack("!L", self.subtype)) |
| 1749 | length = sum([len(x) for x in packed]) |
| 1750 | packed[2] = struct.pack("!H", length) |
| 1751 | return ''.join(packed) |
| 1752 | |
| 1753 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1754 | def unpack(reader): |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1755 | obj = bsn_get_l2_table_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1756 | _version = reader.read("!B")[0] |
| 1757 | assert(_version == 1) |
| 1758 | _type = reader.read("!B")[0] |
| 1759 | assert(_type == 4) |
| 1760 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1761 | orig_reader = reader |
| 1762 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1763 | obj.xid = reader.read("!L")[0] |
| 1764 | _experimenter = reader.read("!L")[0] |
| 1765 | assert(_experimenter == 6035143) |
| 1766 | _subtype = reader.read("!L")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1767 | assert(_subtype == 13) |
| 1768 | return obj |
| 1769 | |
| 1770 | def __eq__(self, other): |
| 1771 | if type(self) != type(other): return False |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1772 | if self.xid != other.xid: return False |
| 1773 | return True |
| 1774 | |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1775 | def pretty_print(self, q): |
| 1776 | q.text("bsn_get_l2_table_request {") |
| 1777 | with q.group(): |
| 1778 | with q.indent(2): |
| 1779 | q.breakable() |
| 1780 | q.text("xid = "); |
| 1781 | if self.xid != None: |
| 1782 | q.text("%#x" % self.xid) |
| 1783 | else: |
| 1784 | q.text('None') |
| 1785 | q.breakable() |
| 1786 | q.text('}') |
| 1787 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1788 | bsn_header.subtypes[13] = bsn_get_l2_table_request |
| 1789 | |
| 1790 | class bsn_get_mirroring_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1791 | version = 1 |
| 1792 | type = 4 |
| 1793 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1794 | subtype = 5 |
| 1795 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1796 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1797 | if xid != None: |
| 1798 | self.xid = xid |
| 1799 | else: |
| 1800 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1801 | if report_mirror_ports != None: |
| 1802 | self.report_mirror_ports = report_mirror_ports |
| 1803 | else: |
| 1804 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1805 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1806 | |
| 1807 | def pack(self): |
| 1808 | packed = [] |
| 1809 | packed.append(struct.pack("!B", self.version)) |
| 1810 | packed.append(struct.pack("!B", self.type)) |
| 1811 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1812 | packed.append(struct.pack("!L", self.xid)) |
| 1813 | packed.append(struct.pack("!L", self.experimenter)) |
| 1814 | packed.append(struct.pack("!L", self.subtype)) |
| 1815 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1816 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1817 | length = sum([len(x) for x in packed]) |
| 1818 | packed[2] = struct.pack("!H", length) |
| 1819 | return ''.join(packed) |
| 1820 | |
| 1821 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1822 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1823 | obj = bsn_get_mirroring_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1824 | _version = reader.read("!B")[0] |
| 1825 | assert(_version == 1) |
| 1826 | _type = reader.read("!B")[0] |
| 1827 | assert(_type == 4) |
| 1828 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1829 | orig_reader = reader |
| 1830 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1831 | obj.xid = reader.read("!L")[0] |
| 1832 | _experimenter = reader.read("!L")[0] |
| 1833 | assert(_experimenter == 6035143) |
| 1834 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1835 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1836 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1837 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1838 | return obj |
| 1839 | |
| 1840 | def __eq__(self, other): |
| 1841 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1842 | if self.xid != other.xid: return False |
| 1843 | if self.report_mirror_ports != other.report_mirror_ports: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1844 | return True |
| 1845 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1846 | def pretty_print(self, q): |
| 1847 | q.text("bsn_get_mirroring_reply {") |
| 1848 | with q.group(): |
| 1849 | with q.indent(2): |
| 1850 | q.breakable() |
| 1851 | q.text("xid = "); |
| 1852 | if self.xid != None: |
| 1853 | q.text("%#x" % self.xid) |
| 1854 | else: |
| 1855 | q.text('None') |
| 1856 | q.text(","); q.breakable() |
| 1857 | q.text("report_mirror_ports = "); |
| 1858 | q.text("%#x" % self.report_mirror_ports) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1859 | q.breakable() |
| 1860 | q.text('}') |
| 1861 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1862 | bsn_header.subtypes[5] = bsn_get_mirroring_reply |
| 1863 | |
| 1864 | class bsn_get_mirroring_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1865 | version = 1 |
| 1866 | type = 4 |
| 1867 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1868 | subtype = 4 |
| 1869 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1870 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1871 | if xid != None: |
| 1872 | self.xid = xid |
| 1873 | else: |
| 1874 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1875 | if report_mirror_ports != None: |
| 1876 | self.report_mirror_ports = report_mirror_ports |
| 1877 | else: |
| 1878 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1879 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1880 | |
| 1881 | def pack(self): |
| 1882 | packed = [] |
| 1883 | packed.append(struct.pack("!B", self.version)) |
| 1884 | packed.append(struct.pack("!B", self.type)) |
| 1885 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1886 | packed.append(struct.pack("!L", self.xid)) |
| 1887 | packed.append(struct.pack("!L", self.experimenter)) |
| 1888 | packed.append(struct.pack("!L", self.subtype)) |
| 1889 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1890 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1891 | length = sum([len(x) for x in packed]) |
| 1892 | packed[2] = struct.pack("!H", length) |
| 1893 | return ''.join(packed) |
| 1894 | |
| 1895 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1896 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1897 | obj = bsn_get_mirroring_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1898 | _version = reader.read("!B")[0] |
| 1899 | assert(_version == 1) |
| 1900 | _type = reader.read("!B")[0] |
| 1901 | assert(_type == 4) |
| 1902 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1903 | orig_reader = reader |
| 1904 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1905 | obj.xid = reader.read("!L")[0] |
| 1906 | _experimenter = reader.read("!L")[0] |
| 1907 | assert(_experimenter == 6035143) |
| 1908 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1909 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1910 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1911 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1912 | return obj |
| 1913 | |
| 1914 | def __eq__(self, other): |
| 1915 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1916 | if self.xid != other.xid: return False |
| 1917 | if self.report_mirror_ports != other.report_mirror_ports: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1918 | return True |
| 1919 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1920 | def pretty_print(self, q): |
| 1921 | q.text("bsn_get_mirroring_request {") |
| 1922 | with q.group(): |
| 1923 | with q.indent(2): |
| 1924 | q.breakable() |
| 1925 | q.text("xid = "); |
| 1926 | if self.xid != None: |
| 1927 | q.text("%#x" % self.xid) |
| 1928 | else: |
| 1929 | q.text('None') |
| 1930 | q.text(","); q.breakable() |
| 1931 | q.text("report_mirror_ports = "); |
| 1932 | q.text("%#x" % self.report_mirror_ports) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1933 | q.breakable() |
| 1934 | q.text('}') |
| 1935 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1936 | bsn_header.subtypes[4] = bsn_get_mirroring_request |
| 1937 | |
| 1938 | class bsn_hybrid_get_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1939 | version = 1 |
| 1940 | type = 4 |
| 1941 | experimenter = 6035143 |
| 1942 | subtype = 28 |
| 1943 | |
| 1944 | def __init__(self, xid=None, hybrid_enable=None, hybrid_version=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1945 | if xid != None: |
| 1946 | self.xid = xid |
| 1947 | else: |
| 1948 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1949 | if hybrid_enable != None: |
| 1950 | self.hybrid_enable = hybrid_enable |
| 1951 | else: |
| 1952 | self.hybrid_enable = 0 |
| 1953 | if hybrid_version != None: |
| 1954 | self.hybrid_version = hybrid_version |
| 1955 | else: |
| 1956 | self.hybrid_version = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1957 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1958 | |
| 1959 | def pack(self): |
| 1960 | packed = [] |
| 1961 | packed.append(struct.pack("!B", self.version)) |
| 1962 | packed.append(struct.pack("!B", self.type)) |
| 1963 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1964 | packed.append(struct.pack("!L", self.xid)) |
| 1965 | packed.append(struct.pack("!L", self.experimenter)) |
| 1966 | packed.append(struct.pack("!L", self.subtype)) |
| 1967 | packed.append(struct.pack("!B", self.hybrid_enable)) |
| 1968 | packed.append('\x00' * 1) |
| 1969 | packed.append(struct.pack("!H", self.hybrid_version)) |
| 1970 | packed.append('\x00' * 4) |
| 1971 | length = sum([len(x) for x in packed]) |
| 1972 | packed[2] = struct.pack("!H", length) |
| 1973 | return ''.join(packed) |
| 1974 | |
| 1975 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1976 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1977 | obj = bsn_hybrid_get_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1978 | _version = reader.read("!B")[0] |
| 1979 | assert(_version == 1) |
| 1980 | _type = reader.read("!B")[0] |
| 1981 | assert(_type == 4) |
| 1982 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1983 | orig_reader = reader |
| 1984 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1985 | obj.xid = reader.read("!L")[0] |
| 1986 | _experimenter = reader.read("!L")[0] |
| 1987 | assert(_experimenter == 6035143) |
| 1988 | _subtype = reader.read("!L")[0] |
| 1989 | assert(_subtype == 28) |
| 1990 | obj.hybrid_enable = reader.read("!B")[0] |
| 1991 | reader.skip(1) |
| 1992 | obj.hybrid_version = reader.read("!H")[0] |
| 1993 | reader.skip(4) |
| 1994 | return obj |
| 1995 | |
| 1996 | def __eq__(self, other): |
| 1997 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1998 | if self.xid != other.xid: return False |
| 1999 | if self.hybrid_enable != other.hybrid_enable: return False |
| 2000 | if self.hybrid_version != other.hybrid_version: return False |
| 2001 | return True |
| 2002 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2003 | def pretty_print(self, q): |
| 2004 | q.text("bsn_hybrid_get_reply {") |
| 2005 | with q.group(): |
| 2006 | with q.indent(2): |
| 2007 | q.breakable() |
| 2008 | q.text("xid = "); |
| 2009 | if self.xid != None: |
| 2010 | q.text("%#x" % self.xid) |
| 2011 | else: |
| 2012 | q.text('None') |
| 2013 | q.text(","); q.breakable() |
| 2014 | q.text("hybrid_enable = "); |
| 2015 | q.text("%#x" % self.hybrid_enable) |
| 2016 | q.text(","); q.breakable() |
| 2017 | q.text("hybrid_version = "); |
| 2018 | q.text("%#x" % self.hybrid_version) |
| 2019 | q.breakable() |
| 2020 | q.text('}') |
| 2021 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2022 | bsn_header.subtypes[28] = bsn_hybrid_get_reply |
| 2023 | |
| 2024 | class bsn_hybrid_get_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2025 | version = 1 |
| 2026 | type = 4 |
| 2027 | experimenter = 6035143 |
| 2028 | subtype = 27 |
| 2029 | |
| 2030 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2031 | if xid != None: |
| 2032 | self.xid = xid |
| 2033 | else: |
| 2034 | self.xid = None |
| 2035 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2036 | |
| 2037 | def pack(self): |
| 2038 | packed = [] |
| 2039 | packed.append(struct.pack("!B", self.version)) |
| 2040 | packed.append(struct.pack("!B", self.type)) |
| 2041 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2042 | packed.append(struct.pack("!L", self.xid)) |
| 2043 | packed.append(struct.pack("!L", self.experimenter)) |
| 2044 | packed.append(struct.pack("!L", self.subtype)) |
| 2045 | length = sum([len(x) for x in packed]) |
| 2046 | packed[2] = struct.pack("!H", length) |
| 2047 | return ''.join(packed) |
| 2048 | |
| 2049 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2050 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2051 | obj = bsn_hybrid_get_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2052 | _version = reader.read("!B")[0] |
| 2053 | assert(_version == 1) |
| 2054 | _type = reader.read("!B")[0] |
| 2055 | assert(_type == 4) |
| 2056 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2057 | orig_reader = reader |
| 2058 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2059 | obj.xid = reader.read("!L")[0] |
| 2060 | _experimenter = reader.read("!L")[0] |
| 2061 | assert(_experimenter == 6035143) |
| 2062 | _subtype = reader.read("!L")[0] |
| 2063 | assert(_subtype == 27) |
| 2064 | return obj |
| 2065 | |
| 2066 | def __eq__(self, other): |
| 2067 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2068 | if self.xid != other.xid: return False |
| 2069 | return True |
| 2070 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2071 | def pretty_print(self, q): |
| 2072 | q.text("bsn_hybrid_get_request {") |
| 2073 | with q.group(): |
| 2074 | with q.indent(2): |
| 2075 | q.breakable() |
| 2076 | q.text("xid = "); |
| 2077 | if self.xid != None: |
| 2078 | q.text("%#x" % self.xid) |
| 2079 | else: |
| 2080 | q.text('None') |
| 2081 | q.breakable() |
| 2082 | q.text('}') |
| 2083 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2084 | bsn_header.subtypes[27] = bsn_hybrid_get_request |
| 2085 | |
| 2086 | class bsn_pdu_rx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2087 | version = 1 |
| 2088 | type = 4 |
| 2089 | experimenter = 6035143 |
| 2090 | subtype = 34 |
| 2091 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2092 | 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] | 2093 | if xid != None: |
| 2094 | self.xid = xid |
| 2095 | else: |
| 2096 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2097 | if status != None: |
| 2098 | self.status = status |
| 2099 | else: |
| 2100 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2101 | if port_no != None: |
| 2102 | self.port_no = port_no |
| 2103 | else: |
| 2104 | self.port_no = 0 |
| 2105 | if slot_num != None: |
| 2106 | self.slot_num = slot_num |
| 2107 | else: |
| 2108 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2109 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2110 | |
| 2111 | def pack(self): |
| 2112 | packed = [] |
| 2113 | packed.append(struct.pack("!B", self.version)) |
| 2114 | packed.append(struct.pack("!B", self.type)) |
| 2115 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2116 | packed.append(struct.pack("!L", self.xid)) |
| 2117 | packed.append(struct.pack("!L", self.experimenter)) |
| 2118 | packed.append(struct.pack("!L", self.subtype)) |
| 2119 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2120 | packed.append(util.pack_port_no(self.port_no)) |
| 2121 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2122 | length = sum([len(x) for x in packed]) |
| 2123 | packed[2] = struct.pack("!H", length) |
| 2124 | return ''.join(packed) |
| 2125 | |
| 2126 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2127 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2128 | obj = bsn_pdu_rx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2129 | _version = reader.read("!B")[0] |
| 2130 | assert(_version == 1) |
| 2131 | _type = reader.read("!B")[0] |
| 2132 | assert(_type == 4) |
| 2133 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2134 | orig_reader = reader |
| 2135 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2136 | obj.xid = reader.read("!L")[0] |
| 2137 | _experimenter = reader.read("!L")[0] |
| 2138 | assert(_experimenter == 6035143) |
| 2139 | _subtype = reader.read("!L")[0] |
| 2140 | assert(_subtype == 34) |
| 2141 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2142 | obj.port_no = util.unpack_port_no(reader) |
| 2143 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2144 | return obj |
| 2145 | |
| 2146 | def __eq__(self, other): |
| 2147 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2148 | if self.xid != other.xid: return False |
| 2149 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2150 | if self.port_no != other.port_no: return False |
| 2151 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2152 | return True |
| 2153 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2154 | def pretty_print(self, q): |
| 2155 | q.text("bsn_pdu_rx_reply {") |
| 2156 | with q.group(): |
| 2157 | with q.indent(2): |
| 2158 | q.breakable() |
| 2159 | q.text("xid = "); |
| 2160 | if self.xid != None: |
| 2161 | q.text("%#x" % self.xid) |
| 2162 | else: |
| 2163 | q.text('None') |
| 2164 | q.text(","); q.breakable() |
| 2165 | q.text("status = "); |
| 2166 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2167 | q.text(","); q.breakable() |
| 2168 | q.text("port_no = "); |
| 2169 | q.text(util.pretty_port(self.port_no)) |
| 2170 | q.text(","); q.breakable() |
| 2171 | q.text("slot_num = "); |
| 2172 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2173 | q.breakable() |
| 2174 | q.text('}') |
| 2175 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2176 | bsn_header.subtypes[34] = bsn_pdu_rx_reply |
| 2177 | |
| 2178 | class bsn_pdu_rx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2179 | version = 1 |
| 2180 | type = 4 |
| 2181 | experimenter = 6035143 |
| 2182 | subtype = 33 |
| 2183 | |
| 2184 | 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] | 2185 | if xid != None: |
| 2186 | self.xid = xid |
| 2187 | else: |
| 2188 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2189 | if timeout_ms != None: |
| 2190 | self.timeout_ms = timeout_ms |
| 2191 | else: |
| 2192 | self.timeout_ms = 0 |
| 2193 | if port_no != None: |
| 2194 | self.port_no = port_no |
| 2195 | else: |
| 2196 | self.port_no = 0 |
| 2197 | if slot_num != None: |
| 2198 | self.slot_num = slot_num |
| 2199 | else: |
| 2200 | self.slot_num = 0 |
| 2201 | if data != None: |
| 2202 | self.data = data |
| 2203 | else: |
| 2204 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2205 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2206 | |
| 2207 | def pack(self): |
| 2208 | packed = [] |
| 2209 | packed.append(struct.pack("!B", self.version)) |
| 2210 | packed.append(struct.pack("!B", self.type)) |
| 2211 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2212 | packed.append(struct.pack("!L", self.xid)) |
| 2213 | packed.append(struct.pack("!L", self.experimenter)) |
| 2214 | packed.append(struct.pack("!L", self.subtype)) |
| 2215 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 2216 | packed.append(util.pack_port_no(self.port_no)) |
| 2217 | packed.append(struct.pack("!B", self.slot_num)) |
| 2218 | packed.append('\x00' * 3) |
| 2219 | packed.append(self.data) |
| 2220 | length = sum([len(x) for x in packed]) |
| 2221 | packed[2] = struct.pack("!H", length) |
| 2222 | return ''.join(packed) |
| 2223 | |
| 2224 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2225 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2226 | obj = bsn_pdu_rx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2227 | _version = reader.read("!B")[0] |
| 2228 | assert(_version == 1) |
| 2229 | _type = reader.read("!B")[0] |
| 2230 | assert(_type == 4) |
| 2231 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2232 | orig_reader = reader |
| 2233 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2234 | obj.xid = reader.read("!L")[0] |
| 2235 | _experimenter = reader.read("!L")[0] |
| 2236 | assert(_experimenter == 6035143) |
| 2237 | _subtype = reader.read("!L")[0] |
| 2238 | assert(_subtype == 33) |
| 2239 | obj.timeout_ms = reader.read("!L")[0] |
| 2240 | obj.port_no = util.unpack_port_no(reader) |
| 2241 | obj.slot_num = reader.read("!B")[0] |
| 2242 | reader.skip(3) |
| 2243 | obj.data = str(reader.read_all()) |
| 2244 | return obj |
| 2245 | |
| 2246 | def __eq__(self, other): |
| 2247 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2248 | if self.xid != other.xid: return False |
| 2249 | if self.timeout_ms != other.timeout_ms: return False |
| 2250 | if self.port_no != other.port_no: return False |
| 2251 | if self.slot_num != other.slot_num: return False |
| 2252 | if self.data != other.data: return False |
| 2253 | return True |
| 2254 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2255 | def pretty_print(self, q): |
| 2256 | q.text("bsn_pdu_rx_request {") |
| 2257 | with q.group(): |
| 2258 | with q.indent(2): |
| 2259 | q.breakable() |
| 2260 | q.text("xid = "); |
| 2261 | if self.xid != None: |
| 2262 | q.text("%#x" % self.xid) |
| 2263 | else: |
| 2264 | q.text('None') |
| 2265 | q.text(","); q.breakable() |
| 2266 | q.text("timeout_ms = "); |
| 2267 | q.text("%#x" % self.timeout_ms) |
| 2268 | q.text(","); q.breakable() |
| 2269 | q.text("port_no = "); |
| 2270 | q.text(util.pretty_port(self.port_no)) |
| 2271 | q.text(","); q.breakable() |
| 2272 | q.text("slot_num = "); |
| 2273 | q.text("%#x" % self.slot_num) |
| 2274 | q.text(","); q.breakable() |
| 2275 | q.text("data = "); |
| 2276 | q.pp(self.data) |
| 2277 | q.breakable() |
| 2278 | q.text('}') |
| 2279 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2280 | bsn_header.subtypes[33] = bsn_pdu_rx_request |
| 2281 | |
| 2282 | class bsn_pdu_rx_timeout(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2283 | version = 1 |
| 2284 | type = 4 |
| 2285 | experimenter = 6035143 |
| 2286 | subtype = 35 |
| 2287 | |
| 2288 | def __init__(self, xid=None, port_no=None, slot_num=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2289 | if xid != None: |
| 2290 | self.xid = xid |
| 2291 | else: |
| 2292 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2293 | if port_no != None: |
| 2294 | self.port_no = port_no |
| 2295 | else: |
| 2296 | self.port_no = 0 |
| 2297 | if slot_num != None: |
| 2298 | self.slot_num = slot_num |
| 2299 | else: |
| 2300 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2301 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2302 | |
| 2303 | def pack(self): |
| 2304 | packed = [] |
| 2305 | packed.append(struct.pack("!B", self.version)) |
| 2306 | packed.append(struct.pack("!B", self.type)) |
| 2307 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2308 | packed.append(struct.pack("!L", self.xid)) |
| 2309 | packed.append(struct.pack("!L", self.experimenter)) |
| 2310 | packed.append(struct.pack("!L", self.subtype)) |
| 2311 | packed.append(util.pack_port_no(self.port_no)) |
| 2312 | packed.append(struct.pack("!B", self.slot_num)) |
| 2313 | length = sum([len(x) for x in packed]) |
| 2314 | packed[2] = struct.pack("!H", length) |
| 2315 | return ''.join(packed) |
| 2316 | |
| 2317 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2318 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2319 | obj = bsn_pdu_rx_timeout() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2320 | _version = reader.read("!B")[0] |
| 2321 | assert(_version == 1) |
| 2322 | _type = reader.read("!B")[0] |
| 2323 | assert(_type == 4) |
| 2324 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2325 | orig_reader = reader |
| 2326 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2327 | obj.xid = reader.read("!L")[0] |
| 2328 | _experimenter = reader.read("!L")[0] |
| 2329 | assert(_experimenter == 6035143) |
| 2330 | _subtype = reader.read("!L")[0] |
| 2331 | assert(_subtype == 35) |
| 2332 | obj.port_no = util.unpack_port_no(reader) |
| 2333 | obj.slot_num = reader.read("!B")[0] |
| 2334 | return obj |
| 2335 | |
| 2336 | def __eq__(self, other): |
| 2337 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2338 | if self.xid != other.xid: return False |
| 2339 | if self.port_no != other.port_no: return False |
| 2340 | if self.slot_num != other.slot_num: return False |
| 2341 | return True |
| 2342 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2343 | def pretty_print(self, q): |
| 2344 | q.text("bsn_pdu_rx_timeout {") |
| 2345 | with q.group(): |
| 2346 | with q.indent(2): |
| 2347 | q.breakable() |
| 2348 | q.text("xid = "); |
| 2349 | if self.xid != None: |
| 2350 | q.text("%#x" % self.xid) |
| 2351 | else: |
| 2352 | q.text('None') |
| 2353 | q.text(","); q.breakable() |
| 2354 | q.text("port_no = "); |
| 2355 | q.text(util.pretty_port(self.port_no)) |
| 2356 | q.text(","); q.breakable() |
| 2357 | q.text("slot_num = "); |
| 2358 | q.text("%#x" % self.slot_num) |
| 2359 | q.breakable() |
| 2360 | q.text('}') |
| 2361 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2362 | bsn_header.subtypes[35] = bsn_pdu_rx_timeout |
| 2363 | |
| 2364 | class bsn_pdu_tx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2365 | version = 1 |
| 2366 | type = 4 |
| 2367 | experimenter = 6035143 |
| 2368 | subtype = 32 |
| 2369 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2370 | 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] | 2371 | if xid != None: |
| 2372 | self.xid = xid |
| 2373 | else: |
| 2374 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2375 | if status != None: |
| 2376 | self.status = status |
| 2377 | else: |
| 2378 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2379 | if port_no != None: |
| 2380 | self.port_no = port_no |
| 2381 | else: |
| 2382 | self.port_no = 0 |
| 2383 | if slot_num != None: |
| 2384 | self.slot_num = slot_num |
| 2385 | else: |
| 2386 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2387 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2388 | |
| 2389 | def pack(self): |
| 2390 | packed = [] |
| 2391 | packed.append(struct.pack("!B", self.version)) |
| 2392 | packed.append(struct.pack("!B", self.type)) |
| 2393 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2394 | packed.append(struct.pack("!L", self.xid)) |
| 2395 | packed.append(struct.pack("!L", self.experimenter)) |
| 2396 | packed.append(struct.pack("!L", self.subtype)) |
| 2397 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2398 | packed.append(util.pack_port_no(self.port_no)) |
| 2399 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2400 | length = sum([len(x) for x in packed]) |
| 2401 | packed[2] = struct.pack("!H", length) |
| 2402 | return ''.join(packed) |
| 2403 | |
| 2404 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2405 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2406 | obj = bsn_pdu_tx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2407 | _version = reader.read("!B")[0] |
| 2408 | assert(_version == 1) |
| 2409 | _type = reader.read("!B")[0] |
| 2410 | assert(_type == 4) |
| 2411 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2412 | orig_reader = reader |
| 2413 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2414 | obj.xid = reader.read("!L")[0] |
| 2415 | _experimenter = reader.read("!L")[0] |
| 2416 | assert(_experimenter == 6035143) |
| 2417 | _subtype = reader.read("!L")[0] |
| 2418 | assert(_subtype == 32) |
| 2419 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2420 | obj.port_no = util.unpack_port_no(reader) |
| 2421 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2422 | return obj |
| 2423 | |
| 2424 | def __eq__(self, other): |
| 2425 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2426 | if self.xid != other.xid: return False |
| 2427 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2428 | if self.port_no != other.port_no: return False |
| 2429 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2430 | return True |
| 2431 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2432 | def pretty_print(self, q): |
| 2433 | q.text("bsn_pdu_tx_reply {") |
| 2434 | with q.group(): |
| 2435 | with q.indent(2): |
| 2436 | q.breakable() |
| 2437 | q.text("xid = "); |
| 2438 | if self.xid != None: |
| 2439 | q.text("%#x" % self.xid) |
| 2440 | else: |
| 2441 | q.text('None') |
| 2442 | q.text(","); q.breakable() |
| 2443 | q.text("status = "); |
| 2444 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2445 | q.text(","); q.breakable() |
| 2446 | q.text("port_no = "); |
| 2447 | q.text(util.pretty_port(self.port_no)) |
| 2448 | q.text(","); q.breakable() |
| 2449 | q.text("slot_num = "); |
| 2450 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2451 | q.breakable() |
| 2452 | q.text('}') |
| 2453 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2454 | bsn_header.subtypes[32] = bsn_pdu_tx_reply |
| 2455 | |
| 2456 | class bsn_pdu_tx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2457 | version = 1 |
| 2458 | type = 4 |
| 2459 | experimenter = 6035143 |
| 2460 | subtype = 31 |
| 2461 | |
| 2462 | 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] | 2463 | if xid != None: |
| 2464 | self.xid = xid |
| 2465 | else: |
| 2466 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2467 | if tx_interval_ms != None: |
| 2468 | self.tx_interval_ms = tx_interval_ms |
| 2469 | else: |
| 2470 | self.tx_interval_ms = 0 |
| 2471 | if port_no != None: |
| 2472 | self.port_no = port_no |
| 2473 | else: |
| 2474 | self.port_no = 0 |
| 2475 | if slot_num != None: |
| 2476 | self.slot_num = slot_num |
| 2477 | else: |
| 2478 | self.slot_num = 0 |
| 2479 | if data != None: |
| 2480 | self.data = data |
| 2481 | else: |
| 2482 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2483 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2484 | |
| 2485 | def pack(self): |
| 2486 | packed = [] |
| 2487 | packed.append(struct.pack("!B", self.version)) |
| 2488 | packed.append(struct.pack("!B", self.type)) |
| 2489 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2490 | packed.append(struct.pack("!L", self.xid)) |
| 2491 | packed.append(struct.pack("!L", self.experimenter)) |
| 2492 | packed.append(struct.pack("!L", self.subtype)) |
| 2493 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 2494 | packed.append(util.pack_port_no(self.port_no)) |
| 2495 | packed.append(struct.pack("!B", self.slot_num)) |
| 2496 | packed.append('\x00' * 3) |
| 2497 | packed.append(self.data) |
| 2498 | length = sum([len(x) for x in packed]) |
| 2499 | packed[2] = struct.pack("!H", length) |
| 2500 | return ''.join(packed) |
| 2501 | |
| 2502 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2503 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2504 | obj = bsn_pdu_tx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2505 | _version = reader.read("!B")[0] |
| 2506 | assert(_version == 1) |
| 2507 | _type = reader.read("!B")[0] |
| 2508 | assert(_type == 4) |
| 2509 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2510 | orig_reader = reader |
| 2511 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2512 | obj.xid = reader.read("!L")[0] |
| 2513 | _experimenter = reader.read("!L")[0] |
| 2514 | assert(_experimenter == 6035143) |
| 2515 | _subtype = reader.read("!L")[0] |
| 2516 | assert(_subtype == 31) |
| 2517 | obj.tx_interval_ms = reader.read("!L")[0] |
| 2518 | obj.port_no = util.unpack_port_no(reader) |
| 2519 | obj.slot_num = reader.read("!B")[0] |
| 2520 | reader.skip(3) |
| 2521 | obj.data = str(reader.read_all()) |
| 2522 | return obj |
| 2523 | |
| 2524 | def __eq__(self, other): |
| 2525 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2526 | if self.xid != other.xid: return False |
| 2527 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 2528 | if self.port_no != other.port_no: return False |
| 2529 | if self.slot_num != other.slot_num: return False |
| 2530 | if self.data != other.data: return False |
| 2531 | return True |
| 2532 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2533 | def pretty_print(self, q): |
| 2534 | q.text("bsn_pdu_tx_request {") |
| 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("tx_interval_ms = "); |
| 2545 | q.text("%#x" % self.tx_interval_ms) |
| 2546 | q.text(","); q.breakable() |
| 2547 | q.text("port_no = "); |
| 2548 | q.text(util.pretty_port(self.port_no)) |
| 2549 | q.text(","); q.breakable() |
| 2550 | q.text("slot_num = "); |
| 2551 | q.text("%#x" % self.slot_num) |
| 2552 | q.text(","); q.breakable() |
| 2553 | q.text("data = "); |
| 2554 | q.pp(self.data) |
| 2555 | q.breakable() |
| 2556 | q.text('}') |
| 2557 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2558 | bsn_header.subtypes[31] = bsn_pdu_tx_request |
| 2559 | |
| 2560 | class bsn_set_ip_mask(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2561 | version = 1 |
| 2562 | type = 4 |
| 2563 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2564 | subtype = 0 |
| 2565 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2566 | def __init__(self, xid=None, index=None, mask=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2567 | if xid != None: |
| 2568 | self.xid = xid |
| 2569 | else: |
| 2570 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2571 | if index != None: |
| 2572 | self.index = index |
| 2573 | else: |
| 2574 | self.index = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2575 | if mask != None: |
| 2576 | self.mask = mask |
| 2577 | else: |
| 2578 | self.mask = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2579 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2580 | |
| 2581 | def pack(self): |
| 2582 | packed = [] |
| 2583 | packed.append(struct.pack("!B", self.version)) |
| 2584 | packed.append(struct.pack("!B", self.type)) |
| 2585 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2586 | packed.append(struct.pack("!L", self.xid)) |
| 2587 | packed.append(struct.pack("!L", self.experimenter)) |
| 2588 | packed.append(struct.pack("!L", self.subtype)) |
| 2589 | packed.append(struct.pack("!B", self.index)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2590 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2591 | packed.append(struct.pack("!L", self.mask)) |
| 2592 | length = sum([len(x) for x in packed]) |
| 2593 | packed[2] = struct.pack("!H", length) |
| 2594 | return ''.join(packed) |
| 2595 | |
| 2596 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2597 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2598 | obj = bsn_set_ip_mask() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2599 | _version = reader.read("!B")[0] |
| 2600 | assert(_version == 1) |
| 2601 | _type = reader.read("!B")[0] |
| 2602 | assert(_type == 4) |
| 2603 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2604 | orig_reader = reader |
| 2605 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2606 | obj.xid = reader.read("!L")[0] |
| 2607 | _experimenter = reader.read("!L")[0] |
| 2608 | assert(_experimenter == 6035143) |
| 2609 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2610 | assert(_subtype == 0) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2611 | obj.index = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2612 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2613 | obj.mask = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2614 | return obj |
| 2615 | |
| 2616 | def __eq__(self, other): |
| 2617 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2618 | if self.xid != other.xid: return False |
| 2619 | if self.index != other.index: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2620 | if self.mask != other.mask: return False |
| 2621 | return True |
| 2622 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2623 | def pretty_print(self, q): |
| 2624 | q.text("bsn_set_ip_mask {") |
| 2625 | with q.group(): |
| 2626 | with q.indent(2): |
| 2627 | q.breakable() |
| 2628 | q.text("xid = "); |
| 2629 | if self.xid != None: |
| 2630 | q.text("%#x" % self.xid) |
| 2631 | else: |
| 2632 | q.text('None') |
| 2633 | q.text(","); q.breakable() |
| 2634 | q.text("index = "); |
| 2635 | q.text("%#x" % self.index) |
| 2636 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2637 | q.text("mask = "); |
| 2638 | q.text("%#x" % self.mask) |
| 2639 | q.breakable() |
| 2640 | q.text('}') |
| 2641 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2642 | bsn_header.subtypes[0] = bsn_set_ip_mask |
| 2643 | |
| 2644 | class bsn_set_l2_table_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2645 | version = 1 |
| 2646 | type = 4 |
| 2647 | experimenter = 6035143 |
| 2648 | subtype = 24 |
| 2649 | |
| 2650 | def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2651 | if xid != None: |
| 2652 | self.xid = xid |
| 2653 | else: |
| 2654 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2655 | if l2_table_enable != None: |
| 2656 | self.l2_table_enable = l2_table_enable |
| 2657 | else: |
| 2658 | self.l2_table_enable = 0 |
| 2659 | if l2_table_priority != None: |
| 2660 | self.l2_table_priority = l2_table_priority |
| 2661 | else: |
| 2662 | self.l2_table_priority = 0 |
| 2663 | if status != None: |
| 2664 | self.status = status |
| 2665 | else: |
| 2666 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2667 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2668 | |
| 2669 | def pack(self): |
| 2670 | packed = [] |
| 2671 | packed.append(struct.pack("!B", self.version)) |
| 2672 | packed.append(struct.pack("!B", self.type)) |
| 2673 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2674 | packed.append(struct.pack("!L", self.xid)) |
| 2675 | packed.append(struct.pack("!L", self.experimenter)) |
| 2676 | packed.append(struct.pack("!L", self.subtype)) |
| 2677 | packed.append(struct.pack("!B", self.l2_table_enable)) |
| 2678 | packed.append('\x00' * 1) |
| 2679 | packed.append(struct.pack("!H", self.l2_table_priority)) |
| 2680 | packed.append(struct.pack("!L", self.status)) |
| 2681 | length = sum([len(x) for x in packed]) |
| 2682 | packed[2] = struct.pack("!H", length) |
| 2683 | return ''.join(packed) |
| 2684 | |
| 2685 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2686 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2687 | obj = bsn_set_l2_table_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2688 | _version = reader.read("!B")[0] |
| 2689 | assert(_version == 1) |
| 2690 | _type = reader.read("!B")[0] |
| 2691 | assert(_type == 4) |
| 2692 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2693 | orig_reader = reader |
| 2694 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2695 | obj.xid = reader.read("!L")[0] |
| 2696 | _experimenter = reader.read("!L")[0] |
| 2697 | assert(_experimenter == 6035143) |
| 2698 | _subtype = reader.read("!L")[0] |
| 2699 | assert(_subtype == 24) |
| 2700 | obj.l2_table_enable = reader.read("!B")[0] |
| 2701 | reader.skip(1) |
| 2702 | obj.l2_table_priority = reader.read("!H")[0] |
| 2703 | obj.status = reader.read("!L")[0] |
| 2704 | return obj |
| 2705 | |
| 2706 | def __eq__(self, other): |
| 2707 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2708 | if self.xid != other.xid: return False |
| 2709 | if self.l2_table_enable != other.l2_table_enable: return False |
| 2710 | if self.l2_table_priority != other.l2_table_priority: return False |
| 2711 | if self.status != other.status: return False |
| 2712 | return True |
| 2713 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2714 | def pretty_print(self, q): |
| 2715 | q.text("bsn_set_l2_table_reply {") |
| 2716 | with q.group(): |
| 2717 | with q.indent(2): |
| 2718 | q.breakable() |
| 2719 | q.text("xid = "); |
| 2720 | if self.xid != None: |
| 2721 | q.text("%#x" % self.xid) |
| 2722 | else: |
| 2723 | q.text('None') |
| 2724 | q.text(","); q.breakable() |
| 2725 | q.text("l2_table_enable = "); |
| 2726 | q.text("%#x" % self.l2_table_enable) |
| 2727 | q.text(","); q.breakable() |
| 2728 | q.text("l2_table_priority = "); |
| 2729 | q.text("%#x" % self.l2_table_priority) |
| 2730 | q.text(","); q.breakable() |
| 2731 | q.text("status = "); |
| 2732 | q.text("%#x" % self.status) |
| 2733 | q.breakable() |
| 2734 | q.text('}') |
| 2735 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2736 | bsn_header.subtypes[24] = bsn_set_l2_table_reply |
| 2737 | |
| 2738 | class bsn_set_l2_table_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2739 | version = 1 |
| 2740 | type = 4 |
| 2741 | experimenter = 6035143 |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2742 | subtype = 12 |
| 2743 | |
| 2744 | def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2745 | if xid != None: |
| 2746 | self.xid = xid |
| 2747 | else: |
| 2748 | self.xid = None |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2749 | if l2_table_enable != None: |
| 2750 | self.l2_table_enable = l2_table_enable |
| 2751 | else: |
| 2752 | self.l2_table_enable = 0 |
| 2753 | if l2_table_priority != None: |
| 2754 | self.l2_table_priority = l2_table_priority |
| 2755 | else: |
| 2756 | self.l2_table_priority = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2757 | return |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2758 | |
| 2759 | def pack(self): |
| 2760 | packed = [] |
| 2761 | packed.append(struct.pack("!B", self.version)) |
| 2762 | packed.append(struct.pack("!B", self.type)) |
| 2763 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2764 | packed.append(struct.pack("!L", self.xid)) |
| 2765 | packed.append(struct.pack("!L", self.experimenter)) |
| 2766 | packed.append(struct.pack("!L", self.subtype)) |
| 2767 | packed.append(struct.pack("!B", self.l2_table_enable)) |
| 2768 | packed.append('\x00' * 1) |
| 2769 | packed.append(struct.pack("!H", self.l2_table_priority)) |
| 2770 | packed.append('\x00' * 4) |
| 2771 | length = sum([len(x) for x in packed]) |
| 2772 | packed[2] = struct.pack("!H", length) |
| 2773 | return ''.join(packed) |
| 2774 | |
| 2775 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2776 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2777 | obj = bsn_set_l2_table_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2778 | _version = reader.read("!B")[0] |
| 2779 | assert(_version == 1) |
| 2780 | _type = reader.read("!B")[0] |
| 2781 | assert(_type == 4) |
| 2782 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2783 | orig_reader = reader |
| 2784 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2785 | obj.xid = reader.read("!L")[0] |
| 2786 | _experimenter = reader.read("!L")[0] |
| 2787 | assert(_experimenter == 6035143) |
| 2788 | _subtype = reader.read("!L")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2789 | assert(_subtype == 12) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2790 | obj.l2_table_enable = reader.read("!B")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2791 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2792 | obj.l2_table_priority = reader.read("!H")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2793 | reader.skip(4) |
| 2794 | return obj |
| 2795 | |
| 2796 | def __eq__(self, other): |
| 2797 | if type(self) != type(other): return False |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2798 | if self.xid != other.xid: return False |
| 2799 | if self.l2_table_enable != other.l2_table_enable: return False |
| 2800 | if self.l2_table_priority != other.l2_table_priority: return False |
| 2801 | return True |
| 2802 | |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2803 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2804 | q.text("bsn_set_l2_table_request {") |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 2805 | with q.group(): |
| 2806 | with q.indent(2): |
| 2807 | q.breakable() |
| 2808 | q.text("xid = "); |
| 2809 | if self.xid != None: |
| 2810 | q.text("%#x" % self.xid) |
| 2811 | else: |
| 2812 | q.text('None') |
| 2813 | q.text(","); q.breakable() |
| 2814 | q.text("l2_table_enable = "); |
| 2815 | q.text("%#x" % self.l2_table_enable) |
| 2816 | q.text(","); q.breakable() |
| 2817 | q.text("l2_table_priority = "); |
| 2818 | q.text("%#x" % self.l2_table_priority) |
| 2819 | q.breakable() |
| 2820 | q.text('}') |
| 2821 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2822 | bsn_header.subtypes[12] = bsn_set_l2_table_request |
| 2823 | |
| 2824 | class bsn_set_mirroring(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2825 | version = 1 |
| 2826 | type = 4 |
| 2827 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2828 | subtype = 3 |
| 2829 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2830 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2831 | if xid != None: |
| 2832 | self.xid = xid |
| 2833 | else: |
| 2834 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2835 | if report_mirror_ports != None: |
| 2836 | self.report_mirror_ports = report_mirror_ports |
| 2837 | else: |
| 2838 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2839 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2840 | |
| 2841 | def pack(self): |
| 2842 | packed = [] |
| 2843 | packed.append(struct.pack("!B", self.version)) |
| 2844 | packed.append(struct.pack("!B", self.type)) |
| 2845 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2846 | packed.append(struct.pack("!L", self.xid)) |
| 2847 | packed.append(struct.pack("!L", self.experimenter)) |
| 2848 | packed.append(struct.pack("!L", self.subtype)) |
| 2849 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2850 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2851 | length = sum([len(x) for x in packed]) |
| 2852 | packed[2] = struct.pack("!H", length) |
| 2853 | return ''.join(packed) |
| 2854 | |
| 2855 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2856 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2857 | obj = bsn_set_mirroring() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2858 | _version = reader.read("!B")[0] |
| 2859 | assert(_version == 1) |
| 2860 | _type = reader.read("!B")[0] |
| 2861 | assert(_type == 4) |
| 2862 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2863 | orig_reader = reader |
| 2864 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2865 | obj.xid = reader.read("!L")[0] |
| 2866 | _experimenter = reader.read("!L")[0] |
| 2867 | assert(_experimenter == 6035143) |
| 2868 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2869 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2870 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2871 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2872 | return obj |
| 2873 | |
| 2874 | def __eq__(self, other): |
| 2875 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2876 | if self.xid != other.xid: return False |
| 2877 | if self.report_mirror_ports != other.report_mirror_ports: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2878 | return True |
| 2879 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2880 | def pretty_print(self, q): |
| 2881 | q.text("bsn_set_mirroring {") |
| 2882 | with q.group(): |
| 2883 | with q.indent(2): |
| 2884 | q.breakable() |
| 2885 | q.text("xid = "); |
| 2886 | if self.xid != None: |
| 2887 | q.text("%#x" % self.xid) |
| 2888 | else: |
| 2889 | q.text('None') |
| 2890 | q.text(","); q.breakable() |
| 2891 | q.text("report_mirror_ports = "); |
| 2892 | q.text("%#x" % self.report_mirror_ports) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2893 | q.breakable() |
| 2894 | q.text('}') |
| 2895 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2896 | bsn_header.subtypes[3] = bsn_set_mirroring |
| 2897 | |
| 2898 | class bsn_set_pktin_suppression_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2899 | version = 1 |
| 2900 | type = 4 |
| 2901 | experimenter = 6035143 |
| 2902 | subtype = 25 |
| 2903 | |
| 2904 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2905 | if xid != None: |
| 2906 | self.xid = xid |
| 2907 | else: |
| 2908 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2909 | if status != None: |
| 2910 | self.status = status |
| 2911 | else: |
| 2912 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2913 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2914 | |
| 2915 | def pack(self): |
| 2916 | packed = [] |
| 2917 | packed.append(struct.pack("!B", self.version)) |
| 2918 | packed.append(struct.pack("!B", self.type)) |
| 2919 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2920 | packed.append(struct.pack("!L", self.xid)) |
| 2921 | packed.append(struct.pack("!L", self.experimenter)) |
| 2922 | packed.append(struct.pack("!L", self.subtype)) |
| 2923 | packed.append(struct.pack("!L", self.status)) |
| 2924 | length = sum([len(x) for x in packed]) |
| 2925 | packed[2] = struct.pack("!H", length) |
| 2926 | return ''.join(packed) |
| 2927 | |
| 2928 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2929 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2930 | obj = bsn_set_pktin_suppression_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2931 | _version = reader.read("!B")[0] |
| 2932 | assert(_version == 1) |
| 2933 | _type = reader.read("!B")[0] |
| 2934 | assert(_type == 4) |
| 2935 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2936 | orig_reader = reader |
| 2937 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2938 | obj.xid = reader.read("!L")[0] |
| 2939 | _experimenter = reader.read("!L")[0] |
| 2940 | assert(_experimenter == 6035143) |
| 2941 | _subtype = reader.read("!L")[0] |
| 2942 | assert(_subtype == 25) |
| 2943 | obj.status = reader.read("!L")[0] |
| 2944 | return obj |
| 2945 | |
| 2946 | def __eq__(self, other): |
| 2947 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2948 | if self.xid != other.xid: return False |
| 2949 | if self.status != other.status: return False |
| 2950 | return True |
| 2951 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2952 | def pretty_print(self, q): |
| 2953 | q.text("bsn_set_pktin_suppression_reply {") |
| 2954 | with q.group(): |
| 2955 | with q.indent(2): |
| 2956 | q.breakable() |
| 2957 | q.text("xid = "); |
| 2958 | if self.xid != None: |
| 2959 | q.text("%#x" % self.xid) |
| 2960 | else: |
| 2961 | q.text('None') |
| 2962 | q.text(","); q.breakable() |
| 2963 | q.text("status = "); |
| 2964 | q.text("%#x" % self.status) |
| 2965 | q.breakable() |
| 2966 | q.text('}') |
| 2967 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2968 | bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply |
| 2969 | |
| 2970 | class bsn_set_pktin_suppression_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2971 | version = 1 |
| 2972 | type = 4 |
| 2973 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2974 | subtype = 11 |
| 2975 | |
| 2976 | 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] | 2977 | if xid != None: |
| 2978 | self.xid = xid |
| 2979 | else: |
| 2980 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2981 | if enabled != None: |
| 2982 | self.enabled = enabled |
| 2983 | else: |
| 2984 | self.enabled = 0 |
| 2985 | if idle_timeout != None: |
| 2986 | self.idle_timeout = idle_timeout |
| 2987 | else: |
| 2988 | self.idle_timeout = 0 |
| 2989 | if hard_timeout != None: |
| 2990 | self.hard_timeout = hard_timeout |
| 2991 | else: |
| 2992 | self.hard_timeout = 0 |
| 2993 | if priority != None: |
| 2994 | self.priority = priority |
| 2995 | else: |
| 2996 | self.priority = 0 |
| 2997 | if cookie != None: |
| 2998 | self.cookie = cookie |
| 2999 | else: |
| 3000 | self.cookie = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3001 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3002 | |
| 3003 | def pack(self): |
| 3004 | packed = [] |
| 3005 | packed.append(struct.pack("!B", self.version)) |
| 3006 | packed.append(struct.pack("!B", self.type)) |
| 3007 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3008 | packed.append(struct.pack("!L", self.xid)) |
| 3009 | packed.append(struct.pack("!L", self.experimenter)) |
| 3010 | packed.append(struct.pack("!L", self.subtype)) |
| 3011 | packed.append(struct.pack("!B", self.enabled)) |
| 3012 | packed.append('\x00' * 1) |
| 3013 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3014 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3015 | packed.append(struct.pack("!H", self.priority)) |
| 3016 | packed.append(struct.pack("!Q", self.cookie)) |
| 3017 | length = sum([len(x) for x in packed]) |
| 3018 | packed[2] = struct.pack("!H", length) |
| 3019 | return ''.join(packed) |
| 3020 | |
| 3021 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3022 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3023 | obj = bsn_set_pktin_suppression_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3024 | _version = reader.read("!B")[0] |
| 3025 | assert(_version == 1) |
| 3026 | _type = reader.read("!B")[0] |
| 3027 | assert(_type == 4) |
| 3028 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3029 | orig_reader = reader |
| 3030 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3031 | obj.xid = reader.read("!L")[0] |
| 3032 | _experimenter = reader.read("!L")[0] |
| 3033 | assert(_experimenter == 6035143) |
| 3034 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3035 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3036 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3037 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3038 | obj.idle_timeout = reader.read("!H")[0] |
| 3039 | obj.hard_timeout = reader.read("!H")[0] |
| 3040 | obj.priority = reader.read("!H")[0] |
| 3041 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3042 | return obj |
| 3043 | |
| 3044 | def __eq__(self, other): |
| 3045 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3046 | if self.xid != other.xid: return False |
| 3047 | if self.enabled != other.enabled: return False |
| 3048 | if self.idle_timeout != other.idle_timeout: return False |
| 3049 | if self.hard_timeout != other.hard_timeout: return False |
| 3050 | if self.priority != other.priority: return False |
| 3051 | if self.cookie != other.cookie: return False |
| 3052 | return True |
| 3053 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3054 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3055 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3056 | with q.group(): |
| 3057 | with q.indent(2): |
| 3058 | q.breakable() |
| 3059 | q.text("xid = "); |
| 3060 | if self.xid != None: |
| 3061 | q.text("%#x" % self.xid) |
| 3062 | else: |
| 3063 | q.text('None') |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3064 | q.text(","); q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3065 | q.text("enabled = "); |
| 3066 | q.text("%#x" % self.enabled) |
| 3067 | q.text(","); q.breakable() |
| 3068 | q.text("idle_timeout = "); |
| 3069 | q.text("%#x" % self.idle_timeout) |
| 3070 | q.text(","); q.breakable() |
| 3071 | q.text("hard_timeout = "); |
| 3072 | q.text("%#x" % self.hard_timeout) |
| 3073 | q.text(","); q.breakable() |
| 3074 | q.text("priority = "); |
| 3075 | q.text("%#x" % self.priority) |
| 3076 | q.text(","); q.breakable() |
| 3077 | q.text("cookie = "); |
| 3078 | q.text("%#x" % self.cookie) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3079 | q.breakable() |
| 3080 | q.text('}') |
| 3081 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3082 | bsn_header.subtypes[11] = bsn_set_pktin_suppression_request |
| 3083 | |
| 3084 | class bsn_shell_command(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3085 | version = 1 |
| 3086 | type = 4 |
| 3087 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3088 | subtype = 6 |
| 3089 | |
| 3090 | def __init__(self, xid=None, service=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3091 | if xid != None: |
| 3092 | self.xid = xid |
| 3093 | else: |
| 3094 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3095 | if service != None: |
| 3096 | self.service = service |
| 3097 | else: |
| 3098 | self.service = 0 |
| 3099 | if data != None: |
| 3100 | self.data = data |
| 3101 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3102 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3103 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3104 | |
| 3105 | def pack(self): |
| 3106 | packed = [] |
| 3107 | packed.append(struct.pack("!B", self.version)) |
| 3108 | packed.append(struct.pack("!B", self.type)) |
| 3109 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3110 | packed.append(struct.pack("!L", self.xid)) |
| 3111 | packed.append(struct.pack("!L", self.experimenter)) |
| 3112 | packed.append(struct.pack("!L", self.subtype)) |
| 3113 | packed.append(struct.pack("!L", self.service)) |
| 3114 | packed.append(self.data) |
| 3115 | length = sum([len(x) for x in packed]) |
| 3116 | packed[2] = struct.pack("!H", length) |
| 3117 | return ''.join(packed) |
| 3118 | |
| 3119 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3120 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3121 | obj = bsn_shell_command() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3122 | _version = reader.read("!B")[0] |
| 3123 | assert(_version == 1) |
| 3124 | _type = reader.read("!B")[0] |
| 3125 | assert(_type == 4) |
| 3126 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3127 | orig_reader = reader |
| 3128 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3129 | obj.xid = reader.read("!L")[0] |
| 3130 | _experimenter = reader.read("!L")[0] |
| 3131 | assert(_experimenter == 6035143) |
| 3132 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3133 | assert(_subtype == 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3134 | obj.service = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3135 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3136 | return obj |
| 3137 | |
| 3138 | def __eq__(self, other): |
| 3139 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3140 | if self.xid != other.xid: return False |
| 3141 | if self.service != other.service: return False |
| 3142 | if self.data != other.data: return False |
| 3143 | return True |
| 3144 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3145 | def pretty_print(self, q): |
| 3146 | q.text("bsn_shell_command {") |
| 3147 | with q.group(): |
| 3148 | with q.indent(2): |
| 3149 | q.breakable() |
| 3150 | q.text("xid = "); |
| 3151 | if self.xid != None: |
| 3152 | q.text("%#x" % self.xid) |
| 3153 | else: |
| 3154 | q.text('None') |
| 3155 | q.text(","); q.breakable() |
| 3156 | q.text("service = "); |
| 3157 | q.text("%#x" % self.service) |
| 3158 | q.text(","); q.breakable() |
| 3159 | q.text("data = "); |
| 3160 | q.pp(self.data) |
| 3161 | q.breakable() |
| 3162 | q.text('}') |
| 3163 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3164 | bsn_header.subtypes[6] = bsn_shell_command |
| 3165 | |
| 3166 | class bsn_shell_output(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3167 | version = 1 |
| 3168 | type = 4 |
| 3169 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3170 | subtype = 7 |
| 3171 | |
| 3172 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3173 | if xid != None: |
| 3174 | self.xid = xid |
| 3175 | else: |
| 3176 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3177 | if data != None: |
| 3178 | self.data = data |
| 3179 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3180 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3181 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3182 | |
| 3183 | def pack(self): |
| 3184 | packed = [] |
| 3185 | packed.append(struct.pack("!B", self.version)) |
| 3186 | packed.append(struct.pack("!B", self.type)) |
| 3187 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3188 | packed.append(struct.pack("!L", self.xid)) |
| 3189 | packed.append(struct.pack("!L", self.experimenter)) |
| 3190 | packed.append(struct.pack("!L", self.subtype)) |
| 3191 | packed.append(self.data) |
| 3192 | length = sum([len(x) for x in packed]) |
| 3193 | packed[2] = struct.pack("!H", length) |
| 3194 | return ''.join(packed) |
| 3195 | |
| 3196 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3197 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3198 | obj = bsn_shell_output() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3199 | _version = reader.read("!B")[0] |
| 3200 | assert(_version == 1) |
| 3201 | _type = reader.read("!B")[0] |
| 3202 | assert(_type == 4) |
| 3203 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3204 | orig_reader = reader |
| 3205 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3206 | obj.xid = reader.read("!L")[0] |
| 3207 | _experimenter = reader.read("!L")[0] |
| 3208 | assert(_experimenter == 6035143) |
| 3209 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3210 | assert(_subtype == 7) |
| 3211 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3212 | return obj |
| 3213 | |
| 3214 | def __eq__(self, other): |
| 3215 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3216 | if self.xid != other.xid: return False |
| 3217 | if self.data != other.data: return False |
| 3218 | return True |
| 3219 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3220 | def pretty_print(self, q): |
| 3221 | q.text("bsn_shell_output {") |
| 3222 | with q.group(): |
| 3223 | with q.indent(2): |
| 3224 | q.breakable() |
| 3225 | q.text("xid = "); |
| 3226 | if self.xid != None: |
| 3227 | q.text("%#x" % self.xid) |
| 3228 | else: |
| 3229 | q.text('None') |
| 3230 | q.text(","); q.breakable() |
| 3231 | q.text("data = "); |
| 3232 | q.pp(self.data) |
| 3233 | q.breakable() |
| 3234 | q.text('}') |
| 3235 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3236 | bsn_header.subtypes[7] = bsn_shell_output |
| 3237 | |
| 3238 | class bsn_shell_status(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3239 | version = 1 |
| 3240 | type = 4 |
| 3241 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3242 | subtype = 8 |
| 3243 | |
| 3244 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3245 | if xid != None: |
| 3246 | self.xid = xid |
| 3247 | else: |
| 3248 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3249 | if status != None: |
| 3250 | self.status = status |
| 3251 | else: |
| 3252 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3253 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3254 | |
| 3255 | def pack(self): |
| 3256 | packed = [] |
| 3257 | packed.append(struct.pack("!B", self.version)) |
| 3258 | packed.append(struct.pack("!B", self.type)) |
| 3259 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3260 | packed.append(struct.pack("!L", self.xid)) |
| 3261 | packed.append(struct.pack("!L", self.experimenter)) |
| 3262 | packed.append(struct.pack("!L", self.subtype)) |
| 3263 | packed.append(struct.pack("!L", self.status)) |
| 3264 | length = sum([len(x) for x in packed]) |
| 3265 | packed[2] = struct.pack("!H", length) |
| 3266 | return ''.join(packed) |
| 3267 | |
| 3268 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3269 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3270 | obj = bsn_shell_status() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3271 | _version = reader.read("!B")[0] |
| 3272 | assert(_version == 1) |
| 3273 | _type = reader.read("!B")[0] |
| 3274 | assert(_type == 4) |
| 3275 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3276 | orig_reader = reader |
| 3277 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3278 | obj.xid = reader.read("!L")[0] |
| 3279 | _experimenter = reader.read("!L")[0] |
| 3280 | assert(_experimenter == 6035143) |
| 3281 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3282 | assert(_subtype == 8) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3283 | obj.status = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3284 | return obj |
| 3285 | |
| 3286 | def __eq__(self, other): |
| 3287 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3288 | if self.xid != other.xid: return False |
| 3289 | if self.status != other.status: return False |
| 3290 | return True |
| 3291 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3292 | def pretty_print(self, q): |
| 3293 | q.text("bsn_shell_status {") |
| 3294 | with q.group(): |
| 3295 | with q.indent(2): |
| 3296 | q.breakable() |
| 3297 | q.text("xid = "); |
| 3298 | if self.xid != None: |
| 3299 | q.text("%#x" % self.xid) |
| 3300 | else: |
| 3301 | q.text('None') |
| 3302 | q.text(","); q.breakable() |
| 3303 | q.text("status = "); |
| 3304 | q.text("%#x" % self.status) |
| 3305 | q.breakable() |
| 3306 | q.text('}') |
| 3307 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3308 | bsn_header.subtypes[8] = bsn_shell_status |
| 3309 | |
| 3310 | class experimenter_stats_reply(stats_reply): |
| 3311 | subtypes = {} |
| 3312 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3313 | version = 1 |
| 3314 | type = 17 |
| 3315 | stats_type = 65535 |
| 3316 | |
| 3317 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 3318 | if xid != None: |
| 3319 | self.xid = xid |
| 3320 | else: |
| 3321 | self.xid = None |
| 3322 | if flags != None: |
| 3323 | self.flags = flags |
| 3324 | else: |
| 3325 | self.flags = 0 |
| 3326 | if experimenter != None: |
| 3327 | self.experimenter = experimenter |
| 3328 | else: |
| 3329 | self.experimenter = 0 |
| 3330 | if data != None: |
| 3331 | self.data = data |
| 3332 | else: |
| 3333 | self.data = '' |
| 3334 | return |
| 3335 | |
| 3336 | def pack(self): |
| 3337 | packed = [] |
| 3338 | packed.append(struct.pack("!B", self.version)) |
| 3339 | packed.append(struct.pack("!B", self.type)) |
| 3340 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3341 | packed.append(struct.pack("!L", self.xid)) |
| 3342 | packed.append(struct.pack("!H", self.stats_type)) |
| 3343 | packed.append(struct.pack("!H", self.flags)) |
| 3344 | packed.append(struct.pack("!L", self.experimenter)) |
| 3345 | packed.append(self.data) |
| 3346 | length = sum([len(x) for x in packed]) |
| 3347 | packed[2] = struct.pack("!H", length) |
| 3348 | return ''.join(packed) |
| 3349 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3350 | @staticmethod |
| 3351 | def unpack(reader): |
| 3352 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3353 | subclass = experimenter_stats_reply.subtypes.get(subtype) |
| 3354 | if subclass: |
| 3355 | return subclass.unpack(reader) |
| 3356 | |
| 3357 | obj = experimenter_stats_reply() |
| 3358 | _version = reader.read("!B")[0] |
| 3359 | assert(_version == 1) |
| 3360 | _type = reader.read("!B")[0] |
| 3361 | assert(_type == 17) |
| 3362 | _length = reader.read("!H")[0] |
| 3363 | orig_reader = reader |
| 3364 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3365 | obj.xid = reader.read("!L")[0] |
| 3366 | _stats_type = reader.read("!H")[0] |
| 3367 | assert(_stats_type == 65535) |
| 3368 | obj.flags = reader.read("!H")[0] |
| 3369 | obj.experimenter = reader.read("!L")[0] |
| 3370 | obj.data = str(reader.read_all()) |
| 3371 | return obj |
| 3372 | |
| 3373 | def __eq__(self, other): |
| 3374 | if type(self) != type(other): return False |
| 3375 | if self.xid != other.xid: return False |
| 3376 | if self.flags != other.flags: return False |
| 3377 | if self.experimenter != other.experimenter: return False |
| 3378 | if self.data != other.data: return False |
| 3379 | return True |
| 3380 | |
| 3381 | def pretty_print(self, q): |
| 3382 | q.text("experimenter_stats_reply {") |
| 3383 | with q.group(): |
| 3384 | with q.indent(2): |
| 3385 | q.breakable() |
| 3386 | q.text("xid = "); |
| 3387 | if self.xid != None: |
| 3388 | q.text("%#x" % self.xid) |
| 3389 | else: |
| 3390 | q.text('None') |
| 3391 | q.text(","); q.breakable() |
| 3392 | q.text("flags = "); |
| 3393 | q.text("%#x" % self.flags) |
| 3394 | q.text(","); q.breakable() |
| 3395 | q.text("data = "); |
| 3396 | q.pp(self.data) |
| 3397 | q.breakable() |
| 3398 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3399 | |
| 3400 | stats_reply.subtypes[65535] = experimenter_stats_reply |
| 3401 | |
| 3402 | class bsn_stats_reply(experimenter_stats_reply): |
| 3403 | subtypes = {} |
| 3404 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3405 | version = 1 |
| 3406 | type = 19 |
| 3407 | stats_type = 65535 |
| 3408 | experimenter = 6035143 |
| 3409 | |
| 3410 | def __init__(self, xid=None, flags=None, subtype=None): |
| 3411 | if xid != None: |
| 3412 | self.xid = xid |
| 3413 | else: |
| 3414 | self.xid = None |
| 3415 | if flags != None: |
| 3416 | self.flags = flags |
| 3417 | else: |
| 3418 | self.flags = 0 |
| 3419 | if subtype != None: |
| 3420 | self.subtype = subtype |
| 3421 | else: |
| 3422 | self.subtype = 0 |
| 3423 | return |
| 3424 | |
| 3425 | def pack(self): |
| 3426 | packed = [] |
| 3427 | packed.append(struct.pack("!B", self.version)) |
| 3428 | packed.append(struct.pack("!B", self.type)) |
| 3429 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3430 | packed.append(struct.pack("!L", self.xid)) |
| 3431 | packed.append(struct.pack("!H", self.stats_type)) |
| 3432 | packed.append(struct.pack("!H", self.flags)) |
| 3433 | packed.append('\x00' * 4) |
| 3434 | packed.append(struct.pack("!L", self.experimenter)) |
| 3435 | packed.append(struct.pack("!L", self.subtype)) |
| 3436 | length = sum([len(x) for x in packed]) |
| 3437 | packed[2] = struct.pack("!H", length) |
| 3438 | return ''.join(packed) |
| 3439 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3440 | @staticmethod |
| 3441 | def unpack(reader): |
| 3442 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3443 | subclass = bsn_stats_reply.subtypes.get(subtype) |
| 3444 | if subclass: |
| 3445 | return subclass.unpack(reader) |
| 3446 | |
| 3447 | obj = bsn_stats_reply() |
| 3448 | _version = reader.read("!B")[0] |
| 3449 | assert(_version == 1) |
| 3450 | _type = reader.read("!B")[0] |
| 3451 | assert(_type == 19) |
| 3452 | _length = reader.read("!H")[0] |
| 3453 | orig_reader = reader |
| 3454 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3455 | obj.xid = reader.read("!L")[0] |
| 3456 | _stats_type = reader.read("!H")[0] |
| 3457 | assert(_stats_type == 65535) |
| 3458 | obj.flags = reader.read("!H")[0] |
| 3459 | reader.skip(4) |
| 3460 | _experimenter = reader.read("!L")[0] |
| 3461 | assert(_experimenter == 6035143) |
| 3462 | obj.subtype = reader.read("!L")[0] |
| 3463 | return obj |
| 3464 | |
| 3465 | def __eq__(self, other): |
| 3466 | if type(self) != type(other): return False |
| 3467 | if self.xid != other.xid: return False |
| 3468 | if self.flags != other.flags: return False |
| 3469 | if self.subtype != other.subtype: return False |
| 3470 | return True |
| 3471 | |
| 3472 | def pretty_print(self, q): |
| 3473 | q.text("bsn_stats_reply {") |
| 3474 | with q.group(): |
| 3475 | with q.indent(2): |
| 3476 | q.breakable() |
| 3477 | q.text("xid = "); |
| 3478 | if self.xid != None: |
| 3479 | q.text("%#x" % self.xid) |
| 3480 | else: |
| 3481 | q.text('None') |
| 3482 | q.text(","); q.breakable() |
| 3483 | q.text("flags = "); |
| 3484 | q.text("%#x" % self.flags) |
| 3485 | q.breakable() |
| 3486 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3487 | |
| 3488 | experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply |
| 3489 | |
| 3490 | class experimenter_stats_request(stats_request): |
| 3491 | subtypes = {} |
| 3492 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3493 | version = 1 |
| 3494 | type = 16 |
| 3495 | stats_type = 65535 |
| 3496 | |
| 3497 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 3498 | if xid != None: |
| 3499 | self.xid = xid |
| 3500 | else: |
| 3501 | self.xid = None |
| 3502 | if flags != None: |
| 3503 | self.flags = flags |
| 3504 | else: |
| 3505 | self.flags = 0 |
| 3506 | if experimenter != None: |
| 3507 | self.experimenter = experimenter |
| 3508 | else: |
| 3509 | self.experimenter = 0 |
| 3510 | if data != None: |
| 3511 | self.data = data |
| 3512 | else: |
| 3513 | self.data = '' |
| 3514 | return |
| 3515 | |
| 3516 | def pack(self): |
| 3517 | packed = [] |
| 3518 | packed.append(struct.pack("!B", self.version)) |
| 3519 | packed.append(struct.pack("!B", self.type)) |
| 3520 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3521 | packed.append(struct.pack("!L", self.xid)) |
| 3522 | packed.append(struct.pack("!H", self.stats_type)) |
| 3523 | packed.append(struct.pack("!H", self.flags)) |
| 3524 | packed.append(struct.pack("!L", self.experimenter)) |
| 3525 | packed.append(self.data) |
| 3526 | length = sum([len(x) for x in packed]) |
| 3527 | packed[2] = struct.pack("!H", length) |
| 3528 | return ''.join(packed) |
| 3529 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3530 | @staticmethod |
| 3531 | def unpack(reader): |
| 3532 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3533 | subclass = experimenter_stats_request.subtypes.get(subtype) |
| 3534 | if subclass: |
| 3535 | return subclass.unpack(reader) |
| 3536 | |
| 3537 | obj = experimenter_stats_request() |
| 3538 | _version = reader.read("!B")[0] |
| 3539 | assert(_version == 1) |
| 3540 | _type = reader.read("!B")[0] |
| 3541 | assert(_type == 16) |
| 3542 | _length = reader.read("!H")[0] |
| 3543 | orig_reader = reader |
| 3544 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3545 | obj.xid = reader.read("!L")[0] |
| 3546 | _stats_type = reader.read("!H")[0] |
| 3547 | assert(_stats_type == 65535) |
| 3548 | obj.flags = reader.read("!H")[0] |
| 3549 | obj.experimenter = reader.read("!L")[0] |
| 3550 | obj.data = str(reader.read_all()) |
| 3551 | return obj |
| 3552 | |
| 3553 | def __eq__(self, other): |
| 3554 | if type(self) != type(other): return False |
| 3555 | if self.xid != other.xid: return False |
| 3556 | if self.flags != other.flags: return False |
| 3557 | if self.experimenter != other.experimenter: return False |
| 3558 | if self.data != other.data: return False |
| 3559 | return True |
| 3560 | |
| 3561 | def pretty_print(self, q): |
| 3562 | q.text("experimenter_stats_request {") |
| 3563 | with q.group(): |
| 3564 | with q.indent(2): |
| 3565 | q.breakable() |
| 3566 | q.text("xid = "); |
| 3567 | if self.xid != None: |
| 3568 | q.text("%#x" % self.xid) |
| 3569 | else: |
| 3570 | q.text('None') |
| 3571 | q.text(","); q.breakable() |
| 3572 | q.text("flags = "); |
| 3573 | q.text("%#x" % self.flags) |
| 3574 | q.text(","); q.breakable() |
| 3575 | q.text("data = "); |
| 3576 | q.pp(self.data) |
| 3577 | q.breakable() |
| 3578 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3579 | |
| 3580 | stats_request.subtypes[65535] = experimenter_stats_request |
| 3581 | |
| 3582 | class bsn_stats_request(experimenter_stats_request): |
| 3583 | subtypes = {} |
| 3584 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3585 | version = 1 |
| 3586 | type = 18 |
| 3587 | stats_type = 65535 |
| 3588 | experimenter = 6035143 |
| 3589 | |
| 3590 | def __init__(self, xid=None, flags=None, subtype=None): |
| 3591 | if xid != None: |
| 3592 | self.xid = xid |
| 3593 | else: |
| 3594 | self.xid = None |
| 3595 | if flags != None: |
| 3596 | self.flags = flags |
| 3597 | else: |
| 3598 | self.flags = 0 |
| 3599 | if subtype != None: |
| 3600 | self.subtype = subtype |
| 3601 | else: |
| 3602 | self.subtype = 0 |
| 3603 | return |
| 3604 | |
| 3605 | def pack(self): |
| 3606 | packed = [] |
| 3607 | packed.append(struct.pack("!B", self.version)) |
| 3608 | packed.append(struct.pack("!B", self.type)) |
| 3609 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3610 | packed.append(struct.pack("!L", self.xid)) |
| 3611 | packed.append(struct.pack("!H", self.stats_type)) |
| 3612 | packed.append(struct.pack("!H", self.flags)) |
| 3613 | packed.append('\x00' * 4) |
| 3614 | packed.append(struct.pack("!L", self.experimenter)) |
| 3615 | packed.append(struct.pack("!L", self.subtype)) |
| 3616 | length = sum([len(x) for x in packed]) |
| 3617 | packed[2] = struct.pack("!H", length) |
| 3618 | return ''.join(packed) |
| 3619 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3620 | @staticmethod |
| 3621 | def unpack(reader): |
| 3622 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3623 | subclass = bsn_stats_request.subtypes.get(subtype) |
| 3624 | if subclass: |
| 3625 | return subclass.unpack(reader) |
| 3626 | |
| 3627 | obj = bsn_stats_request() |
| 3628 | _version = reader.read("!B")[0] |
| 3629 | assert(_version == 1) |
| 3630 | _type = reader.read("!B")[0] |
| 3631 | assert(_type == 18) |
| 3632 | _length = reader.read("!H")[0] |
| 3633 | orig_reader = reader |
| 3634 | reader = orig_reader.slice(_length - (2 + 2)) |
| 3635 | obj.xid = reader.read("!L")[0] |
| 3636 | _stats_type = reader.read("!H")[0] |
| 3637 | assert(_stats_type == 65535) |
| 3638 | obj.flags = reader.read("!H")[0] |
| 3639 | reader.skip(4) |
| 3640 | _experimenter = reader.read("!L")[0] |
| 3641 | assert(_experimenter == 6035143) |
| 3642 | obj.subtype = reader.read("!L")[0] |
| 3643 | return obj |
| 3644 | |
| 3645 | def __eq__(self, other): |
| 3646 | if type(self) != type(other): return False |
| 3647 | if self.xid != other.xid: return False |
| 3648 | if self.flags != other.flags: return False |
| 3649 | if self.subtype != other.subtype: return False |
| 3650 | return True |
| 3651 | |
| 3652 | def pretty_print(self, q): |
| 3653 | q.text("bsn_stats_request {") |
| 3654 | with q.group(): |
| 3655 | with q.indent(2): |
| 3656 | q.breakable() |
| 3657 | q.text("xid = "); |
| 3658 | if self.xid != None: |
| 3659 | q.text("%#x" % self.xid) |
| 3660 | else: |
| 3661 | q.text('None') |
| 3662 | q.text(","); q.breakable() |
| 3663 | q.text("flags = "); |
| 3664 | q.text("%#x" % self.flags) |
| 3665 | q.breakable() |
| 3666 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3667 | |
| 3668 | experimenter_stats_request.subtypes[6035143] = bsn_stats_request |
| 3669 | |
| 3670 | class bsn_virtual_port_create_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3671 | version = 1 |
| 3672 | type = 4 |
| 3673 | experimenter = 6035143 |
| 3674 | subtype = 16 |
| 3675 | |
| 3676 | def __init__(self, xid=None, status=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3677 | if xid != None: |
| 3678 | self.xid = xid |
| 3679 | else: |
| 3680 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3681 | if status != None: |
| 3682 | self.status = status |
| 3683 | else: |
| 3684 | self.status = 0 |
| 3685 | if vport_no != None: |
| 3686 | self.vport_no = vport_no |
| 3687 | else: |
| 3688 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3689 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3690 | |
| 3691 | def pack(self): |
| 3692 | packed = [] |
| 3693 | packed.append(struct.pack("!B", self.version)) |
| 3694 | packed.append(struct.pack("!B", self.type)) |
| 3695 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3696 | packed.append(struct.pack("!L", self.xid)) |
| 3697 | packed.append(struct.pack("!L", self.experimenter)) |
| 3698 | packed.append(struct.pack("!L", self.subtype)) |
| 3699 | packed.append(struct.pack("!L", self.status)) |
| 3700 | packed.append(struct.pack("!L", self.vport_no)) |
| 3701 | length = sum([len(x) for x in packed]) |
| 3702 | packed[2] = struct.pack("!H", length) |
| 3703 | return ''.join(packed) |
| 3704 | |
| 3705 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3706 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3707 | obj = bsn_virtual_port_create_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3708 | _version = reader.read("!B")[0] |
| 3709 | assert(_version == 1) |
| 3710 | _type = reader.read("!B")[0] |
| 3711 | assert(_type == 4) |
| 3712 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3713 | orig_reader = reader |
| 3714 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3715 | obj.xid = reader.read("!L")[0] |
| 3716 | _experimenter = reader.read("!L")[0] |
| 3717 | assert(_experimenter == 6035143) |
| 3718 | _subtype = reader.read("!L")[0] |
| 3719 | assert(_subtype == 16) |
| 3720 | obj.status = reader.read("!L")[0] |
| 3721 | obj.vport_no = reader.read("!L")[0] |
| 3722 | return obj |
| 3723 | |
| 3724 | def __eq__(self, other): |
| 3725 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3726 | if self.xid != other.xid: return False |
| 3727 | if self.status != other.status: return False |
| 3728 | if self.vport_no != other.vport_no: return False |
| 3729 | return True |
| 3730 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3731 | def pretty_print(self, q): |
| 3732 | q.text("bsn_virtual_port_create_reply {") |
| 3733 | with q.group(): |
| 3734 | with q.indent(2): |
| 3735 | q.breakable() |
| 3736 | q.text("xid = "); |
| 3737 | if self.xid != None: |
| 3738 | q.text("%#x" % self.xid) |
| 3739 | else: |
| 3740 | q.text('None') |
| 3741 | q.text(","); q.breakable() |
| 3742 | q.text("status = "); |
| 3743 | q.text("%#x" % self.status) |
| 3744 | q.text(","); q.breakable() |
| 3745 | q.text("vport_no = "); |
| 3746 | q.text("%#x" % self.vport_no) |
| 3747 | q.breakable() |
| 3748 | q.text('}') |
| 3749 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3750 | bsn_header.subtypes[16] = bsn_virtual_port_create_reply |
| 3751 | |
| 3752 | class bsn_virtual_port_create_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3753 | version = 1 |
| 3754 | type = 4 |
| 3755 | experimenter = 6035143 |
| 3756 | subtype = 15 |
| 3757 | |
| 3758 | def __init__(self, xid=None, vport=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3759 | if xid != None: |
| 3760 | self.xid = xid |
| 3761 | else: |
| 3762 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3763 | if vport != None: |
| 3764 | self.vport = vport |
| 3765 | else: |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame^] | 3766 | self.vport = common.bsn_vport() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3767 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3768 | |
| 3769 | def pack(self): |
| 3770 | packed = [] |
| 3771 | packed.append(struct.pack("!B", self.version)) |
| 3772 | packed.append(struct.pack("!B", self.type)) |
| 3773 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3774 | packed.append(struct.pack("!L", self.xid)) |
| 3775 | packed.append(struct.pack("!L", self.experimenter)) |
| 3776 | packed.append(struct.pack("!L", self.subtype)) |
| 3777 | packed.append(self.vport.pack()) |
| 3778 | length = sum([len(x) for x in packed]) |
| 3779 | packed[2] = struct.pack("!H", length) |
| 3780 | return ''.join(packed) |
| 3781 | |
| 3782 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3783 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3784 | obj = bsn_virtual_port_create_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3785 | _version = reader.read("!B")[0] |
| 3786 | assert(_version == 1) |
| 3787 | _type = reader.read("!B")[0] |
| 3788 | assert(_type == 4) |
| 3789 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3790 | orig_reader = reader |
| 3791 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3792 | obj.xid = reader.read("!L")[0] |
| 3793 | _experimenter = reader.read("!L")[0] |
| 3794 | assert(_experimenter == 6035143) |
| 3795 | _subtype = reader.read("!L")[0] |
| 3796 | assert(_subtype == 15) |
Rich Lane | 93b3313 | 2014-04-21 12:20:58 -0700 | [diff] [blame^] | 3797 | obj.vport = common.bsn_vport.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3798 | return obj |
| 3799 | |
| 3800 | def __eq__(self, other): |
| 3801 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3802 | if self.xid != other.xid: return False |
| 3803 | if self.vport != other.vport: return False |
| 3804 | return True |
| 3805 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3806 | def pretty_print(self, q): |
| 3807 | q.text("bsn_virtual_port_create_request {") |
| 3808 | with q.group(): |
| 3809 | with q.indent(2): |
| 3810 | q.breakable() |
| 3811 | q.text("xid = "); |
| 3812 | if self.xid != None: |
| 3813 | q.text("%#x" % self.xid) |
| 3814 | else: |
| 3815 | q.text('None') |
| 3816 | q.text(","); q.breakable() |
| 3817 | q.text("vport = "); |
| 3818 | q.pp(self.vport) |
| 3819 | q.breakable() |
| 3820 | q.text('}') |
| 3821 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3822 | bsn_header.subtypes[15] = bsn_virtual_port_create_request |
| 3823 | |
| 3824 | class bsn_virtual_port_remove_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3825 | version = 1 |
| 3826 | type = 4 |
| 3827 | experimenter = 6035143 |
| 3828 | subtype = 26 |
| 3829 | |
| 3830 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3831 | if xid != None: |
| 3832 | self.xid = xid |
| 3833 | else: |
| 3834 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3835 | if status != None: |
| 3836 | self.status = status |
| 3837 | else: |
| 3838 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3839 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3840 | |
| 3841 | def pack(self): |
| 3842 | packed = [] |
| 3843 | packed.append(struct.pack("!B", self.version)) |
| 3844 | packed.append(struct.pack("!B", self.type)) |
| 3845 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3846 | packed.append(struct.pack("!L", self.xid)) |
| 3847 | packed.append(struct.pack("!L", self.experimenter)) |
| 3848 | packed.append(struct.pack("!L", self.subtype)) |
| 3849 | packed.append(struct.pack("!L", self.status)) |
| 3850 | length = sum([len(x) for x in packed]) |
| 3851 | packed[2] = struct.pack("!H", length) |
| 3852 | return ''.join(packed) |
| 3853 | |
| 3854 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3855 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3856 | obj = bsn_virtual_port_remove_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3857 | _version = reader.read("!B")[0] |
| 3858 | assert(_version == 1) |
| 3859 | _type = reader.read("!B")[0] |
| 3860 | assert(_type == 4) |
| 3861 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3862 | orig_reader = reader |
| 3863 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3864 | obj.xid = reader.read("!L")[0] |
| 3865 | _experimenter = reader.read("!L")[0] |
| 3866 | assert(_experimenter == 6035143) |
| 3867 | _subtype = reader.read("!L")[0] |
| 3868 | assert(_subtype == 26) |
| 3869 | obj.status = reader.read("!L")[0] |
| 3870 | return obj |
| 3871 | |
| 3872 | def __eq__(self, other): |
| 3873 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3874 | if self.xid != other.xid: return False |
| 3875 | if self.status != other.status: return False |
| 3876 | return True |
| 3877 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3878 | def pretty_print(self, q): |
| 3879 | q.text("bsn_virtual_port_remove_reply {") |
| 3880 | with q.group(): |
| 3881 | with q.indent(2): |
| 3882 | q.breakable() |
| 3883 | q.text("xid = "); |
| 3884 | if self.xid != None: |
| 3885 | q.text("%#x" % self.xid) |
| 3886 | else: |
| 3887 | q.text('None') |
| 3888 | q.text(","); q.breakable() |
| 3889 | q.text("status = "); |
| 3890 | q.text("%#x" % self.status) |
| 3891 | q.breakable() |
| 3892 | q.text('}') |
| 3893 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3894 | bsn_header.subtypes[26] = bsn_virtual_port_remove_reply |
| 3895 | |
| 3896 | class bsn_virtual_port_remove_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3897 | version = 1 |
| 3898 | type = 4 |
| 3899 | experimenter = 6035143 |
| 3900 | subtype = 17 |
| 3901 | |
| 3902 | def __init__(self, xid=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3903 | if xid != None: |
| 3904 | self.xid = xid |
| 3905 | else: |
| 3906 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3907 | if vport_no != None: |
| 3908 | self.vport_no = vport_no |
| 3909 | else: |
| 3910 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3911 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3912 | |
| 3913 | def pack(self): |
| 3914 | packed = [] |
| 3915 | packed.append(struct.pack("!B", self.version)) |
| 3916 | packed.append(struct.pack("!B", self.type)) |
| 3917 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3918 | packed.append(struct.pack("!L", self.xid)) |
| 3919 | packed.append(struct.pack("!L", self.experimenter)) |
| 3920 | packed.append(struct.pack("!L", self.subtype)) |
| 3921 | packed.append(struct.pack("!L", self.vport_no)) |
| 3922 | length = sum([len(x) for x in packed]) |
| 3923 | packed[2] = struct.pack("!H", length) |
| 3924 | return ''.join(packed) |
| 3925 | |
| 3926 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3927 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3928 | obj = bsn_virtual_port_remove_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3929 | _version = reader.read("!B")[0] |
| 3930 | assert(_version == 1) |
| 3931 | _type = reader.read("!B")[0] |
| 3932 | assert(_type == 4) |
| 3933 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3934 | orig_reader = reader |
| 3935 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3936 | obj.xid = reader.read("!L")[0] |
| 3937 | _experimenter = reader.read("!L")[0] |
| 3938 | assert(_experimenter == 6035143) |
| 3939 | _subtype = reader.read("!L")[0] |
| 3940 | assert(_subtype == 17) |
| 3941 | obj.vport_no = reader.read("!L")[0] |
| 3942 | return obj |
| 3943 | |
| 3944 | def __eq__(self, other): |
| 3945 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3946 | if self.xid != other.xid: return False |
| 3947 | if self.vport_no != other.vport_no: return False |
| 3948 | return True |
| 3949 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3950 | def pretty_print(self, q): |
| 3951 | q.text("bsn_virtual_port_remove_request {") |
| 3952 | with q.group(): |
| 3953 | with q.indent(2): |
| 3954 | q.breakable() |
| 3955 | q.text("xid = "); |
| 3956 | if self.xid != None: |
| 3957 | q.text("%#x" % self.xid) |
| 3958 | else: |
| 3959 | q.text('None') |
| 3960 | q.text(","); q.breakable() |
| 3961 | q.text("vport_no = "); |
| 3962 | q.text("%#x" % self.vport_no) |
| 3963 | q.breakable() |
| 3964 | q.text('}') |
| 3965 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3966 | bsn_header.subtypes[17] = bsn_virtual_port_remove_request |
| 3967 | |
| 3968 | class desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3969 | version = 1 |
| 3970 | type = 17 |
| 3971 | stats_type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3972 | |
| 3973 | 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] | 3974 | if xid != None: |
| 3975 | self.xid = xid |
| 3976 | else: |
| 3977 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3978 | if flags != None: |
| 3979 | self.flags = flags |
| 3980 | else: |
| 3981 | self.flags = 0 |
| 3982 | if mfr_desc != None: |
| 3983 | self.mfr_desc = mfr_desc |
| 3984 | else: |
| 3985 | self.mfr_desc = "" |
| 3986 | if hw_desc != None: |
| 3987 | self.hw_desc = hw_desc |
| 3988 | else: |
| 3989 | self.hw_desc = "" |
| 3990 | if sw_desc != None: |
| 3991 | self.sw_desc = sw_desc |
| 3992 | else: |
| 3993 | self.sw_desc = "" |
| 3994 | if serial_num != None: |
| 3995 | self.serial_num = serial_num |
| 3996 | else: |
| 3997 | self.serial_num = "" |
| 3998 | if dp_desc != None: |
| 3999 | self.dp_desc = dp_desc |
| 4000 | else: |
| 4001 | self.dp_desc = "" |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4002 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4003 | |
| 4004 | def pack(self): |
| 4005 | packed = [] |
| 4006 | packed.append(struct.pack("!B", self.version)) |
| 4007 | packed.append(struct.pack("!B", self.type)) |
| 4008 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4009 | packed.append(struct.pack("!L", self.xid)) |
| 4010 | packed.append(struct.pack("!H", self.stats_type)) |
| 4011 | packed.append(struct.pack("!H", self.flags)) |
| 4012 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 4013 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 4014 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 4015 | packed.append(struct.pack("!32s", self.serial_num)) |
| 4016 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 4017 | length = sum([len(x) for x in packed]) |
| 4018 | packed[2] = struct.pack("!H", length) |
| 4019 | return ''.join(packed) |
| 4020 | |
| 4021 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4022 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4023 | obj = desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4024 | _version = reader.read("!B")[0] |
| 4025 | assert(_version == 1) |
| 4026 | _type = reader.read("!B")[0] |
| 4027 | assert(_type == 17) |
| 4028 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4029 | orig_reader = reader |
| 4030 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4031 | obj.xid = reader.read("!L")[0] |
| 4032 | _stats_type = reader.read("!H")[0] |
| 4033 | assert(_stats_type == 0) |
| 4034 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4035 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4036 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4037 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4038 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 4039 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4040 | return obj |
| 4041 | |
| 4042 | def __eq__(self, other): |
| 4043 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4044 | if self.xid != other.xid: return False |
| 4045 | if self.flags != other.flags: return False |
| 4046 | if self.mfr_desc != other.mfr_desc: return False |
| 4047 | if self.hw_desc != other.hw_desc: return False |
| 4048 | if self.sw_desc != other.sw_desc: return False |
| 4049 | if self.serial_num != other.serial_num: return False |
| 4050 | if self.dp_desc != other.dp_desc: return False |
| 4051 | return True |
| 4052 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4053 | def pretty_print(self, q): |
| 4054 | q.text("desc_stats_reply {") |
| 4055 | with q.group(): |
| 4056 | with q.indent(2): |
| 4057 | q.breakable() |
| 4058 | q.text("xid = "); |
| 4059 | if self.xid != None: |
| 4060 | q.text("%#x" % self.xid) |
| 4061 | else: |
| 4062 | q.text('None') |
| 4063 | q.text(","); q.breakable() |
| 4064 | q.text("flags = "); |
| 4065 | q.text("%#x" % self.flags) |
| 4066 | q.text(","); q.breakable() |
| 4067 | q.text("mfr_desc = "); |
| 4068 | q.pp(self.mfr_desc) |
| 4069 | q.text(","); q.breakable() |
| 4070 | q.text("hw_desc = "); |
| 4071 | q.pp(self.hw_desc) |
| 4072 | q.text(","); q.breakable() |
| 4073 | q.text("sw_desc = "); |
| 4074 | q.pp(self.sw_desc) |
| 4075 | q.text(","); q.breakable() |
| 4076 | q.text("serial_num = "); |
| 4077 | q.pp(self.serial_num) |
| 4078 | q.text(","); q.breakable() |
| 4079 | q.text("dp_desc = "); |
| 4080 | q.pp(self.dp_desc) |
| 4081 | q.breakable() |
| 4082 | q.text('}') |
| 4083 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4084 | stats_reply.subtypes[0] = desc_stats_reply |
| 4085 | |
| 4086 | class desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4087 | version = 1 |
| 4088 | type = 16 |
| 4089 | stats_type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4090 | |
| 4091 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4092 | if xid != None: |
| 4093 | self.xid = xid |
| 4094 | else: |
| 4095 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4096 | if flags != None: |
| 4097 | self.flags = flags |
| 4098 | else: |
| 4099 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4100 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4101 | |
| 4102 | def pack(self): |
| 4103 | packed = [] |
| 4104 | packed.append(struct.pack("!B", self.version)) |
| 4105 | packed.append(struct.pack("!B", self.type)) |
| 4106 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4107 | packed.append(struct.pack("!L", self.xid)) |
| 4108 | packed.append(struct.pack("!H", self.stats_type)) |
| 4109 | packed.append(struct.pack("!H", self.flags)) |
| 4110 | length = sum([len(x) for x in packed]) |
| 4111 | packed[2] = struct.pack("!H", length) |
| 4112 | return ''.join(packed) |
| 4113 | |
| 4114 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4115 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4116 | obj = desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4117 | _version = reader.read("!B")[0] |
| 4118 | assert(_version == 1) |
| 4119 | _type = reader.read("!B")[0] |
| 4120 | assert(_type == 16) |
| 4121 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4122 | orig_reader = reader |
| 4123 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4124 | obj.xid = reader.read("!L")[0] |
| 4125 | _stats_type = reader.read("!H")[0] |
| 4126 | assert(_stats_type == 0) |
| 4127 | obj.flags = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4128 | return obj |
| 4129 | |
| 4130 | def __eq__(self, other): |
| 4131 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4132 | if self.xid != other.xid: return False |
| 4133 | if self.flags != other.flags: return False |
| 4134 | return True |
| 4135 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4136 | def pretty_print(self, q): |
| 4137 | q.text("desc_stats_request {") |
| 4138 | with q.group(): |
| 4139 | with q.indent(2): |
| 4140 | q.breakable() |
| 4141 | q.text("xid = "); |
| 4142 | if self.xid != None: |
| 4143 | q.text("%#x" % self.xid) |
| 4144 | else: |
| 4145 | q.text('None') |
| 4146 | q.text(","); q.breakable() |
| 4147 | q.text("flags = "); |
| 4148 | q.text("%#x" % self.flags) |
| 4149 | q.breakable() |
| 4150 | q.text('}') |
| 4151 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4152 | stats_request.subtypes[0] = desc_stats_request |
| 4153 | |
| 4154 | class echo_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4155 | version = 1 |
| 4156 | type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4157 | |
| 4158 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4159 | if xid != None: |
| 4160 | self.xid = xid |
| 4161 | else: |
| 4162 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4163 | if data != None: |
| 4164 | self.data = data |
| 4165 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4166 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4167 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4168 | |
| 4169 | def pack(self): |
| 4170 | packed = [] |
| 4171 | packed.append(struct.pack("!B", self.version)) |
| 4172 | packed.append(struct.pack("!B", self.type)) |
| 4173 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4174 | packed.append(struct.pack("!L", self.xid)) |
| 4175 | packed.append(self.data) |
| 4176 | length = sum([len(x) for x in packed]) |
| 4177 | packed[2] = struct.pack("!H", length) |
| 4178 | return ''.join(packed) |
| 4179 | |
| 4180 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4181 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4182 | obj = echo_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4183 | _version = reader.read("!B")[0] |
| 4184 | assert(_version == 1) |
| 4185 | _type = reader.read("!B")[0] |
| 4186 | assert(_type == 3) |
| 4187 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4188 | orig_reader = reader |
| 4189 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4190 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4191 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4192 | return obj |
| 4193 | |
| 4194 | def __eq__(self, other): |
| 4195 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4196 | if self.xid != other.xid: return False |
| 4197 | if self.data != other.data: return False |
| 4198 | return True |
| 4199 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4200 | def pretty_print(self, q): |
| 4201 | q.text("echo_reply {") |
| 4202 | with q.group(): |
| 4203 | with q.indent(2): |
| 4204 | q.breakable() |
| 4205 | q.text("xid = "); |
| 4206 | if self.xid != None: |
| 4207 | q.text("%#x" % self.xid) |
| 4208 | else: |
| 4209 | q.text('None') |
| 4210 | q.text(","); q.breakable() |
| 4211 | q.text("data = "); |
| 4212 | q.pp(self.data) |
| 4213 | q.breakable() |
| 4214 | q.text('}') |
| 4215 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4216 | message.subtypes[3] = echo_reply |
| 4217 | |
| 4218 | class echo_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4219 | version = 1 |
| 4220 | type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4221 | |
| 4222 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4223 | if xid != None: |
| 4224 | self.xid = xid |
| 4225 | else: |
| 4226 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4227 | if data != None: |
| 4228 | self.data = data |
| 4229 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4230 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4231 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4232 | |
| 4233 | def pack(self): |
| 4234 | packed = [] |
| 4235 | packed.append(struct.pack("!B", self.version)) |
| 4236 | packed.append(struct.pack("!B", self.type)) |
| 4237 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4238 | packed.append(struct.pack("!L", self.xid)) |
| 4239 | packed.append(self.data) |
| 4240 | length = sum([len(x) for x in packed]) |
| 4241 | packed[2] = struct.pack("!H", length) |
| 4242 | return ''.join(packed) |
| 4243 | |
| 4244 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4245 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4246 | obj = echo_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4247 | _version = reader.read("!B")[0] |
| 4248 | assert(_version == 1) |
| 4249 | _type = reader.read("!B")[0] |
| 4250 | assert(_type == 2) |
| 4251 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4252 | orig_reader = reader |
| 4253 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4254 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4255 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4256 | return obj |
| 4257 | |
| 4258 | def __eq__(self, other): |
| 4259 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4260 | if self.xid != other.xid: return False |
| 4261 | if self.data != other.data: return False |
| 4262 | return True |
| 4263 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4264 | def pretty_print(self, q): |
| 4265 | q.text("echo_request {") |
| 4266 | with q.group(): |
| 4267 | with q.indent(2): |
| 4268 | q.breakable() |
| 4269 | q.text("xid = "); |
| 4270 | if self.xid != None: |
| 4271 | q.text("%#x" % self.xid) |
| 4272 | else: |
| 4273 | q.text('None') |
| 4274 | q.text(","); q.breakable() |
| 4275 | q.text("data = "); |
| 4276 | q.pp(self.data) |
| 4277 | q.breakable() |
| 4278 | q.text('}') |
| 4279 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4280 | message.subtypes[2] = echo_request |
| 4281 | |
| 4282 | class features_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4283 | version = 1 |
| 4284 | type = 6 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4285 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4286 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, actions=None, ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4287 | if xid != None: |
| 4288 | self.xid = xid |
| 4289 | else: |
| 4290 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4291 | if datapath_id != None: |
| 4292 | self.datapath_id = datapath_id |
| 4293 | else: |
| 4294 | self.datapath_id = 0 |
| 4295 | if n_buffers != None: |
| 4296 | self.n_buffers = n_buffers |
| 4297 | else: |
| 4298 | self.n_buffers = 0 |
| 4299 | if n_tables != None: |
| 4300 | self.n_tables = n_tables |
| 4301 | else: |
| 4302 | self.n_tables = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4303 | if capabilities != None: |
| 4304 | self.capabilities = capabilities |
| 4305 | else: |
| 4306 | self.capabilities = 0 |
| 4307 | if actions != None: |
| 4308 | self.actions = actions |
| 4309 | else: |
| 4310 | self.actions = 0 |
| 4311 | if ports != None: |
| 4312 | self.ports = ports |
| 4313 | else: |
| 4314 | self.ports = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4315 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4316 | |
| 4317 | def pack(self): |
| 4318 | packed = [] |
| 4319 | packed.append(struct.pack("!B", self.version)) |
| 4320 | packed.append(struct.pack("!B", self.type)) |
| 4321 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4322 | packed.append(struct.pack("!L", self.xid)) |
| 4323 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 4324 | packed.append(struct.pack("!L", self.n_buffers)) |
| 4325 | packed.append(struct.pack("!B", self.n_tables)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4326 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4327 | packed.append(struct.pack("!L", self.capabilities)) |
| 4328 | packed.append(struct.pack("!L", self.actions)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4329 | packed.append(loxi.generic_util.pack_list(self.ports)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4330 | length = sum([len(x) for x in packed]) |
| 4331 | packed[2] = struct.pack("!H", length) |
| 4332 | return ''.join(packed) |
| 4333 | |
| 4334 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4335 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4336 | obj = features_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4337 | _version = reader.read("!B")[0] |
| 4338 | assert(_version == 1) |
| 4339 | _type = reader.read("!B")[0] |
| 4340 | assert(_type == 6) |
| 4341 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4342 | orig_reader = reader |
| 4343 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4344 | obj.xid = reader.read("!L")[0] |
| 4345 | obj.datapath_id = reader.read("!Q")[0] |
| 4346 | obj.n_buffers = reader.read("!L")[0] |
| 4347 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4348 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4349 | obj.capabilities = reader.read("!L")[0] |
| 4350 | obj.actions = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4351 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4352 | return obj |
| 4353 | |
| 4354 | def __eq__(self, other): |
| 4355 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4356 | if self.xid != other.xid: return False |
| 4357 | if self.datapath_id != other.datapath_id: return False |
| 4358 | if self.n_buffers != other.n_buffers: return False |
| 4359 | if self.n_tables != other.n_tables: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4360 | if self.capabilities != other.capabilities: return False |
| 4361 | if self.actions != other.actions: return False |
| 4362 | if self.ports != other.ports: return False |
| 4363 | return True |
| 4364 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4365 | def pretty_print(self, q): |
| 4366 | q.text("features_reply {") |
| 4367 | with q.group(): |
| 4368 | with q.indent(2): |
| 4369 | q.breakable() |
| 4370 | q.text("xid = "); |
| 4371 | if self.xid != None: |
| 4372 | q.text("%#x" % self.xid) |
| 4373 | else: |
| 4374 | q.text('None') |
| 4375 | q.text(","); q.breakable() |
| 4376 | q.text("datapath_id = "); |
| 4377 | q.text("%#x" % self.datapath_id) |
| 4378 | q.text(","); q.breakable() |
| 4379 | q.text("n_buffers = "); |
| 4380 | q.text("%#x" % self.n_buffers) |
| 4381 | q.text(","); q.breakable() |
| 4382 | q.text("n_tables = "); |
| 4383 | q.text("%#x" % self.n_tables) |
| 4384 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4385 | q.text("capabilities = "); |
| 4386 | q.text("%#x" % self.capabilities) |
| 4387 | q.text(","); q.breakable() |
| 4388 | q.text("actions = "); |
| 4389 | q.text("%#x" % self.actions) |
| 4390 | q.text(","); q.breakable() |
| 4391 | q.text("ports = "); |
| 4392 | q.pp(self.ports) |
| 4393 | q.breakable() |
| 4394 | q.text('}') |
| 4395 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4396 | message.subtypes[6] = features_reply |
| 4397 | |
| 4398 | class features_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4399 | version = 1 |
| 4400 | type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4401 | |
| 4402 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4403 | if xid != None: |
| 4404 | self.xid = xid |
| 4405 | else: |
| 4406 | self.xid = None |
| 4407 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4408 | |
| 4409 | def pack(self): |
| 4410 | packed = [] |
| 4411 | packed.append(struct.pack("!B", self.version)) |
| 4412 | packed.append(struct.pack("!B", self.type)) |
| 4413 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4414 | packed.append(struct.pack("!L", self.xid)) |
| 4415 | length = sum([len(x) for x in packed]) |
| 4416 | packed[2] = struct.pack("!H", length) |
| 4417 | return ''.join(packed) |
| 4418 | |
| 4419 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4420 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4421 | obj = features_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4422 | _version = reader.read("!B")[0] |
| 4423 | assert(_version == 1) |
| 4424 | _type = reader.read("!B")[0] |
| 4425 | assert(_type == 5) |
| 4426 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4427 | orig_reader = reader |
| 4428 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4429 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4430 | return obj |
| 4431 | |
| 4432 | def __eq__(self, other): |
| 4433 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4434 | if self.xid != other.xid: return False |
| 4435 | return True |
| 4436 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4437 | def pretty_print(self, q): |
| 4438 | q.text("features_request {") |
| 4439 | with q.group(): |
| 4440 | with q.indent(2): |
| 4441 | q.breakable() |
| 4442 | q.text("xid = "); |
| 4443 | if self.xid != None: |
| 4444 | q.text("%#x" % self.xid) |
| 4445 | else: |
| 4446 | q.text('None') |
| 4447 | q.breakable() |
| 4448 | q.text('}') |
| 4449 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4450 | message.subtypes[5] = features_request |
| 4451 | |
| 4452 | class flow_mod(message): |
| 4453 | subtypes = {} |
| 4454 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 4455 | version = 1 |
| 4456 | type = 14 |
| 4457 | |
| 4458 | def __init__(self, xid=None, match=None, cookie=None, _command=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
| 4459 | if xid != None: |
| 4460 | self.xid = xid |
| 4461 | else: |
| 4462 | self.xid = None |
| 4463 | if match != None: |
| 4464 | self.match = match |
| 4465 | else: |
| 4466 | self.match = common.match() |
| 4467 | if cookie != None: |
| 4468 | self.cookie = cookie |
| 4469 | else: |
| 4470 | self.cookie = 0 |
| 4471 | if _command != None: |
| 4472 | self._command = _command |
| 4473 | else: |
| 4474 | self._command = 0 |
| 4475 | if idle_timeout != None: |
| 4476 | self.idle_timeout = idle_timeout |
| 4477 | else: |
| 4478 | self.idle_timeout = 0 |
| 4479 | if hard_timeout != None: |
| 4480 | self.hard_timeout = hard_timeout |
| 4481 | else: |
| 4482 | self.hard_timeout = 0 |
| 4483 | if priority != None: |
| 4484 | self.priority = priority |
| 4485 | else: |
| 4486 | self.priority = 0 |
| 4487 | if buffer_id != None: |
| 4488 | self.buffer_id = buffer_id |
| 4489 | else: |
| 4490 | self.buffer_id = 0 |
| 4491 | if out_port != None: |
| 4492 | self.out_port = out_port |
| 4493 | else: |
| 4494 | self.out_port = 0 |
| 4495 | if flags != None: |
| 4496 | self.flags = flags |
| 4497 | else: |
| 4498 | self.flags = 0 |
| 4499 | if actions != None: |
| 4500 | self.actions = actions |
| 4501 | else: |
| 4502 | self.actions = [] |
| 4503 | return |
| 4504 | |
| 4505 | def pack(self): |
| 4506 | packed = [] |
| 4507 | packed.append(struct.pack("!B", self.version)) |
| 4508 | packed.append(struct.pack("!B", self.type)) |
| 4509 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4510 | packed.append(struct.pack("!L", self.xid)) |
| 4511 | packed.append(self.match.pack()) |
| 4512 | packed.append(struct.pack("!Q", self.cookie)) |
| 4513 | packed.append(util.pack_fm_cmd(self._command)) |
| 4514 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4515 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4516 | packed.append(struct.pack("!H", self.priority)) |
| 4517 | packed.append(struct.pack("!L", self.buffer_id)) |
| 4518 | packed.append(util.pack_port_no(self.out_port)) |
| 4519 | packed.append(struct.pack("!H", self.flags)) |
| 4520 | packed.append(loxi.generic_util.pack_list(self.actions)) |
| 4521 | length = sum([len(x) for x in packed]) |
| 4522 | packed[2] = struct.pack("!H", length) |
| 4523 | return ''.join(packed) |
| 4524 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4525 | @staticmethod |
| 4526 | def unpack(reader): |
| 4527 | subtype, = reader.peek('!H', 56) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 4528 | subclass = flow_mod.subtypes.get(subtype) |
| 4529 | if subclass: |
| 4530 | return subclass.unpack(reader) |
| 4531 | |
| 4532 | obj = flow_mod() |
| 4533 | _version = reader.read("!B")[0] |
| 4534 | assert(_version == 1) |
| 4535 | _type = reader.read("!B")[0] |
| 4536 | assert(_type == 14) |
| 4537 | _length = reader.read("!H")[0] |
| 4538 | orig_reader = reader |
| 4539 | reader = orig_reader.slice(_length - (2 + 2)) |
| 4540 | obj.xid = reader.read("!L")[0] |
| 4541 | obj.match = common.match.unpack(reader) |
| 4542 | obj.cookie = reader.read("!Q")[0] |
| 4543 | obj._command = util.unpack_fm_cmd(reader) |
| 4544 | obj.idle_timeout = reader.read("!H")[0] |
| 4545 | obj.hard_timeout = reader.read("!H")[0] |
| 4546 | obj.priority = reader.read("!H")[0] |
| 4547 | obj.buffer_id = reader.read("!L")[0] |
| 4548 | obj.out_port = util.unpack_port_no(reader) |
| 4549 | obj.flags = reader.read("!H")[0] |
| 4550 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
| 4551 | return obj |
| 4552 | |
| 4553 | def __eq__(self, other): |
| 4554 | if type(self) != type(other): return False |
| 4555 | if self.xid != other.xid: return False |
| 4556 | if self.match != other.match: return False |
| 4557 | if self.cookie != other.cookie: return False |
| 4558 | if self._command != other._command: return False |
| 4559 | if self.idle_timeout != other.idle_timeout: return False |
| 4560 | if self.hard_timeout != other.hard_timeout: return False |
| 4561 | if self.priority != other.priority: return False |
| 4562 | if self.buffer_id != other.buffer_id: return False |
| 4563 | if self.out_port != other.out_port: return False |
| 4564 | if self.flags != other.flags: return False |
| 4565 | if self.actions != other.actions: return False |
| 4566 | return True |
| 4567 | |
| 4568 | def pretty_print(self, q): |
| 4569 | q.text("flow_mod {") |
| 4570 | with q.group(): |
| 4571 | with q.indent(2): |
| 4572 | q.breakable() |
| 4573 | q.text("xid = "); |
| 4574 | if self.xid != None: |
| 4575 | q.text("%#x" % self.xid) |
| 4576 | else: |
| 4577 | q.text('None') |
| 4578 | q.text(","); q.breakable() |
| 4579 | q.text("match = "); |
| 4580 | q.pp(self.match) |
| 4581 | q.text(","); q.breakable() |
| 4582 | q.text("cookie = "); |
| 4583 | q.text("%#x" % self.cookie) |
| 4584 | q.text(","); q.breakable() |
| 4585 | q.text("idle_timeout = "); |
| 4586 | q.text("%#x" % self.idle_timeout) |
| 4587 | q.text(","); q.breakable() |
| 4588 | q.text("hard_timeout = "); |
| 4589 | q.text("%#x" % self.hard_timeout) |
| 4590 | q.text(","); q.breakable() |
| 4591 | q.text("priority = "); |
| 4592 | q.text("%#x" % self.priority) |
| 4593 | q.text(","); q.breakable() |
| 4594 | q.text("buffer_id = "); |
| 4595 | q.text("%#x" % self.buffer_id) |
| 4596 | q.text(","); q.breakable() |
| 4597 | q.text("out_port = "); |
| 4598 | q.text(util.pretty_port(self.out_port)) |
| 4599 | q.text(","); q.breakable() |
| 4600 | q.text("flags = "); |
| 4601 | q.text("%#x" % self.flags) |
| 4602 | q.text(","); q.breakable() |
| 4603 | q.text("actions = "); |
| 4604 | q.pp(self.actions) |
| 4605 | q.breakable() |
| 4606 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4607 | |
| 4608 | message.subtypes[14] = flow_mod |
| 4609 | |
| 4610 | class flow_add(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4611 | version = 1 |
| 4612 | type = 14 |
| 4613 | _command = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4614 | |
| 4615 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4616 | if xid != None: |
| 4617 | self.xid = xid |
| 4618 | else: |
| 4619 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4620 | if match != None: |
| 4621 | self.match = match |
| 4622 | else: |
| 4623 | self.match = common.match() |
| 4624 | if cookie != None: |
| 4625 | self.cookie = cookie |
| 4626 | else: |
| 4627 | self.cookie = 0 |
| 4628 | if idle_timeout != None: |
| 4629 | self.idle_timeout = idle_timeout |
| 4630 | else: |
| 4631 | self.idle_timeout = 0 |
| 4632 | if hard_timeout != None: |
| 4633 | self.hard_timeout = hard_timeout |
| 4634 | else: |
| 4635 | self.hard_timeout = 0 |
| 4636 | if priority != None: |
| 4637 | self.priority = priority |
| 4638 | else: |
| 4639 | self.priority = 0 |
| 4640 | if buffer_id != None: |
| 4641 | self.buffer_id = buffer_id |
| 4642 | else: |
| 4643 | self.buffer_id = 0 |
| 4644 | if out_port != None: |
| 4645 | self.out_port = out_port |
| 4646 | else: |
| 4647 | self.out_port = 0 |
| 4648 | if flags != None: |
| 4649 | self.flags = flags |
| 4650 | else: |
| 4651 | self.flags = 0 |
| 4652 | if actions != None: |
| 4653 | self.actions = actions |
| 4654 | else: |
| 4655 | self.actions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4656 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4657 | |
| 4658 | def pack(self): |
| 4659 | packed = [] |
| 4660 | packed.append(struct.pack("!B", self.version)) |
| 4661 | packed.append(struct.pack("!B", self.type)) |
| 4662 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4663 | packed.append(struct.pack("!L", self.xid)) |
| 4664 | packed.append(self.match.pack()) |
| 4665 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4666 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4667 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4668 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4669 | packed.append(struct.pack("!H", self.priority)) |
| 4670 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4671 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4672 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4673 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4674 | length = sum([len(x) for x in packed]) |
| 4675 | packed[2] = struct.pack("!H", length) |
| 4676 | return ''.join(packed) |
| 4677 | |
| 4678 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4679 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4680 | obj = flow_add() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4681 | _version = reader.read("!B")[0] |
| 4682 | assert(_version == 1) |
| 4683 | _type = reader.read("!B")[0] |
| 4684 | assert(_type == 14) |
| 4685 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4686 | orig_reader = reader |
| 4687 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4688 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4689 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4690 | obj.cookie = reader.read("!Q")[0] |
| 4691 | __command = util.unpack_fm_cmd(reader) |
| 4692 | assert(__command == 0) |
| 4693 | obj.idle_timeout = reader.read("!H")[0] |
| 4694 | obj.hard_timeout = reader.read("!H")[0] |
| 4695 | obj.priority = reader.read("!H")[0] |
| 4696 | obj.buffer_id = reader.read("!L")[0] |
| 4697 | obj.out_port = util.unpack_port_no(reader) |
| 4698 | obj.flags = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4699 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4700 | return obj |
| 4701 | |
| 4702 | def __eq__(self, other): |
| 4703 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4704 | if self.xid != other.xid: return False |
| 4705 | if self.match != other.match: return False |
| 4706 | if self.cookie != other.cookie: return False |
| 4707 | if self.idle_timeout != other.idle_timeout: return False |
| 4708 | if self.hard_timeout != other.hard_timeout: return False |
| 4709 | if self.priority != other.priority: return False |
| 4710 | if self.buffer_id != other.buffer_id: return False |
| 4711 | if self.out_port != other.out_port: return False |
| 4712 | if self.flags != other.flags: return False |
| 4713 | if self.actions != other.actions: return False |
| 4714 | return True |
| 4715 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4716 | def pretty_print(self, q): |
| 4717 | q.text("flow_add {") |
| 4718 | with q.group(): |
| 4719 | with q.indent(2): |
| 4720 | q.breakable() |
| 4721 | q.text("xid = "); |
| 4722 | if self.xid != None: |
| 4723 | q.text("%#x" % self.xid) |
| 4724 | else: |
| 4725 | q.text('None') |
| 4726 | q.text(","); q.breakable() |
| 4727 | q.text("match = "); |
| 4728 | q.pp(self.match) |
| 4729 | q.text(","); q.breakable() |
| 4730 | q.text("cookie = "); |
| 4731 | q.text("%#x" % self.cookie) |
| 4732 | q.text(","); q.breakable() |
| 4733 | q.text("idle_timeout = "); |
| 4734 | q.text("%#x" % self.idle_timeout) |
| 4735 | q.text(","); q.breakable() |
| 4736 | q.text("hard_timeout = "); |
| 4737 | q.text("%#x" % self.hard_timeout) |
| 4738 | q.text(","); q.breakable() |
| 4739 | q.text("priority = "); |
| 4740 | q.text("%#x" % self.priority) |
| 4741 | q.text(","); q.breakable() |
| 4742 | q.text("buffer_id = "); |
| 4743 | q.text("%#x" % self.buffer_id) |
| 4744 | q.text(","); q.breakable() |
| 4745 | q.text("out_port = "); |
| 4746 | q.text(util.pretty_port(self.out_port)) |
| 4747 | q.text(","); q.breakable() |
| 4748 | q.text("flags = "); |
| 4749 | q.text("%#x" % self.flags) |
| 4750 | q.text(","); q.breakable() |
| 4751 | q.text("actions = "); |
| 4752 | q.pp(self.actions) |
| 4753 | q.breakable() |
| 4754 | q.text('}') |
| 4755 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4756 | flow_mod.subtypes[0] = flow_add |
| 4757 | |
| 4758 | class flow_delete(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4759 | version = 1 |
| 4760 | type = 14 |
| 4761 | _command = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4762 | |
| 4763 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4764 | if xid != None: |
| 4765 | self.xid = xid |
| 4766 | else: |
| 4767 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4768 | if match != None: |
| 4769 | self.match = match |
| 4770 | else: |
| 4771 | self.match = common.match() |
| 4772 | if cookie != None: |
| 4773 | self.cookie = cookie |
| 4774 | else: |
| 4775 | self.cookie = 0 |
| 4776 | if idle_timeout != None: |
| 4777 | self.idle_timeout = idle_timeout |
| 4778 | else: |
| 4779 | self.idle_timeout = 0 |
| 4780 | if hard_timeout != None: |
| 4781 | self.hard_timeout = hard_timeout |
| 4782 | else: |
| 4783 | self.hard_timeout = 0 |
| 4784 | if priority != None: |
| 4785 | self.priority = priority |
| 4786 | else: |
| 4787 | self.priority = 0 |
| 4788 | if buffer_id != None: |
| 4789 | self.buffer_id = buffer_id |
| 4790 | else: |
| 4791 | self.buffer_id = 0 |
| 4792 | if out_port != None: |
| 4793 | self.out_port = out_port |
| 4794 | else: |
| 4795 | self.out_port = 0 |
| 4796 | if flags != None: |
| 4797 | self.flags = flags |
| 4798 | else: |
| 4799 | self.flags = 0 |
| 4800 | if actions != None: |
| 4801 | self.actions = actions |
| 4802 | else: |
| 4803 | self.actions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4804 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4805 | |
| 4806 | def pack(self): |
| 4807 | packed = [] |
| 4808 | packed.append(struct.pack("!B", self.version)) |
| 4809 | packed.append(struct.pack("!B", self.type)) |
| 4810 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4811 | packed.append(struct.pack("!L", self.xid)) |
| 4812 | packed.append(self.match.pack()) |
| 4813 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4814 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4815 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4816 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4817 | packed.append(struct.pack("!H", self.priority)) |
| 4818 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4819 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4820 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4821 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4822 | length = sum([len(x) for x in packed]) |
| 4823 | packed[2] = struct.pack("!H", length) |
| 4824 | return ''.join(packed) |
| 4825 | |
| 4826 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4827 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4828 | obj = flow_delete() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4829 | _version = reader.read("!B")[0] |
| 4830 | assert(_version == 1) |
| 4831 | _type = reader.read("!B")[0] |
| 4832 | assert(_type == 14) |
| 4833 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4834 | orig_reader = reader |
| 4835 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4836 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4837 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4838 | obj.cookie = reader.read("!Q")[0] |
| 4839 | __command = util.unpack_fm_cmd(reader) |
| 4840 | assert(__command == 3) |
| 4841 | obj.idle_timeout = reader.read("!H")[0] |
| 4842 | obj.hard_timeout = reader.read("!H")[0] |
| 4843 | obj.priority = reader.read("!H")[0] |
| 4844 | obj.buffer_id = reader.read("!L")[0] |
| 4845 | obj.out_port = util.unpack_port_no(reader) |
| 4846 | obj.flags = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4847 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4848 | return obj |
| 4849 | |
| 4850 | def __eq__(self, other): |
| 4851 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4852 | if self.xid != other.xid: return False |
| 4853 | if self.match != other.match: return False |
| 4854 | if self.cookie != other.cookie: return False |
| 4855 | if self.idle_timeout != other.idle_timeout: return False |
| 4856 | if self.hard_timeout != other.hard_timeout: return False |
| 4857 | if self.priority != other.priority: return False |
| 4858 | if self.buffer_id != other.buffer_id: return False |
| 4859 | if self.out_port != other.out_port: return False |
| 4860 | if self.flags != other.flags: return False |
| 4861 | if self.actions != other.actions: return False |
| 4862 | return True |
| 4863 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4864 | def pretty_print(self, q): |
| 4865 | q.text("flow_delete {") |
| 4866 | with q.group(): |
| 4867 | with q.indent(2): |
| 4868 | q.breakable() |
| 4869 | q.text("xid = "); |
| 4870 | if self.xid != None: |
| 4871 | q.text("%#x" % self.xid) |
| 4872 | else: |
| 4873 | q.text('None') |
| 4874 | q.text(","); q.breakable() |
| 4875 | q.text("match = "); |
| 4876 | q.pp(self.match) |
| 4877 | q.text(","); q.breakable() |
| 4878 | q.text("cookie = "); |
| 4879 | q.text("%#x" % self.cookie) |
| 4880 | q.text(","); q.breakable() |
| 4881 | q.text("idle_timeout = "); |
| 4882 | q.text("%#x" % self.idle_timeout) |
| 4883 | q.text(","); q.breakable() |
| 4884 | q.text("hard_timeout = "); |
| 4885 | q.text("%#x" % self.hard_timeout) |
| 4886 | q.text(","); q.breakable() |
| 4887 | q.text("priority = "); |
| 4888 | q.text("%#x" % self.priority) |
| 4889 | q.text(","); q.breakable() |
| 4890 | q.text("buffer_id = "); |
| 4891 | q.text("%#x" % self.buffer_id) |
| 4892 | q.text(","); q.breakable() |
| 4893 | q.text("out_port = "); |
| 4894 | q.text(util.pretty_port(self.out_port)) |
| 4895 | q.text(","); q.breakable() |
| 4896 | q.text("flags = "); |
| 4897 | q.text("%#x" % self.flags) |
| 4898 | q.text(","); q.breakable() |
| 4899 | q.text("actions = "); |
| 4900 | q.pp(self.actions) |
| 4901 | q.breakable() |
| 4902 | q.text('}') |
| 4903 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4904 | flow_mod.subtypes[3] = flow_delete |
| 4905 | |
| 4906 | class flow_delete_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4907 | version = 1 |
| 4908 | type = 14 |
| 4909 | _command = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4910 | |
| 4911 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4912 | if xid != None: |
| 4913 | self.xid = xid |
| 4914 | else: |
| 4915 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4916 | if match != None: |
| 4917 | self.match = match |
| 4918 | else: |
| 4919 | self.match = common.match() |
| 4920 | if cookie != None: |
| 4921 | self.cookie = cookie |
| 4922 | else: |
| 4923 | self.cookie = 0 |
| 4924 | if idle_timeout != None: |
| 4925 | self.idle_timeout = idle_timeout |
| 4926 | else: |
| 4927 | self.idle_timeout = 0 |
| 4928 | if hard_timeout != None: |
| 4929 | self.hard_timeout = hard_timeout |
| 4930 | else: |
| 4931 | self.hard_timeout = 0 |
| 4932 | if priority != None: |
| 4933 | self.priority = priority |
| 4934 | else: |
| 4935 | self.priority = 0 |
| 4936 | if buffer_id != None: |
| 4937 | self.buffer_id = buffer_id |
| 4938 | else: |
| 4939 | self.buffer_id = 0 |
| 4940 | if out_port != None: |
| 4941 | self.out_port = out_port |
| 4942 | else: |
| 4943 | self.out_port = 0 |
| 4944 | if flags != None: |
| 4945 | self.flags = flags |
| 4946 | else: |
| 4947 | self.flags = 0 |
| 4948 | if actions != None: |
| 4949 | self.actions = actions |
| 4950 | else: |
| 4951 | self.actions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4952 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4953 | |
| 4954 | def pack(self): |
| 4955 | packed = [] |
| 4956 | packed.append(struct.pack("!B", self.version)) |
| 4957 | packed.append(struct.pack("!B", self.type)) |
| 4958 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4959 | packed.append(struct.pack("!L", self.xid)) |
| 4960 | packed.append(self.match.pack()) |
| 4961 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4962 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4963 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4964 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4965 | packed.append(struct.pack("!H", self.priority)) |
| 4966 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4967 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4968 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4969 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4970 | length = sum([len(x) for x in packed]) |
| 4971 | packed[2] = struct.pack("!H", length) |
| 4972 | return ''.join(packed) |
| 4973 | |
| 4974 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4975 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4976 | obj = flow_delete_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4977 | _version = reader.read("!B")[0] |
| 4978 | assert(_version == 1) |
| 4979 | _type = reader.read("!B")[0] |
| 4980 | assert(_type == 14) |
| 4981 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4982 | orig_reader = reader |
| 4983 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4984 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4985 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4986 | obj.cookie = reader.read("!Q")[0] |
| 4987 | __command = util.unpack_fm_cmd(reader) |
| 4988 | assert(__command == 4) |
| 4989 | obj.idle_timeout = reader.read("!H")[0] |
| 4990 | obj.hard_timeout = reader.read("!H")[0] |
| 4991 | obj.priority = reader.read("!H")[0] |
| 4992 | obj.buffer_id = reader.read("!L")[0] |
| 4993 | obj.out_port = util.unpack_port_no(reader) |
| 4994 | obj.flags = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4995 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4996 | return obj |
| 4997 | |
| 4998 | def __eq__(self, other): |
| 4999 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5000 | if self.xid != other.xid: return False |
| 5001 | if self.match != other.match: return False |
| 5002 | if self.cookie != other.cookie: return False |
| 5003 | if self.idle_timeout != other.idle_timeout: return False |
| 5004 | if self.hard_timeout != other.hard_timeout: return False |
| 5005 | if self.priority != other.priority: return False |
| 5006 | if self.buffer_id != other.buffer_id: return False |
| 5007 | if self.out_port != other.out_port: return False |
| 5008 | if self.flags != other.flags: return False |
| 5009 | if self.actions != other.actions: return False |
| 5010 | return True |
| 5011 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5012 | def pretty_print(self, q): |
| 5013 | q.text("flow_delete_strict {") |
| 5014 | with q.group(): |
| 5015 | with q.indent(2): |
| 5016 | q.breakable() |
| 5017 | q.text("xid = "); |
| 5018 | if self.xid != None: |
| 5019 | q.text("%#x" % self.xid) |
| 5020 | else: |
| 5021 | q.text('None') |
| 5022 | q.text(","); q.breakable() |
| 5023 | q.text("match = "); |
| 5024 | q.pp(self.match) |
| 5025 | q.text(","); q.breakable() |
| 5026 | q.text("cookie = "); |
| 5027 | q.text("%#x" % self.cookie) |
| 5028 | q.text(","); q.breakable() |
| 5029 | q.text("idle_timeout = "); |
| 5030 | q.text("%#x" % self.idle_timeout) |
| 5031 | q.text(","); q.breakable() |
| 5032 | q.text("hard_timeout = "); |
| 5033 | q.text("%#x" % self.hard_timeout) |
| 5034 | q.text(","); q.breakable() |
| 5035 | q.text("priority = "); |
| 5036 | q.text("%#x" % self.priority) |
| 5037 | q.text(","); q.breakable() |
| 5038 | q.text("buffer_id = "); |
| 5039 | q.text("%#x" % self.buffer_id) |
| 5040 | q.text(","); q.breakable() |
| 5041 | q.text("out_port = "); |
| 5042 | q.text(util.pretty_port(self.out_port)) |
| 5043 | q.text(","); q.breakable() |
| 5044 | q.text("flags = "); |
| 5045 | q.text("%#x" % self.flags) |
| 5046 | q.text(","); q.breakable() |
| 5047 | q.text("actions = "); |
| 5048 | q.pp(self.actions) |
| 5049 | q.breakable() |
| 5050 | q.text('}') |
| 5051 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5052 | flow_mod.subtypes[4] = flow_delete_strict |
| 5053 | |
| 5054 | class flow_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5055 | version = 1 |
| 5056 | type = 1 |
| 5057 | err_type = 3 |
| 5058 | |
| 5059 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5060 | if xid != None: |
| 5061 | self.xid = xid |
| 5062 | else: |
| 5063 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5064 | if code != None: |
| 5065 | self.code = code |
| 5066 | else: |
| 5067 | self.code = 0 |
| 5068 | if data != None: |
| 5069 | self.data = data |
| 5070 | else: |
| 5071 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5072 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5073 | |
| 5074 | def pack(self): |
| 5075 | packed = [] |
| 5076 | packed.append(struct.pack("!B", self.version)) |
| 5077 | packed.append(struct.pack("!B", self.type)) |
| 5078 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5079 | packed.append(struct.pack("!L", self.xid)) |
| 5080 | packed.append(struct.pack("!H", self.err_type)) |
| 5081 | packed.append(struct.pack("!H", self.code)) |
| 5082 | packed.append(self.data) |
| 5083 | length = sum([len(x) for x in packed]) |
| 5084 | packed[2] = struct.pack("!H", length) |
| 5085 | return ''.join(packed) |
| 5086 | |
| 5087 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5088 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5089 | obj = flow_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5090 | _version = reader.read("!B")[0] |
| 5091 | assert(_version == 1) |
| 5092 | _type = reader.read("!B")[0] |
| 5093 | assert(_type == 1) |
| 5094 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5095 | orig_reader = reader |
| 5096 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5097 | obj.xid = reader.read("!L")[0] |
| 5098 | _err_type = reader.read("!H")[0] |
| 5099 | assert(_err_type == 3) |
| 5100 | obj.code = reader.read("!H")[0] |
| 5101 | obj.data = str(reader.read_all()) |
| 5102 | return obj |
| 5103 | |
| 5104 | def __eq__(self, other): |
| 5105 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5106 | if self.xid != other.xid: return False |
| 5107 | if self.code != other.code: return False |
| 5108 | if self.data != other.data: return False |
| 5109 | return True |
| 5110 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5111 | def pretty_print(self, q): |
| 5112 | q.text("flow_mod_failed_error_msg {") |
| 5113 | with q.group(): |
| 5114 | with q.indent(2): |
| 5115 | q.breakable() |
| 5116 | q.text("xid = "); |
| 5117 | if self.xid != None: |
| 5118 | q.text("%#x" % self.xid) |
| 5119 | else: |
| 5120 | q.text('None') |
| 5121 | q.text(","); q.breakable() |
| 5122 | q.text("code = "); |
| 5123 | q.text("%#x" % self.code) |
| 5124 | q.text(","); q.breakable() |
| 5125 | q.text("data = "); |
| 5126 | q.pp(self.data) |
| 5127 | q.breakable() |
| 5128 | q.text('}') |
| 5129 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5130 | error_msg.subtypes[3] = flow_mod_failed_error_msg |
| 5131 | |
| 5132 | class flow_modify(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5133 | version = 1 |
| 5134 | type = 14 |
| 5135 | _command = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5136 | |
| 5137 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5138 | if xid != None: |
| 5139 | self.xid = xid |
| 5140 | else: |
| 5141 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5142 | if match != None: |
| 5143 | self.match = match |
| 5144 | else: |
| 5145 | self.match = common.match() |
| 5146 | if cookie != None: |
| 5147 | self.cookie = cookie |
| 5148 | else: |
| 5149 | self.cookie = 0 |
| 5150 | if idle_timeout != None: |
| 5151 | self.idle_timeout = idle_timeout |
| 5152 | else: |
| 5153 | self.idle_timeout = 0 |
| 5154 | if hard_timeout != None: |
| 5155 | self.hard_timeout = hard_timeout |
| 5156 | else: |
| 5157 | self.hard_timeout = 0 |
| 5158 | if priority != None: |
| 5159 | self.priority = priority |
| 5160 | else: |
| 5161 | self.priority = 0 |
| 5162 | if buffer_id != None: |
| 5163 | self.buffer_id = buffer_id |
| 5164 | else: |
| 5165 | self.buffer_id = 0 |
| 5166 | if out_port != None: |
| 5167 | self.out_port = out_port |
| 5168 | else: |
| 5169 | self.out_port = 0 |
| 5170 | if flags != None: |
| 5171 | self.flags = flags |
| 5172 | else: |
| 5173 | self.flags = 0 |
| 5174 | if actions != None: |
| 5175 | self.actions = actions |
| 5176 | else: |
| 5177 | self.actions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5178 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5179 | |
| 5180 | def pack(self): |
| 5181 | packed = [] |
| 5182 | packed.append(struct.pack("!B", self.version)) |
| 5183 | packed.append(struct.pack("!B", self.type)) |
| 5184 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5185 | packed.append(struct.pack("!L", self.xid)) |
| 5186 | packed.append(self.match.pack()) |
| 5187 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5188 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5189 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5190 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5191 | packed.append(struct.pack("!H", self.priority)) |
| 5192 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5193 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5194 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5195 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5196 | length = sum([len(x) for x in packed]) |
| 5197 | packed[2] = struct.pack("!H", length) |
| 5198 | return ''.join(packed) |
| 5199 | |
| 5200 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5201 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5202 | obj = flow_modify() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5203 | _version = reader.read("!B")[0] |
| 5204 | assert(_version == 1) |
| 5205 | _type = reader.read("!B")[0] |
| 5206 | assert(_type == 14) |
| 5207 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5208 | orig_reader = reader |
| 5209 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5210 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5211 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5212 | obj.cookie = reader.read("!Q")[0] |
| 5213 | __command = util.unpack_fm_cmd(reader) |
| 5214 | assert(__command == 1) |
| 5215 | obj.idle_timeout = reader.read("!H")[0] |
| 5216 | obj.hard_timeout = reader.read("!H")[0] |
| 5217 | obj.priority = reader.read("!H")[0] |
| 5218 | obj.buffer_id = reader.read("!L")[0] |
| 5219 | obj.out_port = util.unpack_port_no(reader) |
| 5220 | obj.flags = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5221 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5222 | return obj |
| 5223 | |
| 5224 | def __eq__(self, other): |
| 5225 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5226 | if self.xid != other.xid: return False |
| 5227 | if self.match != other.match: return False |
| 5228 | if self.cookie != other.cookie: return False |
| 5229 | if self.idle_timeout != other.idle_timeout: return False |
| 5230 | if self.hard_timeout != other.hard_timeout: return False |
| 5231 | if self.priority != other.priority: return False |
| 5232 | if self.buffer_id != other.buffer_id: return False |
| 5233 | if self.out_port != other.out_port: return False |
| 5234 | if self.flags != other.flags: return False |
| 5235 | if self.actions != other.actions: return False |
| 5236 | return True |
| 5237 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5238 | def pretty_print(self, q): |
| 5239 | q.text("flow_modify {") |
| 5240 | with q.group(): |
| 5241 | with q.indent(2): |
| 5242 | q.breakable() |
| 5243 | q.text("xid = "); |
| 5244 | if self.xid != None: |
| 5245 | q.text("%#x" % self.xid) |
| 5246 | else: |
| 5247 | q.text('None') |
| 5248 | q.text(","); q.breakable() |
| 5249 | q.text("match = "); |
| 5250 | q.pp(self.match) |
| 5251 | q.text(","); q.breakable() |
| 5252 | q.text("cookie = "); |
| 5253 | q.text("%#x" % self.cookie) |
| 5254 | q.text(","); q.breakable() |
| 5255 | q.text("idle_timeout = "); |
| 5256 | q.text("%#x" % self.idle_timeout) |
| 5257 | q.text(","); q.breakable() |
| 5258 | q.text("hard_timeout = "); |
| 5259 | q.text("%#x" % self.hard_timeout) |
| 5260 | q.text(","); q.breakable() |
| 5261 | q.text("priority = "); |
| 5262 | q.text("%#x" % self.priority) |
| 5263 | q.text(","); q.breakable() |
| 5264 | q.text("buffer_id = "); |
| 5265 | q.text("%#x" % self.buffer_id) |
| 5266 | q.text(","); q.breakable() |
| 5267 | q.text("out_port = "); |
| 5268 | q.text(util.pretty_port(self.out_port)) |
| 5269 | q.text(","); q.breakable() |
| 5270 | q.text("flags = "); |
| 5271 | q.text("%#x" % self.flags) |
| 5272 | q.text(","); q.breakable() |
| 5273 | q.text("actions = "); |
| 5274 | q.pp(self.actions) |
| 5275 | q.breakable() |
| 5276 | q.text('}') |
| 5277 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5278 | flow_mod.subtypes[1] = flow_modify |
| 5279 | |
| 5280 | class flow_modify_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5281 | version = 1 |
| 5282 | type = 14 |
| 5283 | _command = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5284 | |
| 5285 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5286 | if xid != None: |
| 5287 | self.xid = xid |
| 5288 | else: |
| 5289 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5290 | if match != None: |
| 5291 | self.match = match |
| 5292 | else: |
| 5293 | self.match = common.match() |
| 5294 | if cookie != None: |
| 5295 | self.cookie = cookie |
| 5296 | else: |
| 5297 | self.cookie = 0 |
| 5298 | if idle_timeout != None: |
| 5299 | self.idle_timeout = idle_timeout |
| 5300 | else: |
| 5301 | self.idle_timeout = 0 |
| 5302 | if hard_timeout != None: |
| 5303 | self.hard_timeout = hard_timeout |
| 5304 | else: |
| 5305 | self.hard_timeout = 0 |
| 5306 | if priority != None: |
| 5307 | self.priority = priority |
| 5308 | else: |
| 5309 | self.priority = 0 |
| 5310 | if buffer_id != None: |
| 5311 | self.buffer_id = buffer_id |
| 5312 | else: |
| 5313 | self.buffer_id = 0 |
| 5314 | if out_port != None: |
| 5315 | self.out_port = out_port |
| 5316 | else: |
| 5317 | self.out_port = 0 |
| 5318 | if flags != None: |
| 5319 | self.flags = flags |
| 5320 | else: |
| 5321 | self.flags = 0 |
| 5322 | if actions != None: |
| 5323 | self.actions = actions |
| 5324 | else: |
| 5325 | self.actions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5326 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5327 | |
| 5328 | def pack(self): |
| 5329 | packed = [] |
| 5330 | packed.append(struct.pack("!B", self.version)) |
| 5331 | packed.append(struct.pack("!B", self.type)) |
| 5332 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5333 | packed.append(struct.pack("!L", self.xid)) |
| 5334 | packed.append(self.match.pack()) |
| 5335 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5336 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5337 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5338 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5339 | packed.append(struct.pack("!H", self.priority)) |
| 5340 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5341 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5342 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5343 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5344 | length = sum([len(x) for x in packed]) |
| 5345 | packed[2] = struct.pack("!H", length) |
| 5346 | return ''.join(packed) |
| 5347 | |
| 5348 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5349 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5350 | obj = flow_modify_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5351 | _version = reader.read("!B")[0] |
| 5352 | assert(_version == 1) |
| 5353 | _type = reader.read("!B")[0] |
| 5354 | assert(_type == 14) |
| 5355 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5356 | orig_reader = reader |
| 5357 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5358 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5359 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5360 | obj.cookie = reader.read("!Q")[0] |
| 5361 | __command = util.unpack_fm_cmd(reader) |
| 5362 | assert(__command == 2) |
| 5363 | obj.idle_timeout = reader.read("!H")[0] |
| 5364 | obj.hard_timeout = reader.read("!H")[0] |
| 5365 | obj.priority = reader.read("!H")[0] |
| 5366 | obj.buffer_id = reader.read("!L")[0] |
| 5367 | obj.out_port = util.unpack_port_no(reader) |
| 5368 | obj.flags = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5369 | obj.actions = loxi.generic_util.unpack_list(reader, action.action.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5370 | return obj |
| 5371 | |
| 5372 | def __eq__(self, other): |
| 5373 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5374 | if self.xid != other.xid: return False |
| 5375 | if self.match != other.match: return False |
| 5376 | if self.cookie != other.cookie: return False |
| 5377 | if self.idle_timeout != other.idle_timeout: return False |
| 5378 | if self.hard_timeout != other.hard_timeout: return False |
| 5379 | if self.priority != other.priority: return False |
| 5380 | if self.buffer_id != other.buffer_id: return False |
| 5381 | if self.out_port != other.out_port: return False |
| 5382 | if self.flags != other.flags: return False |
| 5383 | if self.actions != other.actions: return False |
| 5384 | return True |
| 5385 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5386 | def pretty_print(self, q): |
| 5387 | q.text("flow_modify_strict {") |
| 5388 | with q.group(): |
| 5389 | with q.indent(2): |
| 5390 | q.breakable() |
| 5391 | q.text("xid = "); |
| 5392 | if self.xid != None: |
| 5393 | q.text("%#x" % self.xid) |
| 5394 | else: |
| 5395 | q.text('None') |
| 5396 | q.text(","); q.breakable() |
| 5397 | q.text("match = "); |
| 5398 | q.pp(self.match) |
| 5399 | q.text(","); q.breakable() |
| 5400 | q.text("cookie = "); |
| 5401 | q.text("%#x" % self.cookie) |
| 5402 | q.text(","); q.breakable() |
| 5403 | q.text("idle_timeout = "); |
| 5404 | q.text("%#x" % self.idle_timeout) |
| 5405 | q.text(","); q.breakable() |
| 5406 | q.text("hard_timeout = "); |
| 5407 | q.text("%#x" % self.hard_timeout) |
| 5408 | q.text(","); q.breakable() |
| 5409 | q.text("priority = "); |
| 5410 | q.text("%#x" % self.priority) |
| 5411 | q.text(","); q.breakable() |
| 5412 | q.text("buffer_id = "); |
| 5413 | q.text("%#x" % self.buffer_id) |
| 5414 | q.text(","); q.breakable() |
| 5415 | q.text("out_port = "); |
| 5416 | q.text(util.pretty_port(self.out_port)) |
| 5417 | q.text(","); q.breakable() |
| 5418 | q.text("flags = "); |
| 5419 | q.text("%#x" % self.flags) |
| 5420 | q.text(","); q.breakable() |
| 5421 | q.text("actions = "); |
| 5422 | q.pp(self.actions) |
| 5423 | q.breakable() |
| 5424 | q.text('}') |
| 5425 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5426 | flow_mod.subtypes[2] = flow_modify_strict |
| 5427 | |
| 5428 | class flow_removed(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5429 | version = 1 |
| 5430 | type = 11 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5431 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5432 | def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5433 | if xid != None: |
| 5434 | self.xid = xid |
| 5435 | else: |
| 5436 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5437 | if match != None: |
| 5438 | self.match = match |
| 5439 | else: |
| 5440 | self.match = common.match() |
| 5441 | if cookie != None: |
| 5442 | self.cookie = cookie |
| 5443 | else: |
| 5444 | self.cookie = 0 |
| 5445 | if priority != None: |
| 5446 | self.priority = priority |
| 5447 | else: |
| 5448 | self.priority = 0 |
| 5449 | if reason != None: |
| 5450 | self.reason = reason |
| 5451 | else: |
| 5452 | self.reason = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5453 | if duration_sec != None: |
| 5454 | self.duration_sec = duration_sec |
| 5455 | else: |
| 5456 | self.duration_sec = 0 |
| 5457 | if duration_nsec != None: |
| 5458 | self.duration_nsec = duration_nsec |
| 5459 | else: |
| 5460 | self.duration_nsec = 0 |
| 5461 | if idle_timeout != None: |
| 5462 | self.idle_timeout = idle_timeout |
| 5463 | else: |
| 5464 | self.idle_timeout = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5465 | if packet_count != None: |
| 5466 | self.packet_count = packet_count |
| 5467 | else: |
| 5468 | self.packet_count = 0 |
| 5469 | if byte_count != None: |
| 5470 | self.byte_count = byte_count |
| 5471 | else: |
| 5472 | self.byte_count = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5473 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5474 | |
| 5475 | def pack(self): |
| 5476 | packed = [] |
| 5477 | packed.append(struct.pack("!B", self.version)) |
| 5478 | packed.append(struct.pack("!B", self.type)) |
| 5479 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5480 | packed.append(struct.pack("!L", self.xid)) |
| 5481 | packed.append(self.match.pack()) |
| 5482 | packed.append(struct.pack("!Q", self.cookie)) |
| 5483 | packed.append(struct.pack("!H", self.priority)) |
| 5484 | packed.append(struct.pack("!B", self.reason)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5485 | packed.append('\x00' * 1) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5486 | packed.append(struct.pack("!L", self.duration_sec)) |
| 5487 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 5488 | packed.append(struct.pack("!H", self.idle_timeout)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5489 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5490 | packed.append(struct.pack("!Q", self.packet_count)) |
| 5491 | packed.append(struct.pack("!Q", self.byte_count)) |
| 5492 | length = sum([len(x) for x in packed]) |
| 5493 | packed[2] = struct.pack("!H", length) |
| 5494 | return ''.join(packed) |
| 5495 | |
| 5496 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5497 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5498 | obj = flow_removed() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5499 | _version = reader.read("!B")[0] |
| 5500 | assert(_version == 1) |
| 5501 | _type = reader.read("!B")[0] |
| 5502 | assert(_type == 11) |
| 5503 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5504 | orig_reader = reader |
| 5505 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5506 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5507 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5508 | obj.cookie = reader.read("!Q")[0] |
| 5509 | obj.priority = reader.read("!H")[0] |
| 5510 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5511 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5512 | obj.duration_sec = reader.read("!L")[0] |
| 5513 | obj.duration_nsec = reader.read("!L")[0] |
| 5514 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5515 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5516 | obj.packet_count = reader.read("!Q")[0] |
| 5517 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5518 | return obj |
| 5519 | |
| 5520 | def __eq__(self, other): |
| 5521 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5522 | if self.xid != other.xid: return False |
| 5523 | if self.match != other.match: return False |
| 5524 | if self.cookie != other.cookie: return False |
| 5525 | if self.priority != other.priority: return False |
| 5526 | if self.reason != other.reason: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5527 | if self.duration_sec != other.duration_sec: return False |
| 5528 | if self.duration_nsec != other.duration_nsec: return False |
| 5529 | if self.idle_timeout != other.idle_timeout: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5530 | if self.packet_count != other.packet_count: return False |
| 5531 | if self.byte_count != other.byte_count: return False |
| 5532 | return True |
| 5533 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5534 | def pretty_print(self, q): |
| 5535 | q.text("flow_removed {") |
| 5536 | with q.group(): |
| 5537 | with q.indent(2): |
| 5538 | q.breakable() |
| 5539 | q.text("xid = "); |
| 5540 | if self.xid != None: |
| 5541 | q.text("%#x" % self.xid) |
| 5542 | else: |
| 5543 | q.text('None') |
| 5544 | q.text(","); q.breakable() |
| 5545 | q.text("match = "); |
| 5546 | q.pp(self.match) |
| 5547 | q.text(","); q.breakable() |
| 5548 | q.text("cookie = "); |
| 5549 | q.text("%#x" % self.cookie) |
| 5550 | q.text(","); q.breakable() |
| 5551 | q.text("priority = "); |
| 5552 | q.text("%#x" % self.priority) |
| 5553 | q.text(","); q.breakable() |
| 5554 | q.text("reason = "); |
| 5555 | q.text("%#x" % self.reason) |
| 5556 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5557 | q.text("duration_sec = "); |
| 5558 | q.text("%#x" % self.duration_sec) |
| 5559 | q.text(","); q.breakable() |
| 5560 | q.text("duration_nsec = "); |
| 5561 | q.text("%#x" % self.duration_nsec) |
| 5562 | q.text(","); q.breakable() |
| 5563 | q.text("idle_timeout = "); |
| 5564 | q.text("%#x" % self.idle_timeout) |
| 5565 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5566 | q.text("packet_count = "); |
| 5567 | q.text("%#x" % self.packet_count) |
| 5568 | q.text(","); q.breakable() |
| 5569 | q.text("byte_count = "); |
| 5570 | q.text("%#x" % self.byte_count) |
| 5571 | q.breakable() |
| 5572 | q.text('}') |
| 5573 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5574 | message.subtypes[11] = flow_removed |
| 5575 | |
| 5576 | class flow_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5577 | version = 1 |
| 5578 | type = 17 |
| 5579 | stats_type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5580 | |
| 5581 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5582 | if xid != None: |
| 5583 | self.xid = xid |
| 5584 | else: |
| 5585 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5586 | if flags != None: |
| 5587 | self.flags = flags |
| 5588 | else: |
| 5589 | self.flags = 0 |
| 5590 | if entries != None: |
| 5591 | self.entries = entries |
| 5592 | else: |
| 5593 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5594 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5595 | |
| 5596 | def pack(self): |
| 5597 | packed = [] |
| 5598 | packed.append(struct.pack("!B", self.version)) |
| 5599 | packed.append(struct.pack("!B", self.type)) |
| 5600 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5601 | packed.append(struct.pack("!L", self.xid)) |
| 5602 | packed.append(struct.pack("!H", self.stats_type)) |
| 5603 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5604 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5605 | length = sum([len(x) for x in packed]) |
| 5606 | packed[2] = struct.pack("!H", length) |
| 5607 | return ''.join(packed) |
| 5608 | |
| 5609 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5610 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5611 | obj = flow_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5612 | _version = reader.read("!B")[0] |
| 5613 | assert(_version == 1) |
| 5614 | _type = reader.read("!B")[0] |
| 5615 | assert(_type == 17) |
| 5616 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5617 | orig_reader = reader |
| 5618 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5619 | obj.xid = reader.read("!L")[0] |
| 5620 | _stats_type = reader.read("!H")[0] |
| 5621 | assert(_stats_type == 1) |
| 5622 | obj.flags = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5623 | obj.entries = loxi.generic_util.unpack_list(reader, common.flow_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5624 | return obj |
| 5625 | |
| 5626 | def __eq__(self, other): |
| 5627 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5628 | if self.xid != other.xid: return False |
| 5629 | if self.flags != other.flags: return False |
| 5630 | if self.entries != other.entries: return False |
| 5631 | return True |
| 5632 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5633 | def pretty_print(self, q): |
| 5634 | q.text("flow_stats_reply {") |
| 5635 | with q.group(): |
| 5636 | with q.indent(2): |
| 5637 | q.breakable() |
| 5638 | q.text("xid = "); |
| 5639 | if self.xid != None: |
| 5640 | q.text("%#x" % self.xid) |
| 5641 | else: |
| 5642 | q.text('None') |
| 5643 | q.text(","); q.breakable() |
| 5644 | q.text("flags = "); |
| 5645 | q.text("%#x" % self.flags) |
| 5646 | q.text(","); q.breakable() |
| 5647 | q.text("entries = "); |
| 5648 | q.pp(self.entries) |
| 5649 | q.breakable() |
| 5650 | q.text('}') |
| 5651 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5652 | stats_reply.subtypes[1] = flow_stats_reply |
| 5653 | |
| 5654 | class flow_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5655 | version = 1 |
| 5656 | type = 16 |
| 5657 | stats_type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5658 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5659 | def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5660 | if xid != None: |
| 5661 | self.xid = xid |
| 5662 | else: |
| 5663 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5664 | if flags != None: |
| 5665 | self.flags = flags |
| 5666 | else: |
| 5667 | self.flags = 0 |
| 5668 | if match != None: |
| 5669 | self.match = match |
| 5670 | else: |
| 5671 | self.match = common.match() |
| 5672 | if table_id != None: |
| 5673 | self.table_id = table_id |
| 5674 | else: |
| 5675 | self.table_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5676 | if out_port != None: |
| 5677 | self.out_port = out_port |
| 5678 | else: |
| 5679 | self.out_port = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5680 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5681 | |
| 5682 | def pack(self): |
| 5683 | packed = [] |
| 5684 | packed.append(struct.pack("!B", self.version)) |
| 5685 | packed.append(struct.pack("!B", self.type)) |
| 5686 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5687 | packed.append(struct.pack("!L", self.xid)) |
| 5688 | packed.append(struct.pack("!H", self.stats_type)) |
| 5689 | packed.append(struct.pack("!H", self.flags)) |
| 5690 | packed.append(self.match.pack()) |
| 5691 | packed.append(struct.pack("!B", self.table_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5692 | packed.append('\x00' * 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5693 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5694 | length = sum([len(x) for x in packed]) |
| 5695 | packed[2] = struct.pack("!H", length) |
| 5696 | return ''.join(packed) |
| 5697 | |
| 5698 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5699 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5700 | obj = flow_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5701 | _version = reader.read("!B")[0] |
| 5702 | assert(_version == 1) |
| 5703 | _type = reader.read("!B")[0] |
| 5704 | assert(_type == 16) |
| 5705 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5706 | orig_reader = reader |
| 5707 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5708 | obj.xid = reader.read("!L")[0] |
| 5709 | _stats_type = reader.read("!H")[0] |
| 5710 | assert(_stats_type == 1) |
| 5711 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5712 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5713 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5714 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5715 | obj.out_port = util.unpack_port_no(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5716 | return obj |
| 5717 | |
| 5718 | def __eq__(self, other): |
| 5719 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5720 | if self.xid != other.xid: return False |
| 5721 | if self.flags != other.flags: return False |
| 5722 | if self.match != other.match: return False |
| 5723 | if self.table_id != other.table_id: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5724 | if self.out_port != other.out_port: return False |
| 5725 | return True |
| 5726 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5727 | def pretty_print(self, q): |
| 5728 | q.text("flow_stats_request {") |
| 5729 | with q.group(): |
| 5730 | with q.indent(2): |
| 5731 | q.breakable() |
| 5732 | q.text("xid = "); |
| 5733 | if self.xid != None: |
| 5734 | q.text("%#x" % self.xid) |
| 5735 | else: |
| 5736 | q.text('None') |
| 5737 | q.text(","); q.breakable() |
| 5738 | q.text("flags = "); |
| 5739 | q.text("%#x" % self.flags) |
| 5740 | q.text(","); q.breakable() |
| 5741 | q.text("match = "); |
| 5742 | q.pp(self.match) |
| 5743 | q.text(","); q.breakable() |
| 5744 | q.text("table_id = "); |
| 5745 | q.text("%#x" % self.table_id) |
| 5746 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5747 | q.text("out_port = "); |
| 5748 | q.text(util.pretty_port(self.out_port)) |
| 5749 | q.breakable() |
| 5750 | q.text('}') |
| 5751 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5752 | stats_request.subtypes[1] = flow_stats_request |
| 5753 | |
| 5754 | class get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5755 | version = 1 |
| 5756 | type = 8 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5757 | |
| 5758 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5759 | if xid != None: |
| 5760 | self.xid = xid |
| 5761 | else: |
| 5762 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5763 | if flags != None: |
| 5764 | self.flags = flags |
| 5765 | else: |
| 5766 | self.flags = 0 |
| 5767 | if miss_send_len != None: |
| 5768 | self.miss_send_len = miss_send_len |
| 5769 | else: |
| 5770 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5771 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5772 | |
| 5773 | def pack(self): |
| 5774 | packed = [] |
| 5775 | packed.append(struct.pack("!B", self.version)) |
| 5776 | packed.append(struct.pack("!B", self.type)) |
| 5777 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5778 | packed.append(struct.pack("!L", self.xid)) |
| 5779 | packed.append(struct.pack("!H", self.flags)) |
| 5780 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5781 | length = sum([len(x) for x in packed]) |
| 5782 | packed[2] = struct.pack("!H", length) |
| 5783 | return ''.join(packed) |
| 5784 | |
| 5785 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5786 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5787 | obj = get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5788 | _version = reader.read("!B")[0] |
| 5789 | assert(_version == 1) |
| 5790 | _type = reader.read("!B")[0] |
| 5791 | assert(_type == 8) |
| 5792 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5793 | orig_reader = reader |
| 5794 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5795 | obj.xid = reader.read("!L")[0] |
| 5796 | obj.flags = reader.read("!H")[0] |
| 5797 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5798 | return obj |
| 5799 | |
| 5800 | def __eq__(self, other): |
| 5801 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5802 | if self.xid != other.xid: return False |
| 5803 | if self.flags != other.flags: return False |
| 5804 | if self.miss_send_len != other.miss_send_len: return False |
| 5805 | return True |
| 5806 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5807 | def pretty_print(self, q): |
| 5808 | q.text("get_config_reply {") |
| 5809 | with q.group(): |
| 5810 | with q.indent(2): |
| 5811 | q.breakable() |
| 5812 | q.text("xid = "); |
| 5813 | if self.xid != None: |
| 5814 | q.text("%#x" % self.xid) |
| 5815 | else: |
| 5816 | q.text('None') |
| 5817 | q.text(","); q.breakable() |
| 5818 | q.text("flags = "); |
| 5819 | q.text("%#x" % self.flags) |
| 5820 | q.text(","); q.breakable() |
| 5821 | q.text("miss_send_len = "); |
| 5822 | q.text("%#x" % self.miss_send_len) |
| 5823 | q.breakable() |
| 5824 | q.text('}') |
| 5825 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5826 | message.subtypes[8] = get_config_reply |
| 5827 | |
| 5828 | class get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5829 | version = 1 |
| 5830 | type = 7 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5831 | |
| 5832 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5833 | if xid != None: |
| 5834 | self.xid = xid |
| 5835 | else: |
| 5836 | self.xid = None |
| 5837 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5838 | |
| 5839 | def pack(self): |
| 5840 | packed = [] |
| 5841 | packed.append(struct.pack("!B", self.version)) |
| 5842 | packed.append(struct.pack("!B", self.type)) |
| 5843 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5844 | packed.append(struct.pack("!L", self.xid)) |
| 5845 | length = sum([len(x) for x in packed]) |
| 5846 | packed[2] = struct.pack("!H", length) |
| 5847 | return ''.join(packed) |
| 5848 | |
| 5849 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5850 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5851 | obj = get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5852 | _version = reader.read("!B")[0] |
| 5853 | assert(_version == 1) |
| 5854 | _type = reader.read("!B")[0] |
| 5855 | assert(_type == 7) |
| 5856 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5857 | orig_reader = reader |
| 5858 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5859 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5860 | return obj |
| 5861 | |
| 5862 | def __eq__(self, other): |
| 5863 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5864 | if self.xid != other.xid: return False |
| 5865 | return True |
| 5866 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5867 | def pretty_print(self, q): |
| 5868 | q.text("get_config_request {") |
| 5869 | with q.group(): |
| 5870 | with q.indent(2): |
| 5871 | q.breakable() |
| 5872 | q.text("xid = "); |
| 5873 | if self.xid != None: |
| 5874 | q.text("%#x" % self.xid) |
| 5875 | else: |
| 5876 | q.text('None') |
| 5877 | q.breakable() |
| 5878 | q.text('}') |
| 5879 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5880 | message.subtypes[7] = get_config_request |
| 5881 | |
| 5882 | class hello(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5883 | version = 1 |
| 5884 | type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5885 | |
| 5886 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5887 | if xid != None: |
| 5888 | self.xid = xid |
| 5889 | else: |
| 5890 | self.xid = None |
| 5891 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5892 | |
| 5893 | def pack(self): |
| 5894 | packed = [] |
| 5895 | packed.append(struct.pack("!B", self.version)) |
| 5896 | packed.append(struct.pack("!B", self.type)) |
| 5897 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5898 | packed.append(struct.pack("!L", self.xid)) |
| 5899 | length = sum([len(x) for x in packed]) |
| 5900 | packed[2] = struct.pack("!H", length) |
| 5901 | return ''.join(packed) |
| 5902 | |
| 5903 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5904 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5905 | obj = hello() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5906 | _version = reader.read("!B")[0] |
| 5907 | assert(_version == 1) |
| 5908 | _type = reader.read("!B")[0] |
| 5909 | assert(_type == 0) |
| 5910 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5911 | orig_reader = reader |
| 5912 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5913 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5914 | return obj |
| 5915 | |
| 5916 | def __eq__(self, other): |
| 5917 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5918 | if self.xid != other.xid: return False |
| 5919 | return True |
| 5920 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5921 | def pretty_print(self, q): |
| 5922 | q.text("hello {") |
| 5923 | with q.group(): |
| 5924 | with q.indent(2): |
| 5925 | q.breakable() |
| 5926 | q.text("xid = "); |
| 5927 | if self.xid != None: |
| 5928 | q.text("%#x" % self.xid) |
| 5929 | else: |
| 5930 | q.text('None') |
| 5931 | q.breakable() |
| 5932 | q.text('}') |
| 5933 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5934 | message.subtypes[0] = hello |
| 5935 | |
| 5936 | class hello_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5937 | version = 1 |
| 5938 | type = 1 |
| 5939 | err_type = 0 |
| 5940 | |
| 5941 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5942 | if xid != None: |
| 5943 | self.xid = xid |
| 5944 | else: |
| 5945 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5946 | if code != None: |
| 5947 | self.code = code |
| 5948 | else: |
| 5949 | self.code = 0 |
| 5950 | if data != None: |
| 5951 | self.data = data |
| 5952 | else: |
| 5953 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5954 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5955 | |
| 5956 | def pack(self): |
| 5957 | packed = [] |
| 5958 | packed.append(struct.pack("!B", self.version)) |
| 5959 | packed.append(struct.pack("!B", self.type)) |
| 5960 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5961 | packed.append(struct.pack("!L", self.xid)) |
| 5962 | packed.append(struct.pack("!H", self.err_type)) |
| 5963 | packed.append(struct.pack("!H", self.code)) |
| 5964 | packed.append(self.data) |
| 5965 | length = sum([len(x) for x in packed]) |
| 5966 | packed[2] = struct.pack("!H", length) |
| 5967 | return ''.join(packed) |
| 5968 | |
| 5969 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5970 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5971 | obj = hello_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5972 | _version = reader.read("!B")[0] |
| 5973 | assert(_version == 1) |
| 5974 | _type = reader.read("!B")[0] |
| 5975 | assert(_type == 1) |
| 5976 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5977 | orig_reader = reader |
| 5978 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5979 | obj.xid = reader.read("!L")[0] |
| 5980 | _err_type = reader.read("!H")[0] |
| 5981 | assert(_err_type == 0) |
| 5982 | obj.code = reader.read("!H")[0] |
| 5983 | obj.data = str(reader.read_all()) |
| 5984 | return obj |
| 5985 | |
| 5986 | def __eq__(self, other): |
| 5987 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5988 | if self.xid != other.xid: return False |
| 5989 | if self.code != other.code: return False |
| 5990 | if self.data != other.data: return False |
| 5991 | return True |
| 5992 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5993 | def pretty_print(self, q): |
| 5994 | q.text("hello_failed_error_msg {") |
| 5995 | with q.group(): |
| 5996 | with q.indent(2): |
| 5997 | q.breakable() |
| 5998 | q.text("xid = "); |
| 5999 | if self.xid != None: |
| 6000 | q.text("%#x" % self.xid) |
| 6001 | else: |
| 6002 | q.text('None') |
| 6003 | q.text(","); q.breakable() |
| 6004 | q.text("code = "); |
| 6005 | q.text("%#x" % self.code) |
| 6006 | q.text(","); q.breakable() |
| 6007 | q.text("data = "); |
| 6008 | q.pp(self.data) |
| 6009 | q.breakable() |
| 6010 | q.text('}') |
| 6011 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6012 | error_msg.subtypes[0] = hello_failed_error_msg |
| 6013 | |
| 6014 | class nicira_header(experimenter): |
| 6015 | subtypes = {} |
| 6016 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6017 | version = 1 |
| 6018 | type = 4 |
| 6019 | experimenter = 8992 |
| 6020 | |
| 6021 | def __init__(self, xid=None, subtype=None): |
| 6022 | if xid != None: |
| 6023 | self.xid = xid |
| 6024 | else: |
| 6025 | self.xid = None |
| 6026 | if subtype != None: |
| 6027 | self.subtype = subtype |
| 6028 | else: |
| 6029 | self.subtype = 0 |
| 6030 | return |
| 6031 | |
| 6032 | def pack(self): |
| 6033 | packed = [] |
| 6034 | packed.append(struct.pack("!B", self.version)) |
| 6035 | packed.append(struct.pack("!B", self.type)) |
| 6036 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6037 | packed.append(struct.pack("!L", self.xid)) |
| 6038 | packed.append(struct.pack("!L", self.experimenter)) |
| 6039 | packed.append(struct.pack("!L", self.subtype)) |
| 6040 | length = sum([len(x) for x in packed]) |
| 6041 | packed[2] = struct.pack("!H", length) |
| 6042 | return ''.join(packed) |
| 6043 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6044 | @staticmethod |
| 6045 | def unpack(reader): |
| 6046 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6047 | subclass = nicira_header.subtypes.get(subtype) |
| 6048 | if subclass: |
| 6049 | return subclass.unpack(reader) |
| 6050 | |
| 6051 | obj = nicira_header() |
| 6052 | _version = reader.read("!B")[0] |
| 6053 | assert(_version == 1) |
| 6054 | _type = reader.read("!B")[0] |
| 6055 | assert(_type == 4) |
| 6056 | _length = reader.read("!H")[0] |
| 6057 | orig_reader = reader |
| 6058 | reader = orig_reader.slice(_length - (2 + 2)) |
| 6059 | obj.xid = reader.read("!L")[0] |
| 6060 | _experimenter = reader.read("!L")[0] |
| 6061 | assert(_experimenter == 8992) |
| 6062 | obj.subtype = reader.read("!L")[0] |
| 6063 | return obj |
| 6064 | |
| 6065 | def __eq__(self, other): |
| 6066 | if type(self) != type(other): return False |
| 6067 | if self.xid != other.xid: return False |
| 6068 | if self.subtype != other.subtype: return False |
| 6069 | return True |
| 6070 | |
| 6071 | def pretty_print(self, q): |
| 6072 | q.text("nicira_header {") |
| 6073 | with q.group(): |
| 6074 | with q.indent(2): |
| 6075 | q.breakable() |
| 6076 | q.text("xid = "); |
| 6077 | if self.xid != None: |
| 6078 | q.text("%#x" % self.xid) |
| 6079 | else: |
| 6080 | q.text('None') |
| 6081 | q.breakable() |
| 6082 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6083 | |
| 6084 | experimenter.subtypes[8992] = nicira_header |
| 6085 | |
| 6086 | class nicira_controller_role_reply(nicira_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6087 | version = 1 |
| 6088 | type = 4 |
| 6089 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6090 | subtype = 11 |
| 6091 | |
| 6092 | def __init__(self, xid=None, role=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6093 | if xid != None: |
| 6094 | self.xid = xid |
| 6095 | else: |
| 6096 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6097 | if role != None: |
| 6098 | self.role = role |
| 6099 | else: |
| 6100 | self.role = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6101 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6102 | |
| 6103 | def pack(self): |
| 6104 | packed = [] |
| 6105 | packed.append(struct.pack("!B", self.version)) |
| 6106 | packed.append(struct.pack("!B", self.type)) |
| 6107 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6108 | packed.append(struct.pack("!L", self.xid)) |
| 6109 | packed.append(struct.pack("!L", self.experimenter)) |
| 6110 | packed.append(struct.pack("!L", self.subtype)) |
| 6111 | packed.append(struct.pack("!L", self.role)) |
| 6112 | length = sum([len(x) for x in packed]) |
| 6113 | packed[2] = struct.pack("!H", length) |
| 6114 | return ''.join(packed) |
| 6115 | |
| 6116 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6117 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6118 | obj = nicira_controller_role_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6119 | _version = reader.read("!B")[0] |
| 6120 | assert(_version == 1) |
| 6121 | _type = reader.read("!B")[0] |
| 6122 | assert(_type == 4) |
| 6123 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6124 | orig_reader = reader |
| 6125 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6126 | obj.xid = reader.read("!L")[0] |
| 6127 | _experimenter = reader.read("!L")[0] |
| 6128 | assert(_experimenter == 8992) |
| 6129 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6130 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6131 | obj.role = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6132 | return obj |
| 6133 | |
| 6134 | def __eq__(self, other): |
| 6135 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6136 | if self.xid != other.xid: return False |
| 6137 | if self.role != other.role: return False |
| 6138 | return True |
| 6139 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6140 | def pretty_print(self, q): |
| 6141 | q.text("nicira_controller_role_reply {") |
| 6142 | with q.group(): |
| 6143 | with q.indent(2): |
| 6144 | q.breakable() |
| 6145 | q.text("xid = "); |
| 6146 | if self.xid != None: |
| 6147 | q.text("%#x" % self.xid) |
| 6148 | else: |
| 6149 | q.text('None') |
| 6150 | q.text(","); q.breakable() |
| 6151 | q.text("role = "); |
| 6152 | q.text("%#x" % self.role) |
| 6153 | q.breakable() |
| 6154 | q.text('}') |
| 6155 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6156 | nicira_header.subtypes[11] = nicira_controller_role_reply |
| 6157 | |
| 6158 | class nicira_controller_role_request(nicira_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6159 | version = 1 |
| 6160 | type = 4 |
| 6161 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6162 | subtype = 10 |
| 6163 | |
| 6164 | def __init__(self, xid=None, role=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6165 | if xid != None: |
| 6166 | self.xid = xid |
| 6167 | else: |
| 6168 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6169 | if role != None: |
| 6170 | self.role = role |
| 6171 | else: |
| 6172 | self.role = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6173 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6174 | |
| 6175 | def pack(self): |
| 6176 | packed = [] |
| 6177 | packed.append(struct.pack("!B", self.version)) |
| 6178 | packed.append(struct.pack("!B", self.type)) |
| 6179 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6180 | packed.append(struct.pack("!L", self.xid)) |
| 6181 | packed.append(struct.pack("!L", self.experimenter)) |
| 6182 | packed.append(struct.pack("!L", self.subtype)) |
| 6183 | packed.append(struct.pack("!L", self.role)) |
| 6184 | length = sum([len(x) for x in packed]) |
| 6185 | packed[2] = struct.pack("!H", length) |
| 6186 | return ''.join(packed) |
| 6187 | |
| 6188 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6189 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6190 | obj = nicira_controller_role_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6191 | _version = reader.read("!B")[0] |
| 6192 | assert(_version == 1) |
| 6193 | _type = reader.read("!B")[0] |
| 6194 | assert(_type == 4) |
| 6195 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6196 | orig_reader = reader |
| 6197 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6198 | obj.xid = reader.read("!L")[0] |
| 6199 | _experimenter = reader.read("!L")[0] |
| 6200 | assert(_experimenter == 8992) |
| 6201 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6202 | assert(_subtype == 10) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6203 | obj.role = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6204 | return obj |
| 6205 | |
| 6206 | def __eq__(self, other): |
| 6207 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6208 | if self.xid != other.xid: return False |
| 6209 | if self.role != other.role: return False |
| 6210 | return True |
| 6211 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6212 | def pretty_print(self, q): |
| 6213 | q.text("nicira_controller_role_request {") |
| 6214 | with q.group(): |
| 6215 | with q.indent(2): |
| 6216 | q.breakable() |
| 6217 | q.text("xid = "); |
| 6218 | if self.xid != None: |
| 6219 | q.text("%#x" % self.xid) |
| 6220 | else: |
| 6221 | q.text('None') |
| 6222 | q.text(","); q.breakable() |
| 6223 | q.text("role = "); |
| 6224 | q.text("%#x" % self.role) |
| 6225 | q.breakable() |
| 6226 | q.text('}') |
| 6227 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6228 | nicira_header.subtypes[10] = nicira_controller_role_request |
| 6229 | |
| 6230 | class packet_in(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6231 | version = 1 |
| 6232 | type = 10 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6233 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6234 | def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6235 | if xid != None: |
| 6236 | self.xid = xid |
| 6237 | else: |
| 6238 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6239 | if buffer_id != None: |
| 6240 | self.buffer_id = buffer_id |
| 6241 | else: |
| 6242 | self.buffer_id = 0 |
| 6243 | if total_len != None: |
| 6244 | self.total_len = total_len |
| 6245 | else: |
| 6246 | self.total_len = 0 |
| 6247 | if in_port != None: |
| 6248 | self.in_port = in_port |
| 6249 | else: |
| 6250 | self.in_port = 0 |
| 6251 | if reason != None: |
| 6252 | self.reason = reason |
| 6253 | else: |
| 6254 | self.reason = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6255 | if data != None: |
| 6256 | self.data = data |
| 6257 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6258 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6259 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6260 | |
| 6261 | def pack(self): |
| 6262 | packed = [] |
| 6263 | packed.append(struct.pack("!B", self.version)) |
| 6264 | packed.append(struct.pack("!B", self.type)) |
| 6265 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6266 | packed.append(struct.pack("!L", self.xid)) |
| 6267 | packed.append(struct.pack("!L", self.buffer_id)) |
| 6268 | packed.append(struct.pack("!H", self.total_len)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6269 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6270 | packed.append(struct.pack("!B", self.reason)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6271 | packed.append('\x00' * 1) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6272 | packed.append(self.data) |
| 6273 | length = sum([len(x) for x in packed]) |
| 6274 | packed[2] = struct.pack("!H", length) |
| 6275 | return ''.join(packed) |
| 6276 | |
| 6277 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6278 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6279 | obj = packet_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6280 | _version = reader.read("!B")[0] |
| 6281 | assert(_version == 1) |
| 6282 | _type = reader.read("!B")[0] |
| 6283 | assert(_type == 10) |
| 6284 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6285 | orig_reader = reader |
| 6286 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6287 | obj.xid = reader.read("!L")[0] |
| 6288 | obj.buffer_id = reader.read("!L")[0] |
| 6289 | obj.total_len = reader.read("!H")[0] |
| 6290 | obj.in_port = util.unpack_port_no(reader) |
| 6291 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6292 | reader.skip(1) |
| 6293 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6294 | return obj |
| 6295 | |
| 6296 | def __eq__(self, other): |
| 6297 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6298 | if self.xid != other.xid: return False |
| 6299 | if self.buffer_id != other.buffer_id: return False |
| 6300 | if self.total_len != other.total_len: return False |
| 6301 | if self.in_port != other.in_port: return False |
| 6302 | if self.reason != other.reason: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6303 | if self.data != other.data: return False |
| 6304 | return True |
| 6305 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6306 | def pretty_print(self, q): |
| 6307 | q.text("packet_in {") |
| 6308 | with q.group(): |
| 6309 | with q.indent(2): |
| 6310 | q.breakable() |
| 6311 | q.text("xid = "); |
| 6312 | if self.xid != None: |
| 6313 | q.text("%#x" % self.xid) |
| 6314 | else: |
| 6315 | q.text('None') |
| 6316 | q.text(","); q.breakable() |
| 6317 | q.text("buffer_id = "); |
| 6318 | q.text("%#x" % self.buffer_id) |
| 6319 | q.text(","); q.breakable() |
| 6320 | q.text("total_len = "); |
| 6321 | q.text("%#x" % self.total_len) |
| 6322 | q.text(","); q.breakable() |
| 6323 | q.text("in_port = "); |
| 6324 | q.text(util.pretty_port(self.in_port)) |
| 6325 | q.text(","); q.breakable() |
| 6326 | q.text("reason = "); |
| 6327 | q.text("%#x" % self.reason) |
| 6328 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6329 | q.text("data = "); |
| 6330 | q.pp(self.data) |
| 6331 | q.breakable() |
| 6332 | q.text('}') |
| 6333 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6334 | message.subtypes[10] = packet_in |
| 6335 | |
| 6336 | class packet_out(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6337 | version = 1 |
| 6338 | type = 13 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6339 | |
| 6340 | 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] | 6341 | if xid != None: |
| 6342 | self.xid = xid |
| 6343 | else: |
| 6344 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6345 | if buffer_id != None: |
| 6346 | self.buffer_id = buffer_id |
| 6347 | else: |
Rich Lane | ff637c9 | 2013-04-04 13:57:09 -0700 | [diff] [blame] | 6348 | self.buffer_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6349 | if in_port != None: |
| 6350 | self.in_port = in_port |
| 6351 | else: |
| 6352 | self.in_port = 0 |
| 6353 | if actions != None: |
| 6354 | self.actions = actions |
| 6355 | else: |
| 6356 | self.actions = [] |
| 6357 | if data != None: |
| 6358 | self.data = data |
| 6359 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6360 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6361 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6362 | |
| 6363 | def pack(self): |
| 6364 | packed = [] |
| 6365 | packed.append(struct.pack("!B", self.version)) |
| 6366 | packed.append(struct.pack("!B", self.type)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6367 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6368 | packed.append(struct.pack("!L", self.xid)) |
| 6369 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6370 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6371 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6372 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6373 | packed[6] = struct.pack("!H", len(packed[-1])) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6374 | packed.append(self.data) |
| 6375 | length = sum([len(x) for x in packed]) |
| 6376 | packed[2] = struct.pack("!H", length) |
| 6377 | return ''.join(packed) |
| 6378 | |
| 6379 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6380 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6381 | obj = packet_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6382 | _version = reader.read("!B")[0] |
| 6383 | assert(_version == 1) |
| 6384 | _type = reader.read("!B")[0] |
| 6385 | assert(_type == 13) |
| 6386 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6387 | orig_reader = reader |
| 6388 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6389 | obj.xid = reader.read("!L")[0] |
| 6390 | obj.buffer_id = reader.read("!L")[0] |
| 6391 | obj.in_port = util.unpack_port_no(reader) |
| 6392 | _actions_len = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6393 | 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] | 6394 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6395 | return obj |
| 6396 | |
| 6397 | def __eq__(self, other): |
| 6398 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6399 | if self.xid != other.xid: return False |
| 6400 | if self.buffer_id != other.buffer_id: return False |
| 6401 | if self.in_port != other.in_port: return False |
| 6402 | if self.actions != other.actions: return False |
| 6403 | if self.data != other.data: return False |
| 6404 | return True |
| 6405 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6406 | def pretty_print(self, q): |
| 6407 | q.text("packet_out {") |
| 6408 | with q.group(): |
| 6409 | with q.indent(2): |
| 6410 | q.breakable() |
| 6411 | q.text("xid = "); |
| 6412 | if self.xid != None: |
| 6413 | q.text("%#x" % self.xid) |
| 6414 | else: |
| 6415 | q.text('None') |
| 6416 | q.text(","); q.breakable() |
| 6417 | q.text("buffer_id = "); |
| 6418 | q.text("%#x" % self.buffer_id) |
| 6419 | q.text(","); q.breakable() |
| 6420 | q.text("in_port = "); |
| 6421 | q.text(util.pretty_port(self.in_port)) |
| 6422 | q.text(","); q.breakable() |
| 6423 | q.text("actions = "); |
| 6424 | q.pp(self.actions) |
| 6425 | q.text(","); q.breakable() |
| 6426 | q.text("data = "); |
| 6427 | q.pp(self.data) |
| 6428 | q.breakable() |
| 6429 | q.text('}') |
| 6430 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6431 | message.subtypes[13] = packet_out |
| 6432 | |
| 6433 | class port_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6434 | version = 1 |
| 6435 | type = 15 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6436 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6437 | 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] | 6438 | if xid != None: |
| 6439 | self.xid = xid |
| 6440 | else: |
| 6441 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6442 | if port_no != None: |
| 6443 | self.port_no = port_no |
| 6444 | else: |
| 6445 | self.port_no = 0 |
| 6446 | if hw_addr != None: |
| 6447 | self.hw_addr = hw_addr |
| 6448 | else: |
| 6449 | self.hw_addr = [0,0,0,0,0,0] |
| 6450 | if config != None: |
| 6451 | self.config = config |
| 6452 | else: |
| 6453 | self.config = 0 |
| 6454 | if mask != None: |
| 6455 | self.mask = mask |
| 6456 | else: |
| 6457 | self.mask = 0 |
| 6458 | if advertise != None: |
| 6459 | self.advertise = advertise |
| 6460 | else: |
| 6461 | self.advertise = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6462 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6463 | |
| 6464 | def pack(self): |
| 6465 | packed = [] |
| 6466 | packed.append(struct.pack("!B", self.version)) |
| 6467 | packed.append(struct.pack("!B", self.type)) |
| 6468 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6469 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6470 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6471 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 6472 | packed.append(struct.pack("!L", self.config)) |
| 6473 | packed.append(struct.pack("!L", self.mask)) |
| 6474 | packed.append(struct.pack("!L", self.advertise)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6475 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6476 | length = sum([len(x) for x in packed]) |
| 6477 | packed[2] = struct.pack("!H", length) |
| 6478 | return ''.join(packed) |
| 6479 | |
| 6480 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6481 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6482 | obj = port_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6483 | _version = reader.read("!B")[0] |
| 6484 | assert(_version == 1) |
| 6485 | _type = reader.read("!B")[0] |
| 6486 | assert(_type == 15) |
| 6487 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6488 | orig_reader = reader |
| 6489 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6490 | obj.xid = reader.read("!L")[0] |
| 6491 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6492 | obj.hw_addr = list(reader.read('!6B')) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6493 | obj.config = reader.read("!L")[0] |
| 6494 | obj.mask = reader.read("!L")[0] |
| 6495 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6496 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6497 | return obj |
| 6498 | |
| 6499 | def __eq__(self, other): |
| 6500 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6501 | if self.xid != other.xid: return False |
| 6502 | if self.port_no != other.port_no: return False |
| 6503 | if self.hw_addr != other.hw_addr: return False |
| 6504 | if self.config != other.config: return False |
| 6505 | if self.mask != other.mask: return False |
| 6506 | if self.advertise != other.advertise: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6507 | return True |
| 6508 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6509 | def pretty_print(self, q): |
| 6510 | q.text("port_mod {") |
| 6511 | with q.group(): |
| 6512 | with q.indent(2): |
| 6513 | q.breakable() |
| 6514 | q.text("xid = "); |
| 6515 | if self.xid != None: |
| 6516 | q.text("%#x" % self.xid) |
| 6517 | else: |
| 6518 | q.text('None') |
| 6519 | q.text(","); q.breakable() |
| 6520 | q.text("port_no = "); |
| 6521 | q.text(util.pretty_port(self.port_no)) |
| 6522 | q.text(","); q.breakable() |
| 6523 | q.text("hw_addr = "); |
| 6524 | q.text(util.pretty_mac(self.hw_addr)) |
| 6525 | q.text(","); q.breakable() |
| 6526 | q.text("config = "); |
| 6527 | q.text("%#x" % self.config) |
| 6528 | q.text(","); q.breakable() |
| 6529 | q.text("mask = "); |
| 6530 | q.text("%#x" % self.mask) |
| 6531 | q.text(","); q.breakable() |
| 6532 | q.text("advertise = "); |
| 6533 | q.text("%#x" % self.advertise) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6534 | q.breakable() |
| 6535 | q.text('}') |
| 6536 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6537 | message.subtypes[15] = port_mod |
| 6538 | |
| 6539 | class port_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6540 | version = 1 |
| 6541 | type = 1 |
| 6542 | err_type = 4 |
| 6543 | |
| 6544 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6545 | if xid != None: |
| 6546 | self.xid = xid |
| 6547 | else: |
| 6548 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6549 | if code != None: |
| 6550 | self.code = code |
| 6551 | else: |
| 6552 | self.code = 0 |
| 6553 | if data != None: |
| 6554 | self.data = data |
| 6555 | else: |
| 6556 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6557 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6558 | |
| 6559 | def pack(self): |
| 6560 | packed = [] |
| 6561 | packed.append(struct.pack("!B", self.version)) |
| 6562 | packed.append(struct.pack("!B", self.type)) |
| 6563 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6564 | packed.append(struct.pack("!L", self.xid)) |
| 6565 | packed.append(struct.pack("!H", self.err_type)) |
| 6566 | packed.append(struct.pack("!H", self.code)) |
| 6567 | packed.append(self.data) |
| 6568 | length = sum([len(x) for x in packed]) |
| 6569 | packed[2] = struct.pack("!H", length) |
| 6570 | return ''.join(packed) |
| 6571 | |
| 6572 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6573 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6574 | obj = port_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6575 | _version = reader.read("!B")[0] |
| 6576 | assert(_version == 1) |
| 6577 | _type = reader.read("!B")[0] |
| 6578 | assert(_type == 1) |
| 6579 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6580 | orig_reader = reader |
| 6581 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6582 | obj.xid = reader.read("!L")[0] |
| 6583 | _err_type = reader.read("!H")[0] |
| 6584 | assert(_err_type == 4) |
| 6585 | obj.code = reader.read("!H")[0] |
| 6586 | obj.data = str(reader.read_all()) |
| 6587 | return obj |
| 6588 | |
| 6589 | def __eq__(self, other): |
| 6590 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6591 | if self.xid != other.xid: return False |
| 6592 | if self.code != other.code: return False |
| 6593 | if self.data != other.data: return False |
| 6594 | return True |
| 6595 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6596 | def pretty_print(self, q): |
| 6597 | q.text("port_mod_failed_error_msg {") |
| 6598 | with q.group(): |
| 6599 | with q.indent(2): |
| 6600 | q.breakable() |
| 6601 | q.text("xid = "); |
| 6602 | if self.xid != None: |
| 6603 | q.text("%#x" % self.xid) |
| 6604 | else: |
| 6605 | q.text('None') |
| 6606 | q.text(","); q.breakable() |
| 6607 | q.text("code = "); |
| 6608 | q.text("%#x" % self.code) |
| 6609 | q.text(","); q.breakable() |
| 6610 | q.text("data = "); |
| 6611 | q.pp(self.data) |
| 6612 | q.breakable() |
| 6613 | q.text('}') |
| 6614 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6615 | error_msg.subtypes[4] = port_mod_failed_error_msg |
| 6616 | |
| 6617 | class port_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6618 | version = 1 |
| 6619 | type = 17 |
| 6620 | stats_type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6621 | |
| 6622 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6623 | if xid != None: |
| 6624 | self.xid = xid |
| 6625 | else: |
| 6626 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6627 | if flags != None: |
| 6628 | self.flags = flags |
| 6629 | else: |
| 6630 | self.flags = 0 |
| 6631 | if entries != None: |
| 6632 | self.entries = entries |
| 6633 | else: |
| 6634 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6635 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6636 | |
| 6637 | def pack(self): |
| 6638 | packed = [] |
| 6639 | packed.append(struct.pack("!B", self.version)) |
| 6640 | packed.append(struct.pack("!B", self.type)) |
| 6641 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6642 | packed.append(struct.pack("!L", self.xid)) |
| 6643 | packed.append(struct.pack("!H", self.stats_type)) |
| 6644 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6645 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6646 | length = sum([len(x) for x in packed]) |
| 6647 | packed[2] = struct.pack("!H", length) |
| 6648 | return ''.join(packed) |
| 6649 | |
| 6650 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6651 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6652 | obj = port_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6653 | _version = reader.read("!B")[0] |
| 6654 | assert(_version == 1) |
| 6655 | _type = reader.read("!B")[0] |
| 6656 | assert(_type == 17) |
| 6657 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6658 | orig_reader = reader |
| 6659 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6660 | obj.xid = reader.read("!L")[0] |
| 6661 | _stats_type = reader.read("!H")[0] |
| 6662 | assert(_stats_type == 4) |
| 6663 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6664 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6665 | return obj |
| 6666 | |
| 6667 | def __eq__(self, other): |
| 6668 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6669 | if self.xid != other.xid: return False |
| 6670 | if self.flags != other.flags: return False |
| 6671 | if self.entries != other.entries: return False |
| 6672 | return True |
| 6673 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6674 | def pretty_print(self, q): |
| 6675 | q.text("port_stats_reply {") |
| 6676 | with q.group(): |
| 6677 | with q.indent(2): |
| 6678 | q.breakable() |
| 6679 | q.text("xid = "); |
| 6680 | if self.xid != None: |
| 6681 | q.text("%#x" % self.xid) |
| 6682 | else: |
| 6683 | q.text('None') |
| 6684 | q.text(","); q.breakable() |
| 6685 | q.text("flags = "); |
| 6686 | q.text("%#x" % self.flags) |
| 6687 | q.text(","); q.breakable() |
| 6688 | q.text("entries = "); |
| 6689 | q.pp(self.entries) |
| 6690 | q.breakable() |
| 6691 | q.text('}') |
| 6692 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6693 | stats_reply.subtypes[4] = port_stats_reply |
| 6694 | |
| 6695 | class port_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6696 | version = 1 |
| 6697 | type = 16 |
| 6698 | stats_type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6699 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6700 | def __init__(self, xid=None, flags=None, port_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6701 | if xid != None: |
| 6702 | self.xid = xid |
| 6703 | else: |
| 6704 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6705 | if flags != None: |
| 6706 | self.flags = flags |
| 6707 | else: |
| 6708 | self.flags = 0 |
| 6709 | if port_no != None: |
| 6710 | self.port_no = port_no |
| 6711 | else: |
| 6712 | self.port_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6713 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6714 | |
| 6715 | def pack(self): |
| 6716 | packed = [] |
| 6717 | packed.append(struct.pack("!B", self.version)) |
| 6718 | packed.append(struct.pack("!B", self.type)) |
| 6719 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6720 | packed.append(struct.pack("!L", self.xid)) |
| 6721 | packed.append(struct.pack("!H", self.stats_type)) |
| 6722 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6723 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6724 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6725 | length = sum([len(x) for x in packed]) |
| 6726 | packed[2] = struct.pack("!H", length) |
| 6727 | return ''.join(packed) |
| 6728 | |
| 6729 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6730 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6731 | obj = port_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6732 | _version = reader.read("!B")[0] |
| 6733 | assert(_version == 1) |
| 6734 | _type = reader.read("!B")[0] |
| 6735 | assert(_type == 16) |
| 6736 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6737 | orig_reader = reader |
| 6738 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6739 | obj.xid = reader.read("!L")[0] |
| 6740 | _stats_type = reader.read("!H")[0] |
| 6741 | assert(_stats_type == 4) |
| 6742 | obj.flags = reader.read("!H")[0] |
| 6743 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6744 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6745 | return obj |
| 6746 | |
| 6747 | def __eq__(self, other): |
| 6748 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6749 | if self.xid != other.xid: return False |
| 6750 | if self.flags != other.flags: return False |
| 6751 | if self.port_no != other.port_no: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6752 | return True |
| 6753 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6754 | def pretty_print(self, q): |
| 6755 | q.text("port_stats_request {") |
| 6756 | with q.group(): |
| 6757 | with q.indent(2): |
| 6758 | q.breakable() |
| 6759 | q.text("xid = "); |
| 6760 | if self.xid != None: |
| 6761 | q.text("%#x" % self.xid) |
| 6762 | else: |
| 6763 | q.text('None') |
| 6764 | q.text(","); q.breakable() |
| 6765 | q.text("flags = "); |
| 6766 | q.text("%#x" % self.flags) |
| 6767 | q.text(","); q.breakable() |
| 6768 | q.text("port_no = "); |
| 6769 | q.text(util.pretty_port(self.port_no)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6770 | q.breakable() |
| 6771 | q.text('}') |
| 6772 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6773 | stats_request.subtypes[4] = port_stats_request |
| 6774 | |
| 6775 | class port_status(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6776 | version = 1 |
| 6777 | type = 12 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6778 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6779 | def __init__(self, xid=None, reason=None, desc=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6780 | if xid != None: |
| 6781 | self.xid = xid |
| 6782 | else: |
| 6783 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6784 | if reason != None: |
| 6785 | self.reason = reason |
| 6786 | else: |
| 6787 | self.reason = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6788 | if desc != None: |
| 6789 | self.desc = desc |
| 6790 | else: |
| 6791 | self.desc = common.port_desc() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6792 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6793 | |
| 6794 | def pack(self): |
| 6795 | packed = [] |
| 6796 | packed.append(struct.pack("!B", self.version)) |
| 6797 | packed.append(struct.pack("!B", self.type)) |
| 6798 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6799 | packed.append(struct.pack("!L", self.xid)) |
| 6800 | packed.append(struct.pack("!B", self.reason)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6801 | packed.append('\x00' * 7) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6802 | packed.append(self.desc.pack()) |
| 6803 | length = sum([len(x) for x in packed]) |
| 6804 | packed[2] = struct.pack("!H", length) |
| 6805 | return ''.join(packed) |
| 6806 | |
| 6807 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6808 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6809 | obj = port_status() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6810 | _version = reader.read("!B")[0] |
| 6811 | assert(_version == 1) |
| 6812 | _type = reader.read("!B")[0] |
| 6813 | assert(_type == 12) |
| 6814 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6815 | orig_reader = reader |
| 6816 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6817 | obj.xid = reader.read("!L")[0] |
| 6818 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6819 | reader.skip(7) |
| 6820 | obj.desc = common.port_desc.unpack(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6821 | return obj |
| 6822 | |
| 6823 | def __eq__(self, other): |
| 6824 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6825 | if self.xid != other.xid: return False |
| 6826 | if self.reason != other.reason: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6827 | if self.desc != other.desc: return False |
| 6828 | return True |
| 6829 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6830 | def pretty_print(self, q): |
| 6831 | q.text("port_status {") |
| 6832 | with q.group(): |
| 6833 | with q.indent(2): |
| 6834 | q.breakable() |
| 6835 | q.text("xid = "); |
| 6836 | if self.xid != None: |
| 6837 | q.text("%#x" % self.xid) |
| 6838 | else: |
| 6839 | q.text('None') |
| 6840 | q.text(","); q.breakable() |
| 6841 | q.text("reason = "); |
| 6842 | q.text("%#x" % self.reason) |
| 6843 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6844 | q.text("desc = "); |
| 6845 | q.pp(self.desc) |
| 6846 | q.breakable() |
| 6847 | q.text('}') |
| 6848 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6849 | message.subtypes[12] = port_status |
| 6850 | |
| 6851 | class queue_get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6852 | version = 1 |
| 6853 | type = 21 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6854 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6855 | def __init__(self, xid=None, port=None, queues=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6856 | if xid != None: |
| 6857 | self.xid = xid |
| 6858 | else: |
| 6859 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6860 | if port != None: |
| 6861 | self.port = port |
| 6862 | else: |
| 6863 | self.port = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6864 | if queues != None: |
| 6865 | self.queues = queues |
| 6866 | else: |
| 6867 | self.queues = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6868 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6869 | |
| 6870 | def pack(self): |
| 6871 | packed = [] |
| 6872 | packed.append(struct.pack("!B", self.version)) |
| 6873 | packed.append(struct.pack("!B", self.type)) |
| 6874 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6875 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6876 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6877 | packed.append('\x00' * 6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6878 | packed.append(loxi.generic_util.pack_list(self.queues)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6879 | length = sum([len(x) for x in packed]) |
| 6880 | packed[2] = struct.pack("!H", length) |
| 6881 | return ''.join(packed) |
| 6882 | |
| 6883 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6884 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6885 | obj = queue_get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6886 | _version = reader.read("!B")[0] |
| 6887 | assert(_version == 1) |
| 6888 | _type = reader.read("!B")[0] |
| 6889 | assert(_type == 21) |
| 6890 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6891 | orig_reader = reader |
| 6892 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6893 | obj.xid = reader.read("!L")[0] |
| 6894 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6895 | reader.skip(6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6896 | obj.queues = loxi.generic_util.unpack_list(reader, common.packet_queue.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6897 | return obj |
| 6898 | |
| 6899 | def __eq__(self, other): |
| 6900 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6901 | if self.xid != other.xid: return False |
| 6902 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6903 | if self.queues != other.queues: return False |
| 6904 | return True |
| 6905 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6906 | def pretty_print(self, q): |
| 6907 | q.text("queue_get_config_reply {") |
| 6908 | with q.group(): |
| 6909 | with q.indent(2): |
| 6910 | q.breakable() |
| 6911 | q.text("xid = "); |
| 6912 | if self.xid != None: |
| 6913 | q.text("%#x" % self.xid) |
| 6914 | else: |
| 6915 | q.text('None') |
| 6916 | q.text(","); q.breakable() |
| 6917 | q.text("port = "); |
| 6918 | q.text(util.pretty_port(self.port)) |
| 6919 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6920 | q.text("queues = "); |
| 6921 | q.pp(self.queues) |
| 6922 | q.breakable() |
| 6923 | q.text('}') |
| 6924 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6925 | message.subtypes[21] = queue_get_config_reply |
| 6926 | |
| 6927 | class queue_get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6928 | version = 1 |
| 6929 | type = 20 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6930 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6931 | def __init__(self, xid=None, port=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6932 | if xid != None: |
| 6933 | self.xid = xid |
| 6934 | else: |
| 6935 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6936 | if port != None: |
| 6937 | self.port = port |
| 6938 | else: |
| 6939 | self.port = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6940 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6941 | |
| 6942 | def pack(self): |
| 6943 | packed = [] |
| 6944 | packed.append(struct.pack("!B", self.version)) |
| 6945 | packed.append(struct.pack("!B", self.type)) |
| 6946 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6947 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6948 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6949 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6950 | length = sum([len(x) for x in packed]) |
| 6951 | packed[2] = struct.pack("!H", length) |
| 6952 | return ''.join(packed) |
| 6953 | |
| 6954 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6955 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6956 | obj = queue_get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6957 | _version = reader.read("!B")[0] |
| 6958 | assert(_version == 1) |
| 6959 | _type = reader.read("!B")[0] |
| 6960 | assert(_type == 20) |
| 6961 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6962 | orig_reader = reader |
| 6963 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6964 | obj.xid = reader.read("!L")[0] |
| 6965 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6966 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6967 | return obj |
| 6968 | |
| 6969 | def __eq__(self, other): |
| 6970 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6971 | if self.xid != other.xid: return False |
| 6972 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6973 | return True |
| 6974 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6975 | def pretty_print(self, q): |
| 6976 | q.text("queue_get_config_request {") |
| 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("port = "); |
| 6987 | q.text(util.pretty_port(self.port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6988 | q.breakable() |
| 6989 | q.text('}') |
| 6990 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6991 | message.subtypes[20] = queue_get_config_request |
| 6992 | |
| 6993 | class queue_op_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6994 | version = 1 |
| 6995 | type = 1 |
| 6996 | err_type = 5 |
| 6997 | |
| 6998 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6999 | if xid != None: |
| 7000 | self.xid = xid |
| 7001 | else: |
| 7002 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7003 | if code != None: |
| 7004 | self.code = code |
| 7005 | else: |
| 7006 | self.code = 0 |
| 7007 | if data != None: |
| 7008 | self.data = data |
| 7009 | else: |
| 7010 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7011 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7012 | |
| 7013 | def pack(self): |
| 7014 | packed = [] |
| 7015 | packed.append(struct.pack("!B", self.version)) |
| 7016 | packed.append(struct.pack("!B", self.type)) |
| 7017 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7018 | packed.append(struct.pack("!L", self.xid)) |
| 7019 | packed.append(struct.pack("!H", self.err_type)) |
| 7020 | packed.append(struct.pack("!H", self.code)) |
| 7021 | packed.append(self.data) |
| 7022 | length = sum([len(x) for x in packed]) |
| 7023 | packed[2] = struct.pack("!H", length) |
| 7024 | return ''.join(packed) |
| 7025 | |
| 7026 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7027 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7028 | obj = queue_op_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7029 | _version = reader.read("!B")[0] |
| 7030 | assert(_version == 1) |
| 7031 | _type = reader.read("!B")[0] |
| 7032 | assert(_type == 1) |
| 7033 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7034 | orig_reader = reader |
| 7035 | reader = orig_reader.slice(_length - (2 + 2)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7036 | obj.xid = reader.read("!L")[0] |
| 7037 | _err_type = reader.read("!H")[0] |
| 7038 | assert(_err_type == 5) |
| 7039 | obj.code = reader.read("!H")[0] |
| 7040 | obj.data = str(reader.read_all()) |
| 7041 | return obj |
| 7042 | |
| 7043 | def __eq__(self, other): |
| 7044 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7045 | if self.xid != other.xid: return False |
| 7046 | if self.code != other.code: return False |
| 7047 | if self.data != other.data: return False |
| 7048 | return True |
| 7049 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7050 | def pretty_print(self, q): |
| 7051 | q.text("queue_op_failed_error_msg {") |
| 7052 | with q.group(): |
| 7053 | with q.indent(2): |
| 7054 | q.breakable() |
| 7055 | q.text("xid = "); |
| 7056 | if self.xid != None: |
| 7057 | q.text("%#x" % self.xid) |
| 7058 | else: |
| 7059 | q.text('None') |
| 7060 | q.text(","); q.breakable() |
| 7061 | q.text("code = "); |
| 7062 | q.text("%#x" % self.code) |
| 7063 | q.text(","); q.breakable() |
| 7064 | q.text("data = "); |
| 7065 | q.pp(self.data) |
| 7066 | q.breakable() |
| 7067 | q.text('}') |
| 7068 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7069 | error_msg.subtypes[5] = queue_op_failed_error_msg |
| 7070 | |
| 7071 | class queue_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7072 | version = 1 |
| 7073 | type = 17 |
| 7074 | stats_type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7075 | |
| 7076 | def __init__(self, xid=None, flags=None, entries=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 | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7081 | if flags != None: |
| 7082 | self.flags = flags |
| 7083 | else: |
| 7084 | self.flags = 0 |
| 7085 | if entries != None: |
| 7086 | self.entries = entries |
| 7087 | else: |
| 7088 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7089 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7090 | |
| 7091 | def pack(self): |
| 7092 | packed = [] |
| 7093 | packed.append(struct.pack("!B", self.version)) |
| 7094 | packed.append(struct.pack("!B", self.type)) |
| 7095 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7096 | packed.append(struct.pack("!L", self.xid)) |
| 7097 | packed.append(struct.pack("!H", self.stats_type)) |
| 7098 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7099 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7100 | length = sum([len(x) for x in packed]) |
| 7101 | packed[2] = struct.pack("!H", length) |
| 7102 | return ''.join(packed) |
| 7103 | |
| 7104 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7105 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7106 | obj = queue_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7107 | _version = reader.read("!B")[0] |
| 7108 | assert(_version == 1) |
| 7109 | _type = reader.read("!B")[0] |
| 7110 | assert(_type == 17) |
| 7111 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7112 | orig_reader = reader |
| 7113 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7114 | obj.xid = reader.read("!L")[0] |
| 7115 | _stats_type = reader.read("!H")[0] |
| 7116 | assert(_stats_type == 5) |
| 7117 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7118 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7119 | return obj |
| 7120 | |
| 7121 | def __eq__(self, other): |
| 7122 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7123 | if self.xid != other.xid: return False |
| 7124 | if self.flags != other.flags: return False |
| 7125 | if self.entries != other.entries: return False |
| 7126 | return True |
| 7127 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7128 | def pretty_print(self, q): |
| 7129 | q.text("queue_stats_reply {") |
| 7130 | with q.group(): |
| 7131 | with q.indent(2): |
| 7132 | q.breakable() |
| 7133 | q.text("xid = "); |
| 7134 | if self.xid != None: |
| 7135 | q.text("%#x" % self.xid) |
| 7136 | else: |
| 7137 | q.text('None') |
| 7138 | q.text(","); q.breakable() |
| 7139 | q.text("flags = "); |
| 7140 | q.text("%#x" % self.flags) |
| 7141 | q.text(","); q.breakable() |
| 7142 | q.text("entries = "); |
| 7143 | q.pp(self.entries) |
| 7144 | q.breakable() |
| 7145 | q.text('}') |
| 7146 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7147 | stats_reply.subtypes[5] = queue_stats_reply |
| 7148 | |
| 7149 | class queue_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7150 | version = 1 |
| 7151 | type = 16 |
| 7152 | stats_type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7153 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7154 | 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] | 7155 | if xid != None: |
| 7156 | self.xid = xid |
| 7157 | else: |
| 7158 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7159 | if flags != None: |
| 7160 | self.flags = flags |
| 7161 | else: |
| 7162 | self.flags = 0 |
| 7163 | if port_no != None: |
| 7164 | self.port_no = port_no |
| 7165 | else: |
| 7166 | self.port_no = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7167 | if queue_id != None: |
| 7168 | self.queue_id = queue_id |
| 7169 | else: |
| 7170 | self.queue_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7171 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7172 | |
| 7173 | def pack(self): |
| 7174 | packed = [] |
| 7175 | packed.append(struct.pack("!B", self.version)) |
| 7176 | packed.append(struct.pack("!B", self.type)) |
| 7177 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7178 | packed.append(struct.pack("!L", self.xid)) |
| 7179 | packed.append(struct.pack("!H", self.stats_type)) |
| 7180 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7181 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7182 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7183 | packed.append(struct.pack("!L", self.queue_id)) |
| 7184 | length = sum([len(x) for x in packed]) |
| 7185 | packed[2] = struct.pack("!H", length) |
| 7186 | return ''.join(packed) |
| 7187 | |
| 7188 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7189 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7190 | obj = queue_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7191 | _version = reader.read("!B")[0] |
| 7192 | assert(_version == 1) |
| 7193 | _type = reader.read("!B")[0] |
| 7194 | assert(_type == 16) |
| 7195 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7196 | orig_reader = reader |
| 7197 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7198 | obj.xid = reader.read("!L")[0] |
| 7199 | _stats_type = reader.read("!H")[0] |
| 7200 | assert(_stats_type == 5) |
| 7201 | obj.flags = reader.read("!H")[0] |
| 7202 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7203 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7204 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7205 | return obj |
| 7206 | |
| 7207 | def __eq__(self, other): |
| 7208 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7209 | if self.xid != other.xid: return False |
| 7210 | if self.flags != other.flags: return False |
| 7211 | if self.port_no != other.port_no: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7212 | if self.queue_id != other.queue_id: return False |
| 7213 | return True |
| 7214 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7215 | def pretty_print(self, q): |
| 7216 | q.text("queue_stats_request {") |
| 7217 | with q.group(): |
| 7218 | with q.indent(2): |
| 7219 | q.breakable() |
| 7220 | q.text("xid = "); |
| 7221 | if self.xid != None: |
| 7222 | q.text("%#x" % self.xid) |
| 7223 | else: |
| 7224 | q.text('None') |
| 7225 | q.text(","); q.breakable() |
| 7226 | q.text("flags = "); |
| 7227 | q.text("%#x" % self.flags) |
| 7228 | q.text(","); q.breakable() |
| 7229 | q.text("port_no = "); |
| 7230 | q.text(util.pretty_port(self.port_no)) |
| 7231 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7232 | q.text("queue_id = "); |
| 7233 | q.text("%#x" % self.queue_id) |
| 7234 | q.breakable() |
| 7235 | q.text('}') |
| 7236 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7237 | stats_request.subtypes[5] = queue_stats_request |
| 7238 | |
| 7239 | class set_config(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7240 | version = 1 |
| 7241 | type = 9 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7242 | |
| 7243 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7244 | if xid != None: |
| 7245 | self.xid = xid |
| 7246 | else: |
| 7247 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7248 | if flags != None: |
| 7249 | self.flags = flags |
| 7250 | else: |
| 7251 | self.flags = 0 |
| 7252 | if miss_send_len != None: |
| 7253 | self.miss_send_len = miss_send_len |
| 7254 | else: |
| 7255 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7256 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7257 | |
| 7258 | def pack(self): |
| 7259 | packed = [] |
| 7260 | packed.append(struct.pack("!B", self.version)) |
| 7261 | packed.append(struct.pack("!B", self.type)) |
| 7262 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7263 | packed.append(struct.pack("!L", self.xid)) |
| 7264 | packed.append(struct.pack("!H", self.flags)) |
| 7265 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 7266 | length = sum([len(x) for x in packed]) |
| 7267 | packed[2] = struct.pack("!H", length) |
| 7268 | return ''.join(packed) |
| 7269 | |
| 7270 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7271 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7272 | obj = set_config() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7273 | _version = reader.read("!B")[0] |
| 7274 | assert(_version == 1) |
| 7275 | _type = reader.read("!B")[0] |
| 7276 | assert(_type == 9) |
| 7277 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7278 | orig_reader = reader |
| 7279 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7280 | obj.xid = reader.read("!L")[0] |
| 7281 | obj.flags = reader.read("!H")[0] |
| 7282 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7283 | return obj |
| 7284 | |
| 7285 | def __eq__(self, other): |
| 7286 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7287 | if self.xid != other.xid: return False |
| 7288 | if self.flags != other.flags: return False |
| 7289 | if self.miss_send_len != other.miss_send_len: return False |
| 7290 | return True |
| 7291 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7292 | def pretty_print(self, q): |
| 7293 | q.text("set_config {") |
| 7294 | with q.group(): |
| 7295 | with q.indent(2): |
| 7296 | q.breakable() |
| 7297 | q.text("xid = "); |
| 7298 | if self.xid != None: |
| 7299 | q.text("%#x" % self.xid) |
| 7300 | else: |
| 7301 | q.text('None') |
| 7302 | q.text(","); q.breakable() |
| 7303 | q.text("flags = "); |
| 7304 | q.text("%#x" % self.flags) |
| 7305 | q.text(","); q.breakable() |
| 7306 | q.text("miss_send_len = "); |
| 7307 | q.text("%#x" % self.miss_send_len) |
| 7308 | q.breakable() |
| 7309 | q.text('}') |
| 7310 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7311 | message.subtypes[9] = set_config |
| 7312 | |
| 7313 | class table_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7314 | version = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7315 | type = 22 |
| 7316 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7317 | def __init__(self, xid=None, table_id=None, config=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7318 | if xid != None: |
| 7319 | self.xid = xid |
| 7320 | else: |
| 7321 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7322 | if table_id != None: |
| 7323 | self.table_id = table_id |
| 7324 | else: |
| 7325 | self.table_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7326 | if config != None: |
| 7327 | self.config = config |
| 7328 | else: |
| 7329 | self.config = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7330 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7331 | |
| 7332 | def pack(self): |
| 7333 | packed = [] |
| 7334 | packed.append(struct.pack("!B", self.version)) |
| 7335 | packed.append(struct.pack("!B", self.type)) |
| 7336 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7337 | packed.append(struct.pack("!L", self.xid)) |
| 7338 | packed.append(struct.pack("!B", self.table_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7339 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7340 | packed.append(struct.pack("!L", self.config)) |
| 7341 | length = sum([len(x) for x in packed]) |
| 7342 | packed[2] = struct.pack("!H", length) |
| 7343 | return ''.join(packed) |
| 7344 | |
| 7345 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7346 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7347 | obj = table_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7348 | _version = reader.read("!B")[0] |
| 7349 | assert(_version == 1) |
| 7350 | _type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7351 | assert(_type == 22) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7352 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7353 | orig_reader = reader |
| 7354 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7355 | obj.xid = reader.read("!L")[0] |
| 7356 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7357 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7358 | obj.config = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7359 | return obj |
| 7360 | |
| 7361 | def __eq__(self, other): |
| 7362 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7363 | if self.xid != other.xid: return False |
| 7364 | if self.table_id != other.table_id: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7365 | if self.config != other.config: return False |
| 7366 | return True |
| 7367 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7368 | def pretty_print(self, q): |
| 7369 | q.text("table_mod {") |
| 7370 | with q.group(): |
| 7371 | with q.indent(2): |
| 7372 | q.breakable() |
| 7373 | q.text("xid = "); |
| 7374 | if self.xid != None: |
| 7375 | q.text("%#x" % self.xid) |
| 7376 | else: |
| 7377 | q.text('None') |
| 7378 | q.text(","); q.breakable() |
| 7379 | q.text("table_id = "); |
| 7380 | q.text("%#x" % self.table_id) |
| 7381 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7382 | q.text("config = "); |
| 7383 | q.text("%#x" % self.config) |
| 7384 | q.breakable() |
| 7385 | q.text('}') |
| 7386 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7387 | message.subtypes[22] = table_mod |
| 7388 | |
| 7389 | class table_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7390 | version = 1 |
| 7391 | type = 17 |
| 7392 | stats_type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7393 | |
| 7394 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7395 | if xid != None: |
| 7396 | self.xid = xid |
| 7397 | else: |
| 7398 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7399 | if flags != None: |
| 7400 | self.flags = flags |
| 7401 | else: |
| 7402 | self.flags = 0 |
| 7403 | if entries != None: |
| 7404 | self.entries = entries |
| 7405 | else: |
| 7406 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7407 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7408 | |
| 7409 | def pack(self): |
| 7410 | packed = [] |
| 7411 | packed.append(struct.pack("!B", self.version)) |
| 7412 | packed.append(struct.pack("!B", self.type)) |
| 7413 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7414 | packed.append(struct.pack("!L", self.xid)) |
| 7415 | packed.append(struct.pack("!H", self.stats_type)) |
| 7416 | packed.append(struct.pack("!H", self.flags)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7417 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7418 | length = sum([len(x) for x in packed]) |
| 7419 | packed[2] = struct.pack("!H", length) |
| 7420 | return ''.join(packed) |
| 7421 | |
| 7422 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7423 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7424 | obj = table_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7425 | _version = reader.read("!B")[0] |
| 7426 | assert(_version == 1) |
| 7427 | _type = reader.read("!B")[0] |
| 7428 | assert(_type == 17) |
| 7429 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7430 | orig_reader = reader |
| 7431 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7432 | obj.xid = reader.read("!L")[0] |
| 7433 | _stats_type = reader.read("!H")[0] |
| 7434 | assert(_stats_type == 3) |
| 7435 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7436 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7437 | return obj |
| 7438 | |
| 7439 | def __eq__(self, other): |
| 7440 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7441 | if self.xid != other.xid: return False |
| 7442 | if self.flags != other.flags: return False |
| 7443 | if self.entries != other.entries: return False |
| 7444 | return True |
| 7445 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7446 | def pretty_print(self, q): |
| 7447 | q.text("table_stats_reply {") |
| 7448 | with q.group(): |
| 7449 | with q.indent(2): |
| 7450 | q.breakable() |
| 7451 | q.text("xid = "); |
| 7452 | if self.xid != None: |
| 7453 | q.text("%#x" % self.xid) |
| 7454 | else: |
| 7455 | q.text('None') |
| 7456 | q.text(","); q.breakable() |
| 7457 | q.text("flags = "); |
| 7458 | q.text("%#x" % self.flags) |
| 7459 | q.text(","); q.breakable() |
| 7460 | q.text("entries = "); |
| 7461 | q.pp(self.entries) |
| 7462 | q.breakable() |
| 7463 | q.text('}') |
| 7464 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7465 | stats_reply.subtypes[3] = table_stats_reply |
| 7466 | |
| 7467 | class table_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7468 | version = 1 |
| 7469 | type = 16 |
| 7470 | stats_type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7471 | |
| 7472 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7473 | if xid != None: |
| 7474 | self.xid = xid |
| 7475 | else: |
| 7476 | self.xid = None |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7477 | if flags != None: |
| 7478 | self.flags = flags |
| 7479 | else: |
| 7480 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7481 | return |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7482 | |
| 7483 | def pack(self): |
| 7484 | packed = [] |
| 7485 | packed.append(struct.pack("!B", self.version)) |
| 7486 | packed.append(struct.pack("!B", self.type)) |
| 7487 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7488 | packed.append(struct.pack("!L", self.xid)) |
| 7489 | packed.append(struct.pack("!H", self.stats_type)) |
| 7490 | packed.append(struct.pack("!H", self.flags)) |
| 7491 | length = sum([len(x) for x in packed]) |
| 7492 | packed[2] = struct.pack("!H", length) |
| 7493 | return ''.join(packed) |
| 7494 | |
| 7495 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7496 | def unpack(reader): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7497 | obj = table_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7498 | _version = reader.read("!B")[0] |
| 7499 | assert(_version == 1) |
| 7500 | _type = reader.read("!B")[0] |
| 7501 | assert(_type == 16) |
| 7502 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7503 | orig_reader = reader |
| 7504 | reader = orig_reader.slice(_length - (2 + 2)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7505 | obj.xid = reader.read("!L")[0] |
| 7506 | _stats_type = reader.read("!H")[0] |
| 7507 | assert(_stats_type == 3) |
| 7508 | obj.flags = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7509 | return obj |
| 7510 | |
| 7511 | def __eq__(self, other): |
| 7512 | if type(self) != type(other): return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7513 | if self.xid != other.xid: return False |
| 7514 | if self.flags != other.flags: return False |
| 7515 | return True |
| 7516 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7517 | def pretty_print(self, q): |
| 7518 | q.text("table_stats_request {") |
| 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("flags = "); |
| 7529 | q.text("%#x" % self.flags) |
| 7530 | q.breakable() |
| 7531 | q.text('}') |
| 7532 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7533 | stats_request.subtypes[3] = table_stats_request |
| 7534 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7535 | |
| 7536 | def parse_header(buf): |
| 7537 | if len(buf) < 8: |
| 7538 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 7539 | return struct.unpack_from("!BBHL", buf) |
| 7540 | |
| 7541 | def parse_message(buf): |
| 7542 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 7543 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 7544 | raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 7545 | if len(buf) != msg_len: |
| 7546 | raise loxi.ProtocolError("incorrect message size") |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7547 | return message.unpack(loxi.generic_util.OFReader(buf)) |