Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5 | |
| 6 | # Automatically generated by LOXI from template message.py |
| 7 | # Do not modify |
| 8 | |
| 9 | import struct |
| 10 | import loxi |
| 11 | import const |
| 12 | import common |
| 13 | import action # for unpack_list |
| 14 | import instruction # for unpack_list |
| 15 | import util |
| 16 | import loxi.generic_util |
| 17 | |
| 18 | class Message(object): |
| 19 | version = const.OFP_VERSION |
| 20 | type = None # override in subclass |
| 21 | xid = None |
| 22 | |
| 23 | class aggregate_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 24 | version = 2 |
| 25 | type = 19 |
| 26 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 27 | |
| 28 | def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None): |
| 29 | self.xid = xid |
| 30 | if flags != None: |
| 31 | self.flags = flags |
| 32 | else: |
| 33 | self.flags = 0 |
| 34 | if packet_count != None: |
| 35 | self.packet_count = packet_count |
| 36 | else: |
| 37 | self.packet_count = 0 |
| 38 | if byte_count != None: |
| 39 | self.byte_count = byte_count |
| 40 | else: |
| 41 | self.byte_count = 0 |
| 42 | if flow_count != None: |
| 43 | self.flow_count = flow_count |
| 44 | else: |
| 45 | self.flow_count = 0 |
| 46 | |
| 47 | def pack(self): |
| 48 | packed = [] |
| 49 | packed.append(struct.pack("!B", self.version)) |
| 50 | packed.append(struct.pack("!B", self.type)) |
| 51 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 52 | packed.append(struct.pack("!L", self.xid)) |
| 53 | packed.append(struct.pack("!H", self.stats_type)) |
| 54 | packed.append(struct.pack("!H", self.flags)) |
| 55 | packed.append('\x00' * 4) |
| 56 | packed.append(struct.pack("!Q", self.packet_count)) |
| 57 | packed.append(struct.pack("!Q", self.byte_count)) |
| 58 | packed.append(struct.pack("!L", self.flow_count)) |
| 59 | packed.append('\x00' * 4) |
| 60 | length = sum([len(x) for x in packed]) |
| 61 | packed[2] = struct.pack("!H", length) |
| 62 | return ''.join(packed) |
| 63 | |
| 64 | @staticmethod |
| 65 | def unpack(buf): |
| 66 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 67 | obj = aggregate_stats_reply() |
| 68 | if type(buf) == loxi.generic_util.OFReader: |
| 69 | reader = buf |
| 70 | else: |
| 71 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 72 | _version = reader.read("!B")[0] |
| 73 | assert(_version == 2) |
| 74 | _type = reader.read("!B")[0] |
| 75 | assert(_type == 19) |
| 76 | _length = reader.read("!H")[0] |
| 77 | obj.xid = reader.read("!L")[0] |
| 78 | _stats_type = reader.read("!H")[0] |
| 79 | assert(_stats_type == 2) |
| 80 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 81 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 82 | obj.packet_count = reader.read("!Q")[0] |
| 83 | obj.byte_count = reader.read("!Q")[0] |
| 84 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 85 | reader.skip(4) |
| 86 | return obj |
| 87 | |
| 88 | def __eq__(self, other): |
| 89 | if type(self) != type(other): return False |
| 90 | if self.version != other.version: return False |
| 91 | if self.type != other.type: return False |
| 92 | if self.xid != other.xid: return False |
| 93 | if self.flags != other.flags: return False |
| 94 | if self.packet_count != other.packet_count: return False |
| 95 | if self.byte_count != other.byte_count: return False |
| 96 | if self.flow_count != other.flow_count: return False |
| 97 | return True |
| 98 | |
| 99 | def __ne__(self, other): |
| 100 | return not self.__eq__(other) |
| 101 | |
| 102 | def __str__(self): |
| 103 | return self.show() |
| 104 | |
| 105 | def show(self): |
| 106 | import loxi.pp |
| 107 | return loxi.pp.pp(self) |
| 108 | |
| 109 | def pretty_print(self, q): |
| 110 | q.text("aggregate_stats_reply {") |
| 111 | with q.group(): |
| 112 | with q.indent(2): |
| 113 | q.breakable() |
| 114 | q.text("xid = "); |
| 115 | if self.xid != None: |
| 116 | q.text("%#x" % self.xid) |
| 117 | else: |
| 118 | q.text('None') |
| 119 | q.text(","); q.breakable() |
| 120 | q.text("flags = "); |
| 121 | q.text("%#x" % self.flags) |
| 122 | q.text(","); q.breakable() |
| 123 | q.text("packet_count = "); |
| 124 | q.text("%#x" % self.packet_count) |
| 125 | q.text(","); q.breakable() |
| 126 | q.text("byte_count = "); |
| 127 | q.text("%#x" % self.byte_count) |
| 128 | q.text(","); q.breakable() |
| 129 | q.text("flow_count = "); |
| 130 | q.text("%#x" % self.flow_count) |
| 131 | q.breakable() |
| 132 | q.text('}') |
| 133 | |
| 134 | class aggregate_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 135 | version = 2 |
| 136 | type = 18 |
| 137 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 138 | |
| 139 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 140 | self.xid = xid |
| 141 | if flags != None: |
| 142 | self.flags = flags |
| 143 | else: |
| 144 | self.flags = 0 |
| 145 | if table_id != None: |
| 146 | self.table_id = table_id |
| 147 | else: |
| 148 | self.table_id = 0 |
| 149 | if out_port != None: |
| 150 | self.out_port = out_port |
| 151 | else: |
| 152 | self.out_port = 0 |
| 153 | if out_group != None: |
| 154 | self.out_group = out_group |
| 155 | else: |
| 156 | self.out_group = 0 |
| 157 | if cookie != None: |
| 158 | self.cookie = cookie |
| 159 | else: |
| 160 | self.cookie = 0 |
| 161 | if cookie_mask != None: |
| 162 | self.cookie_mask = cookie_mask |
| 163 | else: |
| 164 | self.cookie_mask = 0 |
| 165 | if match != None: |
| 166 | self.match = match |
| 167 | else: |
| 168 | self.match = common.match() |
| 169 | |
| 170 | def pack(self): |
| 171 | packed = [] |
| 172 | packed.append(struct.pack("!B", self.version)) |
| 173 | packed.append(struct.pack("!B", self.type)) |
| 174 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 175 | packed.append(struct.pack("!L", self.xid)) |
| 176 | packed.append(struct.pack("!H", self.stats_type)) |
| 177 | packed.append(struct.pack("!H", self.flags)) |
| 178 | packed.append('\x00' * 4) |
| 179 | packed.append(struct.pack("!B", self.table_id)) |
| 180 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 181 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 182 | packed.append(struct.pack("!L", self.out_group)) |
| 183 | packed.append('\x00' * 4) |
| 184 | packed.append(struct.pack("!Q", self.cookie)) |
| 185 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 186 | packed.append(self.match.pack()) |
| 187 | length = sum([len(x) for x in packed]) |
| 188 | packed[2] = struct.pack("!H", length) |
| 189 | return ''.join(packed) |
| 190 | |
| 191 | @staticmethod |
| 192 | def unpack(buf): |
| 193 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 194 | obj = aggregate_stats_request() |
| 195 | if type(buf) == loxi.generic_util.OFReader: |
| 196 | reader = buf |
| 197 | else: |
| 198 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 199 | _version = reader.read("!B")[0] |
| 200 | assert(_version == 2) |
| 201 | _type = reader.read("!B")[0] |
| 202 | assert(_type == 18) |
| 203 | _length = reader.read("!H")[0] |
| 204 | obj.xid = reader.read("!L")[0] |
| 205 | _stats_type = reader.read("!H")[0] |
| 206 | assert(_stats_type == 2) |
| 207 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 208 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 209 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 210 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 211 | obj.out_port = util.unpack_port_no(reader) |
| 212 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 213 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 214 | obj.cookie = reader.read("!Q")[0] |
| 215 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 216 | obj.match = common.match.unpack(reader) |
| 217 | return obj |
| 218 | |
| 219 | def __eq__(self, other): |
| 220 | if type(self) != type(other): return False |
| 221 | if self.version != other.version: return False |
| 222 | if self.type != other.type: return False |
| 223 | if self.xid != other.xid: return False |
| 224 | if self.flags != other.flags: return False |
| 225 | if self.table_id != other.table_id: return False |
| 226 | if self.out_port != other.out_port: return False |
| 227 | if self.out_group != other.out_group: return False |
| 228 | if self.cookie != other.cookie: return False |
| 229 | if self.cookie_mask != other.cookie_mask: return False |
| 230 | if self.match != other.match: return False |
| 231 | return True |
| 232 | |
| 233 | def __ne__(self, other): |
| 234 | return not self.__eq__(other) |
| 235 | |
| 236 | def __str__(self): |
| 237 | return self.show() |
| 238 | |
| 239 | def show(self): |
| 240 | import loxi.pp |
| 241 | return loxi.pp.pp(self) |
| 242 | |
| 243 | def pretty_print(self, q): |
| 244 | q.text("aggregate_stats_request {") |
| 245 | with q.group(): |
| 246 | with q.indent(2): |
| 247 | q.breakable() |
| 248 | q.text("xid = "); |
| 249 | if self.xid != None: |
| 250 | q.text("%#x" % self.xid) |
| 251 | else: |
| 252 | q.text('None') |
| 253 | q.text(","); q.breakable() |
| 254 | q.text("flags = "); |
| 255 | q.text("%#x" % self.flags) |
| 256 | q.text(","); q.breakable() |
| 257 | q.text("table_id = "); |
| 258 | q.text("%#x" % self.table_id) |
| 259 | q.text(","); q.breakable() |
| 260 | q.text("out_port = "); |
| 261 | q.text(util.pretty_port(self.out_port)) |
| 262 | q.text(","); q.breakable() |
| 263 | q.text("out_group = "); |
| 264 | q.text("%#x" % self.out_group) |
| 265 | q.text(","); q.breakable() |
| 266 | q.text("cookie = "); |
| 267 | q.text("%#x" % self.cookie) |
| 268 | q.text(","); q.breakable() |
| 269 | q.text("cookie_mask = "); |
| 270 | q.text("%#x" % self.cookie_mask) |
| 271 | q.text(","); q.breakable() |
| 272 | q.text("match = "); |
| 273 | q.pp(self.match) |
| 274 | q.breakable() |
| 275 | q.text('}') |
| 276 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 277 | class bad_action_error_msg(Message): |
| 278 | version = 2 |
| 279 | type = 1 |
| 280 | err_type = 2 |
| 281 | |
| 282 | def __init__(self, xid=None, code=None, data=None): |
| 283 | self.xid = xid |
| 284 | if code != None: |
| 285 | self.code = code |
| 286 | else: |
| 287 | self.code = 0 |
| 288 | if data != None: |
| 289 | self.data = data |
| 290 | else: |
| 291 | self.data = '' |
| 292 | |
| 293 | def pack(self): |
| 294 | packed = [] |
| 295 | packed.append(struct.pack("!B", self.version)) |
| 296 | packed.append(struct.pack("!B", self.type)) |
| 297 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 298 | packed.append(struct.pack("!L", self.xid)) |
| 299 | packed.append(struct.pack("!H", self.err_type)) |
| 300 | packed.append(struct.pack("!H", self.code)) |
| 301 | packed.append(self.data) |
| 302 | length = sum([len(x) for x in packed]) |
| 303 | packed[2] = struct.pack("!H", length) |
| 304 | return ''.join(packed) |
| 305 | |
| 306 | @staticmethod |
| 307 | def unpack(buf): |
| 308 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 309 | obj = bad_action_error_msg() |
| 310 | if type(buf) == loxi.generic_util.OFReader: |
| 311 | reader = buf |
| 312 | else: |
| 313 | reader = loxi.generic_util.OFReader(buf) |
| 314 | _version = reader.read("!B")[0] |
| 315 | assert(_version == 2) |
| 316 | _type = reader.read("!B")[0] |
| 317 | assert(_type == 1) |
| 318 | _length = reader.read("!H")[0] |
| 319 | obj.xid = reader.read("!L")[0] |
| 320 | _err_type = reader.read("!H")[0] |
| 321 | assert(_err_type == 2) |
| 322 | obj.code = reader.read("!H")[0] |
| 323 | obj.data = str(reader.read_all()) |
| 324 | return obj |
| 325 | |
| 326 | def __eq__(self, other): |
| 327 | if type(self) != type(other): return False |
| 328 | if self.version != other.version: return False |
| 329 | if self.type != other.type: return False |
| 330 | if self.xid != other.xid: return False |
| 331 | if self.code != other.code: return False |
| 332 | if self.data != other.data: return False |
| 333 | return True |
| 334 | |
| 335 | def __ne__(self, other): |
| 336 | return not self.__eq__(other) |
| 337 | |
| 338 | def __str__(self): |
| 339 | return self.show() |
| 340 | |
| 341 | def show(self): |
| 342 | import loxi.pp |
| 343 | return loxi.pp.pp(self) |
| 344 | |
| 345 | def pretty_print(self, q): |
| 346 | q.text("bad_action_error_msg {") |
| 347 | with q.group(): |
| 348 | with q.indent(2): |
| 349 | q.breakable() |
| 350 | q.text("xid = "); |
| 351 | if self.xid != None: |
| 352 | q.text("%#x" % self.xid) |
| 353 | else: |
| 354 | q.text('None') |
| 355 | q.text(","); q.breakable() |
| 356 | q.text("code = "); |
| 357 | q.text("%#x" % self.code) |
| 358 | q.text(","); q.breakable() |
| 359 | q.text("data = "); |
| 360 | q.pp(self.data) |
| 361 | q.breakable() |
| 362 | q.text('}') |
| 363 | |
| 364 | class bad_instruction_error_msg(Message): |
| 365 | version = 2 |
| 366 | type = 1 |
| 367 | err_type = 3 |
| 368 | |
| 369 | def __init__(self, xid=None, code=None, data=None): |
| 370 | self.xid = xid |
| 371 | if code != None: |
| 372 | self.code = code |
| 373 | else: |
| 374 | self.code = 0 |
| 375 | if data != None: |
| 376 | self.data = data |
| 377 | else: |
| 378 | self.data = '' |
| 379 | |
| 380 | def pack(self): |
| 381 | packed = [] |
| 382 | packed.append(struct.pack("!B", self.version)) |
| 383 | packed.append(struct.pack("!B", self.type)) |
| 384 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 385 | packed.append(struct.pack("!L", self.xid)) |
| 386 | packed.append(struct.pack("!H", self.err_type)) |
| 387 | packed.append(struct.pack("!H", self.code)) |
| 388 | packed.append(self.data) |
| 389 | length = sum([len(x) for x in packed]) |
| 390 | packed[2] = struct.pack("!H", length) |
| 391 | return ''.join(packed) |
| 392 | |
| 393 | @staticmethod |
| 394 | def unpack(buf): |
| 395 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 396 | obj = bad_instruction_error_msg() |
| 397 | if type(buf) == loxi.generic_util.OFReader: |
| 398 | reader = buf |
| 399 | else: |
| 400 | reader = loxi.generic_util.OFReader(buf) |
| 401 | _version = reader.read("!B")[0] |
| 402 | assert(_version == 2) |
| 403 | _type = reader.read("!B")[0] |
| 404 | assert(_type == 1) |
| 405 | _length = reader.read("!H")[0] |
| 406 | obj.xid = reader.read("!L")[0] |
| 407 | _err_type = reader.read("!H")[0] |
| 408 | assert(_err_type == 3) |
| 409 | obj.code = reader.read("!H")[0] |
| 410 | obj.data = str(reader.read_all()) |
| 411 | return obj |
| 412 | |
| 413 | def __eq__(self, other): |
| 414 | if type(self) != type(other): return False |
| 415 | if self.version != other.version: return False |
| 416 | if self.type != other.type: return False |
| 417 | if self.xid != other.xid: return False |
| 418 | if self.code != other.code: return False |
| 419 | if self.data != other.data: return False |
| 420 | return True |
| 421 | |
| 422 | def __ne__(self, other): |
| 423 | return not self.__eq__(other) |
| 424 | |
| 425 | def __str__(self): |
| 426 | return self.show() |
| 427 | |
| 428 | def show(self): |
| 429 | import loxi.pp |
| 430 | return loxi.pp.pp(self) |
| 431 | |
| 432 | def pretty_print(self, q): |
| 433 | q.text("bad_instruction_error_msg {") |
| 434 | with q.group(): |
| 435 | with q.indent(2): |
| 436 | q.breakable() |
| 437 | q.text("xid = "); |
| 438 | if self.xid != None: |
| 439 | q.text("%#x" % self.xid) |
| 440 | else: |
| 441 | q.text('None') |
| 442 | q.text(","); q.breakable() |
| 443 | q.text("code = "); |
| 444 | q.text("%#x" % self.code) |
| 445 | q.text(","); q.breakable() |
| 446 | q.text("data = "); |
| 447 | q.pp(self.data) |
| 448 | q.breakable() |
| 449 | q.text('}') |
| 450 | |
| 451 | class bad_match_error_msg(Message): |
| 452 | version = 2 |
| 453 | type = 1 |
| 454 | err_type = 4 |
| 455 | |
| 456 | def __init__(self, xid=None, code=None, data=None): |
| 457 | self.xid = xid |
| 458 | if code != None: |
| 459 | self.code = code |
| 460 | else: |
| 461 | self.code = 0 |
| 462 | if data != None: |
| 463 | self.data = data |
| 464 | else: |
| 465 | self.data = '' |
| 466 | |
| 467 | def pack(self): |
| 468 | packed = [] |
| 469 | packed.append(struct.pack("!B", self.version)) |
| 470 | packed.append(struct.pack("!B", self.type)) |
| 471 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 472 | packed.append(struct.pack("!L", self.xid)) |
| 473 | packed.append(struct.pack("!H", self.err_type)) |
| 474 | packed.append(struct.pack("!H", self.code)) |
| 475 | packed.append(self.data) |
| 476 | length = sum([len(x) for x in packed]) |
| 477 | packed[2] = struct.pack("!H", length) |
| 478 | return ''.join(packed) |
| 479 | |
| 480 | @staticmethod |
| 481 | def unpack(buf): |
| 482 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 483 | obj = bad_match_error_msg() |
| 484 | if type(buf) == loxi.generic_util.OFReader: |
| 485 | reader = buf |
| 486 | else: |
| 487 | reader = loxi.generic_util.OFReader(buf) |
| 488 | _version = reader.read("!B")[0] |
| 489 | assert(_version == 2) |
| 490 | _type = reader.read("!B")[0] |
| 491 | assert(_type == 1) |
| 492 | _length = reader.read("!H")[0] |
| 493 | obj.xid = reader.read("!L")[0] |
| 494 | _err_type = reader.read("!H")[0] |
| 495 | assert(_err_type == 4) |
| 496 | obj.code = reader.read("!H")[0] |
| 497 | obj.data = str(reader.read_all()) |
| 498 | return obj |
| 499 | |
| 500 | def __eq__(self, other): |
| 501 | if type(self) != type(other): return False |
| 502 | if self.version != other.version: return False |
| 503 | if self.type != other.type: return False |
| 504 | if self.xid != other.xid: return False |
| 505 | if self.code != other.code: return False |
| 506 | if self.data != other.data: return False |
| 507 | return True |
| 508 | |
| 509 | def __ne__(self, other): |
| 510 | return not self.__eq__(other) |
| 511 | |
| 512 | def __str__(self): |
| 513 | return self.show() |
| 514 | |
| 515 | def show(self): |
| 516 | import loxi.pp |
| 517 | return loxi.pp.pp(self) |
| 518 | |
| 519 | def pretty_print(self, q): |
| 520 | q.text("bad_match_error_msg {") |
| 521 | with q.group(): |
| 522 | with q.indent(2): |
| 523 | q.breakable() |
| 524 | q.text("xid = "); |
| 525 | if self.xid != None: |
| 526 | q.text("%#x" % self.xid) |
| 527 | else: |
| 528 | q.text('None') |
| 529 | q.text(","); q.breakable() |
| 530 | q.text("code = "); |
| 531 | q.text("%#x" % self.code) |
| 532 | q.text(","); q.breakable() |
| 533 | q.text("data = "); |
| 534 | q.pp(self.data) |
| 535 | q.breakable() |
| 536 | q.text('}') |
| 537 | |
| 538 | class bad_request_error_msg(Message): |
| 539 | version = 2 |
| 540 | type = 1 |
| 541 | err_type = 1 |
| 542 | |
| 543 | def __init__(self, xid=None, code=None, data=None): |
| 544 | self.xid = xid |
| 545 | if code != None: |
| 546 | self.code = code |
| 547 | else: |
| 548 | self.code = 0 |
| 549 | if data != None: |
| 550 | self.data = data |
| 551 | else: |
| 552 | self.data = '' |
| 553 | |
| 554 | def pack(self): |
| 555 | packed = [] |
| 556 | packed.append(struct.pack("!B", self.version)) |
| 557 | packed.append(struct.pack("!B", self.type)) |
| 558 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 559 | packed.append(struct.pack("!L", self.xid)) |
| 560 | packed.append(struct.pack("!H", self.err_type)) |
| 561 | packed.append(struct.pack("!H", self.code)) |
| 562 | packed.append(self.data) |
| 563 | length = sum([len(x) for x in packed]) |
| 564 | packed[2] = struct.pack("!H", length) |
| 565 | return ''.join(packed) |
| 566 | |
| 567 | @staticmethod |
| 568 | def unpack(buf): |
| 569 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 570 | obj = bad_request_error_msg() |
| 571 | if type(buf) == loxi.generic_util.OFReader: |
| 572 | reader = buf |
| 573 | else: |
| 574 | reader = loxi.generic_util.OFReader(buf) |
| 575 | _version = reader.read("!B")[0] |
| 576 | assert(_version == 2) |
| 577 | _type = reader.read("!B")[0] |
| 578 | assert(_type == 1) |
| 579 | _length = reader.read("!H")[0] |
| 580 | obj.xid = reader.read("!L")[0] |
| 581 | _err_type = reader.read("!H")[0] |
| 582 | assert(_err_type == 1) |
| 583 | obj.code = reader.read("!H")[0] |
| 584 | obj.data = str(reader.read_all()) |
| 585 | return obj |
| 586 | |
| 587 | def __eq__(self, other): |
| 588 | if type(self) != type(other): return False |
| 589 | if self.version != other.version: return False |
| 590 | if self.type != other.type: return False |
| 591 | if self.xid != other.xid: return False |
| 592 | if self.code != other.code: return False |
| 593 | if self.data != other.data: return False |
| 594 | return True |
| 595 | |
| 596 | def __ne__(self, other): |
| 597 | return not self.__eq__(other) |
| 598 | |
| 599 | def __str__(self): |
| 600 | return self.show() |
| 601 | |
| 602 | def show(self): |
| 603 | import loxi.pp |
| 604 | return loxi.pp.pp(self) |
| 605 | |
| 606 | def pretty_print(self, q): |
| 607 | q.text("bad_request_error_msg {") |
| 608 | with q.group(): |
| 609 | with q.indent(2): |
| 610 | q.breakable() |
| 611 | q.text("xid = "); |
| 612 | if self.xid != None: |
| 613 | q.text("%#x" % self.xid) |
| 614 | else: |
| 615 | q.text('None') |
| 616 | q.text(","); q.breakable() |
| 617 | q.text("code = "); |
| 618 | q.text("%#x" % self.code) |
| 619 | q.text(","); q.breakable() |
| 620 | q.text("data = "); |
| 621 | q.pp(self.data) |
| 622 | q.breakable() |
| 623 | q.text('}') |
| 624 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 625 | class barrier_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 626 | version = 2 |
| 627 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 628 | |
| 629 | def __init__(self, xid=None): |
| 630 | self.xid = xid |
| 631 | |
| 632 | def pack(self): |
| 633 | packed = [] |
| 634 | packed.append(struct.pack("!B", self.version)) |
| 635 | packed.append(struct.pack("!B", self.type)) |
| 636 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 637 | packed.append(struct.pack("!L", self.xid)) |
| 638 | length = sum([len(x) for x in packed]) |
| 639 | packed[2] = struct.pack("!H", length) |
| 640 | return ''.join(packed) |
| 641 | |
| 642 | @staticmethod |
| 643 | def unpack(buf): |
| 644 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 645 | obj = barrier_reply() |
| 646 | if type(buf) == loxi.generic_util.OFReader: |
| 647 | reader = buf |
| 648 | else: |
| 649 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 650 | _version = reader.read("!B")[0] |
| 651 | assert(_version == 2) |
| 652 | _type = reader.read("!B")[0] |
| 653 | assert(_type == 21) |
| 654 | _length = reader.read("!H")[0] |
| 655 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 656 | return obj |
| 657 | |
| 658 | def __eq__(self, other): |
| 659 | if type(self) != type(other): return False |
| 660 | if self.version != other.version: return False |
| 661 | if self.type != other.type: return False |
| 662 | if self.xid != other.xid: return False |
| 663 | return True |
| 664 | |
| 665 | def __ne__(self, other): |
| 666 | return not self.__eq__(other) |
| 667 | |
| 668 | def __str__(self): |
| 669 | return self.show() |
| 670 | |
| 671 | def show(self): |
| 672 | import loxi.pp |
| 673 | return loxi.pp.pp(self) |
| 674 | |
| 675 | def pretty_print(self, q): |
| 676 | q.text("barrier_reply {") |
| 677 | with q.group(): |
| 678 | with q.indent(2): |
| 679 | q.breakable() |
| 680 | q.text("xid = "); |
| 681 | if self.xid != None: |
| 682 | q.text("%#x" % self.xid) |
| 683 | else: |
| 684 | q.text('None') |
| 685 | q.breakable() |
| 686 | q.text('}') |
| 687 | |
| 688 | class barrier_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 689 | version = 2 |
| 690 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 691 | |
| 692 | def __init__(self, xid=None): |
| 693 | self.xid = xid |
| 694 | |
| 695 | def pack(self): |
| 696 | packed = [] |
| 697 | packed.append(struct.pack("!B", self.version)) |
| 698 | packed.append(struct.pack("!B", self.type)) |
| 699 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 700 | packed.append(struct.pack("!L", self.xid)) |
| 701 | length = sum([len(x) for x in packed]) |
| 702 | packed[2] = struct.pack("!H", length) |
| 703 | return ''.join(packed) |
| 704 | |
| 705 | @staticmethod |
| 706 | def unpack(buf): |
| 707 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 708 | obj = barrier_request() |
| 709 | if type(buf) == loxi.generic_util.OFReader: |
| 710 | reader = buf |
| 711 | else: |
| 712 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 713 | _version = reader.read("!B")[0] |
| 714 | assert(_version == 2) |
| 715 | _type = reader.read("!B")[0] |
| 716 | assert(_type == 20) |
| 717 | _length = reader.read("!H")[0] |
| 718 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 719 | return obj |
| 720 | |
| 721 | def __eq__(self, other): |
| 722 | if type(self) != type(other): return False |
| 723 | if self.version != other.version: return False |
| 724 | if self.type != other.type: return False |
| 725 | if self.xid != other.xid: return False |
| 726 | return True |
| 727 | |
| 728 | def __ne__(self, other): |
| 729 | return not self.__eq__(other) |
| 730 | |
| 731 | def __str__(self): |
| 732 | return self.show() |
| 733 | |
| 734 | def show(self): |
| 735 | import loxi.pp |
| 736 | return loxi.pp.pp(self) |
| 737 | |
| 738 | def pretty_print(self, q): |
| 739 | q.text("barrier_request {") |
| 740 | with q.group(): |
| 741 | with q.indent(2): |
| 742 | q.breakable() |
| 743 | q.text("xid = "); |
| 744 | if self.xid != None: |
| 745 | q.text("%#x" % self.xid) |
| 746 | else: |
| 747 | q.text('None') |
| 748 | q.breakable() |
| 749 | q.text('}') |
| 750 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 751 | class bsn_bw_clear_data_reply(Message): |
| 752 | version = 2 |
| 753 | type = 4 |
| 754 | experimenter = 6035143 |
| 755 | subtype = 22 |
| 756 | |
| 757 | def __init__(self, xid=None, status=None): |
| 758 | self.xid = xid |
| 759 | if status != None: |
| 760 | self.status = status |
| 761 | else: |
| 762 | self.status = 0 |
| 763 | |
| 764 | def pack(self): |
| 765 | packed = [] |
| 766 | packed.append(struct.pack("!B", self.version)) |
| 767 | packed.append(struct.pack("!B", self.type)) |
| 768 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 769 | packed.append(struct.pack("!L", self.xid)) |
| 770 | packed.append(struct.pack("!L", self.experimenter)) |
| 771 | packed.append(struct.pack("!L", self.subtype)) |
| 772 | packed.append(struct.pack("!L", self.status)) |
| 773 | length = sum([len(x) for x in packed]) |
| 774 | packed[2] = struct.pack("!H", length) |
| 775 | return ''.join(packed) |
| 776 | |
| 777 | @staticmethod |
| 778 | def unpack(buf): |
| 779 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 780 | obj = bsn_bw_clear_data_reply() |
| 781 | if type(buf) == loxi.generic_util.OFReader: |
| 782 | reader = buf |
| 783 | else: |
| 784 | reader = loxi.generic_util.OFReader(buf) |
| 785 | _version = reader.read("!B")[0] |
| 786 | assert(_version == 2) |
| 787 | _type = reader.read("!B")[0] |
| 788 | assert(_type == 4) |
| 789 | _length = reader.read("!H")[0] |
| 790 | obj.xid = reader.read("!L")[0] |
| 791 | _experimenter = reader.read("!L")[0] |
| 792 | assert(_experimenter == 6035143) |
| 793 | _subtype = reader.read("!L")[0] |
| 794 | assert(_subtype == 22) |
| 795 | obj.status = reader.read("!L")[0] |
| 796 | return obj |
| 797 | |
| 798 | def __eq__(self, other): |
| 799 | if type(self) != type(other): return False |
| 800 | if self.version != other.version: return False |
| 801 | if self.type != other.type: return False |
| 802 | if self.xid != other.xid: return False |
| 803 | if self.status != other.status: return False |
| 804 | return True |
| 805 | |
| 806 | def __ne__(self, other): |
| 807 | return not self.__eq__(other) |
| 808 | |
| 809 | def __str__(self): |
| 810 | return self.show() |
| 811 | |
| 812 | def show(self): |
| 813 | import loxi.pp |
| 814 | return loxi.pp.pp(self) |
| 815 | |
| 816 | def pretty_print(self, q): |
| 817 | q.text("bsn_bw_clear_data_reply {") |
| 818 | with q.group(): |
| 819 | with q.indent(2): |
| 820 | q.breakable() |
| 821 | q.text("xid = "); |
| 822 | if self.xid != None: |
| 823 | q.text("%#x" % self.xid) |
| 824 | else: |
| 825 | q.text('None') |
| 826 | q.text(","); q.breakable() |
| 827 | q.text("status = "); |
| 828 | q.text("%#x" % self.status) |
| 829 | q.breakable() |
| 830 | q.text('}') |
| 831 | |
| 832 | class bsn_bw_clear_data_request(Message): |
| 833 | version = 2 |
| 834 | type = 4 |
| 835 | experimenter = 6035143 |
| 836 | subtype = 21 |
| 837 | |
| 838 | def __init__(self, xid=None): |
| 839 | self.xid = xid |
| 840 | |
| 841 | def pack(self): |
| 842 | packed = [] |
| 843 | packed.append(struct.pack("!B", self.version)) |
| 844 | packed.append(struct.pack("!B", self.type)) |
| 845 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 846 | packed.append(struct.pack("!L", self.xid)) |
| 847 | packed.append(struct.pack("!L", self.experimenter)) |
| 848 | packed.append(struct.pack("!L", self.subtype)) |
| 849 | length = sum([len(x) for x in packed]) |
| 850 | packed[2] = struct.pack("!H", length) |
| 851 | return ''.join(packed) |
| 852 | |
| 853 | @staticmethod |
| 854 | def unpack(buf): |
| 855 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 856 | obj = bsn_bw_clear_data_request() |
| 857 | if type(buf) == loxi.generic_util.OFReader: |
| 858 | reader = buf |
| 859 | else: |
| 860 | reader = loxi.generic_util.OFReader(buf) |
| 861 | _version = reader.read("!B")[0] |
| 862 | assert(_version == 2) |
| 863 | _type = reader.read("!B")[0] |
| 864 | assert(_type == 4) |
| 865 | _length = reader.read("!H")[0] |
| 866 | obj.xid = reader.read("!L")[0] |
| 867 | _experimenter = reader.read("!L")[0] |
| 868 | assert(_experimenter == 6035143) |
| 869 | _subtype = reader.read("!L")[0] |
| 870 | assert(_subtype == 21) |
| 871 | return obj |
| 872 | |
| 873 | def __eq__(self, other): |
| 874 | if type(self) != type(other): return False |
| 875 | if self.version != other.version: return False |
| 876 | if self.type != other.type: return False |
| 877 | if self.xid != other.xid: return False |
| 878 | return True |
| 879 | |
| 880 | def __ne__(self, other): |
| 881 | return not self.__eq__(other) |
| 882 | |
| 883 | def __str__(self): |
| 884 | return self.show() |
| 885 | |
| 886 | def show(self): |
| 887 | import loxi.pp |
| 888 | return loxi.pp.pp(self) |
| 889 | |
| 890 | def pretty_print(self, q): |
| 891 | q.text("bsn_bw_clear_data_request {") |
| 892 | with q.group(): |
| 893 | with q.indent(2): |
| 894 | q.breakable() |
| 895 | q.text("xid = "); |
| 896 | if self.xid != None: |
| 897 | q.text("%#x" % self.xid) |
| 898 | else: |
| 899 | q.text('None') |
| 900 | q.breakable() |
| 901 | q.text('}') |
| 902 | |
| 903 | class bsn_bw_enable_get_reply(Message): |
| 904 | version = 2 |
| 905 | type = 4 |
| 906 | experimenter = 6035143 |
| 907 | subtype = 20 |
| 908 | |
| 909 | def __init__(self, xid=None, enabled=None): |
| 910 | self.xid = xid |
| 911 | if enabled != None: |
| 912 | self.enabled = enabled |
| 913 | else: |
| 914 | self.enabled = 0 |
| 915 | |
| 916 | def pack(self): |
| 917 | packed = [] |
| 918 | packed.append(struct.pack("!B", self.version)) |
| 919 | packed.append(struct.pack("!B", self.type)) |
| 920 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 921 | packed.append(struct.pack("!L", self.xid)) |
| 922 | packed.append(struct.pack("!L", self.experimenter)) |
| 923 | packed.append(struct.pack("!L", self.subtype)) |
| 924 | packed.append(struct.pack("!L", self.enabled)) |
| 925 | length = sum([len(x) for x in packed]) |
| 926 | packed[2] = struct.pack("!H", length) |
| 927 | return ''.join(packed) |
| 928 | |
| 929 | @staticmethod |
| 930 | def unpack(buf): |
| 931 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 932 | obj = bsn_bw_enable_get_reply() |
| 933 | if type(buf) == loxi.generic_util.OFReader: |
| 934 | reader = buf |
| 935 | else: |
| 936 | reader = loxi.generic_util.OFReader(buf) |
| 937 | _version = reader.read("!B")[0] |
| 938 | assert(_version == 2) |
| 939 | _type = reader.read("!B")[0] |
| 940 | assert(_type == 4) |
| 941 | _length = reader.read("!H")[0] |
| 942 | obj.xid = reader.read("!L")[0] |
| 943 | _experimenter = reader.read("!L")[0] |
| 944 | assert(_experimenter == 6035143) |
| 945 | _subtype = reader.read("!L")[0] |
| 946 | assert(_subtype == 20) |
| 947 | obj.enabled = reader.read("!L")[0] |
| 948 | return obj |
| 949 | |
| 950 | def __eq__(self, other): |
| 951 | if type(self) != type(other): return False |
| 952 | if self.version != other.version: return False |
| 953 | if self.type != other.type: return False |
| 954 | if self.xid != other.xid: return False |
| 955 | if self.enabled != other.enabled: return False |
| 956 | return True |
| 957 | |
| 958 | def __ne__(self, other): |
| 959 | return not self.__eq__(other) |
| 960 | |
| 961 | def __str__(self): |
| 962 | return self.show() |
| 963 | |
| 964 | def show(self): |
| 965 | import loxi.pp |
| 966 | return loxi.pp.pp(self) |
| 967 | |
| 968 | def pretty_print(self, q): |
| 969 | q.text("bsn_bw_enable_get_reply {") |
| 970 | with q.group(): |
| 971 | with q.indent(2): |
| 972 | q.breakable() |
| 973 | q.text("xid = "); |
| 974 | if self.xid != None: |
| 975 | q.text("%#x" % self.xid) |
| 976 | else: |
| 977 | q.text('None') |
| 978 | q.text(","); q.breakable() |
| 979 | q.text("enabled = "); |
| 980 | q.text("%#x" % self.enabled) |
| 981 | q.breakable() |
| 982 | q.text('}') |
| 983 | |
| 984 | class bsn_bw_enable_get_request(Message): |
| 985 | version = 2 |
| 986 | type = 4 |
| 987 | experimenter = 6035143 |
| 988 | subtype = 19 |
| 989 | |
| 990 | def __init__(self, xid=None): |
| 991 | self.xid = xid |
| 992 | |
| 993 | def pack(self): |
| 994 | packed = [] |
| 995 | packed.append(struct.pack("!B", self.version)) |
| 996 | packed.append(struct.pack("!B", self.type)) |
| 997 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 998 | packed.append(struct.pack("!L", self.xid)) |
| 999 | packed.append(struct.pack("!L", self.experimenter)) |
| 1000 | packed.append(struct.pack("!L", self.subtype)) |
| 1001 | length = sum([len(x) for x in packed]) |
| 1002 | packed[2] = struct.pack("!H", length) |
| 1003 | return ''.join(packed) |
| 1004 | |
| 1005 | @staticmethod |
| 1006 | def unpack(buf): |
| 1007 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1008 | obj = bsn_bw_enable_get_request() |
| 1009 | if type(buf) == loxi.generic_util.OFReader: |
| 1010 | reader = buf |
| 1011 | else: |
| 1012 | reader = loxi.generic_util.OFReader(buf) |
| 1013 | _version = reader.read("!B")[0] |
| 1014 | assert(_version == 2) |
| 1015 | _type = reader.read("!B")[0] |
| 1016 | assert(_type == 4) |
| 1017 | _length = reader.read("!H")[0] |
| 1018 | obj.xid = reader.read("!L")[0] |
| 1019 | _experimenter = reader.read("!L")[0] |
| 1020 | assert(_experimenter == 6035143) |
| 1021 | _subtype = reader.read("!L")[0] |
| 1022 | assert(_subtype == 19) |
| 1023 | return obj |
| 1024 | |
| 1025 | def __eq__(self, other): |
| 1026 | if type(self) != type(other): return False |
| 1027 | if self.version != other.version: return False |
| 1028 | if self.type != other.type: return False |
| 1029 | if self.xid != other.xid: return False |
| 1030 | return True |
| 1031 | |
| 1032 | def __ne__(self, other): |
| 1033 | return not self.__eq__(other) |
| 1034 | |
| 1035 | def __str__(self): |
| 1036 | return self.show() |
| 1037 | |
| 1038 | def show(self): |
| 1039 | import loxi.pp |
| 1040 | return loxi.pp.pp(self) |
| 1041 | |
| 1042 | def pretty_print(self, q): |
| 1043 | q.text("bsn_bw_enable_get_request {") |
| 1044 | with q.group(): |
| 1045 | with q.indent(2): |
| 1046 | q.breakable() |
| 1047 | q.text("xid = "); |
| 1048 | if self.xid != None: |
| 1049 | q.text("%#x" % self.xid) |
| 1050 | else: |
| 1051 | q.text('None') |
| 1052 | q.breakable() |
| 1053 | q.text('}') |
| 1054 | |
| 1055 | class bsn_bw_enable_set_reply(Message): |
| 1056 | version = 2 |
| 1057 | type = 4 |
| 1058 | experimenter = 6035143 |
| 1059 | subtype = 23 |
| 1060 | |
| 1061 | def __init__(self, xid=None, enable=None, status=None): |
| 1062 | self.xid = xid |
| 1063 | if enable != None: |
| 1064 | self.enable = enable |
| 1065 | else: |
| 1066 | self.enable = 0 |
| 1067 | if status != None: |
| 1068 | self.status = status |
| 1069 | else: |
| 1070 | self.status = 0 |
| 1071 | |
| 1072 | def pack(self): |
| 1073 | packed = [] |
| 1074 | packed.append(struct.pack("!B", self.version)) |
| 1075 | packed.append(struct.pack("!B", self.type)) |
| 1076 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1077 | packed.append(struct.pack("!L", self.xid)) |
| 1078 | packed.append(struct.pack("!L", self.experimenter)) |
| 1079 | packed.append(struct.pack("!L", self.subtype)) |
| 1080 | packed.append(struct.pack("!L", self.enable)) |
| 1081 | packed.append(struct.pack("!L", self.status)) |
| 1082 | length = sum([len(x) for x in packed]) |
| 1083 | packed[2] = struct.pack("!H", length) |
| 1084 | return ''.join(packed) |
| 1085 | |
| 1086 | @staticmethod |
| 1087 | def unpack(buf): |
| 1088 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1089 | obj = bsn_bw_enable_set_reply() |
| 1090 | if type(buf) == loxi.generic_util.OFReader: |
| 1091 | reader = buf |
| 1092 | else: |
| 1093 | reader = loxi.generic_util.OFReader(buf) |
| 1094 | _version = reader.read("!B")[0] |
| 1095 | assert(_version == 2) |
| 1096 | _type = reader.read("!B")[0] |
| 1097 | assert(_type == 4) |
| 1098 | _length = reader.read("!H")[0] |
| 1099 | obj.xid = reader.read("!L")[0] |
| 1100 | _experimenter = reader.read("!L")[0] |
| 1101 | assert(_experimenter == 6035143) |
| 1102 | _subtype = reader.read("!L")[0] |
| 1103 | assert(_subtype == 23) |
| 1104 | obj.enable = reader.read("!L")[0] |
| 1105 | obj.status = reader.read("!L")[0] |
| 1106 | return obj |
| 1107 | |
| 1108 | def __eq__(self, other): |
| 1109 | if type(self) != type(other): return False |
| 1110 | if self.version != other.version: return False |
| 1111 | if self.type != other.type: return False |
| 1112 | if self.xid != other.xid: return False |
| 1113 | if self.enable != other.enable: return False |
| 1114 | if self.status != other.status: return False |
| 1115 | return True |
| 1116 | |
| 1117 | def __ne__(self, other): |
| 1118 | return not self.__eq__(other) |
| 1119 | |
| 1120 | def __str__(self): |
| 1121 | return self.show() |
| 1122 | |
| 1123 | def show(self): |
| 1124 | import loxi.pp |
| 1125 | return loxi.pp.pp(self) |
| 1126 | |
| 1127 | def pretty_print(self, q): |
| 1128 | q.text("bsn_bw_enable_set_reply {") |
| 1129 | with q.group(): |
| 1130 | with q.indent(2): |
| 1131 | q.breakable() |
| 1132 | q.text("xid = "); |
| 1133 | if self.xid != None: |
| 1134 | q.text("%#x" % self.xid) |
| 1135 | else: |
| 1136 | q.text('None') |
| 1137 | q.text(","); q.breakable() |
| 1138 | q.text("enable = "); |
| 1139 | q.text("%#x" % self.enable) |
| 1140 | q.text(","); q.breakable() |
| 1141 | q.text("status = "); |
| 1142 | q.text("%#x" % self.status) |
| 1143 | q.breakable() |
| 1144 | q.text('}') |
| 1145 | |
| 1146 | class bsn_bw_enable_set_request(Message): |
| 1147 | version = 2 |
| 1148 | type = 4 |
| 1149 | experimenter = 6035143 |
| 1150 | subtype = 18 |
| 1151 | |
| 1152 | def __init__(self, xid=None, enable=None): |
| 1153 | self.xid = xid |
| 1154 | if enable != None: |
| 1155 | self.enable = enable |
| 1156 | else: |
| 1157 | self.enable = 0 |
| 1158 | |
| 1159 | def pack(self): |
| 1160 | packed = [] |
| 1161 | packed.append(struct.pack("!B", self.version)) |
| 1162 | packed.append(struct.pack("!B", self.type)) |
| 1163 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1164 | packed.append(struct.pack("!L", self.xid)) |
| 1165 | packed.append(struct.pack("!L", self.experimenter)) |
| 1166 | packed.append(struct.pack("!L", self.subtype)) |
| 1167 | packed.append(struct.pack("!L", self.enable)) |
| 1168 | length = sum([len(x) for x in packed]) |
| 1169 | packed[2] = struct.pack("!H", length) |
| 1170 | return ''.join(packed) |
| 1171 | |
| 1172 | @staticmethod |
| 1173 | def unpack(buf): |
| 1174 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1175 | obj = bsn_bw_enable_set_request() |
| 1176 | if type(buf) == loxi.generic_util.OFReader: |
| 1177 | reader = buf |
| 1178 | else: |
| 1179 | reader = loxi.generic_util.OFReader(buf) |
| 1180 | _version = reader.read("!B")[0] |
| 1181 | assert(_version == 2) |
| 1182 | _type = reader.read("!B")[0] |
| 1183 | assert(_type == 4) |
| 1184 | _length = reader.read("!H")[0] |
| 1185 | obj.xid = reader.read("!L")[0] |
| 1186 | _experimenter = reader.read("!L")[0] |
| 1187 | assert(_experimenter == 6035143) |
| 1188 | _subtype = reader.read("!L")[0] |
| 1189 | assert(_subtype == 18) |
| 1190 | obj.enable = reader.read("!L")[0] |
| 1191 | return obj |
| 1192 | |
| 1193 | def __eq__(self, other): |
| 1194 | if type(self) != type(other): return False |
| 1195 | if self.version != other.version: return False |
| 1196 | if self.type != other.type: return False |
| 1197 | if self.xid != other.xid: return False |
| 1198 | if self.enable != other.enable: return False |
| 1199 | return True |
| 1200 | |
| 1201 | def __ne__(self, other): |
| 1202 | return not self.__eq__(other) |
| 1203 | |
| 1204 | def __str__(self): |
| 1205 | return self.show() |
| 1206 | |
| 1207 | def show(self): |
| 1208 | import loxi.pp |
| 1209 | return loxi.pp.pp(self) |
| 1210 | |
| 1211 | def pretty_print(self, q): |
| 1212 | q.text("bsn_bw_enable_set_request {") |
| 1213 | with q.group(): |
| 1214 | with q.indent(2): |
| 1215 | q.breakable() |
| 1216 | q.text("xid = "); |
| 1217 | if self.xid != None: |
| 1218 | q.text("%#x" % self.xid) |
| 1219 | else: |
| 1220 | q.text('None') |
| 1221 | q.text(","); q.breakable() |
| 1222 | q.text("enable = "); |
| 1223 | q.text("%#x" % self.enable) |
| 1224 | q.breakable() |
| 1225 | q.text('}') |
| 1226 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1227 | class bsn_get_interfaces_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1228 | version = 2 |
| 1229 | type = 4 |
| 1230 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1231 | subtype = 10 |
| 1232 | |
| 1233 | def __init__(self, xid=None, interfaces=None): |
| 1234 | self.xid = xid |
| 1235 | if interfaces != None: |
| 1236 | self.interfaces = interfaces |
| 1237 | else: |
| 1238 | self.interfaces = [] |
| 1239 | |
| 1240 | def pack(self): |
| 1241 | packed = [] |
| 1242 | packed.append(struct.pack("!B", self.version)) |
| 1243 | packed.append(struct.pack("!B", self.type)) |
| 1244 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1245 | packed.append(struct.pack("!L", self.xid)) |
| 1246 | packed.append(struct.pack("!L", self.experimenter)) |
| 1247 | packed.append(struct.pack("!L", self.subtype)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1248 | packed.append(util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1249 | length = sum([len(x) for x in packed]) |
| 1250 | packed[2] = struct.pack("!H", length) |
| 1251 | return ''.join(packed) |
| 1252 | |
| 1253 | @staticmethod |
| 1254 | def unpack(buf): |
| 1255 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1256 | obj = bsn_get_interfaces_reply() |
| 1257 | if type(buf) == loxi.generic_util.OFReader: |
| 1258 | reader = buf |
| 1259 | else: |
| 1260 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1261 | _version = reader.read("!B")[0] |
| 1262 | assert(_version == 2) |
| 1263 | _type = reader.read("!B")[0] |
| 1264 | assert(_type == 4) |
| 1265 | _length = reader.read("!H")[0] |
| 1266 | obj.xid = reader.read("!L")[0] |
| 1267 | _experimenter = reader.read("!L")[0] |
| 1268 | assert(_experimenter == 6035143) |
| 1269 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1270 | assert(_subtype == 10) |
| 1271 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
| 1272 | return obj |
| 1273 | |
| 1274 | def __eq__(self, other): |
| 1275 | if type(self) != type(other): return False |
| 1276 | if self.version != other.version: return False |
| 1277 | if self.type != other.type: return False |
| 1278 | if self.xid != other.xid: return False |
| 1279 | if self.interfaces != other.interfaces: return False |
| 1280 | return True |
| 1281 | |
| 1282 | def __ne__(self, other): |
| 1283 | return not self.__eq__(other) |
| 1284 | |
| 1285 | def __str__(self): |
| 1286 | return self.show() |
| 1287 | |
| 1288 | def show(self): |
| 1289 | import loxi.pp |
| 1290 | return loxi.pp.pp(self) |
| 1291 | |
| 1292 | def pretty_print(self, q): |
| 1293 | q.text("bsn_get_interfaces_reply {") |
| 1294 | with q.group(): |
| 1295 | with q.indent(2): |
| 1296 | q.breakable() |
| 1297 | q.text("xid = "); |
| 1298 | if self.xid != None: |
| 1299 | q.text("%#x" % self.xid) |
| 1300 | else: |
| 1301 | q.text('None') |
| 1302 | q.text(","); q.breakable() |
| 1303 | q.text("interfaces = "); |
| 1304 | q.pp(self.interfaces) |
| 1305 | q.breakable() |
| 1306 | q.text('}') |
| 1307 | |
| 1308 | class bsn_get_interfaces_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1309 | version = 2 |
| 1310 | type = 4 |
| 1311 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1312 | subtype = 9 |
| 1313 | |
| 1314 | def __init__(self, xid=None): |
| 1315 | self.xid = xid |
| 1316 | |
| 1317 | def pack(self): |
| 1318 | packed = [] |
| 1319 | packed.append(struct.pack("!B", self.version)) |
| 1320 | packed.append(struct.pack("!B", self.type)) |
| 1321 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1322 | packed.append(struct.pack("!L", self.xid)) |
| 1323 | packed.append(struct.pack("!L", self.experimenter)) |
| 1324 | packed.append(struct.pack("!L", self.subtype)) |
| 1325 | length = sum([len(x) for x in packed]) |
| 1326 | packed[2] = struct.pack("!H", length) |
| 1327 | return ''.join(packed) |
| 1328 | |
| 1329 | @staticmethod |
| 1330 | def unpack(buf): |
| 1331 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1332 | obj = bsn_get_interfaces_request() |
| 1333 | if type(buf) == loxi.generic_util.OFReader: |
| 1334 | reader = buf |
| 1335 | else: |
| 1336 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1337 | _version = reader.read("!B")[0] |
| 1338 | assert(_version == 2) |
| 1339 | _type = reader.read("!B")[0] |
| 1340 | assert(_type == 4) |
| 1341 | _length = reader.read("!H")[0] |
| 1342 | obj.xid = reader.read("!L")[0] |
| 1343 | _experimenter = reader.read("!L")[0] |
| 1344 | assert(_experimenter == 6035143) |
| 1345 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1346 | assert(_subtype == 9) |
| 1347 | return obj |
| 1348 | |
| 1349 | def __eq__(self, other): |
| 1350 | if type(self) != type(other): return False |
| 1351 | if self.version != other.version: return False |
| 1352 | if self.type != other.type: return False |
| 1353 | if self.xid != other.xid: return False |
| 1354 | return True |
| 1355 | |
| 1356 | def __ne__(self, other): |
| 1357 | return not self.__eq__(other) |
| 1358 | |
| 1359 | def __str__(self): |
| 1360 | return self.show() |
| 1361 | |
| 1362 | def show(self): |
| 1363 | import loxi.pp |
| 1364 | return loxi.pp.pp(self) |
| 1365 | |
| 1366 | def pretty_print(self, q): |
| 1367 | q.text("bsn_get_interfaces_request {") |
| 1368 | with q.group(): |
| 1369 | with q.indent(2): |
| 1370 | q.breakable() |
| 1371 | q.text("xid = "); |
| 1372 | if self.xid != None: |
| 1373 | q.text("%#x" % self.xid) |
| 1374 | else: |
| 1375 | q.text('None') |
| 1376 | q.breakable() |
| 1377 | q.text('}') |
| 1378 | |
| 1379 | class bsn_get_mirroring_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1380 | version = 2 |
| 1381 | type = 4 |
| 1382 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1383 | subtype = 5 |
| 1384 | |
| 1385 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1386 | self.xid = xid |
| 1387 | if report_mirror_ports != None: |
| 1388 | self.report_mirror_ports = report_mirror_ports |
| 1389 | else: |
| 1390 | self.report_mirror_ports = 0 |
| 1391 | |
| 1392 | def pack(self): |
| 1393 | packed = [] |
| 1394 | packed.append(struct.pack("!B", self.version)) |
| 1395 | packed.append(struct.pack("!B", self.type)) |
| 1396 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1397 | packed.append(struct.pack("!L", self.xid)) |
| 1398 | packed.append(struct.pack("!L", self.experimenter)) |
| 1399 | packed.append(struct.pack("!L", self.subtype)) |
| 1400 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1401 | packed.append('\x00' * 3) |
| 1402 | length = sum([len(x) for x in packed]) |
| 1403 | packed[2] = struct.pack("!H", length) |
| 1404 | return ''.join(packed) |
| 1405 | |
| 1406 | @staticmethod |
| 1407 | def unpack(buf): |
| 1408 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1409 | obj = bsn_get_mirroring_reply() |
| 1410 | if type(buf) == loxi.generic_util.OFReader: |
| 1411 | reader = buf |
| 1412 | else: |
| 1413 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1414 | _version = reader.read("!B")[0] |
| 1415 | assert(_version == 2) |
| 1416 | _type = reader.read("!B")[0] |
| 1417 | assert(_type == 4) |
| 1418 | _length = reader.read("!H")[0] |
| 1419 | obj.xid = reader.read("!L")[0] |
| 1420 | _experimenter = reader.read("!L")[0] |
| 1421 | assert(_experimenter == 6035143) |
| 1422 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1423 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1424 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1425 | reader.skip(3) |
| 1426 | return obj |
| 1427 | |
| 1428 | def __eq__(self, other): |
| 1429 | if type(self) != type(other): return False |
| 1430 | if self.version != other.version: return False |
| 1431 | if self.type != other.type: return False |
| 1432 | if self.xid != other.xid: return False |
| 1433 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1434 | return True |
| 1435 | |
| 1436 | def __ne__(self, other): |
| 1437 | return not self.__eq__(other) |
| 1438 | |
| 1439 | def __str__(self): |
| 1440 | return self.show() |
| 1441 | |
| 1442 | def show(self): |
| 1443 | import loxi.pp |
| 1444 | return loxi.pp.pp(self) |
| 1445 | |
| 1446 | def pretty_print(self, q): |
| 1447 | q.text("bsn_get_mirroring_reply {") |
| 1448 | with q.group(): |
| 1449 | with q.indent(2): |
| 1450 | q.breakable() |
| 1451 | q.text("xid = "); |
| 1452 | if self.xid != None: |
| 1453 | q.text("%#x" % self.xid) |
| 1454 | else: |
| 1455 | q.text('None') |
| 1456 | q.text(","); q.breakable() |
| 1457 | q.text("report_mirror_ports = "); |
| 1458 | q.text("%#x" % self.report_mirror_ports) |
| 1459 | q.breakable() |
| 1460 | q.text('}') |
| 1461 | |
| 1462 | class bsn_get_mirroring_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1463 | version = 2 |
| 1464 | type = 4 |
| 1465 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1466 | subtype = 4 |
| 1467 | |
| 1468 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1469 | self.xid = xid |
| 1470 | if report_mirror_ports != None: |
| 1471 | self.report_mirror_ports = report_mirror_ports |
| 1472 | else: |
| 1473 | self.report_mirror_ports = 0 |
| 1474 | |
| 1475 | def pack(self): |
| 1476 | packed = [] |
| 1477 | packed.append(struct.pack("!B", self.version)) |
| 1478 | packed.append(struct.pack("!B", self.type)) |
| 1479 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1480 | packed.append(struct.pack("!L", self.xid)) |
| 1481 | packed.append(struct.pack("!L", self.experimenter)) |
| 1482 | packed.append(struct.pack("!L", self.subtype)) |
| 1483 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1484 | packed.append('\x00' * 3) |
| 1485 | length = sum([len(x) for x in packed]) |
| 1486 | packed[2] = struct.pack("!H", length) |
| 1487 | return ''.join(packed) |
| 1488 | |
| 1489 | @staticmethod |
| 1490 | def unpack(buf): |
| 1491 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1492 | obj = bsn_get_mirroring_request() |
| 1493 | if type(buf) == loxi.generic_util.OFReader: |
| 1494 | reader = buf |
| 1495 | else: |
| 1496 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1497 | _version = reader.read("!B")[0] |
| 1498 | assert(_version == 2) |
| 1499 | _type = reader.read("!B")[0] |
| 1500 | assert(_type == 4) |
| 1501 | _length = reader.read("!H")[0] |
| 1502 | obj.xid = reader.read("!L")[0] |
| 1503 | _experimenter = reader.read("!L")[0] |
| 1504 | assert(_experimenter == 6035143) |
| 1505 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1506 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1507 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1508 | reader.skip(3) |
| 1509 | return obj |
| 1510 | |
| 1511 | def __eq__(self, other): |
| 1512 | if type(self) != type(other): return False |
| 1513 | if self.version != other.version: return False |
| 1514 | if self.type != other.type: return False |
| 1515 | if self.xid != other.xid: return False |
| 1516 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1517 | return True |
| 1518 | |
| 1519 | def __ne__(self, other): |
| 1520 | return not self.__eq__(other) |
| 1521 | |
| 1522 | def __str__(self): |
| 1523 | return self.show() |
| 1524 | |
| 1525 | def show(self): |
| 1526 | import loxi.pp |
| 1527 | return loxi.pp.pp(self) |
| 1528 | |
| 1529 | def pretty_print(self, q): |
| 1530 | q.text("bsn_get_mirroring_request {") |
| 1531 | with q.group(): |
| 1532 | with q.indent(2): |
| 1533 | q.breakable() |
| 1534 | q.text("xid = "); |
| 1535 | if self.xid != None: |
| 1536 | q.text("%#x" % self.xid) |
| 1537 | else: |
| 1538 | q.text('None') |
| 1539 | q.text(","); q.breakable() |
| 1540 | q.text("report_mirror_ports = "); |
| 1541 | q.text("%#x" % self.report_mirror_ports) |
| 1542 | q.breakable() |
| 1543 | q.text('}') |
| 1544 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 1545 | class bsn_pdu_rx_reply(Message): |
| 1546 | version = 2 |
| 1547 | type = 4 |
| 1548 | experimenter = 6035143 |
| 1549 | subtype = 34 |
| 1550 | |
| 1551 | def __init__(self, xid=None, status=None): |
| 1552 | self.xid = xid |
| 1553 | if status != None: |
| 1554 | self.status = status |
| 1555 | else: |
| 1556 | self.status = 0 |
| 1557 | |
| 1558 | def pack(self): |
| 1559 | packed = [] |
| 1560 | packed.append(struct.pack("!B", self.version)) |
| 1561 | packed.append(struct.pack("!B", self.type)) |
| 1562 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1563 | packed.append(struct.pack("!L", self.xid)) |
| 1564 | packed.append(struct.pack("!L", self.experimenter)) |
| 1565 | packed.append(struct.pack("!L", self.subtype)) |
| 1566 | packed.append(struct.pack("!L", self.status)) |
| 1567 | length = sum([len(x) for x in packed]) |
| 1568 | packed[2] = struct.pack("!H", length) |
| 1569 | return ''.join(packed) |
| 1570 | |
| 1571 | @staticmethod |
| 1572 | def unpack(buf): |
| 1573 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1574 | obj = bsn_pdu_rx_reply() |
| 1575 | if type(buf) == loxi.generic_util.OFReader: |
| 1576 | reader = buf |
| 1577 | else: |
| 1578 | reader = loxi.generic_util.OFReader(buf) |
| 1579 | _version = reader.read("!B")[0] |
| 1580 | assert(_version == 2) |
| 1581 | _type = reader.read("!B")[0] |
| 1582 | assert(_type == 4) |
| 1583 | _length = reader.read("!H")[0] |
| 1584 | obj.xid = reader.read("!L")[0] |
| 1585 | _experimenter = reader.read("!L")[0] |
| 1586 | assert(_experimenter == 6035143) |
| 1587 | _subtype = reader.read("!L")[0] |
| 1588 | assert(_subtype == 34) |
| 1589 | obj.status = reader.read("!L")[0] |
| 1590 | return obj |
| 1591 | |
| 1592 | def __eq__(self, other): |
| 1593 | if type(self) != type(other): return False |
| 1594 | if self.version != other.version: return False |
| 1595 | if self.type != other.type: return False |
| 1596 | if self.xid != other.xid: return False |
| 1597 | if self.status != other.status: return False |
| 1598 | return True |
| 1599 | |
| 1600 | def __ne__(self, other): |
| 1601 | return not self.__eq__(other) |
| 1602 | |
| 1603 | def __str__(self): |
| 1604 | return self.show() |
| 1605 | |
| 1606 | def show(self): |
| 1607 | import loxi.pp |
| 1608 | return loxi.pp.pp(self) |
| 1609 | |
| 1610 | def pretty_print(self, q): |
| 1611 | q.text("bsn_pdu_rx_reply {") |
| 1612 | with q.group(): |
| 1613 | with q.indent(2): |
| 1614 | q.breakable() |
| 1615 | q.text("xid = "); |
| 1616 | if self.xid != None: |
| 1617 | q.text("%#x" % self.xid) |
| 1618 | else: |
| 1619 | q.text('None') |
| 1620 | q.text(","); q.breakable() |
| 1621 | q.text("status = "); |
| 1622 | q.text("%#x" % self.status) |
| 1623 | q.breakable() |
| 1624 | q.text('}') |
| 1625 | |
| 1626 | class bsn_pdu_rx_request(Message): |
| 1627 | version = 2 |
| 1628 | type = 4 |
| 1629 | experimenter = 6035143 |
| 1630 | subtype = 33 |
| 1631 | |
| 1632 | def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None): |
| 1633 | self.xid = xid |
| 1634 | if timeout_ms != None: |
| 1635 | self.timeout_ms = timeout_ms |
| 1636 | else: |
| 1637 | self.timeout_ms = 0 |
| 1638 | if port_no != None: |
| 1639 | self.port_no = port_no |
| 1640 | else: |
| 1641 | self.port_no = 0 |
| 1642 | if slot_num != None: |
| 1643 | self.slot_num = slot_num |
| 1644 | else: |
| 1645 | self.slot_num = 0 |
| 1646 | if data != None: |
| 1647 | self.data = data |
| 1648 | else: |
| 1649 | self.data = '' |
| 1650 | |
| 1651 | def pack(self): |
| 1652 | packed = [] |
| 1653 | packed.append(struct.pack("!B", self.version)) |
| 1654 | packed.append(struct.pack("!B", self.type)) |
| 1655 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1656 | packed.append(struct.pack("!L", self.xid)) |
| 1657 | packed.append(struct.pack("!L", self.experimenter)) |
| 1658 | packed.append(struct.pack("!L", self.subtype)) |
| 1659 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 1660 | packed.append(util.pack_port_no(self.port_no)) |
| 1661 | packed.append(struct.pack("!B", self.slot_num)) |
| 1662 | packed.append('\x00' * 3) |
| 1663 | packed.append(self.data) |
| 1664 | length = sum([len(x) for x in packed]) |
| 1665 | packed[2] = struct.pack("!H", length) |
| 1666 | return ''.join(packed) |
| 1667 | |
| 1668 | @staticmethod |
| 1669 | def unpack(buf): |
| 1670 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1671 | obj = bsn_pdu_rx_request() |
| 1672 | if type(buf) == loxi.generic_util.OFReader: |
| 1673 | reader = buf |
| 1674 | else: |
| 1675 | reader = loxi.generic_util.OFReader(buf) |
| 1676 | _version = reader.read("!B")[0] |
| 1677 | assert(_version == 2) |
| 1678 | _type = reader.read("!B")[0] |
| 1679 | assert(_type == 4) |
| 1680 | _length = reader.read("!H")[0] |
| 1681 | obj.xid = reader.read("!L")[0] |
| 1682 | _experimenter = reader.read("!L")[0] |
| 1683 | assert(_experimenter == 6035143) |
| 1684 | _subtype = reader.read("!L")[0] |
| 1685 | assert(_subtype == 33) |
| 1686 | obj.timeout_ms = reader.read("!L")[0] |
| 1687 | obj.port_no = util.unpack_port_no(reader) |
| 1688 | obj.slot_num = reader.read("!B")[0] |
| 1689 | reader.skip(3) |
| 1690 | obj.data = str(reader.read_all()) |
| 1691 | return obj |
| 1692 | |
| 1693 | def __eq__(self, other): |
| 1694 | if type(self) != type(other): return False |
| 1695 | if self.version != other.version: return False |
| 1696 | if self.type != other.type: return False |
| 1697 | if self.xid != other.xid: return False |
| 1698 | if self.timeout_ms != other.timeout_ms: return False |
| 1699 | if self.port_no != other.port_no: return False |
| 1700 | if self.slot_num != other.slot_num: return False |
| 1701 | if self.data != other.data: return False |
| 1702 | return True |
| 1703 | |
| 1704 | def __ne__(self, other): |
| 1705 | return not self.__eq__(other) |
| 1706 | |
| 1707 | def __str__(self): |
| 1708 | return self.show() |
| 1709 | |
| 1710 | def show(self): |
| 1711 | import loxi.pp |
| 1712 | return loxi.pp.pp(self) |
| 1713 | |
| 1714 | def pretty_print(self, q): |
| 1715 | q.text("bsn_pdu_rx_request {") |
| 1716 | with q.group(): |
| 1717 | with q.indent(2): |
| 1718 | q.breakable() |
| 1719 | q.text("xid = "); |
| 1720 | if self.xid != None: |
| 1721 | q.text("%#x" % self.xid) |
| 1722 | else: |
| 1723 | q.text('None') |
| 1724 | q.text(","); q.breakable() |
| 1725 | q.text("timeout_ms = "); |
| 1726 | q.text("%#x" % self.timeout_ms) |
| 1727 | q.text(","); q.breakable() |
| 1728 | q.text("port_no = "); |
| 1729 | q.text(util.pretty_port(self.port_no)) |
| 1730 | q.text(","); q.breakable() |
| 1731 | q.text("slot_num = "); |
| 1732 | q.text("%#x" % self.slot_num) |
| 1733 | q.text(","); q.breakable() |
| 1734 | q.text("data = "); |
| 1735 | q.pp(self.data) |
| 1736 | q.breakable() |
| 1737 | q.text('}') |
| 1738 | |
| 1739 | class bsn_pdu_rx_timeout(Message): |
| 1740 | version = 2 |
| 1741 | type = 4 |
| 1742 | experimenter = 6035143 |
| 1743 | subtype = 35 |
| 1744 | |
| 1745 | def __init__(self, xid=None, port_no=None, slot_num=None): |
| 1746 | self.xid = xid |
| 1747 | if port_no != None: |
| 1748 | self.port_no = port_no |
| 1749 | else: |
| 1750 | self.port_no = 0 |
| 1751 | if slot_num != None: |
| 1752 | self.slot_num = slot_num |
| 1753 | else: |
| 1754 | self.slot_num = 0 |
| 1755 | |
| 1756 | def pack(self): |
| 1757 | packed = [] |
| 1758 | packed.append(struct.pack("!B", self.version)) |
| 1759 | packed.append(struct.pack("!B", self.type)) |
| 1760 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1761 | packed.append(struct.pack("!L", self.xid)) |
| 1762 | packed.append(struct.pack("!L", self.experimenter)) |
| 1763 | packed.append(struct.pack("!L", self.subtype)) |
| 1764 | packed.append(util.pack_port_no(self.port_no)) |
| 1765 | packed.append(struct.pack("!B", self.slot_num)) |
| 1766 | length = sum([len(x) for x in packed]) |
| 1767 | packed[2] = struct.pack("!H", length) |
| 1768 | return ''.join(packed) |
| 1769 | |
| 1770 | @staticmethod |
| 1771 | def unpack(buf): |
| 1772 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1773 | obj = bsn_pdu_rx_timeout() |
| 1774 | if type(buf) == loxi.generic_util.OFReader: |
| 1775 | reader = buf |
| 1776 | else: |
| 1777 | reader = loxi.generic_util.OFReader(buf) |
| 1778 | _version = reader.read("!B")[0] |
| 1779 | assert(_version == 2) |
| 1780 | _type = reader.read("!B")[0] |
| 1781 | assert(_type == 4) |
| 1782 | _length = reader.read("!H")[0] |
| 1783 | obj.xid = reader.read("!L")[0] |
| 1784 | _experimenter = reader.read("!L")[0] |
| 1785 | assert(_experimenter == 6035143) |
| 1786 | _subtype = reader.read("!L")[0] |
| 1787 | assert(_subtype == 35) |
| 1788 | obj.port_no = util.unpack_port_no(reader) |
| 1789 | obj.slot_num = reader.read("!B")[0] |
| 1790 | return obj |
| 1791 | |
| 1792 | def __eq__(self, other): |
| 1793 | if type(self) != type(other): return False |
| 1794 | if self.version != other.version: return False |
| 1795 | if self.type != other.type: return False |
| 1796 | if self.xid != other.xid: return False |
| 1797 | if self.port_no != other.port_no: return False |
| 1798 | if self.slot_num != other.slot_num: return False |
| 1799 | return True |
| 1800 | |
| 1801 | def __ne__(self, other): |
| 1802 | return not self.__eq__(other) |
| 1803 | |
| 1804 | def __str__(self): |
| 1805 | return self.show() |
| 1806 | |
| 1807 | def show(self): |
| 1808 | import loxi.pp |
| 1809 | return loxi.pp.pp(self) |
| 1810 | |
| 1811 | def pretty_print(self, q): |
| 1812 | q.text("bsn_pdu_rx_timeout {") |
| 1813 | with q.group(): |
| 1814 | with q.indent(2): |
| 1815 | q.breakable() |
| 1816 | q.text("xid = "); |
| 1817 | if self.xid != None: |
| 1818 | q.text("%#x" % self.xid) |
| 1819 | else: |
| 1820 | q.text('None') |
| 1821 | q.text(","); q.breakable() |
| 1822 | q.text("port_no = "); |
| 1823 | q.text(util.pretty_port(self.port_no)) |
| 1824 | q.text(","); q.breakable() |
| 1825 | q.text("slot_num = "); |
| 1826 | q.text("%#x" % self.slot_num) |
| 1827 | q.breakable() |
| 1828 | q.text('}') |
| 1829 | |
| 1830 | class bsn_pdu_tx_reply(Message): |
| 1831 | version = 2 |
| 1832 | type = 4 |
| 1833 | experimenter = 6035143 |
| 1834 | subtype = 32 |
| 1835 | |
| 1836 | def __init__(self, xid=None, status=None): |
| 1837 | self.xid = xid |
| 1838 | if status != None: |
| 1839 | self.status = status |
| 1840 | else: |
| 1841 | self.status = 0 |
| 1842 | |
| 1843 | def pack(self): |
| 1844 | packed = [] |
| 1845 | packed.append(struct.pack("!B", self.version)) |
| 1846 | packed.append(struct.pack("!B", self.type)) |
| 1847 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1848 | packed.append(struct.pack("!L", self.xid)) |
| 1849 | packed.append(struct.pack("!L", self.experimenter)) |
| 1850 | packed.append(struct.pack("!L", self.subtype)) |
| 1851 | packed.append(struct.pack("!L", self.status)) |
| 1852 | length = sum([len(x) for x in packed]) |
| 1853 | packed[2] = struct.pack("!H", length) |
| 1854 | return ''.join(packed) |
| 1855 | |
| 1856 | @staticmethod |
| 1857 | def unpack(buf): |
| 1858 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1859 | obj = bsn_pdu_tx_reply() |
| 1860 | if type(buf) == loxi.generic_util.OFReader: |
| 1861 | reader = buf |
| 1862 | else: |
| 1863 | reader = loxi.generic_util.OFReader(buf) |
| 1864 | _version = reader.read("!B")[0] |
| 1865 | assert(_version == 2) |
| 1866 | _type = reader.read("!B")[0] |
| 1867 | assert(_type == 4) |
| 1868 | _length = reader.read("!H")[0] |
| 1869 | obj.xid = reader.read("!L")[0] |
| 1870 | _experimenter = reader.read("!L")[0] |
| 1871 | assert(_experimenter == 6035143) |
| 1872 | _subtype = reader.read("!L")[0] |
| 1873 | assert(_subtype == 32) |
| 1874 | obj.status = reader.read("!L")[0] |
| 1875 | return obj |
| 1876 | |
| 1877 | def __eq__(self, other): |
| 1878 | if type(self) != type(other): return False |
| 1879 | if self.version != other.version: return False |
| 1880 | if self.type != other.type: return False |
| 1881 | if self.xid != other.xid: return False |
| 1882 | if self.status != other.status: return False |
| 1883 | return True |
| 1884 | |
| 1885 | def __ne__(self, other): |
| 1886 | return not self.__eq__(other) |
| 1887 | |
| 1888 | def __str__(self): |
| 1889 | return self.show() |
| 1890 | |
| 1891 | def show(self): |
| 1892 | import loxi.pp |
| 1893 | return loxi.pp.pp(self) |
| 1894 | |
| 1895 | def pretty_print(self, q): |
| 1896 | q.text("bsn_pdu_tx_reply {") |
| 1897 | with q.group(): |
| 1898 | with q.indent(2): |
| 1899 | q.breakable() |
| 1900 | q.text("xid = "); |
| 1901 | if self.xid != None: |
| 1902 | q.text("%#x" % self.xid) |
| 1903 | else: |
| 1904 | q.text('None') |
| 1905 | q.text(","); q.breakable() |
| 1906 | q.text("status = "); |
| 1907 | q.text("%#x" % self.status) |
| 1908 | q.breakable() |
| 1909 | q.text('}') |
| 1910 | |
| 1911 | class bsn_pdu_tx_request(Message): |
| 1912 | version = 2 |
| 1913 | type = 4 |
| 1914 | experimenter = 6035143 |
| 1915 | subtype = 31 |
| 1916 | |
| 1917 | def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None): |
| 1918 | self.xid = xid |
| 1919 | if tx_interval_ms != None: |
| 1920 | self.tx_interval_ms = tx_interval_ms |
| 1921 | else: |
| 1922 | self.tx_interval_ms = 0 |
| 1923 | if port_no != None: |
| 1924 | self.port_no = port_no |
| 1925 | else: |
| 1926 | self.port_no = 0 |
| 1927 | if slot_num != None: |
| 1928 | self.slot_num = slot_num |
| 1929 | else: |
| 1930 | self.slot_num = 0 |
| 1931 | if data != None: |
| 1932 | self.data = data |
| 1933 | else: |
| 1934 | self.data = '' |
| 1935 | |
| 1936 | def pack(self): |
| 1937 | packed = [] |
| 1938 | packed.append(struct.pack("!B", self.version)) |
| 1939 | packed.append(struct.pack("!B", self.type)) |
| 1940 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1941 | packed.append(struct.pack("!L", self.xid)) |
| 1942 | packed.append(struct.pack("!L", self.experimenter)) |
| 1943 | packed.append(struct.pack("!L", self.subtype)) |
| 1944 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 1945 | packed.append(util.pack_port_no(self.port_no)) |
| 1946 | packed.append(struct.pack("!B", self.slot_num)) |
| 1947 | packed.append('\x00' * 3) |
| 1948 | packed.append(self.data) |
| 1949 | length = sum([len(x) for x in packed]) |
| 1950 | packed[2] = struct.pack("!H", length) |
| 1951 | return ''.join(packed) |
| 1952 | |
| 1953 | @staticmethod |
| 1954 | def unpack(buf): |
| 1955 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1956 | obj = bsn_pdu_tx_request() |
| 1957 | if type(buf) == loxi.generic_util.OFReader: |
| 1958 | reader = buf |
| 1959 | else: |
| 1960 | reader = loxi.generic_util.OFReader(buf) |
| 1961 | _version = reader.read("!B")[0] |
| 1962 | assert(_version == 2) |
| 1963 | _type = reader.read("!B")[0] |
| 1964 | assert(_type == 4) |
| 1965 | _length = reader.read("!H")[0] |
| 1966 | obj.xid = reader.read("!L")[0] |
| 1967 | _experimenter = reader.read("!L")[0] |
| 1968 | assert(_experimenter == 6035143) |
| 1969 | _subtype = reader.read("!L")[0] |
| 1970 | assert(_subtype == 31) |
| 1971 | obj.tx_interval_ms = reader.read("!L")[0] |
| 1972 | obj.port_no = util.unpack_port_no(reader) |
| 1973 | obj.slot_num = reader.read("!B")[0] |
| 1974 | reader.skip(3) |
| 1975 | obj.data = str(reader.read_all()) |
| 1976 | return obj |
| 1977 | |
| 1978 | def __eq__(self, other): |
| 1979 | if type(self) != type(other): return False |
| 1980 | if self.version != other.version: return False |
| 1981 | if self.type != other.type: return False |
| 1982 | if self.xid != other.xid: return False |
| 1983 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 1984 | if self.port_no != other.port_no: return False |
| 1985 | if self.slot_num != other.slot_num: return False |
| 1986 | if self.data != other.data: return False |
| 1987 | return True |
| 1988 | |
| 1989 | def __ne__(self, other): |
| 1990 | return not self.__eq__(other) |
| 1991 | |
| 1992 | def __str__(self): |
| 1993 | return self.show() |
| 1994 | |
| 1995 | def show(self): |
| 1996 | import loxi.pp |
| 1997 | return loxi.pp.pp(self) |
| 1998 | |
| 1999 | def pretty_print(self, q): |
| 2000 | q.text("bsn_pdu_tx_request {") |
| 2001 | with q.group(): |
| 2002 | with q.indent(2): |
| 2003 | q.breakable() |
| 2004 | q.text("xid = "); |
| 2005 | if self.xid != None: |
| 2006 | q.text("%#x" % self.xid) |
| 2007 | else: |
| 2008 | q.text('None') |
| 2009 | q.text(","); q.breakable() |
| 2010 | q.text("tx_interval_ms = "); |
| 2011 | q.text("%#x" % self.tx_interval_ms) |
| 2012 | q.text(","); q.breakable() |
| 2013 | q.text("port_no = "); |
| 2014 | q.text(util.pretty_port(self.port_no)) |
| 2015 | q.text(","); q.breakable() |
| 2016 | q.text("slot_num = "); |
| 2017 | q.text("%#x" % self.slot_num) |
| 2018 | q.text(","); q.breakable() |
| 2019 | q.text("data = "); |
| 2020 | q.pp(self.data) |
| 2021 | q.breakable() |
| 2022 | q.text('}') |
| 2023 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2024 | class bsn_set_mirroring(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2025 | version = 2 |
| 2026 | type = 4 |
| 2027 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2028 | subtype = 3 |
| 2029 | |
| 2030 | def __init__(self, xid=None, report_mirror_ports=None): |
| 2031 | self.xid = xid |
| 2032 | if report_mirror_ports != None: |
| 2033 | self.report_mirror_ports = report_mirror_ports |
| 2034 | else: |
| 2035 | self.report_mirror_ports = 0 |
| 2036 | |
| 2037 | def pack(self): |
| 2038 | packed = [] |
| 2039 | packed.append(struct.pack("!B", self.version)) |
| 2040 | packed.append(struct.pack("!B", self.type)) |
| 2041 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2042 | packed.append(struct.pack("!L", self.xid)) |
| 2043 | packed.append(struct.pack("!L", self.experimenter)) |
| 2044 | packed.append(struct.pack("!L", self.subtype)) |
| 2045 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2046 | packed.append('\x00' * 3) |
| 2047 | length = sum([len(x) for x in packed]) |
| 2048 | packed[2] = struct.pack("!H", length) |
| 2049 | return ''.join(packed) |
| 2050 | |
| 2051 | @staticmethod |
| 2052 | def unpack(buf): |
| 2053 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2054 | obj = bsn_set_mirroring() |
| 2055 | if type(buf) == loxi.generic_util.OFReader: |
| 2056 | reader = buf |
| 2057 | else: |
| 2058 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2059 | _version = reader.read("!B")[0] |
| 2060 | assert(_version == 2) |
| 2061 | _type = reader.read("!B")[0] |
| 2062 | assert(_type == 4) |
| 2063 | _length = reader.read("!H")[0] |
| 2064 | obj.xid = reader.read("!L")[0] |
| 2065 | _experimenter = reader.read("!L")[0] |
| 2066 | assert(_experimenter == 6035143) |
| 2067 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2068 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2069 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2070 | reader.skip(3) |
| 2071 | return obj |
| 2072 | |
| 2073 | def __eq__(self, other): |
| 2074 | if type(self) != type(other): return False |
| 2075 | if self.version != other.version: return False |
| 2076 | if self.type != other.type: return False |
| 2077 | if self.xid != other.xid: return False |
| 2078 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2079 | return True |
| 2080 | |
| 2081 | def __ne__(self, other): |
| 2082 | return not self.__eq__(other) |
| 2083 | |
| 2084 | def __str__(self): |
| 2085 | return self.show() |
| 2086 | |
| 2087 | def show(self): |
| 2088 | import loxi.pp |
| 2089 | return loxi.pp.pp(self) |
| 2090 | |
| 2091 | def pretty_print(self, q): |
| 2092 | q.text("bsn_set_mirroring {") |
| 2093 | with q.group(): |
| 2094 | with q.indent(2): |
| 2095 | q.breakable() |
| 2096 | q.text("xid = "); |
| 2097 | if self.xid != None: |
| 2098 | q.text("%#x" % self.xid) |
| 2099 | else: |
| 2100 | q.text('None') |
| 2101 | q.text(","); q.breakable() |
| 2102 | q.text("report_mirror_ports = "); |
| 2103 | q.text("%#x" % self.report_mirror_ports) |
| 2104 | q.breakable() |
| 2105 | q.text('}') |
| 2106 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2107 | class bsn_set_pktin_suppression_reply(Message): |
| 2108 | version = 2 |
| 2109 | type = 4 |
| 2110 | experimenter = 6035143 |
| 2111 | subtype = 25 |
| 2112 | |
| 2113 | def __init__(self, xid=None, status=None): |
| 2114 | self.xid = xid |
| 2115 | if status != None: |
| 2116 | self.status = status |
| 2117 | else: |
| 2118 | self.status = 0 |
| 2119 | |
| 2120 | def pack(self): |
| 2121 | packed = [] |
| 2122 | packed.append(struct.pack("!B", self.version)) |
| 2123 | packed.append(struct.pack("!B", self.type)) |
| 2124 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2125 | packed.append(struct.pack("!L", self.xid)) |
| 2126 | packed.append(struct.pack("!L", self.experimenter)) |
| 2127 | packed.append(struct.pack("!L", self.subtype)) |
| 2128 | packed.append(struct.pack("!L", self.status)) |
| 2129 | length = sum([len(x) for x in packed]) |
| 2130 | packed[2] = struct.pack("!H", length) |
| 2131 | return ''.join(packed) |
| 2132 | |
| 2133 | @staticmethod |
| 2134 | def unpack(buf): |
| 2135 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2136 | obj = bsn_set_pktin_suppression_reply() |
| 2137 | if type(buf) == loxi.generic_util.OFReader: |
| 2138 | reader = buf |
| 2139 | else: |
| 2140 | reader = loxi.generic_util.OFReader(buf) |
| 2141 | _version = reader.read("!B")[0] |
| 2142 | assert(_version == 2) |
| 2143 | _type = reader.read("!B")[0] |
| 2144 | assert(_type == 4) |
| 2145 | _length = reader.read("!H")[0] |
| 2146 | obj.xid = reader.read("!L")[0] |
| 2147 | _experimenter = reader.read("!L")[0] |
| 2148 | assert(_experimenter == 6035143) |
| 2149 | _subtype = reader.read("!L")[0] |
| 2150 | assert(_subtype == 25) |
| 2151 | obj.status = reader.read("!L")[0] |
| 2152 | return obj |
| 2153 | |
| 2154 | def __eq__(self, other): |
| 2155 | if type(self) != type(other): return False |
| 2156 | if self.version != other.version: return False |
| 2157 | if self.type != other.type: return False |
| 2158 | if self.xid != other.xid: return False |
| 2159 | if self.status != other.status: return False |
| 2160 | return True |
| 2161 | |
| 2162 | def __ne__(self, other): |
| 2163 | return not self.__eq__(other) |
| 2164 | |
| 2165 | def __str__(self): |
| 2166 | return self.show() |
| 2167 | |
| 2168 | def show(self): |
| 2169 | import loxi.pp |
| 2170 | return loxi.pp.pp(self) |
| 2171 | |
| 2172 | def pretty_print(self, q): |
| 2173 | q.text("bsn_set_pktin_suppression_reply {") |
| 2174 | with q.group(): |
| 2175 | with q.indent(2): |
| 2176 | q.breakable() |
| 2177 | q.text("xid = "); |
| 2178 | if self.xid != None: |
| 2179 | q.text("%#x" % self.xid) |
| 2180 | else: |
| 2181 | q.text('None') |
| 2182 | q.text(","); q.breakable() |
| 2183 | q.text("status = "); |
| 2184 | q.text("%#x" % self.status) |
| 2185 | q.breakable() |
| 2186 | q.text('}') |
| 2187 | |
| 2188 | class bsn_set_pktin_suppression_request(Message): |
| 2189 | version = 2 |
| 2190 | type = 4 |
| 2191 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2192 | subtype = 11 |
| 2193 | |
| 2194 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
| 2195 | self.xid = xid |
| 2196 | if enabled != None: |
| 2197 | self.enabled = enabled |
| 2198 | else: |
| 2199 | self.enabled = 0 |
| 2200 | if idle_timeout != None: |
| 2201 | self.idle_timeout = idle_timeout |
| 2202 | else: |
| 2203 | self.idle_timeout = 0 |
| 2204 | if hard_timeout != None: |
| 2205 | self.hard_timeout = hard_timeout |
| 2206 | else: |
| 2207 | self.hard_timeout = 0 |
| 2208 | if priority != None: |
| 2209 | self.priority = priority |
| 2210 | else: |
| 2211 | self.priority = 0 |
| 2212 | if cookie != None: |
| 2213 | self.cookie = cookie |
| 2214 | else: |
| 2215 | self.cookie = 0 |
| 2216 | |
| 2217 | def pack(self): |
| 2218 | packed = [] |
| 2219 | packed.append(struct.pack("!B", self.version)) |
| 2220 | packed.append(struct.pack("!B", self.type)) |
| 2221 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2222 | packed.append(struct.pack("!L", self.xid)) |
| 2223 | packed.append(struct.pack("!L", self.experimenter)) |
| 2224 | packed.append(struct.pack("!L", self.subtype)) |
| 2225 | packed.append(struct.pack("!B", self.enabled)) |
| 2226 | packed.append('\x00' * 1) |
| 2227 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2228 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2229 | packed.append(struct.pack("!H", self.priority)) |
| 2230 | packed.append(struct.pack("!Q", self.cookie)) |
| 2231 | length = sum([len(x) for x in packed]) |
| 2232 | packed[2] = struct.pack("!H", length) |
| 2233 | return ''.join(packed) |
| 2234 | |
| 2235 | @staticmethod |
| 2236 | def unpack(buf): |
| 2237 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2238 | obj = bsn_set_pktin_suppression_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2239 | if type(buf) == loxi.generic_util.OFReader: |
| 2240 | reader = buf |
| 2241 | else: |
| 2242 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2243 | _version = reader.read("!B")[0] |
| 2244 | assert(_version == 2) |
| 2245 | _type = reader.read("!B")[0] |
| 2246 | assert(_type == 4) |
| 2247 | _length = reader.read("!H")[0] |
| 2248 | obj.xid = reader.read("!L")[0] |
| 2249 | _experimenter = reader.read("!L")[0] |
| 2250 | assert(_experimenter == 6035143) |
| 2251 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2252 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2253 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2254 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2255 | obj.idle_timeout = reader.read("!H")[0] |
| 2256 | obj.hard_timeout = reader.read("!H")[0] |
| 2257 | obj.priority = reader.read("!H")[0] |
| 2258 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2259 | return obj |
| 2260 | |
| 2261 | def __eq__(self, other): |
| 2262 | if type(self) != type(other): return False |
| 2263 | if self.version != other.version: return False |
| 2264 | if self.type != other.type: return False |
| 2265 | if self.xid != other.xid: return False |
| 2266 | if self.enabled != other.enabled: return False |
| 2267 | if self.idle_timeout != other.idle_timeout: return False |
| 2268 | if self.hard_timeout != other.hard_timeout: return False |
| 2269 | if self.priority != other.priority: return False |
| 2270 | if self.cookie != other.cookie: return False |
| 2271 | return True |
| 2272 | |
| 2273 | def __ne__(self, other): |
| 2274 | return not self.__eq__(other) |
| 2275 | |
| 2276 | def __str__(self): |
| 2277 | return self.show() |
| 2278 | |
| 2279 | def show(self): |
| 2280 | import loxi.pp |
| 2281 | return loxi.pp.pp(self) |
| 2282 | |
| 2283 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2284 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2285 | with q.group(): |
| 2286 | with q.indent(2): |
| 2287 | q.breakable() |
| 2288 | q.text("xid = "); |
| 2289 | if self.xid != None: |
| 2290 | q.text("%#x" % self.xid) |
| 2291 | else: |
| 2292 | q.text('None') |
| 2293 | q.text(","); q.breakable() |
| 2294 | q.text("enabled = "); |
| 2295 | q.text("%#x" % self.enabled) |
| 2296 | q.text(","); q.breakable() |
| 2297 | q.text("idle_timeout = "); |
| 2298 | q.text("%#x" % self.idle_timeout) |
| 2299 | q.text(","); q.breakable() |
| 2300 | q.text("hard_timeout = "); |
| 2301 | q.text("%#x" % self.hard_timeout) |
| 2302 | q.text(","); q.breakable() |
| 2303 | q.text("priority = "); |
| 2304 | q.text("%#x" % self.priority) |
| 2305 | q.text(","); q.breakable() |
| 2306 | q.text("cookie = "); |
| 2307 | q.text("%#x" % self.cookie) |
| 2308 | q.breakable() |
| 2309 | q.text('}') |
| 2310 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2311 | class bsn_virtual_port_create_reply(Message): |
| 2312 | version = 2 |
| 2313 | type = 4 |
| 2314 | experimenter = 6035143 |
| 2315 | subtype = 16 |
| 2316 | |
| 2317 | def __init__(self, xid=None, status=None, vport_no=None): |
| 2318 | self.xid = xid |
| 2319 | if status != None: |
| 2320 | self.status = status |
| 2321 | else: |
| 2322 | self.status = 0 |
| 2323 | if vport_no != None: |
| 2324 | self.vport_no = vport_no |
| 2325 | else: |
| 2326 | self.vport_no = 0 |
| 2327 | |
| 2328 | def pack(self): |
| 2329 | packed = [] |
| 2330 | packed.append(struct.pack("!B", self.version)) |
| 2331 | packed.append(struct.pack("!B", self.type)) |
| 2332 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2333 | packed.append(struct.pack("!L", self.xid)) |
| 2334 | packed.append(struct.pack("!L", self.experimenter)) |
| 2335 | packed.append(struct.pack("!L", self.subtype)) |
| 2336 | packed.append(struct.pack("!L", self.status)) |
| 2337 | packed.append(struct.pack("!L", self.vport_no)) |
| 2338 | length = sum([len(x) for x in packed]) |
| 2339 | packed[2] = struct.pack("!H", length) |
| 2340 | return ''.join(packed) |
| 2341 | |
| 2342 | @staticmethod |
| 2343 | def unpack(buf): |
| 2344 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2345 | obj = bsn_virtual_port_create_reply() |
| 2346 | if type(buf) == loxi.generic_util.OFReader: |
| 2347 | reader = buf |
| 2348 | else: |
| 2349 | reader = loxi.generic_util.OFReader(buf) |
| 2350 | _version = reader.read("!B")[0] |
| 2351 | assert(_version == 2) |
| 2352 | _type = reader.read("!B")[0] |
| 2353 | assert(_type == 4) |
| 2354 | _length = reader.read("!H")[0] |
| 2355 | obj.xid = reader.read("!L")[0] |
| 2356 | _experimenter = reader.read("!L")[0] |
| 2357 | assert(_experimenter == 6035143) |
| 2358 | _subtype = reader.read("!L")[0] |
| 2359 | assert(_subtype == 16) |
| 2360 | obj.status = reader.read("!L")[0] |
| 2361 | obj.vport_no = reader.read("!L")[0] |
| 2362 | return obj |
| 2363 | |
| 2364 | def __eq__(self, other): |
| 2365 | if type(self) != type(other): return False |
| 2366 | if self.version != other.version: return False |
| 2367 | if self.type != other.type: return False |
| 2368 | if self.xid != other.xid: return False |
| 2369 | if self.status != other.status: return False |
| 2370 | if self.vport_no != other.vport_no: return False |
| 2371 | return True |
| 2372 | |
| 2373 | def __ne__(self, other): |
| 2374 | return not self.__eq__(other) |
| 2375 | |
| 2376 | def __str__(self): |
| 2377 | return self.show() |
| 2378 | |
| 2379 | def show(self): |
| 2380 | import loxi.pp |
| 2381 | return loxi.pp.pp(self) |
| 2382 | |
| 2383 | def pretty_print(self, q): |
| 2384 | q.text("bsn_virtual_port_create_reply {") |
| 2385 | with q.group(): |
| 2386 | with q.indent(2): |
| 2387 | q.breakable() |
| 2388 | q.text("xid = "); |
| 2389 | if self.xid != None: |
| 2390 | q.text("%#x" % self.xid) |
| 2391 | else: |
| 2392 | q.text('None') |
| 2393 | q.text(","); q.breakable() |
| 2394 | q.text("status = "); |
| 2395 | q.text("%#x" % self.status) |
| 2396 | q.text(","); q.breakable() |
| 2397 | q.text("vport_no = "); |
| 2398 | q.text("%#x" % self.vport_no) |
| 2399 | q.breakable() |
| 2400 | q.text('}') |
| 2401 | |
| 2402 | class bsn_virtual_port_create_request(Message): |
| 2403 | version = 2 |
| 2404 | type = 4 |
| 2405 | experimenter = 6035143 |
| 2406 | subtype = 15 |
| 2407 | |
| 2408 | def __init__(self, xid=None, vport=None): |
| 2409 | self.xid = xid |
| 2410 | if vport != None: |
| 2411 | self.vport = vport |
| 2412 | else: |
| 2413 | self.vport = common.bsn_vport_q_in_q() |
| 2414 | |
| 2415 | def pack(self): |
| 2416 | packed = [] |
| 2417 | packed.append(struct.pack("!B", self.version)) |
| 2418 | packed.append(struct.pack("!B", self.type)) |
| 2419 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2420 | packed.append(struct.pack("!L", self.xid)) |
| 2421 | packed.append(struct.pack("!L", self.experimenter)) |
| 2422 | packed.append(struct.pack("!L", self.subtype)) |
| 2423 | packed.append(self.vport.pack()) |
| 2424 | length = sum([len(x) for x in packed]) |
| 2425 | packed[2] = struct.pack("!H", length) |
| 2426 | return ''.join(packed) |
| 2427 | |
| 2428 | @staticmethod |
| 2429 | def unpack(buf): |
| 2430 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2431 | obj = bsn_virtual_port_create_request() |
| 2432 | if type(buf) == loxi.generic_util.OFReader: |
| 2433 | reader = buf |
| 2434 | else: |
| 2435 | reader = loxi.generic_util.OFReader(buf) |
| 2436 | _version = reader.read("!B")[0] |
| 2437 | assert(_version == 2) |
| 2438 | _type = reader.read("!B")[0] |
| 2439 | assert(_type == 4) |
| 2440 | _length = reader.read("!H")[0] |
| 2441 | obj.xid = reader.read("!L")[0] |
| 2442 | _experimenter = reader.read("!L")[0] |
| 2443 | assert(_experimenter == 6035143) |
| 2444 | _subtype = reader.read("!L")[0] |
| 2445 | assert(_subtype == 15) |
| 2446 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 2447 | return obj |
| 2448 | |
| 2449 | def __eq__(self, other): |
| 2450 | if type(self) != type(other): return False |
| 2451 | if self.version != other.version: return False |
| 2452 | if self.type != other.type: return False |
| 2453 | if self.xid != other.xid: return False |
| 2454 | if self.vport != other.vport: return False |
| 2455 | return True |
| 2456 | |
| 2457 | def __ne__(self, other): |
| 2458 | return not self.__eq__(other) |
| 2459 | |
| 2460 | def __str__(self): |
| 2461 | return self.show() |
| 2462 | |
| 2463 | def show(self): |
| 2464 | import loxi.pp |
| 2465 | return loxi.pp.pp(self) |
| 2466 | |
| 2467 | def pretty_print(self, q): |
| 2468 | q.text("bsn_virtual_port_create_request {") |
| 2469 | with q.group(): |
| 2470 | with q.indent(2): |
| 2471 | q.breakable() |
| 2472 | q.text("xid = "); |
| 2473 | if self.xid != None: |
| 2474 | q.text("%#x" % self.xid) |
| 2475 | else: |
| 2476 | q.text('None') |
| 2477 | q.text(","); q.breakable() |
| 2478 | q.text("vport = "); |
| 2479 | q.pp(self.vport) |
| 2480 | q.breakable() |
| 2481 | q.text('}') |
| 2482 | |
| 2483 | class bsn_virtual_port_remove_reply(Message): |
| 2484 | version = 2 |
| 2485 | type = 4 |
| 2486 | experimenter = 6035143 |
| 2487 | subtype = 26 |
| 2488 | |
| 2489 | def __init__(self, xid=None, status=None): |
| 2490 | self.xid = xid |
| 2491 | if status != None: |
| 2492 | self.status = status |
| 2493 | else: |
| 2494 | self.status = 0 |
| 2495 | |
| 2496 | def pack(self): |
| 2497 | packed = [] |
| 2498 | packed.append(struct.pack("!B", self.version)) |
| 2499 | packed.append(struct.pack("!B", self.type)) |
| 2500 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2501 | packed.append(struct.pack("!L", self.xid)) |
| 2502 | packed.append(struct.pack("!L", self.experimenter)) |
| 2503 | packed.append(struct.pack("!L", self.subtype)) |
| 2504 | packed.append(struct.pack("!L", self.status)) |
| 2505 | length = sum([len(x) for x in packed]) |
| 2506 | packed[2] = struct.pack("!H", length) |
| 2507 | return ''.join(packed) |
| 2508 | |
| 2509 | @staticmethod |
| 2510 | def unpack(buf): |
| 2511 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2512 | obj = bsn_virtual_port_remove_reply() |
| 2513 | if type(buf) == loxi.generic_util.OFReader: |
| 2514 | reader = buf |
| 2515 | else: |
| 2516 | reader = loxi.generic_util.OFReader(buf) |
| 2517 | _version = reader.read("!B")[0] |
| 2518 | assert(_version == 2) |
| 2519 | _type = reader.read("!B")[0] |
| 2520 | assert(_type == 4) |
| 2521 | _length = reader.read("!H")[0] |
| 2522 | obj.xid = reader.read("!L")[0] |
| 2523 | _experimenter = reader.read("!L")[0] |
| 2524 | assert(_experimenter == 6035143) |
| 2525 | _subtype = reader.read("!L")[0] |
| 2526 | assert(_subtype == 26) |
| 2527 | obj.status = reader.read("!L")[0] |
| 2528 | return obj |
| 2529 | |
| 2530 | def __eq__(self, other): |
| 2531 | if type(self) != type(other): return False |
| 2532 | if self.version != other.version: return False |
| 2533 | if self.type != other.type: return False |
| 2534 | if self.xid != other.xid: return False |
| 2535 | if self.status != other.status: return False |
| 2536 | return True |
| 2537 | |
| 2538 | def __ne__(self, other): |
| 2539 | return not self.__eq__(other) |
| 2540 | |
| 2541 | def __str__(self): |
| 2542 | return self.show() |
| 2543 | |
| 2544 | def show(self): |
| 2545 | import loxi.pp |
| 2546 | return loxi.pp.pp(self) |
| 2547 | |
| 2548 | def pretty_print(self, q): |
| 2549 | q.text("bsn_virtual_port_remove_reply {") |
| 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("status = "); |
| 2560 | q.text("%#x" % self.status) |
| 2561 | q.breakable() |
| 2562 | q.text('}') |
| 2563 | |
| 2564 | class bsn_virtual_port_remove_request(Message): |
| 2565 | version = 2 |
| 2566 | type = 4 |
| 2567 | experimenter = 6035143 |
| 2568 | subtype = 17 |
| 2569 | |
| 2570 | def __init__(self, xid=None, vport_no=None): |
| 2571 | self.xid = xid |
| 2572 | if vport_no != None: |
| 2573 | self.vport_no = vport_no |
| 2574 | else: |
| 2575 | self.vport_no = 0 |
| 2576 | |
| 2577 | def pack(self): |
| 2578 | packed = [] |
| 2579 | packed.append(struct.pack("!B", self.version)) |
| 2580 | packed.append(struct.pack("!B", self.type)) |
| 2581 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2582 | packed.append(struct.pack("!L", self.xid)) |
| 2583 | packed.append(struct.pack("!L", self.experimenter)) |
| 2584 | packed.append(struct.pack("!L", self.subtype)) |
| 2585 | packed.append(struct.pack("!L", self.vport_no)) |
| 2586 | length = sum([len(x) for x in packed]) |
| 2587 | packed[2] = struct.pack("!H", length) |
| 2588 | return ''.join(packed) |
| 2589 | |
| 2590 | @staticmethod |
| 2591 | def unpack(buf): |
| 2592 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2593 | obj = bsn_virtual_port_remove_request() |
| 2594 | if type(buf) == loxi.generic_util.OFReader: |
| 2595 | reader = buf |
| 2596 | else: |
| 2597 | reader = loxi.generic_util.OFReader(buf) |
| 2598 | _version = reader.read("!B")[0] |
| 2599 | assert(_version == 2) |
| 2600 | _type = reader.read("!B")[0] |
| 2601 | assert(_type == 4) |
| 2602 | _length = reader.read("!H")[0] |
| 2603 | obj.xid = reader.read("!L")[0] |
| 2604 | _experimenter = reader.read("!L")[0] |
| 2605 | assert(_experimenter == 6035143) |
| 2606 | _subtype = reader.read("!L")[0] |
| 2607 | assert(_subtype == 17) |
| 2608 | obj.vport_no = reader.read("!L")[0] |
| 2609 | return obj |
| 2610 | |
| 2611 | def __eq__(self, other): |
| 2612 | if type(self) != type(other): return False |
| 2613 | if self.version != other.version: return False |
| 2614 | if self.type != other.type: return False |
| 2615 | if self.xid != other.xid: return False |
| 2616 | if self.vport_no != other.vport_no: return False |
| 2617 | return True |
| 2618 | |
| 2619 | def __ne__(self, other): |
| 2620 | return not self.__eq__(other) |
| 2621 | |
| 2622 | def __str__(self): |
| 2623 | return self.show() |
| 2624 | |
| 2625 | def show(self): |
| 2626 | import loxi.pp |
| 2627 | return loxi.pp.pp(self) |
| 2628 | |
| 2629 | def pretty_print(self, q): |
| 2630 | q.text("bsn_virtual_port_remove_request {") |
| 2631 | with q.group(): |
| 2632 | with q.indent(2): |
| 2633 | q.breakable() |
| 2634 | q.text("xid = "); |
| 2635 | if self.xid != None: |
| 2636 | q.text("%#x" % self.xid) |
| 2637 | else: |
| 2638 | q.text('None') |
| 2639 | q.text(","); q.breakable() |
| 2640 | q.text("vport_no = "); |
| 2641 | q.text("%#x" % self.vport_no) |
| 2642 | q.breakable() |
| 2643 | q.text('}') |
| 2644 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2645 | class desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2646 | version = 2 |
| 2647 | type = 19 |
| 2648 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2649 | |
| 2650 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
| 2651 | self.xid = xid |
| 2652 | if flags != None: |
| 2653 | self.flags = flags |
| 2654 | else: |
| 2655 | self.flags = 0 |
| 2656 | if mfr_desc != None: |
| 2657 | self.mfr_desc = mfr_desc |
| 2658 | else: |
| 2659 | self.mfr_desc = "" |
| 2660 | if hw_desc != None: |
| 2661 | self.hw_desc = hw_desc |
| 2662 | else: |
| 2663 | self.hw_desc = "" |
| 2664 | if sw_desc != None: |
| 2665 | self.sw_desc = sw_desc |
| 2666 | else: |
| 2667 | self.sw_desc = "" |
| 2668 | if serial_num != None: |
| 2669 | self.serial_num = serial_num |
| 2670 | else: |
| 2671 | self.serial_num = "" |
| 2672 | if dp_desc != None: |
| 2673 | self.dp_desc = dp_desc |
| 2674 | else: |
| 2675 | self.dp_desc = "" |
| 2676 | |
| 2677 | def pack(self): |
| 2678 | packed = [] |
| 2679 | packed.append(struct.pack("!B", self.version)) |
| 2680 | packed.append(struct.pack("!B", self.type)) |
| 2681 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2682 | packed.append(struct.pack("!L", self.xid)) |
| 2683 | packed.append(struct.pack("!H", self.stats_type)) |
| 2684 | packed.append(struct.pack("!H", self.flags)) |
| 2685 | packed.append('\x00' * 4) |
| 2686 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 2687 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 2688 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 2689 | packed.append(struct.pack("!32s", self.serial_num)) |
| 2690 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 2691 | length = sum([len(x) for x in packed]) |
| 2692 | packed[2] = struct.pack("!H", length) |
| 2693 | return ''.join(packed) |
| 2694 | |
| 2695 | @staticmethod |
| 2696 | def unpack(buf): |
| 2697 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2698 | obj = desc_stats_reply() |
| 2699 | if type(buf) == loxi.generic_util.OFReader: |
| 2700 | reader = buf |
| 2701 | else: |
| 2702 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2703 | _version = reader.read("!B")[0] |
| 2704 | assert(_version == 2) |
| 2705 | _type = reader.read("!B")[0] |
| 2706 | assert(_type == 19) |
| 2707 | _length = reader.read("!H")[0] |
| 2708 | obj.xid = reader.read("!L")[0] |
| 2709 | _stats_type = reader.read("!H")[0] |
| 2710 | assert(_stats_type == 0) |
| 2711 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2712 | reader.skip(4) |
| 2713 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2714 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2715 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2716 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 2717 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2718 | return obj |
| 2719 | |
| 2720 | def __eq__(self, other): |
| 2721 | if type(self) != type(other): return False |
| 2722 | if self.version != other.version: return False |
| 2723 | if self.type != other.type: return False |
| 2724 | if self.xid != other.xid: return False |
| 2725 | if self.flags != other.flags: return False |
| 2726 | if self.mfr_desc != other.mfr_desc: return False |
| 2727 | if self.hw_desc != other.hw_desc: return False |
| 2728 | if self.sw_desc != other.sw_desc: return False |
| 2729 | if self.serial_num != other.serial_num: return False |
| 2730 | if self.dp_desc != other.dp_desc: return False |
| 2731 | return True |
| 2732 | |
| 2733 | def __ne__(self, other): |
| 2734 | return not self.__eq__(other) |
| 2735 | |
| 2736 | def __str__(self): |
| 2737 | return self.show() |
| 2738 | |
| 2739 | def show(self): |
| 2740 | import loxi.pp |
| 2741 | return loxi.pp.pp(self) |
| 2742 | |
| 2743 | def pretty_print(self, q): |
| 2744 | q.text("desc_stats_reply {") |
| 2745 | with q.group(): |
| 2746 | with q.indent(2): |
| 2747 | q.breakable() |
| 2748 | q.text("xid = "); |
| 2749 | if self.xid != None: |
| 2750 | q.text("%#x" % self.xid) |
| 2751 | else: |
| 2752 | q.text('None') |
| 2753 | q.text(","); q.breakable() |
| 2754 | q.text("flags = "); |
| 2755 | q.text("%#x" % self.flags) |
| 2756 | q.text(","); q.breakable() |
| 2757 | q.text("mfr_desc = "); |
| 2758 | q.pp(self.mfr_desc) |
| 2759 | q.text(","); q.breakable() |
| 2760 | q.text("hw_desc = "); |
| 2761 | q.pp(self.hw_desc) |
| 2762 | q.text(","); q.breakable() |
| 2763 | q.text("sw_desc = "); |
| 2764 | q.pp(self.sw_desc) |
| 2765 | q.text(","); q.breakable() |
| 2766 | q.text("serial_num = "); |
| 2767 | q.pp(self.serial_num) |
| 2768 | q.text(","); q.breakable() |
| 2769 | q.text("dp_desc = "); |
| 2770 | q.pp(self.dp_desc) |
| 2771 | q.breakable() |
| 2772 | q.text('}') |
| 2773 | |
| 2774 | class desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2775 | version = 2 |
| 2776 | type = 18 |
| 2777 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2778 | |
| 2779 | def __init__(self, xid=None, flags=None): |
| 2780 | self.xid = xid |
| 2781 | if flags != None: |
| 2782 | self.flags = flags |
| 2783 | else: |
| 2784 | self.flags = 0 |
| 2785 | |
| 2786 | def pack(self): |
| 2787 | packed = [] |
| 2788 | packed.append(struct.pack("!B", self.version)) |
| 2789 | packed.append(struct.pack("!B", self.type)) |
| 2790 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2791 | packed.append(struct.pack("!L", self.xid)) |
| 2792 | packed.append(struct.pack("!H", self.stats_type)) |
| 2793 | packed.append(struct.pack("!H", self.flags)) |
| 2794 | packed.append('\x00' * 4) |
| 2795 | length = sum([len(x) for x in packed]) |
| 2796 | packed[2] = struct.pack("!H", length) |
| 2797 | return ''.join(packed) |
| 2798 | |
| 2799 | @staticmethod |
| 2800 | def unpack(buf): |
| 2801 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2802 | obj = desc_stats_request() |
| 2803 | if type(buf) == loxi.generic_util.OFReader: |
| 2804 | reader = buf |
| 2805 | else: |
| 2806 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2807 | _version = reader.read("!B")[0] |
| 2808 | assert(_version == 2) |
| 2809 | _type = reader.read("!B")[0] |
| 2810 | assert(_type == 18) |
| 2811 | _length = reader.read("!H")[0] |
| 2812 | obj.xid = reader.read("!L")[0] |
| 2813 | _stats_type = reader.read("!H")[0] |
| 2814 | assert(_stats_type == 0) |
| 2815 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2816 | reader.skip(4) |
| 2817 | return obj |
| 2818 | |
| 2819 | def __eq__(self, other): |
| 2820 | if type(self) != type(other): return False |
| 2821 | if self.version != other.version: return False |
| 2822 | if self.type != other.type: return False |
| 2823 | if self.xid != other.xid: return False |
| 2824 | if self.flags != other.flags: return False |
| 2825 | return True |
| 2826 | |
| 2827 | def __ne__(self, other): |
| 2828 | return not self.__eq__(other) |
| 2829 | |
| 2830 | def __str__(self): |
| 2831 | return self.show() |
| 2832 | |
| 2833 | def show(self): |
| 2834 | import loxi.pp |
| 2835 | return loxi.pp.pp(self) |
| 2836 | |
| 2837 | def pretty_print(self, q): |
| 2838 | q.text("desc_stats_request {") |
| 2839 | with q.group(): |
| 2840 | with q.indent(2): |
| 2841 | q.breakable() |
| 2842 | q.text("xid = "); |
| 2843 | if self.xid != None: |
| 2844 | q.text("%#x" % self.xid) |
| 2845 | else: |
| 2846 | q.text('None') |
| 2847 | q.text(","); q.breakable() |
| 2848 | q.text("flags = "); |
| 2849 | q.text("%#x" % self.flags) |
| 2850 | q.breakable() |
| 2851 | q.text('}') |
| 2852 | |
| 2853 | class echo_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2854 | version = 2 |
| 2855 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2856 | |
| 2857 | def __init__(self, xid=None, data=None): |
| 2858 | self.xid = xid |
| 2859 | if data != None: |
| 2860 | self.data = data |
| 2861 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2862 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2863 | |
| 2864 | def pack(self): |
| 2865 | packed = [] |
| 2866 | packed.append(struct.pack("!B", self.version)) |
| 2867 | packed.append(struct.pack("!B", self.type)) |
| 2868 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2869 | packed.append(struct.pack("!L", self.xid)) |
| 2870 | packed.append(self.data) |
| 2871 | length = sum([len(x) for x in packed]) |
| 2872 | packed[2] = struct.pack("!H", length) |
| 2873 | return ''.join(packed) |
| 2874 | |
| 2875 | @staticmethod |
| 2876 | def unpack(buf): |
| 2877 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2878 | obj = echo_reply() |
| 2879 | if type(buf) == loxi.generic_util.OFReader: |
| 2880 | reader = buf |
| 2881 | else: |
| 2882 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2883 | _version = reader.read("!B")[0] |
| 2884 | assert(_version == 2) |
| 2885 | _type = reader.read("!B")[0] |
| 2886 | assert(_type == 3) |
| 2887 | _length = reader.read("!H")[0] |
| 2888 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2889 | obj.data = str(reader.read_all()) |
| 2890 | return obj |
| 2891 | |
| 2892 | def __eq__(self, other): |
| 2893 | if type(self) != type(other): return False |
| 2894 | if self.version != other.version: return False |
| 2895 | if self.type != other.type: return False |
| 2896 | if self.xid != other.xid: return False |
| 2897 | if self.data != other.data: return False |
| 2898 | return True |
| 2899 | |
| 2900 | def __ne__(self, other): |
| 2901 | return not self.__eq__(other) |
| 2902 | |
| 2903 | def __str__(self): |
| 2904 | return self.show() |
| 2905 | |
| 2906 | def show(self): |
| 2907 | import loxi.pp |
| 2908 | return loxi.pp.pp(self) |
| 2909 | |
| 2910 | def pretty_print(self, q): |
| 2911 | q.text("echo_reply {") |
| 2912 | with q.group(): |
| 2913 | with q.indent(2): |
| 2914 | q.breakable() |
| 2915 | q.text("xid = "); |
| 2916 | if self.xid != None: |
| 2917 | q.text("%#x" % self.xid) |
| 2918 | else: |
| 2919 | q.text('None') |
| 2920 | q.text(","); q.breakable() |
| 2921 | q.text("data = "); |
| 2922 | q.pp(self.data) |
| 2923 | q.breakable() |
| 2924 | q.text('}') |
| 2925 | |
| 2926 | class echo_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2927 | version = 2 |
| 2928 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2929 | |
| 2930 | def __init__(self, xid=None, data=None): |
| 2931 | self.xid = xid |
| 2932 | if data != None: |
| 2933 | self.data = data |
| 2934 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2935 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2936 | |
| 2937 | def pack(self): |
| 2938 | packed = [] |
| 2939 | packed.append(struct.pack("!B", self.version)) |
| 2940 | packed.append(struct.pack("!B", self.type)) |
| 2941 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2942 | packed.append(struct.pack("!L", self.xid)) |
| 2943 | packed.append(self.data) |
| 2944 | length = sum([len(x) for x in packed]) |
| 2945 | packed[2] = struct.pack("!H", length) |
| 2946 | return ''.join(packed) |
| 2947 | |
| 2948 | @staticmethod |
| 2949 | def unpack(buf): |
| 2950 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2951 | obj = echo_request() |
| 2952 | if type(buf) == loxi.generic_util.OFReader: |
| 2953 | reader = buf |
| 2954 | else: |
| 2955 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2956 | _version = reader.read("!B")[0] |
| 2957 | assert(_version == 2) |
| 2958 | _type = reader.read("!B")[0] |
| 2959 | assert(_type == 2) |
| 2960 | _length = reader.read("!H")[0] |
| 2961 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2962 | obj.data = str(reader.read_all()) |
| 2963 | return obj |
| 2964 | |
| 2965 | def __eq__(self, other): |
| 2966 | if type(self) != type(other): return False |
| 2967 | if self.version != other.version: return False |
| 2968 | if self.type != other.type: return False |
| 2969 | if self.xid != other.xid: return False |
| 2970 | if self.data != other.data: return False |
| 2971 | return True |
| 2972 | |
| 2973 | def __ne__(self, other): |
| 2974 | return not self.__eq__(other) |
| 2975 | |
| 2976 | def __str__(self): |
| 2977 | return self.show() |
| 2978 | |
| 2979 | def show(self): |
| 2980 | import loxi.pp |
| 2981 | return loxi.pp.pp(self) |
| 2982 | |
| 2983 | def pretty_print(self, q): |
| 2984 | q.text("echo_request {") |
| 2985 | with q.group(): |
| 2986 | with q.indent(2): |
| 2987 | q.breakable() |
| 2988 | q.text("xid = "); |
| 2989 | if self.xid != None: |
| 2990 | q.text("%#x" % self.xid) |
| 2991 | else: |
| 2992 | q.text('None') |
| 2993 | q.text(","); q.breakable() |
| 2994 | q.text("data = "); |
| 2995 | q.pp(self.data) |
| 2996 | q.breakable() |
| 2997 | q.text('}') |
| 2998 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2999 | class features_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3000 | version = 2 |
| 3001 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3002 | |
| 3003 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None): |
| 3004 | self.xid = xid |
| 3005 | if datapath_id != None: |
| 3006 | self.datapath_id = datapath_id |
| 3007 | else: |
| 3008 | self.datapath_id = 0 |
| 3009 | if n_buffers != None: |
| 3010 | self.n_buffers = n_buffers |
| 3011 | else: |
| 3012 | self.n_buffers = 0 |
| 3013 | if n_tables != None: |
| 3014 | self.n_tables = n_tables |
| 3015 | else: |
| 3016 | self.n_tables = 0 |
| 3017 | if capabilities != None: |
| 3018 | self.capabilities = capabilities |
| 3019 | else: |
| 3020 | self.capabilities = 0 |
| 3021 | if reserved != None: |
| 3022 | self.reserved = reserved |
| 3023 | else: |
| 3024 | self.reserved = 0 |
| 3025 | if ports != None: |
| 3026 | self.ports = ports |
| 3027 | else: |
| 3028 | self.ports = [] |
| 3029 | |
| 3030 | def pack(self): |
| 3031 | packed = [] |
| 3032 | packed.append(struct.pack("!B", self.version)) |
| 3033 | packed.append(struct.pack("!B", self.type)) |
| 3034 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3035 | packed.append(struct.pack("!L", self.xid)) |
| 3036 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 3037 | packed.append(struct.pack("!L", self.n_buffers)) |
| 3038 | packed.append(struct.pack("!B", self.n_tables)) |
| 3039 | packed.append('\x00' * 3) |
| 3040 | packed.append(struct.pack("!L", self.capabilities)) |
| 3041 | packed.append(struct.pack("!L", self.reserved)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3042 | packed.append(util.pack_list(self.ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3043 | length = sum([len(x) for x in packed]) |
| 3044 | packed[2] = struct.pack("!H", length) |
| 3045 | return ''.join(packed) |
| 3046 | |
| 3047 | @staticmethod |
| 3048 | def unpack(buf): |
| 3049 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3050 | obj = features_reply() |
| 3051 | if type(buf) == loxi.generic_util.OFReader: |
| 3052 | reader = buf |
| 3053 | else: |
| 3054 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3055 | _version = reader.read("!B")[0] |
| 3056 | assert(_version == 2) |
| 3057 | _type = reader.read("!B")[0] |
| 3058 | assert(_type == 6) |
| 3059 | _length = reader.read("!H")[0] |
| 3060 | obj.xid = reader.read("!L")[0] |
| 3061 | obj.datapath_id = reader.read("!Q")[0] |
| 3062 | obj.n_buffers = reader.read("!L")[0] |
| 3063 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3064 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3065 | obj.capabilities = reader.read("!L")[0] |
| 3066 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3067 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 3068 | return obj |
| 3069 | |
| 3070 | def __eq__(self, other): |
| 3071 | if type(self) != type(other): return False |
| 3072 | if self.version != other.version: return False |
| 3073 | if self.type != other.type: return False |
| 3074 | if self.xid != other.xid: return False |
| 3075 | if self.datapath_id != other.datapath_id: return False |
| 3076 | if self.n_buffers != other.n_buffers: return False |
| 3077 | if self.n_tables != other.n_tables: return False |
| 3078 | if self.capabilities != other.capabilities: return False |
| 3079 | if self.reserved != other.reserved: return False |
| 3080 | if self.ports != other.ports: return False |
| 3081 | return True |
| 3082 | |
| 3083 | def __ne__(self, other): |
| 3084 | return not self.__eq__(other) |
| 3085 | |
| 3086 | def __str__(self): |
| 3087 | return self.show() |
| 3088 | |
| 3089 | def show(self): |
| 3090 | import loxi.pp |
| 3091 | return loxi.pp.pp(self) |
| 3092 | |
| 3093 | def pretty_print(self, q): |
| 3094 | q.text("features_reply {") |
| 3095 | with q.group(): |
| 3096 | with q.indent(2): |
| 3097 | q.breakable() |
| 3098 | q.text("xid = "); |
| 3099 | if self.xid != None: |
| 3100 | q.text("%#x" % self.xid) |
| 3101 | else: |
| 3102 | q.text('None') |
| 3103 | q.text(","); q.breakable() |
| 3104 | q.text("datapath_id = "); |
| 3105 | q.text("%#x" % self.datapath_id) |
| 3106 | q.text(","); q.breakable() |
| 3107 | q.text("n_buffers = "); |
| 3108 | q.text("%#x" % self.n_buffers) |
| 3109 | q.text(","); q.breakable() |
| 3110 | q.text("n_tables = "); |
| 3111 | q.text("%#x" % self.n_tables) |
| 3112 | q.text(","); q.breakable() |
| 3113 | q.text("capabilities = "); |
| 3114 | q.text("%#x" % self.capabilities) |
| 3115 | q.text(","); q.breakable() |
| 3116 | q.text("reserved = "); |
| 3117 | q.text("%#x" % self.reserved) |
| 3118 | q.text(","); q.breakable() |
| 3119 | q.text("ports = "); |
| 3120 | q.pp(self.ports) |
| 3121 | q.breakable() |
| 3122 | q.text('}') |
| 3123 | |
| 3124 | class features_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3125 | version = 2 |
| 3126 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3127 | |
| 3128 | def __init__(self, xid=None): |
| 3129 | self.xid = xid |
| 3130 | |
| 3131 | def pack(self): |
| 3132 | packed = [] |
| 3133 | packed.append(struct.pack("!B", self.version)) |
| 3134 | packed.append(struct.pack("!B", self.type)) |
| 3135 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3136 | packed.append(struct.pack("!L", self.xid)) |
| 3137 | length = sum([len(x) for x in packed]) |
| 3138 | packed[2] = struct.pack("!H", length) |
| 3139 | return ''.join(packed) |
| 3140 | |
| 3141 | @staticmethod |
| 3142 | def unpack(buf): |
| 3143 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3144 | obj = features_request() |
| 3145 | if type(buf) == loxi.generic_util.OFReader: |
| 3146 | reader = buf |
| 3147 | else: |
| 3148 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3149 | _version = reader.read("!B")[0] |
| 3150 | assert(_version == 2) |
| 3151 | _type = reader.read("!B")[0] |
| 3152 | assert(_type == 5) |
| 3153 | _length = reader.read("!H")[0] |
| 3154 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3155 | return obj |
| 3156 | |
| 3157 | def __eq__(self, other): |
| 3158 | if type(self) != type(other): return False |
| 3159 | if self.version != other.version: return False |
| 3160 | if self.type != other.type: return False |
| 3161 | if self.xid != other.xid: return False |
| 3162 | return True |
| 3163 | |
| 3164 | def __ne__(self, other): |
| 3165 | return not self.__eq__(other) |
| 3166 | |
| 3167 | def __str__(self): |
| 3168 | return self.show() |
| 3169 | |
| 3170 | def show(self): |
| 3171 | import loxi.pp |
| 3172 | return loxi.pp.pp(self) |
| 3173 | |
| 3174 | def pretty_print(self, q): |
| 3175 | q.text("features_request {") |
| 3176 | with q.group(): |
| 3177 | with q.indent(2): |
| 3178 | q.breakable() |
| 3179 | q.text("xid = "); |
| 3180 | if self.xid != None: |
| 3181 | q.text("%#x" % self.xid) |
| 3182 | else: |
| 3183 | q.text('None') |
| 3184 | q.breakable() |
| 3185 | q.text('}') |
| 3186 | |
| 3187 | class flow_add(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3188 | version = 2 |
| 3189 | type = 14 |
| 3190 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3191 | |
| 3192 | 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): |
| 3193 | self.xid = xid |
| 3194 | if cookie != None: |
| 3195 | self.cookie = cookie |
| 3196 | else: |
| 3197 | self.cookie = 0 |
| 3198 | if cookie_mask != None: |
| 3199 | self.cookie_mask = cookie_mask |
| 3200 | else: |
| 3201 | self.cookie_mask = 0 |
| 3202 | if table_id != None: |
| 3203 | self.table_id = table_id |
| 3204 | else: |
| 3205 | self.table_id = 0 |
| 3206 | if idle_timeout != None: |
| 3207 | self.idle_timeout = idle_timeout |
| 3208 | else: |
| 3209 | self.idle_timeout = 0 |
| 3210 | if hard_timeout != None: |
| 3211 | self.hard_timeout = hard_timeout |
| 3212 | else: |
| 3213 | self.hard_timeout = 0 |
| 3214 | if priority != None: |
| 3215 | self.priority = priority |
| 3216 | else: |
| 3217 | self.priority = 0 |
| 3218 | if buffer_id != None: |
| 3219 | self.buffer_id = buffer_id |
| 3220 | else: |
| 3221 | self.buffer_id = 0 |
| 3222 | if out_port != None: |
| 3223 | self.out_port = out_port |
| 3224 | else: |
| 3225 | self.out_port = 0 |
| 3226 | if out_group != None: |
| 3227 | self.out_group = out_group |
| 3228 | else: |
| 3229 | self.out_group = 0 |
| 3230 | if flags != None: |
| 3231 | self.flags = flags |
| 3232 | else: |
| 3233 | self.flags = 0 |
| 3234 | if match != None: |
| 3235 | self.match = match |
| 3236 | else: |
| 3237 | self.match = common.match() |
| 3238 | if instructions != None: |
| 3239 | self.instructions = instructions |
| 3240 | else: |
| 3241 | self.instructions = [] |
| 3242 | |
| 3243 | def pack(self): |
| 3244 | packed = [] |
| 3245 | packed.append(struct.pack("!B", self.version)) |
| 3246 | packed.append(struct.pack("!B", self.type)) |
| 3247 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3248 | packed.append(struct.pack("!L", self.xid)) |
| 3249 | packed.append(struct.pack("!Q", self.cookie)) |
| 3250 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3251 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3252 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3253 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3254 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3255 | packed.append(struct.pack("!H", self.priority)) |
| 3256 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3257 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3258 | packed.append(struct.pack("!L", self.out_group)) |
| 3259 | packed.append(struct.pack("!H", self.flags)) |
| 3260 | packed.append('\x00' * 2) |
| 3261 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3262 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3263 | length = sum([len(x) for x in packed]) |
| 3264 | packed[2] = struct.pack("!H", length) |
| 3265 | return ''.join(packed) |
| 3266 | |
| 3267 | @staticmethod |
| 3268 | def unpack(buf): |
| 3269 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3270 | obj = flow_add() |
| 3271 | if type(buf) == loxi.generic_util.OFReader: |
| 3272 | reader = buf |
| 3273 | else: |
| 3274 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3275 | _version = reader.read("!B")[0] |
| 3276 | assert(_version == 2) |
| 3277 | _type = reader.read("!B")[0] |
| 3278 | assert(_type == 14) |
| 3279 | _length = reader.read("!H")[0] |
| 3280 | obj.xid = reader.read("!L")[0] |
| 3281 | obj.cookie = reader.read("!Q")[0] |
| 3282 | obj.cookie_mask = reader.read("!Q")[0] |
| 3283 | obj.table_id = reader.read("!B")[0] |
| 3284 | __command = util.unpack_fm_cmd(reader) |
| 3285 | assert(__command == 0) |
| 3286 | obj.idle_timeout = reader.read("!H")[0] |
| 3287 | obj.hard_timeout = reader.read("!H")[0] |
| 3288 | obj.priority = reader.read("!H")[0] |
| 3289 | obj.buffer_id = reader.read("!L")[0] |
| 3290 | obj.out_port = util.unpack_port_no(reader) |
| 3291 | obj.out_group = reader.read("!L")[0] |
| 3292 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3293 | reader.skip(2) |
| 3294 | obj.match = common.match.unpack(reader) |
| 3295 | obj.instructions = instruction.unpack_list(reader) |
| 3296 | return obj |
| 3297 | |
| 3298 | def __eq__(self, other): |
| 3299 | if type(self) != type(other): return False |
| 3300 | if self.version != other.version: return False |
| 3301 | if self.type != other.type: return False |
| 3302 | if self.xid != other.xid: return False |
| 3303 | if self.cookie != other.cookie: return False |
| 3304 | if self.cookie_mask != other.cookie_mask: return False |
| 3305 | if self.table_id != other.table_id: return False |
| 3306 | if self.idle_timeout != other.idle_timeout: return False |
| 3307 | if self.hard_timeout != other.hard_timeout: return False |
| 3308 | if self.priority != other.priority: return False |
| 3309 | if self.buffer_id != other.buffer_id: return False |
| 3310 | if self.out_port != other.out_port: return False |
| 3311 | if self.out_group != other.out_group: return False |
| 3312 | if self.flags != other.flags: return False |
| 3313 | if self.match != other.match: return False |
| 3314 | if self.instructions != other.instructions: return False |
| 3315 | return True |
| 3316 | |
| 3317 | def __ne__(self, other): |
| 3318 | return not self.__eq__(other) |
| 3319 | |
| 3320 | def __str__(self): |
| 3321 | return self.show() |
| 3322 | |
| 3323 | def show(self): |
| 3324 | import loxi.pp |
| 3325 | return loxi.pp.pp(self) |
| 3326 | |
| 3327 | def pretty_print(self, q): |
| 3328 | q.text("flow_add {") |
| 3329 | with q.group(): |
| 3330 | with q.indent(2): |
| 3331 | q.breakable() |
| 3332 | q.text("xid = "); |
| 3333 | if self.xid != None: |
| 3334 | q.text("%#x" % self.xid) |
| 3335 | else: |
| 3336 | q.text('None') |
| 3337 | q.text(","); q.breakable() |
| 3338 | q.text("cookie = "); |
| 3339 | q.text("%#x" % self.cookie) |
| 3340 | q.text(","); q.breakable() |
| 3341 | q.text("cookie_mask = "); |
| 3342 | q.text("%#x" % self.cookie_mask) |
| 3343 | q.text(","); q.breakable() |
| 3344 | q.text("table_id = "); |
| 3345 | q.text("%#x" % self.table_id) |
| 3346 | q.text(","); q.breakable() |
| 3347 | q.text("idle_timeout = "); |
| 3348 | q.text("%#x" % self.idle_timeout) |
| 3349 | q.text(","); q.breakable() |
| 3350 | q.text("hard_timeout = "); |
| 3351 | q.text("%#x" % self.hard_timeout) |
| 3352 | q.text(","); q.breakable() |
| 3353 | q.text("priority = "); |
| 3354 | q.text("%#x" % self.priority) |
| 3355 | q.text(","); q.breakable() |
| 3356 | q.text("buffer_id = "); |
| 3357 | q.text("%#x" % self.buffer_id) |
| 3358 | q.text(","); q.breakable() |
| 3359 | q.text("out_port = "); |
| 3360 | q.text(util.pretty_port(self.out_port)) |
| 3361 | q.text(","); q.breakable() |
| 3362 | q.text("out_group = "); |
| 3363 | q.text("%#x" % self.out_group) |
| 3364 | q.text(","); q.breakable() |
| 3365 | q.text("flags = "); |
| 3366 | q.text("%#x" % self.flags) |
| 3367 | q.text(","); q.breakable() |
| 3368 | q.text("match = "); |
| 3369 | q.pp(self.match) |
| 3370 | q.text(","); q.breakable() |
| 3371 | q.text("instructions = "); |
| 3372 | q.pp(self.instructions) |
| 3373 | q.breakable() |
| 3374 | q.text('}') |
| 3375 | |
| 3376 | class flow_delete(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3377 | version = 2 |
| 3378 | type = 14 |
| 3379 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3380 | |
| 3381 | 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): |
| 3382 | self.xid = xid |
| 3383 | if cookie != None: |
| 3384 | self.cookie = cookie |
| 3385 | else: |
| 3386 | self.cookie = 0 |
| 3387 | if cookie_mask != None: |
| 3388 | self.cookie_mask = cookie_mask |
| 3389 | else: |
| 3390 | self.cookie_mask = 0 |
| 3391 | if table_id != None: |
| 3392 | self.table_id = table_id |
| 3393 | else: |
| 3394 | self.table_id = 0 |
| 3395 | if idle_timeout != None: |
| 3396 | self.idle_timeout = idle_timeout |
| 3397 | else: |
| 3398 | self.idle_timeout = 0 |
| 3399 | if hard_timeout != None: |
| 3400 | self.hard_timeout = hard_timeout |
| 3401 | else: |
| 3402 | self.hard_timeout = 0 |
| 3403 | if priority != None: |
| 3404 | self.priority = priority |
| 3405 | else: |
| 3406 | self.priority = 0 |
| 3407 | if buffer_id != None: |
| 3408 | self.buffer_id = buffer_id |
| 3409 | else: |
| 3410 | self.buffer_id = 0 |
| 3411 | if out_port != None: |
| 3412 | self.out_port = out_port |
| 3413 | else: |
| 3414 | self.out_port = 0 |
| 3415 | if out_group != None: |
| 3416 | self.out_group = out_group |
| 3417 | else: |
| 3418 | self.out_group = 0 |
| 3419 | if flags != None: |
| 3420 | self.flags = flags |
| 3421 | else: |
| 3422 | self.flags = 0 |
| 3423 | if match != None: |
| 3424 | self.match = match |
| 3425 | else: |
| 3426 | self.match = common.match() |
| 3427 | if instructions != None: |
| 3428 | self.instructions = instructions |
| 3429 | else: |
| 3430 | self.instructions = [] |
| 3431 | |
| 3432 | def pack(self): |
| 3433 | packed = [] |
| 3434 | packed.append(struct.pack("!B", self.version)) |
| 3435 | packed.append(struct.pack("!B", self.type)) |
| 3436 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3437 | packed.append(struct.pack("!L", self.xid)) |
| 3438 | packed.append(struct.pack("!Q", self.cookie)) |
| 3439 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3440 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3441 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3442 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3443 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3444 | packed.append(struct.pack("!H", self.priority)) |
| 3445 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3446 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3447 | packed.append(struct.pack("!L", self.out_group)) |
| 3448 | packed.append(struct.pack("!H", self.flags)) |
| 3449 | packed.append('\x00' * 2) |
| 3450 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3451 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3452 | length = sum([len(x) for x in packed]) |
| 3453 | packed[2] = struct.pack("!H", length) |
| 3454 | return ''.join(packed) |
| 3455 | |
| 3456 | @staticmethod |
| 3457 | def unpack(buf): |
| 3458 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3459 | obj = flow_delete() |
| 3460 | if type(buf) == loxi.generic_util.OFReader: |
| 3461 | reader = buf |
| 3462 | else: |
| 3463 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3464 | _version = reader.read("!B")[0] |
| 3465 | assert(_version == 2) |
| 3466 | _type = reader.read("!B")[0] |
| 3467 | assert(_type == 14) |
| 3468 | _length = reader.read("!H")[0] |
| 3469 | obj.xid = reader.read("!L")[0] |
| 3470 | obj.cookie = reader.read("!Q")[0] |
| 3471 | obj.cookie_mask = reader.read("!Q")[0] |
| 3472 | obj.table_id = reader.read("!B")[0] |
| 3473 | __command = util.unpack_fm_cmd(reader) |
| 3474 | assert(__command == 3) |
| 3475 | obj.idle_timeout = reader.read("!H")[0] |
| 3476 | obj.hard_timeout = reader.read("!H")[0] |
| 3477 | obj.priority = reader.read("!H")[0] |
| 3478 | obj.buffer_id = reader.read("!L")[0] |
| 3479 | obj.out_port = util.unpack_port_no(reader) |
| 3480 | obj.out_group = reader.read("!L")[0] |
| 3481 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3482 | reader.skip(2) |
| 3483 | obj.match = common.match.unpack(reader) |
| 3484 | obj.instructions = instruction.unpack_list(reader) |
| 3485 | return obj |
| 3486 | |
| 3487 | def __eq__(self, other): |
| 3488 | if type(self) != type(other): return False |
| 3489 | if self.version != other.version: return False |
| 3490 | if self.type != other.type: return False |
| 3491 | if self.xid != other.xid: return False |
| 3492 | if self.cookie != other.cookie: return False |
| 3493 | if self.cookie_mask != other.cookie_mask: return False |
| 3494 | if self.table_id != other.table_id: return False |
| 3495 | if self.idle_timeout != other.idle_timeout: return False |
| 3496 | if self.hard_timeout != other.hard_timeout: return False |
| 3497 | if self.priority != other.priority: return False |
| 3498 | if self.buffer_id != other.buffer_id: return False |
| 3499 | if self.out_port != other.out_port: return False |
| 3500 | if self.out_group != other.out_group: return False |
| 3501 | if self.flags != other.flags: return False |
| 3502 | if self.match != other.match: return False |
| 3503 | if self.instructions != other.instructions: return False |
| 3504 | return True |
| 3505 | |
| 3506 | def __ne__(self, other): |
| 3507 | return not self.__eq__(other) |
| 3508 | |
| 3509 | def __str__(self): |
| 3510 | return self.show() |
| 3511 | |
| 3512 | def show(self): |
| 3513 | import loxi.pp |
| 3514 | return loxi.pp.pp(self) |
| 3515 | |
| 3516 | def pretty_print(self, q): |
| 3517 | q.text("flow_delete {") |
| 3518 | with q.group(): |
| 3519 | with q.indent(2): |
| 3520 | q.breakable() |
| 3521 | q.text("xid = "); |
| 3522 | if self.xid != None: |
| 3523 | q.text("%#x" % self.xid) |
| 3524 | else: |
| 3525 | q.text('None') |
| 3526 | q.text(","); q.breakable() |
| 3527 | q.text("cookie = "); |
| 3528 | q.text("%#x" % self.cookie) |
| 3529 | q.text(","); q.breakable() |
| 3530 | q.text("cookie_mask = "); |
| 3531 | q.text("%#x" % self.cookie_mask) |
| 3532 | q.text(","); q.breakable() |
| 3533 | q.text("table_id = "); |
| 3534 | q.text("%#x" % self.table_id) |
| 3535 | q.text(","); q.breakable() |
| 3536 | q.text("idle_timeout = "); |
| 3537 | q.text("%#x" % self.idle_timeout) |
| 3538 | q.text(","); q.breakable() |
| 3539 | q.text("hard_timeout = "); |
| 3540 | q.text("%#x" % self.hard_timeout) |
| 3541 | q.text(","); q.breakable() |
| 3542 | q.text("priority = "); |
| 3543 | q.text("%#x" % self.priority) |
| 3544 | q.text(","); q.breakable() |
| 3545 | q.text("buffer_id = "); |
| 3546 | q.text("%#x" % self.buffer_id) |
| 3547 | q.text(","); q.breakable() |
| 3548 | q.text("out_port = "); |
| 3549 | q.text(util.pretty_port(self.out_port)) |
| 3550 | q.text(","); q.breakable() |
| 3551 | q.text("out_group = "); |
| 3552 | q.text("%#x" % self.out_group) |
| 3553 | q.text(","); q.breakable() |
| 3554 | q.text("flags = "); |
| 3555 | q.text("%#x" % self.flags) |
| 3556 | q.text(","); q.breakable() |
| 3557 | q.text("match = "); |
| 3558 | q.pp(self.match) |
| 3559 | q.text(","); q.breakable() |
| 3560 | q.text("instructions = "); |
| 3561 | q.pp(self.instructions) |
| 3562 | q.breakable() |
| 3563 | q.text('}') |
| 3564 | |
| 3565 | class flow_delete_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3566 | version = 2 |
| 3567 | type = 14 |
| 3568 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3569 | |
| 3570 | 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): |
| 3571 | self.xid = xid |
| 3572 | if cookie != None: |
| 3573 | self.cookie = cookie |
| 3574 | else: |
| 3575 | self.cookie = 0 |
| 3576 | if cookie_mask != None: |
| 3577 | self.cookie_mask = cookie_mask |
| 3578 | else: |
| 3579 | self.cookie_mask = 0 |
| 3580 | if table_id != None: |
| 3581 | self.table_id = table_id |
| 3582 | else: |
| 3583 | self.table_id = 0 |
| 3584 | if idle_timeout != None: |
| 3585 | self.idle_timeout = idle_timeout |
| 3586 | else: |
| 3587 | self.idle_timeout = 0 |
| 3588 | if hard_timeout != None: |
| 3589 | self.hard_timeout = hard_timeout |
| 3590 | else: |
| 3591 | self.hard_timeout = 0 |
| 3592 | if priority != None: |
| 3593 | self.priority = priority |
| 3594 | else: |
| 3595 | self.priority = 0 |
| 3596 | if buffer_id != None: |
| 3597 | self.buffer_id = buffer_id |
| 3598 | else: |
| 3599 | self.buffer_id = 0 |
| 3600 | if out_port != None: |
| 3601 | self.out_port = out_port |
| 3602 | else: |
| 3603 | self.out_port = 0 |
| 3604 | if out_group != None: |
| 3605 | self.out_group = out_group |
| 3606 | else: |
| 3607 | self.out_group = 0 |
| 3608 | if flags != None: |
| 3609 | self.flags = flags |
| 3610 | else: |
| 3611 | self.flags = 0 |
| 3612 | if match != None: |
| 3613 | self.match = match |
| 3614 | else: |
| 3615 | self.match = common.match() |
| 3616 | if instructions != None: |
| 3617 | self.instructions = instructions |
| 3618 | else: |
| 3619 | self.instructions = [] |
| 3620 | |
| 3621 | def pack(self): |
| 3622 | packed = [] |
| 3623 | packed.append(struct.pack("!B", self.version)) |
| 3624 | packed.append(struct.pack("!B", self.type)) |
| 3625 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3626 | packed.append(struct.pack("!L", self.xid)) |
| 3627 | packed.append(struct.pack("!Q", self.cookie)) |
| 3628 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3629 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3630 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3631 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3632 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3633 | packed.append(struct.pack("!H", self.priority)) |
| 3634 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3635 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3636 | packed.append(struct.pack("!L", self.out_group)) |
| 3637 | packed.append(struct.pack("!H", self.flags)) |
| 3638 | packed.append('\x00' * 2) |
| 3639 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3640 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3641 | length = sum([len(x) for x in packed]) |
| 3642 | packed[2] = struct.pack("!H", length) |
| 3643 | return ''.join(packed) |
| 3644 | |
| 3645 | @staticmethod |
| 3646 | def unpack(buf): |
| 3647 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3648 | obj = flow_delete_strict() |
| 3649 | if type(buf) == loxi.generic_util.OFReader: |
| 3650 | reader = buf |
| 3651 | else: |
| 3652 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3653 | _version = reader.read("!B")[0] |
| 3654 | assert(_version == 2) |
| 3655 | _type = reader.read("!B")[0] |
| 3656 | assert(_type == 14) |
| 3657 | _length = reader.read("!H")[0] |
| 3658 | obj.xid = reader.read("!L")[0] |
| 3659 | obj.cookie = reader.read("!Q")[0] |
| 3660 | obj.cookie_mask = reader.read("!Q")[0] |
| 3661 | obj.table_id = reader.read("!B")[0] |
| 3662 | __command = util.unpack_fm_cmd(reader) |
| 3663 | assert(__command == 4) |
| 3664 | obj.idle_timeout = reader.read("!H")[0] |
| 3665 | obj.hard_timeout = reader.read("!H")[0] |
| 3666 | obj.priority = reader.read("!H")[0] |
| 3667 | obj.buffer_id = reader.read("!L")[0] |
| 3668 | obj.out_port = util.unpack_port_no(reader) |
| 3669 | obj.out_group = reader.read("!L")[0] |
| 3670 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3671 | reader.skip(2) |
| 3672 | obj.match = common.match.unpack(reader) |
| 3673 | obj.instructions = instruction.unpack_list(reader) |
| 3674 | return obj |
| 3675 | |
| 3676 | def __eq__(self, other): |
| 3677 | if type(self) != type(other): return False |
| 3678 | if self.version != other.version: return False |
| 3679 | if self.type != other.type: return False |
| 3680 | if self.xid != other.xid: return False |
| 3681 | if self.cookie != other.cookie: return False |
| 3682 | if self.cookie_mask != other.cookie_mask: return False |
| 3683 | if self.table_id != other.table_id: return False |
| 3684 | if self.idle_timeout != other.idle_timeout: return False |
| 3685 | if self.hard_timeout != other.hard_timeout: return False |
| 3686 | if self.priority != other.priority: return False |
| 3687 | if self.buffer_id != other.buffer_id: return False |
| 3688 | if self.out_port != other.out_port: return False |
| 3689 | if self.out_group != other.out_group: return False |
| 3690 | if self.flags != other.flags: return False |
| 3691 | if self.match != other.match: return False |
| 3692 | if self.instructions != other.instructions: return False |
| 3693 | return True |
| 3694 | |
| 3695 | def __ne__(self, other): |
| 3696 | return not self.__eq__(other) |
| 3697 | |
| 3698 | def __str__(self): |
| 3699 | return self.show() |
| 3700 | |
| 3701 | def show(self): |
| 3702 | import loxi.pp |
| 3703 | return loxi.pp.pp(self) |
| 3704 | |
| 3705 | def pretty_print(self, q): |
| 3706 | q.text("flow_delete_strict {") |
| 3707 | with q.group(): |
| 3708 | with q.indent(2): |
| 3709 | q.breakable() |
| 3710 | q.text("xid = "); |
| 3711 | if self.xid != None: |
| 3712 | q.text("%#x" % self.xid) |
| 3713 | else: |
| 3714 | q.text('None') |
| 3715 | q.text(","); q.breakable() |
| 3716 | q.text("cookie = "); |
| 3717 | q.text("%#x" % self.cookie) |
| 3718 | q.text(","); q.breakable() |
| 3719 | q.text("cookie_mask = "); |
| 3720 | q.text("%#x" % self.cookie_mask) |
| 3721 | q.text(","); q.breakable() |
| 3722 | q.text("table_id = "); |
| 3723 | q.text("%#x" % self.table_id) |
| 3724 | q.text(","); q.breakable() |
| 3725 | q.text("idle_timeout = "); |
| 3726 | q.text("%#x" % self.idle_timeout) |
| 3727 | q.text(","); q.breakable() |
| 3728 | q.text("hard_timeout = "); |
| 3729 | q.text("%#x" % self.hard_timeout) |
| 3730 | q.text(","); q.breakable() |
| 3731 | q.text("priority = "); |
| 3732 | q.text("%#x" % self.priority) |
| 3733 | q.text(","); q.breakable() |
| 3734 | q.text("buffer_id = "); |
| 3735 | q.text("%#x" % self.buffer_id) |
| 3736 | q.text(","); q.breakable() |
| 3737 | q.text("out_port = "); |
| 3738 | q.text(util.pretty_port(self.out_port)) |
| 3739 | q.text(","); q.breakable() |
| 3740 | q.text("out_group = "); |
| 3741 | q.text("%#x" % self.out_group) |
| 3742 | q.text(","); q.breakable() |
| 3743 | q.text("flags = "); |
| 3744 | q.text("%#x" % self.flags) |
| 3745 | q.text(","); q.breakable() |
| 3746 | q.text("match = "); |
| 3747 | q.pp(self.match) |
| 3748 | q.text(","); q.breakable() |
| 3749 | q.text("instructions = "); |
| 3750 | q.pp(self.instructions) |
| 3751 | q.breakable() |
| 3752 | q.text('}') |
| 3753 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 3754 | class flow_mod_failed_error_msg(Message): |
| 3755 | version = 2 |
| 3756 | type = 1 |
| 3757 | err_type = 5 |
| 3758 | |
| 3759 | def __init__(self, xid=None, code=None, data=None): |
| 3760 | self.xid = xid |
| 3761 | if code != None: |
| 3762 | self.code = code |
| 3763 | else: |
| 3764 | self.code = 0 |
| 3765 | if data != None: |
| 3766 | self.data = data |
| 3767 | else: |
| 3768 | self.data = '' |
| 3769 | |
| 3770 | def pack(self): |
| 3771 | packed = [] |
| 3772 | packed.append(struct.pack("!B", self.version)) |
| 3773 | packed.append(struct.pack("!B", self.type)) |
| 3774 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3775 | packed.append(struct.pack("!L", self.xid)) |
| 3776 | packed.append(struct.pack("!H", self.err_type)) |
| 3777 | packed.append(struct.pack("!H", self.code)) |
| 3778 | packed.append(self.data) |
| 3779 | length = sum([len(x) for x in packed]) |
| 3780 | packed[2] = struct.pack("!H", length) |
| 3781 | return ''.join(packed) |
| 3782 | |
| 3783 | @staticmethod |
| 3784 | def unpack(buf): |
| 3785 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3786 | obj = flow_mod_failed_error_msg() |
| 3787 | if type(buf) == loxi.generic_util.OFReader: |
| 3788 | reader = buf |
| 3789 | else: |
| 3790 | reader = loxi.generic_util.OFReader(buf) |
| 3791 | _version = reader.read("!B")[0] |
| 3792 | assert(_version == 2) |
| 3793 | _type = reader.read("!B")[0] |
| 3794 | assert(_type == 1) |
| 3795 | _length = reader.read("!H")[0] |
| 3796 | obj.xid = reader.read("!L")[0] |
| 3797 | _err_type = reader.read("!H")[0] |
| 3798 | assert(_err_type == 5) |
| 3799 | obj.code = reader.read("!H")[0] |
| 3800 | obj.data = str(reader.read_all()) |
| 3801 | return obj |
| 3802 | |
| 3803 | def __eq__(self, other): |
| 3804 | if type(self) != type(other): return False |
| 3805 | if self.version != other.version: return False |
| 3806 | if self.type != other.type: return False |
| 3807 | if self.xid != other.xid: return False |
| 3808 | if self.code != other.code: return False |
| 3809 | if self.data != other.data: return False |
| 3810 | return True |
| 3811 | |
| 3812 | def __ne__(self, other): |
| 3813 | return not self.__eq__(other) |
| 3814 | |
| 3815 | def __str__(self): |
| 3816 | return self.show() |
| 3817 | |
| 3818 | def show(self): |
| 3819 | import loxi.pp |
| 3820 | return loxi.pp.pp(self) |
| 3821 | |
| 3822 | def pretty_print(self, q): |
| 3823 | q.text("flow_mod_failed_error_msg {") |
| 3824 | with q.group(): |
| 3825 | with q.indent(2): |
| 3826 | q.breakable() |
| 3827 | q.text("xid = "); |
| 3828 | if self.xid != None: |
| 3829 | q.text("%#x" % self.xid) |
| 3830 | else: |
| 3831 | q.text('None') |
| 3832 | q.text(","); q.breakable() |
| 3833 | q.text("code = "); |
| 3834 | q.text("%#x" % self.code) |
| 3835 | q.text(","); q.breakable() |
| 3836 | q.text("data = "); |
| 3837 | q.pp(self.data) |
| 3838 | q.breakable() |
| 3839 | q.text('}') |
| 3840 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3841 | class flow_modify(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3842 | version = 2 |
| 3843 | type = 14 |
| 3844 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3845 | |
| 3846 | 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): |
| 3847 | self.xid = xid |
| 3848 | if cookie != None: |
| 3849 | self.cookie = cookie |
| 3850 | else: |
| 3851 | self.cookie = 0 |
| 3852 | if cookie_mask != None: |
| 3853 | self.cookie_mask = cookie_mask |
| 3854 | else: |
| 3855 | self.cookie_mask = 0 |
| 3856 | if table_id != None: |
| 3857 | self.table_id = table_id |
| 3858 | else: |
| 3859 | self.table_id = 0 |
| 3860 | if idle_timeout != None: |
| 3861 | self.idle_timeout = idle_timeout |
| 3862 | else: |
| 3863 | self.idle_timeout = 0 |
| 3864 | if hard_timeout != None: |
| 3865 | self.hard_timeout = hard_timeout |
| 3866 | else: |
| 3867 | self.hard_timeout = 0 |
| 3868 | if priority != None: |
| 3869 | self.priority = priority |
| 3870 | else: |
| 3871 | self.priority = 0 |
| 3872 | if buffer_id != None: |
| 3873 | self.buffer_id = buffer_id |
| 3874 | else: |
| 3875 | self.buffer_id = 0 |
| 3876 | if out_port != None: |
| 3877 | self.out_port = out_port |
| 3878 | else: |
| 3879 | self.out_port = 0 |
| 3880 | if out_group != None: |
| 3881 | self.out_group = out_group |
| 3882 | else: |
| 3883 | self.out_group = 0 |
| 3884 | if flags != None: |
| 3885 | self.flags = flags |
| 3886 | else: |
| 3887 | self.flags = 0 |
| 3888 | if match != None: |
| 3889 | self.match = match |
| 3890 | else: |
| 3891 | self.match = common.match() |
| 3892 | if instructions != None: |
| 3893 | self.instructions = instructions |
| 3894 | else: |
| 3895 | self.instructions = [] |
| 3896 | |
| 3897 | def pack(self): |
| 3898 | packed = [] |
| 3899 | packed.append(struct.pack("!B", self.version)) |
| 3900 | packed.append(struct.pack("!B", self.type)) |
| 3901 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3902 | packed.append(struct.pack("!L", self.xid)) |
| 3903 | packed.append(struct.pack("!Q", self.cookie)) |
| 3904 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3905 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3906 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3907 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3908 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3909 | packed.append(struct.pack("!H", self.priority)) |
| 3910 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3911 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3912 | packed.append(struct.pack("!L", self.out_group)) |
| 3913 | packed.append(struct.pack("!H", self.flags)) |
| 3914 | packed.append('\x00' * 2) |
| 3915 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3916 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3917 | length = sum([len(x) for x in packed]) |
| 3918 | packed[2] = struct.pack("!H", length) |
| 3919 | return ''.join(packed) |
| 3920 | |
| 3921 | @staticmethod |
| 3922 | def unpack(buf): |
| 3923 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3924 | obj = flow_modify() |
| 3925 | if type(buf) == loxi.generic_util.OFReader: |
| 3926 | reader = buf |
| 3927 | else: |
| 3928 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3929 | _version = reader.read("!B")[0] |
| 3930 | assert(_version == 2) |
| 3931 | _type = reader.read("!B")[0] |
| 3932 | assert(_type == 14) |
| 3933 | _length = reader.read("!H")[0] |
| 3934 | obj.xid = reader.read("!L")[0] |
| 3935 | obj.cookie = reader.read("!Q")[0] |
| 3936 | obj.cookie_mask = reader.read("!Q")[0] |
| 3937 | obj.table_id = reader.read("!B")[0] |
| 3938 | __command = util.unpack_fm_cmd(reader) |
| 3939 | assert(__command == 1) |
| 3940 | obj.idle_timeout = reader.read("!H")[0] |
| 3941 | obj.hard_timeout = reader.read("!H")[0] |
| 3942 | obj.priority = reader.read("!H")[0] |
| 3943 | obj.buffer_id = reader.read("!L")[0] |
| 3944 | obj.out_port = util.unpack_port_no(reader) |
| 3945 | obj.out_group = reader.read("!L")[0] |
| 3946 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3947 | reader.skip(2) |
| 3948 | obj.match = common.match.unpack(reader) |
| 3949 | obj.instructions = instruction.unpack_list(reader) |
| 3950 | return obj |
| 3951 | |
| 3952 | def __eq__(self, other): |
| 3953 | if type(self) != type(other): return False |
| 3954 | if self.version != other.version: return False |
| 3955 | if self.type != other.type: return False |
| 3956 | if self.xid != other.xid: return False |
| 3957 | if self.cookie != other.cookie: return False |
| 3958 | if self.cookie_mask != other.cookie_mask: return False |
| 3959 | if self.table_id != other.table_id: return False |
| 3960 | if self.idle_timeout != other.idle_timeout: return False |
| 3961 | if self.hard_timeout != other.hard_timeout: return False |
| 3962 | if self.priority != other.priority: return False |
| 3963 | if self.buffer_id != other.buffer_id: return False |
| 3964 | if self.out_port != other.out_port: return False |
| 3965 | if self.out_group != other.out_group: return False |
| 3966 | if self.flags != other.flags: return False |
| 3967 | if self.match != other.match: return False |
| 3968 | if self.instructions != other.instructions: return False |
| 3969 | return True |
| 3970 | |
| 3971 | def __ne__(self, other): |
| 3972 | return not self.__eq__(other) |
| 3973 | |
| 3974 | def __str__(self): |
| 3975 | return self.show() |
| 3976 | |
| 3977 | def show(self): |
| 3978 | import loxi.pp |
| 3979 | return loxi.pp.pp(self) |
| 3980 | |
| 3981 | def pretty_print(self, q): |
| 3982 | q.text("flow_modify {") |
| 3983 | with q.group(): |
| 3984 | with q.indent(2): |
| 3985 | q.breakable() |
| 3986 | q.text("xid = "); |
| 3987 | if self.xid != None: |
| 3988 | q.text("%#x" % self.xid) |
| 3989 | else: |
| 3990 | q.text('None') |
| 3991 | q.text(","); q.breakable() |
| 3992 | q.text("cookie = "); |
| 3993 | q.text("%#x" % self.cookie) |
| 3994 | q.text(","); q.breakable() |
| 3995 | q.text("cookie_mask = "); |
| 3996 | q.text("%#x" % self.cookie_mask) |
| 3997 | q.text(","); q.breakable() |
| 3998 | q.text("table_id = "); |
| 3999 | q.text("%#x" % self.table_id) |
| 4000 | q.text(","); q.breakable() |
| 4001 | q.text("idle_timeout = "); |
| 4002 | q.text("%#x" % self.idle_timeout) |
| 4003 | q.text(","); q.breakable() |
| 4004 | q.text("hard_timeout = "); |
| 4005 | q.text("%#x" % self.hard_timeout) |
| 4006 | q.text(","); q.breakable() |
| 4007 | q.text("priority = "); |
| 4008 | q.text("%#x" % self.priority) |
| 4009 | q.text(","); q.breakable() |
| 4010 | q.text("buffer_id = "); |
| 4011 | q.text("%#x" % self.buffer_id) |
| 4012 | q.text(","); q.breakable() |
| 4013 | q.text("out_port = "); |
| 4014 | q.text(util.pretty_port(self.out_port)) |
| 4015 | q.text(","); q.breakable() |
| 4016 | q.text("out_group = "); |
| 4017 | q.text("%#x" % self.out_group) |
| 4018 | q.text(","); q.breakable() |
| 4019 | q.text("flags = "); |
| 4020 | q.text("%#x" % self.flags) |
| 4021 | q.text(","); q.breakable() |
| 4022 | q.text("match = "); |
| 4023 | q.pp(self.match) |
| 4024 | q.text(","); q.breakable() |
| 4025 | q.text("instructions = "); |
| 4026 | q.pp(self.instructions) |
| 4027 | q.breakable() |
| 4028 | q.text('}') |
| 4029 | |
| 4030 | class flow_modify_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4031 | version = 2 |
| 4032 | type = 14 |
| 4033 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4034 | |
| 4035 | 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): |
| 4036 | self.xid = xid |
| 4037 | if cookie != None: |
| 4038 | self.cookie = cookie |
| 4039 | else: |
| 4040 | self.cookie = 0 |
| 4041 | if cookie_mask != None: |
| 4042 | self.cookie_mask = cookie_mask |
| 4043 | else: |
| 4044 | self.cookie_mask = 0 |
| 4045 | if table_id != None: |
| 4046 | self.table_id = table_id |
| 4047 | else: |
| 4048 | self.table_id = 0 |
| 4049 | if idle_timeout != None: |
| 4050 | self.idle_timeout = idle_timeout |
| 4051 | else: |
| 4052 | self.idle_timeout = 0 |
| 4053 | if hard_timeout != None: |
| 4054 | self.hard_timeout = hard_timeout |
| 4055 | else: |
| 4056 | self.hard_timeout = 0 |
| 4057 | if priority != None: |
| 4058 | self.priority = priority |
| 4059 | else: |
| 4060 | self.priority = 0 |
| 4061 | if buffer_id != None: |
| 4062 | self.buffer_id = buffer_id |
| 4063 | else: |
| 4064 | self.buffer_id = 0 |
| 4065 | if out_port != None: |
| 4066 | self.out_port = out_port |
| 4067 | else: |
| 4068 | self.out_port = 0 |
| 4069 | if out_group != None: |
| 4070 | self.out_group = out_group |
| 4071 | else: |
| 4072 | self.out_group = 0 |
| 4073 | if flags != None: |
| 4074 | self.flags = flags |
| 4075 | else: |
| 4076 | self.flags = 0 |
| 4077 | if match != None: |
| 4078 | self.match = match |
| 4079 | else: |
| 4080 | self.match = common.match() |
| 4081 | if instructions != None: |
| 4082 | self.instructions = instructions |
| 4083 | else: |
| 4084 | self.instructions = [] |
| 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()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4105 | packed.append(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 |
| 4111 | def unpack(buf): |
| 4112 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4113 | obj = flow_modify_strict() |
| 4114 | if type(buf) == loxi.generic_util.OFReader: |
| 4115 | reader = buf |
| 4116 | else: |
| 4117 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4118 | _version = reader.read("!B")[0] |
| 4119 | assert(_version == 2) |
| 4120 | _type = reader.read("!B")[0] |
| 4121 | assert(_type == 14) |
| 4122 | _length = reader.read("!H")[0] |
| 4123 | obj.xid = reader.read("!L")[0] |
| 4124 | obj.cookie = reader.read("!Q")[0] |
| 4125 | obj.cookie_mask = reader.read("!Q")[0] |
| 4126 | obj.table_id = reader.read("!B")[0] |
| 4127 | __command = util.unpack_fm_cmd(reader) |
| 4128 | assert(__command == 2) |
| 4129 | obj.idle_timeout = reader.read("!H")[0] |
| 4130 | obj.hard_timeout = reader.read("!H")[0] |
| 4131 | obj.priority = reader.read("!H")[0] |
| 4132 | obj.buffer_id = reader.read("!L")[0] |
| 4133 | obj.out_port = util.unpack_port_no(reader) |
| 4134 | obj.out_group = reader.read("!L")[0] |
| 4135 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4136 | reader.skip(2) |
| 4137 | obj.match = common.match.unpack(reader) |
| 4138 | obj.instructions = instruction.unpack_list(reader) |
| 4139 | return obj |
| 4140 | |
| 4141 | def __eq__(self, other): |
| 4142 | if type(self) != type(other): return False |
| 4143 | if self.version != other.version: return False |
| 4144 | if self.type != other.type: return False |
| 4145 | if self.xid != other.xid: return False |
| 4146 | if self.cookie != other.cookie: return False |
| 4147 | if self.cookie_mask != other.cookie_mask: return False |
| 4148 | if self.table_id != other.table_id: return False |
| 4149 | if self.idle_timeout != other.idle_timeout: return False |
| 4150 | if self.hard_timeout != other.hard_timeout: return False |
| 4151 | if self.priority != other.priority: return False |
| 4152 | if self.buffer_id != other.buffer_id: return False |
| 4153 | if self.out_port != other.out_port: return False |
| 4154 | if self.out_group != other.out_group: return False |
| 4155 | if self.flags != other.flags: return False |
| 4156 | if self.match != other.match: return False |
| 4157 | if self.instructions != other.instructions: return False |
| 4158 | return True |
| 4159 | |
| 4160 | def __ne__(self, other): |
| 4161 | return not self.__eq__(other) |
| 4162 | |
| 4163 | def __str__(self): |
| 4164 | return self.show() |
| 4165 | |
| 4166 | def show(self): |
| 4167 | import loxi.pp |
| 4168 | return loxi.pp.pp(self) |
| 4169 | |
| 4170 | def pretty_print(self, q): |
| 4171 | q.text("flow_modify_strict {") |
| 4172 | with q.group(): |
| 4173 | with q.indent(2): |
| 4174 | q.breakable() |
| 4175 | q.text("xid = "); |
| 4176 | if self.xid != None: |
| 4177 | q.text("%#x" % self.xid) |
| 4178 | else: |
| 4179 | q.text('None') |
| 4180 | q.text(","); q.breakable() |
| 4181 | q.text("cookie = "); |
| 4182 | q.text("%#x" % self.cookie) |
| 4183 | q.text(","); q.breakable() |
| 4184 | q.text("cookie_mask = "); |
| 4185 | q.text("%#x" % self.cookie_mask) |
| 4186 | q.text(","); q.breakable() |
| 4187 | q.text("table_id = "); |
| 4188 | q.text("%#x" % self.table_id) |
| 4189 | q.text(","); q.breakable() |
| 4190 | q.text("idle_timeout = "); |
| 4191 | q.text("%#x" % self.idle_timeout) |
| 4192 | q.text(","); q.breakable() |
| 4193 | q.text("hard_timeout = "); |
| 4194 | q.text("%#x" % self.hard_timeout) |
| 4195 | q.text(","); q.breakable() |
| 4196 | q.text("priority = "); |
| 4197 | q.text("%#x" % self.priority) |
| 4198 | q.text(","); q.breakable() |
| 4199 | q.text("buffer_id = "); |
| 4200 | q.text("%#x" % self.buffer_id) |
| 4201 | q.text(","); q.breakable() |
| 4202 | q.text("out_port = "); |
| 4203 | q.text(util.pretty_port(self.out_port)) |
| 4204 | q.text(","); q.breakable() |
| 4205 | q.text("out_group = "); |
| 4206 | q.text("%#x" % self.out_group) |
| 4207 | q.text(","); q.breakable() |
| 4208 | q.text("flags = "); |
| 4209 | q.text("%#x" % self.flags) |
| 4210 | q.text(","); q.breakable() |
| 4211 | q.text("match = "); |
| 4212 | q.pp(self.match) |
| 4213 | q.text(","); q.breakable() |
| 4214 | q.text("instructions = "); |
| 4215 | q.pp(self.instructions) |
| 4216 | q.breakable() |
| 4217 | q.text('}') |
| 4218 | |
| 4219 | class flow_removed(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4220 | version = 2 |
| 4221 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4222 | |
| 4223 | def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None, match=None): |
| 4224 | self.xid = xid |
| 4225 | if cookie != None: |
| 4226 | self.cookie = cookie |
| 4227 | else: |
| 4228 | self.cookie = 0 |
| 4229 | if priority != None: |
| 4230 | self.priority = priority |
| 4231 | else: |
| 4232 | self.priority = 0 |
| 4233 | if reason != None: |
| 4234 | self.reason = reason |
| 4235 | else: |
| 4236 | self.reason = 0 |
| 4237 | if table_id != None: |
| 4238 | self.table_id = table_id |
| 4239 | else: |
| 4240 | self.table_id = 0 |
| 4241 | if duration_sec != None: |
| 4242 | self.duration_sec = duration_sec |
| 4243 | else: |
| 4244 | self.duration_sec = 0 |
| 4245 | if duration_nsec != None: |
| 4246 | self.duration_nsec = duration_nsec |
| 4247 | else: |
| 4248 | self.duration_nsec = 0 |
| 4249 | if idle_timeout != None: |
| 4250 | self.idle_timeout = idle_timeout |
| 4251 | else: |
| 4252 | self.idle_timeout = 0 |
| 4253 | if packet_count != None: |
| 4254 | self.packet_count = packet_count |
| 4255 | else: |
| 4256 | self.packet_count = 0 |
| 4257 | if byte_count != None: |
| 4258 | self.byte_count = byte_count |
| 4259 | else: |
| 4260 | self.byte_count = 0 |
| 4261 | if match != None: |
| 4262 | self.match = match |
| 4263 | else: |
| 4264 | self.match = common.match() |
| 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("!H", self.priority)) |
| 4274 | packed.append(struct.pack("!B", self.reason)) |
| 4275 | packed.append(struct.pack("!B", self.table_id)) |
| 4276 | packed.append(struct.pack("!L", self.duration_sec)) |
| 4277 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 4278 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4279 | packed.append('\x00' * 2) |
| 4280 | packed.append(struct.pack("!Q", self.packet_count)) |
| 4281 | packed.append(struct.pack("!Q", self.byte_count)) |
| 4282 | packed.append(self.match.pack()) |
| 4283 | length = sum([len(x) for x in packed]) |
| 4284 | packed[2] = struct.pack("!H", length) |
| 4285 | return ''.join(packed) |
| 4286 | |
| 4287 | @staticmethod |
| 4288 | def unpack(buf): |
| 4289 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4290 | obj = flow_removed() |
| 4291 | if type(buf) == loxi.generic_util.OFReader: |
| 4292 | reader = buf |
| 4293 | else: |
| 4294 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4295 | _version = reader.read("!B")[0] |
| 4296 | assert(_version == 2) |
| 4297 | _type = reader.read("!B")[0] |
| 4298 | assert(_type == 11) |
| 4299 | _length = reader.read("!H")[0] |
| 4300 | obj.xid = reader.read("!L")[0] |
| 4301 | obj.cookie = reader.read("!Q")[0] |
| 4302 | obj.priority = reader.read("!H")[0] |
| 4303 | obj.reason = reader.read("!B")[0] |
| 4304 | obj.table_id = reader.read("!B")[0] |
| 4305 | obj.duration_sec = reader.read("!L")[0] |
| 4306 | obj.duration_nsec = reader.read("!L")[0] |
| 4307 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4308 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4309 | obj.packet_count = reader.read("!Q")[0] |
| 4310 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4311 | obj.match = common.match.unpack(reader) |
| 4312 | return obj |
| 4313 | |
| 4314 | def __eq__(self, other): |
| 4315 | if type(self) != type(other): return False |
| 4316 | if self.version != other.version: return False |
| 4317 | if self.type != other.type: return False |
| 4318 | if self.xid != other.xid: return False |
| 4319 | if self.cookie != other.cookie: return False |
| 4320 | if self.priority != other.priority: return False |
| 4321 | if self.reason != other.reason: return False |
| 4322 | if self.table_id != other.table_id: return False |
| 4323 | if self.duration_sec != other.duration_sec: return False |
| 4324 | if self.duration_nsec != other.duration_nsec: return False |
| 4325 | if self.idle_timeout != other.idle_timeout: return False |
| 4326 | if self.packet_count != other.packet_count: return False |
| 4327 | if self.byte_count != other.byte_count: return False |
| 4328 | if self.match != other.match: return False |
| 4329 | return True |
| 4330 | |
| 4331 | def __ne__(self, other): |
| 4332 | return not self.__eq__(other) |
| 4333 | |
| 4334 | def __str__(self): |
| 4335 | return self.show() |
| 4336 | |
| 4337 | def show(self): |
| 4338 | import loxi.pp |
| 4339 | return loxi.pp.pp(self) |
| 4340 | |
| 4341 | def pretty_print(self, q): |
| 4342 | q.text("flow_removed {") |
| 4343 | with q.group(): |
| 4344 | with q.indent(2): |
| 4345 | q.breakable() |
| 4346 | q.text("xid = "); |
| 4347 | if self.xid != None: |
| 4348 | q.text("%#x" % self.xid) |
| 4349 | else: |
| 4350 | q.text('None') |
| 4351 | q.text(","); q.breakable() |
| 4352 | q.text("cookie = "); |
| 4353 | q.text("%#x" % self.cookie) |
| 4354 | q.text(","); q.breakable() |
| 4355 | q.text("priority = "); |
| 4356 | q.text("%#x" % self.priority) |
| 4357 | q.text(","); q.breakable() |
| 4358 | q.text("reason = "); |
| 4359 | q.text("%#x" % self.reason) |
| 4360 | q.text(","); q.breakable() |
| 4361 | q.text("table_id = "); |
| 4362 | q.text("%#x" % self.table_id) |
| 4363 | q.text(","); q.breakable() |
| 4364 | q.text("duration_sec = "); |
| 4365 | q.text("%#x" % self.duration_sec) |
| 4366 | q.text(","); q.breakable() |
| 4367 | q.text("duration_nsec = "); |
| 4368 | q.text("%#x" % self.duration_nsec) |
| 4369 | q.text(","); q.breakable() |
| 4370 | q.text("idle_timeout = "); |
| 4371 | q.text("%#x" % self.idle_timeout) |
| 4372 | q.text(","); q.breakable() |
| 4373 | q.text("packet_count = "); |
| 4374 | q.text("%#x" % self.packet_count) |
| 4375 | q.text(","); q.breakable() |
| 4376 | q.text("byte_count = "); |
| 4377 | q.text("%#x" % self.byte_count) |
| 4378 | q.text(","); q.breakable() |
| 4379 | q.text("match = "); |
| 4380 | q.pp(self.match) |
| 4381 | q.breakable() |
| 4382 | q.text('}') |
| 4383 | |
| 4384 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4385 | version = 2 |
| 4386 | type = 19 |
| 4387 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4388 | |
| 4389 | def __init__(self, xid=None, flags=None, entries=None): |
| 4390 | self.xid = xid |
| 4391 | if flags != None: |
| 4392 | self.flags = flags |
| 4393 | else: |
| 4394 | self.flags = 0 |
| 4395 | if entries != None: |
| 4396 | self.entries = entries |
| 4397 | else: |
| 4398 | self.entries = [] |
| 4399 | |
| 4400 | def pack(self): |
| 4401 | packed = [] |
| 4402 | packed.append(struct.pack("!B", self.version)) |
| 4403 | packed.append(struct.pack("!B", self.type)) |
| 4404 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4405 | packed.append(struct.pack("!L", self.xid)) |
| 4406 | packed.append(struct.pack("!H", self.stats_type)) |
| 4407 | packed.append(struct.pack("!H", self.flags)) |
| 4408 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4409 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4410 | length = sum([len(x) for x in packed]) |
| 4411 | packed[2] = struct.pack("!H", length) |
| 4412 | return ''.join(packed) |
| 4413 | |
| 4414 | @staticmethod |
| 4415 | def unpack(buf): |
| 4416 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4417 | obj = flow_stats_reply() |
| 4418 | if type(buf) == loxi.generic_util.OFReader: |
| 4419 | reader = buf |
| 4420 | else: |
| 4421 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4422 | _version = reader.read("!B")[0] |
| 4423 | assert(_version == 2) |
| 4424 | _type = reader.read("!B")[0] |
| 4425 | assert(_type == 19) |
| 4426 | _length = reader.read("!H")[0] |
| 4427 | obj.xid = reader.read("!L")[0] |
| 4428 | _stats_type = reader.read("!H")[0] |
| 4429 | assert(_stats_type == 1) |
| 4430 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4431 | reader.skip(4) |
| 4432 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
| 4433 | return obj |
| 4434 | |
| 4435 | def __eq__(self, other): |
| 4436 | if type(self) != type(other): return False |
| 4437 | if self.version != other.version: return False |
| 4438 | if self.type != other.type: return False |
| 4439 | if self.xid != other.xid: return False |
| 4440 | if self.flags != other.flags: return False |
| 4441 | if self.entries != other.entries: return False |
| 4442 | return True |
| 4443 | |
| 4444 | def __ne__(self, other): |
| 4445 | return not self.__eq__(other) |
| 4446 | |
| 4447 | def __str__(self): |
| 4448 | return self.show() |
| 4449 | |
| 4450 | def show(self): |
| 4451 | import loxi.pp |
| 4452 | return loxi.pp.pp(self) |
| 4453 | |
| 4454 | def pretty_print(self, q): |
| 4455 | q.text("flow_stats_reply {") |
| 4456 | with q.group(): |
| 4457 | with q.indent(2): |
| 4458 | q.breakable() |
| 4459 | q.text("xid = "); |
| 4460 | if self.xid != None: |
| 4461 | q.text("%#x" % self.xid) |
| 4462 | else: |
| 4463 | q.text('None') |
| 4464 | q.text(","); q.breakable() |
| 4465 | q.text("flags = "); |
| 4466 | q.text("%#x" % self.flags) |
| 4467 | q.text(","); q.breakable() |
| 4468 | q.text("entries = "); |
| 4469 | q.pp(self.entries) |
| 4470 | q.breakable() |
| 4471 | q.text('}') |
| 4472 | |
| 4473 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4474 | version = 2 |
| 4475 | type = 18 |
| 4476 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4477 | |
| 4478 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 4479 | self.xid = xid |
| 4480 | if flags != None: |
| 4481 | self.flags = flags |
| 4482 | else: |
| 4483 | self.flags = 0 |
| 4484 | if table_id != None: |
| 4485 | self.table_id = table_id |
| 4486 | else: |
| 4487 | self.table_id = 0 |
| 4488 | if out_port != None: |
| 4489 | self.out_port = out_port |
| 4490 | else: |
| 4491 | self.out_port = 0 |
| 4492 | if out_group != None: |
| 4493 | self.out_group = out_group |
| 4494 | else: |
| 4495 | self.out_group = 0 |
| 4496 | if cookie != None: |
| 4497 | self.cookie = cookie |
| 4498 | else: |
| 4499 | self.cookie = 0 |
| 4500 | if cookie_mask != None: |
| 4501 | self.cookie_mask = cookie_mask |
| 4502 | else: |
| 4503 | self.cookie_mask = 0 |
| 4504 | if match != None: |
| 4505 | self.match = match |
| 4506 | else: |
| 4507 | self.match = common.match() |
| 4508 | |
| 4509 | def pack(self): |
| 4510 | packed = [] |
| 4511 | packed.append(struct.pack("!B", self.version)) |
| 4512 | packed.append(struct.pack("!B", self.type)) |
| 4513 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4514 | packed.append(struct.pack("!L", self.xid)) |
| 4515 | packed.append(struct.pack("!H", self.stats_type)) |
| 4516 | packed.append(struct.pack("!H", self.flags)) |
| 4517 | packed.append('\x00' * 4) |
| 4518 | packed.append(struct.pack("!B", self.table_id)) |
| 4519 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4520 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4521 | packed.append(struct.pack("!L", self.out_group)) |
| 4522 | packed.append('\x00' * 4) |
| 4523 | packed.append(struct.pack("!Q", self.cookie)) |
| 4524 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4525 | packed.append(self.match.pack()) |
| 4526 | length = sum([len(x) for x in packed]) |
| 4527 | packed[2] = struct.pack("!H", length) |
| 4528 | return ''.join(packed) |
| 4529 | |
| 4530 | @staticmethod |
| 4531 | def unpack(buf): |
| 4532 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4533 | obj = flow_stats_request() |
| 4534 | if type(buf) == loxi.generic_util.OFReader: |
| 4535 | reader = buf |
| 4536 | else: |
| 4537 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4538 | _version = reader.read("!B")[0] |
| 4539 | assert(_version == 2) |
| 4540 | _type = reader.read("!B")[0] |
| 4541 | assert(_type == 18) |
| 4542 | _length = reader.read("!H")[0] |
| 4543 | obj.xid = reader.read("!L")[0] |
| 4544 | _stats_type = reader.read("!H")[0] |
| 4545 | assert(_stats_type == 1) |
| 4546 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4547 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4548 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4549 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4550 | obj.out_port = util.unpack_port_no(reader) |
| 4551 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4552 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4553 | obj.cookie = reader.read("!Q")[0] |
| 4554 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4555 | obj.match = common.match.unpack(reader) |
| 4556 | return obj |
| 4557 | |
| 4558 | def __eq__(self, other): |
| 4559 | if type(self) != type(other): return False |
| 4560 | if self.version != other.version: return False |
| 4561 | if self.type != other.type: return False |
| 4562 | if self.xid != other.xid: return False |
| 4563 | if self.flags != other.flags: return False |
| 4564 | if self.table_id != other.table_id: return False |
| 4565 | if self.out_port != other.out_port: return False |
| 4566 | if self.out_group != other.out_group: return False |
| 4567 | if self.cookie != other.cookie: return False |
| 4568 | if self.cookie_mask != other.cookie_mask: return False |
| 4569 | if self.match != other.match: return False |
| 4570 | return True |
| 4571 | |
| 4572 | def __ne__(self, other): |
| 4573 | return not self.__eq__(other) |
| 4574 | |
| 4575 | def __str__(self): |
| 4576 | return self.show() |
| 4577 | |
| 4578 | def show(self): |
| 4579 | import loxi.pp |
| 4580 | return loxi.pp.pp(self) |
| 4581 | |
| 4582 | def pretty_print(self, q): |
| 4583 | q.text("flow_stats_request {") |
| 4584 | with q.group(): |
| 4585 | with q.indent(2): |
| 4586 | q.breakable() |
| 4587 | q.text("xid = "); |
| 4588 | if self.xid != None: |
| 4589 | q.text("%#x" % self.xid) |
| 4590 | else: |
| 4591 | q.text('None') |
| 4592 | q.text(","); q.breakable() |
| 4593 | q.text("flags = "); |
| 4594 | q.text("%#x" % self.flags) |
| 4595 | q.text(","); q.breakable() |
| 4596 | q.text("table_id = "); |
| 4597 | q.text("%#x" % self.table_id) |
| 4598 | q.text(","); q.breakable() |
| 4599 | q.text("out_port = "); |
| 4600 | q.text(util.pretty_port(self.out_port)) |
| 4601 | q.text(","); q.breakable() |
| 4602 | q.text("out_group = "); |
| 4603 | q.text("%#x" % self.out_group) |
| 4604 | q.text(","); q.breakable() |
| 4605 | q.text("cookie = "); |
| 4606 | q.text("%#x" % self.cookie) |
| 4607 | q.text(","); q.breakable() |
| 4608 | q.text("cookie_mask = "); |
| 4609 | q.text("%#x" % self.cookie_mask) |
| 4610 | q.text(","); q.breakable() |
| 4611 | q.text("match = "); |
| 4612 | q.pp(self.match) |
| 4613 | q.breakable() |
| 4614 | q.text('}') |
| 4615 | |
| 4616 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4617 | version = 2 |
| 4618 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4619 | |
| 4620 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 4621 | self.xid = xid |
| 4622 | if flags != None: |
| 4623 | self.flags = flags |
| 4624 | else: |
| 4625 | self.flags = 0 |
| 4626 | if miss_send_len != None: |
| 4627 | self.miss_send_len = miss_send_len |
| 4628 | else: |
| 4629 | self.miss_send_len = 0 |
| 4630 | |
| 4631 | def pack(self): |
| 4632 | packed = [] |
| 4633 | packed.append(struct.pack("!B", self.version)) |
| 4634 | packed.append(struct.pack("!B", self.type)) |
| 4635 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4636 | packed.append(struct.pack("!L", self.xid)) |
| 4637 | packed.append(struct.pack("!H", self.flags)) |
| 4638 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 4639 | length = sum([len(x) for x in packed]) |
| 4640 | packed[2] = struct.pack("!H", length) |
| 4641 | return ''.join(packed) |
| 4642 | |
| 4643 | @staticmethod |
| 4644 | def unpack(buf): |
| 4645 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4646 | obj = get_config_reply() |
| 4647 | if type(buf) == loxi.generic_util.OFReader: |
| 4648 | reader = buf |
| 4649 | else: |
| 4650 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4651 | _version = reader.read("!B")[0] |
| 4652 | assert(_version == 2) |
| 4653 | _type = reader.read("!B")[0] |
| 4654 | assert(_type == 8) |
| 4655 | _length = reader.read("!H")[0] |
| 4656 | obj.xid = reader.read("!L")[0] |
| 4657 | obj.flags = reader.read("!H")[0] |
| 4658 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4659 | return obj |
| 4660 | |
| 4661 | def __eq__(self, other): |
| 4662 | if type(self) != type(other): return False |
| 4663 | if self.version != other.version: return False |
| 4664 | if self.type != other.type: return False |
| 4665 | if self.xid != other.xid: return False |
| 4666 | if self.flags != other.flags: return False |
| 4667 | if self.miss_send_len != other.miss_send_len: return False |
| 4668 | return True |
| 4669 | |
| 4670 | def __ne__(self, other): |
| 4671 | return not self.__eq__(other) |
| 4672 | |
| 4673 | def __str__(self): |
| 4674 | return self.show() |
| 4675 | |
| 4676 | def show(self): |
| 4677 | import loxi.pp |
| 4678 | return loxi.pp.pp(self) |
| 4679 | |
| 4680 | def pretty_print(self, q): |
| 4681 | q.text("get_config_reply {") |
| 4682 | with q.group(): |
| 4683 | with q.indent(2): |
| 4684 | q.breakable() |
| 4685 | q.text("xid = "); |
| 4686 | if self.xid != None: |
| 4687 | q.text("%#x" % self.xid) |
| 4688 | else: |
| 4689 | q.text('None') |
| 4690 | q.text(","); q.breakable() |
| 4691 | q.text("flags = "); |
| 4692 | q.text("%#x" % self.flags) |
| 4693 | q.text(","); q.breakable() |
| 4694 | q.text("miss_send_len = "); |
| 4695 | q.text("%#x" % self.miss_send_len) |
| 4696 | q.breakable() |
| 4697 | q.text('}') |
| 4698 | |
| 4699 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4700 | version = 2 |
| 4701 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4702 | |
| 4703 | def __init__(self, xid=None): |
| 4704 | self.xid = xid |
| 4705 | |
| 4706 | def pack(self): |
| 4707 | packed = [] |
| 4708 | packed.append(struct.pack("!B", self.version)) |
| 4709 | packed.append(struct.pack("!B", self.type)) |
| 4710 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4711 | packed.append(struct.pack("!L", self.xid)) |
| 4712 | length = sum([len(x) for x in packed]) |
| 4713 | packed[2] = struct.pack("!H", length) |
| 4714 | return ''.join(packed) |
| 4715 | |
| 4716 | @staticmethod |
| 4717 | def unpack(buf): |
| 4718 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4719 | obj = get_config_request() |
| 4720 | if type(buf) == loxi.generic_util.OFReader: |
| 4721 | reader = buf |
| 4722 | else: |
| 4723 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4724 | _version = reader.read("!B")[0] |
| 4725 | assert(_version == 2) |
| 4726 | _type = reader.read("!B")[0] |
| 4727 | assert(_type == 7) |
| 4728 | _length = reader.read("!H")[0] |
| 4729 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4730 | return obj |
| 4731 | |
| 4732 | def __eq__(self, other): |
| 4733 | if type(self) != type(other): return False |
| 4734 | if self.version != other.version: return False |
| 4735 | if self.type != other.type: return False |
| 4736 | if self.xid != other.xid: return False |
| 4737 | return True |
| 4738 | |
| 4739 | def __ne__(self, other): |
| 4740 | return not self.__eq__(other) |
| 4741 | |
| 4742 | def __str__(self): |
| 4743 | return self.show() |
| 4744 | |
| 4745 | def show(self): |
| 4746 | import loxi.pp |
| 4747 | return loxi.pp.pp(self) |
| 4748 | |
| 4749 | def pretty_print(self, q): |
| 4750 | q.text("get_config_request {") |
| 4751 | with q.group(): |
| 4752 | with q.indent(2): |
| 4753 | q.breakable() |
| 4754 | q.text("xid = "); |
| 4755 | if self.xid != None: |
| 4756 | q.text("%#x" % self.xid) |
| 4757 | else: |
| 4758 | q.text('None') |
| 4759 | q.breakable() |
| 4760 | q.text('}') |
| 4761 | |
| 4762 | class group_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4763 | version = 2 |
| 4764 | type = 19 |
| 4765 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4766 | |
| 4767 | def __init__(self, xid=None, flags=None, entries=None): |
| 4768 | self.xid = xid |
| 4769 | if flags != None: |
| 4770 | self.flags = flags |
| 4771 | else: |
| 4772 | self.flags = 0 |
| 4773 | if entries != None: |
| 4774 | self.entries = entries |
| 4775 | else: |
| 4776 | self.entries = [] |
| 4777 | |
| 4778 | def pack(self): |
| 4779 | packed = [] |
| 4780 | packed.append(struct.pack("!B", self.version)) |
| 4781 | packed.append(struct.pack("!B", self.type)) |
| 4782 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4783 | packed.append(struct.pack("!L", self.xid)) |
| 4784 | packed.append(struct.pack("!H", self.stats_type)) |
| 4785 | packed.append(struct.pack("!H", self.flags)) |
| 4786 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4787 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4788 | length = sum([len(x) for x in packed]) |
| 4789 | packed[2] = struct.pack("!H", length) |
| 4790 | return ''.join(packed) |
| 4791 | |
| 4792 | @staticmethod |
| 4793 | def unpack(buf): |
| 4794 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4795 | obj = group_desc_stats_reply() |
| 4796 | if type(buf) == loxi.generic_util.OFReader: |
| 4797 | reader = buf |
| 4798 | else: |
| 4799 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4800 | _version = reader.read("!B")[0] |
| 4801 | assert(_version == 2) |
| 4802 | _type = reader.read("!B")[0] |
| 4803 | assert(_type == 19) |
| 4804 | _length = reader.read("!H")[0] |
| 4805 | obj.xid = reader.read("!L")[0] |
| 4806 | _stats_type = reader.read("!H")[0] |
| 4807 | assert(_stats_type == 7) |
| 4808 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4809 | reader.skip(4) |
| 4810 | obj.entries = common.unpack_list_group_desc_stats_entry(reader) |
| 4811 | return obj |
| 4812 | |
| 4813 | def __eq__(self, other): |
| 4814 | if type(self) != type(other): return False |
| 4815 | if self.version != other.version: return False |
| 4816 | if self.type != other.type: return False |
| 4817 | if self.xid != other.xid: return False |
| 4818 | if self.flags != other.flags: return False |
| 4819 | if self.entries != other.entries: return False |
| 4820 | return True |
| 4821 | |
| 4822 | def __ne__(self, other): |
| 4823 | return not self.__eq__(other) |
| 4824 | |
| 4825 | def __str__(self): |
| 4826 | return self.show() |
| 4827 | |
| 4828 | def show(self): |
| 4829 | import loxi.pp |
| 4830 | return loxi.pp.pp(self) |
| 4831 | |
| 4832 | def pretty_print(self, q): |
| 4833 | q.text("group_desc_stats_reply {") |
| 4834 | with q.group(): |
| 4835 | with q.indent(2): |
| 4836 | q.breakable() |
| 4837 | q.text("xid = "); |
| 4838 | if self.xid != None: |
| 4839 | q.text("%#x" % self.xid) |
| 4840 | else: |
| 4841 | q.text('None') |
| 4842 | q.text(","); q.breakable() |
| 4843 | q.text("flags = "); |
| 4844 | q.text("%#x" % self.flags) |
| 4845 | q.text(","); q.breakable() |
| 4846 | q.text("entries = "); |
| 4847 | q.pp(self.entries) |
| 4848 | q.breakable() |
| 4849 | q.text('}') |
| 4850 | |
| 4851 | class group_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4852 | version = 2 |
| 4853 | type = 18 |
| 4854 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4855 | |
| 4856 | def __init__(self, xid=None, flags=None): |
| 4857 | self.xid = xid |
| 4858 | if flags != None: |
| 4859 | self.flags = flags |
| 4860 | else: |
| 4861 | self.flags = 0 |
| 4862 | |
| 4863 | def pack(self): |
| 4864 | packed = [] |
| 4865 | packed.append(struct.pack("!B", self.version)) |
| 4866 | packed.append(struct.pack("!B", self.type)) |
| 4867 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4868 | packed.append(struct.pack("!L", self.xid)) |
| 4869 | packed.append(struct.pack("!H", self.stats_type)) |
| 4870 | packed.append(struct.pack("!H", self.flags)) |
| 4871 | packed.append('\x00' * 4) |
| 4872 | length = sum([len(x) for x in packed]) |
| 4873 | packed[2] = struct.pack("!H", length) |
| 4874 | return ''.join(packed) |
| 4875 | |
| 4876 | @staticmethod |
| 4877 | def unpack(buf): |
| 4878 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4879 | obj = group_desc_stats_request() |
| 4880 | if type(buf) == loxi.generic_util.OFReader: |
| 4881 | reader = buf |
| 4882 | else: |
| 4883 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4884 | _version = reader.read("!B")[0] |
| 4885 | assert(_version == 2) |
| 4886 | _type = reader.read("!B")[0] |
| 4887 | assert(_type == 18) |
| 4888 | _length = reader.read("!H")[0] |
| 4889 | obj.xid = reader.read("!L")[0] |
| 4890 | _stats_type = reader.read("!H")[0] |
| 4891 | assert(_stats_type == 7) |
| 4892 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4893 | reader.skip(4) |
| 4894 | return obj |
| 4895 | |
| 4896 | def __eq__(self, other): |
| 4897 | if type(self) != type(other): return False |
| 4898 | if self.version != other.version: return False |
| 4899 | if self.type != other.type: return False |
| 4900 | if self.xid != other.xid: return False |
| 4901 | if self.flags != other.flags: return False |
| 4902 | return True |
| 4903 | |
| 4904 | def __ne__(self, other): |
| 4905 | return not self.__eq__(other) |
| 4906 | |
| 4907 | def __str__(self): |
| 4908 | return self.show() |
| 4909 | |
| 4910 | def show(self): |
| 4911 | import loxi.pp |
| 4912 | return loxi.pp.pp(self) |
| 4913 | |
| 4914 | def pretty_print(self, q): |
| 4915 | q.text("group_desc_stats_request {") |
| 4916 | with q.group(): |
| 4917 | with q.indent(2): |
| 4918 | q.breakable() |
| 4919 | q.text("xid = "); |
| 4920 | if self.xid != None: |
| 4921 | q.text("%#x" % self.xid) |
| 4922 | else: |
| 4923 | q.text('None') |
| 4924 | q.text(","); q.breakable() |
| 4925 | q.text("flags = "); |
| 4926 | q.text("%#x" % self.flags) |
| 4927 | q.breakable() |
| 4928 | q.text('}') |
| 4929 | |
| 4930 | class group_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4931 | version = 2 |
| 4932 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4933 | |
| 4934 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 4935 | self.xid = xid |
| 4936 | if command != None: |
| 4937 | self.command = command |
| 4938 | else: |
| 4939 | self.command = 0 |
| 4940 | if group_type != None: |
| 4941 | self.group_type = group_type |
| 4942 | else: |
| 4943 | self.group_type = 0 |
| 4944 | if group_id != None: |
| 4945 | self.group_id = group_id |
| 4946 | else: |
| 4947 | self.group_id = 0 |
| 4948 | if buckets != None: |
| 4949 | self.buckets = buckets |
| 4950 | else: |
| 4951 | self.buckets = [] |
| 4952 | |
| 4953 | def pack(self): |
| 4954 | packed = [] |
| 4955 | packed.append(struct.pack("!B", self.version)) |
| 4956 | packed.append(struct.pack("!B", self.type)) |
| 4957 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4958 | packed.append(struct.pack("!L", self.xid)) |
| 4959 | packed.append(struct.pack("!H", self.command)) |
| 4960 | packed.append(struct.pack("!B", self.group_type)) |
| 4961 | packed.append('\x00' * 1) |
| 4962 | packed.append(struct.pack("!L", self.group_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4963 | packed.append(util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4964 | length = sum([len(x) for x in packed]) |
| 4965 | packed[2] = struct.pack("!H", length) |
| 4966 | return ''.join(packed) |
| 4967 | |
| 4968 | @staticmethod |
| 4969 | def unpack(buf): |
| 4970 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4971 | obj = group_mod() |
| 4972 | if type(buf) == loxi.generic_util.OFReader: |
| 4973 | reader = buf |
| 4974 | else: |
| 4975 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4976 | _version = reader.read("!B")[0] |
| 4977 | assert(_version == 2) |
| 4978 | _type = reader.read("!B")[0] |
| 4979 | assert(_type == 15) |
| 4980 | _length = reader.read("!H")[0] |
| 4981 | obj.xid = reader.read("!L")[0] |
| 4982 | obj.command = reader.read("!H")[0] |
| 4983 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4984 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4985 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4986 | obj.buckets = common.unpack_list_bucket(reader) |
| 4987 | return obj |
| 4988 | |
| 4989 | def __eq__(self, other): |
| 4990 | if type(self) != type(other): return False |
| 4991 | if self.version != other.version: return False |
| 4992 | if self.type != other.type: return False |
| 4993 | if self.xid != other.xid: return False |
| 4994 | if self.command != other.command: return False |
| 4995 | if self.group_type != other.group_type: return False |
| 4996 | if self.group_id != other.group_id: return False |
| 4997 | if self.buckets != other.buckets: return False |
| 4998 | return True |
| 4999 | |
| 5000 | def __ne__(self, other): |
| 5001 | return not self.__eq__(other) |
| 5002 | |
| 5003 | def __str__(self): |
| 5004 | return self.show() |
| 5005 | |
| 5006 | def show(self): |
| 5007 | import loxi.pp |
| 5008 | return loxi.pp.pp(self) |
| 5009 | |
| 5010 | def pretty_print(self, q): |
| 5011 | q.text("group_mod {") |
| 5012 | with q.group(): |
| 5013 | with q.indent(2): |
| 5014 | q.breakable() |
| 5015 | q.text("xid = "); |
| 5016 | if self.xid != None: |
| 5017 | q.text("%#x" % self.xid) |
| 5018 | else: |
| 5019 | q.text('None') |
| 5020 | q.text(","); q.breakable() |
| 5021 | q.text("command = "); |
| 5022 | q.text("%#x" % self.command) |
| 5023 | q.text(","); q.breakable() |
| 5024 | q.text("group_type = "); |
| 5025 | q.text("%#x" % self.group_type) |
| 5026 | q.text(","); q.breakable() |
| 5027 | q.text("group_id = "); |
| 5028 | q.text("%#x" % self.group_id) |
| 5029 | q.text(","); q.breakable() |
| 5030 | q.text("buckets = "); |
| 5031 | q.pp(self.buckets) |
| 5032 | q.breakable() |
| 5033 | q.text('}') |
| 5034 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 5035 | class group_mod_failed_error_msg(Message): |
| 5036 | version = 2 |
| 5037 | type = 1 |
| 5038 | err_type = 6 |
| 5039 | |
| 5040 | def __init__(self, xid=None, code=None, data=None): |
| 5041 | self.xid = xid |
| 5042 | if code != None: |
| 5043 | self.code = code |
| 5044 | else: |
| 5045 | self.code = 0 |
| 5046 | if data != None: |
| 5047 | self.data = data |
| 5048 | else: |
| 5049 | self.data = '' |
| 5050 | |
| 5051 | def pack(self): |
| 5052 | packed = [] |
| 5053 | packed.append(struct.pack("!B", self.version)) |
| 5054 | packed.append(struct.pack("!B", self.type)) |
| 5055 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5056 | packed.append(struct.pack("!L", self.xid)) |
| 5057 | packed.append(struct.pack("!H", self.err_type)) |
| 5058 | packed.append(struct.pack("!H", self.code)) |
| 5059 | packed.append(self.data) |
| 5060 | length = sum([len(x) for x in packed]) |
| 5061 | packed[2] = struct.pack("!H", length) |
| 5062 | return ''.join(packed) |
| 5063 | |
| 5064 | @staticmethod |
| 5065 | def unpack(buf): |
| 5066 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5067 | obj = group_mod_failed_error_msg() |
| 5068 | if type(buf) == loxi.generic_util.OFReader: |
| 5069 | reader = buf |
| 5070 | else: |
| 5071 | reader = loxi.generic_util.OFReader(buf) |
| 5072 | _version = reader.read("!B")[0] |
| 5073 | assert(_version == 2) |
| 5074 | _type = reader.read("!B")[0] |
| 5075 | assert(_type == 1) |
| 5076 | _length = reader.read("!H")[0] |
| 5077 | obj.xid = reader.read("!L")[0] |
| 5078 | _err_type = reader.read("!H")[0] |
| 5079 | assert(_err_type == 6) |
| 5080 | obj.code = reader.read("!H")[0] |
| 5081 | obj.data = str(reader.read_all()) |
| 5082 | return obj |
| 5083 | |
| 5084 | def __eq__(self, other): |
| 5085 | if type(self) != type(other): return False |
| 5086 | if self.version != other.version: return False |
| 5087 | if self.type != other.type: return False |
| 5088 | if self.xid != other.xid: return False |
| 5089 | if self.code != other.code: return False |
| 5090 | if self.data != other.data: return False |
| 5091 | return True |
| 5092 | |
| 5093 | def __ne__(self, other): |
| 5094 | return not self.__eq__(other) |
| 5095 | |
| 5096 | def __str__(self): |
| 5097 | return self.show() |
| 5098 | |
| 5099 | def show(self): |
| 5100 | import loxi.pp |
| 5101 | return loxi.pp.pp(self) |
| 5102 | |
| 5103 | def pretty_print(self, q): |
| 5104 | q.text("group_mod_failed_error_msg {") |
| 5105 | with q.group(): |
| 5106 | with q.indent(2): |
| 5107 | q.breakable() |
| 5108 | q.text("xid = "); |
| 5109 | if self.xid != None: |
| 5110 | q.text("%#x" % self.xid) |
| 5111 | else: |
| 5112 | q.text('None') |
| 5113 | q.text(","); q.breakable() |
| 5114 | q.text("code = "); |
| 5115 | q.text("%#x" % self.code) |
| 5116 | q.text(","); q.breakable() |
| 5117 | q.text("data = "); |
| 5118 | q.pp(self.data) |
| 5119 | q.breakable() |
| 5120 | q.text('}') |
| 5121 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5122 | class group_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5123 | version = 2 |
| 5124 | type = 19 |
| 5125 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5126 | |
| 5127 | def __init__(self, xid=None, flags=None, entries=None): |
| 5128 | self.xid = xid |
| 5129 | if flags != None: |
| 5130 | self.flags = flags |
| 5131 | else: |
| 5132 | self.flags = 0 |
| 5133 | if entries != None: |
| 5134 | self.entries = entries |
| 5135 | else: |
| 5136 | self.entries = [] |
| 5137 | |
| 5138 | def pack(self): |
| 5139 | packed = [] |
| 5140 | packed.append(struct.pack("!B", self.version)) |
| 5141 | packed.append(struct.pack("!B", self.type)) |
| 5142 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5143 | packed.append(struct.pack("!L", self.xid)) |
| 5144 | packed.append(struct.pack("!H", self.stats_type)) |
| 5145 | packed.append(struct.pack("!H", self.flags)) |
| 5146 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5147 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5148 | length = sum([len(x) for x in packed]) |
| 5149 | packed[2] = struct.pack("!H", length) |
| 5150 | return ''.join(packed) |
| 5151 | |
| 5152 | @staticmethod |
| 5153 | def unpack(buf): |
| 5154 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5155 | obj = group_stats_reply() |
| 5156 | if type(buf) == loxi.generic_util.OFReader: |
| 5157 | reader = buf |
| 5158 | else: |
| 5159 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5160 | _version = reader.read("!B")[0] |
| 5161 | assert(_version == 2) |
| 5162 | _type = reader.read("!B")[0] |
| 5163 | assert(_type == 19) |
| 5164 | _length = reader.read("!H")[0] |
| 5165 | obj.xid = reader.read("!L")[0] |
| 5166 | _stats_type = reader.read("!H")[0] |
| 5167 | assert(_stats_type == 6) |
| 5168 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5169 | reader.skip(4) |
| 5170 | obj.entries = common.unpack_list_group_stats_entry(reader) |
| 5171 | return obj |
| 5172 | |
| 5173 | def __eq__(self, other): |
| 5174 | if type(self) != type(other): return False |
| 5175 | if self.version != other.version: return False |
| 5176 | if self.type != other.type: return False |
| 5177 | if self.xid != other.xid: return False |
| 5178 | if self.flags != other.flags: return False |
| 5179 | if self.entries != other.entries: return False |
| 5180 | return True |
| 5181 | |
| 5182 | def __ne__(self, other): |
| 5183 | return not self.__eq__(other) |
| 5184 | |
| 5185 | def __str__(self): |
| 5186 | return self.show() |
| 5187 | |
| 5188 | def show(self): |
| 5189 | import loxi.pp |
| 5190 | return loxi.pp.pp(self) |
| 5191 | |
| 5192 | def pretty_print(self, q): |
| 5193 | q.text("group_stats_reply {") |
| 5194 | with q.group(): |
| 5195 | with q.indent(2): |
| 5196 | q.breakable() |
| 5197 | q.text("xid = "); |
| 5198 | if self.xid != None: |
| 5199 | q.text("%#x" % self.xid) |
| 5200 | else: |
| 5201 | q.text('None') |
| 5202 | q.text(","); q.breakable() |
| 5203 | q.text("flags = "); |
| 5204 | q.text("%#x" % self.flags) |
| 5205 | q.text(","); q.breakable() |
| 5206 | q.text("entries = "); |
| 5207 | q.pp(self.entries) |
| 5208 | q.breakable() |
| 5209 | q.text('}') |
| 5210 | |
| 5211 | class group_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5212 | version = 2 |
| 5213 | type = 18 |
| 5214 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5215 | |
| 5216 | def __init__(self, xid=None, flags=None, group_id=None): |
| 5217 | self.xid = xid |
| 5218 | if flags != None: |
| 5219 | self.flags = flags |
| 5220 | else: |
| 5221 | self.flags = 0 |
| 5222 | if group_id != None: |
| 5223 | self.group_id = group_id |
| 5224 | else: |
| 5225 | self.group_id = 0 |
| 5226 | |
| 5227 | def pack(self): |
| 5228 | packed = [] |
| 5229 | packed.append(struct.pack("!B", self.version)) |
| 5230 | packed.append(struct.pack("!B", self.type)) |
| 5231 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5232 | packed.append(struct.pack("!L", self.xid)) |
| 5233 | packed.append(struct.pack("!H", self.stats_type)) |
| 5234 | packed.append(struct.pack("!H", self.flags)) |
| 5235 | packed.append('\x00' * 4) |
| 5236 | packed.append(struct.pack("!L", self.group_id)) |
| 5237 | packed.append('\x00' * 4) |
| 5238 | length = sum([len(x) for x in packed]) |
| 5239 | packed[2] = struct.pack("!H", length) |
| 5240 | return ''.join(packed) |
| 5241 | |
| 5242 | @staticmethod |
| 5243 | def unpack(buf): |
| 5244 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5245 | obj = group_stats_request() |
| 5246 | if type(buf) == loxi.generic_util.OFReader: |
| 5247 | reader = buf |
| 5248 | else: |
| 5249 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5250 | _version = reader.read("!B")[0] |
| 5251 | assert(_version == 2) |
| 5252 | _type = reader.read("!B")[0] |
| 5253 | assert(_type == 18) |
| 5254 | _length = reader.read("!H")[0] |
| 5255 | obj.xid = reader.read("!L")[0] |
| 5256 | _stats_type = reader.read("!H")[0] |
| 5257 | assert(_stats_type == 6) |
| 5258 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5259 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5260 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5261 | reader.skip(4) |
| 5262 | return obj |
| 5263 | |
| 5264 | def __eq__(self, other): |
| 5265 | if type(self) != type(other): return False |
| 5266 | if self.version != other.version: return False |
| 5267 | if self.type != other.type: return False |
| 5268 | if self.xid != other.xid: return False |
| 5269 | if self.flags != other.flags: return False |
| 5270 | if self.group_id != other.group_id: return False |
| 5271 | return True |
| 5272 | |
| 5273 | def __ne__(self, other): |
| 5274 | return not self.__eq__(other) |
| 5275 | |
| 5276 | def __str__(self): |
| 5277 | return self.show() |
| 5278 | |
| 5279 | def show(self): |
| 5280 | import loxi.pp |
| 5281 | return loxi.pp.pp(self) |
| 5282 | |
| 5283 | def pretty_print(self, q): |
| 5284 | q.text("group_stats_request {") |
| 5285 | with q.group(): |
| 5286 | with q.indent(2): |
| 5287 | q.breakable() |
| 5288 | q.text("xid = "); |
| 5289 | if self.xid != None: |
| 5290 | q.text("%#x" % self.xid) |
| 5291 | else: |
| 5292 | q.text('None') |
| 5293 | q.text(","); q.breakable() |
| 5294 | q.text("flags = "); |
| 5295 | q.text("%#x" % self.flags) |
| 5296 | q.text(","); q.breakable() |
| 5297 | q.text("group_id = "); |
| 5298 | q.text("%#x" % self.group_id) |
| 5299 | q.breakable() |
| 5300 | q.text('}') |
| 5301 | |
| 5302 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5303 | version = 2 |
| 5304 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5305 | |
| 5306 | def __init__(self, xid=None): |
| 5307 | self.xid = xid |
| 5308 | |
| 5309 | def pack(self): |
| 5310 | packed = [] |
| 5311 | packed.append(struct.pack("!B", self.version)) |
| 5312 | packed.append(struct.pack("!B", self.type)) |
| 5313 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5314 | packed.append(struct.pack("!L", self.xid)) |
| 5315 | length = sum([len(x) for x in packed]) |
| 5316 | packed[2] = struct.pack("!H", length) |
| 5317 | return ''.join(packed) |
| 5318 | |
| 5319 | @staticmethod |
| 5320 | def unpack(buf): |
| 5321 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5322 | obj = hello() |
| 5323 | if type(buf) == loxi.generic_util.OFReader: |
| 5324 | reader = buf |
| 5325 | else: |
| 5326 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5327 | _version = reader.read("!B")[0] |
| 5328 | assert(_version == 2) |
| 5329 | _type = reader.read("!B")[0] |
| 5330 | assert(_type == 0) |
| 5331 | _length = reader.read("!H")[0] |
| 5332 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5333 | return obj |
| 5334 | |
| 5335 | def __eq__(self, other): |
| 5336 | if type(self) != type(other): return False |
| 5337 | if self.version != other.version: return False |
| 5338 | if self.type != other.type: return False |
| 5339 | if self.xid != other.xid: return False |
| 5340 | return True |
| 5341 | |
| 5342 | def __ne__(self, other): |
| 5343 | return not self.__eq__(other) |
| 5344 | |
| 5345 | def __str__(self): |
| 5346 | return self.show() |
| 5347 | |
| 5348 | def show(self): |
| 5349 | import loxi.pp |
| 5350 | return loxi.pp.pp(self) |
| 5351 | |
| 5352 | def pretty_print(self, q): |
| 5353 | q.text("hello {") |
| 5354 | with q.group(): |
| 5355 | with q.indent(2): |
| 5356 | q.breakable() |
| 5357 | q.text("xid = "); |
| 5358 | if self.xid != None: |
| 5359 | q.text("%#x" % self.xid) |
| 5360 | else: |
| 5361 | q.text('None') |
| 5362 | q.breakable() |
| 5363 | q.text('}') |
| 5364 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 5365 | class hello_failed_error_msg(Message): |
| 5366 | version = 2 |
| 5367 | type = 1 |
| 5368 | err_type = 0 |
| 5369 | |
| 5370 | def __init__(self, xid=None, code=None, data=None): |
| 5371 | self.xid = xid |
| 5372 | if code != None: |
| 5373 | self.code = code |
| 5374 | else: |
| 5375 | self.code = 0 |
| 5376 | if data != None: |
| 5377 | self.data = data |
| 5378 | else: |
| 5379 | self.data = '' |
| 5380 | |
| 5381 | def pack(self): |
| 5382 | packed = [] |
| 5383 | packed.append(struct.pack("!B", self.version)) |
| 5384 | packed.append(struct.pack("!B", self.type)) |
| 5385 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5386 | packed.append(struct.pack("!L", self.xid)) |
| 5387 | packed.append(struct.pack("!H", self.err_type)) |
| 5388 | packed.append(struct.pack("!H", self.code)) |
| 5389 | packed.append(self.data) |
| 5390 | length = sum([len(x) for x in packed]) |
| 5391 | packed[2] = struct.pack("!H", length) |
| 5392 | return ''.join(packed) |
| 5393 | |
| 5394 | @staticmethod |
| 5395 | def unpack(buf): |
| 5396 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5397 | obj = hello_failed_error_msg() |
| 5398 | if type(buf) == loxi.generic_util.OFReader: |
| 5399 | reader = buf |
| 5400 | else: |
| 5401 | reader = loxi.generic_util.OFReader(buf) |
| 5402 | _version = reader.read("!B")[0] |
| 5403 | assert(_version == 2) |
| 5404 | _type = reader.read("!B")[0] |
| 5405 | assert(_type == 1) |
| 5406 | _length = reader.read("!H")[0] |
| 5407 | obj.xid = reader.read("!L")[0] |
| 5408 | _err_type = reader.read("!H")[0] |
| 5409 | assert(_err_type == 0) |
| 5410 | obj.code = reader.read("!H")[0] |
| 5411 | obj.data = str(reader.read_all()) |
| 5412 | return obj |
| 5413 | |
| 5414 | def __eq__(self, other): |
| 5415 | if type(self) != type(other): return False |
| 5416 | if self.version != other.version: return False |
| 5417 | if self.type != other.type: return False |
| 5418 | if self.xid != other.xid: return False |
| 5419 | if self.code != other.code: return False |
| 5420 | if self.data != other.data: return False |
| 5421 | return True |
| 5422 | |
| 5423 | def __ne__(self, other): |
| 5424 | return not self.__eq__(other) |
| 5425 | |
| 5426 | def __str__(self): |
| 5427 | return self.show() |
| 5428 | |
| 5429 | def show(self): |
| 5430 | import loxi.pp |
| 5431 | return loxi.pp.pp(self) |
| 5432 | |
| 5433 | def pretty_print(self, q): |
| 5434 | q.text("hello_failed_error_msg {") |
| 5435 | with q.group(): |
| 5436 | with q.indent(2): |
| 5437 | q.breakable() |
| 5438 | q.text("xid = "); |
| 5439 | if self.xid != None: |
| 5440 | q.text("%#x" % self.xid) |
| 5441 | else: |
| 5442 | q.text('None') |
| 5443 | q.text(","); q.breakable() |
| 5444 | q.text("code = "); |
| 5445 | q.text("%#x" % self.code) |
| 5446 | q.text(","); q.breakable() |
| 5447 | q.text("data = "); |
| 5448 | q.pp(self.data) |
| 5449 | q.breakable() |
| 5450 | q.text('}') |
| 5451 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5452 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5453 | version = 2 |
| 5454 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5455 | |
| 5456 | def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None): |
| 5457 | self.xid = xid |
| 5458 | if buffer_id != None: |
| 5459 | self.buffer_id = buffer_id |
| 5460 | else: |
| 5461 | self.buffer_id = 0 |
| 5462 | if in_port != None: |
| 5463 | self.in_port = in_port |
| 5464 | else: |
| 5465 | self.in_port = 0 |
| 5466 | if in_phy_port != None: |
| 5467 | self.in_phy_port = in_phy_port |
| 5468 | else: |
| 5469 | self.in_phy_port = 0 |
| 5470 | if total_len != None: |
| 5471 | self.total_len = total_len |
| 5472 | else: |
| 5473 | self.total_len = 0 |
| 5474 | if reason != None: |
| 5475 | self.reason = reason |
| 5476 | else: |
| 5477 | self.reason = 0 |
| 5478 | if table_id != None: |
| 5479 | self.table_id = table_id |
| 5480 | else: |
| 5481 | self.table_id = 0 |
| 5482 | if data != None: |
| 5483 | self.data = data |
| 5484 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5485 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5486 | |
| 5487 | def pack(self): |
| 5488 | packed = [] |
| 5489 | packed.append(struct.pack("!B", self.version)) |
| 5490 | packed.append(struct.pack("!B", self.type)) |
| 5491 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5492 | packed.append(struct.pack("!L", self.xid)) |
| 5493 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5494 | packed.append(util.pack_port_no(self.in_port)) |
| 5495 | packed.append(util.pack_port_no(self.in_phy_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5496 | packed.append(struct.pack("!H", self.total_len)) |
| 5497 | packed.append(struct.pack("!B", self.reason)) |
| 5498 | packed.append(struct.pack("!B", self.table_id)) |
| 5499 | packed.append(self.data) |
| 5500 | length = sum([len(x) for x in packed]) |
| 5501 | packed[2] = struct.pack("!H", length) |
| 5502 | return ''.join(packed) |
| 5503 | |
| 5504 | @staticmethod |
| 5505 | def unpack(buf): |
| 5506 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5507 | obj = packet_in() |
| 5508 | if type(buf) == loxi.generic_util.OFReader: |
| 5509 | reader = buf |
| 5510 | else: |
| 5511 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5512 | _version = reader.read("!B")[0] |
| 5513 | assert(_version == 2) |
| 5514 | _type = reader.read("!B")[0] |
| 5515 | assert(_type == 10) |
| 5516 | _length = reader.read("!H")[0] |
| 5517 | obj.xid = reader.read("!L")[0] |
| 5518 | obj.buffer_id = reader.read("!L")[0] |
| 5519 | obj.in_port = util.unpack_port_no(reader) |
| 5520 | obj.in_phy_port = util.unpack_port_no(reader) |
| 5521 | obj.total_len = reader.read("!H")[0] |
| 5522 | obj.reason = reader.read("!B")[0] |
| 5523 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5524 | obj.data = str(reader.read_all()) |
| 5525 | return obj |
| 5526 | |
| 5527 | def __eq__(self, other): |
| 5528 | if type(self) != type(other): return False |
| 5529 | if self.version != other.version: return False |
| 5530 | if self.type != other.type: return False |
| 5531 | if self.xid != other.xid: return False |
| 5532 | if self.buffer_id != other.buffer_id: return False |
| 5533 | if self.in_port != other.in_port: return False |
| 5534 | if self.in_phy_port != other.in_phy_port: return False |
| 5535 | if self.total_len != other.total_len: return False |
| 5536 | if self.reason != other.reason: return False |
| 5537 | if self.table_id != other.table_id: return False |
| 5538 | if self.data != other.data: return False |
| 5539 | return True |
| 5540 | |
| 5541 | def __ne__(self, other): |
| 5542 | return not self.__eq__(other) |
| 5543 | |
| 5544 | def __str__(self): |
| 5545 | return self.show() |
| 5546 | |
| 5547 | def show(self): |
| 5548 | import loxi.pp |
| 5549 | return loxi.pp.pp(self) |
| 5550 | |
| 5551 | def pretty_print(self, q): |
| 5552 | q.text("packet_in {") |
| 5553 | with q.group(): |
| 5554 | with q.indent(2): |
| 5555 | q.breakable() |
| 5556 | q.text("xid = "); |
| 5557 | if self.xid != None: |
| 5558 | q.text("%#x" % self.xid) |
| 5559 | else: |
| 5560 | q.text('None') |
| 5561 | q.text(","); q.breakable() |
| 5562 | q.text("buffer_id = "); |
| 5563 | q.text("%#x" % self.buffer_id) |
| 5564 | q.text(","); q.breakable() |
| 5565 | q.text("in_port = "); |
| 5566 | q.text(util.pretty_port(self.in_port)) |
| 5567 | q.text(","); q.breakable() |
| 5568 | q.text("in_phy_port = "); |
| 5569 | q.text(util.pretty_port(self.in_phy_port)) |
| 5570 | q.text(","); q.breakable() |
| 5571 | q.text("total_len = "); |
| 5572 | q.text("%#x" % self.total_len) |
| 5573 | q.text(","); q.breakable() |
| 5574 | q.text("reason = "); |
| 5575 | q.text("%#x" % self.reason) |
| 5576 | q.text(","); q.breakable() |
| 5577 | q.text("table_id = "); |
| 5578 | q.text("%#x" % self.table_id) |
| 5579 | q.text(","); q.breakable() |
| 5580 | q.text("data = "); |
| 5581 | q.pp(self.data) |
| 5582 | q.breakable() |
| 5583 | q.text('}') |
| 5584 | |
| 5585 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5586 | version = 2 |
| 5587 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5588 | |
| 5589 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 5590 | self.xid = xid |
| 5591 | if buffer_id != None: |
| 5592 | self.buffer_id = buffer_id |
| 5593 | else: |
| 5594 | self.buffer_id = 0 |
| 5595 | if in_port != None: |
| 5596 | self.in_port = in_port |
| 5597 | else: |
| 5598 | self.in_port = 0 |
| 5599 | if actions != None: |
| 5600 | self.actions = actions |
| 5601 | else: |
| 5602 | self.actions = [] |
| 5603 | if data != None: |
| 5604 | self.data = data |
| 5605 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5606 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5607 | |
| 5608 | def pack(self): |
| 5609 | packed = [] |
| 5610 | packed.append(struct.pack("!B", self.version)) |
| 5611 | packed.append(struct.pack("!B", self.type)) |
| 5612 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5613 | packed.append(struct.pack("!L", self.xid)) |
| 5614 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5615 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5616 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 5617 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5618 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5619 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 5620 | packed.append(self.data) |
| 5621 | length = sum([len(x) for x in packed]) |
| 5622 | packed[2] = struct.pack("!H", length) |
| 5623 | return ''.join(packed) |
| 5624 | |
| 5625 | @staticmethod |
| 5626 | def unpack(buf): |
| 5627 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5628 | obj = packet_out() |
| 5629 | if type(buf) == loxi.generic_util.OFReader: |
| 5630 | reader = buf |
| 5631 | else: |
| 5632 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5633 | _version = reader.read("!B")[0] |
| 5634 | assert(_version == 2) |
| 5635 | _type = reader.read("!B")[0] |
| 5636 | assert(_type == 13) |
| 5637 | _length = reader.read("!H")[0] |
| 5638 | obj.xid = reader.read("!L")[0] |
| 5639 | obj.buffer_id = reader.read("!L")[0] |
| 5640 | obj.in_port = util.unpack_port_no(reader) |
| 5641 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5642 | reader.skip(6) |
| 5643 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 5644 | obj.data = str(reader.read_all()) |
| 5645 | return obj |
| 5646 | |
| 5647 | def __eq__(self, other): |
| 5648 | if type(self) != type(other): return False |
| 5649 | if self.version != other.version: return False |
| 5650 | if self.type != other.type: return False |
| 5651 | if self.xid != other.xid: return False |
| 5652 | if self.buffer_id != other.buffer_id: return False |
| 5653 | if self.in_port != other.in_port: return False |
| 5654 | if self.actions != other.actions: return False |
| 5655 | if self.data != other.data: return False |
| 5656 | return True |
| 5657 | |
| 5658 | def __ne__(self, other): |
| 5659 | return not self.__eq__(other) |
| 5660 | |
| 5661 | def __str__(self): |
| 5662 | return self.show() |
| 5663 | |
| 5664 | def show(self): |
| 5665 | import loxi.pp |
| 5666 | return loxi.pp.pp(self) |
| 5667 | |
| 5668 | def pretty_print(self, q): |
| 5669 | q.text("packet_out {") |
| 5670 | with q.group(): |
| 5671 | with q.indent(2): |
| 5672 | q.breakable() |
| 5673 | q.text("xid = "); |
| 5674 | if self.xid != None: |
| 5675 | q.text("%#x" % self.xid) |
| 5676 | else: |
| 5677 | q.text('None') |
| 5678 | q.text(","); q.breakable() |
| 5679 | q.text("buffer_id = "); |
| 5680 | q.text("%#x" % self.buffer_id) |
| 5681 | q.text(","); q.breakable() |
| 5682 | q.text("in_port = "); |
| 5683 | q.text(util.pretty_port(self.in_port)) |
| 5684 | q.text(","); q.breakable() |
| 5685 | q.text("actions = "); |
| 5686 | q.pp(self.actions) |
| 5687 | q.text(","); q.breakable() |
| 5688 | q.text("data = "); |
| 5689 | q.pp(self.data) |
| 5690 | q.breakable() |
| 5691 | q.text('}') |
| 5692 | |
| 5693 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5694 | version = 2 |
| 5695 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5696 | |
| 5697 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
| 5698 | self.xid = xid |
| 5699 | if port_no != None: |
| 5700 | self.port_no = port_no |
| 5701 | else: |
| 5702 | self.port_no = 0 |
| 5703 | if hw_addr != None: |
| 5704 | self.hw_addr = hw_addr |
| 5705 | else: |
| 5706 | self.hw_addr = [0,0,0,0,0,0] |
| 5707 | if config != None: |
| 5708 | self.config = config |
| 5709 | else: |
| 5710 | self.config = 0 |
| 5711 | if mask != None: |
| 5712 | self.mask = mask |
| 5713 | else: |
| 5714 | self.mask = 0 |
| 5715 | if advertise != None: |
| 5716 | self.advertise = advertise |
| 5717 | else: |
| 5718 | self.advertise = 0 |
| 5719 | |
| 5720 | def pack(self): |
| 5721 | packed = [] |
| 5722 | packed.append(struct.pack("!B", self.version)) |
| 5723 | packed.append(struct.pack("!B", self.type)) |
| 5724 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5725 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5726 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5727 | packed.append('\x00' * 4) |
| 5728 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 5729 | packed.append('\x00' * 2) |
| 5730 | packed.append(struct.pack("!L", self.config)) |
| 5731 | packed.append(struct.pack("!L", self.mask)) |
| 5732 | packed.append(struct.pack("!L", self.advertise)) |
| 5733 | packed.append('\x00' * 4) |
| 5734 | length = sum([len(x) for x in packed]) |
| 5735 | packed[2] = struct.pack("!H", length) |
| 5736 | return ''.join(packed) |
| 5737 | |
| 5738 | @staticmethod |
| 5739 | def unpack(buf): |
| 5740 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5741 | obj = port_mod() |
| 5742 | if type(buf) == loxi.generic_util.OFReader: |
| 5743 | reader = buf |
| 5744 | else: |
| 5745 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5746 | _version = reader.read("!B")[0] |
| 5747 | assert(_version == 2) |
| 5748 | _type = reader.read("!B")[0] |
| 5749 | assert(_type == 16) |
| 5750 | _length = reader.read("!H")[0] |
| 5751 | obj.xid = reader.read("!L")[0] |
| 5752 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5753 | reader.skip(4) |
| 5754 | obj.hw_addr = list(reader.read('!6B')) |
| 5755 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5756 | obj.config = reader.read("!L")[0] |
| 5757 | obj.mask = reader.read("!L")[0] |
| 5758 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5759 | reader.skip(4) |
| 5760 | return obj |
| 5761 | |
| 5762 | def __eq__(self, other): |
| 5763 | if type(self) != type(other): return False |
| 5764 | if self.version != other.version: return False |
| 5765 | if self.type != other.type: return False |
| 5766 | if self.xid != other.xid: return False |
| 5767 | if self.port_no != other.port_no: return False |
| 5768 | if self.hw_addr != other.hw_addr: return False |
| 5769 | if self.config != other.config: return False |
| 5770 | if self.mask != other.mask: return False |
| 5771 | if self.advertise != other.advertise: return False |
| 5772 | return True |
| 5773 | |
| 5774 | def __ne__(self, other): |
| 5775 | return not self.__eq__(other) |
| 5776 | |
| 5777 | def __str__(self): |
| 5778 | return self.show() |
| 5779 | |
| 5780 | def show(self): |
| 5781 | import loxi.pp |
| 5782 | return loxi.pp.pp(self) |
| 5783 | |
| 5784 | def pretty_print(self, q): |
| 5785 | q.text("port_mod {") |
| 5786 | with q.group(): |
| 5787 | with q.indent(2): |
| 5788 | q.breakable() |
| 5789 | q.text("xid = "); |
| 5790 | if self.xid != None: |
| 5791 | q.text("%#x" % self.xid) |
| 5792 | else: |
| 5793 | q.text('None') |
| 5794 | q.text(","); q.breakable() |
| 5795 | q.text("port_no = "); |
| 5796 | q.text(util.pretty_port(self.port_no)) |
| 5797 | q.text(","); q.breakable() |
| 5798 | q.text("hw_addr = "); |
| 5799 | q.text(util.pretty_mac(self.hw_addr)) |
| 5800 | q.text(","); q.breakable() |
| 5801 | q.text("config = "); |
| 5802 | q.text("%#x" % self.config) |
| 5803 | q.text(","); q.breakable() |
| 5804 | q.text("mask = "); |
| 5805 | q.text("%#x" % self.mask) |
| 5806 | q.text(","); q.breakable() |
| 5807 | q.text("advertise = "); |
| 5808 | q.text("%#x" % self.advertise) |
| 5809 | q.breakable() |
| 5810 | q.text('}') |
| 5811 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 5812 | class port_mod_failed_error_msg(Message): |
| 5813 | version = 2 |
| 5814 | type = 1 |
| 5815 | err_type = 7 |
| 5816 | |
| 5817 | def __init__(self, xid=None, code=None, data=None): |
| 5818 | self.xid = xid |
| 5819 | if code != None: |
| 5820 | self.code = code |
| 5821 | else: |
| 5822 | self.code = 0 |
| 5823 | if data != None: |
| 5824 | self.data = data |
| 5825 | else: |
| 5826 | self.data = '' |
| 5827 | |
| 5828 | def pack(self): |
| 5829 | packed = [] |
| 5830 | packed.append(struct.pack("!B", self.version)) |
| 5831 | packed.append(struct.pack("!B", self.type)) |
| 5832 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5833 | packed.append(struct.pack("!L", self.xid)) |
| 5834 | packed.append(struct.pack("!H", self.err_type)) |
| 5835 | packed.append(struct.pack("!H", self.code)) |
| 5836 | packed.append(self.data) |
| 5837 | length = sum([len(x) for x in packed]) |
| 5838 | packed[2] = struct.pack("!H", length) |
| 5839 | return ''.join(packed) |
| 5840 | |
| 5841 | @staticmethod |
| 5842 | def unpack(buf): |
| 5843 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5844 | obj = port_mod_failed_error_msg() |
| 5845 | if type(buf) == loxi.generic_util.OFReader: |
| 5846 | reader = buf |
| 5847 | else: |
| 5848 | reader = loxi.generic_util.OFReader(buf) |
| 5849 | _version = reader.read("!B")[0] |
| 5850 | assert(_version == 2) |
| 5851 | _type = reader.read("!B")[0] |
| 5852 | assert(_type == 1) |
| 5853 | _length = reader.read("!H")[0] |
| 5854 | obj.xid = reader.read("!L")[0] |
| 5855 | _err_type = reader.read("!H")[0] |
| 5856 | assert(_err_type == 7) |
| 5857 | obj.code = reader.read("!H")[0] |
| 5858 | obj.data = str(reader.read_all()) |
| 5859 | return obj |
| 5860 | |
| 5861 | def __eq__(self, other): |
| 5862 | if type(self) != type(other): return False |
| 5863 | if self.version != other.version: return False |
| 5864 | if self.type != other.type: return False |
| 5865 | if self.xid != other.xid: return False |
| 5866 | if self.code != other.code: return False |
| 5867 | if self.data != other.data: return False |
| 5868 | return True |
| 5869 | |
| 5870 | def __ne__(self, other): |
| 5871 | return not self.__eq__(other) |
| 5872 | |
| 5873 | def __str__(self): |
| 5874 | return self.show() |
| 5875 | |
| 5876 | def show(self): |
| 5877 | import loxi.pp |
| 5878 | return loxi.pp.pp(self) |
| 5879 | |
| 5880 | def pretty_print(self, q): |
| 5881 | q.text("port_mod_failed_error_msg {") |
| 5882 | with q.group(): |
| 5883 | with q.indent(2): |
| 5884 | q.breakable() |
| 5885 | q.text("xid = "); |
| 5886 | if self.xid != None: |
| 5887 | q.text("%#x" % self.xid) |
| 5888 | else: |
| 5889 | q.text('None') |
| 5890 | q.text(","); q.breakable() |
| 5891 | q.text("code = "); |
| 5892 | q.text("%#x" % self.code) |
| 5893 | q.text(","); q.breakable() |
| 5894 | q.text("data = "); |
| 5895 | q.pp(self.data) |
| 5896 | q.breakable() |
| 5897 | q.text('}') |
| 5898 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5899 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5900 | version = 2 |
| 5901 | type = 19 |
| 5902 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5903 | |
| 5904 | def __init__(self, xid=None, flags=None, entries=None): |
| 5905 | self.xid = xid |
| 5906 | if flags != None: |
| 5907 | self.flags = flags |
| 5908 | else: |
| 5909 | self.flags = 0 |
| 5910 | if entries != None: |
| 5911 | self.entries = entries |
| 5912 | else: |
| 5913 | self.entries = [] |
| 5914 | |
| 5915 | def pack(self): |
| 5916 | packed = [] |
| 5917 | packed.append(struct.pack("!B", self.version)) |
| 5918 | packed.append(struct.pack("!B", self.type)) |
| 5919 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5920 | packed.append(struct.pack("!L", self.xid)) |
| 5921 | packed.append(struct.pack("!H", self.stats_type)) |
| 5922 | packed.append(struct.pack("!H", self.flags)) |
| 5923 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5924 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5925 | length = sum([len(x) for x in packed]) |
| 5926 | packed[2] = struct.pack("!H", length) |
| 5927 | return ''.join(packed) |
| 5928 | |
| 5929 | @staticmethod |
| 5930 | def unpack(buf): |
| 5931 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5932 | obj = port_stats_reply() |
| 5933 | if type(buf) == loxi.generic_util.OFReader: |
| 5934 | reader = buf |
| 5935 | else: |
| 5936 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5937 | _version = reader.read("!B")[0] |
| 5938 | assert(_version == 2) |
| 5939 | _type = reader.read("!B")[0] |
| 5940 | assert(_type == 19) |
| 5941 | _length = reader.read("!H")[0] |
| 5942 | obj.xid = reader.read("!L")[0] |
| 5943 | _stats_type = reader.read("!H")[0] |
| 5944 | assert(_stats_type == 4) |
| 5945 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5946 | reader.skip(4) |
| 5947 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 5948 | return obj |
| 5949 | |
| 5950 | def __eq__(self, other): |
| 5951 | if type(self) != type(other): return False |
| 5952 | if self.version != other.version: return False |
| 5953 | if self.type != other.type: return False |
| 5954 | if self.xid != other.xid: return False |
| 5955 | if self.flags != other.flags: return False |
| 5956 | if self.entries != other.entries: return False |
| 5957 | return True |
| 5958 | |
| 5959 | def __ne__(self, other): |
| 5960 | return not self.__eq__(other) |
| 5961 | |
| 5962 | def __str__(self): |
| 5963 | return self.show() |
| 5964 | |
| 5965 | def show(self): |
| 5966 | import loxi.pp |
| 5967 | return loxi.pp.pp(self) |
| 5968 | |
| 5969 | def pretty_print(self, q): |
| 5970 | q.text("port_stats_reply {") |
| 5971 | with q.group(): |
| 5972 | with q.indent(2): |
| 5973 | q.breakable() |
| 5974 | q.text("xid = "); |
| 5975 | if self.xid != None: |
| 5976 | q.text("%#x" % self.xid) |
| 5977 | else: |
| 5978 | q.text('None') |
| 5979 | q.text(","); q.breakable() |
| 5980 | q.text("flags = "); |
| 5981 | q.text("%#x" % self.flags) |
| 5982 | q.text(","); q.breakable() |
| 5983 | q.text("entries = "); |
| 5984 | q.pp(self.entries) |
| 5985 | q.breakable() |
| 5986 | q.text('}') |
| 5987 | |
| 5988 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5989 | version = 2 |
| 5990 | type = 18 |
| 5991 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5992 | |
| 5993 | def __init__(self, xid=None, flags=None, port_no=None): |
| 5994 | self.xid = xid |
| 5995 | if flags != None: |
| 5996 | self.flags = flags |
| 5997 | else: |
| 5998 | self.flags = 0 |
| 5999 | if port_no != None: |
| 6000 | self.port_no = port_no |
| 6001 | else: |
| 6002 | self.port_no = 0 |
| 6003 | |
| 6004 | def pack(self): |
| 6005 | packed = [] |
| 6006 | packed.append(struct.pack("!B", self.version)) |
| 6007 | packed.append(struct.pack("!B", self.type)) |
| 6008 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6009 | packed.append(struct.pack("!L", self.xid)) |
| 6010 | packed.append(struct.pack("!H", self.stats_type)) |
| 6011 | packed.append(struct.pack("!H", self.flags)) |
| 6012 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6013 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6014 | packed.append('\x00' * 4) |
| 6015 | length = sum([len(x) for x in packed]) |
| 6016 | packed[2] = struct.pack("!H", length) |
| 6017 | return ''.join(packed) |
| 6018 | |
| 6019 | @staticmethod |
| 6020 | def unpack(buf): |
| 6021 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6022 | obj = port_stats_request() |
| 6023 | if type(buf) == loxi.generic_util.OFReader: |
| 6024 | reader = buf |
| 6025 | else: |
| 6026 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6027 | _version = reader.read("!B")[0] |
| 6028 | assert(_version == 2) |
| 6029 | _type = reader.read("!B")[0] |
| 6030 | assert(_type == 18) |
| 6031 | _length = reader.read("!H")[0] |
| 6032 | obj.xid = reader.read("!L")[0] |
| 6033 | _stats_type = reader.read("!H")[0] |
| 6034 | assert(_stats_type == 4) |
| 6035 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6036 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6037 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6038 | reader.skip(4) |
| 6039 | return obj |
| 6040 | |
| 6041 | def __eq__(self, other): |
| 6042 | if type(self) != type(other): return False |
| 6043 | if self.version != other.version: return False |
| 6044 | if self.type != other.type: return False |
| 6045 | if self.xid != other.xid: return False |
| 6046 | if self.flags != other.flags: return False |
| 6047 | if self.port_no != other.port_no: return False |
| 6048 | return True |
| 6049 | |
| 6050 | def __ne__(self, other): |
| 6051 | return not self.__eq__(other) |
| 6052 | |
| 6053 | def __str__(self): |
| 6054 | return self.show() |
| 6055 | |
| 6056 | def show(self): |
| 6057 | import loxi.pp |
| 6058 | return loxi.pp.pp(self) |
| 6059 | |
| 6060 | def pretty_print(self, q): |
| 6061 | q.text("port_stats_request {") |
| 6062 | with q.group(): |
| 6063 | with q.indent(2): |
| 6064 | q.breakable() |
| 6065 | q.text("xid = "); |
| 6066 | if self.xid != None: |
| 6067 | q.text("%#x" % self.xid) |
| 6068 | else: |
| 6069 | q.text('None') |
| 6070 | q.text(","); q.breakable() |
| 6071 | q.text("flags = "); |
| 6072 | q.text("%#x" % self.flags) |
| 6073 | q.text(","); q.breakable() |
| 6074 | q.text("port_no = "); |
| 6075 | q.text(util.pretty_port(self.port_no)) |
| 6076 | q.breakable() |
| 6077 | q.text('}') |
| 6078 | |
| 6079 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6080 | version = 2 |
| 6081 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6082 | |
| 6083 | def __init__(self, xid=None, reason=None, desc=None): |
| 6084 | self.xid = xid |
| 6085 | if reason != None: |
| 6086 | self.reason = reason |
| 6087 | else: |
| 6088 | self.reason = 0 |
| 6089 | if desc != None: |
| 6090 | self.desc = desc |
| 6091 | else: |
| 6092 | self.desc = common.port_desc() |
| 6093 | |
| 6094 | def pack(self): |
| 6095 | packed = [] |
| 6096 | packed.append(struct.pack("!B", self.version)) |
| 6097 | packed.append(struct.pack("!B", self.type)) |
| 6098 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6099 | packed.append(struct.pack("!L", self.xid)) |
| 6100 | packed.append(struct.pack("!B", self.reason)) |
| 6101 | packed.append('\x00' * 7) |
| 6102 | packed.append(self.desc.pack()) |
| 6103 | length = sum([len(x) for x in packed]) |
| 6104 | packed[2] = struct.pack("!H", length) |
| 6105 | return ''.join(packed) |
| 6106 | |
| 6107 | @staticmethod |
| 6108 | def unpack(buf): |
| 6109 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6110 | obj = port_status() |
| 6111 | if type(buf) == loxi.generic_util.OFReader: |
| 6112 | reader = buf |
| 6113 | else: |
| 6114 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6115 | _version = reader.read("!B")[0] |
| 6116 | assert(_version == 2) |
| 6117 | _type = reader.read("!B")[0] |
| 6118 | assert(_type == 12) |
| 6119 | _length = reader.read("!H")[0] |
| 6120 | obj.xid = reader.read("!L")[0] |
| 6121 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6122 | reader.skip(7) |
| 6123 | obj.desc = common.port_desc.unpack(reader) |
| 6124 | return obj |
| 6125 | |
| 6126 | def __eq__(self, other): |
| 6127 | if type(self) != type(other): return False |
| 6128 | if self.version != other.version: return False |
| 6129 | if self.type != other.type: return False |
| 6130 | if self.xid != other.xid: return False |
| 6131 | if self.reason != other.reason: return False |
| 6132 | if self.desc != other.desc: return False |
| 6133 | return True |
| 6134 | |
| 6135 | def __ne__(self, other): |
| 6136 | return not self.__eq__(other) |
| 6137 | |
| 6138 | def __str__(self): |
| 6139 | return self.show() |
| 6140 | |
| 6141 | def show(self): |
| 6142 | import loxi.pp |
| 6143 | return loxi.pp.pp(self) |
| 6144 | |
| 6145 | def pretty_print(self, q): |
| 6146 | q.text("port_status {") |
| 6147 | with q.group(): |
| 6148 | with q.indent(2): |
| 6149 | q.breakable() |
| 6150 | q.text("xid = "); |
| 6151 | if self.xid != None: |
| 6152 | q.text("%#x" % self.xid) |
| 6153 | else: |
| 6154 | q.text('None') |
| 6155 | q.text(","); q.breakable() |
| 6156 | q.text("reason = "); |
| 6157 | q.text("%#x" % self.reason) |
| 6158 | q.text(","); q.breakable() |
| 6159 | q.text("desc = "); |
| 6160 | q.pp(self.desc) |
| 6161 | q.breakable() |
| 6162 | q.text('}') |
| 6163 | |
| 6164 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6165 | version = 2 |
| 6166 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6167 | |
| 6168 | def __init__(self, xid=None, port=None, queues=None): |
| 6169 | self.xid = xid |
| 6170 | if port != None: |
| 6171 | self.port = port |
| 6172 | else: |
| 6173 | self.port = 0 |
| 6174 | if queues != None: |
| 6175 | self.queues = queues |
| 6176 | else: |
| 6177 | self.queues = [] |
| 6178 | |
| 6179 | def pack(self): |
| 6180 | packed = [] |
| 6181 | packed.append(struct.pack("!B", self.version)) |
| 6182 | packed.append(struct.pack("!B", self.type)) |
| 6183 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6184 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6185 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6186 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6187 | packed.append(util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6188 | length = sum([len(x) for x in packed]) |
| 6189 | packed[2] = struct.pack("!H", length) |
| 6190 | return ''.join(packed) |
| 6191 | |
| 6192 | @staticmethod |
| 6193 | def unpack(buf): |
| 6194 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6195 | obj = queue_get_config_reply() |
| 6196 | if type(buf) == loxi.generic_util.OFReader: |
| 6197 | reader = buf |
| 6198 | else: |
| 6199 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6200 | _version = reader.read("!B")[0] |
| 6201 | assert(_version == 2) |
| 6202 | _type = reader.read("!B")[0] |
| 6203 | assert(_type == 23) |
| 6204 | _length = reader.read("!H")[0] |
| 6205 | obj.xid = reader.read("!L")[0] |
| 6206 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6207 | reader.skip(4) |
| 6208 | obj.queues = common.unpack_list_packet_queue(reader) |
| 6209 | return obj |
| 6210 | |
| 6211 | def __eq__(self, other): |
| 6212 | if type(self) != type(other): return False |
| 6213 | if self.version != other.version: return False |
| 6214 | if self.type != other.type: return False |
| 6215 | if self.xid != other.xid: return False |
| 6216 | if self.port != other.port: return False |
| 6217 | if self.queues != other.queues: return False |
| 6218 | return True |
| 6219 | |
| 6220 | def __ne__(self, other): |
| 6221 | return not self.__eq__(other) |
| 6222 | |
| 6223 | def __str__(self): |
| 6224 | return self.show() |
| 6225 | |
| 6226 | def show(self): |
| 6227 | import loxi.pp |
| 6228 | return loxi.pp.pp(self) |
| 6229 | |
| 6230 | def pretty_print(self, q): |
| 6231 | q.text("queue_get_config_reply {") |
| 6232 | with q.group(): |
| 6233 | with q.indent(2): |
| 6234 | q.breakable() |
| 6235 | q.text("xid = "); |
| 6236 | if self.xid != None: |
| 6237 | q.text("%#x" % self.xid) |
| 6238 | else: |
| 6239 | q.text('None') |
| 6240 | q.text(","); q.breakable() |
| 6241 | q.text("port = "); |
| 6242 | q.text(util.pretty_port(self.port)) |
| 6243 | q.text(","); q.breakable() |
| 6244 | q.text("queues = "); |
| 6245 | q.pp(self.queues) |
| 6246 | q.breakable() |
| 6247 | q.text('}') |
| 6248 | |
| 6249 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6250 | version = 2 |
| 6251 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6252 | |
| 6253 | def __init__(self, xid=None, port=None): |
| 6254 | self.xid = xid |
| 6255 | if port != None: |
| 6256 | self.port = port |
| 6257 | else: |
| 6258 | self.port = 0 |
| 6259 | |
| 6260 | def pack(self): |
| 6261 | packed = [] |
| 6262 | packed.append(struct.pack("!B", self.version)) |
| 6263 | packed.append(struct.pack("!B", self.type)) |
| 6264 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6265 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6266 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6267 | packed.append('\x00' * 4) |
| 6268 | length = sum([len(x) for x in packed]) |
| 6269 | packed[2] = struct.pack("!H", length) |
| 6270 | return ''.join(packed) |
| 6271 | |
| 6272 | @staticmethod |
| 6273 | def unpack(buf): |
| 6274 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6275 | obj = queue_get_config_request() |
| 6276 | if type(buf) == loxi.generic_util.OFReader: |
| 6277 | reader = buf |
| 6278 | else: |
| 6279 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6280 | _version = reader.read("!B")[0] |
| 6281 | assert(_version == 2) |
| 6282 | _type = reader.read("!B")[0] |
| 6283 | assert(_type == 22) |
| 6284 | _length = reader.read("!H")[0] |
| 6285 | obj.xid = reader.read("!L")[0] |
| 6286 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6287 | reader.skip(4) |
| 6288 | return obj |
| 6289 | |
| 6290 | def __eq__(self, other): |
| 6291 | if type(self) != type(other): return False |
| 6292 | if self.version != other.version: return False |
| 6293 | if self.type != other.type: return False |
| 6294 | if self.xid != other.xid: return False |
| 6295 | if self.port != other.port: return False |
| 6296 | return True |
| 6297 | |
| 6298 | def __ne__(self, other): |
| 6299 | return not self.__eq__(other) |
| 6300 | |
| 6301 | def __str__(self): |
| 6302 | return self.show() |
| 6303 | |
| 6304 | def show(self): |
| 6305 | import loxi.pp |
| 6306 | return loxi.pp.pp(self) |
| 6307 | |
| 6308 | def pretty_print(self, q): |
| 6309 | q.text("queue_get_config_request {") |
| 6310 | with q.group(): |
| 6311 | with q.indent(2): |
| 6312 | q.breakable() |
| 6313 | q.text("xid = "); |
| 6314 | if self.xid != None: |
| 6315 | q.text("%#x" % self.xid) |
| 6316 | else: |
| 6317 | q.text('None') |
| 6318 | q.text(","); q.breakable() |
| 6319 | q.text("port = "); |
| 6320 | q.text(util.pretty_port(self.port)) |
| 6321 | q.breakable() |
| 6322 | q.text('}') |
| 6323 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 6324 | class queue_op_failed_error_msg(Message): |
| 6325 | version = 2 |
| 6326 | type = 1 |
| 6327 | err_type = 9 |
| 6328 | |
| 6329 | def __init__(self, xid=None, code=None, data=None): |
| 6330 | self.xid = xid |
| 6331 | if code != None: |
| 6332 | self.code = code |
| 6333 | else: |
| 6334 | self.code = 0 |
| 6335 | if data != None: |
| 6336 | self.data = data |
| 6337 | else: |
| 6338 | self.data = '' |
| 6339 | |
| 6340 | def pack(self): |
| 6341 | packed = [] |
| 6342 | packed.append(struct.pack("!B", self.version)) |
| 6343 | packed.append(struct.pack("!B", self.type)) |
| 6344 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6345 | packed.append(struct.pack("!L", self.xid)) |
| 6346 | packed.append(struct.pack("!H", self.err_type)) |
| 6347 | packed.append(struct.pack("!H", self.code)) |
| 6348 | packed.append(self.data) |
| 6349 | length = sum([len(x) for x in packed]) |
| 6350 | packed[2] = struct.pack("!H", length) |
| 6351 | return ''.join(packed) |
| 6352 | |
| 6353 | @staticmethod |
| 6354 | def unpack(buf): |
| 6355 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6356 | obj = queue_op_failed_error_msg() |
| 6357 | if type(buf) == loxi.generic_util.OFReader: |
| 6358 | reader = buf |
| 6359 | else: |
| 6360 | reader = loxi.generic_util.OFReader(buf) |
| 6361 | _version = reader.read("!B")[0] |
| 6362 | assert(_version == 2) |
| 6363 | _type = reader.read("!B")[0] |
| 6364 | assert(_type == 1) |
| 6365 | _length = reader.read("!H")[0] |
| 6366 | obj.xid = reader.read("!L")[0] |
| 6367 | _err_type = reader.read("!H")[0] |
| 6368 | assert(_err_type == 9) |
| 6369 | obj.code = reader.read("!H")[0] |
| 6370 | obj.data = str(reader.read_all()) |
| 6371 | return obj |
| 6372 | |
| 6373 | def __eq__(self, other): |
| 6374 | if type(self) != type(other): return False |
| 6375 | if self.version != other.version: return False |
| 6376 | if self.type != other.type: return False |
| 6377 | if self.xid != other.xid: return False |
| 6378 | if self.code != other.code: return False |
| 6379 | if self.data != other.data: return False |
| 6380 | return True |
| 6381 | |
| 6382 | def __ne__(self, other): |
| 6383 | return not self.__eq__(other) |
| 6384 | |
| 6385 | def __str__(self): |
| 6386 | return self.show() |
| 6387 | |
| 6388 | def show(self): |
| 6389 | import loxi.pp |
| 6390 | return loxi.pp.pp(self) |
| 6391 | |
| 6392 | def pretty_print(self, q): |
| 6393 | q.text("queue_op_failed_error_msg {") |
| 6394 | with q.group(): |
| 6395 | with q.indent(2): |
| 6396 | q.breakable() |
| 6397 | q.text("xid = "); |
| 6398 | if self.xid != None: |
| 6399 | q.text("%#x" % self.xid) |
| 6400 | else: |
| 6401 | q.text('None') |
| 6402 | q.text(","); q.breakable() |
| 6403 | q.text("code = "); |
| 6404 | q.text("%#x" % self.code) |
| 6405 | q.text(","); q.breakable() |
| 6406 | q.text("data = "); |
| 6407 | q.pp(self.data) |
| 6408 | q.breakable() |
| 6409 | q.text('}') |
| 6410 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6411 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6412 | version = 2 |
| 6413 | type = 19 |
| 6414 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6415 | |
| 6416 | def __init__(self, xid=None, flags=None, entries=None): |
| 6417 | self.xid = xid |
| 6418 | if flags != None: |
| 6419 | self.flags = flags |
| 6420 | else: |
| 6421 | self.flags = 0 |
| 6422 | if entries != None: |
| 6423 | self.entries = entries |
| 6424 | else: |
| 6425 | self.entries = [] |
| 6426 | |
| 6427 | def pack(self): |
| 6428 | packed = [] |
| 6429 | packed.append(struct.pack("!B", self.version)) |
| 6430 | packed.append(struct.pack("!B", self.type)) |
| 6431 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6432 | packed.append(struct.pack("!L", self.xid)) |
| 6433 | packed.append(struct.pack("!H", self.stats_type)) |
| 6434 | packed.append(struct.pack("!H", self.flags)) |
| 6435 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6436 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6437 | length = sum([len(x) for x in packed]) |
| 6438 | packed[2] = struct.pack("!H", length) |
| 6439 | return ''.join(packed) |
| 6440 | |
| 6441 | @staticmethod |
| 6442 | def unpack(buf): |
| 6443 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6444 | obj = queue_stats_reply() |
| 6445 | if type(buf) == loxi.generic_util.OFReader: |
| 6446 | reader = buf |
| 6447 | else: |
| 6448 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6449 | _version = reader.read("!B")[0] |
| 6450 | assert(_version == 2) |
| 6451 | _type = reader.read("!B")[0] |
| 6452 | assert(_type == 19) |
| 6453 | _length = reader.read("!H")[0] |
| 6454 | obj.xid = reader.read("!L")[0] |
| 6455 | _stats_type = reader.read("!H")[0] |
| 6456 | assert(_stats_type == 5) |
| 6457 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6458 | reader.skip(4) |
| 6459 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 6460 | return obj |
| 6461 | |
| 6462 | def __eq__(self, other): |
| 6463 | if type(self) != type(other): return False |
| 6464 | if self.version != other.version: return False |
| 6465 | if self.type != other.type: return False |
| 6466 | if self.xid != other.xid: return False |
| 6467 | if self.flags != other.flags: return False |
| 6468 | if self.entries != other.entries: return False |
| 6469 | return True |
| 6470 | |
| 6471 | def __ne__(self, other): |
| 6472 | return not self.__eq__(other) |
| 6473 | |
| 6474 | def __str__(self): |
| 6475 | return self.show() |
| 6476 | |
| 6477 | def show(self): |
| 6478 | import loxi.pp |
| 6479 | return loxi.pp.pp(self) |
| 6480 | |
| 6481 | def pretty_print(self, q): |
| 6482 | q.text("queue_stats_reply {") |
| 6483 | with q.group(): |
| 6484 | with q.indent(2): |
| 6485 | q.breakable() |
| 6486 | q.text("xid = "); |
| 6487 | if self.xid != None: |
| 6488 | q.text("%#x" % self.xid) |
| 6489 | else: |
| 6490 | q.text('None') |
| 6491 | q.text(","); q.breakable() |
| 6492 | q.text("flags = "); |
| 6493 | q.text("%#x" % self.flags) |
| 6494 | q.text(","); q.breakable() |
| 6495 | q.text("entries = "); |
| 6496 | q.pp(self.entries) |
| 6497 | q.breakable() |
| 6498 | q.text('}') |
| 6499 | |
| 6500 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6501 | version = 2 |
| 6502 | type = 18 |
| 6503 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6504 | |
| 6505 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
| 6506 | self.xid = xid |
| 6507 | if flags != None: |
| 6508 | self.flags = flags |
| 6509 | else: |
| 6510 | self.flags = 0 |
| 6511 | if port_no != None: |
| 6512 | self.port_no = port_no |
| 6513 | else: |
| 6514 | self.port_no = 0 |
| 6515 | if queue_id != None: |
| 6516 | self.queue_id = queue_id |
| 6517 | else: |
| 6518 | self.queue_id = 0 |
| 6519 | |
| 6520 | def pack(self): |
| 6521 | packed = [] |
| 6522 | packed.append(struct.pack("!B", self.version)) |
| 6523 | packed.append(struct.pack("!B", self.type)) |
| 6524 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6525 | packed.append(struct.pack("!L", self.xid)) |
| 6526 | packed.append(struct.pack("!H", self.stats_type)) |
| 6527 | packed.append(struct.pack("!H", self.flags)) |
| 6528 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6529 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6530 | packed.append(struct.pack("!L", self.queue_id)) |
| 6531 | length = sum([len(x) for x in packed]) |
| 6532 | packed[2] = struct.pack("!H", length) |
| 6533 | return ''.join(packed) |
| 6534 | |
| 6535 | @staticmethod |
| 6536 | def unpack(buf): |
| 6537 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6538 | obj = queue_stats_request() |
| 6539 | if type(buf) == loxi.generic_util.OFReader: |
| 6540 | reader = buf |
| 6541 | else: |
| 6542 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6543 | _version = reader.read("!B")[0] |
| 6544 | assert(_version == 2) |
| 6545 | _type = reader.read("!B")[0] |
| 6546 | assert(_type == 18) |
| 6547 | _length = reader.read("!H")[0] |
| 6548 | obj.xid = reader.read("!L")[0] |
| 6549 | _stats_type = reader.read("!H")[0] |
| 6550 | assert(_stats_type == 5) |
| 6551 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6552 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6553 | obj.port_no = util.unpack_port_no(reader) |
| 6554 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6555 | return obj |
| 6556 | |
| 6557 | def __eq__(self, other): |
| 6558 | if type(self) != type(other): return False |
| 6559 | if self.version != other.version: return False |
| 6560 | if self.type != other.type: return False |
| 6561 | if self.xid != other.xid: return False |
| 6562 | if self.flags != other.flags: return False |
| 6563 | if self.port_no != other.port_no: return False |
| 6564 | if self.queue_id != other.queue_id: return False |
| 6565 | return True |
| 6566 | |
| 6567 | def __ne__(self, other): |
| 6568 | return not self.__eq__(other) |
| 6569 | |
| 6570 | def __str__(self): |
| 6571 | return self.show() |
| 6572 | |
| 6573 | def show(self): |
| 6574 | import loxi.pp |
| 6575 | return loxi.pp.pp(self) |
| 6576 | |
| 6577 | def pretty_print(self, q): |
| 6578 | q.text("queue_stats_request {") |
| 6579 | with q.group(): |
| 6580 | with q.indent(2): |
| 6581 | q.breakable() |
| 6582 | q.text("xid = "); |
| 6583 | if self.xid != None: |
| 6584 | q.text("%#x" % self.xid) |
| 6585 | else: |
| 6586 | q.text('None') |
| 6587 | q.text(","); q.breakable() |
| 6588 | q.text("flags = "); |
| 6589 | q.text("%#x" % self.flags) |
| 6590 | q.text(","); q.breakable() |
| 6591 | q.text("port_no = "); |
| 6592 | q.text(util.pretty_port(self.port_no)) |
| 6593 | q.text(","); q.breakable() |
| 6594 | q.text("queue_id = "); |
| 6595 | q.text("%#x" % self.queue_id) |
| 6596 | q.breakable() |
| 6597 | q.text('}') |
| 6598 | |
| 6599 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6600 | version = 2 |
| 6601 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6602 | |
| 6603 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 6604 | self.xid = xid |
| 6605 | if flags != None: |
| 6606 | self.flags = flags |
| 6607 | else: |
| 6608 | self.flags = 0 |
| 6609 | if miss_send_len != None: |
| 6610 | self.miss_send_len = miss_send_len |
| 6611 | else: |
| 6612 | self.miss_send_len = 0 |
| 6613 | |
| 6614 | def pack(self): |
| 6615 | packed = [] |
| 6616 | packed.append(struct.pack("!B", self.version)) |
| 6617 | packed.append(struct.pack("!B", self.type)) |
| 6618 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6619 | packed.append(struct.pack("!L", self.xid)) |
| 6620 | packed.append(struct.pack("!H", self.flags)) |
| 6621 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 6622 | length = sum([len(x) for x in packed]) |
| 6623 | packed[2] = struct.pack("!H", length) |
| 6624 | return ''.join(packed) |
| 6625 | |
| 6626 | @staticmethod |
| 6627 | def unpack(buf): |
| 6628 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6629 | obj = set_config() |
| 6630 | if type(buf) == loxi.generic_util.OFReader: |
| 6631 | reader = buf |
| 6632 | else: |
| 6633 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6634 | _version = reader.read("!B")[0] |
| 6635 | assert(_version == 2) |
| 6636 | _type = reader.read("!B")[0] |
| 6637 | assert(_type == 9) |
| 6638 | _length = reader.read("!H")[0] |
| 6639 | obj.xid = reader.read("!L")[0] |
| 6640 | obj.flags = reader.read("!H")[0] |
| 6641 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6642 | return obj |
| 6643 | |
| 6644 | def __eq__(self, other): |
| 6645 | if type(self) != type(other): return False |
| 6646 | if self.version != other.version: return False |
| 6647 | if self.type != other.type: return False |
| 6648 | if self.xid != other.xid: return False |
| 6649 | if self.flags != other.flags: return False |
| 6650 | if self.miss_send_len != other.miss_send_len: return False |
| 6651 | return True |
| 6652 | |
| 6653 | def __ne__(self, other): |
| 6654 | return not self.__eq__(other) |
| 6655 | |
| 6656 | def __str__(self): |
| 6657 | return self.show() |
| 6658 | |
| 6659 | def show(self): |
| 6660 | import loxi.pp |
| 6661 | return loxi.pp.pp(self) |
| 6662 | |
| 6663 | def pretty_print(self, q): |
| 6664 | q.text("set_config {") |
| 6665 | with q.group(): |
| 6666 | with q.indent(2): |
| 6667 | q.breakable() |
| 6668 | q.text("xid = "); |
| 6669 | if self.xid != None: |
| 6670 | q.text("%#x" % self.xid) |
| 6671 | else: |
| 6672 | q.text('None') |
| 6673 | q.text(","); q.breakable() |
| 6674 | q.text("flags = "); |
| 6675 | q.text("%#x" % self.flags) |
| 6676 | q.text(","); q.breakable() |
| 6677 | q.text("miss_send_len = "); |
| 6678 | q.text("%#x" % self.miss_send_len) |
| 6679 | q.breakable() |
| 6680 | q.text('}') |
| 6681 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 6682 | class switch_config_failed_error_msg(Message): |
| 6683 | version = 2 |
| 6684 | type = 1 |
| 6685 | err_type = 10 |
| 6686 | |
| 6687 | def __init__(self, xid=None, code=None, data=None): |
| 6688 | self.xid = xid |
| 6689 | if code != None: |
| 6690 | self.code = code |
| 6691 | else: |
| 6692 | self.code = 0 |
| 6693 | if data != None: |
| 6694 | self.data = data |
| 6695 | else: |
| 6696 | self.data = '' |
| 6697 | |
| 6698 | def pack(self): |
| 6699 | packed = [] |
| 6700 | packed.append(struct.pack("!B", self.version)) |
| 6701 | packed.append(struct.pack("!B", self.type)) |
| 6702 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6703 | packed.append(struct.pack("!L", self.xid)) |
| 6704 | packed.append(struct.pack("!H", self.err_type)) |
| 6705 | packed.append(struct.pack("!H", self.code)) |
| 6706 | packed.append(self.data) |
| 6707 | length = sum([len(x) for x in packed]) |
| 6708 | packed[2] = struct.pack("!H", length) |
| 6709 | return ''.join(packed) |
| 6710 | |
| 6711 | @staticmethod |
| 6712 | def unpack(buf): |
| 6713 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6714 | obj = switch_config_failed_error_msg() |
| 6715 | if type(buf) == loxi.generic_util.OFReader: |
| 6716 | reader = buf |
| 6717 | else: |
| 6718 | reader = loxi.generic_util.OFReader(buf) |
| 6719 | _version = reader.read("!B")[0] |
| 6720 | assert(_version == 2) |
| 6721 | _type = reader.read("!B")[0] |
| 6722 | assert(_type == 1) |
| 6723 | _length = reader.read("!H")[0] |
| 6724 | obj.xid = reader.read("!L")[0] |
| 6725 | _err_type = reader.read("!H")[0] |
| 6726 | assert(_err_type == 10) |
| 6727 | obj.code = reader.read("!H")[0] |
| 6728 | obj.data = str(reader.read_all()) |
| 6729 | return obj |
| 6730 | |
| 6731 | def __eq__(self, other): |
| 6732 | if type(self) != type(other): return False |
| 6733 | if self.version != other.version: return False |
| 6734 | if self.type != other.type: return False |
| 6735 | if self.xid != other.xid: return False |
| 6736 | if self.code != other.code: return False |
| 6737 | if self.data != other.data: return False |
| 6738 | return True |
| 6739 | |
| 6740 | def __ne__(self, other): |
| 6741 | return not self.__eq__(other) |
| 6742 | |
| 6743 | def __str__(self): |
| 6744 | return self.show() |
| 6745 | |
| 6746 | def show(self): |
| 6747 | import loxi.pp |
| 6748 | return loxi.pp.pp(self) |
| 6749 | |
| 6750 | def pretty_print(self, q): |
| 6751 | q.text("switch_config_failed_error_msg {") |
| 6752 | with q.group(): |
| 6753 | with q.indent(2): |
| 6754 | q.breakable() |
| 6755 | q.text("xid = "); |
| 6756 | if self.xid != None: |
| 6757 | q.text("%#x" % self.xid) |
| 6758 | else: |
| 6759 | q.text('None') |
| 6760 | q.text(","); q.breakable() |
| 6761 | q.text("code = "); |
| 6762 | q.text("%#x" % self.code) |
| 6763 | q.text(","); q.breakable() |
| 6764 | q.text("data = "); |
| 6765 | q.pp(self.data) |
| 6766 | q.breakable() |
| 6767 | q.text('}') |
| 6768 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6769 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6770 | version = 2 |
| 6771 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6772 | |
| 6773 | def __init__(self, xid=None, table_id=None, config=None): |
| 6774 | self.xid = xid |
| 6775 | if table_id != None: |
| 6776 | self.table_id = table_id |
| 6777 | else: |
| 6778 | self.table_id = 0 |
| 6779 | if config != None: |
| 6780 | self.config = config |
| 6781 | else: |
| 6782 | self.config = 0 |
| 6783 | |
| 6784 | def pack(self): |
| 6785 | packed = [] |
| 6786 | packed.append(struct.pack("!B", self.version)) |
| 6787 | packed.append(struct.pack("!B", self.type)) |
| 6788 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6789 | packed.append(struct.pack("!L", self.xid)) |
| 6790 | packed.append(struct.pack("!B", self.table_id)) |
| 6791 | packed.append('\x00' * 3) |
| 6792 | packed.append(struct.pack("!L", self.config)) |
| 6793 | length = sum([len(x) for x in packed]) |
| 6794 | packed[2] = struct.pack("!H", length) |
| 6795 | return ''.join(packed) |
| 6796 | |
| 6797 | @staticmethod |
| 6798 | def unpack(buf): |
| 6799 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6800 | obj = table_mod() |
| 6801 | if type(buf) == loxi.generic_util.OFReader: |
| 6802 | reader = buf |
| 6803 | else: |
| 6804 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6805 | _version = reader.read("!B")[0] |
| 6806 | assert(_version == 2) |
| 6807 | _type = reader.read("!B")[0] |
| 6808 | assert(_type == 17) |
| 6809 | _length = reader.read("!H")[0] |
| 6810 | obj.xid = reader.read("!L")[0] |
| 6811 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6812 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6813 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6814 | return obj |
| 6815 | |
| 6816 | def __eq__(self, other): |
| 6817 | if type(self) != type(other): return False |
| 6818 | if self.version != other.version: return False |
| 6819 | if self.type != other.type: return False |
| 6820 | if self.xid != other.xid: return False |
| 6821 | if self.table_id != other.table_id: return False |
| 6822 | if self.config != other.config: return False |
| 6823 | return True |
| 6824 | |
| 6825 | def __ne__(self, other): |
| 6826 | return not self.__eq__(other) |
| 6827 | |
| 6828 | def __str__(self): |
| 6829 | return self.show() |
| 6830 | |
| 6831 | def show(self): |
| 6832 | import loxi.pp |
| 6833 | return loxi.pp.pp(self) |
| 6834 | |
| 6835 | def pretty_print(self, q): |
| 6836 | q.text("table_mod {") |
| 6837 | with q.group(): |
| 6838 | with q.indent(2): |
| 6839 | q.breakable() |
| 6840 | q.text("xid = "); |
| 6841 | if self.xid != None: |
| 6842 | q.text("%#x" % self.xid) |
| 6843 | else: |
| 6844 | q.text('None') |
| 6845 | q.text(","); q.breakable() |
| 6846 | q.text("table_id = "); |
| 6847 | q.text("%#x" % self.table_id) |
| 6848 | q.text(","); q.breakable() |
| 6849 | q.text("config = "); |
| 6850 | q.text("%#x" % self.config) |
| 6851 | q.breakable() |
| 6852 | q.text('}') |
| 6853 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 6854 | class table_mod_failed_error_msg(Message): |
| 6855 | version = 2 |
| 6856 | type = 1 |
| 6857 | err_type = 8 |
| 6858 | |
| 6859 | def __init__(self, xid=None, code=None, data=None): |
| 6860 | self.xid = xid |
| 6861 | if code != None: |
| 6862 | self.code = code |
| 6863 | else: |
| 6864 | self.code = 0 |
| 6865 | if data != None: |
| 6866 | self.data = data |
| 6867 | else: |
| 6868 | self.data = '' |
| 6869 | |
| 6870 | def pack(self): |
| 6871 | packed = [] |
| 6872 | packed.append(struct.pack("!B", self.version)) |
| 6873 | packed.append(struct.pack("!B", self.type)) |
| 6874 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6875 | packed.append(struct.pack("!L", self.xid)) |
| 6876 | packed.append(struct.pack("!H", self.err_type)) |
| 6877 | packed.append(struct.pack("!H", self.code)) |
| 6878 | packed.append(self.data) |
| 6879 | length = sum([len(x) for x in packed]) |
| 6880 | packed[2] = struct.pack("!H", length) |
| 6881 | return ''.join(packed) |
| 6882 | |
| 6883 | @staticmethod |
| 6884 | def unpack(buf): |
| 6885 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6886 | obj = table_mod_failed_error_msg() |
| 6887 | if type(buf) == loxi.generic_util.OFReader: |
| 6888 | reader = buf |
| 6889 | else: |
| 6890 | reader = loxi.generic_util.OFReader(buf) |
| 6891 | _version = reader.read("!B")[0] |
| 6892 | assert(_version == 2) |
| 6893 | _type = reader.read("!B")[0] |
| 6894 | assert(_type == 1) |
| 6895 | _length = reader.read("!H")[0] |
| 6896 | obj.xid = reader.read("!L")[0] |
| 6897 | _err_type = reader.read("!H")[0] |
| 6898 | assert(_err_type == 8) |
| 6899 | obj.code = reader.read("!H")[0] |
| 6900 | obj.data = str(reader.read_all()) |
| 6901 | return obj |
| 6902 | |
| 6903 | def __eq__(self, other): |
| 6904 | if type(self) != type(other): return False |
| 6905 | if self.version != other.version: return False |
| 6906 | if self.type != other.type: return False |
| 6907 | if self.xid != other.xid: return False |
| 6908 | if self.code != other.code: return False |
| 6909 | if self.data != other.data: return False |
| 6910 | return True |
| 6911 | |
| 6912 | def __ne__(self, other): |
| 6913 | return not self.__eq__(other) |
| 6914 | |
| 6915 | def __str__(self): |
| 6916 | return self.show() |
| 6917 | |
| 6918 | def show(self): |
| 6919 | import loxi.pp |
| 6920 | return loxi.pp.pp(self) |
| 6921 | |
| 6922 | def pretty_print(self, q): |
| 6923 | q.text("table_mod_failed_error_msg {") |
| 6924 | with q.group(): |
| 6925 | with q.indent(2): |
| 6926 | q.breakable() |
| 6927 | q.text("xid = "); |
| 6928 | if self.xid != None: |
| 6929 | q.text("%#x" % self.xid) |
| 6930 | else: |
| 6931 | q.text('None') |
| 6932 | q.text(","); q.breakable() |
| 6933 | q.text("code = "); |
| 6934 | q.text("%#x" % self.code) |
| 6935 | q.text(","); q.breakable() |
| 6936 | q.text("data = "); |
| 6937 | q.pp(self.data) |
| 6938 | q.breakable() |
| 6939 | q.text('}') |
| 6940 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6941 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6942 | version = 2 |
| 6943 | type = 19 |
| 6944 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6945 | |
| 6946 | def __init__(self, xid=None, flags=None, entries=None): |
| 6947 | self.xid = xid |
| 6948 | if flags != None: |
| 6949 | self.flags = flags |
| 6950 | else: |
| 6951 | self.flags = 0 |
| 6952 | if entries != None: |
| 6953 | self.entries = entries |
| 6954 | else: |
| 6955 | self.entries = [] |
| 6956 | |
| 6957 | def pack(self): |
| 6958 | packed = [] |
| 6959 | packed.append(struct.pack("!B", self.version)) |
| 6960 | packed.append(struct.pack("!B", self.type)) |
| 6961 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6962 | packed.append(struct.pack("!L", self.xid)) |
| 6963 | packed.append(struct.pack("!H", self.stats_type)) |
| 6964 | packed.append(struct.pack("!H", self.flags)) |
| 6965 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6966 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6967 | length = sum([len(x) for x in packed]) |
| 6968 | packed[2] = struct.pack("!H", length) |
| 6969 | return ''.join(packed) |
| 6970 | |
| 6971 | @staticmethod |
| 6972 | def unpack(buf): |
| 6973 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6974 | obj = table_stats_reply() |
| 6975 | if type(buf) == loxi.generic_util.OFReader: |
| 6976 | reader = buf |
| 6977 | else: |
| 6978 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6979 | _version = reader.read("!B")[0] |
| 6980 | assert(_version == 2) |
| 6981 | _type = reader.read("!B")[0] |
| 6982 | assert(_type == 19) |
| 6983 | _length = reader.read("!H")[0] |
| 6984 | obj.xid = reader.read("!L")[0] |
| 6985 | _stats_type = reader.read("!H")[0] |
| 6986 | assert(_stats_type == 3) |
| 6987 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6988 | reader.skip(4) |
| 6989 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 6990 | return obj |
| 6991 | |
| 6992 | def __eq__(self, other): |
| 6993 | if type(self) != type(other): return False |
| 6994 | if self.version != other.version: return False |
| 6995 | if self.type != other.type: return False |
| 6996 | if self.xid != other.xid: return False |
| 6997 | if self.flags != other.flags: return False |
| 6998 | if self.entries != other.entries: return False |
| 6999 | return True |
| 7000 | |
| 7001 | def __ne__(self, other): |
| 7002 | return not self.__eq__(other) |
| 7003 | |
| 7004 | def __str__(self): |
| 7005 | return self.show() |
| 7006 | |
| 7007 | def show(self): |
| 7008 | import loxi.pp |
| 7009 | return loxi.pp.pp(self) |
| 7010 | |
| 7011 | def pretty_print(self, q): |
| 7012 | q.text("table_stats_reply {") |
| 7013 | with q.group(): |
| 7014 | with q.indent(2): |
| 7015 | q.breakable() |
| 7016 | q.text("xid = "); |
| 7017 | if self.xid != None: |
| 7018 | q.text("%#x" % self.xid) |
| 7019 | else: |
| 7020 | q.text('None') |
| 7021 | q.text(","); q.breakable() |
| 7022 | q.text("flags = "); |
| 7023 | q.text("%#x" % self.flags) |
| 7024 | q.text(","); q.breakable() |
| 7025 | q.text("entries = "); |
| 7026 | q.pp(self.entries) |
| 7027 | q.breakable() |
| 7028 | q.text('}') |
| 7029 | |
| 7030 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7031 | version = 2 |
| 7032 | type = 18 |
| 7033 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7034 | |
| 7035 | def __init__(self, xid=None, flags=None): |
| 7036 | self.xid = xid |
| 7037 | if flags != None: |
| 7038 | self.flags = flags |
| 7039 | else: |
| 7040 | self.flags = 0 |
| 7041 | |
| 7042 | def pack(self): |
| 7043 | packed = [] |
| 7044 | packed.append(struct.pack("!B", self.version)) |
| 7045 | packed.append(struct.pack("!B", self.type)) |
| 7046 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7047 | packed.append(struct.pack("!L", self.xid)) |
| 7048 | packed.append(struct.pack("!H", self.stats_type)) |
| 7049 | packed.append(struct.pack("!H", self.flags)) |
| 7050 | packed.append('\x00' * 4) |
| 7051 | length = sum([len(x) for x in packed]) |
| 7052 | packed[2] = struct.pack("!H", length) |
| 7053 | return ''.join(packed) |
| 7054 | |
| 7055 | @staticmethod |
| 7056 | def unpack(buf): |
| 7057 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7058 | obj = table_stats_request() |
| 7059 | if type(buf) == loxi.generic_util.OFReader: |
| 7060 | reader = buf |
| 7061 | else: |
| 7062 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7063 | _version = reader.read("!B")[0] |
| 7064 | assert(_version == 2) |
| 7065 | _type = reader.read("!B")[0] |
| 7066 | assert(_type == 18) |
| 7067 | _length = reader.read("!H")[0] |
| 7068 | obj.xid = reader.read("!L")[0] |
| 7069 | _stats_type = reader.read("!H")[0] |
| 7070 | assert(_stats_type == 3) |
| 7071 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7072 | reader.skip(4) |
| 7073 | return obj |
| 7074 | |
| 7075 | def __eq__(self, other): |
| 7076 | if type(self) != type(other): return False |
| 7077 | if self.version != other.version: return False |
| 7078 | if self.type != other.type: return False |
| 7079 | if self.xid != other.xid: return False |
| 7080 | if self.flags != other.flags: return False |
| 7081 | return True |
| 7082 | |
| 7083 | def __ne__(self, other): |
| 7084 | return not self.__eq__(other) |
| 7085 | |
| 7086 | def __str__(self): |
| 7087 | return self.show() |
| 7088 | |
| 7089 | def show(self): |
| 7090 | import loxi.pp |
| 7091 | return loxi.pp.pp(self) |
| 7092 | |
| 7093 | def pretty_print(self, q): |
| 7094 | q.text("table_stats_request {") |
| 7095 | with q.group(): |
| 7096 | with q.indent(2): |
| 7097 | q.breakable() |
| 7098 | q.text("xid = "); |
| 7099 | if self.xid != None: |
| 7100 | q.text("%#x" % self.xid) |
| 7101 | else: |
| 7102 | q.text('None') |
| 7103 | q.text(","); q.breakable() |
| 7104 | q.text("flags = "); |
| 7105 | q.text("%#x" % self.flags) |
| 7106 | q.breakable() |
| 7107 | q.text('}') |
| 7108 | |
| 7109 | |
| 7110 | def parse_header(buf): |
| 7111 | if len(buf) < 8: |
| 7112 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 7113 | return struct.unpack_from("!BBHL", buf) |
| 7114 | |
| 7115 | def parse_message(buf): |
| 7116 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 7117 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 7118 | raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7119 | if len(buf) != msg_len: |
| 7120 | raise loxi.ProtocolError("incorrect message size") |
| 7121 | if msg_type in parsers: |
| 7122 | return parsers[msg_type](buf) |
| 7123 | else: |
| 7124 | raise loxi.ProtocolError("unexpected message type") |
| 7125 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 7126 | def parse_error(buf): |
| 7127 | if len(buf) < 8 + 2: |
| 7128 | raise loxi.ProtocolError("message too short") |
| 7129 | err_type, = struct.unpack_from("!H", buf, 8) |
| 7130 | if err_type in error_msg_parsers: |
| 7131 | return error_msg_parsers[err_type](buf) |
| 7132 | else: |
| 7133 | raise loxi.ProtocolError("unexpected error type %u" % err_type) |
| 7134 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7135 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 7136 | if len(buf) < 25 + 1: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7137 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 7138 | # Technically uint16_t for OF 1.0 |
| 7139 | cmd, = struct.unpack_from("!B", buf, 25) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7140 | if cmd in flow_mod_parsers: |
| 7141 | return flow_mod_parsers[cmd](buf) |
| 7142 | else: |
| 7143 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 7144 | |
| 7145 | def parse_stats_reply(buf): |
| 7146 | if len(buf) < 8 + 2: |
| 7147 | raise loxi.ProtocolError("message too short") |
| 7148 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 7149 | if stats_type in stats_reply_parsers: |
| 7150 | return stats_reply_parsers[stats_type](buf) |
| 7151 | else: |
| 7152 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 7153 | |
| 7154 | def parse_stats_request(buf): |
| 7155 | if len(buf) < 8 + 2: |
| 7156 | raise loxi.ProtocolError("message too short") |
| 7157 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 7158 | if stats_type in stats_request_parsers: |
| 7159 | return stats_request_parsers[stats_type](buf) |
| 7160 | else: |
| 7161 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 7162 | |
| 7163 | def parse_experimenter(buf): |
| 7164 | if len(buf) < 16: |
| 7165 | raise loxi.ProtocolError("experimenter message too short") |
| 7166 | |
| 7167 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 7168 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 7169 | subtype, = struct.unpack_from("!L", buf, 12) |
| 7170 | elif experimenter == 0x00002320: # Nicira |
| 7171 | subtype, = struct.unpack_from("!L", buf, 12) |
| 7172 | else: |
| 7173 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 7174 | |
| 7175 | if subtype in experimenter_parsers[experimenter]: |
| 7176 | return experimenter_parsers[experimenter][subtype](buf) |
| 7177 | else: |
| 7178 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 7179 | |
| 7180 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7181 | const.OFPT_HELLO : hello.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 7182 | const.OFPT_ERROR : parse_error, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7183 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 7184 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
| 7185 | const.OFPT_EXPERIMENTER : parse_experimenter, |
| 7186 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 7187 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 7188 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 7189 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7190 | const.OFPT_SET_CONFIG : set_config.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7191 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 7192 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 7193 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 7194 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 7195 | const.OFPT_FLOW_MOD : parse_flow_mod, |
| 7196 | const.OFPT_GROUP_MOD : group_mod.unpack, |
| 7197 | const.OFPT_PORT_MOD : port_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7198 | const.OFPT_TABLE_MOD : table_mod.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7199 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 7200 | const.OFPT_STATS_REPLY : parse_stats_reply, |
| 7201 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 7202 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 7203 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 7204 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7205 | } |
| 7206 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 7207 | error_msg_parsers = { |
| 7208 | const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack, |
| 7209 | const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack, |
| 7210 | const.OFPET_BAD_ACTION : bad_action_error_msg.unpack, |
| 7211 | const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack, |
| 7212 | const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack, |
| 7213 | const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack, |
| 7214 | const.OFPET_BAD_INSTRUCTION : bad_instruction_error_msg.unpack, |
| 7215 | const.OFPET_BAD_MATCH : bad_match_error_msg.unpack, |
| 7216 | const.OFPET_GROUP_MOD_FAILED : group_mod_failed_error_msg.unpack, |
| 7217 | const.OFPET_TABLE_MOD_FAILED : table_mod_failed_error_msg.unpack, |
| 7218 | const.OFPET_SWITCH_CONFIG_FAILED : switch_config_failed_error_msg.unpack, |
| 7219 | } |
| 7220 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7221 | flow_mod_parsers = { |
| 7222 | const.OFPFC_ADD : flow_add.unpack, |
| 7223 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 7224 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 7225 | const.OFPFC_DELETE : flow_delete.unpack, |
| 7226 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 7227 | } |
| 7228 | |
| 7229 | stats_reply_parsers = { |
| 7230 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 7231 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 7232 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 7233 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 7234 | const.OFPST_PORT : port_stats_reply.unpack, |
| 7235 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 7236 | const.OFPST_GROUP : group_stats_reply.unpack, |
| 7237 | const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7238 | } |
| 7239 | |
| 7240 | stats_request_parsers = { |
| 7241 | const.OFPST_DESC : desc_stats_request.unpack, |
| 7242 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 7243 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 7244 | const.OFPST_TABLE : table_stats_request.unpack, |
| 7245 | const.OFPST_PORT : port_stats_request.unpack, |
| 7246 | const.OFPST_QUEUE : queue_stats_request.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 7247 | const.OFPST_GROUP : group_stats_request.unpack, |
| 7248 | const.OFPST_GROUP_DESC : group_desc_stats_request.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7249 | } |
| 7250 | |
| 7251 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7252 | 6035143 : { |
| 7253 | 22: bsn_bw_clear_data_reply.unpack, |
| 7254 | 21: bsn_bw_clear_data_request.unpack, |
| 7255 | 20: bsn_bw_enable_get_reply.unpack, |
| 7256 | 19: bsn_bw_enable_get_request.unpack, |
| 7257 | 23: bsn_bw_enable_set_reply.unpack, |
| 7258 | 18: bsn_bw_enable_set_request.unpack, |
| 7259 | 10: bsn_get_interfaces_reply.unpack, |
| 7260 | 9: bsn_get_interfaces_request.unpack, |
| 7261 | 5: bsn_get_mirroring_reply.unpack, |
| 7262 | 4: bsn_get_mirroring_request.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame^] | 7263 | 34: bsn_pdu_rx_reply.unpack, |
| 7264 | 33: bsn_pdu_rx_request.unpack, |
| 7265 | 35: bsn_pdu_rx_timeout.unpack, |
| 7266 | 32: bsn_pdu_tx_reply.unpack, |
| 7267 | 31: bsn_pdu_tx_request.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7268 | 3: bsn_set_mirroring.unpack, |
| 7269 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 7270 | 11: bsn_set_pktin_suppression_request.unpack, |
| 7271 | 16: bsn_virtual_port_create_reply.unpack, |
| 7272 | 15: bsn_virtual_port_create_request.unpack, |
| 7273 | 26: bsn_virtual_port_remove_reply.unpack, |
| 7274 | 17: bsn_virtual_port_remove_request.unpack, |
| 7275 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7276 | } |