Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame^] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 17 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 18 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 19 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 20 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 21 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 22 | # Automatically generated by LOXI from template module.py |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 23 | # Do not modify |
| 24 | |
| 25 | import struct |
| 26 | import loxi |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 27 | import util |
| 28 | import loxi.generic_util |
| 29 | |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 30 | import sys |
| 31 | ofp = sys.modules['loxi.of12'] |
| 32 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 33 | class message(loxi.OFObject): |
| 34 | subtypes = {} |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 35 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 36 | version = 3 |
| 37 | |
| 38 | def __init__(self, type=None, xid=None): |
| 39 | if type != None: |
| 40 | self.type = type |
| 41 | else: |
| 42 | self.type = 0 |
| 43 | if xid != None: |
| 44 | self.xid = xid |
| 45 | else: |
| 46 | self.xid = None |
| 47 | return |
| 48 | |
| 49 | def pack(self): |
| 50 | packed = [] |
| 51 | packed.append(struct.pack("!B", self.version)) |
| 52 | packed.append(struct.pack("!B", self.type)) |
| 53 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 54 | packed.append(struct.pack("!L", self.xid)) |
| 55 | length = sum([len(x) for x in packed]) |
| 56 | packed[2] = struct.pack("!H", length) |
| 57 | return ''.join(packed) |
| 58 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 59 | @staticmethod |
| 60 | def unpack(reader): |
| 61 | subtype, = reader.peek('B', 1) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 62 | subclass = message.subtypes.get(subtype) |
| 63 | if subclass: |
| 64 | return subclass.unpack(reader) |
| 65 | |
| 66 | obj = message() |
| 67 | _version = reader.read("!B")[0] |
| 68 | assert(_version == 3) |
| 69 | obj.type = reader.read("!B")[0] |
| 70 | _length = reader.read("!H")[0] |
| 71 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 72 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 73 | obj.xid = reader.read("!L")[0] |
| 74 | return obj |
| 75 | |
| 76 | def __eq__(self, other): |
| 77 | if type(self) != type(other): return False |
| 78 | if self.type != other.type: return False |
| 79 | if self.xid != other.xid: return False |
| 80 | return True |
| 81 | |
| 82 | def pretty_print(self, q): |
| 83 | q.text("message {") |
| 84 | with q.group(): |
| 85 | with q.indent(2): |
| 86 | q.breakable() |
| 87 | q.text("xid = "); |
| 88 | if self.xid != None: |
| 89 | q.text("%#x" % self.xid) |
| 90 | else: |
| 91 | q.text('None') |
| 92 | q.breakable() |
| 93 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 94 | |
| 95 | |
| 96 | class stats_reply(message): |
| 97 | subtypes = {} |
| 98 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 99 | version = 3 |
| 100 | type = 19 |
| 101 | |
| 102 | def __init__(self, xid=None, stats_type=None, flags=None): |
| 103 | if xid != None: |
| 104 | self.xid = xid |
| 105 | else: |
| 106 | self.xid = None |
| 107 | if stats_type != None: |
| 108 | self.stats_type = stats_type |
| 109 | else: |
| 110 | self.stats_type = 0 |
| 111 | if flags != None: |
| 112 | self.flags = flags |
| 113 | else: |
| 114 | self.flags = 0 |
| 115 | return |
| 116 | |
| 117 | def pack(self): |
| 118 | packed = [] |
| 119 | packed.append(struct.pack("!B", self.version)) |
| 120 | packed.append(struct.pack("!B", self.type)) |
| 121 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 122 | packed.append(struct.pack("!L", self.xid)) |
| 123 | packed.append(struct.pack("!H", self.stats_type)) |
| 124 | packed.append(struct.pack("!H", self.flags)) |
| 125 | packed.append('\x00' * 4) |
| 126 | length = sum([len(x) for x in packed]) |
| 127 | packed[2] = struct.pack("!H", length) |
| 128 | return ''.join(packed) |
| 129 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 130 | @staticmethod |
| 131 | def unpack(reader): |
| 132 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 133 | subclass = stats_reply.subtypes.get(subtype) |
| 134 | if subclass: |
| 135 | return subclass.unpack(reader) |
| 136 | |
| 137 | obj = stats_reply() |
| 138 | _version = reader.read("!B")[0] |
| 139 | assert(_version == 3) |
| 140 | _type = reader.read("!B")[0] |
| 141 | assert(_type == 19) |
| 142 | _length = reader.read("!H")[0] |
| 143 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 144 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 145 | obj.xid = reader.read("!L")[0] |
| 146 | obj.stats_type = reader.read("!H")[0] |
| 147 | obj.flags = reader.read("!H")[0] |
| 148 | reader.skip(4) |
| 149 | return obj |
| 150 | |
| 151 | def __eq__(self, other): |
| 152 | if type(self) != type(other): return False |
| 153 | if self.xid != other.xid: return False |
| 154 | if self.stats_type != other.stats_type: return False |
| 155 | if self.flags != other.flags: return False |
| 156 | return True |
| 157 | |
| 158 | def pretty_print(self, q): |
| 159 | q.text("stats_reply {") |
| 160 | with q.group(): |
| 161 | with q.indent(2): |
| 162 | q.breakable() |
| 163 | q.text("xid = "); |
| 164 | if self.xid != None: |
| 165 | q.text("%#x" % self.xid) |
| 166 | else: |
| 167 | q.text('None') |
| 168 | q.text(","); q.breakable() |
| 169 | q.text("flags = "); |
| 170 | q.text("%#x" % self.flags) |
| 171 | q.breakable() |
| 172 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 173 | |
| 174 | message.subtypes[19] = stats_reply |
| 175 | |
| 176 | class aggregate_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 177 | version = 3 |
| 178 | type = 19 |
| 179 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 180 | |
| 181 | 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] | 182 | if xid != None: |
| 183 | self.xid = xid |
| 184 | else: |
| 185 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 186 | if flags != None: |
| 187 | self.flags = flags |
| 188 | else: |
| 189 | self.flags = 0 |
| 190 | if packet_count != None: |
| 191 | self.packet_count = packet_count |
| 192 | else: |
| 193 | self.packet_count = 0 |
| 194 | if byte_count != None: |
| 195 | self.byte_count = byte_count |
| 196 | else: |
| 197 | self.byte_count = 0 |
| 198 | if flow_count != None: |
| 199 | self.flow_count = flow_count |
| 200 | else: |
| 201 | self.flow_count = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 202 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 203 | |
| 204 | def pack(self): |
| 205 | packed = [] |
| 206 | packed.append(struct.pack("!B", self.version)) |
| 207 | packed.append(struct.pack("!B", self.type)) |
| 208 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 209 | packed.append(struct.pack("!L", self.xid)) |
| 210 | packed.append(struct.pack("!H", self.stats_type)) |
| 211 | packed.append(struct.pack("!H", self.flags)) |
| 212 | packed.append('\x00' * 4) |
| 213 | packed.append(struct.pack("!Q", self.packet_count)) |
| 214 | packed.append(struct.pack("!Q", self.byte_count)) |
| 215 | packed.append(struct.pack("!L", self.flow_count)) |
| 216 | packed.append('\x00' * 4) |
| 217 | length = sum([len(x) for x in packed]) |
| 218 | packed[2] = struct.pack("!H", length) |
| 219 | return ''.join(packed) |
| 220 | |
| 221 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 222 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 223 | obj = aggregate_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 224 | _version = reader.read("!B")[0] |
| 225 | assert(_version == 3) |
| 226 | _type = reader.read("!B")[0] |
| 227 | assert(_type == 19) |
| 228 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 229 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 230 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 231 | obj.xid = reader.read("!L")[0] |
| 232 | _stats_type = reader.read("!H")[0] |
| 233 | assert(_stats_type == 2) |
| 234 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 235 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 236 | obj.packet_count = reader.read("!Q")[0] |
| 237 | obj.byte_count = reader.read("!Q")[0] |
| 238 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 239 | reader.skip(4) |
| 240 | return obj |
| 241 | |
| 242 | def __eq__(self, other): |
| 243 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 244 | if self.xid != other.xid: return False |
| 245 | if self.flags != other.flags: return False |
| 246 | if self.packet_count != other.packet_count: return False |
| 247 | if self.byte_count != other.byte_count: return False |
| 248 | if self.flow_count != other.flow_count: return False |
| 249 | return True |
| 250 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 251 | def pretty_print(self, q): |
| 252 | q.text("aggregate_stats_reply {") |
| 253 | with q.group(): |
| 254 | with q.indent(2): |
| 255 | q.breakable() |
| 256 | q.text("xid = "); |
| 257 | if self.xid != None: |
| 258 | q.text("%#x" % self.xid) |
| 259 | else: |
| 260 | q.text('None') |
| 261 | q.text(","); q.breakable() |
| 262 | q.text("flags = "); |
| 263 | q.text("%#x" % self.flags) |
| 264 | q.text(","); q.breakable() |
| 265 | q.text("packet_count = "); |
| 266 | q.text("%#x" % self.packet_count) |
| 267 | q.text(","); q.breakable() |
| 268 | q.text("byte_count = "); |
| 269 | q.text("%#x" % self.byte_count) |
| 270 | q.text(","); q.breakable() |
| 271 | q.text("flow_count = "); |
| 272 | q.text("%#x" % self.flow_count) |
| 273 | q.breakable() |
| 274 | q.text('}') |
| 275 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 276 | stats_reply.subtypes[2] = aggregate_stats_reply |
| 277 | |
| 278 | class stats_request(message): |
| 279 | subtypes = {} |
| 280 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 281 | version = 3 |
| 282 | type = 18 |
| 283 | |
| 284 | def __init__(self, xid=None, stats_type=None, flags=None): |
| 285 | if xid != None: |
| 286 | self.xid = xid |
| 287 | else: |
| 288 | self.xid = None |
| 289 | if stats_type != None: |
| 290 | self.stats_type = stats_type |
| 291 | else: |
| 292 | self.stats_type = 0 |
| 293 | if flags != None: |
| 294 | self.flags = flags |
| 295 | else: |
| 296 | self.flags = 0 |
| 297 | return |
| 298 | |
| 299 | def pack(self): |
| 300 | packed = [] |
| 301 | packed.append(struct.pack("!B", self.version)) |
| 302 | packed.append(struct.pack("!B", self.type)) |
| 303 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 304 | packed.append(struct.pack("!L", self.xid)) |
| 305 | packed.append(struct.pack("!H", self.stats_type)) |
| 306 | packed.append(struct.pack("!H", self.flags)) |
| 307 | packed.append('\x00' * 4) |
| 308 | length = sum([len(x) for x in packed]) |
| 309 | packed[2] = struct.pack("!H", length) |
| 310 | return ''.join(packed) |
| 311 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 312 | @staticmethod |
| 313 | def unpack(reader): |
| 314 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 315 | subclass = stats_request.subtypes.get(subtype) |
| 316 | if subclass: |
| 317 | return subclass.unpack(reader) |
| 318 | |
| 319 | obj = stats_request() |
| 320 | _version = reader.read("!B")[0] |
| 321 | assert(_version == 3) |
| 322 | _type = reader.read("!B")[0] |
| 323 | assert(_type == 18) |
| 324 | _length = reader.read("!H")[0] |
| 325 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 326 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 327 | obj.xid = reader.read("!L")[0] |
| 328 | obj.stats_type = reader.read("!H")[0] |
| 329 | obj.flags = reader.read("!H")[0] |
| 330 | reader.skip(4) |
| 331 | return obj |
| 332 | |
| 333 | def __eq__(self, other): |
| 334 | if type(self) != type(other): return False |
| 335 | if self.xid != other.xid: return False |
| 336 | if self.stats_type != other.stats_type: return False |
| 337 | if self.flags != other.flags: return False |
| 338 | return True |
| 339 | |
| 340 | def pretty_print(self, q): |
| 341 | q.text("stats_request {") |
| 342 | with q.group(): |
| 343 | with q.indent(2): |
| 344 | q.breakable() |
| 345 | q.text("xid = "); |
| 346 | if self.xid != None: |
| 347 | q.text("%#x" % self.xid) |
| 348 | else: |
| 349 | q.text('None') |
| 350 | q.text(","); q.breakable() |
| 351 | q.text("flags = "); |
| 352 | q.text("%#x" % self.flags) |
| 353 | q.breakable() |
| 354 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 355 | |
| 356 | message.subtypes[18] = stats_request |
| 357 | |
| 358 | class aggregate_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 359 | version = 3 |
| 360 | type = 18 |
| 361 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 362 | |
| 363 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 364 | if xid != None: |
| 365 | self.xid = xid |
| 366 | else: |
| 367 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 368 | if flags != None: |
| 369 | self.flags = flags |
| 370 | else: |
| 371 | self.flags = 0 |
| 372 | if table_id != None: |
| 373 | self.table_id = table_id |
| 374 | else: |
| 375 | self.table_id = 0 |
| 376 | if out_port != None: |
| 377 | self.out_port = out_port |
| 378 | else: |
| 379 | self.out_port = 0 |
| 380 | if out_group != None: |
| 381 | self.out_group = out_group |
| 382 | else: |
| 383 | self.out_group = 0 |
| 384 | if cookie != None: |
| 385 | self.cookie = cookie |
| 386 | else: |
| 387 | self.cookie = 0 |
| 388 | if cookie_mask != None: |
| 389 | self.cookie_mask = cookie_mask |
| 390 | else: |
| 391 | self.cookie_mask = 0 |
| 392 | if match != None: |
| 393 | self.match = match |
| 394 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 395 | self.match = ofp.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 396 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 397 | |
| 398 | def pack(self): |
| 399 | packed = [] |
| 400 | packed.append(struct.pack("!B", self.version)) |
| 401 | packed.append(struct.pack("!B", self.type)) |
| 402 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 403 | packed.append(struct.pack("!L", self.xid)) |
| 404 | packed.append(struct.pack("!H", self.stats_type)) |
| 405 | packed.append(struct.pack("!H", self.flags)) |
| 406 | packed.append('\x00' * 4) |
| 407 | packed.append(struct.pack("!B", self.table_id)) |
| 408 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 409 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 410 | packed.append(struct.pack("!L", self.out_group)) |
| 411 | packed.append('\x00' * 4) |
| 412 | packed.append(struct.pack("!Q", self.cookie)) |
| 413 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 414 | packed.append(self.match.pack()) |
| 415 | length = sum([len(x) for x in packed]) |
| 416 | packed[2] = struct.pack("!H", length) |
| 417 | return ''.join(packed) |
| 418 | |
| 419 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 420 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 421 | obj = aggregate_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 422 | _version = reader.read("!B")[0] |
| 423 | assert(_version == 3) |
| 424 | _type = reader.read("!B")[0] |
| 425 | assert(_type == 18) |
| 426 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 427 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 428 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 429 | obj.xid = reader.read("!L")[0] |
| 430 | _stats_type = reader.read("!H")[0] |
| 431 | assert(_stats_type == 2) |
| 432 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 433 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 434 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 435 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 436 | obj.out_port = util.unpack_port_no(reader) |
| 437 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 438 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 439 | obj.cookie = reader.read("!Q")[0] |
| 440 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 441 | obj.match = ofp.match.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 442 | return obj |
| 443 | |
| 444 | def __eq__(self, other): |
| 445 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 446 | if self.xid != other.xid: return False |
| 447 | if self.flags != other.flags: return False |
| 448 | if self.table_id != other.table_id: return False |
| 449 | if self.out_port != other.out_port: return False |
| 450 | if self.out_group != other.out_group: return False |
| 451 | if self.cookie != other.cookie: return False |
| 452 | if self.cookie_mask != other.cookie_mask: return False |
| 453 | if self.match != other.match: return False |
| 454 | return True |
| 455 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 456 | def pretty_print(self, q): |
| 457 | q.text("aggregate_stats_request {") |
| 458 | with q.group(): |
| 459 | with q.indent(2): |
| 460 | q.breakable() |
| 461 | q.text("xid = "); |
| 462 | if self.xid != None: |
| 463 | q.text("%#x" % self.xid) |
| 464 | else: |
| 465 | q.text('None') |
| 466 | q.text(","); q.breakable() |
| 467 | q.text("flags = "); |
| 468 | q.text("%#x" % self.flags) |
| 469 | q.text(","); q.breakable() |
| 470 | q.text("table_id = "); |
| 471 | q.text("%#x" % self.table_id) |
| 472 | q.text(","); q.breakable() |
| 473 | q.text("out_port = "); |
| 474 | q.text(util.pretty_port(self.out_port)) |
| 475 | q.text(","); q.breakable() |
| 476 | q.text("out_group = "); |
| 477 | q.text("%#x" % self.out_group) |
| 478 | q.text(","); q.breakable() |
| 479 | q.text("cookie = "); |
| 480 | q.text("%#x" % self.cookie) |
| 481 | q.text(","); q.breakable() |
| 482 | q.text("cookie_mask = "); |
| 483 | q.text("%#x" % self.cookie_mask) |
| 484 | q.text(","); q.breakable() |
| 485 | q.text("match = "); |
| 486 | q.pp(self.match) |
| 487 | q.breakable() |
| 488 | q.text('}') |
| 489 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 490 | stats_request.subtypes[2] = aggregate_stats_request |
| 491 | |
| 492 | class error_msg(message): |
| 493 | subtypes = {} |
| 494 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 495 | version = 3 |
| 496 | type = 1 |
| 497 | |
| 498 | def __init__(self, xid=None, err_type=None): |
| 499 | if xid != None: |
| 500 | self.xid = xid |
| 501 | else: |
| 502 | self.xid = None |
| 503 | if err_type != None: |
| 504 | self.err_type = err_type |
| 505 | else: |
| 506 | self.err_type = 0 |
| 507 | return |
| 508 | |
| 509 | def pack(self): |
| 510 | packed = [] |
| 511 | packed.append(struct.pack("!B", self.version)) |
| 512 | packed.append(struct.pack("!B", self.type)) |
| 513 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 514 | packed.append(struct.pack("!L", self.xid)) |
| 515 | packed.append(struct.pack("!H", self.err_type)) |
| 516 | length = sum([len(x) for x in packed]) |
| 517 | packed[2] = struct.pack("!H", length) |
| 518 | return ''.join(packed) |
| 519 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 520 | @staticmethod |
| 521 | def unpack(reader): |
| 522 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 523 | subclass = error_msg.subtypes.get(subtype) |
| 524 | if subclass: |
| 525 | return subclass.unpack(reader) |
| 526 | |
| 527 | obj = error_msg() |
| 528 | _version = reader.read("!B")[0] |
| 529 | assert(_version == 3) |
| 530 | _type = reader.read("!B")[0] |
| 531 | assert(_type == 1) |
| 532 | _length = reader.read("!H")[0] |
| 533 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 534 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 535 | obj.xid = reader.read("!L")[0] |
| 536 | obj.err_type = reader.read("!H")[0] |
| 537 | return obj |
| 538 | |
| 539 | def __eq__(self, other): |
| 540 | if type(self) != type(other): return False |
| 541 | if self.xid != other.xid: return False |
| 542 | if self.err_type != other.err_type: return False |
| 543 | return True |
| 544 | |
| 545 | def pretty_print(self, q): |
| 546 | q.text("error_msg {") |
| 547 | with q.group(): |
| 548 | with q.indent(2): |
| 549 | q.breakable() |
| 550 | q.text("xid = "); |
| 551 | if self.xid != None: |
| 552 | q.text("%#x" % self.xid) |
| 553 | else: |
| 554 | q.text('None') |
| 555 | q.breakable() |
| 556 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 557 | |
| 558 | message.subtypes[1] = error_msg |
| 559 | |
| 560 | class bad_action_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 561 | version = 3 |
| 562 | type = 1 |
| 563 | err_type = 2 |
| 564 | |
| 565 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 566 | if xid != None: |
| 567 | self.xid = xid |
| 568 | else: |
| 569 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 570 | if code != None: |
| 571 | self.code = code |
| 572 | else: |
| 573 | self.code = 0 |
| 574 | if data != None: |
| 575 | self.data = data |
| 576 | else: |
| 577 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 578 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 579 | |
| 580 | def pack(self): |
| 581 | packed = [] |
| 582 | packed.append(struct.pack("!B", self.version)) |
| 583 | packed.append(struct.pack("!B", self.type)) |
| 584 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 585 | packed.append(struct.pack("!L", self.xid)) |
| 586 | packed.append(struct.pack("!H", self.err_type)) |
| 587 | packed.append(struct.pack("!H", self.code)) |
| 588 | packed.append(self.data) |
| 589 | length = sum([len(x) for x in packed]) |
| 590 | packed[2] = struct.pack("!H", length) |
| 591 | return ''.join(packed) |
| 592 | |
| 593 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 594 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 595 | obj = bad_action_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 596 | _version = reader.read("!B")[0] |
| 597 | assert(_version == 3) |
| 598 | _type = reader.read("!B")[0] |
| 599 | assert(_type == 1) |
| 600 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 601 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 602 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 603 | obj.xid = reader.read("!L")[0] |
| 604 | _err_type = reader.read("!H")[0] |
| 605 | assert(_err_type == 2) |
| 606 | obj.code = reader.read("!H")[0] |
| 607 | obj.data = str(reader.read_all()) |
| 608 | return obj |
| 609 | |
| 610 | def __eq__(self, other): |
| 611 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 612 | if self.xid != other.xid: return False |
| 613 | if self.code != other.code: return False |
| 614 | if self.data != other.data: return False |
| 615 | return True |
| 616 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 617 | def pretty_print(self, q): |
| 618 | q.text("bad_action_error_msg {") |
| 619 | with q.group(): |
| 620 | with q.indent(2): |
| 621 | q.breakable() |
| 622 | q.text("xid = "); |
| 623 | if self.xid != None: |
| 624 | q.text("%#x" % self.xid) |
| 625 | else: |
| 626 | q.text('None') |
| 627 | q.text(","); q.breakable() |
| 628 | q.text("code = "); |
| 629 | q.text("%#x" % self.code) |
| 630 | q.text(","); q.breakable() |
| 631 | q.text("data = "); |
| 632 | q.pp(self.data) |
| 633 | q.breakable() |
| 634 | q.text('}') |
| 635 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 636 | error_msg.subtypes[2] = bad_action_error_msg |
| 637 | |
| 638 | class bad_instruction_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 639 | version = 3 |
| 640 | type = 1 |
| 641 | err_type = 3 |
| 642 | |
| 643 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 644 | if xid != None: |
| 645 | self.xid = xid |
| 646 | else: |
| 647 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 648 | if code != None: |
| 649 | self.code = code |
| 650 | else: |
| 651 | self.code = 0 |
| 652 | if data != None: |
| 653 | self.data = data |
| 654 | else: |
| 655 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 656 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 657 | |
| 658 | def pack(self): |
| 659 | packed = [] |
| 660 | packed.append(struct.pack("!B", self.version)) |
| 661 | packed.append(struct.pack("!B", self.type)) |
| 662 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 663 | packed.append(struct.pack("!L", self.xid)) |
| 664 | packed.append(struct.pack("!H", self.err_type)) |
| 665 | packed.append(struct.pack("!H", self.code)) |
| 666 | packed.append(self.data) |
| 667 | length = sum([len(x) for x in packed]) |
| 668 | packed[2] = struct.pack("!H", length) |
| 669 | return ''.join(packed) |
| 670 | |
| 671 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 672 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 673 | obj = bad_instruction_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 674 | _version = reader.read("!B")[0] |
| 675 | assert(_version == 3) |
| 676 | _type = reader.read("!B")[0] |
| 677 | assert(_type == 1) |
| 678 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 679 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 680 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 681 | obj.xid = reader.read("!L")[0] |
| 682 | _err_type = reader.read("!H")[0] |
| 683 | assert(_err_type == 3) |
| 684 | obj.code = reader.read("!H")[0] |
| 685 | obj.data = str(reader.read_all()) |
| 686 | return obj |
| 687 | |
| 688 | def __eq__(self, other): |
| 689 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 690 | if self.xid != other.xid: return False |
| 691 | if self.code != other.code: return False |
| 692 | if self.data != other.data: return False |
| 693 | return True |
| 694 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 695 | def pretty_print(self, q): |
| 696 | q.text("bad_instruction_error_msg {") |
| 697 | with q.group(): |
| 698 | with q.indent(2): |
| 699 | q.breakable() |
| 700 | q.text("xid = "); |
| 701 | if self.xid != None: |
| 702 | q.text("%#x" % self.xid) |
| 703 | else: |
| 704 | q.text('None') |
| 705 | q.text(","); q.breakable() |
| 706 | q.text("code = "); |
| 707 | q.text("%#x" % self.code) |
| 708 | q.text(","); q.breakable() |
| 709 | q.text("data = "); |
| 710 | q.pp(self.data) |
| 711 | q.breakable() |
| 712 | q.text('}') |
| 713 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 714 | error_msg.subtypes[3] = bad_instruction_error_msg |
| 715 | |
| 716 | class bad_match_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 717 | version = 3 |
| 718 | type = 1 |
| 719 | err_type = 4 |
| 720 | |
| 721 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 722 | if xid != None: |
| 723 | self.xid = xid |
| 724 | else: |
| 725 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 726 | if code != None: |
| 727 | self.code = code |
| 728 | else: |
| 729 | self.code = 0 |
| 730 | if data != None: |
| 731 | self.data = data |
| 732 | else: |
| 733 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 734 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 735 | |
| 736 | def pack(self): |
| 737 | packed = [] |
| 738 | packed.append(struct.pack("!B", self.version)) |
| 739 | packed.append(struct.pack("!B", self.type)) |
| 740 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 741 | packed.append(struct.pack("!L", self.xid)) |
| 742 | packed.append(struct.pack("!H", self.err_type)) |
| 743 | packed.append(struct.pack("!H", self.code)) |
| 744 | packed.append(self.data) |
| 745 | length = sum([len(x) for x in packed]) |
| 746 | packed[2] = struct.pack("!H", length) |
| 747 | return ''.join(packed) |
| 748 | |
| 749 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 750 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 751 | obj = bad_match_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 752 | _version = reader.read("!B")[0] |
| 753 | assert(_version == 3) |
| 754 | _type = reader.read("!B")[0] |
| 755 | assert(_type == 1) |
| 756 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 757 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 758 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 759 | obj.xid = reader.read("!L")[0] |
| 760 | _err_type = reader.read("!H")[0] |
| 761 | assert(_err_type == 4) |
| 762 | obj.code = reader.read("!H")[0] |
| 763 | obj.data = str(reader.read_all()) |
| 764 | return obj |
| 765 | |
| 766 | def __eq__(self, other): |
| 767 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 768 | if self.xid != other.xid: return False |
| 769 | if self.code != other.code: return False |
| 770 | if self.data != other.data: return False |
| 771 | return True |
| 772 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 773 | def pretty_print(self, q): |
| 774 | q.text("bad_match_error_msg {") |
| 775 | with q.group(): |
| 776 | with q.indent(2): |
| 777 | q.breakable() |
| 778 | q.text("xid = "); |
| 779 | if self.xid != None: |
| 780 | q.text("%#x" % self.xid) |
| 781 | else: |
| 782 | q.text('None') |
| 783 | q.text(","); q.breakable() |
| 784 | q.text("code = "); |
| 785 | q.text("%#x" % self.code) |
| 786 | q.text(","); q.breakable() |
| 787 | q.text("data = "); |
| 788 | q.pp(self.data) |
| 789 | q.breakable() |
| 790 | q.text('}') |
| 791 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 792 | error_msg.subtypes[4] = bad_match_error_msg |
| 793 | |
| 794 | class bad_request_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 795 | version = 3 |
| 796 | type = 1 |
| 797 | err_type = 1 |
| 798 | |
| 799 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 800 | if xid != None: |
| 801 | self.xid = xid |
| 802 | else: |
| 803 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 804 | if code != None: |
| 805 | self.code = code |
| 806 | else: |
| 807 | self.code = 0 |
| 808 | if data != None: |
| 809 | self.data = data |
| 810 | else: |
| 811 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 812 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 813 | |
| 814 | def pack(self): |
| 815 | packed = [] |
| 816 | packed.append(struct.pack("!B", self.version)) |
| 817 | packed.append(struct.pack("!B", self.type)) |
| 818 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 819 | packed.append(struct.pack("!L", self.xid)) |
| 820 | packed.append(struct.pack("!H", self.err_type)) |
| 821 | packed.append(struct.pack("!H", self.code)) |
| 822 | packed.append(self.data) |
| 823 | length = sum([len(x) for x in packed]) |
| 824 | packed[2] = struct.pack("!H", length) |
| 825 | return ''.join(packed) |
| 826 | |
| 827 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 828 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 829 | obj = bad_request_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 830 | _version = reader.read("!B")[0] |
| 831 | assert(_version == 3) |
| 832 | _type = reader.read("!B")[0] |
| 833 | assert(_type == 1) |
| 834 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 835 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 836 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 837 | obj.xid = reader.read("!L")[0] |
| 838 | _err_type = reader.read("!H")[0] |
| 839 | assert(_err_type == 1) |
| 840 | obj.code = reader.read("!H")[0] |
| 841 | obj.data = str(reader.read_all()) |
| 842 | return obj |
| 843 | |
| 844 | def __eq__(self, other): |
| 845 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 846 | if self.xid != other.xid: return False |
| 847 | if self.code != other.code: return False |
| 848 | if self.data != other.data: return False |
| 849 | return True |
| 850 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 851 | def pretty_print(self, q): |
| 852 | q.text("bad_request_error_msg {") |
| 853 | with q.group(): |
| 854 | with q.indent(2): |
| 855 | q.breakable() |
| 856 | q.text("xid = "); |
| 857 | if self.xid != None: |
| 858 | q.text("%#x" % self.xid) |
| 859 | else: |
| 860 | q.text('None') |
| 861 | q.text(","); q.breakable() |
| 862 | q.text("code = "); |
| 863 | q.text("%#x" % self.code) |
| 864 | q.text(","); q.breakable() |
| 865 | q.text("data = "); |
| 866 | q.pp(self.data) |
| 867 | q.breakable() |
| 868 | q.text('}') |
| 869 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 870 | error_msg.subtypes[1] = bad_request_error_msg |
| 871 | |
| 872 | class barrier_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 873 | version = 3 |
| 874 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 875 | |
| 876 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 877 | if xid != None: |
| 878 | self.xid = xid |
| 879 | else: |
| 880 | self.xid = None |
| 881 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 882 | |
| 883 | def pack(self): |
| 884 | packed = [] |
| 885 | packed.append(struct.pack("!B", self.version)) |
| 886 | packed.append(struct.pack("!B", self.type)) |
| 887 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 888 | packed.append(struct.pack("!L", self.xid)) |
| 889 | length = sum([len(x) for x in packed]) |
| 890 | packed[2] = struct.pack("!H", length) |
| 891 | return ''.join(packed) |
| 892 | |
| 893 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 894 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 895 | obj = barrier_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 896 | _version = reader.read("!B")[0] |
| 897 | assert(_version == 3) |
| 898 | _type = reader.read("!B")[0] |
| 899 | assert(_type == 21) |
| 900 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 901 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 902 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 903 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 904 | return obj |
| 905 | |
| 906 | def __eq__(self, other): |
| 907 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 908 | if self.xid != other.xid: return False |
| 909 | return True |
| 910 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 911 | def pretty_print(self, q): |
| 912 | q.text("barrier_reply {") |
| 913 | with q.group(): |
| 914 | with q.indent(2): |
| 915 | q.breakable() |
| 916 | q.text("xid = "); |
| 917 | if self.xid != None: |
| 918 | q.text("%#x" % self.xid) |
| 919 | else: |
| 920 | q.text('None') |
| 921 | q.breakable() |
| 922 | q.text('}') |
| 923 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 924 | message.subtypes[21] = barrier_reply |
| 925 | |
| 926 | class barrier_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 927 | version = 3 |
| 928 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 929 | |
| 930 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 931 | if xid != None: |
| 932 | self.xid = xid |
| 933 | else: |
| 934 | self.xid = None |
| 935 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 936 | |
| 937 | def pack(self): |
| 938 | packed = [] |
| 939 | packed.append(struct.pack("!B", self.version)) |
| 940 | packed.append(struct.pack("!B", self.type)) |
| 941 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 942 | packed.append(struct.pack("!L", self.xid)) |
| 943 | length = sum([len(x) for x in packed]) |
| 944 | packed[2] = struct.pack("!H", length) |
| 945 | return ''.join(packed) |
| 946 | |
| 947 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 948 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 949 | obj = barrier_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 950 | _version = reader.read("!B")[0] |
| 951 | assert(_version == 3) |
| 952 | _type = reader.read("!B")[0] |
| 953 | assert(_type == 20) |
| 954 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 955 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 956 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 957 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 958 | return obj |
| 959 | |
| 960 | def __eq__(self, other): |
| 961 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 962 | if self.xid != other.xid: return False |
| 963 | return True |
| 964 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 965 | def pretty_print(self, q): |
| 966 | q.text("barrier_request {") |
| 967 | with q.group(): |
| 968 | with q.indent(2): |
| 969 | q.breakable() |
| 970 | q.text("xid = "); |
| 971 | if self.xid != None: |
| 972 | q.text("%#x" % self.xid) |
| 973 | else: |
| 974 | q.text('None') |
| 975 | q.breakable() |
| 976 | q.text('}') |
| 977 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 978 | message.subtypes[20] = barrier_request |
| 979 | |
| 980 | class experimenter(message): |
| 981 | subtypes = {} |
| 982 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 983 | version = 3 |
| 984 | type = 4 |
| 985 | |
| 986 | def __init__(self, xid=None, experimenter=None, subtype=None, data=None): |
| 987 | if xid != None: |
| 988 | self.xid = xid |
| 989 | else: |
| 990 | self.xid = None |
| 991 | if experimenter != None: |
| 992 | self.experimenter = experimenter |
| 993 | else: |
| 994 | self.experimenter = 0 |
| 995 | if subtype != None: |
| 996 | self.subtype = subtype |
| 997 | else: |
| 998 | self.subtype = 0 |
| 999 | if data != None: |
| 1000 | self.data = data |
| 1001 | else: |
| 1002 | self.data = '' |
| 1003 | return |
| 1004 | |
| 1005 | def pack(self): |
| 1006 | packed = [] |
| 1007 | packed.append(struct.pack("!B", self.version)) |
| 1008 | packed.append(struct.pack("!B", self.type)) |
| 1009 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1010 | packed.append(struct.pack("!L", self.xid)) |
| 1011 | packed.append(struct.pack("!L", self.experimenter)) |
| 1012 | packed.append(struct.pack("!L", self.subtype)) |
| 1013 | packed.append(self.data) |
| 1014 | length = sum([len(x) for x in packed]) |
| 1015 | packed[2] = struct.pack("!H", length) |
| 1016 | return ''.join(packed) |
| 1017 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1018 | @staticmethod |
| 1019 | def unpack(reader): |
| 1020 | subtype, = reader.peek('!L', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1021 | subclass = experimenter.subtypes.get(subtype) |
| 1022 | if subclass: |
| 1023 | return subclass.unpack(reader) |
| 1024 | |
| 1025 | obj = experimenter() |
| 1026 | _version = reader.read("!B")[0] |
| 1027 | assert(_version == 3) |
| 1028 | _type = reader.read("!B")[0] |
| 1029 | assert(_type == 4) |
| 1030 | _length = reader.read("!H")[0] |
| 1031 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1032 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1033 | obj.xid = reader.read("!L")[0] |
| 1034 | obj.experimenter = reader.read("!L")[0] |
| 1035 | obj.subtype = reader.read("!L")[0] |
| 1036 | obj.data = str(reader.read_all()) |
| 1037 | return obj |
| 1038 | |
| 1039 | def __eq__(self, other): |
| 1040 | if type(self) != type(other): return False |
| 1041 | if self.xid != other.xid: return False |
| 1042 | if self.experimenter != other.experimenter: return False |
| 1043 | if self.subtype != other.subtype: return False |
| 1044 | if self.data != other.data: return False |
| 1045 | return True |
| 1046 | |
| 1047 | def pretty_print(self, q): |
| 1048 | q.text("experimenter {") |
| 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.text(","); q.breakable() |
| 1058 | q.text("subtype = "); |
| 1059 | q.text("%#x" % self.subtype) |
| 1060 | q.text(","); q.breakable() |
| 1061 | q.text("data = "); |
| 1062 | q.pp(self.data) |
| 1063 | q.breakable() |
| 1064 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1065 | |
| 1066 | message.subtypes[4] = experimenter |
| 1067 | |
| 1068 | class bsn_header(experimenter): |
| 1069 | subtypes = {} |
| 1070 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1071 | version = 3 |
| 1072 | type = 4 |
| 1073 | experimenter = 6035143 |
| 1074 | |
| 1075 | def __init__(self, xid=None, subtype=None): |
| 1076 | if xid != None: |
| 1077 | self.xid = xid |
| 1078 | else: |
| 1079 | self.xid = None |
| 1080 | if subtype != None: |
| 1081 | self.subtype = subtype |
| 1082 | else: |
| 1083 | self.subtype = 0 |
| 1084 | return |
| 1085 | |
| 1086 | def pack(self): |
| 1087 | packed = [] |
| 1088 | packed.append(struct.pack("!B", self.version)) |
| 1089 | packed.append(struct.pack("!B", self.type)) |
| 1090 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1091 | packed.append(struct.pack("!L", self.xid)) |
| 1092 | packed.append(struct.pack("!L", self.experimenter)) |
| 1093 | packed.append(struct.pack("!L", self.subtype)) |
| 1094 | length = sum([len(x) for x in packed]) |
| 1095 | packed[2] = struct.pack("!H", length) |
| 1096 | return ''.join(packed) |
| 1097 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1098 | @staticmethod |
| 1099 | def unpack(reader): |
| 1100 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1101 | subclass = bsn_header.subtypes.get(subtype) |
| 1102 | if subclass: |
| 1103 | return subclass.unpack(reader) |
| 1104 | |
| 1105 | obj = bsn_header() |
| 1106 | _version = reader.read("!B")[0] |
| 1107 | assert(_version == 3) |
| 1108 | _type = reader.read("!B")[0] |
| 1109 | assert(_type == 4) |
| 1110 | _length = reader.read("!H")[0] |
| 1111 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1112 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 1113 | obj.xid = reader.read("!L")[0] |
| 1114 | _experimenter = reader.read("!L")[0] |
| 1115 | assert(_experimenter == 6035143) |
| 1116 | obj.subtype = reader.read("!L")[0] |
| 1117 | return obj |
| 1118 | |
| 1119 | def __eq__(self, other): |
| 1120 | if type(self) != type(other): return False |
| 1121 | if self.xid != other.xid: return False |
| 1122 | if self.subtype != other.subtype: return False |
| 1123 | return True |
| 1124 | |
| 1125 | def pretty_print(self, q): |
| 1126 | q.text("bsn_header {") |
| 1127 | with q.group(): |
| 1128 | with q.indent(2): |
| 1129 | q.breakable() |
| 1130 | q.text("xid = "); |
| 1131 | if self.xid != None: |
| 1132 | q.text("%#x" % self.xid) |
| 1133 | else: |
| 1134 | q.text('None') |
| 1135 | q.breakable() |
| 1136 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1137 | |
| 1138 | experimenter.subtypes[6035143] = bsn_header |
| 1139 | |
| 1140 | class bsn_bw_clear_data_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1141 | version = 3 |
| 1142 | type = 4 |
| 1143 | experimenter = 6035143 |
| 1144 | subtype = 22 |
| 1145 | |
| 1146 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1147 | if xid != None: |
| 1148 | self.xid = xid |
| 1149 | else: |
| 1150 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1151 | if status != None: |
| 1152 | self.status = status |
| 1153 | else: |
| 1154 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1155 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1156 | |
| 1157 | def pack(self): |
| 1158 | packed = [] |
| 1159 | packed.append(struct.pack("!B", self.version)) |
| 1160 | packed.append(struct.pack("!B", self.type)) |
| 1161 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1162 | packed.append(struct.pack("!L", self.xid)) |
| 1163 | packed.append(struct.pack("!L", self.experimenter)) |
| 1164 | packed.append(struct.pack("!L", self.subtype)) |
| 1165 | packed.append(struct.pack("!L", self.status)) |
| 1166 | length = sum([len(x) for x in packed]) |
| 1167 | packed[2] = struct.pack("!H", length) |
| 1168 | return ''.join(packed) |
| 1169 | |
| 1170 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1171 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1172 | obj = bsn_bw_clear_data_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1173 | _version = reader.read("!B")[0] |
| 1174 | assert(_version == 3) |
| 1175 | _type = reader.read("!B")[0] |
| 1176 | assert(_type == 4) |
| 1177 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1178 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1179 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1180 | obj.xid = reader.read("!L")[0] |
| 1181 | _experimenter = reader.read("!L")[0] |
| 1182 | assert(_experimenter == 6035143) |
| 1183 | _subtype = reader.read("!L")[0] |
| 1184 | assert(_subtype == 22) |
| 1185 | obj.status = reader.read("!L")[0] |
| 1186 | return obj |
| 1187 | |
| 1188 | def __eq__(self, other): |
| 1189 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1190 | if self.xid != other.xid: return False |
| 1191 | if self.status != other.status: return False |
| 1192 | return True |
| 1193 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1194 | def pretty_print(self, q): |
| 1195 | q.text("bsn_bw_clear_data_reply {") |
| 1196 | with q.group(): |
| 1197 | with q.indent(2): |
| 1198 | q.breakable() |
| 1199 | q.text("xid = "); |
| 1200 | if self.xid != None: |
| 1201 | q.text("%#x" % self.xid) |
| 1202 | else: |
| 1203 | q.text('None') |
| 1204 | q.text(","); q.breakable() |
| 1205 | q.text("status = "); |
| 1206 | q.text("%#x" % self.status) |
| 1207 | q.breakable() |
| 1208 | q.text('}') |
| 1209 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1210 | bsn_header.subtypes[22] = bsn_bw_clear_data_reply |
| 1211 | |
| 1212 | class bsn_bw_clear_data_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1213 | version = 3 |
| 1214 | type = 4 |
| 1215 | experimenter = 6035143 |
| 1216 | subtype = 21 |
| 1217 | |
| 1218 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1219 | if xid != None: |
| 1220 | self.xid = xid |
| 1221 | else: |
| 1222 | self.xid = None |
| 1223 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1224 | |
| 1225 | def pack(self): |
| 1226 | packed = [] |
| 1227 | packed.append(struct.pack("!B", self.version)) |
| 1228 | packed.append(struct.pack("!B", self.type)) |
| 1229 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1230 | packed.append(struct.pack("!L", self.xid)) |
| 1231 | packed.append(struct.pack("!L", self.experimenter)) |
| 1232 | packed.append(struct.pack("!L", self.subtype)) |
| 1233 | length = sum([len(x) for x in packed]) |
| 1234 | packed[2] = struct.pack("!H", length) |
| 1235 | return ''.join(packed) |
| 1236 | |
| 1237 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1238 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1239 | obj = bsn_bw_clear_data_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1240 | _version = reader.read("!B")[0] |
| 1241 | assert(_version == 3) |
| 1242 | _type = reader.read("!B")[0] |
| 1243 | assert(_type == 4) |
| 1244 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1245 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1246 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1247 | obj.xid = reader.read("!L")[0] |
| 1248 | _experimenter = reader.read("!L")[0] |
| 1249 | assert(_experimenter == 6035143) |
| 1250 | _subtype = reader.read("!L")[0] |
| 1251 | assert(_subtype == 21) |
| 1252 | return obj |
| 1253 | |
| 1254 | def __eq__(self, other): |
| 1255 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1256 | if self.xid != other.xid: return False |
| 1257 | return True |
| 1258 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1259 | def pretty_print(self, q): |
| 1260 | q.text("bsn_bw_clear_data_request {") |
| 1261 | with q.group(): |
| 1262 | with q.indent(2): |
| 1263 | q.breakable() |
| 1264 | q.text("xid = "); |
| 1265 | if self.xid != None: |
| 1266 | q.text("%#x" % self.xid) |
| 1267 | else: |
| 1268 | q.text('None') |
| 1269 | q.breakable() |
| 1270 | q.text('}') |
| 1271 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1272 | bsn_header.subtypes[21] = bsn_bw_clear_data_request |
| 1273 | |
| 1274 | class bsn_bw_enable_get_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1275 | version = 3 |
| 1276 | type = 4 |
| 1277 | experimenter = 6035143 |
| 1278 | subtype = 20 |
| 1279 | |
| 1280 | def __init__(self, xid=None, enabled=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1281 | if xid != None: |
| 1282 | self.xid = xid |
| 1283 | else: |
| 1284 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1285 | if enabled != None: |
| 1286 | self.enabled = enabled |
| 1287 | else: |
| 1288 | self.enabled = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1289 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1290 | |
| 1291 | def pack(self): |
| 1292 | packed = [] |
| 1293 | packed.append(struct.pack("!B", self.version)) |
| 1294 | packed.append(struct.pack("!B", self.type)) |
| 1295 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1296 | packed.append(struct.pack("!L", self.xid)) |
| 1297 | packed.append(struct.pack("!L", self.experimenter)) |
| 1298 | packed.append(struct.pack("!L", self.subtype)) |
| 1299 | packed.append(struct.pack("!L", self.enabled)) |
| 1300 | length = sum([len(x) for x in packed]) |
| 1301 | packed[2] = struct.pack("!H", length) |
| 1302 | return ''.join(packed) |
| 1303 | |
| 1304 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1305 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1306 | obj = bsn_bw_enable_get_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1307 | _version = reader.read("!B")[0] |
| 1308 | assert(_version == 3) |
| 1309 | _type = reader.read("!B")[0] |
| 1310 | assert(_type == 4) |
| 1311 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1312 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1313 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1314 | obj.xid = reader.read("!L")[0] |
| 1315 | _experimenter = reader.read("!L")[0] |
| 1316 | assert(_experimenter == 6035143) |
| 1317 | _subtype = reader.read("!L")[0] |
| 1318 | assert(_subtype == 20) |
| 1319 | obj.enabled = reader.read("!L")[0] |
| 1320 | return obj |
| 1321 | |
| 1322 | def __eq__(self, other): |
| 1323 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1324 | if self.xid != other.xid: return False |
| 1325 | if self.enabled != other.enabled: return False |
| 1326 | return True |
| 1327 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1328 | def pretty_print(self, q): |
| 1329 | q.text("bsn_bw_enable_get_reply {") |
| 1330 | with q.group(): |
| 1331 | with q.indent(2): |
| 1332 | q.breakable() |
| 1333 | q.text("xid = "); |
| 1334 | if self.xid != None: |
| 1335 | q.text("%#x" % self.xid) |
| 1336 | else: |
| 1337 | q.text('None') |
| 1338 | q.text(","); q.breakable() |
| 1339 | q.text("enabled = "); |
| 1340 | q.text("%#x" % self.enabled) |
| 1341 | q.breakable() |
| 1342 | q.text('}') |
| 1343 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1344 | bsn_header.subtypes[20] = bsn_bw_enable_get_reply |
| 1345 | |
| 1346 | class bsn_bw_enable_get_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1347 | version = 3 |
| 1348 | type = 4 |
| 1349 | experimenter = 6035143 |
| 1350 | subtype = 19 |
| 1351 | |
| 1352 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1353 | if xid != None: |
| 1354 | self.xid = xid |
| 1355 | else: |
| 1356 | self.xid = None |
| 1357 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1358 | |
| 1359 | def pack(self): |
| 1360 | packed = [] |
| 1361 | packed.append(struct.pack("!B", self.version)) |
| 1362 | packed.append(struct.pack("!B", self.type)) |
| 1363 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1364 | packed.append(struct.pack("!L", self.xid)) |
| 1365 | packed.append(struct.pack("!L", self.experimenter)) |
| 1366 | packed.append(struct.pack("!L", self.subtype)) |
| 1367 | length = sum([len(x) for x in packed]) |
| 1368 | packed[2] = struct.pack("!H", length) |
| 1369 | return ''.join(packed) |
| 1370 | |
| 1371 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1372 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1373 | obj = bsn_bw_enable_get_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1374 | _version = reader.read("!B")[0] |
| 1375 | assert(_version == 3) |
| 1376 | _type = reader.read("!B")[0] |
| 1377 | assert(_type == 4) |
| 1378 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1379 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1380 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1381 | obj.xid = reader.read("!L")[0] |
| 1382 | _experimenter = reader.read("!L")[0] |
| 1383 | assert(_experimenter == 6035143) |
| 1384 | _subtype = reader.read("!L")[0] |
| 1385 | assert(_subtype == 19) |
| 1386 | return obj |
| 1387 | |
| 1388 | def __eq__(self, other): |
| 1389 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1390 | if self.xid != other.xid: return False |
| 1391 | return True |
| 1392 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1393 | def pretty_print(self, q): |
| 1394 | q.text("bsn_bw_enable_get_request {") |
| 1395 | with q.group(): |
| 1396 | with q.indent(2): |
| 1397 | q.breakable() |
| 1398 | q.text("xid = "); |
| 1399 | if self.xid != None: |
| 1400 | q.text("%#x" % self.xid) |
| 1401 | else: |
| 1402 | q.text('None') |
| 1403 | q.breakable() |
| 1404 | q.text('}') |
| 1405 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1406 | bsn_header.subtypes[19] = bsn_bw_enable_get_request |
| 1407 | |
| 1408 | class bsn_bw_enable_set_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1409 | version = 3 |
| 1410 | type = 4 |
| 1411 | experimenter = 6035143 |
| 1412 | subtype = 23 |
| 1413 | |
| 1414 | def __init__(self, xid=None, enable=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1415 | if xid != None: |
| 1416 | self.xid = xid |
| 1417 | else: |
| 1418 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1419 | if enable != None: |
| 1420 | self.enable = enable |
| 1421 | else: |
| 1422 | self.enable = 0 |
| 1423 | if status != None: |
| 1424 | self.status = status |
| 1425 | else: |
| 1426 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1427 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1428 | |
| 1429 | def pack(self): |
| 1430 | packed = [] |
| 1431 | packed.append(struct.pack("!B", self.version)) |
| 1432 | packed.append(struct.pack("!B", self.type)) |
| 1433 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1434 | packed.append(struct.pack("!L", self.xid)) |
| 1435 | packed.append(struct.pack("!L", self.experimenter)) |
| 1436 | packed.append(struct.pack("!L", self.subtype)) |
| 1437 | packed.append(struct.pack("!L", self.enable)) |
| 1438 | packed.append(struct.pack("!L", self.status)) |
| 1439 | length = sum([len(x) for x in packed]) |
| 1440 | packed[2] = struct.pack("!H", length) |
| 1441 | return ''.join(packed) |
| 1442 | |
| 1443 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1444 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1445 | obj = bsn_bw_enable_set_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1446 | _version = reader.read("!B")[0] |
| 1447 | assert(_version == 3) |
| 1448 | _type = reader.read("!B")[0] |
| 1449 | assert(_type == 4) |
| 1450 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1451 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1452 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1453 | obj.xid = reader.read("!L")[0] |
| 1454 | _experimenter = reader.read("!L")[0] |
| 1455 | assert(_experimenter == 6035143) |
| 1456 | _subtype = reader.read("!L")[0] |
| 1457 | assert(_subtype == 23) |
| 1458 | obj.enable = reader.read("!L")[0] |
| 1459 | obj.status = reader.read("!L")[0] |
| 1460 | return obj |
| 1461 | |
| 1462 | def __eq__(self, other): |
| 1463 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1464 | if self.xid != other.xid: return False |
| 1465 | if self.enable != other.enable: return False |
| 1466 | if self.status != other.status: return False |
| 1467 | return True |
| 1468 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1469 | def pretty_print(self, q): |
| 1470 | q.text("bsn_bw_enable_set_reply {") |
| 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.text(","); q.breakable() |
| 1480 | q.text("enable = "); |
| 1481 | q.text("%#x" % self.enable) |
| 1482 | q.text(","); q.breakable() |
| 1483 | q.text("status = "); |
| 1484 | q.text("%#x" % self.status) |
| 1485 | q.breakable() |
| 1486 | q.text('}') |
| 1487 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1488 | bsn_header.subtypes[23] = bsn_bw_enable_set_reply |
| 1489 | |
| 1490 | class bsn_bw_enable_set_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1491 | version = 3 |
| 1492 | type = 4 |
| 1493 | experimenter = 6035143 |
| 1494 | subtype = 18 |
| 1495 | |
| 1496 | def __init__(self, xid=None, enable=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1497 | if xid != None: |
| 1498 | self.xid = xid |
| 1499 | else: |
| 1500 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1501 | if enable != None: |
| 1502 | self.enable = enable |
| 1503 | else: |
| 1504 | self.enable = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1505 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1506 | |
| 1507 | def pack(self): |
| 1508 | packed = [] |
| 1509 | packed.append(struct.pack("!B", self.version)) |
| 1510 | packed.append(struct.pack("!B", self.type)) |
| 1511 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1512 | packed.append(struct.pack("!L", self.xid)) |
| 1513 | packed.append(struct.pack("!L", self.experimenter)) |
| 1514 | packed.append(struct.pack("!L", self.subtype)) |
| 1515 | packed.append(struct.pack("!L", self.enable)) |
| 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): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1522 | obj = bsn_bw_enable_set_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1523 | _version = reader.read("!B")[0] |
| 1524 | assert(_version == 3) |
| 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 |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1529 | reader = orig_reader.slice(_length, 4) |
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] |
| 1534 | assert(_subtype == 18) |
| 1535 | obj.enable = reader.read("!L")[0] |
| 1536 | return obj |
| 1537 | |
| 1538 | def __eq__(self, other): |
| 1539 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1540 | if self.xid != other.xid: return False |
| 1541 | if self.enable != other.enable: return False |
| 1542 | return True |
| 1543 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1544 | def pretty_print(self, q): |
| 1545 | q.text("bsn_bw_enable_set_request {") |
| 1546 | with q.group(): |
| 1547 | with q.indent(2): |
| 1548 | q.breakable() |
| 1549 | q.text("xid = "); |
| 1550 | if self.xid != None: |
| 1551 | q.text("%#x" % self.xid) |
| 1552 | else: |
| 1553 | q.text('None') |
| 1554 | q.text(","); q.breakable() |
| 1555 | q.text("enable = "); |
| 1556 | q.text("%#x" % self.enable) |
| 1557 | q.breakable() |
| 1558 | q.text('}') |
| 1559 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1560 | bsn_header.subtypes[18] = bsn_bw_enable_set_request |
| 1561 | |
| 1562 | class bsn_get_interfaces_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1563 | version = 3 |
| 1564 | type = 4 |
| 1565 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1566 | subtype = 10 |
| 1567 | |
| 1568 | def __init__(self, xid=None, interfaces=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1569 | if xid != None: |
| 1570 | self.xid = xid |
| 1571 | else: |
| 1572 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1573 | if interfaces != None: |
| 1574 | self.interfaces = interfaces |
| 1575 | else: |
| 1576 | self.interfaces = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1577 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1578 | |
| 1579 | def pack(self): |
| 1580 | packed = [] |
| 1581 | packed.append(struct.pack("!B", self.version)) |
| 1582 | packed.append(struct.pack("!B", self.type)) |
| 1583 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1584 | packed.append(struct.pack("!L", self.xid)) |
| 1585 | packed.append(struct.pack("!L", self.experimenter)) |
| 1586 | packed.append(struct.pack("!L", self.subtype)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1587 | packed.append(loxi.generic_util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1588 | length = sum([len(x) for x in packed]) |
| 1589 | packed[2] = struct.pack("!H", length) |
| 1590 | return ''.join(packed) |
| 1591 | |
| 1592 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1593 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1594 | obj = bsn_get_interfaces_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1595 | _version = reader.read("!B")[0] |
| 1596 | assert(_version == 3) |
| 1597 | _type = reader.read("!B")[0] |
| 1598 | assert(_type == 4) |
| 1599 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1600 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1601 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1602 | obj.xid = reader.read("!L")[0] |
| 1603 | _experimenter = reader.read("!L")[0] |
| 1604 | assert(_experimenter == 6035143) |
| 1605 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1606 | assert(_subtype == 10) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 1607 | obj.interfaces = loxi.generic_util.unpack_list(reader, ofp.common.bsn_interface.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1608 | return obj |
| 1609 | |
| 1610 | def __eq__(self, other): |
| 1611 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1612 | if self.xid != other.xid: return False |
| 1613 | if self.interfaces != other.interfaces: return False |
| 1614 | return True |
| 1615 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1616 | def pretty_print(self, q): |
| 1617 | q.text("bsn_get_interfaces_reply {") |
| 1618 | with q.group(): |
| 1619 | with q.indent(2): |
| 1620 | q.breakable() |
| 1621 | q.text("xid = "); |
| 1622 | if self.xid != None: |
| 1623 | q.text("%#x" % self.xid) |
| 1624 | else: |
| 1625 | q.text('None') |
| 1626 | q.text(","); q.breakable() |
| 1627 | q.text("interfaces = "); |
| 1628 | q.pp(self.interfaces) |
| 1629 | q.breakable() |
| 1630 | q.text('}') |
| 1631 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1632 | bsn_header.subtypes[10] = bsn_get_interfaces_reply |
| 1633 | |
| 1634 | class bsn_get_interfaces_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1635 | version = 3 |
| 1636 | type = 4 |
| 1637 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1638 | subtype = 9 |
| 1639 | |
| 1640 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1641 | if xid != None: |
| 1642 | self.xid = xid |
| 1643 | else: |
| 1644 | self.xid = None |
| 1645 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1646 | |
| 1647 | def pack(self): |
| 1648 | packed = [] |
| 1649 | packed.append(struct.pack("!B", self.version)) |
| 1650 | packed.append(struct.pack("!B", self.type)) |
| 1651 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1652 | packed.append(struct.pack("!L", self.xid)) |
| 1653 | packed.append(struct.pack("!L", self.experimenter)) |
| 1654 | packed.append(struct.pack("!L", self.subtype)) |
| 1655 | length = sum([len(x) for x in packed]) |
| 1656 | packed[2] = struct.pack("!H", length) |
| 1657 | return ''.join(packed) |
| 1658 | |
| 1659 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1660 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1661 | obj = bsn_get_interfaces_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1662 | _version = reader.read("!B")[0] |
| 1663 | assert(_version == 3) |
| 1664 | _type = reader.read("!B")[0] |
| 1665 | assert(_type == 4) |
| 1666 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1667 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1668 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1669 | obj.xid = reader.read("!L")[0] |
| 1670 | _experimenter = reader.read("!L")[0] |
| 1671 | assert(_experimenter == 6035143) |
| 1672 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1673 | assert(_subtype == 9) |
| 1674 | return obj |
| 1675 | |
| 1676 | def __eq__(self, other): |
| 1677 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1678 | if self.xid != other.xid: return False |
| 1679 | return True |
| 1680 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1681 | def pretty_print(self, q): |
| 1682 | q.text("bsn_get_interfaces_request {") |
| 1683 | with q.group(): |
| 1684 | with q.indent(2): |
| 1685 | q.breakable() |
| 1686 | q.text("xid = "); |
| 1687 | if self.xid != None: |
| 1688 | q.text("%#x" % self.xid) |
| 1689 | else: |
| 1690 | q.text('None') |
| 1691 | q.breakable() |
| 1692 | q.text('}') |
| 1693 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1694 | bsn_header.subtypes[9] = bsn_get_interfaces_request |
| 1695 | |
| 1696 | class bsn_get_mirroring_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1697 | version = 3 |
| 1698 | type = 4 |
| 1699 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1700 | subtype = 5 |
| 1701 | |
| 1702 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1703 | if xid != None: |
| 1704 | self.xid = xid |
| 1705 | else: |
| 1706 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1707 | if report_mirror_ports != None: |
| 1708 | self.report_mirror_ports = report_mirror_ports |
| 1709 | else: |
| 1710 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1711 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1712 | |
| 1713 | def pack(self): |
| 1714 | packed = [] |
| 1715 | packed.append(struct.pack("!B", self.version)) |
| 1716 | packed.append(struct.pack("!B", self.type)) |
| 1717 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1718 | packed.append(struct.pack("!L", self.xid)) |
| 1719 | packed.append(struct.pack("!L", self.experimenter)) |
| 1720 | packed.append(struct.pack("!L", self.subtype)) |
| 1721 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1722 | packed.append('\x00' * 3) |
| 1723 | length = sum([len(x) for x in packed]) |
| 1724 | packed[2] = struct.pack("!H", length) |
| 1725 | return ''.join(packed) |
| 1726 | |
| 1727 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1728 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1729 | obj = bsn_get_mirroring_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1730 | _version = reader.read("!B")[0] |
| 1731 | assert(_version == 3) |
| 1732 | _type = reader.read("!B")[0] |
| 1733 | assert(_type == 4) |
| 1734 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1735 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1736 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1737 | obj.xid = reader.read("!L")[0] |
| 1738 | _experimenter = reader.read("!L")[0] |
| 1739 | assert(_experimenter == 6035143) |
| 1740 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1741 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1742 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1743 | reader.skip(3) |
| 1744 | return obj |
| 1745 | |
| 1746 | def __eq__(self, other): |
| 1747 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1748 | if self.xid != other.xid: return False |
| 1749 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1750 | return True |
| 1751 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1752 | def pretty_print(self, q): |
| 1753 | q.text("bsn_get_mirroring_reply {") |
| 1754 | with q.group(): |
| 1755 | with q.indent(2): |
| 1756 | q.breakable() |
| 1757 | q.text("xid = "); |
| 1758 | if self.xid != None: |
| 1759 | q.text("%#x" % self.xid) |
| 1760 | else: |
| 1761 | q.text('None') |
| 1762 | q.text(","); q.breakable() |
| 1763 | q.text("report_mirror_ports = "); |
| 1764 | q.text("%#x" % self.report_mirror_ports) |
| 1765 | q.breakable() |
| 1766 | q.text('}') |
| 1767 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1768 | bsn_header.subtypes[5] = bsn_get_mirroring_reply |
| 1769 | |
| 1770 | class bsn_get_mirroring_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1771 | version = 3 |
| 1772 | type = 4 |
| 1773 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1774 | subtype = 4 |
| 1775 | |
| 1776 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1777 | if xid != None: |
| 1778 | self.xid = xid |
| 1779 | else: |
| 1780 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1781 | if report_mirror_ports != None: |
| 1782 | self.report_mirror_ports = report_mirror_ports |
| 1783 | else: |
| 1784 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1785 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1786 | |
| 1787 | def pack(self): |
| 1788 | packed = [] |
| 1789 | packed.append(struct.pack("!B", self.version)) |
| 1790 | packed.append(struct.pack("!B", self.type)) |
| 1791 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1792 | packed.append(struct.pack("!L", self.xid)) |
| 1793 | packed.append(struct.pack("!L", self.experimenter)) |
| 1794 | packed.append(struct.pack("!L", self.subtype)) |
| 1795 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1796 | packed.append('\x00' * 3) |
| 1797 | length = sum([len(x) for x in packed]) |
| 1798 | packed[2] = struct.pack("!H", length) |
| 1799 | return ''.join(packed) |
| 1800 | |
| 1801 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1802 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1803 | obj = bsn_get_mirroring_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1804 | _version = reader.read("!B")[0] |
| 1805 | assert(_version == 3) |
| 1806 | _type = reader.read("!B")[0] |
| 1807 | assert(_type == 4) |
| 1808 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1809 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1810 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1811 | obj.xid = reader.read("!L")[0] |
| 1812 | _experimenter = reader.read("!L")[0] |
| 1813 | assert(_experimenter == 6035143) |
| 1814 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1815 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1816 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1817 | reader.skip(3) |
| 1818 | return obj |
| 1819 | |
| 1820 | def __eq__(self, other): |
| 1821 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1822 | if self.xid != other.xid: return False |
| 1823 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1824 | return True |
| 1825 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1826 | def pretty_print(self, q): |
| 1827 | q.text("bsn_get_mirroring_request {") |
| 1828 | with q.group(): |
| 1829 | with q.indent(2): |
| 1830 | q.breakable() |
| 1831 | q.text("xid = "); |
| 1832 | if self.xid != None: |
| 1833 | q.text("%#x" % self.xid) |
| 1834 | else: |
| 1835 | q.text('None') |
| 1836 | q.text(","); q.breakable() |
| 1837 | q.text("report_mirror_ports = "); |
| 1838 | q.text("%#x" % self.report_mirror_ports) |
| 1839 | q.breakable() |
| 1840 | q.text('}') |
| 1841 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1842 | bsn_header.subtypes[4] = bsn_get_mirroring_request |
| 1843 | |
| 1844 | class bsn_pdu_rx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1845 | version = 3 |
| 1846 | type = 4 |
| 1847 | experimenter = 6035143 |
| 1848 | subtype = 34 |
| 1849 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1850 | 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] | 1851 | if xid != None: |
| 1852 | self.xid = xid |
| 1853 | else: |
| 1854 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1855 | if status != None: |
| 1856 | self.status = status |
| 1857 | else: |
| 1858 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1859 | if port_no != None: |
| 1860 | self.port_no = port_no |
| 1861 | else: |
| 1862 | self.port_no = 0 |
| 1863 | if slot_num != None: |
| 1864 | self.slot_num = slot_num |
| 1865 | else: |
| 1866 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1867 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1868 | |
| 1869 | def pack(self): |
| 1870 | packed = [] |
| 1871 | packed.append(struct.pack("!B", self.version)) |
| 1872 | packed.append(struct.pack("!B", self.type)) |
| 1873 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1874 | packed.append(struct.pack("!L", self.xid)) |
| 1875 | packed.append(struct.pack("!L", self.experimenter)) |
| 1876 | packed.append(struct.pack("!L", self.subtype)) |
| 1877 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1878 | packed.append(util.pack_port_no(self.port_no)) |
| 1879 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1880 | length = sum([len(x) for x in packed]) |
| 1881 | packed[2] = struct.pack("!H", length) |
| 1882 | return ''.join(packed) |
| 1883 | |
| 1884 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1885 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1886 | obj = bsn_pdu_rx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1887 | _version = reader.read("!B")[0] |
| 1888 | assert(_version == 3) |
| 1889 | _type = reader.read("!B")[0] |
| 1890 | assert(_type == 4) |
| 1891 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1892 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1893 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1894 | obj.xid = reader.read("!L")[0] |
| 1895 | _experimenter = reader.read("!L")[0] |
| 1896 | assert(_experimenter == 6035143) |
| 1897 | _subtype = reader.read("!L")[0] |
| 1898 | assert(_subtype == 34) |
| 1899 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1900 | obj.port_no = util.unpack_port_no(reader) |
| 1901 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1902 | return obj |
| 1903 | |
| 1904 | def __eq__(self, other): |
| 1905 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1906 | if self.xid != other.xid: return False |
| 1907 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1908 | if self.port_no != other.port_no: return False |
| 1909 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1910 | return True |
| 1911 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1912 | def pretty_print(self, q): |
| 1913 | q.text("bsn_pdu_rx_reply {") |
| 1914 | with q.group(): |
| 1915 | with q.indent(2): |
| 1916 | q.breakable() |
| 1917 | q.text("xid = "); |
| 1918 | if self.xid != None: |
| 1919 | q.text("%#x" % self.xid) |
| 1920 | else: |
| 1921 | q.text('None') |
| 1922 | q.text(","); q.breakable() |
| 1923 | q.text("status = "); |
| 1924 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 1925 | q.text(","); q.breakable() |
| 1926 | q.text("port_no = "); |
| 1927 | q.text(util.pretty_port(self.port_no)) |
| 1928 | q.text(","); q.breakable() |
| 1929 | q.text("slot_num = "); |
| 1930 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1931 | q.breakable() |
| 1932 | q.text('}') |
| 1933 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1934 | bsn_header.subtypes[34] = bsn_pdu_rx_reply |
| 1935 | |
| 1936 | class bsn_pdu_rx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1937 | version = 3 |
| 1938 | type = 4 |
| 1939 | experimenter = 6035143 |
| 1940 | subtype = 33 |
| 1941 | |
| 1942 | 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] | 1943 | if xid != None: |
| 1944 | self.xid = xid |
| 1945 | else: |
| 1946 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1947 | if timeout_ms != None: |
| 1948 | self.timeout_ms = timeout_ms |
| 1949 | else: |
| 1950 | self.timeout_ms = 0 |
| 1951 | if port_no != None: |
| 1952 | self.port_no = port_no |
| 1953 | else: |
| 1954 | self.port_no = 0 |
| 1955 | if slot_num != None: |
| 1956 | self.slot_num = slot_num |
| 1957 | else: |
| 1958 | self.slot_num = 0 |
| 1959 | if data != None: |
| 1960 | self.data = data |
| 1961 | else: |
| 1962 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1963 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1964 | |
| 1965 | def pack(self): |
| 1966 | packed = [] |
| 1967 | packed.append(struct.pack("!B", self.version)) |
| 1968 | packed.append(struct.pack("!B", self.type)) |
| 1969 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1970 | packed.append(struct.pack("!L", self.xid)) |
| 1971 | packed.append(struct.pack("!L", self.experimenter)) |
| 1972 | packed.append(struct.pack("!L", self.subtype)) |
| 1973 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 1974 | packed.append(util.pack_port_no(self.port_no)) |
| 1975 | packed.append(struct.pack("!B", self.slot_num)) |
| 1976 | packed.append('\x00' * 3) |
| 1977 | packed.append(self.data) |
| 1978 | length = sum([len(x) for x in packed]) |
| 1979 | packed[2] = struct.pack("!H", length) |
| 1980 | return ''.join(packed) |
| 1981 | |
| 1982 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1983 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1984 | obj = bsn_pdu_rx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1985 | _version = reader.read("!B")[0] |
| 1986 | assert(_version == 3) |
| 1987 | _type = reader.read("!B")[0] |
| 1988 | assert(_type == 4) |
| 1989 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 1990 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 1991 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1992 | obj.xid = reader.read("!L")[0] |
| 1993 | _experimenter = reader.read("!L")[0] |
| 1994 | assert(_experimenter == 6035143) |
| 1995 | _subtype = reader.read("!L")[0] |
| 1996 | assert(_subtype == 33) |
| 1997 | obj.timeout_ms = reader.read("!L")[0] |
| 1998 | obj.port_no = util.unpack_port_no(reader) |
| 1999 | obj.slot_num = reader.read("!B")[0] |
| 2000 | reader.skip(3) |
| 2001 | obj.data = str(reader.read_all()) |
| 2002 | return obj |
| 2003 | |
| 2004 | def __eq__(self, other): |
| 2005 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2006 | if self.xid != other.xid: return False |
| 2007 | if self.timeout_ms != other.timeout_ms: return False |
| 2008 | if self.port_no != other.port_no: return False |
| 2009 | if self.slot_num != other.slot_num: return False |
| 2010 | if self.data != other.data: return False |
| 2011 | return True |
| 2012 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2013 | def pretty_print(self, q): |
| 2014 | q.text("bsn_pdu_rx_request {") |
| 2015 | with q.group(): |
| 2016 | with q.indent(2): |
| 2017 | q.breakable() |
| 2018 | q.text("xid = "); |
| 2019 | if self.xid != None: |
| 2020 | q.text("%#x" % self.xid) |
| 2021 | else: |
| 2022 | q.text('None') |
| 2023 | q.text(","); q.breakable() |
| 2024 | q.text("timeout_ms = "); |
| 2025 | q.text("%#x" % self.timeout_ms) |
| 2026 | q.text(","); q.breakable() |
| 2027 | q.text("port_no = "); |
| 2028 | q.text(util.pretty_port(self.port_no)) |
| 2029 | q.text(","); q.breakable() |
| 2030 | q.text("slot_num = "); |
| 2031 | q.text("%#x" % self.slot_num) |
| 2032 | q.text(","); q.breakable() |
| 2033 | q.text("data = "); |
| 2034 | q.pp(self.data) |
| 2035 | q.breakable() |
| 2036 | q.text('}') |
| 2037 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2038 | bsn_header.subtypes[33] = bsn_pdu_rx_request |
| 2039 | |
| 2040 | class bsn_pdu_rx_timeout(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2041 | version = 3 |
| 2042 | type = 4 |
| 2043 | experimenter = 6035143 |
| 2044 | subtype = 35 |
| 2045 | |
| 2046 | def __init__(self, xid=None, port_no=None, slot_num=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2047 | if xid != None: |
| 2048 | self.xid = xid |
| 2049 | else: |
| 2050 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2051 | if port_no != None: |
| 2052 | self.port_no = port_no |
| 2053 | else: |
| 2054 | self.port_no = 0 |
| 2055 | if slot_num != None: |
| 2056 | self.slot_num = slot_num |
| 2057 | else: |
| 2058 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2059 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2060 | |
| 2061 | def pack(self): |
| 2062 | packed = [] |
| 2063 | packed.append(struct.pack("!B", self.version)) |
| 2064 | packed.append(struct.pack("!B", self.type)) |
| 2065 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2066 | packed.append(struct.pack("!L", self.xid)) |
| 2067 | packed.append(struct.pack("!L", self.experimenter)) |
| 2068 | packed.append(struct.pack("!L", self.subtype)) |
| 2069 | packed.append(util.pack_port_no(self.port_no)) |
| 2070 | packed.append(struct.pack("!B", self.slot_num)) |
| 2071 | length = sum([len(x) for x in packed]) |
| 2072 | packed[2] = struct.pack("!H", length) |
| 2073 | return ''.join(packed) |
| 2074 | |
| 2075 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2076 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2077 | obj = bsn_pdu_rx_timeout() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2078 | _version = reader.read("!B")[0] |
| 2079 | assert(_version == 3) |
| 2080 | _type = reader.read("!B")[0] |
| 2081 | assert(_type == 4) |
| 2082 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2083 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2084 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2085 | obj.xid = reader.read("!L")[0] |
| 2086 | _experimenter = reader.read("!L")[0] |
| 2087 | assert(_experimenter == 6035143) |
| 2088 | _subtype = reader.read("!L")[0] |
| 2089 | assert(_subtype == 35) |
| 2090 | obj.port_no = util.unpack_port_no(reader) |
| 2091 | obj.slot_num = reader.read("!B")[0] |
| 2092 | return obj |
| 2093 | |
| 2094 | def __eq__(self, other): |
| 2095 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2096 | if self.xid != other.xid: return False |
| 2097 | if self.port_no != other.port_no: return False |
| 2098 | if self.slot_num != other.slot_num: return False |
| 2099 | return True |
| 2100 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2101 | def pretty_print(self, q): |
| 2102 | q.text("bsn_pdu_rx_timeout {") |
| 2103 | with q.group(): |
| 2104 | with q.indent(2): |
| 2105 | q.breakable() |
| 2106 | q.text("xid = "); |
| 2107 | if self.xid != None: |
| 2108 | q.text("%#x" % self.xid) |
| 2109 | else: |
| 2110 | q.text('None') |
| 2111 | q.text(","); q.breakable() |
| 2112 | q.text("port_no = "); |
| 2113 | q.text(util.pretty_port(self.port_no)) |
| 2114 | q.text(","); q.breakable() |
| 2115 | q.text("slot_num = "); |
| 2116 | q.text("%#x" % self.slot_num) |
| 2117 | q.breakable() |
| 2118 | q.text('}') |
| 2119 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2120 | bsn_header.subtypes[35] = bsn_pdu_rx_timeout |
| 2121 | |
| 2122 | class bsn_pdu_tx_reply(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2123 | version = 3 |
| 2124 | type = 4 |
| 2125 | experimenter = 6035143 |
| 2126 | subtype = 32 |
| 2127 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2128 | 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] | 2129 | if xid != None: |
| 2130 | self.xid = xid |
| 2131 | else: |
| 2132 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2133 | if status != None: |
| 2134 | self.status = status |
| 2135 | else: |
| 2136 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2137 | if port_no != None: |
| 2138 | self.port_no = port_no |
| 2139 | else: |
| 2140 | self.port_no = 0 |
| 2141 | if slot_num != None: |
| 2142 | self.slot_num = slot_num |
| 2143 | else: |
| 2144 | self.slot_num = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2145 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2146 | |
| 2147 | def pack(self): |
| 2148 | packed = [] |
| 2149 | packed.append(struct.pack("!B", self.version)) |
| 2150 | packed.append(struct.pack("!B", self.type)) |
| 2151 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2152 | packed.append(struct.pack("!L", self.xid)) |
| 2153 | packed.append(struct.pack("!L", self.experimenter)) |
| 2154 | packed.append(struct.pack("!L", self.subtype)) |
| 2155 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2156 | packed.append(util.pack_port_no(self.port_no)) |
| 2157 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2158 | length = sum([len(x) for x in packed]) |
| 2159 | packed[2] = struct.pack("!H", length) |
| 2160 | return ''.join(packed) |
| 2161 | |
| 2162 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2163 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2164 | obj = bsn_pdu_tx_reply() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2165 | _version = reader.read("!B")[0] |
| 2166 | assert(_version == 3) |
| 2167 | _type = reader.read("!B")[0] |
| 2168 | assert(_type == 4) |
| 2169 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2170 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2171 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2172 | obj.xid = reader.read("!L")[0] |
| 2173 | _experimenter = reader.read("!L")[0] |
| 2174 | assert(_experimenter == 6035143) |
| 2175 | _subtype = reader.read("!L")[0] |
| 2176 | assert(_subtype == 32) |
| 2177 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2178 | obj.port_no = util.unpack_port_no(reader) |
| 2179 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2180 | return obj |
| 2181 | |
| 2182 | def __eq__(self, other): |
| 2183 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2184 | if self.xid != other.xid: return False |
| 2185 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2186 | if self.port_no != other.port_no: return False |
| 2187 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2188 | return True |
| 2189 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2190 | def pretty_print(self, q): |
| 2191 | q.text("bsn_pdu_tx_reply {") |
| 2192 | with q.group(): |
| 2193 | with q.indent(2): |
| 2194 | q.breakable() |
| 2195 | q.text("xid = "); |
| 2196 | if self.xid != None: |
| 2197 | q.text("%#x" % self.xid) |
| 2198 | else: |
| 2199 | q.text('None') |
| 2200 | q.text(","); q.breakable() |
| 2201 | q.text("status = "); |
| 2202 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2203 | q.text(","); q.breakable() |
| 2204 | q.text("port_no = "); |
| 2205 | q.text(util.pretty_port(self.port_no)) |
| 2206 | q.text(","); q.breakable() |
| 2207 | q.text("slot_num = "); |
| 2208 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2209 | q.breakable() |
| 2210 | q.text('}') |
| 2211 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2212 | bsn_header.subtypes[32] = bsn_pdu_tx_reply |
| 2213 | |
| 2214 | class bsn_pdu_tx_request(bsn_header): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2215 | version = 3 |
| 2216 | type = 4 |
| 2217 | experimenter = 6035143 |
| 2218 | subtype = 31 |
| 2219 | |
| 2220 | 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] | 2221 | if xid != None: |
| 2222 | self.xid = xid |
| 2223 | else: |
| 2224 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2225 | if tx_interval_ms != None: |
| 2226 | self.tx_interval_ms = tx_interval_ms |
| 2227 | else: |
| 2228 | self.tx_interval_ms = 0 |
| 2229 | if port_no != None: |
| 2230 | self.port_no = port_no |
| 2231 | else: |
| 2232 | self.port_no = 0 |
| 2233 | if slot_num != None: |
| 2234 | self.slot_num = slot_num |
| 2235 | else: |
| 2236 | self.slot_num = 0 |
| 2237 | if data != None: |
| 2238 | self.data = data |
| 2239 | else: |
| 2240 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2241 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2242 | |
| 2243 | def pack(self): |
| 2244 | packed = [] |
| 2245 | packed.append(struct.pack("!B", self.version)) |
| 2246 | packed.append(struct.pack("!B", self.type)) |
| 2247 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2248 | packed.append(struct.pack("!L", self.xid)) |
| 2249 | packed.append(struct.pack("!L", self.experimenter)) |
| 2250 | packed.append(struct.pack("!L", self.subtype)) |
| 2251 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 2252 | packed.append(util.pack_port_no(self.port_no)) |
| 2253 | packed.append(struct.pack("!B", self.slot_num)) |
| 2254 | packed.append('\x00' * 3) |
| 2255 | packed.append(self.data) |
| 2256 | length = sum([len(x) for x in packed]) |
| 2257 | packed[2] = struct.pack("!H", length) |
| 2258 | return ''.join(packed) |
| 2259 | |
| 2260 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2261 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2262 | obj = bsn_pdu_tx_request() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2263 | _version = reader.read("!B")[0] |
| 2264 | assert(_version == 3) |
| 2265 | _type = reader.read("!B")[0] |
| 2266 | assert(_type == 4) |
| 2267 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2268 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2269 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2270 | obj.xid = reader.read("!L")[0] |
| 2271 | _experimenter = reader.read("!L")[0] |
| 2272 | assert(_experimenter == 6035143) |
| 2273 | _subtype = reader.read("!L")[0] |
| 2274 | assert(_subtype == 31) |
| 2275 | obj.tx_interval_ms = reader.read("!L")[0] |
| 2276 | obj.port_no = util.unpack_port_no(reader) |
| 2277 | obj.slot_num = reader.read("!B")[0] |
| 2278 | reader.skip(3) |
| 2279 | obj.data = str(reader.read_all()) |
| 2280 | return obj |
| 2281 | |
| 2282 | def __eq__(self, other): |
| 2283 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2284 | if self.xid != other.xid: return False |
| 2285 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 2286 | if self.port_no != other.port_no: return False |
| 2287 | if self.slot_num != other.slot_num: return False |
| 2288 | if self.data != other.data: return False |
| 2289 | return True |
| 2290 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2291 | def pretty_print(self, q): |
| 2292 | q.text("bsn_pdu_tx_request {") |
| 2293 | with q.group(): |
| 2294 | with q.indent(2): |
| 2295 | q.breakable() |
| 2296 | q.text("xid = "); |
| 2297 | if self.xid != None: |
| 2298 | q.text("%#x" % self.xid) |
| 2299 | else: |
| 2300 | q.text('None') |
| 2301 | q.text(","); q.breakable() |
| 2302 | q.text("tx_interval_ms = "); |
| 2303 | q.text("%#x" % self.tx_interval_ms) |
| 2304 | q.text(","); q.breakable() |
| 2305 | q.text("port_no = "); |
| 2306 | q.text(util.pretty_port(self.port_no)) |
| 2307 | q.text(","); q.breakable() |
| 2308 | q.text("slot_num = "); |
| 2309 | q.text("%#x" % self.slot_num) |
| 2310 | q.text(","); q.breakable() |
| 2311 | q.text("data = "); |
| 2312 | q.pp(self.data) |
| 2313 | q.breakable() |
| 2314 | q.text('}') |
| 2315 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2316 | bsn_header.subtypes[31] = bsn_pdu_tx_request |
| 2317 | |
| 2318 | class bsn_set_mirroring(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2319 | version = 3 |
| 2320 | type = 4 |
| 2321 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2322 | subtype = 3 |
| 2323 | |
| 2324 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2325 | if xid != None: |
| 2326 | self.xid = xid |
| 2327 | else: |
| 2328 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2329 | if report_mirror_ports != None: |
| 2330 | self.report_mirror_ports = report_mirror_ports |
| 2331 | else: |
| 2332 | self.report_mirror_ports = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2333 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2334 | |
| 2335 | def pack(self): |
| 2336 | packed = [] |
| 2337 | packed.append(struct.pack("!B", self.version)) |
| 2338 | packed.append(struct.pack("!B", self.type)) |
| 2339 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2340 | packed.append(struct.pack("!L", self.xid)) |
| 2341 | packed.append(struct.pack("!L", self.experimenter)) |
| 2342 | packed.append(struct.pack("!L", self.subtype)) |
| 2343 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2344 | packed.append('\x00' * 3) |
| 2345 | length = sum([len(x) for x in packed]) |
| 2346 | packed[2] = struct.pack("!H", length) |
| 2347 | return ''.join(packed) |
| 2348 | |
| 2349 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2350 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2351 | obj = bsn_set_mirroring() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2352 | _version = reader.read("!B")[0] |
| 2353 | assert(_version == 3) |
| 2354 | _type = reader.read("!B")[0] |
| 2355 | assert(_type == 4) |
| 2356 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2357 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2358 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2359 | obj.xid = reader.read("!L")[0] |
| 2360 | _experimenter = reader.read("!L")[0] |
| 2361 | assert(_experimenter == 6035143) |
| 2362 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2363 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2364 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2365 | reader.skip(3) |
| 2366 | return obj |
| 2367 | |
| 2368 | def __eq__(self, other): |
| 2369 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2370 | if self.xid != other.xid: return False |
| 2371 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2372 | return True |
| 2373 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2374 | def pretty_print(self, q): |
| 2375 | q.text("bsn_set_mirroring {") |
| 2376 | with q.group(): |
| 2377 | with q.indent(2): |
| 2378 | q.breakable() |
| 2379 | q.text("xid = "); |
| 2380 | if self.xid != None: |
| 2381 | q.text("%#x" % self.xid) |
| 2382 | else: |
| 2383 | q.text('None') |
| 2384 | q.text(","); q.breakable() |
| 2385 | q.text("report_mirror_ports = "); |
| 2386 | q.text("%#x" % self.report_mirror_ports) |
| 2387 | q.breakable() |
| 2388 | q.text('}') |
| 2389 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2390 | bsn_header.subtypes[3] = bsn_set_mirroring |
| 2391 | |
| 2392 | class bsn_set_pktin_suppression_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2393 | version = 3 |
| 2394 | type = 4 |
| 2395 | experimenter = 6035143 |
| 2396 | subtype = 25 |
| 2397 | |
| 2398 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2399 | if xid != None: |
| 2400 | self.xid = xid |
| 2401 | else: |
| 2402 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2403 | if status != None: |
| 2404 | self.status = status |
| 2405 | else: |
| 2406 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2407 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2408 | |
| 2409 | def pack(self): |
| 2410 | packed = [] |
| 2411 | packed.append(struct.pack("!B", self.version)) |
| 2412 | packed.append(struct.pack("!B", self.type)) |
| 2413 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2414 | packed.append(struct.pack("!L", self.xid)) |
| 2415 | packed.append(struct.pack("!L", self.experimenter)) |
| 2416 | packed.append(struct.pack("!L", self.subtype)) |
| 2417 | packed.append(struct.pack("!L", self.status)) |
| 2418 | length = sum([len(x) for x in packed]) |
| 2419 | packed[2] = struct.pack("!H", length) |
| 2420 | return ''.join(packed) |
| 2421 | |
| 2422 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2423 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2424 | obj = bsn_set_pktin_suppression_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2425 | _version = reader.read("!B")[0] |
| 2426 | assert(_version == 3) |
| 2427 | _type = reader.read("!B")[0] |
| 2428 | assert(_type == 4) |
| 2429 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2430 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2431 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2432 | obj.xid = reader.read("!L")[0] |
| 2433 | _experimenter = reader.read("!L")[0] |
| 2434 | assert(_experimenter == 6035143) |
| 2435 | _subtype = reader.read("!L")[0] |
| 2436 | assert(_subtype == 25) |
| 2437 | obj.status = reader.read("!L")[0] |
| 2438 | return obj |
| 2439 | |
| 2440 | def __eq__(self, other): |
| 2441 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2442 | if self.xid != other.xid: return False |
| 2443 | if self.status != other.status: return False |
| 2444 | return True |
| 2445 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2446 | def pretty_print(self, q): |
| 2447 | q.text("bsn_set_pktin_suppression_reply {") |
| 2448 | with q.group(): |
| 2449 | with q.indent(2): |
| 2450 | q.breakable() |
| 2451 | q.text("xid = "); |
| 2452 | if self.xid != None: |
| 2453 | q.text("%#x" % self.xid) |
| 2454 | else: |
| 2455 | q.text('None') |
| 2456 | q.text(","); q.breakable() |
| 2457 | q.text("status = "); |
| 2458 | q.text("%#x" % self.status) |
| 2459 | q.breakable() |
| 2460 | q.text('}') |
| 2461 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2462 | bsn_header.subtypes[25] = bsn_set_pktin_suppression_reply |
| 2463 | |
| 2464 | class bsn_set_pktin_suppression_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2465 | version = 3 |
| 2466 | type = 4 |
| 2467 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2468 | subtype = 11 |
| 2469 | |
| 2470 | 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] | 2471 | if xid != None: |
| 2472 | self.xid = xid |
| 2473 | else: |
| 2474 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2475 | if enabled != None: |
| 2476 | self.enabled = enabled |
| 2477 | else: |
| 2478 | self.enabled = 0 |
| 2479 | if idle_timeout != None: |
| 2480 | self.idle_timeout = idle_timeout |
| 2481 | else: |
| 2482 | self.idle_timeout = 0 |
| 2483 | if hard_timeout != None: |
| 2484 | self.hard_timeout = hard_timeout |
| 2485 | else: |
| 2486 | self.hard_timeout = 0 |
| 2487 | if priority != None: |
| 2488 | self.priority = priority |
| 2489 | else: |
| 2490 | self.priority = 0 |
| 2491 | if cookie != None: |
| 2492 | self.cookie = cookie |
| 2493 | else: |
| 2494 | self.cookie = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2495 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2496 | |
| 2497 | def pack(self): |
| 2498 | packed = [] |
| 2499 | packed.append(struct.pack("!B", self.version)) |
| 2500 | packed.append(struct.pack("!B", self.type)) |
| 2501 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2502 | packed.append(struct.pack("!L", self.xid)) |
| 2503 | packed.append(struct.pack("!L", self.experimenter)) |
| 2504 | packed.append(struct.pack("!L", self.subtype)) |
| 2505 | packed.append(struct.pack("!B", self.enabled)) |
| 2506 | packed.append('\x00' * 1) |
| 2507 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2508 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2509 | packed.append(struct.pack("!H", self.priority)) |
| 2510 | packed.append(struct.pack("!Q", self.cookie)) |
| 2511 | length = sum([len(x) for x in packed]) |
| 2512 | packed[2] = struct.pack("!H", length) |
| 2513 | return ''.join(packed) |
| 2514 | |
| 2515 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2516 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2517 | obj = bsn_set_pktin_suppression_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2518 | _version = reader.read("!B")[0] |
| 2519 | assert(_version == 3) |
| 2520 | _type = reader.read("!B")[0] |
| 2521 | assert(_type == 4) |
| 2522 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2523 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2524 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2525 | obj.xid = reader.read("!L")[0] |
| 2526 | _experimenter = reader.read("!L")[0] |
| 2527 | assert(_experimenter == 6035143) |
| 2528 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2529 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2530 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2531 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2532 | obj.idle_timeout = reader.read("!H")[0] |
| 2533 | obj.hard_timeout = reader.read("!H")[0] |
| 2534 | obj.priority = reader.read("!H")[0] |
| 2535 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2536 | return obj |
| 2537 | |
| 2538 | def __eq__(self, other): |
| 2539 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2540 | if self.xid != other.xid: return False |
| 2541 | if self.enabled != other.enabled: return False |
| 2542 | if self.idle_timeout != other.idle_timeout: return False |
| 2543 | if self.hard_timeout != other.hard_timeout: return False |
| 2544 | if self.priority != other.priority: return False |
| 2545 | if self.cookie != other.cookie: return False |
| 2546 | return True |
| 2547 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2548 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2549 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2550 | with q.group(): |
| 2551 | with q.indent(2): |
| 2552 | q.breakable() |
| 2553 | q.text("xid = "); |
| 2554 | if self.xid != None: |
| 2555 | q.text("%#x" % self.xid) |
| 2556 | else: |
| 2557 | q.text('None') |
| 2558 | q.text(","); q.breakable() |
| 2559 | q.text("enabled = "); |
| 2560 | q.text("%#x" % self.enabled) |
| 2561 | q.text(","); q.breakable() |
| 2562 | q.text("idle_timeout = "); |
| 2563 | q.text("%#x" % self.idle_timeout) |
| 2564 | q.text(","); q.breakable() |
| 2565 | q.text("hard_timeout = "); |
| 2566 | q.text("%#x" % self.hard_timeout) |
| 2567 | q.text(","); q.breakable() |
| 2568 | q.text("priority = "); |
| 2569 | q.text("%#x" % self.priority) |
| 2570 | q.text(","); q.breakable() |
| 2571 | q.text("cookie = "); |
| 2572 | q.text("%#x" % self.cookie) |
| 2573 | q.breakable() |
| 2574 | q.text('}') |
| 2575 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2576 | bsn_header.subtypes[11] = bsn_set_pktin_suppression_request |
| 2577 | |
| 2578 | class experimenter_stats_reply(stats_reply): |
| 2579 | subtypes = {} |
| 2580 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2581 | version = 3 |
| 2582 | type = 19 |
| 2583 | stats_type = 65535 |
| 2584 | |
| 2585 | def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None): |
| 2586 | if xid != None: |
| 2587 | self.xid = xid |
| 2588 | else: |
| 2589 | self.xid = None |
| 2590 | if flags != None: |
| 2591 | self.flags = flags |
| 2592 | else: |
| 2593 | self.flags = 0 |
| 2594 | if experimenter != None: |
| 2595 | self.experimenter = experimenter |
| 2596 | else: |
| 2597 | self.experimenter = 0 |
| 2598 | if subtype != None: |
| 2599 | self.subtype = subtype |
| 2600 | else: |
| 2601 | self.subtype = 0 |
| 2602 | if data != None: |
| 2603 | self.data = data |
| 2604 | else: |
| 2605 | self.data = '' |
| 2606 | return |
| 2607 | |
| 2608 | def pack(self): |
| 2609 | packed = [] |
| 2610 | packed.append(struct.pack("!B", self.version)) |
| 2611 | packed.append(struct.pack("!B", self.type)) |
| 2612 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2613 | packed.append(struct.pack("!L", self.xid)) |
| 2614 | packed.append(struct.pack("!H", self.stats_type)) |
| 2615 | packed.append(struct.pack("!H", self.flags)) |
| 2616 | packed.append('\x00' * 4) |
| 2617 | packed.append(struct.pack("!L", self.experimenter)) |
| 2618 | packed.append(struct.pack("!L", self.subtype)) |
| 2619 | packed.append(self.data) |
| 2620 | length = sum([len(x) for x in packed]) |
| 2621 | packed[2] = struct.pack("!H", length) |
| 2622 | return ''.join(packed) |
| 2623 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2624 | @staticmethod |
| 2625 | def unpack(reader): |
| 2626 | subtype, = reader.peek('!L', 16) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2627 | subclass = experimenter_stats_reply.subtypes.get(subtype) |
| 2628 | if subclass: |
| 2629 | return subclass.unpack(reader) |
| 2630 | |
| 2631 | obj = experimenter_stats_reply() |
| 2632 | _version = reader.read("!B")[0] |
| 2633 | assert(_version == 3) |
| 2634 | _type = reader.read("!B")[0] |
| 2635 | assert(_type == 19) |
| 2636 | _length = reader.read("!H")[0] |
| 2637 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2638 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2639 | obj.xid = reader.read("!L")[0] |
| 2640 | _stats_type = reader.read("!H")[0] |
| 2641 | assert(_stats_type == 65535) |
| 2642 | obj.flags = reader.read("!H")[0] |
| 2643 | reader.skip(4) |
| 2644 | obj.experimenter = reader.read("!L")[0] |
| 2645 | obj.subtype = reader.read("!L")[0] |
| 2646 | obj.data = str(reader.read_all()) |
| 2647 | return obj |
| 2648 | |
| 2649 | def __eq__(self, other): |
| 2650 | if type(self) != type(other): return False |
| 2651 | if self.xid != other.xid: return False |
| 2652 | if self.flags != other.flags: return False |
| 2653 | if self.experimenter != other.experimenter: return False |
| 2654 | if self.subtype != other.subtype: return False |
| 2655 | if self.data != other.data: return False |
| 2656 | return True |
| 2657 | |
| 2658 | def pretty_print(self, q): |
| 2659 | q.text("experimenter_stats_reply {") |
| 2660 | with q.group(): |
| 2661 | with q.indent(2): |
| 2662 | q.breakable() |
| 2663 | q.text("xid = "); |
| 2664 | if self.xid != None: |
| 2665 | q.text("%#x" % self.xid) |
| 2666 | else: |
| 2667 | q.text('None') |
| 2668 | q.text(","); q.breakable() |
| 2669 | q.text("flags = "); |
| 2670 | q.text("%#x" % self.flags) |
| 2671 | q.text(","); q.breakable() |
| 2672 | q.text("subtype = "); |
| 2673 | q.text("%#x" % self.subtype) |
| 2674 | q.text(","); q.breakable() |
| 2675 | q.text("data = "); |
| 2676 | q.pp(self.data) |
| 2677 | q.breakable() |
| 2678 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2679 | |
| 2680 | stats_reply.subtypes[65535] = experimenter_stats_reply |
| 2681 | |
| 2682 | class bsn_stats_reply(experimenter_stats_reply): |
| 2683 | subtypes = {} |
| 2684 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2685 | version = 3 |
| 2686 | type = 19 |
| 2687 | stats_type = 65535 |
| 2688 | experimenter = 6035143 |
| 2689 | |
| 2690 | def __init__(self, xid=None, flags=None, subtype=None): |
| 2691 | if xid != None: |
| 2692 | self.xid = xid |
| 2693 | else: |
| 2694 | self.xid = None |
| 2695 | if flags != None: |
| 2696 | self.flags = flags |
| 2697 | else: |
| 2698 | self.flags = 0 |
| 2699 | if subtype != None: |
| 2700 | self.subtype = subtype |
| 2701 | else: |
| 2702 | self.subtype = 0 |
| 2703 | return |
| 2704 | |
| 2705 | def pack(self): |
| 2706 | packed = [] |
| 2707 | packed.append(struct.pack("!B", self.version)) |
| 2708 | packed.append(struct.pack("!B", self.type)) |
| 2709 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2710 | packed.append(struct.pack("!L", self.xid)) |
| 2711 | packed.append(struct.pack("!H", self.stats_type)) |
| 2712 | packed.append(struct.pack("!H", self.flags)) |
| 2713 | packed.append('\x00' * 4) |
| 2714 | packed.append(struct.pack("!L", self.experimenter)) |
| 2715 | packed.append(struct.pack("!L", self.subtype)) |
| 2716 | length = sum([len(x) for x in packed]) |
| 2717 | packed[2] = struct.pack("!H", length) |
| 2718 | return ''.join(packed) |
| 2719 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2720 | @staticmethod |
| 2721 | def unpack(reader): |
| 2722 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2723 | subclass = bsn_stats_reply.subtypes.get(subtype) |
| 2724 | if subclass: |
| 2725 | return subclass.unpack(reader) |
| 2726 | |
| 2727 | obj = bsn_stats_reply() |
| 2728 | _version = reader.read("!B")[0] |
| 2729 | assert(_version == 3) |
| 2730 | _type = reader.read("!B")[0] |
| 2731 | assert(_type == 19) |
| 2732 | _length = reader.read("!H")[0] |
| 2733 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2734 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2735 | obj.xid = reader.read("!L")[0] |
| 2736 | _stats_type = reader.read("!H")[0] |
| 2737 | assert(_stats_type == 65535) |
| 2738 | obj.flags = reader.read("!H")[0] |
| 2739 | reader.skip(4) |
| 2740 | _experimenter = reader.read("!L")[0] |
| 2741 | assert(_experimenter == 6035143) |
| 2742 | obj.subtype = reader.read("!L")[0] |
| 2743 | return obj |
| 2744 | |
| 2745 | def __eq__(self, other): |
| 2746 | if type(self) != type(other): return False |
| 2747 | if self.xid != other.xid: return False |
| 2748 | if self.flags != other.flags: return False |
| 2749 | if self.subtype != other.subtype: return False |
| 2750 | return True |
| 2751 | |
| 2752 | def pretty_print(self, q): |
| 2753 | q.text("bsn_stats_reply {") |
| 2754 | with q.group(): |
| 2755 | with q.indent(2): |
| 2756 | q.breakable() |
| 2757 | q.text("xid = "); |
| 2758 | if self.xid != None: |
| 2759 | q.text("%#x" % self.xid) |
| 2760 | else: |
| 2761 | q.text('None') |
| 2762 | q.text(","); q.breakable() |
| 2763 | q.text("flags = "); |
| 2764 | q.text("%#x" % self.flags) |
| 2765 | q.breakable() |
| 2766 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2767 | |
| 2768 | experimenter_stats_reply.subtypes[6035143] = bsn_stats_reply |
| 2769 | |
| 2770 | class experimenter_stats_request(stats_request): |
| 2771 | subtypes = {} |
| 2772 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2773 | version = 3 |
| 2774 | type = 18 |
| 2775 | stats_type = 65535 |
| 2776 | |
| 2777 | def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None): |
| 2778 | if xid != None: |
| 2779 | self.xid = xid |
| 2780 | else: |
| 2781 | self.xid = None |
| 2782 | if flags != None: |
| 2783 | self.flags = flags |
| 2784 | else: |
| 2785 | self.flags = 0 |
| 2786 | if experimenter != None: |
| 2787 | self.experimenter = experimenter |
| 2788 | else: |
| 2789 | self.experimenter = 0 |
| 2790 | if subtype != None: |
| 2791 | self.subtype = subtype |
| 2792 | else: |
| 2793 | self.subtype = 0 |
| 2794 | if data != None: |
| 2795 | self.data = data |
| 2796 | else: |
| 2797 | self.data = '' |
| 2798 | return |
| 2799 | |
| 2800 | def pack(self): |
| 2801 | packed = [] |
| 2802 | packed.append(struct.pack("!B", self.version)) |
| 2803 | packed.append(struct.pack("!B", self.type)) |
| 2804 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2805 | packed.append(struct.pack("!L", self.xid)) |
| 2806 | packed.append(struct.pack("!H", self.stats_type)) |
| 2807 | packed.append(struct.pack("!H", self.flags)) |
| 2808 | packed.append('\x00' * 4) |
| 2809 | packed.append(struct.pack("!L", self.experimenter)) |
| 2810 | packed.append(struct.pack("!L", self.subtype)) |
| 2811 | packed.append(self.data) |
| 2812 | length = sum([len(x) for x in packed]) |
| 2813 | packed[2] = struct.pack("!H", length) |
| 2814 | return ''.join(packed) |
| 2815 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2816 | @staticmethod |
| 2817 | def unpack(reader): |
| 2818 | subtype, = reader.peek('!L', 16) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2819 | subclass = experimenter_stats_request.subtypes.get(subtype) |
| 2820 | if subclass: |
| 2821 | return subclass.unpack(reader) |
| 2822 | |
| 2823 | obj = experimenter_stats_request() |
| 2824 | _version = reader.read("!B")[0] |
| 2825 | assert(_version == 3) |
| 2826 | _type = reader.read("!B")[0] |
| 2827 | assert(_type == 18) |
| 2828 | _length = reader.read("!H")[0] |
| 2829 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2830 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2831 | obj.xid = reader.read("!L")[0] |
| 2832 | _stats_type = reader.read("!H")[0] |
| 2833 | assert(_stats_type == 65535) |
| 2834 | obj.flags = reader.read("!H")[0] |
| 2835 | reader.skip(4) |
| 2836 | obj.experimenter = reader.read("!L")[0] |
| 2837 | obj.subtype = reader.read("!L")[0] |
| 2838 | obj.data = str(reader.read_all()) |
| 2839 | return obj |
| 2840 | |
| 2841 | def __eq__(self, other): |
| 2842 | if type(self) != type(other): return False |
| 2843 | if self.xid != other.xid: return False |
| 2844 | if self.flags != other.flags: return False |
| 2845 | if self.experimenter != other.experimenter: return False |
| 2846 | if self.subtype != other.subtype: return False |
| 2847 | if self.data != other.data: return False |
| 2848 | return True |
| 2849 | |
| 2850 | def pretty_print(self, q): |
| 2851 | q.text("experimenter_stats_request {") |
| 2852 | with q.group(): |
| 2853 | with q.indent(2): |
| 2854 | q.breakable() |
| 2855 | q.text("xid = "); |
| 2856 | if self.xid != None: |
| 2857 | q.text("%#x" % self.xid) |
| 2858 | else: |
| 2859 | q.text('None') |
| 2860 | q.text(","); q.breakable() |
| 2861 | q.text("flags = "); |
| 2862 | q.text("%#x" % self.flags) |
| 2863 | q.text(","); q.breakable() |
| 2864 | q.text("subtype = "); |
| 2865 | q.text("%#x" % self.subtype) |
| 2866 | q.text(","); q.breakable() |
| 2867 | q.text("data = "); |
| 2868 | q.pp(self.data) |
| 2869 | q.breakable() |
| 2870 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2871 | |
| 2872 | stats_request.subtypes[65535] = experimenter_stats_request |
| 2873 | |
| 2874 | class bsn_stats_request(experimenter_stats_request): |
| 2875 | subtypes = {} |
| 2876 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2877 | version = 3 |
| 2878 | type = 18 |
| 2879 | stats_type = 65535 |
| 2880 | experimenter = 6035143 |
| 2881 | |
| 2882 | def __init__(self, xid=None, flags=None, subtype=None): |
| 2883 | if xid != None: |
| 2884 | self.xid = xid |
| 2885 | else: |
| 2886 | self.xid = None |
| 2887 | if flags != None: |
| 2888 | self.flags = flags |
| 2889 | else: |
| 2890 | self.flags = 0 |
| 2891 | if subtype != None: |
| 2892 | self.subtype = subtype |
| 2893 | else: |
| 2894 | self.subtype = 0 |
| 2895 | return |
| 2896 | |
| 2897 | def pack(self): |
| 2898 | packed = [] |
| 2899 | packed.append(struct.pack("!B", self.version)) |
| 2900 | packed.append(struct.pack("!B", self.type)) |
| 2901 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2902 | packed.append(struct.pack("!L", self.xid)) |
| 2903 | packed.append(struct.pack("!H", self.stats_type)) |
| 2904 | packed.append(struct.pack("!H", self.flags)) |
| 2905 | packed.append('\x00' * 4) |
| 2906 | packed.append(struct.pack("!L", self.experimenter)) |
| 2907 | packed.append(struct.pack("!L", self.subtype)) |
| 2908 | length = sum([len(x) for x in packed]) |
| 2909 | packed[2] = struct.pack("!H", length) |
| 2910 | return ''.join(packed) |
| 2911 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2912 | @staticmethod |
| 2913 | def unpack(reader): |
| 2914 | subtype, = reader.peek('!L', 20) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2915 | subclass = bsn_stats_request.subtypes.get(subtype) |
| 2916 | if subclass: |
| 2917 | return subclass.unpack(reader) |
| 2918 | |
| 2919 | obj = bsn_stats_request() |
| 2920 | _version = reader.read("!B")[0] |
| 2921 | assert(_version == 3) |
| 2922 | _type = reader.read("!B")[0] |
| 2923 | assert(_type == 18) |
| 2924 | _length = reader.read("!H")[0] |
| 2925 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 2926 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 2927 | obj.xid = reader.read("!L")[0] |
| 2928 | _stats_type = reader.read("!H")[0] |
| 2929 | assert(_stats_type == 65535) |
| 2930 | obj.flags = reader.read("!H")[0] |
| 2931 | reader.skip(4) |
| 2932 | _experimenter = reader.read("!L")[0] |
| 2933 | assert(_experimenter == 6035143) |
| 2934 | obj.subtype = reader.read("!L")[0] |
| 2935 | return obj |
| 2936 | |
| 2937 | def __eq__(self, other): |
| 2938 | if type(self) != type(other): return False |
| 2939 | if self.xid != other.xid: return False |
| 2940 | if self.flags != other.flags: return False |
| 2941 | if self.subtype != other.subtype: return False |
| 2942 | return True |
| 2943 | |
| 2944 | def pretty_print(self, q): |
| 2945 | q.text("bsn_stats_request {") |
| 2946 | with q.group(): |
| 2947 | with q.indent(2): |
| 2948 | q.breakable() |
| 2949 | q.text("xid = "); |
| 2950 | if self.xid != None: |
| 2951 | q.text("%#x" % self.xid) |
| 2952 | else: |
| 2953 | q.text('None') |
| 2954 | q.text(","); q.breakable() |
| 2955 | q.text("flags = "); |
| 2956 | q.text("%#x" % self.flags) |
| 2957 | q.breakable() |
| 2958 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2959 | |
| 2960 | experimenter_stats_request.subtypes[6035143] = bsn_stats_request |
| 2961 | |
| 2962 | class bsn_virtual_port_create_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2963 | version = 3 |
| 2964 | type = 4 |
| 2965 | experimenter = 6035143 |
| 2966 | subtype = 16 |
| 2967 | |
| 2968 | def __init__(self, xid=None, status=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2969 | if xid != None: |
| 2970 | self.xid = xid |
| 2971 | else: |
| 2972 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2973 | if status != None: |
| 2974 | self.status = status |
| 2975 | else: |
| 2976 | self.status = 0 |
| 2977 | if vport_no != None: |
| 2978 | self.vport_no = vport_no |
| 2979 | else: |
| 2980 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2981 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2982 | |
| 2983 | def pack(self): |
| 2984 | packed = [] |
| 2985 | packed.append(struct.pack("!B", self.version)) |
| 2986 | packed.append(struct.pack("!B", self.type)) |
| 2987 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2988 | packed.append(struct.pack("!L", self.xid)) |
| 2989 | packed.append(struct.pack("!L", self.experimenter)) |
| 2990 | packed.append(struct.pack("!L", self.subtype)) |
| 2991 | packed.append(struct.pack("!L", self.status)) |
| 2992 | packed.append(struct.pack("!L", self.vport_no)) |
| 2993 | length = sum([len(x) for x in packed]) |
| 2994 | packed[2] = struct.pack("!H", length) |
| 2995 | return ''.join(packed) |
| 2996 | |
| 2997 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 2998 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2999 | obj = bsn_virtual_port_create_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3000 | _version = reader.read("!B")[0] |
| 3001 | assert(_version == 3) |
| 3002 | _type = reader.read("!B")[0] |
| 3003 | assert(_type == 4) |
| 3004 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3005 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3006 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3007 | obj.xid = reader.read("!L")[0] |
| 3008 | _experimenter = reader.read("!L")[0] |
| 3009 | assert(_experimenter == 6035143) |
| 3010 | _subtype = reader.read("!L")[0] |
| 3011 | assert(_subtype == 16) |
| 3012 | obj.status = reader.read("!L")[0] |
| 3013 | obj.vport_no = reader.read("!L")[0] |
| 3014 | return obj |
| 3015 | |
| 3016 | def __eq__(self, other): |
| 3017 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3018 | if self.xid != other.xid: return False |
| 3019 | if self.status != other.status: return False |
| 3020 | if self.vport_no != other.vport_no: return False |
| 3021 | return True |
| 3022 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3023 | def pretty_print(self, q): |
| 3024 | q.text("bsn_virtual_port_create_reply {") |
| 3025 | with q.group(): |
| 3026 | with q.indent(2): |
| 3027 | q.breakable() |
| 3028 | q.text("xid = "); |
| 3029 | if self.xid != None: |
| 3030 | q.text("%#x" % self.xid) |
| 3031 | else: |
| 3032 | q.text('None') |
| 3033 | q.text(","); q.breakable() |
| 3034 | q.text("status = "); |
| 3035 | q.text("%#x" % self.status) |
| 3036 | q.text(","); q.breakable() |
| 3037 | q.text("vport_no = "); |
| 3038 | q.text("%#x" % self.vport_no) |
| 3039 | q.breakable() |
| 3040 | q.text('}') |
| 3041 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3042 | bsn_header.subtypes[16] = bsn_virtual_port_create_reply |
| 3043 | |
| 3044 | class bsn_virtual_port_create_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3045 | version = 3 |
| 3046 | type = 4 |
| 3047 | experimenter = 6035143 |
| 3048 | subtype = 15 |
| 3049 | |
| 3050 | def __init__(self, xid=None, vport=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3051 | if xid != None: |
| 3052 | self.xid = xid |
| 3053 | else: |
| 3054 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3055 | if vport != None: |
| 3056 | self.vport = vport |
| 3057 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 3058 | self.vport = ofp.bsn_vport() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3059 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3060 | |
| 3061 | def pack(self): |
| 3062 | packed = [] |
| 3063 | packed.append(struct.pack("!B", self.version)) |
| 3064 | packed.append(struct.pack("!B", self.type)) |
| 3065 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3066 | packed.append(struct.pack("!L", self.xid)) |
| 3067 | packed.append(struct.pack("!L", self.experimenter)) |
| 3068 | packed.append(struct.pack("!L", self.subtype)) |
| 3069 | packed.append(self.vport.pack()) |
| 3070 | length = sum([len(x) for x in packed]) |
| 3071 | packed[2] = struct.pack("!H", length) |
| 3072 | return ''.join(packed) |
| 3073 | |
| 3074 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3075 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3076 | obj = bsn_virtual_port_create_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3077 | _version = reader.read("!B")[0] |
| 3078 | assert(_version == 3) |
| 3079 | _type = reader.read("!B")[0] |
| 3080 | assert(_type == 4) |
| 3081 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3082 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3083 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3084 | obj.xid = reader.read("!L")[0] |
| 3085 | _experimenter = reader.read("!L")[0] |
| 3086 | assert(_experimenter == 6035143) |
| 3087 | _subtype = reader.read("!L")[0] |
| 3088 | assert(_subtype == 15) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 3089 | obj.vport = ofp.bsn_vport.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3090 | return obj |
| 3091 | |
| 3092 | def __eq__(self, other): |
| 3093 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3094 | if self.xid != other.xid: return False |
| 3095 | if self.vport != other.vport: return False |
| 3096 | return True |
| 3097 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3098 | def pretty_print(self, q): |
| 3099 | q.text("bsn_virtual_port_create_request {") |
| 3100 | with q.group(): |
| 3101 | with q.indent(2): |
| 3102 | q.breakable() |
| 3103 | q.text("xid = "); |
| 3104 | if self.xid != None: |
| 3105 | q.text("%#x" % self.xid) |
| 3106 | else: |
| 3107 | q.text('None') |
| 3108 | q.text(","); q.breakable() |
| 3109 | q.text("vport = "); |
| 3110 | q.pp(self.vport) |
| 3111 | q.breakable() |
| 3112 | q.text('}') |
| 3113 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3114 | bsn_header.subtypes[15] = bsn_virtual_port_create_request |
| 3115 | |
| 3116 | class bsn_virtual_port_remove_reply(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3117 | version = 3 |
| 3118 | type = 4 |
| 3119 | experimenter = 6035143 |
| 3120 | subtype = 26 |
| 3121 | |
| 3122 | def __init__(self, xid=None, status=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3123 | if xid != None: |
| 3124 | self.xid = xid |
| 3125 | else: |
| 3126 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3127 | if status != None: |
| 3128 | self.status = status |
| 3129 | else: |
| 3130 | self.status = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3131 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3132 | |
| 3133 | def pack(self): |
| 3134 | packed = [] |
| 3135 | packed.append(struct.pack("!B", self.version)) |
| 3136 | packed.append(struct.pack("!B", self.type)) |
| 3137 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3138 | packed.append(struct.pack("!L", self.xid)) |
| 3139 | packed.append(struct.pack("!L", self.experimenter)) |
| 3140 | packed.append(struct.pack("!L", self.subtype)) |
| 3141 | packed.append(struct.pack("!L", self.status)) |
| 3142 | length = sum([len(x) for x in packed]) |
| 3143 | packed[2] = struct.pack("!H", length) |
| 3144 | return ''.join(packed) |
| 3145 | |
| 3146 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3147 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3148 | obj = bsn_virtual_port_remove_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3149 | _version = reader.read("!B")[0] |
| 3150 | assert(_version == 3) |
| 3151 | _type = reader.read("!B")[0] |
| 3152 | assert(_type == 4) |
| 3153 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3154 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3155 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3156 | obj.xid = reader.read("!L")[0] |
| 3157 | _experimenter = reader.read("!L")[0] |
| 3158 | assert(_experimenter == 6035143) |
| 3159 | _subtype = reader.read("!L")[0] |
| 3160 | assert(_subtype == 26) |
| 3161 | obj.status = reader.read("!L")[0] |
| 3162 | return obj |
| 3163 | |
| 3164 | def __eq__(self, other): |
| 3165 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3166 | if self.xid != other.xid: return False |
| 3167 | if self.status != other.status: return False |
| 3168 | return True |
| 3169 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3170 | def pretty_print(self, q): |
| 3171 | q.text("bsn_virtual_port_remove_reply {") |
| 3172 | with q.group(): |
| 3173 | with q.indent(2): |
| 3174 | q.breakable() |
| 3175 | q.text("xid = "); |
| 3176 | if self.xid != None: |
| 3177 | q.text("%#x" % self.xid) |
| 3178 | else: |
| 3179 | q.text('None') |
| 3180 | q.text(","); q.breakable() |
| 3181 | q.text("status = "); |
| 3182 | q.text("%#x" % self.status) |
| 3183 | q.breakable() |
| 3184 | q.text('}') |
| 3185 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3186 | bsn_header.subtypes[26] = bsn_virtual_port_remove_reply |
| 3187 | |
| 3188 | class bsn_virtual_port_remove_request(bsn_header): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3189 | version = 3 |
| 3190 | type = 4 |
| 3191 | experimenter = 6035143 |
| 3192 | subtype = 17 |
| 3193 | |
| 3194 | def __init__(self, xid=None, vport_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3195 | if xid != None: |
| 3196 | self.xid = xid |
| 3197 | else: |
| 3198 | self.xid = None |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3199 | if vport_no != None: |
| 3200 | self.vport_no = vport_no |
| 3201 | else: |
| 3202 | self.vport_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3203 | return |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3204 | |
| 3205 | def pack(self): |
| 3206 | packed = [] |
| 3207 | packed.append(struct.pack("!B", self.version)) |
| 3208 | packed.append(struct.pack("!B", self.type)) |
| 3209 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3210 | packed.append(struct.pack("!L", self.xid)) |
| 3211 | packed.append(struct.pack("!L", self.experimenter)) |
| 3212 | packed.append(struct.pack("!L", self.subtype)) |
| 3213 | packed.append(struct.pack("!L", self.vport_no)) |
| 3214 | length = sum([len(x) for x in packed]) |
| 3215 | packed[2] = struct.pack("!H", length) |
| 3216 | return ''.join(packed) |
| 3217 | |
| 3218 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3219 | def unpack(reader): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3220 | obj = bsn_virtual_port_remove_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3221 | _version = reader.read("!B")[0] |
| 3222 | assert(_version == 3) |
| 3223 | _type = reader.read("!B")[0] |
| 3224 | assert(_type == 4) |
| 3225 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3226 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3227 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3228 | obj.xid = reader.read("!L")[0] |
| 3229 | _experimenter = reader.read("!L")[0] |
| 3230 | assert(_experimenter == 6035143) |
| 3231 | _subtype = reader.read("!L")[0] |
| 3232 | assert(_subtype == 17) |
| 3233 | obj.vport_no = reader.read("!L")[0] |
| 3234 | return obj |
| 3235 | |
| 3236 | def __eq__(self, other): |
| 3237 | if type(self) != type(other): return False |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3238 | if self.xid != other.xid: return False |
| 3239 | if self.vport_no != other.vport_no: return False |
| 3240 | return True |
| 3241 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3242 | def pretty_print(self, q): |
| 3243 | q.text("bsn_virtual_port_remove_request {") |
| 3244 | with q.group(): |
| 3245 | with q.indent(2): |
| 3246 | q.breakable() |
| 3247 | q.text("xid = "); |
| 3248 | if self.xid != None: |
| 3249 | q.text("%#x" % self.xid) |
| 3250 | else: |
| 3251 | q.text('None') |
| 3252 | q.text(","); q.breakable() |
| 3253 | q.text("vport_no = "); |
| 3254 | q.text("%#x" % self.vport_no) |
| 3255 | q.breakable() |
| 3256 | q.text('}') |
| 3257 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3258 | bsn_header.subtypes[17] = bsn_virtual_port_remove_request |
| 3259 | |
| 3260 | class desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3261 | version = 3 |
| 3262 | type = 19 |
| 3263 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3264 | |
| 3265 | 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] | 3266 | if xid != None: |
| 3267 | self.xid = xid |
| 3268 | else: |
| 3269 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3270 | if flags != None: |
| 3271 | self.flags = flags |
| 3272 | else: |
| 3273 | self.flags = 0 |
| 3274 | if mfr_desc != None: |
| 3275 | self.mfr_desc = mfr_desc |
| 3276 | else: |
| 3277 | self.mfr_desc = "" |
| 3278 | if hw_desc != None: |
| 3279 | self.hw_desc = hw_desc |
| 3280 | else: |
| 3281 | self.hw_desc = "" |
| 3282 | if sw_desc != None: |
| 3283 | self.sw_desc = sw_desc |
| 3284 | else: |
| 3285 | self.sw_desc = "" |
| 3286 | if serial_num != None: |
| 3287 | self.serial_num = serial_num |
| 3288 | else: |
| 3289 | self.serial_num = "" |
| 3290 | if dp_desc != None: |
| 3291 | self.dp_desc = dp_desc |
| 3292 | else: |
| 3293 | self.dp_desc = "" |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3294 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3295 | |
| 3296 | def pack(self): |
| 3297 | packed = [] |
| 3298 | packed.append(struct.pack("!B", self.version)) |
| 3299 | packed.append(struct.pack("!B", self.type)) |
| 3300 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3301 | packed.append(struct.pack("!L", self.xid)) |
| 3302 | packed.append(struct.pack("!H", self.stats_type)) |
| 3303 | packed.append(struct.pack("!H", self.flags)) |
| 3304 | packed.append('\x00' * 4) |
| 3305 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 3306 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 3307 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 3308 | packed.append(struct.pack("!32s", self.serial_num)) |
| 3309 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 3310 | length = sum([len(x) for x in packed]) |
| 3311 | packed[2] = struct.pack("!H", length) |
| 3312 | return ''.join(packed) |
| 3313 | |
| 3314 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3315 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3316 | obj = desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3317 | _version = reader.read("!B")[0] |
| 3318 | assert(_version == 3) |
| 3319 | _type = reader.read("!B")[0] |
| 3320 | assert(_type == 19) |
| 3321 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3322 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3323 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3324 | obj.xid = reader.read("!L")[0] |
| 3325 | _stats_type = reader.read("!H")[0] |
| 3326 | assert(_stats_type == 0) |
| 3327 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3328 | reader.skip(4) |
| 3329 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3330 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3331 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3332 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 3333 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3334 | return obj |
| 3335 | |
| 3336 | def __eq__(self, other): |
| 3337 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3338 | if self.xid != other.xid: return False |
| 3339 | if self.flags != other.flags: return False |
| 3340 | if self.mfr_desc != other.mfr_desc: return False |
| 3341 | if self.hw_desc != other.hw_desc: return False |
| 3342 | if self.sw_desc != other.sw_desc: return False |
| 3343 | if self.serial_num != other.serial_num: return False |
| 3344 | if self.dp_desc != other.dp_desc: return False |
| 3345 | return True |
| 3346 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3347 | def pretty_print(self, q): |
| 3348 | q.text("desc_stats_reply {") |
| 3349 | with q.group(): |
| 3350 | with q.indent(2): |
| 3351 | q.breakable() |
| 3352 | q.text("xid = "); |
| 3353 | if self.xid != None: |
| 3354 | q.text("%#x" % self.xid) |
| 3355 | else: |
| 3356 | q.text('None') |
| 3357 | q.text(","); q.breakable() |
| 3358 | q.text("flags = "); |
| 3359 | q.text("%#x" % self.flags) |
| 3360 | q.text(","); q.breakable() |
| 3361 | q.text("mfr_desc = "); |
| 3362 | q.pp(self.mfr_desc) |
| 3363 | q.text(","); q.breakable() |
| 3364 | q.text("hw_desc = "); |
| 3365 | q.pp(self.hw_desc) |
| 3366 | q.text(","); q.breakable() |
| 3367 | q.text("sw_desc = "); |
| 3368 | q.pp(self.sw_desc) |
| 3369 | q.text(","); q.breakable() |
| 3370 | q.text("serial_num = "); |
| 3371 | q.pp(self.serial_num) |
| 3372 | q.text(","); q.breakable() |
| 3373 | q.text("dp_desc = "); |
| 3374 | q.pp(self.dp_desc) |
| 3375 | q.breakable() |
| 3376 | q.text('}') |
| 3377 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3378 | stats_reply.subtypes[0] = desc_stats_reply |
| 3379 | |
| 3380 | class desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3381 | version = 3 |
| 3382 | type = 18 |
| 3383 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3384 | |
| 3385 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3386 | if xid != None: |
| 3387 | self.xid = xid |
| 3388 | else: |
| 3389 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3390 | if flags != None: |
| 3391 | self.flags = flags |
| 3392 | else: |
| 3393 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3394 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3395 | |
| 3396 | def pack(self): |
| 3397 | packed = [] |
| 3398 | packed.append(struct.pack("!B", self.version)) |
| 3399 | packed.append(struct.pack("!B", self.type)) |
| 3400 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3401 | packed.append(struct.pack("!L", self.xid)) |
| 3402 | packed.append(struct.pack("!H", self.stats_type)) |
| 3403 | packed.append(struct.pack("!H", self.flags)) |
| 3404 | packed.append('\x00' * 4) |
| 3405 | length = sum([len(x) for x in packed]) |
| 3406 | packed[2] = struct.pack("!H", length) |
| 3407 | return ''.join(packed) |
| 3408 | |
| 3409 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3410 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3411 | obj = desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3412 | _version = reader.read("!B")[0] |
| 3413 | assert(_version == 3) |
| 3414 | _type = reader.read("!B")[0] |
| 3415 | assert(_type == 18) |
| 3416 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3417 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3418 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3419 | obj.xid = reader.read("!L")[0] |
| 3420 | _stats_type = reader.read("!H")[0] |
| 3421 | assert(_stats_type == 0) |
| 3422 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3423 | reader.skip(4) |
| 3424 | return obj |
| 3425 | |
| 3426 | def __eq__(self, other): |
| 3427 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3428 | if self.xid != other.xid: return False |
| 3429 | if self.flags != other.flags: return False |
| 3430 | return True |
| 3431 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3432 | def pretty_print(self, q): |
| 3433 | q.text("desc_stats_request {") |
| 3434 | with q.group(): |
| 3435 | with q.indent(2): |
| 3436 | q.breakable() |
| 3437 | q.text("xid = "); |
| 3438 | if self.xid != None: |
| 3439 | q.text("%#x" % self.xid) |
| 3440 | else: |
| 3441 | q.text('None') |
| 3442 | q.text(","); q.breakable() |
| 3443 | q.text("flags = "); |
| 3444 | q.text("%#x" % self.flags) |
| 3445 | q.breakable() |
| 3446 | q.text('}') |
| 3447 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3448 | stats_request.subtypes[0] = desc_stats_request |
| 3449 | |
| 3450 | class echo_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3451 | version = 3 |
| 3452 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3453 | |
| 3454 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3455 | if xid != None: |
| 3456 | self.xid = xid |
| 3457 | else: |
| 3458 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3459 | if data != None: |
| 3460 | self.data = data |
| 3461 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3462 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3463 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3464 | |
| 3465 | def pack(self): |
| 3466 | packed = [] |
| 3467 | packed.append(struct.pack("!B", self.version)) |
| 3468 | packed.append(struct.pack("!B", self.type)) |
| 3469 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3470 | packed.append(struct.pack("!L", self.xid)) |
| 3471 | packed.append(self.data) |
| 3472 | length = sum([len(x) for x in packed]) |
| 3473 | packed[2] = struct.pack("!H", length) |
| 3474 | return ''.join(packed) |
| 3475 | |
| 3476 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3477 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3478 | obj = echo_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3479 | _version = reader.read("!B")[0] |
| 3480 | assert(_version == 3) |
| 3481 | _type = reader.read("!B")[0] |
| 3482 | assert(_type == 3) |
| 3483 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3484 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3485 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3486 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3487 | obj.data = str(reader.read_all()) |
| 3488 | return obj |
| 3489 | |
| 3490 | def __eq__(self, other): |
| 3491 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3492 | if self.xid != other.xid: return False |
| 3493 | if self.data != other.data: return False |
| 3494 | return True |
| 3495 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3496 | def pretty_print(self, q): |
| 3497 | q.text("echo_reply {") |
| 3498 | with q.group(): |
| 3499 | with q.indent(2): |
| 3500 | q.breakable() |
| 3501 | q.text("xid = "); |
| 3502 | if self.xid != None: |
| 3503 | q.text("%#x" % self.xid) |
| 3504 | else: |
| 3505 | q.text('None') |
| 3506 | q.text(","); q.breakable() |
| 3507 | q.text("data = "); |
| 3508 | q.pp(self.data) |
| 3509 | q.breakable() |
| 3510 | q.text('}') |
| 3511 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3512 | message.subtypes[3] = echo_reply |
| 3513 | |
| 3514 | class echo_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3515 | version = 3 |
| 3516 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3517 | |
| 3518 | def __init__(self, xid=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3519 | if xid != None: |
| 3520 | self.xid = xid |
| 3521 | else: |
| 3522 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3523 | if data != None: |
| 3524 | self.data = data |
| 3525 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3526 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3527 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3528 | |
| 3529 | def pack(self): |
| 3530 | packed = [] |
| 3531 | packed.append(struct.pack("!B", self.version)) |
| 3532 | packed.append(struct.pack("!B", self.type)) |
| 3533 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3534 | packed.append(struct.pack("!L", self.xid)) |
| 3535 | packed.append(self.data) |
| 3536 | length = sum([len(x) for x in packed]) |
| 3537 | packed[2] = struct.pack("!H", length) |
| 3538 | return ''.join(packed) |
| 3539 | |
| 3540 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3541 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3542 | obj = echo_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3543 | _version = reader.read("!B")[0] |
| 3544 | assert(_version == 3) |
| 3545 | _type = reader.read("!B")[0] |
| 3546 | assert(_type == 2) |
| 3547 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3548 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3549 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3550 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3551 | obj.data = str(reader.read_all()) |
| 3552 | return obj |
| 3553 | |
| 3554 | def __eq__(self, other): |
| 3555 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3556 | if self.xid != other.xid: return False |
| 3557 | if self.data != other.data: return False |
| 3558 | return True |
| 3559 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3560 | def pretty_print(self, q): |
| 3561 | q.text("echo_request {") |
| 3562 | with q.group(): |
| 3563 | with q.indent(2): |
| 3564 | q.breakable() |
| 3565 | q.text("xid = "); |
| 3566 | if self.xid != None: |
| 3567 | q.text("%#x" % self.xid) |
| 3568 | else: |
| 3569 | q.text('None') |
| 3570 | q.text(","); q.breakable() |
| 3571 | q.text("data = "); |
| 3572 | q.pp(self.data) |
| 3573 | q.breakable() |
| 3574 | q.text('}') |
| 3575 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3576 | message.subtypes[2] = echo_request |
| 3577 | |
| 3578 | class experimenter_error_msg(error_msg): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3579 | version = 3 |
| 3580 | type = 1 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3581 | err_type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3582 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3583 | def __init__(self, xid=None, subtype=None, experimenter=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3584 | if xid != None: |
| 3585 | self.xid = xid |
| 3586 | else: |
| 3587 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3588 | if subtype != None: |
| 3589 | self.subtype = subtype |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3590 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3591 | self.subtype = 0 |
| 3592 | if experimenter != None: |
| 3593 | self.experimenter = experimenter |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3594 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3595 | self.experimenter = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3596 | if data != None: |
| 3597 | self.data = data |
| 3598 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3599 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3600 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3601 | |
| 3602 | def pack(self): |
| 3603 | packed = [] |
| 3604 | packed.append(struct.pack("!B", self.version)) |
| 3605 | packed.append(struct.pack("!B", self.type)) |
| 3606 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3607 | packed.append(struct.pack("!L", self.xid)) |
| 3608 | packed.append(struct.pack("!H", self.err_type)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3609 | packed.append(struct.pack("!H", self.subtype)) |
| 3610 | packed.append(struct.pack("!L", self.experimenter)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3611 | packed.append(self.data) |
| 3612 | length = sum([len(x) for x in packed]) |
| 3613 | packed[2] = struct.pack("!H", length) |
| 3614 | return ''.join(packed) |
| 3615 | |
| 3616 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3617 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3618 | obj = experimenter_error_msg() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3619 | _version = reader.read("!B")[0] |
| 3620 | assert(_version == 3) |
| 3621 | _type = reader.read("!B")[0] |
| 3622 | assert(_type == 1) |
| 3623 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3624 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3625 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3626 | obj.xid = reader.read("!L")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3627 | _err_type = reader.read("!H")[0] |
| 3628 | assert(_err_type == 65535) |
| 3629 | obj.subtype = reader.read("!H")[0] |
| 3630 | obj.experimenter = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3631 | obj.data = str(reader.read_all()) |
| 3632 | return obj |
| 3633 | |
| 3634 | def __eq__(self, other): |
| 3635 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3636 | if self.xid != other.xid: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3637 | if self.subtype != other.subtype: return False |
| 3638 | if self.experimenter != other.experimenter: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3639 | if self.data != other.data: return False |
| 3640 | return True |
| 3641 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3642 | def pretty_print(self, q): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3643 | q.text("experimenter_error_msg {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3644 | with q.group(): |
| 3645 | with q.indent(2): |
| 3646 | q.breakable() |
| 3647 | q.text("xid = "); |
| 3648 | if self.xid != None: |
| 3649 | q.text("%#x" % self.xid) |
| 3650 | else: |
| 3651 | q.text('None') |
| 3652 | q.text(","); q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3653 | q.text("subtype = "); |
| 3654 | q.text("%#x" % self.subtype) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3655 | q.text(","); q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3656 | q.text("experimenter = "); |
| 3657 | q.text("%#x" % self.experimenter) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3658 | q.text(","); q.breakable() |
| 3659 | q.text("data = "); |
| 3660 | q.pp(self.data) |
| 3661 | q.breakable() |
| 3662 | q.text('}') |
| 3663 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3664 | error_msg.subtypes[65535] = experimenter_error_msg |
| 3665 | |
| 3666 | class features_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3667 | version = 3 |
| 3668 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3669 | |
| 3670 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3671 | if xid != None: |
| 3672 | self.xid = xid |
| 3673 | else: |
| 3674 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3675 | if datapath_id != None: |
| 3676 | self.datapath_id = datapath_id |
| 3677 | else: |
| 3678 | self.datapath_id = 0 |
| 3679 | if n_buffers != None: |
| 3680 | self.n_buffers = n_buffers |
| 3681 | else: |
| 3682 | self.n_buffers = 0 |
| 3683 | if n_tables != None: |
| 3684 | self.n_tables = n_tables |
| 3685 | else: |
| 3686 | self.n_tables = 0 |
| 3687 | if capabilities != None: |
| 3688 | self.capabilities = capabilities |
| 3689 | else: |
| 3690 | self.capabilities = 0 |
| 3691 | if reserved != None: |
| 3692 | self.reserved = reserved |
| 3693 | else: |
| 3694 | self.reserved = 0 |
| 3695 | if ports != None: |
| 3696 | self.ports = ports |
| 3697 | else: |
| 3698 | self.ports = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3699 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3700 | |
| 3701 | def pack(self): |
| 3702 | packed = [] |
| 3703 | packed.append(struct.pack("!B", self.version)) |
| 3704 | packed.append(struct.pack("!B", self.type)) |
| 3705 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3706 | packed.append(struct.pack("!L", self.xid)) |
| 3707 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 3708 | packed.append(struct.pack("!L", self.n_buffers)) |
| 3709 | packed.append(struct.pack("!B", self.n_tables)) |
| 3710 | packed.append('\x00' * 3) |
| 3711 | packed.append(struct.pack("!L", self.capabilities)) |
| 3712 | packed.append(struct.pack("!L", self.reserved)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3713 | packed.append(loxi.generic_util.pack_list(self.ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3714 | length = sum([len(x) for x in packed]) |
| 3715 | packed[2] = struct.pack("!H", length) |
| 3716 | return ''.join(packed) |
| 3717 | |
| 3718 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3719 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3720 | obj = features_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3721 | _version = reader.read("!B")[0] |
| 3722 | assert(_version == 3) |
| 3723 | _type = reader.read("!B")[0] |
| 3724 | assert(_type == 6) |
| 3725 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3726 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3727 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3728 | obj.xid = reader.read("!L")[0] |
| 3729 | obj.datapath_id = reader.read("!Q")[0] |
| 3730 | obj.n_buffers = reader.read("!L")[0] |
| 3731 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3732 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3733 | obj.capabilities = reader.read("!L")[0] |
| 3734 | obj.reserved = reader.read("!L")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 3735 | obj.ports = loxi.generic_util.unpack_list(reader, ofp.common.port_desc.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3736 | return obj |
| 3737 | |
| 3738 | def __eq__(self, other): |
| 3739 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3740 | if self.xid != other.xid: return False |
| 3741 | if self.datapath_id != other.datapath_id: return False |
| 3742 | if self.n_buffers != other.n_buffers: return False |
| 3743 | if self.n_tables != other.n_tables: return False |
| 3744 | if self.capabilities != other.capabilities: return False |
| 3745 | if self.reserved != other.reserved: return False |
| 3746 | if self.ports != other.ports: return False |
| 3747 | return True |
| 3748 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3749 | def pretty_print(self, q): |
| 3750 | q.text("features_reply {") |
| 3751 | with q.group(): |
| 3752 | with q.indent(2): |
| 3753 | q.breakable() |
| 3754 | q.text("xid = "); |
| 3755 | if self.xid != None: |
| 3756 | q.text("%#x" % self.xid) |
| 3757 | else: |
| 3758 | q.text('None') |
| 3759 | q.text(","); q.breakable() |
| 3760 | q.text("datapath_id = "); |
| 3761 | q.text("%#x" % self.datapath_id) |
| 3762 | q.text(","); q.breakable() |
| 3763 | q.text("n_buffers = "); |
| 3764 | q.text("%#x" % self.n_buffers) |
| 3765 | q.text(","); q.breakable() |
| 3766 | q.text("n_tables = "); |
| 3767 | q.text("%#x" % self.n_tables) |
| 3768 | q.text(","); q.breakable() |
| 3769 | q.text("capabilities = "); |
| 3770 | q.text("%#x" % self.capabilities) |
| 3771 | q.text(","); q.breakable() |
| 3772 | q.text("reserved = "); |
| 3773 | q.text("%#x" % self.reserved) |
| 3774 | q.text(","); q.breakable() |
| 3775 | q.text("ports = "); |
| 3776 | q.pp(self.ports) |
| 3777 | q.breakable() |
| 3778 | q.text('}') |
| 3779 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3780 | message.subtypes[6] = features_reply |
| 3781 | |
| 3782 | class features_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3783 | version = 3 |
| 3784 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3785 | |
| 3786 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3787 | if xid != None: |
| 3788 | self.xid = xid |
| 3789 | else: |
| 3790 | self.xid = None |
| 3791 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3792 | |
| 3793 | def pack(self): |
| 3794 | packed = [] |
| 3795 | packed.append(struct.pack("!B", self.version)) |
| 3796 | packed.append(struct.pack("!B", self.type)) |
| 3797 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3798 | packed.append(struct.pack("!L", self.xid)) |
| 3799 | length = sum([len(x) for x in packed]) |
| 3800 | packed[2] = struct.pack("!H", length) |
| 3801 | return ''.join(packed) |
| 3802 | |
| 3803 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3804 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3805 | obj = features_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3806 | _version = reader.read("!B")[0] |
| 3807 | assert(_version == 3) |
| 3808 | _type = reader.read("!B")[0] |
| 3809 | assert(_type == 5) |
| 3810 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3811 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3812 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3813 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3814 | return obj |
| 3815 | |
| 3816 | def __eq__(self, other): |
| 3817 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3818 | if self.xid != other.xid: return False |
| 3819 | return True |
| 3820 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3821 | def pretty_print(self, q): |
| 3822 | q.text("features_request {") |
| 3823 | with q.group(): |
| 3824 | with q.indent(2): |
| 3825 | q.breakable() |
| 3826 | q.text("xid = "); |
| 3827 | if self.xid != None: |
| 3828 | q.text("%#x" % self.xid) |
| 3829 | else: |
| 3830 | q.text('None') |
| 3831 | q.breakable() |
| 3832 | q.text('}') |
| 3833 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3834 | message.subtypes[5] = features_request |
| 3835 | |
| 3836 | class flow_mod(message): |
| 3837 | subtypes = {} |
| 3838 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3839 | version = 3 |
| 3840 | type = 14 |
| 3841 | |
| 3842 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, _command=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
| 3843 | if xid != None: |
| 3844 | self.xid = xid |
| 3845 | else: |
| 3846 | self.xid = None |
| 3847 | if cookie != None: |
| 3848 | self.cookie = cookie |
| 3849 | else: |
| 3850 | self.cookie = 0 |
| 3851 | if cookie_mask != None: |
| 3852 | self.cookie_mask = cookie_mask |
| 3853 | else: |
| 3854 | self.cookie_mask = 0 |
| 3855 | if table_id != None: |
| 3856 | self.table_id = table_id |
| 3857 | else: |
| 3858 | self.table_id = 0 |
| 3859 | if _command != None: |
| 3860 | self._command = _command |
| 3861 | else: |
| 3862 | self._command = 0 |
| 3863 | if idle_timeout != None: |
| 3864 | self.idle_timeout = idle_timeout |
| 3865 | else: |
| 3866 | self.idle_timeout = 0 |
| 3867 | if hard_timeout != None: |
| 3868 | self.hard_timeout = hard_timeout |
| 3869 | else: |
| 3870 | self.hard_timeout = 0 |
| 3871 | if priority != None: |
| 3872 | self.priority = priority |
| 3873 | else: |
| 3874 | self.priority = 0 |
| 3875 | if buffer_id != None: |
| 3876 | self.buffer_id = buffer_id |
| 3877 | else: |
| 3878 | self.buffer_id = 0 |
| 3879 | if out_port != None: |
| 3880 | self.out_port = out_port |
| 3881 | else: |
| 3882 | self.out_port = 0 |
| 3883 | if out_group != None: |
| 3884 | self.out_group = out_group |
| 3885 | else: |
| 3886 | self.out_group = 0 |
| 3887 | if flags != None: |
| 3888 | self.flags = flags |
| 3889 | else: |
| 3890 | self.flags = 0 |
| 3891 | if match != None: |
| 3892 | self.match = match |
| 3893 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 3894 | self.match = ofp.match() |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3895 | if instructions != None: |
| 3896 | self.instructions = instructions |
| 3897 | else: |
| 3898 | self.instructions = [] |
| 3899 | return |
| 3900 | |
| 3901 | def pack(self): |
| 3902 | packed = [] |
| 3903 | packed.append(struct.pack("!B", self.version)) |
| 3904 | packed.append(struct.pack("!B", self.type)) |
| 3905 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3906 | packed.append(struct.pack("!L", self.xid)) |
| 3907 | packed.append(struct.pack("!Q", self.cookie)) |
| 3908 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3909 | packed.append(struct.pack("!B", self.table_id)) |
| 3910 | packed.append(util.pack_fm_cmd(self._command)) |
| 3911 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3912 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3913 | packed.append(struct.pack("!H", self.priority)) |
| 3914 | packed.append(struct.pack("!L", self.buffer_id)) |
| 3915 | packed.append(util.pack_port_no(self.out_port)) |
| 3916 | packed.append(struct.pack("!L", self.out_group)) |
| 3917 | packed.append(struct.pack("!H", self.flags)) |
| 3918 | packed.append('\x00' * 2) |
| 3919 | packed.append(self.match.pack()) |
| 3920 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
| 3921 | length = sum([len(x) for x in packed]) |
| 3922 | packed[2] = struct.pack("!H", length) |
| 3923 | return ''.join(packed) |
| 3924 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 3925 | @staticmethod |
| 3926 | def unpack(reader): |
| 3927 | subtype, = reader.peek('B', 25) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3928 | subclass = flow_mod.subtypes.get(subtype) |
| 3929 | if subclass: |
| 3930 | return subclass.unpack(reader) |
| 3931 | |
| 3932 | obj = flow_mod() |
| 3933 | _version = reader.read("!B")[0] |
| 3934 | assert(_version == 3) |
| 3935 | _type = reader.read("!B")[0] |
| 3936 | assert(_type == 14) |
| 3937 | _length = reader.read("!H")[0] |
| 3938 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 3939 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3940 | obj.xid = reader.read("!L")[0] |
| 3941 | obj.cookie = reader.read("!Q")[0] |
| 3942 | obj.cookie_mask = reader.read("!Q")[0] |
| 3943 | obj.table_id = reader.read("!B")[0] |
| 3944 | obj._command = util.unpack_fm_cmd(reader) |
| 3945 | obj.idle_timeout = reader.read("!H")[0] |
| 3946 | obj.hard_timeout = reader.read("!H")[0] |
| 3947 | obj.priority = reader.read("!H")[0] |
| 3948 | obj.buffer_id = reader.read("!L")[0] |
| 3949 | obj.out_port = util.unpack_port_no(reader) |
| 3950 | obj.out_group = reader.read("!L")[0] |
| 3951 | obj.flags = reader.read("!H")[0] |
| 3952 | reader.skip(2) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 3953 | obj.match = ofp.match.unpack(reader) |
| 3954 | obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 3955 | return obj |
| 3956 | |
| 3957 | def __eq__(self, other): |
| 3958 | if type(self) != type(other): return False |
| 3959 | if self.xid != other.xid: return False |
| 3960 | if self.cookie != other.cookie: return False |
| 3961 | if self.cookie_mask != other.cookie_mask: return False |
| 3962 | if self.table_id != other.table_id: return False |
| 3963 | if self._command != other._command: return False |
| 3964 | if self.idle_timeout != other.idle_timeout: return False |
| 3965 | if self.hard_timeout != other.hard_timeout: return False |
| 3966 | if self.priority != other.priority: return False |
| 3967 | if self.buffer_id != other.buffer_id: return False |
| 3968 | if self.out_port != other.out_port: return False |
| 3969 | if self.out_group != other.out_group: return False |
| 3970 | if self.flags != other.flags: return False |
| 3971 | if self.match != other.match: return False |
| 3972 | if self.instructions != other.instructions: return False |
| 3973 | return True |
| 3974 | |
| 3975 | def pretty_print(self, q): |
| 3976 | q.text("flow_mod {") |
| 3977 | with q.group(): |
| 3978 | with q.indent(2): |
| 3979 | q.breakable() |
| 3980 | q.text("xid = "); |
| 3981 | if self.xid != None: |
| 3982 | q.text("%#x" % self.xid) |
| 3983 | else: |
| 3984 | q.text('None') |
| 3985 | q.text(","); q.breakable() |
| 3986 | q.text("cookie = "); |
| 3987 | q.text("%#x" % self.cookie) |
| 3988 | q.text(","); q.breakable() |
| 3989 | q.text("cookie_mask = "); |
| 3990 | q.text("%#x" % self.cookie_mask) |
| 3991 | q.text(","); q.breakable() |
| 3992 | q.text("table_id = "); |
| 3993 | q.text("%#x" % self.table_id) |
| 3994 | q.text(","); q.breakable() |
| 3995 | q.text("idle_timeout = "); |
| 3996 | q.text("%#x" % self.idle_timeout) |
| 3997 | q.text(","); q.breakable() |
| 3998 | q.text("hard_timeout = "); |
| 3999 | q.text("%#x" % self.hard_timeout) |
| 4000 | q.text(","); q.breakable() |
| 4001 | q.text("priority = "); |
| 4002 | q.text("%#x" % self.priority) |
| 4003 | q.text(","); q.breakable() |
| 4004 | q.text("buffer_id = "); |
| 4005 | q.text("%#x" % self.buffer_id) |
| 4006 | q.text(","); q.breakable() |
| 4007 | q.text("out_port = "); |
| 4008 | q.text(util.pretty_port(self.out_port)) |
| 4009 | q.text(","); q.breakable() |
| 4010 | q.text("out_group = "); |
| 4011 | q.text("%#x" % self.out_group) |
| 4012 | q.text(","); q.breakable() |
| 4013 | q.text("flags = "); |
| 4014 | q.text("%#x" % self.flags) |
| 4015 | q.text(","); q.breakable() |
| 4016 | q.text("match = "); |
| 4017 | q.pp(self.match) |
| 4018 | q.text(","); q.breakable() |
| 4019 | q.text("instructions = "); |
| 4020 | q.pp(self.instructions) |
| 4021 | q.breakable() |
| 4022 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4023 | |
| 4024 | message.subtypes[14] = flow_mod |
| 4025 | |
| 4026 | class flow_add(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4027 | version = 3 |
| 4028 | type = 14 |
| 4029 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4030 | |
| 4031 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4032 | if xid != None: |
| 4033 | self.xid = xid |
| 4034 | else: |
| 4035 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4036 | if cookie != None: |
| 4037 | self.cookie = cookie |
| 4038 | else: |
| 4039 | self.cookie = 0 |
| 4040 | if cookie_mask != None: |
| 4041 | self.cookie_mask = cookie_mask |
| 4042 | else: |
| 4043 | self.cookie_mask = 0 |
| 4044 | if table_id != None: |
| 4045 | self.table_id = table_id |
| 4046 | else: |
| 4047 | self.table_id = 0 |
| 4048 | if idle_timeout != None: |
| 4049 | self.idle_timeout = idle_timeout |
| 4050 | else: |
| 4051 | self.idle_timeout = 0 |
| 4052 | if hard_timeout != None: |
| 4053 | self.hard_timeout = hard_timeout |
| 4054 | else: |
| 4055 | self.hard_timeout = 0 |
| 4056 | if priority != None: |
| 4057 | self.priority = priority |
| 4058 | else: |
| 4059 | self.priority = 0 |
| 4060 | if buffer_id != None: |
| 4061 | self.buffer_id = buffer_id |
| 4062 | else: |
| 4063 | self.buffer_id = 0 |
| 4064 | if out_port != None: |
| 4065 | self.out_port = out_port |
| 4066 | else: |
| 4067 | self.out_port = 0 |
| 4068 | if out_group != None: |
| 4069 | self.out_group = out_group |
| 4070 | else: |
| 4071 | self.out_group = 0 |
| 4072 | if flags != None: |
| 4073 | self.flags = flags |
| 4074 | else: |
| 4075 | self.flags = 0 |
| 4076 | if match != None: |
| 4077 | self.match = match |
| 4078 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4079 | self.match = ofp.match() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4080 | if instructions != None: |
| 4081 | self.instructions = instructions |
| 4082 | else: |
| 4083 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4084 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4085 | |
| 4086 | def pack(self): |
| 4087 | packed = [] |
| 4088 | packed.append(struct.pack("!B", self.version)) |
| 4089 | packed.append(struct.pack("!B", self.type)) |
| 4090 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4091 | packed.append(struct.pack("!L", self.xid)) |
| 4092 | packed.append(struct.pack("!Q", self.cookie)) |
| 4093 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4094 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4095 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4096 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4097 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4098 | packed.append(struct.pack("!H", self.priority)) |
| 4099 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4100 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4101 | packed.append(struct.pack("!L", self.out_group)) |
| 4102 | packed.append(struct.pack("!H", self.flags)) |
| 4103 | packed.append('\x00' * 2) |
| 4104 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4105 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4106 | length = sum([len(x) for x in packed]) |
| 4107 | packed[2] = struct.pack("!H", length) |
| 4108 | return ''.join(packed) |
| 4109 | |
| 4110 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4111 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4112 | obj = flow_add() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4113 | _version = reader.read("!B")[0] |
| 4114 | assert(_version == 3) |
| 4115 | _type = reader.read("!B")[0] |
| 4116 | assert(_type == 14) |
| 4117 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4118 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4119 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4120 | obj.xid = reader.read("!L")[0] |
| 4121 | obj.cookie = reader.read("!Q")[0] |
| 4122 | obj.cookie_mask = reader.read("!Q")[0] |
| 4123 | obj.table_id = reader.read("!B")[0] |
| 4124 | __command = util.unpack_fm_cmd(reader) |
| 4125 | assert(__command == 0) |
| 4126 | obj.idle_timeout = reader.read("!H")[0] |
| 4127 | obj.hard_timeout = reader.read("!H")[0] |
| 4128 | obj.priority = reader.read("!H")[0] |
| 4129 | obj.buffer_id = reader.read("!L")[0] |
| 4130 | obj.out_port = util.unpack_port_no(reader) |
| 4131 | obj.out_group = reader.read("!L")[0] |
| 4132 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4133 | reader.skip(2) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4134 | obj.match = ofp.match.unpack(reader) |
| 4135 | obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4136 | return obj |
| 4137 | |
| 4138 | def __eq__(self, other): |
| 4139 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4140 | if self.xid != other.xid: return False |
| 4141 | if self.cookie != other.cookie: return False |
| 4142 | if self.cookie_mask != other.cookie_mask: return False |
| 4143 | if self.table_id != other.table_id: return False |
| 4144 | if self.idle_timeout != other.idle_timeout: return False |
| 4145 | if self.hard_timeout != other.hard_timeout: return False |
| 4146 | if self.priority != other.priority: return False |
| 4147 | if self.buffer_id != other.buffer_id: return False |
| 4148 | if self.out_port != other.out_port: return False |
| 4149 | if self.out_group != other.out_group: return False |
| 4150 | if self.flags != other.flags: return False |
| 4151 | if self.match != other.match: return False |
| 4152 | if self.instructions != other.instructions: return False |
| 4153 | return True |
| 4154 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4155 | def pretty_print(self, q): |
| 4156 | q.text("flow_add {") |
| 4157 | with q.group(): |
| 4158 | with q.indent(2): |
| 4159 | q.breakable() |
| 4160 | q.text("xid = "); |
| 4161 | if self.xid != None: |
| 4162 | q.text("%#x" % self.xid) |
| 4163 | else: |
| 4164 | q.text('None') |
| 4165 | q.text(","); q.breakable() |
| 4166 | q.text("cookie = "); |
| 4167 | q.text("%#x" % self.cookie) |
| 4168 | q.text(","); q.breakable() |
| 4169 | q.text("cookie_mask = "); |
| 4170 | q.text("%#x" % self.cookie_mask) |
| 4171 | q.text(","); q.breakable() |
| 4172 | q.text("table_id = "); |
| 4173 | q.text("%#x" % self.table_id) |
| 4174 | q.text(","); q.breakable() |
| 4175 | q.text("idle_timeout = "); |
| 4176 | q.text("%#x" % self.idle_timeout) |
| 4177 | q.text(","); q.breakable() |
| 4178 | q.text("hard_timeout = "); |
| 4179 | q.text("%#x" % self.hard_timeout) |
| 4180 | q.text(","); q.breakable() |
| 4181 | q.text("priority = "); |
| 4182 | q.text("%#x" % self.priority) |
| 4183 | q.text(","); q.breakable() |
| 4184 | q.text("buffer_id = "); |
| 4185 | q.text("%#x" % self.buffer_id) |
| 4186 | q.text(","); q.breakable() |
| 4187 | q.text("out_port = "); |
| 4188 | q.text(util.pretty_port(self.out_port)) |
| 4189 | q.text(","); q.breakable() |
| 4190 | q.text("out_group = "); |
| 4191 | q.text("%#x" % self.out_group) |
| 4192 | q.text(","); q.breakable() |
| 4193 | q.text("flags = "); |
| 4194 | q.text("%#x" % self.flags) |
| 4195 | q.text(","); q.breakable() |
| 4196 | q.text("match = "); |
| 4197 | q.pp(self.match) |
| 4198 | q.text(","); q.breakable() |
| 4199 | q.text("instructions = "); |
| 4200 | q.pp(self.instructions) |
| 4201 | q.breakable() |
| 4202 | q.text('}') |
| 4203 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4204 | flow_mod.subtypes[0] = flow_add |
| 4205 | |
| 4206 | class flow_delete(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4207 | version = 3 |
| 4208 | type = 14 |
| 4209 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4210 | |
| 4211 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4212 | if xid != None: |
| 4213 | self.xid = xid |
| 4214 | else: |
| 4215 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4216 | if cookie != None: |
| 4217 | self.cookie = cookie |
| 4218 | else: |
| 4219 | self.cookie = 0 |
| 4220 | if cookie_mask != None: |
| 4221 | self.cookie_mask = cookie_mask |
| 4222 | else: |
| 4223 | self.cookie_mask = 0 |
| 4224 | if table_id != None: |
| 4225 | self.table_id = table_id |
| 4226 | else: |
| 4227 | self.table_id = 0 |
| 4228 | if idle_timeout != None: |
| 4229 | self.idle_timeout = idle_timeout |
| 4230 | else: |
| 4231 | self.idle_timeout = 0 |
| 4232 | if hard_timeout != None: |
| 4233 | self.hard_timeout = hard_timeout |
| 4234 | else: |
| 4235 | self.hard_timeout = 0 |
| 4236 | if priority != None: |
| 4237 | self.priority = priority |
| 4238 | else: |
| 4239 | self.priority = 0 |
| 4240 | if buffer_id != None: |
| 4241 | self.buffer_id = buffer_id |
| 4242 | else: |
| 4243 | self.buffer_id = 0 |
| 4244 | if out_port != None: |
| 4245 | self.out_port = out_port |
| 4246 | else: |
| 4247 | self.out_port = 0 |
| 4248 | if out_group != None: |
| 4249 | self.out_group = out_group |
| 4250 | else: |
| 4251 | self.out_group = 0 |
| 4252 | if flags != None: |
| 4253 | self.flags = flags |
| 4254 | else: |
| 4255 | self.flags = 0 |
| 4256 | if match != None: |
| 4257 | self.match = match |
| 4258 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4259 | self.match = ofp.match() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4260 | if instructions != None: |
| 4261 | self.instructions = instructions |
| 4262 | else: |
| 4263 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4264 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4265 | |
| 4266 | def pack(self): |
| 4267 | packed = [] |
| 4268 | packed.append(struct.pack("!B", self.version)) |
| 4269 | packed.append(struct.pack("!B", self.type)) |
| 4270 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4271 | packed.append(struct.pack("!L", self.xid)) |
| 4272 | packed.append(struct.pack("!Q", self.cookie)) |
| 4273 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4274 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4275 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4276 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4277 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4278 | packed.append(struct.pack("!H", self.priority)) |
| 4279 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4280 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4281 | packed.append(struct.pack("!L", self.out_group)) |
| 4282 | packed.append(struct.pack("!H", self.flags)) |
| 4283 | packed.append('\x00' * 2) |
| 4284 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4285 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4286 | length = sum([len(x) for x in packed]) |
| 4287 | packed[2] = struct.pack("!H", length) |
| 4288 | return ''.join(packed) |
| 4289 | |
| 4290 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4291 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4292 | obj = flow_delete() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4293 | _version = reader.read("!B")[0] |
| 4294 | assert(_version == 3) |
| 4295 | _type = reader.read("!B")[0] |
| 4296 | assert(_type == 14) |
| 4297 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4298 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4299 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4300 | obj.xid = reader.read("!L")[0] |
| 4301 | obj.cookie = reader.read("!Q")[0] |
| 4302 | obj.cookie_mask = reader.read("!Q")[0] |
| 4303 | obj.table_id = reader.read("!B")[0] |
| 4304 | __command = util.unpack_fm_cmd(reader) |
| 4305 | assert(__command == 3) |
| 4306 | obj.idle_timeout = reader.read("!H")[0] |
| 4307 | obj.hard_timeout = reader.read("!H")[0] |
| 4308 | obj.priority = reader.read("!H")[0] |
| 4309 | obj.buffer_id = reader.read("!L")[0] |
| 4310 | obj.out_port = util.unpack_port_no(reader) |
| 4311 | obj.out_group = reader.read("!L")[0] |
| 4312 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4313 | reader.skip(2) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4314 | obj.match = ofp.match.unpack(reader) |
| 4315 | obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4316 | return obj |
| 4317 | |
| 4318 | def __eq__(self, other): |
| 4319 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4320 | if self.xid != other.xid: return False |
| 4321 | if self.cookie != other.cookie: return False |
| 4322 | if self.cookie_mask != other.cookie_mask: return False |
| 4323 | if self.table_id != other.table_id: return False |
| 4324 | if self.idle_timeout != other.idle_timeout: return False |
| 4325 | if self.hard_timeout != other.hard_timeout: return False |
| 4326 | if self.priority != other.priority: return False |
| 4327 | if self.buffer_id != other.buffer_id: return False |
| 4328 | if self.out_port != other.out_port: return False |
| 4329 | if self.out_group != other.out_group: return False |
| 4330 | if self.flags != other.flags: return False |
| 4331 | if self.match != other.match: return False |
| 4332 | if self.instructions != other.instructions: return False |
| 4333 | return True |
| 4334 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4335 | def pretty_print(self, q): |
| 4336 | q.text("flow_delete {") |
| 4337 | with q.group(): |
| 4338 | with q.indent(2): |
| 4339 | q.breakable() |
| 4340 | q.text("xid = "); |
| 4341 | if self.xid != None: |
| 4342 | q.text("%#x" % self.xid) |
| 4343 | else: |
| 4344 | q.text('None') |
| 4345 | q.text(","); q.breakable() |
| 4346 | q.text("cookie = "); |
| 4347 | q.text("%#x" % self.cookie) |
| 4348 | q.text(","); q.breakable() |
| 4349 | q.text("cookie_mask = "); |
| 4350 | q.text("%#x" % self.cookie_mask) |
| 4351 | q.text(","); q.breakable() |
| 4352 | q.text("table_id = "); |
| 4353 | q.text("%#x" % self.table_id) |
| 4354 | q.text(","); q.breakable() |
| 4355 | q.text("idle_timeout = "); |
| 4356 | q.text("%#x" % self.idle_timeout) |
| 4357 | q.text(","); q.breakable() |
| 4358 | q.text("hard_timeout = "); |
| 4359 | q.text("%#x" % self.hard_timeout) |
| 4360 | q.text(","); q.breakable() |
| 4361 | q.text("priority = "); |
| 4362 | q.text("%#x" % self.priority) |
| 4363 | q.text(","); q.breakable() |
| 4364 | q.text("buffer_id = "); |
| 4365 | q.text("%#x" % self.buffer_id) |
| 4366 | q.text(","); q.breakable() |
| 4367 | q.text("out_port = "); |
| 4368 | q.text(util.pretty_port(self.out_port)) |
| 4369 | q.text(","); q.breakable() |
| 4370 | q.text("out_group = "); |
| 4371 | q.text("%#x" % self.out_group) |
| 4372 | q.text(","); q.breakable() |
| 4373 | q.text("flags = "); |
| 4374 | q.text("%#x" % self.flags) |
| 4375 | q.text(","); q.breakable() |
| 4376 | q.text("match = "); |
| 4377 | q.pp(self.match) |
| 4378 | q.text(","); q.breakable() |
| 4379 | q.text("instructions = "); |
| 4380 | q.pp(self.instructions) |
| 4381 | q.breakable() |
| 4382 | q.text('}') |
| 4383 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4384 | flow_mod.subtypes[3] = flow_delete |
| 4385 | |
| 4386 | class flow_delete_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4387 | version = 3 |
| 4388 | type = 14 |
| 4389 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4390 | |
| 4391 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4392 | if xid != None: |
| 4393 | self.xid = xid |
| 4394 | else: |
| 4395 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4396 | if cookie != None: |
| 4397 | self.cookie = cookie |
| 4398 | else: |
| 4399 | self.cookie = 0 |
| 4400 | if cookie_mask != None: |
| 4401 | self.cookie_mask = cookie_mask |
| 4402 | else: |
| 4403 | self.cookie_mask = 0 |
| 4404 | if table_id != None: |
| 4405 | self.table_id = table_id |
| 4406 | else: |
| 4407 | self.table_id = 0 |
| 4408 | if idle_timeout != None: |
| 4409 | self.idle_timeout = idle_timeout |
| 4410 | else: |
| 4411 | self.idle_timeout = 0 |
| 4412 | if hard_timeout != None: |
| 4413 | self.hard_timeout = hard_timeout |
| 4414 | else: |
| 4415 | self.hard_timeout = 0 |
| 4416 | if priority != None: |
| 4417 | self.priority = priority |
| 4418 | else: |
| 4419 | self.priority = 0 |
| 4420 | if buffer_id != None: |
| 4421 | self.buffer_id = buffer_id |
| 4422 | else: |
| 4423 | self.buffer_id = 0 |
| 4424 | if out_port != None: |
| 4425 | self.out_port = out_port |
| 4426 | else: |
| 4427 | self.out_port = 0 |
| 4428 | if out_group != None: |
| 4429 | self.out_group = out_group |
| 4430 | else: |
| 4431 | self.out_group = 0 |
| 4432 | if flags != None: |
| 4433 | self.flags = flags |
| 4434 | else: |
| 4435 | self.flags = 0 |
| 4436 | if match != None: |
| 4437 | self.match = match |
| 4438 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4439 | self.match = ofp.match() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4440 | if instructions != None: |
| 4441 | self.instructions = instructions |
| 4442 | else: |
| 4443 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4444 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4445 | |
| 4446 | def pack(self): |
| 4447 | packed = [] |
| 4448 | packed.append(struct.pack("!B", self.version)) |
| 4449 | packed.append(struct.pack("!B", self.type)) |
| 4450 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4451 | packed.append(struct.pack("!L", self.xid)) |
| 4452 | packed.append(struct.pack("!Q", self.cookie)) |
| 4453 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4454 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4455 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4456 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4457 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4458 | packed.append(struct.pack("!H", self.priority)) |
| 4459 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4460 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4461 | packed.append(struct.pack("!L", self.out_group)) |
| 4462 | packed.append(struct.pack("!H", self.flags)) |
| 4463 | packed.append('\x00' * 2) |
| 4464 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4465 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4466 | length = sum([len(x) for x in packed]) |
| 4467 | packed[2] = struct.pack("!H", length) |
| 4468 | return ''.join(packed) |
| 4469 | |
| 4470 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4471 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4472 | obj = flow_delete_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4473 | _version = reader.read("!B")[0] |
| 4474 | assert(_version == 3) |
| 4475 | _type = reader.read("!B")[0] |
| 4476 | assert(_type == 14) |
| 4477 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4478 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4479 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4480 | obj.xid = reader.read("!L")[0] |
| 4481 | obj.cookie = reader.read("!Q")[0] |
| 4482 | obj.cookie_mask = reader.read("!Q")[0] |
| 4483 | obj.table_id = reader.read("!B")[0] |
| 4484 | __command = util.unpack_fm_cmd(reader) |
| 4485 | assert(__command == 4) |
| 4486 | obj.idle_timeout = reader.read("!H")[0] |
| 4487 | obj.hard_timeout = reader.read("!H")[0] |
| 4488 | obj.priority = reader.read("!H")[0] |
| 4489 | obj.buffer_id = reader.read("!L")[0] |
| 4490 | obj.out_port = util.unpack_port_no(reader) |
| 4491 | obj.out_group = reader.read("!L")[0] |
| 4492 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4493 | reader.skip(2) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4494 | obj.match = ofp.match.unpack(reader) |
| 4495 | obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4496 | return obj |
| 4497 | |
| 4498 | def __eq__(self, other): |
| 4499 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4500 | if self.xid != other.xid: return False |
| 4501 | if self.cookie != other.cookie: return False |
| 4502 | if self.cookie_mask != other.cookie_mask: return False |
| 4503 | if self.table_id != other.table_id: return False |
| 4504 | if self.idle_timeout != other.idle_timeout: return False |
| 4505 | if self.hard_timeout != other.hard_timeout: return False |
| 4506 | if self.priority != other.priority: return False |
| 4507 | if self.buffer_id != other.buffer_id: return False |
| 4508 | if self.out_port != other.out_port: return False |
| 4509 | if self.out_group != other.out_group: return False |
| 4510 | if self.flags != other.flags: return False |
| 4511 | if self.match != other.match: return False |
| 4512 | if self.instructions != other.instructions: return False |
| 4513 | return True |
| 4514 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4515 | def pretty_print(self, q): |
| 4516 | q.text("flow_delete_strict {") |
| 4517 | with q.group(): |
| 4518 | with q.indent(2): |
| 4519 | q.breakable() |
| 4520 | q.text("xid = "); |
| 4521 | if self.xid != None: |
| 4522 | q.text("%#x" % self.xid) |
| 4523 | else: |
| 4524 | q.text('None') |
| 4525 | q.text(","); q.breakable() |
| 4526 | q.text("cookie = "); |
| 4527 | q.text("%#x" % self.cookie) |
| 4528 | q.text(","); q.breakable() |
| 4529 | q.text("cookie_mask = "); |
| 4530 | q.text("%#x" % self.cookie_mask) |
| 4531 | q.text(","); q.breakable() |
| 4532 | q.text("table_id = "); |
| 4533 | q.text("%#x" % self.table_id) |
| 4534 | q.text(","); q.breakable() |
| 4535 | q.text("idle_timeout = "); |
| 4536 | q.text("%#x" % self.idle_timeout) |
| 4537 | q.text(","); q.breakable() |
| 4538 | q.text("hard_timeout = "); |
| 4539 | q.text("%#x" % self.hard_timeout) |
| 4540 | q.text(","); q.breakable() |
| 4541 | q.text("priority = "); |
| 4542 | q.text("%#x" % self.priority) |
| 4543 | q.text(","); q.breakable() |
| 4544 | q.text("buffer_id = "); |
| 4545 | q.text("%#x" % self.buffer_id) |
| 4546 | q.text(","); q.breakable() |
| 4547 | q.text("out_port = "); |
| 4548 | q.text(util.pretty_port(self.out_port)) |
| 4549 | q.text(","); q.breakable() |
| 4550 | q.text("out_group = "); |
| 4551 | q.text("%#x" % self.out_group) |
| 4552 | q.text(","); q.breakable() |
| 4553 | q.text("flags = "); |
| 4554 | q.text("%#x" % self.flags) |
| 4555 | q.text(","); q.breakable() |
| 4556 | q.text("match = "); |
| 4557 | q.pp(self.match) |
| 4558 | q.text(","); q.breakable() |
| 4559 | q.text("instructions = "); |
| 4560 | q.pp(self.instructions) |
| 4561 | q.breakable() |
| 4562 | q.text('}') |
| 4563 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4564 | flow_mod.subtypes[4] = flow_delete_strict |
| 4565 | |
| 4566 | class flow_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4567 | version = 3 |
| 4568 | type = 1 |
| 4569 | err_type = 5 |
| 4570 | |
| 4571 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4572 | if xid != None: |
| 4573 | self.xid = xid |
| 4574 | else: |
| 4575 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4576 | if code != None: |
| 4577 | self.code = code |
| 4578 | else: |
| 4579 | self.code = 0 |
| 4580 | if data != None: |
| 4581 | self.data = data |
| 4582 | else: |
| 4583 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4584 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4585 | |
| 4586 | def pack(self): |
| 4587 | packed = [] |
| 4588 | packed.append(struct.pack("!B", self.version)) |
| 4589 | packed.append(struct.pack("!B", self.type)) |
| 4590 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4591 | packed.append(struct.pack("!L", self.xid)) |
| 4592 | packed.append(struct.pack("!H", self.err_type)) |
| 4593 | packed.append(struct.pack("!H", self.code)) |
| 4594 | packed.append(self.data) |
| 4595 | length = sum([len(x) for x in packed]) |
| 4596 | packed[2] = struct.pack("!H", length) |
| 4597 | return ''.join(packed) |
| 4598 | |
| 4599 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4600 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4601 | obj = flow_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4602 | _version = reader.read("!B")[0] |
| 4603 | assert(_version == 3) |
| 4604 | _type = reader.read("!B")[0] |
| 4605 | assert(_type == 1) |
| 4606 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4607 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4608 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4609 | obj.xid = reader.read("!L")[0] |
| 4610 | _err_type = reader.read("!H")[0] |
| 4611 | assert(_err_type == 5) |
| 4612 | obj.code = reader.read("!H")[0] |
| 4613 | obj.data = str(reader.read_all()) |
| 4614 | return obj |
| 4615 | |
| 4616 | def __eq__(self, other): |
| 4617 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4618 | if self.xid != other.xid: return False |
| 4619 | if self.code != other.code: return False |
| 4620 | if self.data != other.data: return False |
| 4621 | return True |
| 4622 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4623 | def pretty_print(self, q): |
| 4624 | q.text("flow_mod_failed_error_msg {") |
| 4625 | with q.group(): |
| 4626 | with q.indent(2): |
| 4627 | q.breakable() |
| 4628 | q.text("xid = "); |
| 4629 | if self.xid != None: |
| 4630 | q.text("%#x" % self.xid) |
| 4631 | else: |
| 4632 | q.text('None') |
| 4633 | q.text(","); q.breakable() |
| 4634 | q.text("code = "); |
| 4635 | q.text("%#x" % self.code) |
| 4636 | q.text(","); q.breakable() |
| 4637 | q.text("data = "); |
| 4638 | q.pp(self.data) |
| 4639 | q.breakable() |
| 4640 | q.text('}') |
| 4641 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4642 | error_msg.subtypes[5] = flow_mod_failed_error_msg |
| 4643 | |
| 4644 | class flow_modify(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4645 | version = 3 |
| 4646 | type = 14 |
| 4647 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4648 | |
| 4649 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4650 | if xid != None: |
| 4651 | self.xid = xid |
| 4652 | else: |
| 4653 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4654 | if cookie != None: |
| 4655 | self.cookie = cookie |
| 4656 | else: |
| 4657 | self.cookie = 0 |
| 4658 | if cookie_mask != None: |
| 4659 | self.cookie_mask = cookie_mask |
| 4660 | else: |
| 4661 | self.cookie_mask = 0 |
| 4662 | if table_id != None: |
| 4663 | self.table_id = table_id |
| 4664 | else: |
| 4665 | self.table_id = 0 |
| 4666 | if idle_timeout != None: |
| 4667 | self.idle_timeout = idle_timeout |
| 4668 | else: |
| 4669 | self.idle_timeout = 0 |
| 4670 | if hard_timeout != None: |
| 4671 | self.hard_timeout = hard_timeout |
| 4672 | else: |
| 4673 | self.hard_timeout = 0 |
| 4674 | if priority != None: |
| 4675 | self.priority = priority |
| 4676 | else: |
| 4677 | self.priority = 0 |
| 4678 | if buffer_id != None: |
| 4679 | self.buffer_id = buffer_id |
| 4680 | else: |
| 4681 | self.buffer_id = 0 |
| 4682 | if out_port != None: |
| 4683 | self.out_port = out_port |
| 4684 | else: |
| 4685 | self.out_port = 0 |
| 4686 | if out_group != None: |
| 4687 | self.out_group = out_group |
| 4688 | else: |
| 4689 | self.out_group = 0 |
| 4690 | if flags != None: |
| 4691 | self.flags = flags |
| 4692 | else: |
| 4693 | self.flags = 0 |
| 4694 | if match != None: |
| 4695 | self.match = match |
| 4696 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4697 | self.match = ofp.match() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4698 | if instructions != None: |
| 4699 | self.instructions = instructions |
| 4700 | else: |
| 4701 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4702 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4703 | |
| 4704 | def pack(self): |
| 4705 | packed = [] |
| 4706 | packed.append(struct.pack("!B", self.version)) |
| 4707 | packed.append(struct.pack("!B", self.type)) |
| 4708 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4709 | packed.append(struct.pack("!L", self.xid)) |
| 4710 | packed.append(struct.pack("!Q", self.cookie)) |
| 4711 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4712 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4713 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4714 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4715 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4716 | packed.append(struct.pack("!H", self.priority)) |
| 4717 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4718 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4719 | packed.append(struct.pack("!L", self.out_group)) |
| 4720 | packed.append(struct.pack("!H", self.flags)) |
| 4721 | packed.append('\x00' * 2) |
| 4722 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4723 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4724 | length = sum([len(x) for x in packed]) |
| 4725 | packed[2] = struct.pack("!H", length) |
| 4726 | return ''.join(packed) |
| 4727 | |
| 4728 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4729 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4730 | obj = flow_modify() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4731 | _version = reader.read("!B")[0] |
| 4732 | assert(_version == 3) |
| 4733 | _type = reader.read("!B")[0] |
| 4734 | assert(_type == 14) |
| 4735 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4736 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4737 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4738 | obj.xid = reader.read("!L")[0] |
| 4739 | obj.cookie = reader.read("!Q")[0] |
| 4740 | obj.cookie_mask = reader.read("!Q")[0] |
| 4741 | obj.table_id = reader.read("!B")[0] |
| 4742 | __command = util.unpack_fm_cmd(reader) |
| 4743 | assert(__command == 1) |
| 4744 | obj.idle_timeout = reader.read("!H")[0] |
| 4745 | obj.hard_timeout = reader.read("!H")[0] |
| 4746 | obj.priority = reader.read("!H")[0] |
| 4747 | obj.buffer_id = reader.read("!L")[0] |
| 4748 | obj.out_port = util.unpack_port_no(reader) |
| 4749 | obj.out_group = reader.read("!L")[0] |
| 4750 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4751 | reader.skip(2) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4752 | obj.match = ofp.match.unpack(reader) |
| 4753 | obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4754 | return obj |
| 4755 | |
| 4756 | def __eq__(self, other): |
| 4757 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4758 | if self.xid != other.xid: return False |
| 4759 | if self.cookie != other.cookie: return False |
| 4760 | if self.cookie_mask != other.cookie_mask: return False |
| 4761 | if self.table_id != other.table_id: return False |
| 4762 | if self.idle_timeout != other.idle_timeout: return False |
| 4763 | if self.hard_timeout != other.hard_timeout: return False |
| 4764 | if self.priority != other.priority: return False |
| 4765 | if self.buffer_id != other.buffer_id: return False |
| 4766 | if self.out_port != other.out_port: return False |
| 4767 | if self.out_group != other.out_group: return False |
| 4768 | if self.flags != other.flags: return False |
| 4769 | if self.match != other.match: return False |
| 4770 | if self.instructions != other.instructions: return False |
| 4771 | return True |
| 4772 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4773 | def pretty_print(self, q): |
| 4774 | q.text("flow_modify {") |
| 4775 | with q.group(): |
| 4776 | with q.indent(2): |
| 4777 | q.breakable() |
| 4778 | q.text("xid = "); |
| 4779 | if self.xid != None: |
| 4780 | q.text("%#x" % self.xid) |
| 4781 | else: |
| 4782 | q.text('None') |
| 4783 | q.text(","); q.breakable() |
| 4784 | q.text("cookie = "); |
| 4785 | q.text("%#x" % self.cookie) |
| 4786 | q.text(","); q.breakable() |
| 4787 | q.text("cookie_mask = "); |
| 4788 | q.text("%#x" % self.cookie_mask) |
| 4789 | q.text(","); q.breakable() |
| 4790 | q.text("table_id = "); |
| 4791 | q.text("%#x" % self.table_id) |
| 4792 | q.text(","); q.breakable() |
| 4793 | q.text("idle_timeout = "); |
| 4794 | q.text("%#x" % self.idle_timeout) |
| 4795 | q.text(","); q.breakable() |
| 4796 | q.text("hard_timeout = "); |
| 4797 | q.text("%#x" % self.hard_timeout) |
| 4798 | q.text(","); q.breakable() |
| 4799 | q.text("priority = "); |
| 4800 | q.text("%#x" % self.priority) |
| 4801 | q.text(","); q.breakable() |
| 4802 | q.text("buffer_id = "); |
| 4803 | q.text("%#x" % self.buffer_id) |
| 4804 | q.text(","); q.breakable() |
| 4805 | q.text("out_port = "); |
| 4806 | q.text(util.pretty_port(self.out_port)) |
| 4807 | q.text(","); q.breakable() |
| 4808 | q.text("out_group = "); |
| 4809 | q.text("%#x" % self.out_group) |
| 4810 | q.text(","); q.breakable() |
| 4811 | q.text("flags = "); |
| 4812 | q.text("%#x" % self.flags) |
| 4813 | q.text(","); q.breakable() |
| 4814 | q.text("match = "); |
| 4815 | q.pp(self.match) |
| 4816 | q.text(","); q.breakable() |
| 4817 | q.text("instructions = "); |
| 4818 | q.pp(self.instructions) |
| 4819 | q.breakable() |
| 4820 | q.text('}') |
| 4821 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4822 | flow_mod.subtypes[1] = flow_modify |
| 4823 | |
| 4824 | class flow_modify_strict(flow_mod): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4825 | version = 3 |
| 4826 | type = 14 |
| 4827 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4828 | |
| 4829 | def __init__(self, xid=None, cookie=None, cookie_mask=None, table_id=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, out_group=None, flags=None, match=None, instructions=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4830 | if xid != None: |
| 4831 | self.xid = xid |
| 4832 | else: |
| 4833 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4834 | if cookie != None: |
| 4835 | self.cookie = cookie |
| 4836 | else: |
| 4837 | self.cookie = 0 |
| 4838 | if cookie_mask != None: |
| 4839 | self.cookie_mask = cookie_mask |
| 4840 | else: |
| 4841 | self.cookie_mask = 0 |
| 4842 | if table_id != None: |
| 4843 | self.table_id = table_id |
| 4844 | else: |
| 4845 | self.table_id = 0 |
| 4846 | if idle_timeout != None: |
| 4847 | self.idle_timeout = idle_timeout |
| 4848 | else: |
| 4849 | self.idle_timeout = 0 |
| 4850 | if hard_timeout != None: |
| 4851 | self.hard_timeout = hard_timeout |
| 4852 | else: |
| 4853 | self.hard_timeout = 0 |
| 4854 | if priority != None: |
| 4855 | self.priority = priority |
| 4856 | else: |
| 4857 | self.priority = 0 |
| 4858 | if buffer_id != None: |
| 4859 | self.buffer_id = buffer_id |
| 4860 | else: |
| 4861 | self.buffer_id = 0 |
| 4862 | if out_port != None: |
| 4863 | self.out_port = out_port |
| 4864 | else: |
| 4865 | self.out_port = 0 |
| 4866 | if out_group != None: |
| 4867 | self.out_group = out_group |
| 4868 | else: |
| 4869 | self.out_group = 0 |
| 4870 | if flags != None: |
| 4871 | self.flags = flags |
| 4872 | else: |
| 4873 | self.flags = 0 |
| 4874 | if match != None: |
| 4875 | self.match = match |
| 4876 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4877 | self.match = ofp.match() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4878 | if instructions != None: |
| 4879 | self.instructions = instructions |
| 4880 | else: |
| 4881 | self.instructions = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4882 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4883 | |
| 4884 | def pack(self): |
| 4885 | packed = [] |
| 4886 | packed.append(struct.pack("!B", self.version)) |
| 4887 | packed.append(struct.pack("!B", self.type)) |
| 4888 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4889 | packed.append(struct.pack("!L", self.xid)) |
| 4890 | packed.append(struct.pack("!Q", self.cookie)) |
| 4891 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4892 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4893 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4894 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4895 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4896 | packed.append(struct.pack("!H", self.priority)) |
| 4897 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4898 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4899 | packed.append(struct.pack("!L", self.out_group)) |
| 4900 | packed.append(struct.pack("!H", self.flags)) |
| 4901 | packed.append('\x00' * 2) |
| 4902 | packed.append(self.match.pack()) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4903 | packed.append(loxi.generic_util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4904 | length = sum([len(x) for x in packed]) |
| 4905 | packed[2] = struct.pack("!H", length) |
| 4906 | return ''.join(packed) |
| 4907 | |
| 4908 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4909 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4910 | obj = flow_modify_strict() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4911 | _version = reader.read("!B")[0] |
| 4912 | assert(_version == 3) |
| 4913 | _type = reader.read("!B")[0] |
| 4914 | assert(_type == 14) |
| 4915 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 4916 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 4917 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4918 | obj.xid = reader.read("!L")[0] |
| 4919 | obj.cookie = reader.read("!Q")[0] |
| 4920 | obj.cookie_mask = reader.read("!Q")[0] |
| 4921 | obj.table_id = reader.read("!B")[0] |
| 4922 | __command = util.unpack_fm_cmd(reader) |
| 4923 | assert(__command == 2) |
| 4924 | obj.idle_timeout = reader.read("!H")[0] |
| 4925 | obj.hard_timeout = reader.read("!H")[0] |
| 4926 | obj.priority = reader.read("!H")[0] |
| 4927 | obj.buffer_id = reader.read("!L")[0] |
| 4928 | obj.out_port = util.unpack_port_no(reader) |
| 4929 | obj.out_group = reader.read("!L")[0] |
| 4930 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4931 | reader.skip(2) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 4932 | obj.match = ofp.match.unpack(reader) |
| 4933 | obj.instructions = loxi.generic_util.unpack_list(reader, ofp.instruction.instruction.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4934 | return obj |
| 4935 | |
| 4936 | def __eq__(self, other): |
| 4937 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4938 | if self.xid != other.xid: return False |
| 4939 | if self.cookie != other.cookie: return False |
| 4940 | if self.cookie_mask != other.cookie_mask: return False |
| 4941 | if self.table_id != other.table_id: return False |
| 4942 | if self.idle_timeout != other.idle_timeout: return False |
| 4943 | if self.hard_timeout != other.hard_timeout: return False |
| 4944 | if self.priority != other.priority: return False |
| 4945 | if self.buffer_id != other.buffer_id: return False |
| 4946 | if self.out_port != other.out_port: return False |
| 4947 | if self.out_group != other.out_group: return False |
| 4948 | if self.flags != other.flags: return False |
| 4949 | if self.match != other.match: return False |
| 4950 | if self.instructions != other.instructions: return False |
| 4951 | return True |
| 4952 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4953 | def pretty_print(self, q): |
| 4954 | q.text("flow_modify_strict {") |
| 4955 | with q.group(): |
| 4956 | with q.indent(2): |
| 4957 | q.breakable() |
| 4958 | q.text("xid = "); |
| 4959 | if self.xid != None: |
| 4960 | q.text("%#x" % self.xid) |
| 4961 | else: |
| 4962 | q.text('None') |
| 4963 | q.text(","); q.breakable() |
| 4964 | q.text("cookie = "); |
| 4965 | q.text("%#x" % self.cookie) |
| 4966 | q.text(","); q.breakable() |
| 4967 | q.text("cookie_mask = "); |
| 4968 | q.text("%#x" % self.cookie_mask) |
| 4969 | q.text(","); q.breakable() |
| 4970 | q.text("table_id = "); |
| 4971 | q.text("%#x" % self.table_id) |
| 4972 | q.text(","); q.breakable() |
| 4973 | q.text("idle_timeout = "); |
| 4974 | q.text("%#x" % self.idle_timeout) |
| 4975 | q.text(","); q.breakable() |
| 4976 | q.text("hard_timeout = "); |
| 4977 | q.text("%#x" % self.hard_timeout) |
| 4978 | q.text(","); q.breakable() |
| 4979 | q.text("priority = "); |
| 4980 | q.text("%#x" % self.priority) |
| 4981 | q.text(","); q.breakable() |
| 4982 | q.text("buffer_id = "); |
| 4983 | q.text("%#x" % self.buffer_id) |
| 4984 | q.text(","); q.breakable() |
| 4985 | q.text("out_port = "); |
| 4986 | q.text(util.pretty_port(self.out_port)) |
| 4987 | q.text(","); q.breakable() |
| 4988 | q.text("out_group = "); |
| 4989 | q.text("%#x" % self.out_group) |
| 4990 | q.text(","); q.breakable() |
| 4991 | q.text("flags = "); |
| 4992 | q.text("%#x" % self.flags) |
| 4993 | q.text(","); q.breakable() |
| 4994 | q.text("match = "); |
| 4995 | q.pp(self.match) |
| 4996 | q.text(","); q.breakable() |
| 4997 | q.text("instructions = "); |
| 4998 | q.pp(self.instructions) |
| 4999 | q.breakable() |
| 5000 | q.text('}') |
| 5001 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5002 | flow_mod.subtypes[2] = flow_modify_strict |
| 5003 | |
| 5004 | class flow_removed(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5005 | version = 3 |
| 5006 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5007 | |
| 5008 | def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, hard_timeout=None, packet_count=None, byte_count=None, match=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5009 | if xid != None: |
| 5010 | self.xid = xid |
| 5011 | else: |
| 5012 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5013 | if cookie != None: |
| 5014 | self.cookie = cookie |
| 5015 | else: |
| 5016 | self.cookie = 0 |
| 5017 | if priority != None: |
| 5018 | self.priority = priority |
| 5019 | else: |
| 5020 | self.priority = 0 |
| 5021 | if reason != None: |
| 5022 | self.reason = reason |
| 5023 | else: |
| 5024 | self.reason = 0 |
| 5025 | if table_id != None: |
| 5026 | self.table_id = table_id |
| 5027 | else: |
| 5028 | self.table_id = 0 |
| 5029 | if duration_sec != None: |
| 5030 | self.duration_sec = duration_sec |
| 5031 | else: |
| 5032 | self.duration_sec = 0 |
| 5033 | if duration_nsec != None: |
| 5034 | self.duration_nsec = duration_nsec |
| 5035 | else: |
| 5036 | self.duration_nsec = 0 |
| 5037 | if idle_timeout != None: |
| 5038 | self.idle_timeout = idle_timeout |
| 5039 | else: |
| 5040 | self.idle_timeout = 0 |
| 5041 | if hard_timeout != None: |
| 5042 | self.hard_timeout = hard_timeout |
| 5043 | else: |
| 5044 | self.hard_timeout = 0 |
| 5045 | if packet_count != None: |
| 5046 | self.packet_count = packet_count |
| 5047 | else: |
| 5048 | self.packet_count = 0 |
| 5049 | if byte_count != None: |
| 5050 | self.byte_count = byte_count |
| 5051 | else: |
| 5052 | self.byte_count = 0 |
| 5053 | if match != None: |
| 5054 | self.match = match |
| 5055 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5056 | self.match = ofp.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5057 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5058 | |
| 5059 | def pack(self): |
| 5060 | packed = [] |
| 5061 | packed.append(struct.pack("!B", self.version)) |
| 5062 | packed.append(struct.pack("!B", self.type)) |
| 5063 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5064 | packed.append(struct.pack("!L", self.xid)) |
| 5065 | packed.append(struct.pack("!Q", self.cookie)) |
| 5066 | packed.append(struct.pack("!H", self.priority)) |
| 5067 | packed.append(struct.pack("!B", self.reason)) |
| 5068 | packed.append(struct.pack("!B", self.table_id)) |
| 5069 | packed.append(struct.pack("!L", self.duration_sec)) |
| 5070 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 5071 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5072 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5073 | packed.append(struct.pack("!Q", self.packet_count)) |
| 5074 | packed.append(struct.pack("!Q", self.byte_count)) |
| 5075 | packed.append(self.match.pack()) |
| 5076 | length = sum([len(x) for x in packed]) |
| 5077 | packed[2] = struct.pack("!H", length) |
| 5078 | return ''.join(packed) |
| 5079 | |
| 5080 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5081 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5082 | obj = flow_removed() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5083 | _version = reader.read("!B")[0] |
| 5084 | assert(_version == 3) |
| 5085 | _type = reader.read("!B")[0] |
| 5086 | assert(_type == 11) |
| 5087 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5088 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5089 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5090 | obj.xid = reader.read("!L")[0] |
| 5091 | obj.cookie = reader.read("!Q")[0] |
| 5092 | obj.priority = reader.read("!H")[0] |
| 5093 | obj.reason = reader.read("!B")[0] |
| 5094 | obj.table_id = reader.read("!B")[0] |
| 5095 | obj.duration_sec = reader.read("!L")[0] |
| 5096 | obj.duration_nsec = reader.read("!L")[0] |
| 5097 | obj.idle_timeout = reader.read("!H")[0] |
| 5098 | obj.hard_timeout = reader.read("!H")[0] |
| 5099 | obj.packet_count = reader.read("!Q")[0] |
| 5100 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5101 | obj.match = ofp.match.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5102 | return obj |
| 5103 | |
| 5104 | def __eq__(self, other): |
| 5105 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5106 | if self.xid != other.xid: return False |
| 5107 | if self.cookie != other.cookie: return False |
| 5108 | if self.priority != other.priority: return False |
| 5109 | if self.reason != other.reason: return False |
| 5110 | if self.table_id != other.table_id: return False |
| 5111 | if self.duration_sec != other.duration_sec: return False |
| 5112 | if self.duration_nsec != other.duration_nsec: return False |
| 5113 | if self.idle_timeout != other.idle_timeout: return False |
| 5114 | if self.hard_timeout != other.hard_timeout: return False |
| 5115 | if self.packet_count != other.packet_count: return False |
| 5116 | if self.byte_count != other.byte_count: return False |
| 5117 | if self.match != other.match: return False |
| 5118 | return True |
| 5119 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5120 | def pretty_print(self, q): |
| 5121 | q.text("flow_removed {") |
| 5122 | with q.group(): |
| 5123 | with q.indent(2): |
| 5124 | q.breakable() |
| 5125 | q.text("xid = "); |
| 5126 | if self.xid != None: |
| 5127 | q.text("%#x" % self.xid) |
| 5128 | else: |
| 5129 | q.text('None') |
| 5130 | q.text(","); q.breakable() |
| 5131 | q.text("cookie = "); |
| 5132 | q.text("%#x" % self.cookie) |
| 5133 | q.text(","); q.breakable() |
| 5134 | q.text("priority = "); |
| 5135 | q.text("%#x" % self.priority) |
| 5136 | q.text(","); q.breakable() |
| 5137 | q.text("reason = "); |
| 5138 | q.text("%#x" % self.reason) |
| 5139 | q.text(","); q.breakable() |
| 5140 | q.text("table_id = "); |
| 5141 | q.text("%#x" % self.table_id) |
| 5142 | q.text(","); q.breakable() |
| 5143 | q.text("duration_sec = "); |
| 5144 | q.text("%#x" % self.duration_sec) |
| 5145 | q.text(","); q.breakable() |
| 5146 | q.text("duration_nsec = "); |
| 5147 | q.text("%#x" % self.duration_nsec) |
| 5148 | q.text(","); q.breakable() |
| 5149 | q.text("idle_timeout = "); |
| 5150 | q.text("%#x" % self.idle_timeout) |
| 5151 | q.text(","); q.breakable() |
| 5152 | q.text("hard_timeout = "); |
| 5153 | q.text("%#x" % self.hard_timeout) |
| 5154 | q.text(","); q.breakable() |
| 5155 | q.text("packet_count = "); |
| 5156 | q.text("%#x" % self.packet_count) |
| 5157 | q.text(","); q.breakable() |
| 5158 | q.text("byte_count = "); |
| 5159 | q.text("%#x" % self.byte_count) |
| 5160 | q.text(","); q.breakable() |
| 5161 | q.text("match = "); |
| 5162 | q.pp(self.match) |
| 5163 | q.breakable() |
| 5164 | q.text('}') |
| 5165 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5166 | message.subtypes[11] = flow_removed |
| 5167 | |
| 5168 | class flow_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5169 | version = 3 |
| 5170 | type = 19 |
| 5171 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5172 | |
| 5173 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5174 | if xid != None: |
| 5175 | self.xid = xid |
| 5176 | else: |
| 5177 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5178 | if flags != None: |
| 5179 | self.flags = flags |
| 5180 | else: |
| 5181 | self.flags = 0 |
| 5182 | if entries != None: |
| 5183 | self.entries = entries |
| 5184 | else: |
| 5185 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5186 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5187 | |
| 5188 | def pack(self): |
| 5189 | packed = [] |
| 5190 | packed.append(struct.pack("!B", self.version)) |
| 5191 | packed.append(struct.pack("!B", self.type)) |
| 5192 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5193 | packed.append(struct.pack("!L", self.xid)) |
| 5194 | packed.append(struct.pack("!H", self.stats_type)) |
| 5195 | packed.append(struct.pack("!H", self.flags)) |
| 5196 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5197 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5198 | length = sum([len(x) for x in packed]) |
| 5199 | packed[2] = struct.pack("!H", length) |
| 5200 | return ''.join(packed) |
| 5201 | |
| 5202 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5203 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5204 | obj = flow_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5205 | _version = reader.read("!B")[0] |
| 5206 | assert(_version == 3) |
| 5207 | _type = reader.read("!B")[0] |
| 5208 | assert(_type == 19) |
| 5209 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5210 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5211 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5212 | obj.xid = reader.read("!L")[0] |
| 5213 | _stats_type = reader.read("!H")[0] |
| 5214 | assert(_stats_type == 1) |
| 5215 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5216 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5217 | obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.flow_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5218 | return obj |
| 5219 | |
| 5220 | def __eq__(self, other): |
| 5221 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5222 | if self.xid != other.xid: return False |
| 5223 | if self.flags != other.flags: return False |
| 5224 | if self.entries != other.entries: return False |
| 5225 | return True |
| 5226 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5227 | def pretty_print(self, q): |
| 5228 | q.text("flow_stats_reply {") |
| 5229 | with q.group(): |
| 5230 | with q.indent(2): |
| 5231 | q.breakable() |
| 5232 | q.text("xid = "); |
| 5233 | if self.xid != None: |
| 5234 | q.text("%#x" % self.xid) |
| 5235 | else: |
| 5236 | q.text('None') |
| 5237 | q.text(","); q.breakable() |
| 5238 | q.text("flags = "); |
| 5239 | q.text("%#x" % self.flags) |
| 5240 | q.text(","); q.breakable() |
| 5241 | q.text("entries = "); |
| 5242 | q.pp(self.entries) |
| 5243 | q.breakable() |
| 5244 | q.text('}') |
| 5245 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5246 | stats_reply.subtypes[1] = flow_stats_reply |
| 5247 | |
| 5248 | class flow_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5249 | version = 3 |
| 5250 | type = 18 |
| 5251 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5252 | |
| 5253 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5254 | if xid != None: |
| 5255 | self.xid = xid |
| 5256 | else: |
| 5257 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5258 | if flags != None: |
| 5259 | self.flags = flags |
| 5260 | else: |
| 5261 | self.flags = 0 |
| 5262 | if table_id != None: |
| 5263 | self.table_id = table_id |
| 5264 | else: |
| 5265 | self.table_id = 0 |
| 5266 | if out_port != None: |
| 5267 | self.out_port = out_port |
| 5268 | else: |
| 5269 | self.out_port = 0 |
| 5270 | if out_group != None: |
| 5271 | self.out_group = out_group |
| 5272 | else: |
| 5273 | self.out_group = 0 |
| 5274 | if cookie != None: |
| 5275 | self.cookie = cookie |
| 5276 | else: |
| 5277 | self.cookie = 0 |
| 5278 | if cookie_mask != None: |
| 5279 | self.cookie_mask = cookie_mask |
| 5280 | else: |
| 5281 | self.cookie_mask = 0 |
| 5282 | if match != None: |
| 5283 | self.match = match |
| 5284 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5285 | self.match = ofp.match() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5286 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5287 | |
| 5288 | def pack(self): |
| 5289 | packed = [] |
| 5290 | packed.append(struct.pack("!B", self.version)) |
| 5291 | packed.append(struct.pack("!B", self.type)) |
| 5292 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5293 | packed.append(struct.pack("!L", self.xid)) |
| 5294 | packed.append(struct.pack("!H", self.stats_type)) |
| 5295 | packed.append(struct.pack("!H", self.flags)) |
| 5296 | packed.append('\x00' * 4) |
| 5297 | packed.append(struct.pack("!B", self.table_id)) |
| 5298 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5299 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5300 | packed.append(struct.pack("!L", self.out_group)) |
| 5301 | packed.append('\x00' * 4) |
| 5302 | packed.append(struct.pack("!Q", self.cookie)) |
| 5303 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5304 | packed.append(self.match.pack()) |
| 5305 | length = sum([len(x) for x in packed]) |
| 5306 | packed[2] = struct.pack("!H", length) |
| 5307 | return ''.join(packed) |
| 5308 | |
| 5309 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5310 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5311 | obj = flow_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5312 | _version = reader.read("!B")[0] |
| 5313 | assert(_version == 3) |
| 5314 | _type = reader.read("!B")[0] |
| 5315 | assert(_type == 18) |
| 5316 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5317 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5318 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5319 | obj.xid = reader.read("!L")[0] |
| 5320 | _stats_type = reader.read("!H")[0] |
| 5321 | assert(_stats_type == 1) |
| 5322 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5323 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5324 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5325 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5326 | obj.out_port = util.unpack_port_no(reader) |
| 5327 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5328 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5329 | obj.cookie = reader.read("!Q")[0] |
| 5330 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5331 | obj.match = ofp.match.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5332 | return obj |
| 5333 | |
| 5334 | def __eq__(self, other): |
| 5335 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5336 | if self.xid != other.xid: return False |
| 5337 | if self.flags != other.flags: return False |
| 5338 | if self.table_id != other.table_id: return False |
| 5339 | if self.out_port != other.out_port: return False |
| 5340 | if self.out_group != other.out_group: return False |
| 5341 | if self.cookie != other.cookie: return False |
| 5342 | if self.cookie_mask != other.cookie_mask: return False |
| 5343 | if self.match != other.match: return False |
| 5344 | return True |
| 5345 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5346 | def pretty_print(self, q): |
| 5347 | q.text("flow_stats_request {") |
| 5348 | with q.group(): |
| 5349 | with q.indent(2): |
| 5350 | q.breakable() |
| 5351 | q.text("xid = "); |
| 5352 | if self.xid != None: |
| 5353 | q.text("%#x" % self.xid) |
| 5354 | else: |
| 5355 | q.text('None') |
| 5356 | q.text(","); q.breakable() |
| 5357 | q.text("flags = "); |
| 5358 | q.text("%#x" % self.flags) |
| 5359 | q.text(","); q.breakable() |
| 5360 | q.text("table_id = "); |
| 5361 | q.text("%#x" % self.table_id) |
| 5362 | q.text(","); q.breakable() |
| 5363 | q.text("out_port = "); |
| 5364 | q.text(util.pretty_port(self.out_port)) |
| 5365 | q.text(","); q.breakable() |
| 5366 | q.text("out_group = "); |
| 5367 | q.text("%#x" % self.out_group) |
| 5368 | q.text(","); q.breakable() |
| 5369 | q.text("cookie = "); |
| 5370 | q.text("%#x" % self.cookie) |
| 5371 | q.text(","); q.breakable() |
| 5372 | q.text("cookie_mask = "); |
| 5373 | q.text("%#x" % self.cookie_mask) |
| 5374 | q.text(","); q.breakable() |
| 5375 | q.text("match = "); |
| 5376 | q.pp(self.match) |
| 5377 | q.breakable() |
| 5378 | q.text('}') |
| 5379 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5380 | stats_request.subtypes[1] = flow_stats_request |
| 5381 | |
| 5382 | class get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5383 | version = 3 |
| 5384 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5385 | |
| 5386 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5387 | if xid != None: |
| 5388 | self.xid = xid |
| 5389 | else: |
| 5390 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5391 | if flags != None: |
| 5392 | self.flags = flags |
| 5393 | else: |
| 5394 | self.flags = 0 |
| 5395 | if miss_send_len != None: |
| 5396 | self.miss_send_len = miss_send_len |
| 5397 | else: |
| 5398 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5399 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5400 | |
| 5401 | def pack(self): |
| 5402 | packed = [] |
| 5403 | packed.append(struct.pack("!B", self.version)) |
| 5404 | packed.append(struct.pack("!B", self.type)) |
| 5405 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5406 | packed.append(struct.pack("!L", self.xid)) |
| 5407 | packed.append(struct.pack("!H", self.flags)) |
| 5408 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5409 | length = sum([len(x) for x in packed]) |
| 5410 | packed[2] = struct.pack("!H", length) |
| 5411 | return ''.join(packed) |
| 5412 | |
| 5413 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5414 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5415 | obj = get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5416 | _version = reader.read("!B")[0] |
| 5417 | assert(_version == 3) |
| 5418 | _type = reader.read("!B")[0] |
| 5419 | assert(_type == 8) |
| 5420 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5421 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5422 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5423 | obj.xid = reader.read("!L")[0] |
| 5424 | obj.flags = reader.read("!H")[0] |
| 5425 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5426 | return obj |
| 5427 | |
| 5428 | def __eq__(self, other): |
| 5429 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5430 | if self.xid != other.xid: return False |
| 5431 | if self.flags != other.flags: return False |
| 5432 | if self.miss_send_len != other.miss_send_len: return False |
| 5433 | return True |
| 5434 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5435 | def pretty_print(self, q): |
| 5436 | q.text("get_config_reply {") |
| 5437 | with q.group(): |
| 5438 | with q.indent(2): |
| 5439 | q.breakable() |
| 5440 | q.text("xid = "); |
| 5441 | if self.xid != None: |
| 5442 | q.text("%#x" % self.xid) |
| 5443 | else: |
| 5444 | q.text('None') |
| 5445 | q.text(","); q.breakable() |
| 5446 | q.text("flags = "); |
| 5447 | q.text("%#x" % self.flags) |
| 5448 | q.text(","); q.breakable() |
| 5449 | q.text("miss_send_len = "); |
| 5450 | q.text("%#x" % self.miss_send_len) |
| 5451 | q.breakable() |
| 5452 | q.text('}') |
| 5453 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5454 | message.subtypes[8] = get_config_reply |
| 5455 | |
| 5456 | class get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5457 | version = 3 |
| 5458 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5459 | |
| 5460 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5461 | if xid != None: |
| 5462 | self.xid = xid |
| 5463 | else: |
| 5464 | self.xid = None |
| 5465 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5466 | |
| 5467 | def pack(self): |
| 5468 | packed = [] |
| 5469 | packed.append(struct.pack("!B", self.version)) |
| 5470 | packed.append(struct.pack("!B", self.type)) |
| 5471 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5472 | packed.append(struct.pack("!L", self.xid)) |
| 5473 | length = sum([len(x) for x in packed]) |
| 5474 | packed[2] = struct.pack("!H", length) |
| 5475 | return ''.join(packed) |
| 5476 | |
| 5477 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5478 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5479 | obj = get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5480 | _version = reader.read("!B")[0] |
| 5481 | assert(_version == 3) |
| 5482 | _type = reader.read("!B")[0] |
| 5483 | assert(_type == 7) |
| 5484 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5485 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5486 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5487 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5488 | return obj |
| 5489 | |
| 5490 | def __eq__(self, other): |
| 5491 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5492 | if self.xid != other.xid: return False |
| 5493 | return True |
| 5494 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5495 | def pretty_print(self, q): |
| 5496 | q.text("get_config_request {") |
| 5497 | with q.group(): |
| 5498 | with q.indent(2): |
| 5499 | q.breakable() |
| 5500 | q.text("xid = "); |
| 5501 | if self.xid != None: |
| 5502 | q.text("%#x" % self.xid) |
| 5503 | else: |
| 5504 | q.text('None') |
| 5505 | q.breakable() |
| 5506 | q.text('}') |
| 5507 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5508 | message.subtypes[7] = get_config_request |
| 5509 | |
| 5510 | class group_mod(message): |
| 5511 | subtypes = {} |
| 5512 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5513 | version = 3 |
| 5514 | type = 15 |
| 5515 | |
| 5516 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 5517 | if xid != None: |
| 5518 | self.xid = xid |
| 5519 | else: |
| 5520 | self.xid = None |
| 5521 | if command != None: |
| 5522 | self.command = command |
| 5523 | else: |
| 5524 | self.command = 0 |
| 5525 | if group_type != None: |
| 5526 | self.group_type = group_type |
| 5527 | else: |
| 5528 | self.group_type = 0 |
| 5529 | if group_id != None: |
| 5530 | self.group_id = group_id |
| 5531 | else: |
| 5532 | self.group_id = 0 |
| 5533 | if buckets != None: |
| 5534 | self.buckets = buckets |
| 5535 | else: |
| 5536 | self.buckets = [] |
| 5537 | return |
| 5538 | |
| 5539 | def pack(self): |
| 5540 | packed = [] |
| 5541 | packed.append(struct.pack("!B", self.version)) |
| 5542 | packed.append(struct.pack("!B", self.type)) |
| 5543 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5544 | packed.append(struct.pack("!L", self.xid)) |
| 5545 | packed.append(struct.pack("!H", self.command)) |
| 5546 | packed.append(struct.pack("!B", self.group_type)) |
| 5547 | packed.append('\x00' * 1) |
| 5548 | packed.append(struct.pack("!L", self.group_id)) |
| 5549 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
| 5550 | length = sum([len(x) for x in packed]) |
| 5551 | packed[2] = struct.pack("!H", length) |
| 5552 | return ''.join(packed) |
| 5553 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5554 | @staticmethod |
| 5555 | def unpack(reader): |
| 5556 | subtype, = reader.peek('!H', 8) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5557 | subclass = group_mod.subtypes.get(subtype) |
| 5558 | if subclass: |
| 5559 | return subclass.unpack(reader) |
| 5560 | |
| 5561 | obj = group_mod() |
| 5562 | _version = reader.read("!B")[0] |
| 5563 | assert(_version == 3) |
| 5564 | _type = reader.read("!B")[0] |
| 5565 | assert(_type == 15) |
| 5566 | _length = reader.read("!H")[0] |
| 5567 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5568 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5569 | obj.xid = reader.read("!L")[0] |
| 5570 | obj.command = reader.read("!H")[0] |
| 5571 | obj.group_type = reader.read("!B")[0] |
| 5572 | reader.skip(1) |
| 5573 | obj.group_id = reader.read("!L")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5574 | obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 5575 | return obj |
| 5576 | |
| 5577 | def __eq__(self, other): |
| 5578 | if type(self) != type(other): return False |
| 5579 | if self.xid != other.xid: return False |
| 5580 | if self.command != other.command: return False |
| 5581 | if self.group_type != other.group_type: return False |
| 5582 | if self.group_id != other.group_id: return False |
| 5583 | if self.buckets != other.buckets: return False |
| 5584 | return True |
| 5585 | |
| 5586 | def pretty_print(self, q): |
| 5587 | q.text("group_mod {") |
| 5588 | with q.group(): |
| 5589 | with q.indent(2): |
| 5590 | q.breakable() |
| 5591 | q.text("xid = "); |
| 5592 | if self.xid != None: |
| 5593 | q.text("%#x" % self.xid) |
| 5594 | else: |
| 5595 | q.text('None') |
| 5596 | q.text(","); q.breakable() |
| 5597 | q.text("group_type = "); |
| 5598 | q.text("%#x" % self.group_type) |
| 5599 | q.text(","); q.breakable() |
| 5600 | q.text("group_id = "); |
| 5601 | q.text("%#x" % self.group_id) |
| 5602 | q.text(","); q.breakable() |
| 5603 | q.text("buckets = "); |
| 5604 | q.pp(self.buckets) |
| 5605 | q.breakable() |
| 5606 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5607 | |
| 5608 | message.subtypes[15] = group_mod |
| 5609 | |
| 5610 | class group_add(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5611 | version = 3 |
| 5612 | type = 15 |
| 5613 | command = 0 |
| 5614 | |
| 5615 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5616 | if xid != None: |
| 5617 | self.xid = xid |
| 5618 | else: |
| 5619 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5620 | if group_type != None: |
| 5621 | self.group_type = group_type |
| 5622 | else: |
| 5623 | self.group_type = 0 |
| 5624 | if group_id != None: |
| 5625 | self.group_id = group_id |
| 5626 | else: |
| 5627 | self.group_id = 0 |
| 5628 | if buckets != None: |
| 5629 | self.buckets = buckets |
| 5630 | else: |
| 5631 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5632 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5633 | |
| 5634 | def pack(self): |
| 5635 | packed = [] |
| 5636 | packed.append(struct.pack("!B", self.version)) |
| 5637 | packed.append(struct.pack("!B", self.type)) |
| 5638 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5639 | packed.append(struct.pack("!L", self.xid)) |
| 5640 | packed.append(struct.pack("!H", self.command)) |
| 5641 | packed.append(struct.pack("!B", self.group_type)) |
| 5642 | packed.append('\x00' * 1) |
| 5643 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5644 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5645 | length = sum([len(x) for x in packed]) |
| 5646 | packed[2] = struct.pack("!H", length) |
| 5647 | return ''.join(packed) |
| 5648 | |
| 5649 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5650 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5651 | obj = group_add() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5652 | _version = reader.read("!B")[0] |
| 5653 | assert(_version == 3) |
| 5654 | _type = reader.read("!B")[0] |
| 5655 | assert(_type == 15) |
| 5656 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5657 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5658 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5659 | obj.xid = reader.read("!L")[0] |
| 5660 | _command = reader.read("!H")[0] |
| 5661 | assert(_command == 0) |
| 5662 | obj.group_type = reader.read("!B")[0] |
| 5663 | reader.skip(1) |
| 5664 | obj.group_id = reader.read("!L")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5665 | obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5666 | return obj |
| 5667 | |
| 5668 | def __eq__(self, other): |
| 5669 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5670 | if self.xid != other.xid: return False |
| 5671 | if self.group_type != other.group_type: return False |
| 5672 | if self.group_id != other.group_id: return False |
| 5673 | if self.buckets != other.buckets: return False |
| 5674 | return True |
| 5675 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5676 | def pretty_print(self, q): |
| 5677 | q.text("group_add {") |
| 5678 | with q.group(): |
| 5679 | with q.indent(2): |
| 5680 | q.breakable() |
| 5681 | q.text("xid = "); |
| 5682 | if self.xid != None: |
| 5683 | q.text("%#x" % self.xid) |
| 5684 | else: |
| 5685 | q.text('None') |
| 5686 | q.text(","); q.breakable() |
| 5687 | q.text("group_type = "); |
| 5688 | q.text("%#x" % self.group_type) |
| 5689 | q.text(","); q.breakable() |
| 5690 | q.text("group_id = "); |
| 5691 | q.text("%#x" % self.group_id) |
| 5692 | q.text(","); q.breakable() |
| 5693 | q.text("buckets = "); |
| 5694 | q.pp(self.buckets) |
| 5695 | q.breakable() |
| 5696 | q.text('}') |
| 5697 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5698 | group_mod.subtypes[0] = group_add |
| 5699 | |
| 5700 | class group_delete(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5701 | version = 3 |
| 5702 | type = 15 |
| 5703 | command = 2 |
| 5704 | |
| 5705 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5706 | if xid != None: |
| 5707 | self.xid = xid |
| 5708 | else: |
| 5709 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5710 | if group_type != None: |
| 5711 | self.group_type = group_type |
| 5712 | else: |
| 5713 | self.group_type = 0 |
| 5714 | if group_id != None: |
| 5715 | self.group_id = group_id |
| 5716 | else: |
| 5717 | self.group_id = 0 |
| 5718 | if buckets != None: |
| 5719 | self.buckets = buckets |
| 5720 | else: |
| 5721 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5722 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5723 | |
| 5724 | def pack(self): |
| 5725 | packed = [] |
| 5726 | packed.append(struct.pack("!B", self.version)) |
| 5727 | packed.append(struct.pack("!B", self.type)) |
| 5728 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5729 | packed.append(struct.pack("!L", self.xid)) |
| 5730 | packed.append(struct.pack("!H", self.command)) |
| 5731 | packed.append(struct.pack("!B", self.group_type)) |
| 5732 | packed.append('\x00' * 1) |
| 5733 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5734 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5735 | length = sum([len(x) for x in packed]) |
| 5736 | packed[2] = struct.pack("!H", length) |
| 5737 | return ''.join(packed) |
| 5738 | |
| 5739 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5740 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5741 | obj = group_delete() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5742 | _version = reader.read("!B")[0] |
| 5743 | assert(_version == 3) |
| 5744 | _type = reader.read("!B")[0] |
| 5745 | assert(_type == 15) |
| 5746 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5747 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5748 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5749 | obj.xid = reader.read("!L")[0] |
| 5750 | _command = reader.read("!H")[0] |
| 5751 | assert(_command == 2) |
| 5752 | obj.group_type = reader.read("!B")[0] |
| 5753 | reader.skip(1) |
| 5754 | obj.group_id = reader.read("!L")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5755 | obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5756 | return obj |
| 5757 | |
| 5758 | def __eq__(self, other): |
| 5759 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5760 | if self.xid != other.xid: return False |
| 5761 | if self.group_type != other.group_type: return False |
| 5762 | if self.group_id != other.group_id: return False |
| 5763 | if self.buckets != other.buckets: return False |
| 5764 | return True |
| 5765 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 5766 | def pretty_print(self, q): |
| 5767 | q.text("group_delete {") |
| 5768 | with q.group(): |
| 5769 | with q.indent(2): |
| 5770 | q.breakable() |
| 5771 | q.text("xid = "); |
| 5772 | if self.xid != None: |
| 5773 | q.text("%#x" % self.xid) |
| 5774 | else: |
| 5775 | q.text('None') |
| 5776 | q.text(","); q.breakable() |
| 5777 | q.text("group_type = "); |
| 5778 | q.text("%#x" % self.group_type) |
| 5779 | q.text(","); q.breakable() |
| 5780 | q.text("group_id = "); |
| 5781 | q.text("%#x" % self.group_id) |
| 5782 | q.text(","); q.breakable() |
| 5783 | q.text("buckets = "); |
| 5784 | q.pp(self.buckets) |
| 5785 | q.breakable() |
| 5786 | q.text('}') |
| 5787 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5788 | group_mod.subtypes[2] = group_delete |
| 5789 | |
| 5790 | class group_desc_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5791 | version = 3 |
| 5792 | type = 19 |
| 5793 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5794 | |
| 5795 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5796 | if xid != None: |
| 5797 | self.xid = xid |
| 5798 | else: |
| 5799 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5800 | if flags != None: |
| 5801 | self.flags = flags |
| 5802 | else: |
| 5803 | self.flags = 0 |
| 5804 | if entries != None: |
| 5805 | self.entries = entries |
| 5806 | else: |
| 5807 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5808 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5809 | |
| 5810 | def pack(self): |
| 5811 | packed = [] |
| 5812 | packed.append(struct.pack("!B", self.version)) |
| 5813 | packed.append(struct.pack("!B", self.type)) |
| 5814 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5815 | packed.append(struct.pack("!L", self.xid)) |
| 5816 | packed.append(struct.pack("!H", self.stats_type)) |
| 5817 | packed.append(struct.pack("!H", self.flags)) |
| 5818 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5819 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5820 | length = sum([len(x) for x in packed]) |
| 5821 | packed[2] = struct.pack("!H", length) |
| 5822 | return ''.join(packed) |
| 5823 | |
| 5824 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5825 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5826 | obj = group_desc_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5827 | _version = reader.read("!B")[0] |
| 5828 | assert(_version == 3) |
| 5829 | _type = reader.read("!B")[0] |
| 5830 | assert(_type == 19) |
| 5831 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5832 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5833 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5834 | obj.xid = reader.read("!L")[0] |
| 5835 | _stats_type = reader.read("!H")[0] |
| 5836 | assert(_stats_type == 7) |
| 5837 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5838 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 5839 | obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.group_desc_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5840 | return obj |
| 5841 | |
| 5842 | def __eq__(self, other): |
| 5843 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5844 | if self.xid != other.xid: return False |
| 5845 | if self.flags != other.flags: return False |
| 5846 | if self.entries != other.entries: return False |
| 5847 | return True |
| 5848 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5849 | def pretty_print(self, q): |
| 5850 | q.text("group_desc_stats_reply {") |
| 5851 | with q.group(): |
| 5852 | with q.indent(2): |
| 5853 | q.breakable() |
| 5854 | q.text("xid = "); |
| 5855 | if self.xid != None: |
| 5856 | q.text("%#x" % self.xid) |
| 5857 | else: |
| 5858 | q.text('None') |
| 5859 | q.text(","); q.breakable() |
| 5860 | q.text("flags = "); |
| 5861 | q.text("%#x" % self.flags) |
| 5862 | q.text(","); q.breakable() |
| 5863 | q.text("entries = "); |
| 5864 | q.pp(self.entries) |
| 5865 | q.breakable() |
| 5866 | q.text('}') |
| 5867 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5868 | stats_reply.subtypes[7] = group_desc_stats_reply |
| 5869 | |
| 5870 | class group_desc_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5871 | version = 3 |
| 5872 | type = 18 |
| 5873 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5874 | |
| 5875 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5876 | if xid != None: |
| 5877 | self.xid = xid |
| 5878 | else: |
| 5879 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5880 | if flags != None: |
| 5881 | self.flags = flags |
| 5882 | else: |
| 5883 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5884 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5885 | |
| 5886 | def pack(self): |
| 5887 | packed = [] |
| 5888 | packed.append(struct.pack("!B", self.version)) |
| 5889 | packed.append(struct.pack("!B", self.type)) |
| 5890 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5891 | packed.append(struct.pack("!L", self.xid)) |
| 5892 | packed.append(struct.pack("!H", self.stats_type)) |
| 5893 | packed.append(struct.pack("!H", self.flags)) |
| 5894 | packed.append('\x00' * 4) |
| 5895 | length = sum([len(x) for x in packed]) |
| 5896 | packed[2] = struct.pack("!H", length) |
| 5897 | return ''.join(packed) |
| 5898 | |
| 5899 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5900 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5901 | obj = group_desc_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5902 | _version = reader.read("!B")[0] |
| 5903 | assert(_version == 3) |
| 5904 | _type = reader.read("!B")[0] |
| 5905 | assert(_type == 18) |
| 5906 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5907 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 5908 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5909 | obj.xid = reader.read("!L")[0] |
| 5910 | _stats_type = reader.read("!H")[0] |
| 5911 | assert(_stats_type == 7) |
| 5912 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5913 | reader.skip(4) |
| 5914 | return obj |
| 5915 | |
| 5916 | def __eq__(self, other): |
| 5917 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5918 | if self.xid != other.xid: return False |
| 5919 | if self.flags != other.flags: return False |
| 5920 | return True |
| 5921 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5922 | def pretty_print(self, q): |
| 5923 | q.text("group_desc_stats_request {") |
| 5924 | with q.group(): |
| 5925 | with q.indent(2): |
| 5926 | q.breakable() |
| 5927 | q.text("xid = "); |
| 5928 | if self.xid != None: |
| 5929 | q.text("%#x" % self.xid) |
| 5930 | else: |
| 5931 | q.text('None') |
| 5932 | q.text(","); q.breakable() |
| 5933 | q.text("flags = "); |
| 5934 | q.text("%#x" % self.flags) |
| 5935 | q.breakable() |
| 5936 | q.text('}') |
| 5937 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5938 | stats_request.subtypes[7] = group_desc_stats_request |
| 5939 | |
| 5940 | class group_features_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5941 | version = 3 |
| 5942 | type = 19 |
| 5943 | stats_type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5944 | |
| 5945 | def __init__(self, xid=None, flags=None, types=None, capabilities=None, max_groups_all=None, max_groups_select=None, max_groups_indirect=None, max_groups_ff=None, actions_all=None, actions_select=None, actions_indirect=None, actions_ff=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5946 | if xid != None: |
| 5947 | self.xid = xid |
| 5948 | else: |
| 5949 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5950 | if flags != None: |
| 5951 | self.flags = flags |
| 5952 | else: |
| 5953 | self.flags = 0 |
| 5954 | if types != None: |
| 5955 | self.types = types |
| 5956 | else: |
| 5957 | self.types = 0 |
| 5958 | if capabilities != None: |
| 5959 | self.capabilities = capabilities |
| 5960 | else: |
| 5961 | self.capabilities = 0 |
| 5962 | if max_groups_all != None: |
| 5963 | self.max_groups_all = max_groups_all |
| 5964 | else: |
| 5965 | self.max_groups_all = 0 |
| 5966 | if max_groups_select != None: |
| 5967 | self.max_groups_select = max_groups_select |
| 5968 | else: |
| 5969 | self.max_groups_select = 0 |
| 5970 | if max_groups_indirect != None: |
| 5971 | self.max_groups_indirect = max_groups_indirect |
| 5972 | else: |
| 5973 | self.max_groups_indirect = 0 |
| 5974 | if max_groups_ff != None: |
| 5975 | self.max_groups_ff = max_groups_ff |
| 5976 | else: |
| 5977 | self.max_groups_ff = 0 |
| 5978 | if actions_all != None: |
| 5979 | self.actions_all = actions_all |
| 5980 | else: |
| 5981 | self.actions_all = 0 |
| 5982 | if actions_select != None: |
| 5983 | self.actions_select = actions_select |
| 5984 | else: |
| 5985 | self.actions_select = 0 |
| 5986 | if actions_indirect != None: |
| 5987 | self.actions_indirect = actions_indirect |
| 5988 | else: |
| 5989 | self.actions_indirect = 0 |
| 5990 | if actions_ff != None: |
| 5991 | self.actions_ff = actions_ff |
| 5992 | else: |
| 5993 | self.actions_ff = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 5994 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5995 | |
| 5996 | def pack(self): |
| 5997 | packed = [] |
| 5998 | packed.append(struct.pack("!B", self.version)) |
| 5999 | packed.append(struct.pack("!B", self.type)) |
| 6000 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6001 | packed.append(struct.pack("!L", self.xid)) |
| 6002 | packed.append(struct.pack("!H", self.stats_type)) |
| 6003 | packed.append(struct.pack("!H", self.flags)) |
| 6004 | packed.append('\x00' * 4) |
| 6005 | packed.append(struct.pack("!L", self.types)) |
| 6006 | packed.append(struct.pack("!L", self.capabilities)) |
| 6007 | packed.append(struct.pack("!L", self.max_groups_all)) |
| 6008 | packed.append(struct.pack("!L", self.max_groups_select)) |
| 6009 | packed.append(struct.pack("!L", self.max_groups_indirect)) |
| 6010 | packed.append(struct.pack("!L", self.max_groups_ff)) |
| 6011 | packed.append(struct.pack("!L", self.actions_all)) |
| 6012 | packed.append(struct.pack("!L", self.actions_select)) |
| 6013 | packed.append(struct.pack("!L", self.actions_indirect)) |
| 6014 | packed.append(struct.pack("!L", self.actions_ff)) |
| 6015 | length = sum([len(x) for x in packed]) |
| 6016 | packed[2] = struct.pack("!H", length) |
| 6017 | return ''.join(packed) |
| 6018 | |
| 6019 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6020 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6021 | obj = group_features_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6022 | _version = reader.read("!B")[0] |
| 6023 | assert(_version == 3) |
| 6024 | _type = reader.read("!B")[0] |
| 6025 | assert(_type == 19) |
| 6026 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6027 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6028 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6029 | obj.xid = reader.read("!L")[0] |
| 6030 | _stats_type = reader.read("!H")[0] |
| 6031 | assert(_stats_type == 8) |
| 6032 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6033 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6034 | obj.types = reader.read("!L")[0] |
| 6035 | obj.capabilities = reader.read("!L")[0] |
| 6036 | obj.max_groups_all = reader.read("!L")[0] |
| 6037 | obj.max_groups_select = reader.read("!L")[0] |
| 6038 | obj.max_groups_indirect = reader.read("!L")[0] |
| 6039 | obj.max_groups_ff = reader.read("!L")[0] |
| 6040 | obj.actions_all = reader.read("!L")[0] |
| 6041 | obj.actions_select = reader.read("!L")[0] |
| 6042 | obj.actions_indirect = reader.read("!L")[0] |
| 6043 | obj.actions_ff = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6044 | return obj |
| 6045 | |
| 6046 | def __eq__(self, other): |
| 6047 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6048 | if self.xid != other.xid: return False |
| 6049 | if self.flags != other.flags: return False |
| 6050 | if self.types != other.types: return False |
| 6051 | if self.capabilities != other.capabilities: return False |
| 6052 | if self.max_groups_all != other.max_groups_all: return False |
| 6053 | if self.max_groups_select != other.max_groups_select: return False |
| 6054 | if self.max_groups_indirect != other.max_groups_indirect: return False |
| 6055 | if self.max_groups_ff != other.max_groups_ff: return False |
| 6056 | if self.actions_all != other.actions_all: return False |
| 6057 | if self.actions_select != other.actions_select: return False |
| 6058 | if self.actions_indirect != other.actions_indirect: return False |
| 6059 | if self.actions_ff != other.actions_ff: return False |
| 6060 | return True |
| 6061 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6062 | def pretty_print(self, q): |
| 6063 | q.text("group_features_stats_reply {") |
| 6064 | with q.group(): |
| 6065 | with q.indent(2): |
| 6066 | q.breakable() |
| 6067 | q.text("xid = "); |
| 6068 | if self.xid != None: |
| 6069 | q.text("%#x" % self.xid) |
| 6070 | else: |
| 6071 | q.text('None') |
| 6072 | q.text(","); q.breakable() |
| 6073 | q.text("flags = "); |
| 6074 | q.text("%#x" % self.flags) |
| 6075 | q.text(","); q.breakable() |
| 6076 | q.text("types = "); |
| 6077 | q.text("%#x" % self.types) |
| 6078 | q.text(","); q.breakable() |
| 6079 | q.text("capabilities = "); |
| 6080 | q.text("%#x" % self.capabilities) |
| 6081 | q.text(","); q.breakable() |
| 6082 | q.text("max_groups_all = "); |
| 6083 | q.text("%#x" % self.max_groups_all) |
| 6084 | q.text(","); q.breakable() |
| 6085 | q.text("max_groups_select = "); |
| 6086 | q.text("%#x" % self.max_groups_select) |
| 6087 | q.text(","); q.breakable() |
| 6088 | q.text("max_groups_indirect = "); |
| 6089 | q.text("%#x" % self.max_groups_indirect) |
| 6090 | q.text(","); q.breakable() |
| 6091 | q.text("max_groups_ff = "); |
| 6092 | q.text("%#x" % self.max_groups_ff) |
| 6093 | q.text(","); q.breakable() |
| 6094 | q.text("actions_all = "); |
| 6095 | q.text("%#x" % self.actions_all) |
| 6096 | q.text(","); q.breakable() |
| 6097 | q.text("actions_select = "); |
| 6098 | q.text("%#x" % self.actions_select) |
| 6099 | q.text(","); q.breakable() |
| 6100 | q.text("actions_indirect = "); |
| 6101 | q.text("%#x" % self.actions_indirect) |
| 6102 | q.text(","); q.breakable() |
| 6103 | q.text("actions_ff = "); |
| 6104 | q.text("%#x" % self.actions_ff) |
| 6105 | q.breakable() |
| 6106 | q.text('}') |
| 6107 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6108 | stats_reply.subtypes[8] = group_features_stats_reply |
| 6109 | |
| 6110 | class group_features_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6111 | version = 3 |
| 6112 | type = 18 |
| 6113 | stats_type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6114 | |
| 6115 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6116 | if xid != None: |
| 6117 | self.xid = xid |
| 6118 | else: |
| 6119 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6120 | if flags != None: |
| 6121 | self.flags = flags |
| 6122 | else: |
| 6123 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6124 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6125 | |
| 6126 | def pack(self): |
| 6127 | packed = [] |
| 6128 | packed.append(struct.pack("!B", self.version)) |
| 6129 | packed.append(struct.pack("!B", self.type)) |
| 6130 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6131 | packed.append(struct.pack("!L", self.xid)) |
| 6132 | packed.append(struct.pack("!H", self.stats_type)) |
| 6133 | packed.append(struct.pack("!H", self.flags)) |
| 6134 | packed.append('\x00' * 4) |
| 6135 | length = sum([len(x) for x in packed]) |
| 6136 | packed[2] = struct.pack("!H", length) |
| 6137 | return ''.join(packed) |
| 6138 | |
| 6139 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6140 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6141 | obj = group_features_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6142 | _version = reader.read("!B")[0] |
| 6143 | assert(_version == 3) |
| 6144 | _type = reader.read("!B")[0] |
| 6145 | assert(_type == 18) |
| 6146 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6147 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6148 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6149 | obj.xid = reader.read("!L")[0] |
| 6150 | _stats_type = reader.read("!H")[0] |
| 6151 | assert(_stats_type == 8) |
| 6152 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6153 | reader.skip(4) |
| 6154 | return obj |
| 6155 | |
| 6156 | def __eq__(self, other): |
| 6157 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6158 | if self.xid != other.xid: return False |
| 6159 | if self.flags != other.flags: return False |
| 6160 | return True |
| 6161 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6162 | def pretty_print(self, q): |
| 6163 | q.text("group_features_stats_request {") |
| 6164 | with q.group(): |
| 6165 | with q.indent(2): |
| 6166 | q.breakable() |
| 6167 | q.text("xid = "); |
| 6168 | if self.xid != None: |
| 6169 | q.text("%#x" % self.xid) |
| 6170 | else: |
| 6171 | q.text('None') |
| 6172 | q.text(","); q.breakable() |
| 6173 | q.text("flags = "); |
| 6174 | q.text("%#x" % self.flags) |
| 6175 | q.breakable() |
| 6176 | q.text('}') |
| 6177 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6178 | stats_request.subtypes[8] = group_features_stats_request |
| 6179 | |
| 6180 | class group_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6181 | version = 3 |
| 6182 | type = 1 |
| 6183 | err_type = 6 |
| 6184 | |
| 6185 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6186 | if xid != None: |
| 6187 | self.xid = xid |
| 6188 | else: |
| 6189 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6190 | if code != None: |
| 6191 | self.code = code |
| 6192 | else: |
| 6193 | self.code = 0 |
| 6194 | if data != None: |
| 6195 | self.data = data |
| 6196 | else: |
| 6197 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6198 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6199 | |
| 6200 | def pack(self): |
| 6201 | packed = [] |
| 6202 | packed.append(struct.pack("!B", self.version)) |
| 6203 | packed.append(struct.pack("!B", self.type)) |
| 6204 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6205 | packed.append(struct.pack("!L", self.xid)) |
| 6206 | packed.append(struct.pack("!H", self.err_type)) |
| 6207 | packed.append(struct.pack("!H", self.code)) |
| 6208 | packed.append(self.data) |
| 6209 | length = sum([len(x) for x in packed]) |
| 6210 | packed[2] = struct.pack("!H", length) |
| 6211 | return ''.join(packed) |
| 6212 | |
| 6213 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6214 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6215 | obj = group_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6216 | _version = reader.read("!B")[0] |
| 6217 | assert(_version == 3) |
| 6218 | _type = reader.read("!B")[0] |
| 6219 | assert(_type == 1) |
| 6220 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6221 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6222 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6223 | obj.xid = reader.read("!L")[0] |
| 6224 | _err_type = reader.read("!H")[0] |
| 6225 | assert(_err_type == 6) |
| 6226 | obj.code = reader.read("!H")[0] |
| 6227 | obj.data = str(reader.read_all()) |
| 6228 | return obj |
| 6229 | |
| 6230 | def __eq__(self, other): |
| 6231 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6232 | if self.xid != other.xid: return False |
| 6233 | if self.code != other.code: return False |
| 6234 | if self.data != other.data: return False |
| 6235 | return True |
| 6236 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6237 | def pretty_print(self, q): |
| 6238 | q.text("group_mod_failed_error_msg {") |
| 6239 | with q.group(): |
| 6240 | with q.indent(2): |
| 6241 | q.breakable() |
| 6242 | q.text("xid = "); |
| 6243 | if self.xid != None: |
| 6244 | q.text("%#x" % self.xid) |
| 6245 | else: |
| 6246 | q.text('None') |
| 6247 | q.text(","); q.breakable() |
| 6248 | q.text("code = "); |
| 6249 | q.text("%#x" % self.code) |
| 6250 | q.text(","); q.breakable() |
| 6251 | q.text("data = "); |
| 6252 | q.pp(self.data) |
| 6253 | q.breakable() |
| 6254 | q.text('}') |
| 6255 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6256 | error_msg.subtypes[6] = group_mod_failed_error_msg |
| 6257 | |
| 6258 | class group_modify(group_mod): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6259 | version = 3 |
| 6260 | type = 15 |
| 6261 | command = 1 |
| 6262 | |
| 6263 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6264 | if xid != None: |
| 6265 | self.xid = xid |
| 6266 | else: |
| 6267 | self.xid = None |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6268 | if group_type != None: |
| 6269 | self.group_type = group_type |
| 6270 | else: |
| 6271 | self.group_type = 0 |
| 6272 | if group_id != None: |
| 6273 | self.group_id = group_id |
| 6274 | else: |
| 6275 | self.group_id = 0 |
| 6276 | if buckets != None: |
| 6277 | self.buckets = buckets |
| 6278 | else: |
| 6279 | self.buckets = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6280 | return |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6281 | |
| 6282 | def pack(self): |
| 6283 | packed = [] |
| 6284 | packed.append(struct.pack("!B", self.version)) |
| 6285 | packed.append(struct.pack("!B", self.type)) |
| 6286 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6287 | packed.append(struct.pack("!L", self.xid)) |
| 6288 | packed.append(struct.pack("!H", self.command)) |
| 6289 | packed.append(struct.pack("!B", self.group_type)) |
| 6290 | packed.append('\x00' * 1) |
| 6291 | packed.append(struct.pack("!L", self.group_id)) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6292 | packed.append(loxi.generic_util.pack_list(self.buckets)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6293 | length = sum([len(x) for x in packed]) |
| 6294 | packed[2] = struct.pack("!H", length) |
| 6295 | return ''.join(packed) |
| 6296 | |
| 6297 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6298 | def unpack(reader): |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6299 | obj = group_modify() |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6300 | _version = reader.read("!B")[0] |
| 6301 | assert(_version == 3) |
| 6302 | _type = reader.read("!B")[0] |
| 6303 | assert(_type == 15) |
| 6304 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6305 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6306 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6307 | obj.xid = reader.read("!L")[0] |
| 6308 | _command = reader.read("!H")[0] |
| 6309 | assert(_command == 1) |
| 6310 | obj.group_type = reader.read("!B")[0] |
| 6311 | reader.skip(1) |
| 6312 | obj.group_id = reader.read("!L")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 6313 | obj.buckets = loxi.generic_util.unpack_list(reader, ofp.common.bucket.unpack) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6314 | return obj |
| 6315 | |
| 6316 | def __eq__(self, other): |
| 6317 | if type(self) != type(other): return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6318 | if self.xid != other.xid: return False |
| 6319 | if self.group_type != other.group_type: return False |
| 6320 | if self.group_id != other.group_id: return False |
| 6321 | if self.buckets != other.buckets: return False |
| 6322 | return True |
| 6323 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6324 | def pretty_print(self, q): |
| 6325 | q.text("group_modify {") |
| 6326 | with q.group(): |
| 6327 | with q.indent(2): |
| 6328 | q.breakable() |
| 6329 | q.text("xid = "); |
| 6330 | if self.xid != None: |
| 6331 | q.text("%#x" % self.xid) |
| 6332 | else: |
| 6333 | q.text('None') |
| 6334 | q.text(","); q.breakable() |
| 6335 | q.text("group_type = "); |
| 6336 | q.text("%#x" % self.group_type) |
| 6337 | q.text(","); q.breakable() |
| 6338 | q.text("group_id = "); |
| 6339 | q.text("%#x" % self.group_id) |
| 6340 | q.text(","); q.breakable() |
| 6341 | q.text("buckets = "); |
| 6342 | q.pp(self.buckets) |
| 6343 | q.breakable() |
| 6344 | q.text('}') |
| 6345 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6346 | group_mod.subtypes[1] = group_modify |
| 6347 | |
| 6348 | class group_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6349 | version = 3 |
| 6350 | type = 19 |
| 6351 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6352 | |
| 6353 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6354 | if xid != None: |
| 6355 | self.xid = xid |
| 6356 | else: |
| 6357 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6358 | if flags != None: |
| 6359 | self.flags = flags |
| 6360 | else: |
| 6361 | self.flags = 0 |
| 6362 | if entries != None: |
| 6363 | self.entries = entries |
| 6364 | else: |
| 6365 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6366 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6367 | |
| 6368 | def pack(self): |
| 6369 | packed = [] |
| 6370 | packed.append(struct.pack("!B", self.version)) |
| 6371 | packed.append(struct.pack("!B", self.type)) |
| 6372 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6373 | packed.append(struct.pack("!L", self.xid)) |
| 6374 | packed.append(struct.pack("!H", self.stats_type)) |
| 6375 | packed.append(struct.pack("!H", self.flags)) |
| 6376 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6377 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6378 | length = sum([len(x) for x in packed]) |
| 6379 | packed[2] = struct.pack("!H", length) |
| 6380 | return ''.join(packed) |
| 6381 | |
| 6382 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6383 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6384 | obj = group_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6385 | _version = reader.read("!B")[0] |
| 6386 | assert(_version == 3) |
| 6387 | _type = reader.read("!B")[0] |
| 6388 | assert(_type == 19) |
| 6389 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6390 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6391 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6392 | obj.xid = reader.read("!L")[0] |
| 6393 | _stats_type = reader.read("!H")[0] |
| 6394 | assert(_stats_type == 6) |
| 6395 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6396 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 6397 | obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.group_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6398 | return obj |
| 6399 | |
| 6400 | def __eq__(self, other): |
| 6401 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6402 | if self.xid != other.xid: return False |
| 6403 | if self.flags != other.flags: return False |
| 6404 | if self.entries != other.entries: return False |
| 6405 | return True |
| 6406 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6407 | def pretty_print(self, q): |
| 6408 | q.text("group_stats_reply {") |
| 6409 | with q.group(): |
| 6410 | with q.indent(2): |
| 6411 | q.breakable() |
| 6412 | q.text("xid = "); |
| 6413 | if self.xid != None: |
| 6414 | q.text("%#x" % self.xid) |
| 6415 | else: |
| 6416 | q.text('None') |
| 6417 | q.text(","); q.breakable() |
| 6418 | q.text("flags = "); |
| 6419 | q.text("%#x" % self.flags) |
| 6420 | q.text(","); q.breakable() |
| 6421 | q.text("entries = "); |
| 6422 | q.pp(self.entries) |
| 6423 | q.breakable() |
| 6424 | q.text('}') |
| 6425 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6426 | stats_reply.subtypes[6] = group_stats_reply |
| 6427 | |
| 6428 | class group_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6429 | version = 3 |
| 6430 | type = 18 |
| 6431 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6432 | |
| 6433 | def __init__(self, xid=None, flags=None, group_id=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6434 | if xid != None: |
| 6435 | self.xid = xid |
| 6436 | else: |
| 6437 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6438 | if flags != None: |
| 6439 | self.flags = flags |
| 6440 | else: |
| 6441 | self.flags = 0 |
| 6442 | if group_id != None: |
| 6443 | self.group_id = group_id |
| 6444 | else: |
| 6445 | self.group_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6446 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6447 | |
| 6448 | def pack(self): |
| 6449 | packed = [] |
| 6450 | packed.append(struct.pack("!B", self.version)) |
| 6451 | packed.append(struct.pack("!B", self.type)) |
| 6452 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6453 | packed.append(struct.pack("!L", self.xid)) |
| 6454 | packed.append(struct.pack("!H", self.stats_type)) |
| 6455 | packed.append(struct.pack("!H", self.flags)) |
| 6456 | packed.append('\x00' * 4) |
| 6457 | packed.append(struct.pack("!L", self.group_id)) |
| 6458 | packed.append('\x00' * 4) |
| 6459 | length = sum([len(x) for x in packed]) |
| 6460 | packed[2] = struct.pack("!H", length) |
| 6461 | return ''.join(packed) |
| 6462 | |
| 6463 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6464 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6465 | obj = group_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6466 | _version = reader.read("!B")[0] |
| 6467 | assert(_version == 3) |
| 6468 | _type = reader.read("!B")[0] |
| 6469 | assert(_type == 18) |
| 6470 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6471 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6472 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6473 | obj.xid = reader.read("!L")[0] |
| 6474 | _stats_type = reader.read("!H")[0] |
| 6475 | assert(_stats_type == 6) |
| 6476 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6477 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6478 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6479 | reader.skip(4) |
| 6480 | return obj |
| 6481 | |
| 6482 | def __eq__(self, other): |
| 6483 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6484 | if self.xid != other.xid: return False |
| 6485 | if self.flags != other.flags: return False |
| 6486 | if self.group_id != other.group_id: return False |
| 6487 | return True |
| 6488 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6489 | def pretty_print(self, q): |
| 6490 | q.text("group_stats_request {") |
| 6491 | with q.group(): |
| 6492 | with q.indent(2): |
| 6493 | q.breakable() |
| 6494 | q.text("xid = "); |
| 6495 | if self.xid != None: |
| 6496 | q.text("%#x" % self.xid) |
| 6497 | else: |
| 6498 | q.text('None') |
| 6499 | q.text(","); q.breakable() |
| 6500 | q.text("flags = "); |
| 6501 | q.text("%#x" % self.flags) |
| 6502 | q.text(","); q.breakable() |
| 6503 | q.text("group_id = "); |
| 6504 | q.text("%#x" % self.group_id) |
| 6505 | q.breakable() |
| 6506 | q.text('}') |
| 6507 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6508 | stats_request.subtypes[6] = group_stats_request |
| 6509 | |
| 6510 | class hello(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6511 | version = 3 |
| 6512 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6513 | |
| 6514 | def __init__(self, xid=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6515 | if xid != None: |
| 6516 | self.xid = xid |
| 6517 | else: |
| 6518 | self.xid = None |
| 6519 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6520 | |
| 6521 | def pack(self): |
| 6522 | packed = [] |
| 6523 | packed.append(struct.pack("!B", self.version)) |
| 6524 | packed.append(struct.pack("!B", self.type)) |
| 6525 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6526 | packed.append(struct.pack("!L", self.xid)) |
| 6527 | length = sum([len(x) for x in packed]) |
| 6528 | packed[2] = struct.pack("!H", length) |
| 6529 | return ''.join(packed) |
| 6530 | |
| 6531 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6532 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6533 | obj = hello() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6534 | _version = reader.read("!B")[0] |
| 6535 | assert(_version == 3) |
| 6536 | _type = reader.read("!B")[0] |
| 6537 | assert(_type == 0) |
| 6538 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6539 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6540 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6541 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6542 | return obj |
| 6543 | |
| 6544 | def __eq__(self, other): |
| 6545 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6546 | if self.xid != other.xid: return False |
| 6547 | return True |
| 6548 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6549 | def pretty_print(self, q): |
| 6550 | q.text("hello {") |
| 6551 | with q.group(): |
| 6552 | with q.indent(2): |
| 6553 | q.breakable() |
| 6554 | q.text("xid = "); |
| 6555 | if self.xid != None: |
| 6556 | q.text("%#x" % self.xid) |
| 6557 | else: |
| 6558 | q.text('None') |
| 6559 | q.breakable() |
| 6560 | q.text('}') |
| 6561 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6562 | message.subtypes[0] = hello |
| 6563 | |
| 6564 | class hello_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6565 | version = 3 |
| 6566 | type = 1 |
| 6567 | err_type = 0 |
| 6568 | |
| 6569 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6570 | if xid != None: |
| 6571 | self.xid = xid |
| 6572 | else: |
| 6573 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6574 | if code != None: |
| 6575 | self.code = code |
| 6576 | else: |
| 6577 | self.code = 0 |
| 6578 | if data != None: |
| 6579 | self.data = data |
| 6580 | else: |
| 6581 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6582 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6583 | |
| 6584 | def pack(self): |
| 6585 | packed = [] |
| 6586 | packed.append(struct.pack("!B", self.version)) |
| 6587 | packed.append(struct.pack("!B", self.type)) |
| 6588 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6589 | packed.append(struct.pack("!L", self.xid)) |
| 6590 | packed.append(struct.pack("!H", self.err_type)) |
| 6591 | packed.append(struct.pack("!H", self.code)) |
| 6592 | packed.append(self.data) |
| 6593 | length = sum([len(x) for x in packed]) |
| 6594 | packed[2] = struct.pack("!H", length) |
| 6595 | return ''.join(packed) |
| 6596 | |
| 6597 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6598 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6599 | obj = hello_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6600 | _version = reader.read("!B")[0] |
| 6601 | assert(_version == 3) |
| 6602 | _type = reader.read("!B")[0] |
| 6603 | assert(_type == 1) |
| 6604 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6605 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6606 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6607 | obj.xid = reader.read("!L")[0] |
| 6608 | _err_type = reader.read("!H")[0] |
| 6609 | assert(_err_type == 0) |
| 6610 | obj.code = reader.read("!H")[0] |
| 6611 | obj.data = str(reader.read_all()) |
| 6612 | return obj |
| 6613 | |
| 6614 | def __eq__(self, other): |
| 6615 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6616 | if self.xid != other.xid: return False |
| 6617 | if self.code != other.code: return False |
| 6618 | if self.data != other.data: return False |
| 6619 | return True |
| 6620 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6621 | def pretty_print(self, q): |
| 6622 | q.text("hello_failed_error_msg {") |
| 6623 | with q.group(): |
| 6624 | with q.indent(2): |
| 6625 | q.breakable() |
| 6626 | q.text("xid = "); |
| 6627 | if self.xid != None: |
| 6628 | q.text("%#x" % self.xid) |
| 6629 | else: |
| 6630 | q.text('None') |
| 6631 | q.text(","); q.breakable() |
| 6632 | q.text("code = "); |
| 6633 | q.text("%#x" % self.code) |
| 6634 | q.text(","); q.breakable() |
| 6635 | q.text("data = "); |
| 6636 | q.pp(self.data) |
| 6637 | q.breakable() |
| 6638 | q.text('}') |
| 6639 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6640 | error_msg.subtypes[0] = hello_failed_error_msg |
| 6641 | |
| 6642 | class nicira_header(experimenter): |
| 6643 | subtypes = {} |
| 6644 | |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6645 | version = 3 |
| 6646 | type = 4 |
| 6647 | experimenter = 8992 |
| 6648 | |
| 6649 | def __init__(self, xid=None, subtype=None): |
| 6650 | if xid != None: |
| 6651 | self.xid = xid |
| 6652 | else: |
| 6653 | self.xid = None |
| 6654 | if subtype != None: |
| 6655 | self.subtype = subtype |
| 6656 | else: |
| 6657 | self.subtype = 0 |
| 6658 | return |
| 6659 | |
| 6660 | def pack(self): |
| 6661 | packed = [] |
| 6662 | packed.append(struct.pack("!B", self.version)) |
| 6663 | packed.append(struct.pack("!B", self.type)) |
| 6664 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6665 | packed.append(struct.pack("!L", self.xid)) |
| 6666 | packed.append(struct.pack("!L", self.experimenter)) |
| 6667 | packed.append(struct.pack("!L", self.subtype)) |
| 6668 | length = sum([len(x) for x in packed]) |
| 6669 | packed[2] = struct.pack("!H", length) |
| 6670 | return ''.join(packed) |
| 6671 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6672 | @staticmethod |
| 6673 | def unpack(reader): |
| 6674 | subtype, = reader.peek('!L', 12) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6675 | subclass = nicira_header.subtypes.get(subtype) |
| 6676 | if subclass: |
| 6677 | return subclass.unpack(reader) |
| 6678 | |
| 6679 | obj = nicira_header() |
| 6680 | _version = reader.read("!B")[0] |
| 6681 | assert(_version == 3) |
| 6682 | _type = reader.read("!B")[0] |
| 6683 | assert(_type == 4) |
| 6684 | _length = reader.read("!H")[0] |
| 6685 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6686 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 95f7fc9 | 2014-01-27 17:08:16 -0800 | [diff] [blame] | 6687 | obj.xid = reader.read("!L")[0] |
| 6688 | _experimenter = reader.read("!L")[0] |
| 6689 | assert(_experimenter == 8992) |
| 6690 | obj.subtype = reader.read("!L")[0] |
| 6691 | return obj |
| 6692 | |
| 6693 | def __eq__(self, other): |
| 6694 | if type(self) != type(other): return False |
| 6695 | if self.xid != other.xid: return False |
| 6696 | if self.subtype != other.subtype: return False |
| 6697 | return True |
| 6698 | |
| 6699 | def pretty_print(self, q): |
| 6700 | q.text("nicira_header {") |
| 6701 | with q.group(): |
| 6702 | with q.indent(2): |
| 6703 | q.breakable() |
| 6704 | q.text("xid = "); |
| 6705 | if self.xid != None: |
| 6706 | q.text("%#x" % self.xid) |
| 6707 | else: |
| 6708 | q.text('None') |
| 6709 | q.breakable() |
| 6710 | q.text('}') |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6711 | |
| 6712 | experimenter.subtypes[8992] = nicira_header |
| 6713 | |
| 6714 | class packet_in(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6715 | version = 3 |
| 6716 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6717 | |
| 6718 | def __init__(self, xid=None, buffer_id=None, total_len=None, reason=None, table_id=None, match=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6719 | if xid != None: |
| 6720 | self.xid = xid |
| 6721 | else: |
| 6722 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6723 | if buffer_id != None: |
| 6724 | self.buffer_id = buffer_id |
| 6725 | else: |
| 6726 | self.buffer_id = 0 |
| 6727 | if total_len != None: |
| 6728 | self.total_len = total_len |
| 6729 | else: |
| 6730 | self.total_len = 0 |
| 6731 | if reason != None: |
| 6732 | self.reason = reason |
| 6733 | else: |
| 6734 | self.reason = 0 |
| 6735 | if table_id != None: |
| 6736 | self.table_id = table_id |
| 6737 | else: |
| 6738 | self.table_id = 0 |
| 6739 | if match != None: |
| 6740 | self.match = match |
| 6741 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 6742 | self.match = ofp.match() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6743 | if data != None: |
| 6744 | self.data = data |
| 6745 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6746 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6747 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6748 | |
| 6749 | def pack(self): |
| 6750 | packed = [] |
| 6751 | packed.append(struct.pack("!B", self.version)) |
| 6752 | packed.append(struct.pack("!B", self.type)) |
| 6753 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6754 | packed.append(struct.pack("!L", self.xid)) |
| 6755 | packed.append(struct.pack("!L", self.buffer_id)) |
| 6756 | packed.append(struct.pack("!H", self.total_len)) |
| 6757 | packed.append(struct.pack("!B", self.reason)) |
| 6758 | packed.append(struct.pack("!B", self.table_id)) |
| 6759 | packed.append(self.match.pack()) |
| 6760 | packed.append('\x00' * 2) |
| 6761 | packed.append(self.data) |
| 6762 | length = sum([len(x) for x in packed]) |
| 6763 | packed[2] = struct.pack("!H", length) |
| 6764 | return ''.join(packed) |
| 6765 | |
| 6766 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6767 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6768 | obj = packet_in() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6769 | _version = reader.read("!B")[0] |
| 6770 | assert(_version == 3) |
| 6771 | _type = reader.read("!B")[0] |
| 6772 | assert(_type == 10) |
| 6773 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6774 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6775 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6776 | obj.xid = reader.read("!L")[0] |
| 6777 | obj.buffer_id = reader.read("!L")[0] |
| 6778 | obj.total_len = reader.read("!H")[0] |
| 6779 | obj.reason = reader.read("!B")[0] |
| 6780 | obj.table_id = reader.read("!B")[0] |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 6781 | obj.match = ofp.match.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6782 | reader.skip(2) |
| 6783 | obj.data = str(reader.read_all()) |
| 6784 | return obj |
| 6785 | |
| 6786 | def __eq__(self, other): |
| 6787 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6788 | if self.xid != other.xid: return False |
| 6789 | if self.buffer_id != other.buffer_id: return False |
| 6790 | if self.total_len != other.total_len: return False |
| 6791 | if self.reason != other.reason: return False |
| 6792 | if self.table_id != other.table_id: return False |
| 6793 | if self.match != other.match: return False |
| 6794 | if self.data != other.data: return False |
| 6795 | return True |
| 6796 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6797 | def pretty_print(self, q): |
| 6798 | q.text("packet_in {") |
| 6799 | with q.group(): |
| 6800 | with q.indent(2): |
| 6801 | q.breakable() |
| 6802 | q.text("xid = "); |
| 6803 | if self.xid != None: |
| 6804 | q.text("%#x" % self.xid) |
| 6805 | else: |
| 6806 | q.text('None') |
| 6807 | q.text(","); q.breakable() |
| 6808 | q.text("buffer_id = "); |
| 6809 | q.text("%#x" % self.buffer_id) |
| 6810 | q.text(","); q.breakable() |
| 6811 | q.text("total_len = "); |
| 6812 | q.text("%#x" % self.total_len) |
| 6813 | q.text(","); q.breakable() |
| 6814 | q.text("reason = "); |
| 6815 | q.text("%#x" % self.reason) |
| 6816 | q.text(","); q.breakable() |
| 6817 | q.text("table_id = "); |
| 6818 | q.text("%#x" % self.table_id) |
| 6819 | q.text(","); q.breakable() |
| 6820 | q.text("match = "); |
| 6821 | q.pp(self.match) |
| 6822 | q.text(","); q.breakable() |
| 6823 | q.text("data = "); |
| 6824 | q.pp(self.data) |
| 6825 | q.breakable() |
| 6826 | q.text('}') |
| 6827 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6828 | message.subtypes[10] = packet_in |
| 6829 | |
| 6830 | class packet_out(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6831 | version = 3 |
| 6832 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6833 | |
| 6834 | 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] | 6835 | if xid != None: |
| 6836 | self.xid = xid |
| 6837 | else: |
| 6838 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6839 | if buffer_id != None: |
| 6840 | self.buffer_id = buffer_id |
| 6841 | else: |
| 6842 | self.buffer_id = 0 |
| 6843 | if in_port != None: |
| 6844 | self.in_port = in_port |
| 6845 | else: |
| 6846 | self.in_port = 0 |
| 6847 | if actions != None: |
| 6848 | self.actions = actions |
| 6849 | else: |
| 6850 | self.actions = [] |
| 6851 | if data != None: |
| 6852 | self.data = data |
| 6853 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6854 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6855 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6856 | |
| 6857 | def pack(self): |
| 6858 | packed = [] |
| 6859 | packed.append(struct.pack("!B", self.version)) |
| 6860 | packed.append(struct.pack("!B", self.type)) |
| 6861 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6862 | packed.append(struct.pack("!L", self.xid)) |
| 6863 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6864 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6865 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 6866 | packed.append('\x00' * 6) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6867 | packed.append(loxi.generic_util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6868 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 6869 | packed.append(self.data) |
| 6870 | length = sum([len(x) for x in packed]) |
| 6871 | packed[2] = struct.pack("!H", length) |
| 6872 | return ''.join(packed) |
| 6873 | |
| 6874 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6875 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6876 | obj = packet_out() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6877 | _version = reader.read("!B")[0] |
| 6878 | assert(_version == 3) |
| 6879 | _type = reader.read("!B")[0] |
| 6880 | assert(_type == 13) |
| 6881 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6882 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6883 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6884 | obj.xid = reader.read("!L")[0] |
| 6885 | obj.buffer_id = reader.read("!L")[0] |
| 6886 | obj.in_port = util.unpack_port_no(reader) |
| 6887 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6888 | reader.skip(6) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 6889 | obj.actions = loxi.generic_util.unpack_list(reader.slice(_actions_len), ofp.action.action.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6890 | obj.data = str(reader.read_all()) |
| 6891 | return obj |
| 6892 | |
| 6893 | def __eq__(self, other): |
| 6894 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6895 | if self.xid != other.xid: return False |
| 6896 | if self.buffer_id != other.buffer_id: return False |
| 6897 | if self.in_port != other.in_port: return False |
| 6898 | if self.actions != other.actions: return False |
| 6899 | if self.data != other.data: return False |
| 6900 | return True |
| 6901 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6902 | def pretty_print(self, q): |
| 6903 | q.text("packet_out {") |
| 6904 | with q.group(): |
| 6905 | with q.indent(2): |
| 6906 | q.breakable() |
| 6907 | q.text("xid = "); |
| 6908 | if self.xid != None: |
| 6909 | q.text("%#x" % self.xid) |
| 6910 | else: |
| 6911 | q.text('None') |
| 6912 | q.text(","); q.breakable() |
| 6913 | q.text("buffer_id = "); |
| 6914 | q.text("%#x" % self.buffer_id) |
| 6915 | q.text(","); q.breakable() |
| 6916 | q.text("in_port = "); |
| 6917 | q.text(util.pretty_port(self.in_port)) |
| 6918 | q.text(","); q.breakable() |
| 6919 | q.text("actions = "); |
| 6920 | q.pp(self.actions) |
| 6921 | q.text(","); q.breakable() |
| 6922 | q.text("data = "); |
| 6923 | q.pp(self.data) |
| 6924 | q.breakable() |
| 6925 | q.text('}') |
| 6926 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6927 | message.subtypes[13] = packet_out |
| 6928 | |
| 6929 | class port_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6930 | version = 3 |
| 6931 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6932 | |
| 6933 | 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] | 6934 | if xid != None: |
| 6935 | self.xid = xid |
| 6936 | else: |
| 6937 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6938 | if port_no != None: |
| 6939 | self.port_no = port_no |
| 6940 | else: |
| 6941 | self.port_no = 0 |
| 6942 | if hw_addr != None: |
| 6943 | self.hw_addr = hw_addr |
| 6944 | else: |
| 6945 | self.hw_addr = [0,0,0,0,0,0] |
| 6946 | if config != None: |
| 6947 | self.config = config |
| 6948 | else: |
| 6949 | self.config = 0 |
| 6950 | if mask != None: |
| 6951 | self.mask = mask |
| 6952 | else: |
| 6953 | self.mask = 0 |
| 6954 | if advertise != None: |
| 6955 | self.advertise = advertise |
| 6956 | else: |
| 6957 | self.advertise = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6958 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6959 | |
| 6960 | def pack(self): |
| 6961 | packed = [] |
| 6962 | packed.append(struct.pack("!B", self.version)) |
| 6963 | packed.append(struct.pack("!B", self.type)) |
| 6964 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6965 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6966 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6967 | packed.append('\x00' * 4) |
| 6968 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 6969 | packed.append('\x00' * 2) |
| 6970 | packed.append(struct.pack("!L", self.config)) |
| 6971 | packed.append(struct.pack("!L", self.mask)) |
| 6972 | packed.append(struct.pack("!L", self.advertise)) |
| 6973 | packed.append('\x00' * 4) |
| 6974 | length = sum([len(x) for x in packed]) |
| 6975 | packed[2] = struct.pack("!H", length) |
| 6976 | return ''.join(packed) |
| 6977 | |
| 6978 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6979 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6980 | obj = port_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6981 | _version = reader.read("!B")[0] |
| 6982 | assert(_version == 3) |
| 6983 | _type = reader.read("!B")[0] |
| 6984 | assert(_type == 16) |
| 6985 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 6986 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 6987 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6988 | obj.xid = reader.read("!L")[0] |
| 6989 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6990 | reader.skip(4) |
| 6991 | obj.hw_addr = list(reader.read('!6B')) |
| 6992 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6993 | obj.config = reader.read("!L")[0] |
| 6994 | obj.mask = reader.read("!L")[0] |
| 6995 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6996 | reader.skip(4) |
| 6997 | return obj |
| 6998 | |
| 6999 | def __eq__(self, other): |
| 7000 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7001 | if self.xid != other.xid: return False |
| 7002 | if self.port_no != other.port_no: return False |
| 7003 | if self.hw_addr != other.hw_addr: return False |
| 7004 | if self.config != other.config: return False |
| 7005 | if self.mask != other.mask: return False |
| 7006 | if self.advertise != other.advertise: return False |
| 7007 | return True |
| 7008 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7009 | def pretty_print(self, q): |
| 7010 | q.text("port_mod {") |
| 7011 | with q.group(): |
| 7012 | with q.indent(2): |
| 7013 | q.breakable() |
| 7014 | q.text("xid = "); |
| 7015 | if self.xid != None: |
| 7016 | q.text("%#x" % self.xid) |
| 7017 | else: |
| 7018 | q.text('None') |
| 7019 | q.text(","); q.breakable() |
| 7020 | q.text("port_no = "); |
| 7021 | q.text(util.pretty_port(self.port_no)) |
| 7022 | q.text(","); q.breakable() |
| 7023 | q.text("hw_addr = "); |
| 7024 | q.text(util.pretty_mac(self.hw_addr)) |
| 7025 | q.text(","); q.breakable() |
| 7026 | q.text("config = "); |
| 7027 | q.text("%#x" % self.config) |
| 7028 | q.text(","); q.breakable() |
| 7029 | q.text("mask = "); |
| 7030 | q.text("%#x" % self.mask) |
| 7031 | q.text(","); q.breakable() |
| 7032 | q.text("advertise = "); |
| 7033 | q.text("%#x" % self.advertise) |
| 7034 | q.breakable() |
| 7035 | q.text('}') |
| 7036 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7037 | message.subtypes[16] = port_mod |
| 7038 | |
| 7039 | class port_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7040 | version = 3 |
| 7041 | type = 1 |
| 7042 | err_type = 7 |
| 7043 | |
| 7044 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7045 | if xid != None: |
| 7046 | self.xid = xid |
| 7047 | else: |
| 7048 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7049 | if code != None: |
| 7050 | self.code = code |
| 7051 | else: |
| 7052 | self.code = 0 |
| 7053 | if data != None: |
| 7054 | self.data = data |
| 7055 | else: |
| 7056 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7057 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7058 | |
| 7059 | def pack(self): |
| 7060 | packed = [] |
| 7061 | packed.append(struct.pack("!B", self.version)) |
| 7062 | packed.append(struct.pack("!B", self.type)) |
| 7063 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7064 | packed.append(struct.pack("!L", self.xid)) |
| 7065 | packed.append(struct.pack("!H", self.err_type)) |
| 7066 | packed.append(struct.pack("!H", self.code)) |
| 7067 | packed.append(self.data) |
| 7068 | length = sum([len(x) for x in packed]) |
| 7069 | packed[2] = struct.pack("!H", length) |
| 7070 | return ''.join(packed) |
| 7071 | |
| 7072 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7073 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7074 | obj = port_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7075 | _version = reader.read("!B")[0] |
| 7076 | assert(_version == 3) |
| 7077 | _type = reader.read("!B")[0] |
| 7078 | assert(_type == 1) |
| 7079 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7080 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7081 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7082 | obj.xid = reader.read("!L")[0] |
| 7083 | _err_type = reader.read("!H")[0] |
| 7084 | assert(_err_type == 7) |
| 7085 | obj.code = reader.read("!H")[0] |
| 7086 | obj.data = str(reader.read_all()) |
| 7087 | return obj |
| 7088 | |
| 7089 | def __eq__(self, other): |
| 7090 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7091 | if self.xid != other.xid: return False |
| 7092 | if self.code != other.code: return False |
| 7093 | if self.data != other.data: return False |
| 7094 | return True |
| 7095 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7096 | def pretty_print(self, q): |
| 7097 | q.text("port_mod_failed_error_msg {") |
| 7098 | with q.group(): |
| 7099 | with q.indent(2): |
| 7100 | q.breakable() |
| 7101 | q.text("xid = "); |
| 7102 | if self.xid != None: |
| 7103 | q.text("%#x" % self.xid) |
| 7104 | else: |
| 7105 | q.text('None') |
| 7106 | q.text(","); q.breakable() |
| 7107 | q.text("code = "); |
| 7108 | q.text("%#x" % self.code) |
| 7109 | q.text(","); q.breakable() |
| 7110 | q.text("data = "); |
| 7111 | q.pp(self.data) |
| 7112 | q.breakable() |
| 7113 | q.text('}') |
| 7114 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7115 | error_msg.subtypes[7] = port_mod_failed_error_msg |
| 7116 | |
| 7117 | class port_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7118 | version = 3 |
| 7119 | type = 19 |
| 7120 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7121 | |
| 7122 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7123 | if xid != None: |
| 7124 | self.xid = xid |
| 7125 | else: |
| 7126 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7127 | if flags != None: |
| 7128 | self.flags = flags |
| 7129 | else: |
| 7130 | self.flags = 0 |
| 7131 | if entries != None: |
| 7132 | self.entries = entries |
| 7133 | else: |
| 7134 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7135 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7136 | |
| 7137 | def pack(self): |
| 7138 | packed = [] |
| 7139 | packed.append(struct.pack("!B", self.version)) |
| 7140 | packed.append(struct.pack("!B", self.type)) |
| 7141 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7142 | packed.append(struct.pack("!L", self.xid)) |
| 7143 | packed.append(struct.pack("!H", self.stats_type)) |
| 7144 | packed.append(struct.pack("!H", self.flags)) |
| 7145 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7146 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7147 | length = sum([len(x) for x in packed]) |
| 7148 | packed[2] = struct.pack("!H", length) |
| 7149 | return ''.join(packed) |
| 7150 | |
| 7151 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7152 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7153 | obj = port_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7154 | _version = reader.read("!B")[0] |
| 7155 | assert(_version == 3) |
| 7156 | _type = reader.read("!B")[0] |
| 7157 | assert(_type == 19) |
| 7158 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7159 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7160 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7161 | obj.xid = reader.read("!L")[0] |
| 7162 | _stats_type = reader.read("!H")[0] |
| 7163 | assert(_stats_type == 4) |
| 7164 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7165 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 7166 | obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.port_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7167 | return obj |
| 7168 | |
| 7169 | def __eq__(self, other): |
| 7170 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7171 | if self.xid != other.xid: return False |
| 7172 | if self.flags != other.flags: return False |
| 7173 | if self.entries != other.entries: return False |
| 7174 | return True |
| 7175 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7176 | def pretty_print(self, q): |
| 7177 | q.text("port_stats_reply {") |
| 7178 | with q.group(): |
| 7179 | with q.indent(2): |
| 7180 | q.breakable() |
| 7181 | q.text("xid = "); |
| 7182 | if self.xid != None: |
| 7183 | q.text("%#x" % self.xid) |
| 7184 | else: |
| 7185 | q.text('None') |
| 7186 | q.text(","); q.breakable() |
| 7187 | q.text("flags = "); |
| 7188 | q.text("%#x" % self.flags) |
| 7189 | q.text(","); q.breakable() |
| 7190 | q.text("entries = "); |
| 7191 | q.pp(self.entries) |
| 7192 | q.breakable() |
| 7193 | q.text('}') |
| 7194 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7195 | stats_reply.subtypes[4] = port_stats_reply |
| 7196 | |
| 7197 | class port_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7198 | version = 3 |
| 7199 | type = 18 |
| 7200 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7201 | |
| 7202 | def __init__(self, xid=None, flags=None, port_no=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7203 | if xid != None: |
| 7204 | self.xid = xid |
| 7205 | else: |
| 7206 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7207 | if flags != None: |
| 7208 | self.flags = flags |
| 7209 | else: |
| 7210 | self.flags = 0 |
| 7211 | if port_no != None: |
| 7212 | self.port_no = port_no |
| 7213 | else: |
| 7214 | self.port_no = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7215 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7216 | |
| 7217 | def pack(self): |
| 7218 | packed = [] |
| 7219 | packed.append(struct.pack("!B", self.version)) |
| 7220 | packed.append(struct.pack("!B", self.type)) |
| 7221 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7222 | packed.append(struct.pack("!L", self.xid)) |
| 7223 | packed.append(struct.pack("!H", self.stats_type)) |
| 7224 | packed.append(struct.pack("!H", self.flags)) |
| 7225 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7226 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7227 | packed.append('\x00' * 4) |
| 7228 | length = sum([len(x) for x in packed]) |
| 7229 | packed[2] = struct.pack("!H", length) |
| 7230 | return ''.join(packed) |
| 7231 | |
| 7232 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7233 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7234 | obj = port_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7235 | _version = reader.read("!B")[0] |
| 7236 | assert(_version == 3) |
| 7237 | _type = reader.read("!B")[0] |
| 7238 | assert(_type == 18) |
| 7239 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7240 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7241 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7242 | obj.xid = reader.read("!L")[0] |
| 7243 | _stats_type = reader.read("!H")[0] |
| 7244 | assert(_stats_type == 4) |
| 7245 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7246 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7247 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7248 | reader.skip(4) |
| 7249 | return obj |
| 7250 | |
| 7251 | def __eq__(self, other): |
| 7252 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7253 | if self.xid != other.xid: return False |
| 7254 | if self.flags != other.flags: return False |
| 7255 | if self.port_no != other.port_no: return False |
| 7256 | return True |
| 7257 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7258 | def pretty_print(self, q): |
| 7259 | q.text("port_stats_request {") |
| 7260 | with q.group(): |
| 7261 | with q.indent(2): |
| 7262 | q.breakable() |
| 7263 | q.text("xid = "); |
| 7264 | if self.xid != None: |
| 7265 | q.text("%#x" % self.xid) |
| 7266 | else: |
| 7267 | q.text('None') |
| 7268 | q.text(","); q.breakable() |
| 7269 | q.text("flags = "); |
| 7270 | q.text("%#x" % self.flags) |
| 7271 | q.text(","); q.breakable() |
| 7272 | q.text("port_no = "); |
| 7273 | q.text(util.pretty_port(self.port_no)) |
| 7274 | q.breakable() |
| 7275 | q.text('}') |
| 7276 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7277 | stats_request.subtypes[4] = port_stats_request |
| 7278 | |
| 7279 | class port_status(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7280 | version = 3 |
| 7281 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7282 | |
| 7283 | def __init__(self, xid=None, reason=None, desc=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7284 | if xid != None: |
| 7285 | self.xid = xid |
| 7286 | else: |
| 7287 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7288 | if reason != None: |
| 7289 | self.reason = reason |
| 7290 | else: |
| 7291 | self.reason = 0 |
| 7292 | if desc != None: |
| 7293 | self.desc = desc |
| 7294 | else: |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 7295 | self.desc = ofp.port_desc() |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7296 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7297 | |
| 7298 | def pack(self): |
| 7299 | packed = [] |
| 7300 | packed.append(struct.pack("!B", self.version)) |
| 7301 | packed.append(struct.pack("!B", self.type)) |
| 7302 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7303 | packed.append(struct.pack("!L", self.xid)) |
| 7304 | packed.append(struct.pack("!B", self.reason)) |
| 7305 | packed.append('\x00' * 7) |
| 7306 | packed.append(self.desc.pack()) |
| 7307 | length = sum([len(x) for x in packed]) |
| 7308 | packed[2] = struct.pack("!H", length) |
| 7309 | return ''.join(packed) |
| 7310 | |
| 7311 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7312 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7313 | obj = port_status() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7314 | _version = reader.read("!B")[0] |
| 7315 | assert(_version == 3) |
| 7316 | _type = reader.read("!B")[0] |
| 7317 | assert(_type == 12) |
| 7318 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7319 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7320 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7321 | obj.xid = reader.read("!L")[0] |
| 7322 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7323 | reader.skip(7) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 7324 | obj.desc = ofp.port_desc.unpack(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7325 | return obj |
| 7326 | |
| 7327 | def __eq__(self, other): |
| 7328 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7329 | if self.xid != other.xid: return False |
| 7330 | if self.reason != other.reason: return False |
| 7331 | if self.desc != other.desc: return False |
| 7332 | return True |
| 7333 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7334 | def pretty_print(self, q): |
| 7335 | q.text("port_status {") |
| 7336 | with q.group(): |
| 7337 | with q.indent(2): |
| 7338 | q.breakable() |
| 7339 | q.text("xid = "); |
| 7340 | if self.xid != None: |
| 7341 | q.text("%#x" % self.xid) |
| 7342 | else: |
| 7343 | q.text('None') |
| 7344 | q.text(","); q.breakable() |
| 7345 | q.text("reason = "); |
| 7346 | q.text("%#x" % self.reason) |
| 7347 | q.text(","); q.breakable() |
| 7348 | q.text("desc = "); |
| 7349 | q.pp(self.desc) |
| 7350 | q.breakable() |
| 7351 | q.text('}') |
| 7352 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7353 | message.subtypes[12] = port_status |
| 7354 | |
| 7355 | class queue_get_config_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7356 | version = 3 |
| 7357 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7358 | |
| 7359 | def __init__(self, xid=None, port=None, queues=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7360 | if xid != None: |
| 7361 | self.xid = xid |
| 7362 | else: |
| 7363 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7364 | if port != None: |
| 7365 | self.port = port |
| 7366 | else: |
| 7367 | self.port = 0 |
| 7368 | if queues != None: |
| 7369 | self.queues = queues |
| 7370 | else: |
| 7371 | self.queues = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7372 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7373 | |
| 7374 | def pack(self): |
| 7375 | packed = [] |
| 7376 | packed.append(struct.pack("!B", self.version)) |
| 7377 | packed.append(struct.pack("!B", self.type)) |
| 7378 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7379 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7380 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7381 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7382 | packed.append(loxi.generic_util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7383 | length = sum([len(x) for x in packed]) |
| 7384 | packed[2] = struct.pack("!H", length) |
| 7385 | return ''.join(packed) |
| 7386 | |
| 7387 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7388 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7389 | obj = queue_get_config_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7390 | _version = reader.read("!B")[0] |
| 7391 | assert(_version == 3) |
| 7392 | _type = reader.read("!B")[0] |
| 7393 | assert(_type == 23) |
| 7394 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7395 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7396 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7397 | obj.xid = reader.read("!L")[0] |
| 7398 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7399 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 7400 | obj.queues = loxi.generic_util.unpack_list(reader, ofp.common.packet_queue.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7401 | return obj |
| 7402 | |
| 7403 | def __eq__(self, other): |
| 7404 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7405 | if self.xid != other.xid: return False |
| 7406 | if self.port != other.port: return False |
| 7407 | if self.queues != other.queues: return False |
| 7408 | return True |
| 7409 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7410 | def pretty_print(self, q): |
| 7411 | q.text("queue_get_config_reply {") |
| 7412 | with q.group(): |
| 7413 | with q.indent(2): |
| 7414 | q.breakable() |
| 7415 | q.text("xid = "); |
| 7416 | if self.xid != None: |
| 7417 | q.text("%#x" % self.xid) |
| 7418 | else: |
| 7419 | q.text('None') |
| 7420 | q.text(","); q.breakable() |
| 7421 | q.text("port = "); |
| 7422 | q.text(util.pretty_port(self.port)) |
| 7423 | q.text(","); q.breakable() |
| 7424 | q.text("queues = "); |
| 7425 | q.pp(self.queues) |
| 7426 | q.breakable() |
| 7427 | q.text('}') |
| 7428 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7429 | message.subtypes[23] = queue_get_config_reply |
| 7430 | |
| 7431 | class queue_get_config_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7432 | version = 3 |
| 7433 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7434 | |
| 7435 | def __init__(self, xid=None, port=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7436 | if xid != None: |
| 7437 | self.xid = xid |
| 7438 | else: |
| 7439 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7440 | if port != None: |
| 7441 | self.port = port |
| 7442 | else: |
| 7443 | self.port = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7444 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7445 | |
| 7446 | def pack(self): |
| 7447 | packed = [] |
| 7448 | packed.append(struct.pack("!B", self.version)) |
| 7449 | packed.append(struct.pack("!B", self.type)) |
| 7450 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7451 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7452 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7453 | packed.append('\x00' * 4) |
| 7454 | length = sum([len(x) for x in packed]) |
| 7455 | packed[2] = struct.pack("!H", length) |
| 7456 | return ''.join(packed) |
| 7457 | |
| 7458 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7459 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7460 | obj = queue_get_config_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7461 | _version = reader.read("!B")[0] |
| 7462 | assert(_version == 3) |
| 7463 | _type = reader.read("!B")[0] |
| 7464 | assert(_type == 22) |
| 7465 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7466 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7467 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7468 | obj.xid = reader.read("!L")[0] |
| 7469 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7470 | reader.skip(4) |
| 7471 | return obj |
| 7472 | |
| 7473 | def __eq__(self, other): |
| 7474 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7475 | if self.xid != other.xid: return False |
| 7476 | if self.port != other.port: return False |
| 7477 | return True |
| 7478 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7479 | def pretty_print(self, q): |
| 7480 | q.text("queue_get_config_request {") |
| 7481 | with q.group(): |
| 7482 | with q.indent(2): |
| 7483 | q.breakable() |
| 7484 | q.text("xid = "); |
| 7485 | if self.xid != None: |
| 7486 | q.text("%#x" % self.xid) |
| 7487 | else: |
| 7488 | q.text('None') |
| 7489 | q.text(","); q.breakable() |
| 7490 | q.text("port = "); |
| 7491 | q.text(util.pretty_port(self.port)) |
| 7492 | q.breakable() |
| 7493 | q.text('}') |
| 7494 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7495 | message.subtypes[22] = queue_get_config_request |
| 7496 | |
| 7497 | class queue_op_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7498 | version = 3 |
| 7499 | type = 1 |
| 7500 | err_type = 9 |
| 7501 | |
| 7502 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7503 | if xid != None: |
| 7504 | self.xid = xid |
| 7505 | else: |
| 7506 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7507 | if code != None: |
| 7508 | self.code = code |
| 7509 | else: |
| 7510 | self.code = 0 |
| 7511 | if data != None: |
| 7512 | self.data = data |
| 7513 | else: |
| 7514 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7515 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7516 | |
| 7517 | def pack(self): |
| 7518 | packed = [] |
| 7519 | packed.append(struct.pack("!B", self.version)) |
| 7520 | packed.append(struct.pack("!B", self.type)) |
| 7521 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7522 | packed.append(struct.pack("!L", self.xid)) |
| 7523 | packed.append(struct.pack("!H", self.err_type)) |
| 7524 | packed.append(struct.pack("!H", self.code)) |
| 7525 | packed.append(self.data) |
| 7526 | length = sum([len(x) for x in packed]) |
| 7527 | packed[2] = struct.pack("!H", length) |
| 7528 | return ''.join(packed) |
| 7529 | |
| 7530 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7531 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7532 | obj = queue_op_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7533 | _version = reader.read("!B")[0] |
| 7534 | assert(_version == 3) |
| 7535 | _type = reader.read("!B")[0] |
| 7536 | assert(_type == 1) |
| 7537 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7538 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7539 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7540 | obj.xid = reader.read("!L")[0] |
| 7541 | _err_type = reader.read("!H")[0] |
| 7542 | assert(_err_type == 9) |
| 7543 | obj.code = reader.read("!H")[0] |
| 7544 | obj.data = str(reader.read_all()) |
| 7545 | return obj |
| 7546 | |
| 7547 | def __eq__(self, other): |
| 7548 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7549 | if self.xid != other.xid: return False |
| 7550 | if self.code != other.code: return False |
| 7551 | if self.data != other.data: return False |
| 7552 | return True |
| 7553 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7554 | def pretty_print(self, q): |
| 7555 | q.text("queue_op_failed_error_msg {") |
| 7556 | with q.group(): |
| 7557 | with q.indent(2): |
| 7558 | q.breakable() |
| 7559 | q.text("xid = "); |
| 7560 | if self.xid != None: |
| 7561 | q.text("%#x" % self.xid) |
| 7562 | else: |
| 7563 | q.text('None') |
| 7564 | q.text(","); q.breakable() |
| 7565 | q.text("code = "); |
| 7566 | q.text("%#x" % self.code) |
| 7567 | q.text(","); q.breakable() |
| 7568 | q.text("data = "); |
| 7569 | q.pp(self.data) |
| 7570 | q.breakable() |
| 7571 | q.text('}') |
| 7572 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7573 | error_msg.subtypes[9] = queue_op_failed_error_msg |
| 7574 | |
| 7575 | class queue_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7576 | version = 3 |
| 7577 | type = 19 |
| 7578 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7579 | |
| 7580 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7581 | if xid != None: |
| 7582 | self.xid = xid |
| 7583 | else: |
| 7584 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7585 | if flags != None: |
| 7586 | self.flags = flags |
| 7587 | else: |
| 7588 | self.flags = 0 |
| 7589 | if entries != None: |
| 7590 | self.entries = entries |
| 7591 | else: |
| 7592 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7593 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7594 | |
| 7595 | def pack(self): |
| 7596 | packed = [] |
| 7597 | packed.append(struct.pack("!B", self.version)) |
| 7598 | packed.append(struct.pack("!B", self.type)) |
| 7599 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7600 | packed.append(struct.pack("!L", self.xid)) |
| 7601 | packed.append(struct.pack("!H", self.stats_type)) |
| 7602 | packed.append(struct.pack("!H", self.flags)) |
| 7603 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7604 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7605 | length = sum([len(x) for x in packed]) |
| 7606 | packed[2] = struct.pack("!H", length) |
| 7607 | return ''.join(packed) |
| 7608 | |
| 7609 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7610 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7611 | obj = queue_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7612 | _version = reader.read("!B")[0] |
| 7613 | assert(_version == 3) |
| 7614 | _type = reader.read("!B")[0] |
| 7615 | assert(_type == 19) |
| 7616 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7617 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7618 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7619 | obj.xid = reader.read("!L")[0] |
| 7620 | _stats_type = reader.read("!H")[0] |
| 7621 | assert(_stats_type == 5) |
| 7622 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7623 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 7624 | obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.queue_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7625 | return obj |
| 7626 | |
| 7627 | def __eq__(self, other): |
| 7628 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7629 | if self.xid != other.xid: return False |
| 7630 | if self.flags != other.flags: return False |
| 7631 | if self.entries != other.entries: return False |
| 7632 | return True |
| 7633 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7634 | def pretty_print(self, q): |
| 7635 | q.text("queue_stats_reply {") |
| 7636 | with q.group(): |
| 7637 | with q.indent(2): |
| 7638 | q.breakable() |
| 7639 | q.text("xid = "); |
| 7640 | if self.xid != None: |
| 7641 | q.text("%#x" % self.xid) |
| 7642 | else: |
| 7643 | q.text('None') |
| 7644 | q.text(","); q.breakable() |
| 7645 | q.text("flags = "); |
| 7646 | q.text("%#x" % self.flags) |
| 7647 | q.text(","); q.breakable() |
| 7648 | q.text("entries = "); |
| 7649 | q.pp(self.entries) |
| 7650 | q.breakable() |
| 7651 | q.text('}') |
| 7652 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7653 | stats_reply.subtypes[5] = queue_stats_reply |
| 7654 | |
| 7655 | class queue_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7656 | version = 3 |
| 7657 | type = 18 |
| 7658 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7659 | |
| 7660 | 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] | 7661 | if xid != None: |
| 7662 | self.xid = xid |
| 7663 | else: |
| 7664 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7665 | if flags != None: |
| 7666 | self.flags = flags |
| 7667 | else: |
| 7668 | self.flags = 0 |
| 7669 | if port_no != None: |
| 7670 | self.port_no = port_no |
| 7671 | else: |
| 7672 | self.port_no = 0 |
| 7673 | if queue_id != None: |
| 7674 | self.queue_id = queue_id |
| 7675 | else: |
| 7676 | self.queue_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7677 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7678 | |
| 7679 | def pack(self): |
| 7680 | packed = [] |
| 7681 | packed.append(struct.pack("!B", self.version)) |
| 7682 | packed.append(struct.pack("!B", self.type)) |
| 7683 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7684 | packed.append(struct.pack("!L", self.xid)) |
| 7685 | packed.append(struct.pack("!H", self.stats_type)) |
| 7686 | packed.append(struct.pack("!H", self.flags)) |
| 7687 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7688 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7689 | packed.append(struct.pack("!L", self.queue_id)) |
| 7690 | length = sum([len(x) for x in packed]) |
| 7691 | packed[2] = struct.pack("!H", length) |
| 7692 | return ''.join(packed) |
| 7693 | |
| 7694 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7695 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7696 | obj = queue_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7697 | _version = reader.read("!B")[0] |
| 7698 | assert(_version == 3) |
| 7699 | _type = reader.read("!B")[0] |
| 7700 | assert(_type == 18) |
| 7701 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7702 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7703 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7704 | obj.xid = reader.read("!L")[0] |
| 7705 | _stats_type = reader.read("!H")[0] |
| 7706 | assert(_stats_type == 5) |
| 7707 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7708 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7709 | obj.port_no = util.unpack_port_no(reader) |
| 7710 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7711 | return obj |
| 7712 | |
| 7713 | def __eq__(self, other): |
| 7714 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7715 | if self.xid != other.xid: return False |
| 7716 | if self.flags != other.flags: return False |
| 7717 | if self.port_no != other.port_no: return False |
| 7718 | if self.queue_id != other.queue_id: return False |
| 7719 | return True |
| 7720 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7721 | def pretty_print(self, q): |
| 7722 | q.text("queue_stats_request {") |
| 7723 | with q.group(): |
| 7724 | with q.indent(2): |
| 7725 | q.breakable() |
| 7726 | q.text("xid = "); |
| 7727 | if self.xid != None: |
| 7728 | q.text("%#x" % self.xid) |
| 7729 | else: |
| 7730 | q.text('None') |
| 7731 | q.text(","); q.breakable() |
| 7732 | q.text("flags = "); |
| 7733 | q.text("%#x" % self.flags) |
| 7734 | q.text(","); q.breakable() |
| 7735 | q.text("port_no = "); |
| 7736 | q.text(util.pretty_port(self.port_no)) |
| 7737 | q.text(","); q.breakable() |
| 7738 | q.text("queue_id = "); |
| 7739 | q.text("%#x" % self.queue_id) |
| 7740 | q.breakable() |
| 7741 | q.text('}') |
| 7742 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7743 | stats_request.subtypes[5] = queue_stats_request |
| 7744 | |
| 7745 | class role_reply(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7746 | version = 3 |
| 7747 | type = 25 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7748 | |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7749 | def __init__(self, xid=None, role=None, generation_id=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7750 | if xid != None: |
| 7751 | self.xid = xid |
| 7752 | else: |
| 7753 | self.xid = None |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7754 | if role != None: |
| 7755 | self.role = role |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7756 | else: |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7757 | self.role = 0 |
| 7758 | if generation_id != None: |
| 7759 | self.generation_id = generation_id |
| 7760 | else: |
| 7761 | self.generation_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7762 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7763 | |
| 7764 | def pack(self): |
| 7765 | packed = [] |
| 7766 | packed.append(struct.pack("!B", self.version)) |
| 7767 | packed.append(struct.pack("!B", self.type)) |
| 7768 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7769 | packed.append(struct.pack("!L", self.xid)) |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7770 | packed.append(struct.pack("!L", self.role)) |
| 7771 | packed.append('\x00' * 4) |
| 7772 | packed.append(struct.pack("!Q", self.generation_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7773 | length = sum([len(x) for x in packed]) |
| 7774 | packed[2] = struct.pack("!H", length) |
| 7775 | return ''.join(packed) |
| 7776 | |
| 7777 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7778 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7779 | obj = role_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7780 | _version = reader.read("!B")[0] |
| 7781 | assert(_version == 3) |
| 7782 | _type = reader.read("!B")[0] |
| 7783 | assert(_type == 25) |
| 7784 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7785 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7786 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7787 | obj.xid = reader.read("!L")[0] |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7788 | obj.role = reader.read("!L")[0] |
| 7789 | reader.skip(4) |
| 7790 | obj.generation_id = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7791 | return obj |
| 7792 | |
| 7793 | def __eq__(self, other): |
| 7794 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7795 | if self.xid != other.xid: return False |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7796 | if self.role != other.role: return False |
| 7797 | if self.generation_id != other.generation_id: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7798 | return True |
| 7799 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7800 | def pretty_print(self, q): |
| 7801 | q.text("role_reply {") |
| 7802 | with q.group(): |
| 7803 | with q.indent(2): |
| 7804 | q.breakable() |
| 7805 | q.text("xid = "); |
| 7806 | if self.xid != None: |
| 7807 | q.text("%#x" % self.xid) |
| 7808 | else: |
| 7809 | q.text('None') |
| 7810 | q.text(","); q.breakable() |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 7811 | q.text("role = "); |
| 7812 | q.text("%#x" % self.role) |
| 7813 | q.text(","); q.breakable() |
| 7814 | q.text("generation_id = "); |
| 7815 | q.text("%#x" % self.generation_id) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7816 | q.breakable() |
| 7817 | q.text('}') |
| 7818 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7819 | message.subtypes[25] = role_reply |
| 7820 | |
| 7821 | class role_request(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7822 | version = 3 |
| 7823 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7824 | |
| 7825 | def __init__(self, xid=None, role=None, generation_id=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7826 | if xid != None: |
| 7827 | self.xid = xid |
| 7828 | else: |
| 7829 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7830 | if role != None: |
| 7831 | self.role = role |
| 7832 | else: |
| 7833 | self.role = 0 |
| 7834 | if generation_id != None: |
| 7835 | self.generation_id = generation_id |
| 7836 | else: |
| 7837 | self.generation_id = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7838 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7839 | |
| 7840 | def pack(self): |
| 7841 | packed = [] |
| 7842 | packed.append(struct.pack("!B", self.version)) |
| 7843 | packed.append(struct.pack("!B", self.type)) |
| 7844 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7845 | packed.append(struct.pack("!L", self.xid)) |
| 7846 | packed.append(struct.pack("!L", self.role)) |
| 7847 | packed.append('\x00' * 4) |
| 7848 | packed.append(struct.pack("!Q", self.generation_id)) |
| 7849 | length = sum([len(x) for x in packed]) |
| 7850 | packed[2] = struct.pack("!H", length) |
| 7851 | return ''.join(packed) |
| 7852 | |
| 7853 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7854 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7855 | obj = role_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7856 | _version = reader.read("!B")[0] |
| 7857 | assert(_version == 3) |
| 7858 | _type = reader.read("!B")[0] |
| 7859 | assert(_type == 24) |
| 7860 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7861 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7862 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7863 | obj.xid = reader.read("!L")[0] |
| 7864 | obj.role = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7865 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7866 | obj.generation_id = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7867 | return obj |
| 7868 | |
| 7869 | def __eq__(self, other): |
| 7870 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7871 | if self.xid != other.xid: return False |
| 7872 | if self.role != other.role: return False |
| 7873 | if self.generation_id != other.generation_id: return False |
| 7874 | return True |
| 7875 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7876 | def pretty_print(self, q): |
| 7877 | q.text("role_request {") |
| 7878 | with q.group(): |
| 7879 | with q.indent(2): |
| 7880 | q.breakable() |
| 7881 | q.text("xid = "); |
| 7882 | if self.xid != None: |
| 7883 | q.text("%#x" % self.xid) |
| 7884 | else: |
| 7885 | q.text('None') |
| 7886 | q.text(","); q.breakable() |
| 7887 | q.text("role = "); |
| 7888 | q.text("%#x" % self.role) |
| 7889 | q.text(","); q.breakable() |
| 7890 | q.text("generation_id = "); |
| 7891 | q.text("%#x" % self.generation_id) |
| 7892 | q.breakable() |
| 7893 | q.text('}') |
| 7894 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7895 | message.subtypes[24] = role_request |
| 7896 | |
| 7897 | class role_request_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7898 | version = 3 |
| 7899 | type = 1 |
| 7900 | err_type = 11 |
| 7901 | |
| 7902 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7903 | if xid != None: |
| 7904 | self.xid = xid |
| 7905 | else: |
| 7906 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7907 | if code != None: |
| 7908 | self.code = code |
| 7909 | else: |
| 7910 | self.code = 0 |
| 7911 | if data != None: |
| 7912 | self.data = data |
| 7913 | else: |
| 7914 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7915 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7916 | |
| 7917 | def pack(self): |
| 7918 | packed = [] |
| 7919 | packed.append(struct.pack("!B", self.version)) |
| 7920 | packed.append(struct.pack("!B", self.type)) |
| 7921 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7922 | packed.append(struct.pack("!L", self.xid)) |
| 7923 | packed.append(struct.pack("!H", self.err_type)) |
| 7924 | packed.append(struct.pack("!H", self.code)) |
| 7925 | packed.append(self.data) |
| 7926 | length = sum([len(x) for x in packed]) |
| 7927 | packed[2] = struct.pack("!H", length) |
| 7928 | return ''.join(packed) |
| 7929 | |
| 7930 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7931 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7932 | obj = role_request_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7933 | _version = reader.read("!B")[0] |
| 7934 | assert(_version == 3) |
| 7935 | _type = reader.read("!B")[0] |
| 7936 | assert(_type == 1) |
| 7937 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7938 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 7939 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7940 | obj.xid = reader.read("!L")[0] |
| 7941 | _err_type = reader.read("!H")[0] |
| 7942 | assert(_err_type == 11) |
| 7943 | obj.code = reader.read("!H")[0] |
| 7944 | obj.data = str(reader.read_all()) |
| 7945 | return obj |
| 7946 | |
| 7947 | def __eq__(self, other): |
| 7948 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7949 | if self.xid != other.xid: return False |
| 7950 | if self.code != other.code: return False |
| 7951 | if self.data != other.data: return False |
| 7952 | return True |
| 7953 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7954 | def pretty_print(self, q): |
| 7955 | q.text("role_request_failed_error_msg {") |
| 7956 | with q.group(): |
| 7957 | with q.indent(2): |
| 7958 | q.breakable() |
| 7959 | q.text("xid = "); |
| 7960 | if self.xid != None: |
| 7961 | q.text("%#x" % self.xid) |
| 7962 | else: |
| 7963 | q.text('None') |
| 7964 | q.text(","); q.breakable() |
| 7965 | q.text("code = "); |
| 7966 | q.text("%#x" % self.code) |
| 7967 | q.text(","); q.breakable() |
| 7968 | q.text("data = "); |
| 7969 | q.pp(self.data) |
| 7970 | q.breakable() |
| 7971 | q.text('}') |
| 7972 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7973 | error_msg.subtypes[11] = role_request_failed_error_msg |
| 7974 | |
| 7975 | class set_config(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7976 | version = 3 |
| 7977 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7978 | |
| 7979 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7980 | if xid != None: |
| 7981 | self.xid = xid |
| 7982 | else: |
| 7983 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7984 | if flags != None: |
| 7985 | self.flags = flags |
| 7986 | else: |
| 7987 | self.flags = 0 |
| 7988 | if miss_send_len != None: |
| 7989 | self.miss_send_len = miss_send_len |
| 7990 | else: |
| 7991 | self.miss_send_len = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 7992 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7993 | |
| 7994 | def pack(self): |
| 7995 | packed = [] |
| 7996 | packed.append(struct.pack("!B", self.version)) |
| 7997 | packed.append(struct.pack("!B", self.type)) |
| 7998 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7999 | packed.append(struct.pack("!L", self.xid)) |
| 8000 | packed.append(struct.pack("!H", self.flags)) |
| 8001 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 8002 | length = sum([len(x) for x in packed]) |
| 8003 | packed[2] = struct.pack("!H", length) |
| 8004 | return ''.join(packed) |
| 8005 | |
| 8006 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8007 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8008 | obj = set_config() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8009 | _version = reader.read("!B")[0] |
| 8010 | assert(_version == 3) |
| 8011 | _type = reader.read("!B")[0] |
| 8012 | assert(_type == 9) |
| 8013 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8014 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 8015 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8016 | obj.xid = reader.read("!L")[0] |
| 8017 | obj.flags = reader.read("!H")[0] |
| 8018 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8019 | return obj |
| 8020 | |
| 8021 | def __eq__(self, other): |
| 8022 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8023 | if self.xid != other.xid: return False |
| 8024 | if self.flags != other.flags: return False |
| 8025 | if self.miss_send_len != other.miss_send_len: return False |
| 8026 | return True |
| 8027 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8028 | def pretty_print(self, q): |
| 8029 | q.text("set_config {") |
| 8030 | with q.group(): |
| 8031 | with q.indent(2): |
| 8032 | q.breakable() |
| 8033 | q.text("xid = "); |
| 8034 | if self.xid != None: |
| 8035 | q.text("%#x" % self.xid) |
| 8036 | else: |
| 8037 | q.text('None') |
| 8038 | q.text(","); q.breakable() |
| 8039 | q.text("flags = "); |
| 8040 | q.text("%#x" % self.flags) |
| 8041 | q.text(","); q.breakable() |
| 8042 | q.text("miss_send_len = "); |
| 8043 | q.text("%#x" % self.miss_send_len) |
| 8044 | q.breakable() |
| 8045 | q.text('}') |
| 8046 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8047 | message.subtypes[9] = set_config |
| 8048 | |
| 8049 | class switch_config_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8050 | version = 3 |
| 8051 | type = 1 |
| 8052 | err_type = 10 |
| 8053 | |
| 8054 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8055 | if xid != None: |
| 8056 | self.xid = xid |
| 8057 | else: |
| 8058 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8059 | if code != None: |
| 8060 | self.code = code |
| 8061 | else: |
| 8062 | self.code = 0 |
| 8063 | if data != None: |
| 8064 | self.data = data |
| 8065 | else: |
| 8066 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8067 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8068 | |
| 8069 | def pack(self): |
| 8070 | packed = [] |
| 8071 | packed.append(struct.pack("!B", self.version)) |
| 8072 | packed.append(struct.pack("!B", self.type)) |
| 8073 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8074 | packed.append(struct.pack("!L", self.xid)) |
| 8075 | packed.append(struct.pack("!H", self.err_type)) |
| 8076 | packed.append(struct.pack("!H", self.code)) |
| 8077 | packed.append(self.data) |
| 8078 | length = sum([len(x) for x in packed]) |
| 8079 | packed[2] = struct.pack("!H", length) |
| 8080 | return ''.join(packed) |
| 8081 | |
| 8082 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8083 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8084 | obj = switch_config_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8085 | _version = reader.read("!B")[0] |
| 8086 | assert(_version == 3) |
| 8087 | _type = reader.read("!B")[0] |
| 8088 | assert(_type == 1) |
| 8089 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8090 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 8091 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8092 | obj.xid = reader.read("!L")[0] |
| 8093 | _err_type = reader.read("!H")[0] |
| 8094 | assert(_err_type == 10) |
| 8095 | obj.code = reader.read("!H")[0] |
| 8096 | obj.data = str(reader.read_all()) |
| 8097 | return obj |
| 8098 | |
| 8099 | def __eq__(self, other): |
| 8100 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8101 | if self.xid != other.xid: return False |
| 8102 | if self.code != other.code: return False |
| 8103 | if self.data != other.data: return False |
| 8104 | return True |
| 8105 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8106 | def pretty_print(self, q): |
| 8107 | q.text("switch_config_failed_error_msg {") |
| 8108 | with q.group(): |
| 8109 | with q.indent(2): |
| 8110 | q.breakable() |
| 8111 | q.text("xid = "); |
| 8112 | if self.xid != None: |
| 8113 | q.text("%#x" % self.xid) |
| 8114 | else: |
| 8115 | q.text('None') |
| 8116 | q.text(","); q.breakable() |
| 8117 | q.text("code = "); |
| 8118 | q.text("%#x" % self.code) |
| 8119 | q.text(","); q.breakable() |
| 8120 | q.text("data = "); |
| 8121 | q.pp(self.data) |
| 8122 | q.breakable() |
| 8123 | q.text('}') |
| 8124 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8125 | error_msg.subtypes[10] = switch_config_failed_error_msg |
| 8126 | |
| 8127 | class table_mod(message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8128 | version = 3 |
| 8129 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8130 | |
| 8131 | def __init__(self, xid=None, table_id=None, config=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8132 | if xid != None: |
| 8133 | self.xid = xid |
| 8134 | else: |
| 8135 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8136 | if table_id != None: |
| 8137 | self.table_id = table_id |
| 8138 | else: |
| 8139 | self.table_id = 0 |
| 8140 | if config != None: |
| 8141 | self.config = config |
| 8142 | else: |
| 8143 | self.config = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8144 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8145 | |
| 8146 | def pack(self): |
| 8147 | packed = [] |
| 8148 | packed.append(struct.pack("!B", self.version)) |
| 8149 | packed.append(struct.pack("!B", self.type)) |
| 8150 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8151 | packed.append(struct.pack("!L", self.xid)) |
| 8152 | packed.append(struct.pack("!B", self.table_id)) |
| 8153 | packed.append('\x00' * 3) |
| 8154 | packed.append(struct.pack("!L", self.config)) |
| 8155 | length = sum([len(x) for x in packed]) |
| 8156 | packed[2] = struct.pack("!H", length) |
| 8157 | return ''.join(packed) |
| 8158 | |
| 8159 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8160 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8161 | obj = table_mod() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8162 | _version = reader.read("!B")[0] |
| 8163 | assert(_version == 3) |
| 8164 | _type = reader.read("!B")[0] |
| 8165 | assert(_type == 17) |
| 8166 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8167 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 8168 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8169 | obj.xid = reader.read("!L")[0] |
| 8170 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8171 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8172 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8173 | return obj |
| 8174 | |
| 8175 | def __eq__(self, other): |
| 8176 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8177 | if self.xid != other.xid: return False |
| 8178 | if self.table_id != other.table_id: return False |
| 8179 | if self.config != other.config: return False |
| 8180 | return True |
| 8181 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8182 | def pretty_print(self, q): |
| 8183 | q.text("table_mod {") |
| 8184 | with q.group(): |
| 8185 | with q.indent(2): |
| 8186 | q.breakable() |
| 8187 | q.text("xid = "); |
| 8188 | if self.xid != None: |
| 8189 | q.text("%#x" % self.xid) |
| 8190 | else: |
| 8191 | q.text('None') |
| 8192 | q.text(","); q.breakable() |
| 8193 | q.text("table_id = "); |
| 8194 | q.text("%#x" % self.table_id) |
| 8195 | q.text(","); q.breakable() |
| 8196 | q.text("config = "); |
| 8197 | q.text("%#x" % self.config) |
| 8198 | q.breakable() |
| 8199 | q.text('}') |
| 8200 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8201 | message.subtypes[17] = table_mod |
| 8202 | |
| 8203 | class table_mod_failed_error_msg(error_msg): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8204 | version = 3 |
| 8205 | type = 1 |
| 8206 | err_type = 8 |
| 8207 | |
| 8208 | def __init__(self, xid=None, code=None, data=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8209 | if xid != None: |
| 8210 | self.xid = xid |
| 8211 | else: |
| 8212 | self.xid = None |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8213 | if code != None: |
| 8214 | self.code = code |
| 8215 | else: |
| 8216 | self.code = 0 |
| 8217 | if data != None: |
| 8218 | self.data = data |
| 8219 | else: |
| 8220 | self.data = '' |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8221 | return |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8222 | |
| 8223 | def pack(self): |
| 8224 | packed = [] |
| 8225 | packed.append(struct.pack("!B", self.version)) |
| 8226 | packed.append(struct.pack("!B", self.type)) |
| 8227 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8228 | packed.append(struct.pack("!L", self.xid)) |
| 8229 | packed.append(struct.pack("!H", self.err_type)) |
| 8230 | packed.append(struct.pack("!H", self.code)) |
| 8231 | packed.append(self.data) |
| 8232 | length = sum([len(x) for x in packed]) |
| 8233 | packed[2] = struct.pack("!H", length) |
| 8234 | return ''.join(packed) |
| 8235 | |
| 8236 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8237 | def unpack(reader): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8238 | obj = table_mod_failed_error_msg() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8239 | _version = reader.read("!B")[0] |
| 8240 | assert(_version == 3) |
| 8241 | _type = reader.read("!B")[0] |
| 8242 | assert(_type == 1) |
| 8243 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8244 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 8245 | reader = orig_reader.slice(_length, 4) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8246 | obj.xid = reader.read("!L")[0] |
| 8247 | _err_type = reader.read("!H")[0] |
| 8248 | assert(_err_type == 8) |
| 8249 | obj.code = reader.read("!H")[0] |
| 8250 | obj.data = str(reader.read_all()) |
| 8251 | return obj |
| 8252 | |
| 8253 | def __eq__(self, other): |
| 8254 | if type(self) != type(other): return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8255 | if self.xid != other.xid: return False |
| 8256 | if self.code != other.code: return False |
| 8257 | if self.data != other.data: return False |
| 8258 | return True |
| 8259 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8260 | def pretty_print(self, q): |
| 8261 | q.text("table_mod_failed_error_msg {") |
| 8262 | with q.group(): |
| 8263 | with q.indent(2): |
| 8264 | q.breakable() |
| 8265 | q.text("xid = "); |
| 8266 | if self.xid != None: |
| 8267 | q.text("%#x" % self.xid) |
| 8268 | else: |
| 8269 | q.text('None') |
| 8270 | q.text(","); q.breakable() |
| 8271 | q.text("code = "); |
| 8272 | q.text("%#x" % self.code) |
| 8273 | q.text(","); q.breakable() |
| 8274 | q.text("data = "); |
| 8275 | q.pp(self.data) |
| 8276 | q.breakable() |
| 8277 | q.text('}') |
| 8278 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8279 | error_msg.subtypes[8] = table_mod_failed_error_msg |
| 8280 | |
| 8281 | class table_stats_reply(stats_reply): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8282 | version = 3 |
| 8283 | type = 19 |
| 8284 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8285 | |
| 8286 | def __init__(self, xid=None, flags=None, entries=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8287 | if xid != None: |
| 8288 | self.xid = xid |
| 8289 | else: |
| 8290 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8291 | if flags != None: |
| 8292 | self.flags = flags |
| 8293 | else: |
| 8294 | self.flags = 0 |
| 8295 | if entries != None: |
| 8296 | self.entries = entries |
| 8297 | else: |
| 8298 | self.entries = [] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8299 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8300 | |
| 8301 | def pack(self): |
| 8302 | packed = [] |
| 8303 | packed.append(struct.pack("!B", self.version)) |
| 8304 | packed.append(struct.pack("!B", self.type)) |
| 8305 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8306 | packed.append(struct.pack("!L", self.xid)) |
| 8307 | packed.append(struct.pack("!H", self.stats_type)) |
| 8308 | packed.append(struct.pack("!H", self.flags)) |
| 8309 | packed.append('\x00' * 4) |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8310 | packed.append(loxi.generic_util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8311 | length = sum([len(x) for x in packed]) |
| 8312 | packed[2] = struct.pack("!H", length) |
| 8313 | return ''.join(packed) |
| 8314 | |
| 8315 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8316 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8317 | obj = table_stats_reply() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8318 | _version = reader.read("!B")[0] |
| 8319 | assert(_version == 3) |
| 8320 | _type = reader.read("!B")[0] |
| 8321 | assert(_type == 19) |
| 8322 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8323 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 8324 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8325 | obj.xid = reader.read("!L")[0] |
| 8326 | _stats_type = reader.read("!H")[0] |
| 8327 | assert(_stats_type == 3) |
| 8328 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8329 | reader.skip(4) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 8330 | obj.entries = loxi.generic_util.unpack_list(reader, ofp.common.table_stats_entry.unpack) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8331 | return obj |
| 8332 | |
| 8333 | def __eq__(self, other): |
| 8334 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8335 | if self.xid != other.xid: return False |
| 8336 | if self.flags != other.flags: return False |
| 8337 | if self.entries != other.entries: return False |
| 8338 | return True |
| 8339 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8340 | def pretty_print(self, q): |
| 8341 | q.text("table_stats_reply {") |
| 8342 | with q.group(): |
| 8343 | with q.indent(2): |
| 8344 | q.breakable() |
| 8345 | q.text("xid = "); |
| 8346 | if self.xid != None: |
| 8347 | q.text("%#x" % self.xid) |
| 8348 | else: |
| 8349 | q.text('None') |
| 8350 | q.text(","); q.breakable() |
| 8351 | q.text("flags = "); |
| 8352 | q.text("%#x" % self.flags) |
| 8353 | q.text(","); q.breakable() |
| 8354 | q.text("entries = "); |
| 8355 | q.pp(self.entries) |
| 8356 | q.breakable() |
| 8357 | q.text('}') |
| 8358 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8359 | stats_reply.subtypes[3] = table_stats_reply |
| 8360 | |
| 8361 | class table_stats_request(stats_request): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8362 | version = 3 |
| 8363 | type = 18 |
| 8364 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8365 | |
| 8366 | def __init__(self, xid=None, flags=None): |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8367 | if xid != None: |
| 8368 | self.xid = xid |
| 8369 | else: |
| 8370 | self.xid = None |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8371 | if flags != None: |
| 8372 | self.flags = flags |
| 8373 | else: |
| 8374 | self.flags = 0 |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8375 | return |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8376 | |
| 8377 | def pack(self): |
| 8378 | packed = [] |
| 8379 | packed.append(struct.pack("!B", self.version)) |
| 8380 | packed.append(struct.pack("!B", self.type)) |
| 8381 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8382 | packed.append(struct.pack("!L", self.xid)) |
| 8383 | packed.append(struct.pack("!H", self.stats_type)) |
| 8384 | packed.append(struct.pack("!H", self.flags)) |
| 8385 | packed.append('\x00' * 4) |
| 8386 | length = sum([len(x) for x in packed]) |
| 8387 | packed[2] = struct.pack("!H", length) |
| 8388 | return ''.join(packed) |
| 8389 | |
| 8390 | @staticmethod |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8391 | def unpack(reader): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8392 | obj = table_stats_request() |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8393 | _version = reader.read("!B")[0] |
| 8394 | assert(_version == 3) |
| 8395 | _type = reader.read("!B")[0] |
| 8396 | assert(_type == 18) |
| 8397 | _length = reader.read("!H")[0] |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8398 | orig_reader = reader |
Rich Lane | cb18dbd | 2014-12-18 10:02:29 -0800 | [diff] [blame] | 8399 | reader = orig_reader.slice(_length, 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8400 | obj.xid = reader.read("!L")[0] |
| 8401 | _stats_type = reader.read("!H")[0] |
| 8402 | assert(_stats_type == 3) |
| 8403 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8404 | reader.skip(4) |
| 8405 | return obj |
| 8406 | |
| 8407 | def __eq__(self, other): |
| 8408 | if type(self) != type(other): return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8409 | if self.xid != other.xid: return False |
| 8410 | if self.flags != other.flags: return False |
| 8411 | return True |
| 8412 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8413 | def pretty_print(self, q): |
| 8414 | q.text("table_stats_request {") |
| 8415 | with q.group(): |
| 8416 | with q.indent(2): |
| 8417 | q.breakable() |
| 8418 | q.text("xid = "); |
| 8419 | if self.xid != None: |
| 8420 | q.text("%#x" % self.xid) |
| 8421 | else: |
| 8422 | q.text('None') |
| 8423 | q.text(","); q.breakable() |
| 8424 | q.text("flags = "); |
| 8425 | q.text("%#x" % self.flags) |
| 8426 | q.breakable() |
| 8427 | q.text('}') |
| 8428 | |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8429 | stats_request.subtypes[3] = table_stats_request |
| 8430 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8431 | |
| 8432 | def parse_header(buf): |
| 8433 | if len(buf) < 8: |
| 8434 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 8435 | return struct.unpack_from("!BBHL", buf) |
| 8436 | |
| 8437 | def parse_message(buf): |
| 8438 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | e256770 | 2015-01-26 15:04:35 -0800 | [diff] [blame] | 8439 | if msg_ver != ofp.OFP_VERSION and msg_type != ofp.OFPT_HELLO: |
| 8440 | raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (ofp.OFP_VERSION, msg_ver)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8441 | if len(buf) != msg_len: |
| 8442 | raise loxi.ProtocolError("incorrect message size") |
Rich Lane | 7dcdf02 | 2013-12-11 14:45:27 -0800 | [diff] [blame] | 8443 | return message.unpack(loxi.generic_util.OFReader(buf)) |