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 | |
| 277 | class barrier_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 278 | version = 2 |
| 279 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 280 | |
| 281 | def __init__(self, xid=None): |
| 282 | self.xid = xid |
| 283 | |
| 284 | def pack(self): |
| 285 | packed = [] |
| 286 | packed.append(struct.pack("!B", self.version)) |
| 287 | packed.append(struct.pack("!B", self.type)) |
| 288 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 289 | packed.append(struct.pack("!L", self.xid)) |
| 290 | length = sum([len(x) for x in packed]) |
| 291 | packed[2] = struct.pack("!H", length) |
| 292 | return ''.join(packed) |
| 293 | |
| 294 | @staticmethod |
| 295 | def unpack(buf): |
| 296 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 297 | obj = barrier_reply() |
| 298 | if type(buf) == loxi.generic_util.OFReader: |
| 299 | reader = buf |
| 300 | else: |
| 301 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 302 | _version = reader.read("!B")[0] |
| 303 | assert(_version == 2) |
| 304 | _type = reader.read("!B")[0] |
| 305 | assert(_type == 21) |
| 306 | _length = reader.read("!H")[0] |
| 307 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 308 | return obj |
| 309 | |
| 310 | def __eq__(self, other): |
| 311 | if type(self) != type(other): return False |
| 312 | if self.version != other.version: return False |
| 313 | if self.type != other.type: return False |
| 314 | if self.xid != other.xid: return False |
| 315 | return True |
| 316 | |
| 317 | def __ne__(self, other): |
| 318 | return not self.__eq__(other) |
| 319 | |
| 320 | def __str__(self): |
| 321 | return self.show() |
| 322 | |
| 323 | def show(self): |
| 324 | import loxi.pp |
| 325 | return loxi.pp.pp(self) |
| 326 | |
| 327 | def pretty_print(self, q): |
| 328 | q.text("barrier_reply {") |
| 329 | with q.group(): |
| 330 | with q.indent(2): |
| 331 | q.breakable() |
| 332 | q.text("xid = "); |
| 333 | if self.xid != None: |
| 334 | q.text("%#x" % self.xid) |
| 335 | else: |
| 336 | q.text('None') |
| 337 | q.breakable() |
| 338 | q.text('}') |
| 339 | |
| 340 | class barrier_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 341 | version = 2 |
| 342 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 343 | |
| 344 | def __init__(self, xid=None): |
| 345 | self.xid = xid |
| 346 | |
| 347 | def pack(self): |
| 348 | packed = [] |
| 349 | packed.append(struct.pack("!B", self.version)) |
| 350 | packed.append(struct.pack("!B", self.type)) |
| 351 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 352 | packed.append(struct.pack("!L", self.xid)) |
| 353 | length = sum([len(x) for x in packed]) |
| 354 | packed[2] = struct.pack("!H", length) |
| 355 | return ''.join(packed) |
| 356 | |
| 357 | @staticmethod |
| 358 | def unpack(buf): |
| 359 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 360 | obj = barrier_request() |
| 361 | if type(buf) == loxi.generic_util.OFReader: |
| 362 | reader = buf |
| 363 | else: |
| 364 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 365 | _version = reader.read("!B")[0] |
| 366 | assert(_version == 2) |
| 367 | _type = reader.read("!B")[0] |
| 368 | assert(_type == 20) |
| 369 | _length = reader.read("!H")[0] |
| 370 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 371 | return obj |
| 372 | |
| 373 | def __eq__(self, other): |
| 374 | if type(self) != type(other): return False |
| 375 | if self.version != other.version: return False |
| 376 | if self.type != other.type: return False |
| 377 | if self.xid != other.xid: return False |
| 378 | return True |
| 379 | |
| 380 | def __ne__(self, other): |
| 381 | return not self.__eq__(other) |
| 382 | |
| 383 | def __str__(self): |
| 384 | return self.show() |
| 385 | |
| 386 | def show(self): |
| 387 | import loxi.pp |
| 388 | return loxi.pp.pp(self) |
| 389 | |
| 390 | def pretty_print(self, q): |
| 391 | q.text("barrier_request {") |
| 392 | with q.group(): |
| 393 | with q.indent(2): |
| 394 | q.breakable() |
| 395 | q.text("xid = "); |
| 396 | if self.xid != None: |
| 397 | q.text("%#x" % self.xid) |
| 398 | else: |
| 399 | q.text('None') |
| 400 | q.breakable() |
| 401 | q.text('}') |
| 402 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 403 | class bsn_bw_clear_data_reply(Message): |
| 404 | version = 2 |
| 405 | type = 4 |
| 406 | experimenter = 6035143 |
| 407 | subtype = 22 |
| 408 | |
| 409 | def __init__(self, xid=None, status=None): |
| 410 | self.xid = xid |
| 411 | if status != None: |
| 412 | self.status = status |
| 413 | else: |
| 414 | self.status = 0 |
| 415 | |
| 416 | def pack(self): |
| 417 | packed = [] |
| 418 | packed.append(struct.pack("!B", self.version)) |
| 419 | packed.append(struct.pack("!B", self.type)) |
| 420 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 421 | packed.append(struct.pack("!L", self.xid)) |
| 422 | packed.append(struct.pack("!L", self.experimenter)) |
| 423 | packed.append(struct.pack("!L", self.subtype)) |
| 424 | packed.append(struct.pack("!L", self.status)) |
| 425 | length = sum([len(x) for x in packed]) |
| 426 | packed[2] = struct.pack("!H", length) |
| 427 | return ''.join(packed) |
| 428 | |
| 429 | @staticmethod |
| 430 | def unpack(buf): |
| 431 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 432 | obj = bsn_bw_clear_data_reply() |
| 433 | if type(buf) == loxi.generic_util.OFReader: |
| 434 | reader = buf |
| 435 | else: |
| 436 | reader = loxi.generic_util.OFReader(buf) |
| 437 | _version = reader.read("!B")[0] |
| 438 | assert(_version == 2) |
| 439 | _type = reader.read("!B")[0] |
| 440 | assert(_type == 4) |
| 441 | _length = reader.read("!H")[0] |
| 442 | obj.xid = reader.read("!L")[0] |
| 443 | _experimenter = reader.read("!L")[0] |
| 444 | assert(_experimenter == 6035143) |
| 445 | _subtype = reader.read("!L")[0] |
| 446 | assert(_subtype == 22) |
| 447 | obj.status = reader.read("!L")[0] |
| 448 | return obj |
| 449 | |
| 450 | def __eq__(self, other): |
| 451 | if type(self) != type(other): return False |
| 452 | if self.version != other.version: return False |
| 453 | if self.type != other.type: return False |
| 454 | if self.xid != other.xid: return False |
| 455 | if self.status != other.status: return False |
| 456 | return True |
| 457 | |
| 458 | def __ne__(self, other): |
| 459 | return not self.__eq__(other) |
| 460 | |
| 461 | def __str__(self): |
| 462 | return self.show() |
| 463 | |
| 464 | def show(self): |
| 465 | import loxi.pp |
| 466 | return loxi.pp.pp(self) |
| 467 | |
| 468 | def pretty_print(self, q): |
| 469 | q.text("bsn_bw_clear_data_reply {") |
| 470 | with q.group(): |
| 471 | with q.indent(2): |
| 472 | q.breakable() |
| 473 | q.text("xid = "); |
| 474 | if self.xid != None: |
| 475 | q.text("%#x" % self.xid) |
| 476 | else: |
| 477 | q.text('None') |
| 478 | q.text(","); q.breakable() |
| 479 | q.text("status = "); |
| 480 | q.text("%#x" % self.status) |
| 481 | q.breakable() |
| 482 | q.text('}') |
| 483 | |
| 484 | class bsn_bw_clear_data_request(Message): |
| 485 | version = 2 |
| 486 | type = 4 |
| 487 | experimenter = 6035143 |
| 488 | subtype = 21 |
| 489 | |
| 490 | def __init__(self, xid=None): |
| 491 | self.xid = xid |
| 492 | |
| 493 | def pack(self): |
| 494 | packed = [] |
| 495 | packed.append(struct.pack("!B", self.version)) |
| 496 | packed.append(struct.pack("!B", self.type)) |
| 497 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 498 | packed.append(struct.pack("!L", self.xid)) |
| 499 | packed.append(struct.pack("!L", self.experimenter)) |
| 500 | packed.append(struct.pack("!L", self.subtype)) |
| 501 | length = sum([len(x) for x in packed]) |
| 502 | packed[2] = struct.pack("!H", length) |
| 503 | return ''.join(packed) |
| 504 | |
| 505 | @staticmethod |
| 506 | def unpack(buf): |
| 507 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 508 | obj = bsn_bw_clear_data_request() |
| 509 | if type(buf) == loxi.generic_util.OFReader: |
| 510 | reader = buf |
| 511 | else: |
| 512 | reader = loxi.generic_util.OFReader(buf) |
| 513 | _version = reader.read("!B")[0] |
| 514 | assert(_version == 2) |
| 515 | _type = reader.read("!B")[0] |
| 516 | assert(_type == 4) |
| 517 | _length = reader.read("!H")[0] |
| 518 | obj.xid = reader.read("!L")[0] |
| 519 | _experimenter = reader.read("!L")[0] |
| 520 | assert(_experimenter == 6035143) |
| 521 | _subtype = reader.read("!L")[0] |
| 522 | assert(_subtype == 21) |
| 523 | return obj |
| 524 | |
| 525 | def __eq__(self, other): |
| 526 | if type(self) != type(other): return False |
| 527 | if self.version != other.version: return False |
| 528 | if self.type != other.type: return False |
| 529 | if self.xid != other.xid: return False |
| 530 | return True |
| 531 | |
| 532 | def __ne__(self, other): |
| 533 | return not self.__eq__(other) |
| 534 | |
| 535 | def __str__(self): |
| 536 | return self.show() |
| 537 | |
| 538 | def show(self): |
| 539 | import loxi.pp |
| 540 | return loxi.pp.pp(self) |
| 541 | |
| 542 | def pretty_print(self, q): |
| 543 | q.text("bsn_bw_clear_data_request {") |
| 544 | with q.group(): |
| 545 | with q.indent(2): |
| 546 | q.breakable() |
| 547 | q.text("xid = "); |
| 548 | if self.xid != None: |
| 549 | q.text("%#x" % self.xid) |
| 550 | else: |
| 551 | q.text('None') |
| 552 | q.breakable() |
| 553 | q.text('}') |
| 554 | |
| 555 | class bsn_bw_enable_get_reply(Message): |
| 556 | version = 2 |
| 557 | type = 4 |
| 558 | experimenter = 6035143 |
| 559 | subtype = 20 |
| 560 | |
| 561 | def __init__(self, xid=None, enabled=None): |
| 562 | self.xid = xid |
| 563 | if enabled != None: |
| 564 | self.enabled = enabled |
| 565 | else: |
| 566 | self.enabled = 0 |
| 567 | |
| 568 | def pack(self): |
| 569 | packed = [] |
| 570 | packed.append(struct.pack("!B", self.version)) |
| 571 | packed.append(struct.pack("!B", self.type)) |
| 572 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 573 | packed.append(struct.pack("!L", self.xid)) |
| 574 | packed.append(struct.pack("!L", self.experimenter)) |
| 575 | packed.append(struct.pack("!L", self.subtype)) |
| 576 | packed.append(struct.pack("!L", self.enabled)) |
| 577 | length = sum([len(x) for x in packed]) |
| 578 | packed[2] = struct.pack("!H", length) |
| 579 | return ''.join(packed) |
| 580 | |
| 581 | @staticmethod |
| 582 | def unpack(buf): |
| 583 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 584 | obj = bsn_bw_enable_get_reply() |
| 585 | if type(buf) == loxi.generic_util.OFReader: |
| 586 | reader = buf |
| 587 | else: |
| 588 | reader = loxi.generic_util.OFReader(buf) |
| 589 | _version = reader.read("!B")[0] |
| 590 | assert(_version == 2) |
| 591 | _type = reader.read("!B")[0] |
| 592 | assert(_type == 4) |
| 593 | _length = reader.read("!H")[0] |
| 594 | obj.xid = reader.read("!L")[0] |
| 595 | _experimenter = reader.read("!L")[0] |
| 596 | assert(_experimenter == 6035143) |
| 597 | _subtype = reader.read("!L")[0] |
| 598 | assert(_subtype == 20) |
| 599 | obj.enabled = reader.read("!L")[0] |
| 600 | return obj |
| 601 | |
| 602 | def __eq__(self, other): |
| 603 | if type(self) != type(other): return False |
| 604 | if self.version != other.version: return False |
| 605 | if self.type != other.type: return False |
| 606 | if self.xid != other.xid: return False |
| 607 | if self.enabled != other.enabled: return False |
| 608 | return True |
| 609 | |
| 610 | def __ne__(self, other): |
| 611 | return not self.__eq__(other) |
| 612 | |
| 613 | def __str__(self): |
| 614 | return self.show() |
| 615 | |
| 616 | def show(self): |
| 617 | import loxi.pp |
| 618 | return loxi.pp.pp(self) |
| 619 | |
| 620 | def pretty_print(self, q): |
| 621 | q.text("bsn_bw_enable_get_reply {") |
| 622 | with q.group(): |
| 623 | with q.indent(2): |
| 624 | q.breakable() |
| 625 | q.text("xid = "); |
| 626 | if self.xid != None: |
| 627 | q.text("%#x" % self.xid) |
| 628 | else: |
| 629 | q.text('None') |
| 630 | q.text(","); q.breakable() |
| 631 | q.text("enabled = "); |
| 632 | q.text("%#x" % self.enabled) |
| 633 | q.breakable() |
| 634 | q.text('}') |
| 635 | |
| 636 | class bsn_bw_enable_get_request(Message): |
| 637 | version = 2 |
| 638 | type = 4 |
| 639 | experimenter = 6035143 |
| 640 | subtype = 19 |
| 641 | |
| 642 | def __init__(self, xid=None): |
| 643 | self.xid = xid |
| 644 | |
| 645 | def pack(self): |
| 646 | packed = [] |
| 647 | packed.append(struct.pack("!B", self.version)) |
| 648 | packed.append(struct.pack("!B", self.type)) |
| 649 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 650 | packed.append(struct.pack("!L", self.xid)) |
| 651 | packed.append(struct.pack("!L", self.experimenter)) |
| 652 | packed.append(struct.pack("!L", self.subtype)) |
| 653 | length = sum([len(x) for x in packed]) |
| 654 | packed[2] = struct.pack("!H", length) |
| 655 | return ''.join(packed) |
| 656 | |
| 657 | @staticmethod |
| 658 | def unpack(buf): |
| 659 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 660 | obj = bsn_bw_enable_get_request() |
| 661 | if type(buf) == loxi.generic_util.OFReader: |
| 662 | reader = buf |
| 663 | else: |
| 664 | reader = loxi.generic_util.OFReader(buf) |
| 665 | _version = reader.read("!B")[0] |
| 666 | assert(_version == 2) |
| 667 | _type = reader.read("!B")[0] |
| 668 | assert(_type == 4) |
| 669 | _length = reader.read("!H")[0] |
| 670 | obj.xid = reader.read("!L")[0] |
| 671 | _experimenter = reader.read("!L")[0] |
| 672 | assert(_experimenter == 6035143) |
| 673 | _subtype = reader.read("!L")[0] |
| 674 | assert(_subtype == 19) |
| 675 | return obj |
| 676 | |
| 677 | def __eq__(self, other): |
| 678 | if type(self) != type(other): return False |
| 679 | if self.version != other.version: return False |
| 680 | if self.type != other.type: return False |
| 681 | if self.xid != other.xid: return False |
| 682 | return True |
| 683 | |
| 684 | def __ne__(self, other): |
| 685 | return not self.__eq__(other) |
| 686 | |
| 687 | def __str__(self): |
| 688 | return self.show() |
| 689 | |
| 690 | def show(self): |
| 691 | import loxi.pp |
| 692 | return loxi.pp.pp(self) |
| 693 | |
| 694 | def pretty_print(self, q): |
| 695 | q.text("bsn_bw_enable_get_request {") |
| 696 | with q.group(): |
| 697 | with q.indent(2): |
| 698 | q.breakable() |
| 699 | q.text("xid = "); |
| 700 | if self.xid != None: |
| 701 | q.text("%#x" % self.xid) |
| 702 | else: |
| 703 | q.text('None') |
| 704 | q.breakable() |
| 705 | q.text('}') |
| 706 | |
| 707 | class bsn_bw_enable_set_reply(Message): |
| 708 | version = 2 |
| 709 | type = 4 |
| 710 | experimenter = 6035143 |
| 711 | subtype = 23 |
| 712 | |
| 713 | def __init__(self, xid=None, enable=None, status=None): |
| 714 | self.xid = xid |
| 715 | if enable != None: |
| 716 | self.enable = enable |
| 717 | else: |
| 718 | self.enable = 0 |
| 719 | if status != None: |
| 720 | self.status = status |
| 721 | else: |
| 722 | self.status = 0 |
| 723 | |
| 724 | def pack(self): |
| 725 | packed = [] |
| 726 | packed.append(struct.pack("!B", self.version)) |
| 727 | packed.append(struct.pack("!B", self.type)) |
| 728 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 729 | packed.append(struct.pack("!L", self.xid)) |
| 730 | packed.append(struct.pack("!L", self.experimenter)) |
| 731 | packed.append(struct.pack("!L", self.subtype)) |
| 732 | packed.append(struct.pack("!L", self.enable)) |
| 733 | packed.append(struct.pack("!L", self.status)) |
| 734 | length = sum([len(x) for x in packed]) |
| 735 | packed[2] = struct.pack("!H", length) |
| 736 | return ''.join(packed) |
| 737 | |
| 738 | @staticmethod |
| 739 | def unpack(buf): |
| 740 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 741 | obj = bsn_bw_enable_set_reply() |
| 742 | if type(buf) == loxi.generic_util.OFReader: |
| 743 | reader = buf |
| 744 | else: |
| 745 | reader = loxi.generic_util.OFReader(buf) |
| 746 | _version = reader.read("!B")[0] |
| 747 | assert(_version == 2) |
| 748 | _type = reader.read("!B")[0] |
| 749 | assert(_type == 4) |
| 750 | _length = reader.read("!H")[0] |
| 751 | obj.xid = reader.read("!L")[0] |
| 752 | _experimenter = reader.read("!L")[0] |
| 753 | assert(_experimenter == 6035143) |
| 754 | _subtype = reader.read("!L")[0] |
| 755 | assert(_subtype == 23) |
| 756 | obj.enable = reader.read("!L")[0] |
| 757 | obj.status = reader.read("!L")[0] |
| 758 | return obj |
| 759 | |
| 760 | def __eq__(self, other): |
| 761 | if type(self) != type(other): return False |
| 762 | if self.version != other.version: return False |
| 763 | if self.type != other.type: return False |
| 764 | if self.xid != other.xid: return False |
| 765 | if self.enable != other.enable: return False |
| 766 | if self.status != other.status: return False |
| 767 | return True |
| 768 | |
| 769 | def __ne__(self, other): |
| 770 | return not self.__eq__(other) |
| 771 | |
| 772 | def __str__(self): |
| 773 | return self.show() |
| 774 | |
| 775 | def show(self): |
| 776 | import loxi.pp |
| 777 | return loxi.pp.pp(self) |
| 778 | |
| 779 | def pretty_print(self, q): |
| 780 | q.text("bsn_bw_enable_set_reply {") |
| 781 | with q.group(): |
| 782 | with q.indent(2): |
| 783 | q.breakable() |
| 784 | q.text("xid = "); |
| 785 | if self.xid != None: |
| 786 | q.text("%#x" % self.xid) |
| 787 | else: |
| 788 | q.text('None') |
| 789 | q.text(","); q.breakable() |
| 790 | q.text("enable = "); |
| 791 | q.text("%#x" % self.enable) |
| 792 | q.text(","); q.breakable() |
| 793 | q.text("status = "); |
| 794 | q.text("%#x" % self.status) |
| 795 | q.breakable() |
| 796 | q.text('}') |
| 797 | |
| 798 | class bsn_bw_enable_set_request(Message): |
| 799 | version = 2 |
| 800 | type = 4 |
| 801 | experimenter = 6035143 |
| 802 | subtype = 18 |
| 803 | |
| 804 | def __init__(self, xid=None, enable=None): |
| 805 | self.xid = xid |
| 806 | if enable != None: |
| 807 | self.enable = enable |
| 808 | else: |
| 809 | self.enable = 0 |
| 810 | |
| 811 | def pack(self): |
| 812 | packed = [] |
| 813 | packed.append(struct.pack("!B", self.version)) |
| 814 | packed.append(struct.pack("!B", self.type)) |
| 815 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 816 | packed.append(struct.pack("!L", self.xid)) |
| 817 | packed.append(struct.pack("!L", self.experimenter)) |
| 818 | packed.append(struct.pack("!L", self.subtype)) |
| 819 | packed.append(struct.pack("!L", self.enable)) |
| 820 | length = sum([len(x) for x in packed]) |
| 821 | packed[2] = struct.pack("!H", length) |
| 822 | return ''.join(packed) |
| 823 | |
| 824 | @staticmethod |
| 825 | def unpack(buf): |
| 826 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 827 | obj = bsn_bw_enable_set_request() |
| 828 | if type(buf) == loxi.generic_util.OFReader: |
| 829 | reader = buf |
| 830 | else: |
| 831 | reader = loxi.generic_util.OFReader(buf) |
| 832 | _version = reader.read("!B")[0] |
| 833 | assert(_version == 2) |
| 834 | _type = reader.read("!B")[0] |
| 835 | assert(_type == 4) |
| 836 | _length = reader.read("!H")[0] |
| 837 | obj.xid = reader.read("!L")[0] |
| 838 | _experimenter = reader.read("!L")[0] |
| 839 | assert(_experimenter == 6035143) |
| 840 | _subtype = reader.read("!L")[0] |
| 841 | assert(_subtype == 18) |
| 842 | obj.enable = reader.read("!L")[0] |
| 843 | return obj |
| 844 | |
| 845 | def __eq__(self, other): |
| 846 | if type(self) != type(other): return False |
| 847 | if self.version != other.version: return False |
| 848 | if self.type != other.type: return False |
| 849 | if self.xid != other.xid: return False |
| 850 | if self.enable != other.enable: return False |
| 851 | return True |
| 852 | |
| 853 | def __ne__(self, other): |
| 854 | return not self.__eq__(other) |
| 855 | |
| 856 | def __str__(self): |
| 857 | return self.show() |
| 858 | |
| 859 | def show(self): |
| 860 | import loxi.pp |
| 861 | return loxi.pp.pp(self) |
| 862 | |
| 863 | def pretty_print(self, q): |
| 864 | q.text("bsn_bw_enable_set_request {") |
| 865 | with q.group(): |
| 866 | with q.indent(2): |
| 867 | q.breakable() |
| 868 | q.text("xid = "); |
| 869 | if self.xid != None: |
| 870 | q.text("%#x" % self.xid) |
| 871 | else: |
| 872 | q.text('None') |
| 873 | q.text(","); q.breakable() |
| 874 | q.text("enable = "); |
| 875 | q.text("%#x" % self.enable) |
| 876 | q.breakable() |
| 877 | q.text('}') |
| 878 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 879 | class bsn_get_interfaces_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 880 | version = 2 |
| 881 | type = 4 |
| 882 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 883 | subtype = 10 |
| 884 | |
| 885 | def __init__(self, xid=None, interfaces=None): |
| 886 | self.xid = xid |
| 887 | if interfaces != None: |
| 888 | self.interfaces = interfaces |
| 889 | else: |
| 890 | self.interfaces = [] |
| 891 | |
| 892 | def pack(self): |
| 893 | packed = [] |
| 894 | packed.append(struct.pack("!B", self.version)) |
| 895 | packed.append(struct.pack("!B", self.type)) |
| 896 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 897 | packed.append(struct.pack("!L", self.xid)) |
| 898 | packed.append(struct.pack("!L", self.experimenter)) |
| 899 | packed.append(struct.pack("!L", self.subtype)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 900 | packed.append(util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 901 | length = sum([len(x) for x in packed]) |
| 902 | packed[2] = struct.pack("!H", length) |
| 903 | return ''.join(packed) |
| 904 | |
| 905 | @staticmethod |
| 906 | def unpack(buf): |
| 907 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 908 | obj = bsn_get_interfaces_reply() |
| 909 | if type(buf) == loxi.generic_util.OFReader: |
| 910 | reader = buf |
| 911 | else: |
| 912 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 913 | _version = reader.read("!B")[0] |
| 914 | assert(_version == 2) |
| 915 | _type = reader.read("!B")[0] |
| 916 | assert(_type == 4) |
| 917 | _length = reader.read("!H")[0] |
| 918 | obj.xid = reader.read("!L")[0] |
| 919 | _experimenter = reader.read("!L")[0] |
| 920 | assert(_experimenter == 6035143) |
| 921 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 922 | assert(_subtype == 10) |
| 923 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
| 924 | return obj |
| 925 | |
| 926 | def __eq__(self, other): |
| 927 | if type(self) != type(other): return False |
| 928 | if self.version != other.version: return False |
| 929 | if self.type != other.type: return False |
| 930 | if self.xid != other.xid: return False |
| 931 | if self.interfaces != other.interfaces: return False |
| 932 | return True |
| 933 | |
| 934 | def __ne__(self, other): |
| 935 | return not self.__eq__(other) |
| 936 | |
| 937 | def __str__(self): |
| 938 | return self.show() |
| 939 | |
| 940 | def show(self): |
| 941 | import loxi.pp |
| 942 | return loxi.pp.pp(self) |
| 943 | |
| 944 | def pretty_print(self, q): |
| 945 | q.text("bsn_get_interfaces_reply {") |
| 946 | with q.group(): |
| 947 | with q.indent(2): |
| 948 | q.breakable() |
| 949 | q.text("xid = "); |
| 950 | if self.xid != None: |
| 951 | q.text("%#x" % self.xid) |
| 952 | else: |
| 953 | q.text('None') |
| 954 | q.text(","); q.breakable() |
| 955 | q.text("interfaces = "); |
| 956 | q.pp(self.interfaces) |
| 957 | q.breakable() |
| 958 | q.text('}') |
| 959 | |
| 960 | class bsn_get_interfaces_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 961 | version = 2 |
| 962 | type = 4 |
| 963 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 964 | subtype = 9 |
| 965 | |
| 966 | def __init__(self, xid=None): |
| 967 | self.xid = xid |
| 968 | |
| 969 | def pack(self): |
| 970 | packed = [] |
| 971 | packed.append(struct.pack("!B", self.version)) |
| 972 | packed.append(struct.pack("!B", self.type)) |
| 973 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 974 | packed.append(struct.pack("!L", self.xid)) |
| 975 | packed.append(struct.pack("!L", self.experimenter)) |
| 976 | packed.append(struct.pack("!L", self.subtype)) |
| 977 | length = sum([len(x) for x in packed]) |
| 978 | packed[2] = struct.pack("!H", length) |
| 979 | return ''.join(packed) |
| 980 | |
| 981 | @staticmethod |
| 982 | def unpack(buf): |
| 983 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 984 | obj = bsn_get_interfaces_request() |
| 985 | if type(buf) == loxi.generic_util.OFReader: |
| 986 | reader = buf |
| 987 | else: |
| 988 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 989 | _version = reader.read("!B")[0] |
| 990 | assert(_version == 2) |
| 991 | _type = reader.read("!B")[0] |
| 992 | assert(_type == 4) |
| 993 | _length = reader.read("!H")[0] |
| 994 | obj.xid = reader.read("!L")[0] |
| 995 | _experimenter = reader.read("!L")[0] |
| 996 | assert(_experimenter == 6035143) |
| 997 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 998 | assert(_subtype == 9) |
| 999 | return obj |
| 1000 | |
| 1001 | def __eq__(self, other): |
| 1002 | if type(self) != type(other): return False |
| 1003 | if self.version != other.version: return False |
| 1004 | if self.type != other.type: return False |
| 1005 | if self.xid != other.xid: return False |
| 1006 | return True |
| 1007 | |
| 1008 | def __ne__(self, other): |
| 1009 | return not self.__eq__(other) |
| 1010 | |
| 1011 | def __str__(self): |
| 1012 | return self.show() |
| 1013 | |
| 1014 | def show(self): |
| 1015 | import loxi.pp |
| 1016 | return loxi.pp.pp(self) |
| 1017 | |
| 1018 | def pretty_print(self, q): |
| 1019 | q.text("bsn_get_interfaces_request {") |
| 1020 | with q.group(): |
| 1021 | with q.indent(2): |
| 1022 | q.breakable() |
| 1023 | q.text("xid = "); |
| 1024 | if self.xid != None: |
| 1025 | q.text("%#x" % self.xid) |
| 1026 | else: |
| 1027 | q.text('None') |
| 1028 | q.breakable() |
| 1029 | q.text('}') |
| 1030 | |
| 1031 | class bsn_get_mirroring_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1032 | version = 2 |
| 1033 | type = 4 |
| 1034 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1035 | subtype = 5 |
| 1036 | |
| 1037 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1038 | self.xid = xid |
| 1039 | if report_mirror_ports != None: |
| 1040 | self.report_mirror_ports = report_mirror_ports |
| 1041 | else: |
| 1042 | self.report_mirror_ports = 0 |
| 1043 | |
| 1044 | def pack(self): |
| 1045 | packed = [] |
| 1046 | packed.append(struct.pack("!B", self.version)) |
| 1047 | packed.append(struct.pack("!B", self.type)) |
| 1048 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1049 | packed.append(struct.pack("!L", self.xid)) |
| 1050 | packed.append(struct.pack("!L", self.experimenter)) |
| 1051 | packed.append(struct.pack("!L", self.subtype)) |
| 1052 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1053 | packed.append('\x00' * 3) |
| 1054 | length = sum([len(x) for x in packed]) |
| 1055 | packed[2] = struct.pack("!H", length) |
| 1056 | return ''.join(packed) |
| 1057 | |
| 1058 | @staticmethod |
| 1059 | def unpack(buf): |
| 1060 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1061 | obj = bsn_get_mirroring_reply() |
| 1062 | if type(buf) == loxi.generic_util.OFReader: |
| 1063 | reader = buf |
| 1064 | else: |
| 1065 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1066 | _version = reader.read("!B")[0] |
| 1067 | assert(_version == 2) |
| 1068 | _type = reader.read("!B")[0] |
| 1069 | assert(_type == 4) |
| 1070 | _length = reader.read("!H")[0] |
| 1071 | obj.xid = reader.read("!L")[0] |
| 1072 | _experimenter = reader.read("!L")[0] |
| 1073 | assert(_experimenter == 6035143) |
| 1074 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1075 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1076 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1077 | reader.skip(3) |
| 1078 | return obj |
| 1079 | |
| 1080 | def __eq__(self, other): |
| 1081 | if type(self) != type(other): return False |
| 1082 | if self.version != other.version: return False |
| 1083 | if self.type != other.type: return False |
| 1084 | if self.xid != other.xid: return False |
| 1085 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1086 | return True |
| 1087 | |
| 1088 | def __ne__(self, other): |
| 1089 | return not self.__eq__(other) |
| 1090 | |
| 1091 | def __str__(self): |
| 1092 | return self.show() |
| 1093 | |
| 1094 | def show(self): |
| 1095 | import loxi.pp |
| 1096 | return loxi.pp.pp(self) |
| 1097 | |
| 1098 | def pretty_print(self, q): |
| 1099 | q.text("bsn_get_mirroring_reply {") |
| 1100 | with q.group(): |
| 1101 | with q.indent(2): |
| 1102 | q.breakable() |
| 1103 | q.text("xid = "); |
| 1104 | if self.xid != None: |
| 1105 | q.text("%#x" % self.xid) |
| 1106 | else: |
| 1107 | q.text('None') |
| 1108 | q.text(","); q.breakable() |
| 1109 | q.text("report_mirror_ports = "); |
| 1110 | q.text("%#x" % self.report_mirror_ports) |
| 1111 | q.breakable() |
| 1112 | q.text('}') |
| 1113 | |
| 1114 | class bsn_get_mirroring_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1115 | version = 2 |
| 1116 | type = 4 |
| 1117 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1118 | subtype = 4 |
| 1119 | |
| 1120 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1121 | self.xid = xid |
| 1122 | if report_mirror_ports != None: |
| 1123 | self.report_mirror_ports = report_mirror_ports |
| 1124 | else: |
| 1125 | self.report_mirror_ports = 0 |
| 1126 | |
| 1127 | def pack(self): |
| 1128 | packed = [] |
| 1129 | packed.append(struct.pack("!B", self.version)) |
| 1130 | packed.append(struct.pack("!B", self.type)) |
| 1131 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1132 | packed.append(struct.pack("!L", self.xid)) |
| 1133 | packed.append(struct.pack("!L", self.experimenter)) |
| 1134 | packed.append(struct.pack("!L", self.subtype)) |
| 1135 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1136 | packed.append('\x00' * 3) |
| 1137 | length = sum([len(x) for x in packed]) |
| 1138 | packed[2] = struct.pack("!H", length) |
| 1139 | return ''.join(packed) |
| 1140 | |
| 1141 | @staticmethod |
| 1142 | def unpack(buf): |
| 1143 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1144 | obj = bsn_get_mirroring_request() |
| 1145 | if type(buf) == loxi.generic_util.OFReader: |
| 1146 | reader = buf |
| 1147 | else: |
| 1148 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1149 | _version = reader.read("!B")[0] |
| 1150 | assert(_version == 2) |
| 1151 | _type = reader.read("!B")[0] |
| 1152 | assert(_type == 4) |
| 1153 | _length = reader.read("!H")[0] |
| 1154 | obj.xid = reader.read("!L")[0] |
| 1155 | _experimenter = reader.read("!L")[0] |
| 1156 | assert(_experimenter == 6035143) |
| 1157 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1158 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1159 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1160 | reader.skip(3) |
| 1161 | return obj |
| 1162 | |
| 1163 | def __eq__(self, other): |
| 1164 | if type(self) != type(other): return False |
| 1165 | if self.version != other.version: return False |
| 1166 | if self.type != other.type: return False |
| 1167 | if self.xid != other.xid: return False |
| 1168 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1169 | return True |
| 1170 | |
| 1171 | def __ne__(self, other): |
| 1172 | return not self.__eq__(other) |
| 1173 | |
| 1174 | def __str__(self): |
| 1175 | return self.show() |
| 1176 | |
| 1177 | def show(self): |
| 1178 | import loxi.pp |
| 1179 | return loxi.pp.pp(self) |
| 1180 | |
| 1181 | def pretty_print(self, q): |
| 1182 | q.text("bsn_get_mirroring_request {") |
| 1183 | with q.group(): |
| 1184 | with q.indent(2): |
| 1185 | q.breakable() |
| 1186 | q.text("xid = "); |
| 1187 | if self.xid != None: |
| 1188 | q.text("%#x" % self.xid) |
| 1189 | else: |
| 1190 | q.text('None') |
| 1191 | q.text(","); q.breakable() |
| 1192 | q.text("report_mirror_ports = "); |
| 1193 | q.text("%#x" % self.report_mirror_ports) |
| 1194 | q.breakable() |
| 1195 | q.text('}') |
| 1196 | |
| 1197 | class bsn_set_mirroring(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1198 | version = 2 |
| 1199 | type = 4 |
| 1200 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1201 | subtype = 3 |
| 1202 | |
| 1203 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1204 | self.xid = xid |
| 1205 | if report_mirror_ports != None: |
| 1206 | self.report_mirror_ports = report_mirror_ports |
| 1207 | else: |
| 1208 | self.report_mirror_ports = 0 |
| 1209 | |
| 1210 | def pack(self): |
| 1211 | packed = [] |
| 1212 | packed.append(struct.pack("!B", self.version)) |
| 1213 | packed.append(struct.pack("!B", self.type)) |
| 1214 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1215 | packed.append(struct.pack("!L", self.xid)) |
| 1216 | packed.append(struct.pack("!L", self.experimenter)) |
| 1217 | packed.append(struct.pack("!L", self.subtype)) |
| 1218 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1219 | packed.append('\x00' * 3) |
| 1220 | length = sum([len(x) for x in packed]) |
| 1221 | packed[2] = struct.pack("!H", length) |
| 1222 | return ''.join(packed) |
| 1223 | |
| 1224 | @staticmethod |
| 1225 | def unpack(buf): |
| 1226 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1227 | obj = bsn_set_mirroring() |
| 1228 | if type(buf) == loxi.generic_util.OFReader: |
| 1229 | reader = buf |
| 1230 | else: |
| 1231 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1232 | _version = reader.read("!B")[0] |
| 1233 | assert(_version == 2) |
| 1234 | _type = reader.read("!B")[0] |
| 1235 | assert(_type == 4) |
| 1236 | _length = reader.read("!H")[0] |
| 1237 | obj.xid = reader.read("!L")[0] |
| 1238 | _experimenter = reader.read("!L")[0] |
| 1239 | assert(_experimenter == 6035143) |
| 1240 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1241 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1242 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1243 | reader.skip(3) |
| 1244 | return obj |
| 1245 | |
| 1246 | def __eq__(self, other): |
| 1247 | if type(self) != type(other): return False |
| 1248 | if self.version != other.version: return False |
| 1249 | if self.type != other.type: return False |
| 1250 | if self.xid != other.xid: return False |
| 1251 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1252 | return True |
| 1253 | |
| 1254 | def __ne__(self, other): |
| 1255 | return not self.__eq__(other) |
| 1256 | |
| 1257 | def __str__(self): |
| 1258 | return self.show() |
| 1259 | |
| 1260 | def show(self): |
| 1261 | import loxi.pp |
| 1262 | return loxi.pp.pp(self) |
| 1263 | |
| 1264 | def pretty_print(self, q): |
| 1265 | q.text("bsn_set_mirroring {") |
| 1266 | with q.group(): |
| 1267 | with q.indent(2): |
| 1268 | q.breakable() |
| 1269 | q.text("xid = "); |
| 1270 | if self.xid != None: |
| 1271 | q.text("%#x" % self.xid) |
| 1272 | else: |
| 1273 | q.text('None') |
| 1274 | q.text(","); q.breakable() |
| 1275 | q.text("report_mirror_ports = "); |
| 1276 | q.text("%#x" % self.report_mirror_ports) |
| 1277 | q.breakable() |
| 1278 | q.text('}') |
| 1279 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1280 | class bsn_set_pktin_suppression_reply(Message): |
| 1281 | version = 2 |
| 1282 | type = 4 |
| 1283 | experimenter = 6035143 |
| 1284 | subtype = 25 |
| 1285 | |
| 1286 | def __init__(self, xid=None, status=None): |
| 1287 | self.xid = xid |
| 1288 | if status != None: |
| 1289 | self.status = status |
| 1290 | else: |
| 1291 | self.status = 0 |
| 1292 | |
| 1293 | def pack(self): |
| 1294 | packed = [] |
| 1295 | packed.append(struct.pack("!B", self.version)) |
| 1296 | packed.append(struct.pack("!B", self.type)) |
| 1297 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1298 | packed.append(struct.pack("!L", self.xid)) |
| 1299 | packed.append(struct.pack("!L", self.experimenter)) |
| 1300 | packed.append(struct.pack("!L", self.subtype)) |
| 1301 | packed.append(struct.pack("!L", self.status)) |
| 1302 | length = sum([len(x) for x in packed]) |
| 1303 | packed[2] = struct.pack("!H", length) |
| 1304 | return ''.join(packed) |
| 1305 | |
| 1306 | @staticmethod |
| 1307 | def unpack(buf): |
| 1308 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1309 | obj = bsn_set_pktin_suppression_reply() |
| 1310 | if type(buf) == loxi.generic_util.OFReader: |
| 1311 | reader = buf |
| 1312 | else: |
| 1313 | reader = loxi.generic_util.OFReader(buf) |
| 1314 | _version = reader.read("!B")[0] |
| 1315 | assert(_version == 2) |
| 1316 | _type = reader.read("!B")[0] |
| 1317 | assert(_type == 4) |
| 1318 | _length = reader.read("!H")[0] |
| 1319 | obj.xid = reader.read("!L")[0] |
| 1320 | _experimenter = reader.read("!L")[0] |
| 1321 | assert(_experimenter == 6035143) |
| 1322 | _subtype = reader.read("!L")[0] |
| 1323 | assert(_subtype == 25) |
| 1324 | obj.status = reader.read("!L")[0] |
| 1325 | return obj |
| 1326 | |
| 1327 | def __eq__(self, other): |
| 1328 | if type(self) != type(other): return False |
| 1329 | if self.version != other.version: return False |
| 1330 | if self.type != other.type: return False |
| 1331 | if self.xid != other.xid: return False |
| 1332 | if self.status != other.status: return False |
| 1333 | return True |
| 1334 | |
| 1335 | def __ne__(self, other): |
| 1336 | return not self.__eq__(other) |
| 1337 | |
| 1338 | def __str__(self): |
| 1339 | return self.show() |
| 1340 | |
| 1341 | def show(self): |
| 1342 | import loxi.pp |
| 1343 | return loxi.pp.pp(self) |
| 1344 | |
| 1345 | def pretty_print(self, q): |
| 1346 | q.text("bsn_set_pktin_suppression_reply {") |
| 1347 | with q.group(): |
| 1348 | with q.indent(2): |
| 1349 | q.breakable() |
| 1350 | q.text("xid = "); |
| 1351 | if self.xid != None: |
| 1352 | q.text("%#x" % self.xid) |
| 1353 | else: |
| 1354 | q.text('None') |
| 1355 | q.text(","); q.breakable() |
| 1356 | q.text("status = "); |
| 1357 | q.text("%#x" % self.status) |
| 1358 | q.breakable() |
| 1359 | q.text('}') |
| 1360 | |
| 1361 | class bsn_set_pktin_suppression_request(Message): |
| 1362 | version = 2 |
| 1363 | type = 4 |
| 1364 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1365 | subtype = 11 |
| 1366 | |
| 1367 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
| 1368 | self.xid = xid |
| 1369 | if enabled != None: |
| 1370 | self.enabled = enabled |
| 1371 | else: |
| 1372 | self.enabled = 0 |
| 1373 | if idle_timeout != None: |
| 1374 | self.idle_timeout = idle_timeout |
| 1375 | else: |
| 1376 | self.idle_timeout = 0 |
| 1377 | if hard_timeout != None: |
| 1378 | self.hard_timeout = hard_timeout |
| 1379 | else: |
| 1380 | self.hard_timeout = 0 |
| 1381 | if priority != None: |
| 1382 | self.priority = priority |
| 1383 | else: |
| 1384 | self.priority = 0 |
| 1385 | if cookie != None: |
| 1386 | self.cookie = cookie |
| 1387 | else: |
| 1388 | self.cookie = 0 |
| 1389 | |
| 1390 | def pack(self): |
| 1391 | packed = [] |
| 1392 | packed.append(struct.pack("!B", self.version)) |
| 1393 | packed.append(struct.pack("!B", self.type)) |
| 1394 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1395 | packed.append(struct.pack("!L", self.xid)) |
| 1396 | packed.append(struct.pack("!L", self.experimenter)) |
| 1397 | packed.append(struct.pack("!L", self.subtype)) |
| 1398 | packed.append(struct.pack("!B", self.enabled)) |
| 1399 | packed.append('\x00' * 1) |
| 1400 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 1401 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 1402 | packed.append(struct.pack("!H", self.priority)) |
| 1403 | packed.append(struct.pack("!Q", self.cookie)) |
| 1404 | length = sum([len(x) for x in packed]) |
| 1405 | packed[2] = struct.pack("!H", length) |
| 1406 | return ''.join(packed) |
| 1407 | |
| 1408 | @staticmethod |
| 1409 | def unpack(buf): |
| 1410 | 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] | 1411 | obj = bsn_set_pktin_suppression_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1412 | if type(buf) == loxi.generic_util.OFReader: |
| 1413 | reader = buf |
| 1414 | else: |
| 1415 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1416 | _version = reader.read("!B")[0] |
| 1417 | assert(_version == 2) |
| 1418 | _type = reader.read("!B")[0] |
| 1419 | assert(_type == 4) |
| 1420 | _length = reader.read("!H")[0] |
| 1421 | obj.xid = reader.read("!L")[0] |
| 1422 | _experimenter = reader.read("!L")[0] |
| 1423 | assert(_experimenter == 6035143) |
| 1424 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1425 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1426 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1427 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1428 | obj.idle_timeout = reader.read("!H")[0] |
| 1429 | obj.hard_timeout = reader.read("!H")[0] |
| 1430 | obj.priority = reader.read("!H")[0] |
| 1431 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1432 | return obj |
| 1433 | |
| 1434 | def __eq__(self, other): |
| 1435 | if type(self) != type(other): return False |
| 1436 | if self.version != other.version: return False |
| 1437 | if self.type != other.type: return False |
| 1438 | if self.xid != other.xid: return False |
| 1439 | if self.enabled != other.enabled: return False |
| 1440 | if self.idle_timeout != other.idle_timeout: return False |
| 1441 | if self.hard_timeout != other.hard_timeout: return False |
| 1442 | if self.priority != other.priority: return False |
| 1443 | if self.cookie != other.cookie: return False |
| 1444 | return True |
| 1445 | |
| 1446 | def __ne__(self, other): |
| 1447 | return not self.__eq__(other) |
| 1448 | |
| 1449 | def __str__(self): |
| 1450 | return self.show() |
| 1451 | |
| 1452 | def show(self): |
| 1453 | import loxi.pp |
| 1454 | return loxi.pp.pp(self) |
| 1455 | |
| 1456 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1457 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1458 | with q.group(): |
| 1459 | with q.indent(2): |
| 1460 | q.breakable() |
| 1461 | q.text("xid = "); |
| 1462 | if self.xid != None: |
| 1463 | q.text("%#x" % self.xid) |
| 1464 | else: |
| 1465 | q.text('None') |
| 1466 | q.text(","); q.breakable() |
| 1467 | q.text("enabled = "); |
| 1468 | q.text("%#x" % self.enabled) |
| 1469 | q.text(","); q.breakable() |
| 1470 | q.text("idle_timeout = "); |
| 1471 | q.text("%#x" % self.idle_timeout) |
| 1472 | q.text(","); q.breakable() |
| 1473 | q.text("hard_timeout = "); |
| 1474 | q.text("%#x" % self.hard_timeout) |
| 1475 | q.text(","); q.breakable() |
| 1476 | q.text("priority = "); |
| 1477 | q.text("%#x" % self.priority) |
| 1478 | q.text(","); q.breakable() |
| 1479 | q.text("cookie = "); |
| 1480 | q.text("%#x" % self.cookie) |
| 1481 | q.breakable() |
| 1482 | q.text('}') |
| 1483 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1484 | class bsn_virtual_port_create_reply(Message): |
| 1485 | version = 2 |
| 1486 | type = 4 |
| 1487 | experimenter = 6035143 |
| 1488 | subtype = 16 |
| 1489 | |
| 1490 | def __init__(self, xid=None, status=None, vport_no=None): |
| 1491 | self.xid = xid |
| 1492 | if status != None: |
| 1493 | self.status = status |
| 1494 | else: |
| 1495 | self.status = 0 |
| 1496 | if vport_no != None: |
| 1497 | self.vport_no = vport_no |
| 1498 | else: |
| 1499 | self.vport_no = 0 |
| 1500 | |
| 1501 | def pack(self): |
| 1502 | packed = [] |
| 1503 | packed.append(struct.pack("!B", self.version)) |
| 1504 | packed.append(struct.pack("!B", self.type)) |
| 1505 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1506 | packed.append(struct.pack("!L", self.xid)) |
| 1507 | packed.append(struct.pack("!L", self.experimenter)) |
| 1508 | packed.append(struct.pack("!L", self.subtype)) |
| 1509 | packed.append(struct.pack("!L", self.status)) |
| 1510 | packed.append(struct.pack("!L", self.vport_no)) |
| 1511 | length = sum([len(x) for x in packed]) |
| 1512 | packed[2] = struct.pack("!H", length) |
| 1513 | return ''.join(packed) |
| 1514 | |
| 1515 | @staticmethod |
| 1516 | def unpack(buf): |
| 1517 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1518 | obj = bsn_virtual_port_create_reply() |
| 1519 | if type(buf) == loxi.generic_util.OFReader: |
| 1520 | reader = buf |
| 1521 | else: |
| 1522 | reader = loxi.generic_util.OFReader(buf) |
| 1523 | _version = reader.read("!B")[0] |
| 1524 | assert(_version == 2) |
| 1525 | _type = reader.read("!B")[0] |
| 1526 | assert(_type == 4) |
| 1527 | _length = reader.read("!H")[0] |
| 1528 | obj.xid = reader.read("!L")[0] |
| 1529 | _experimenter = reader.read("!L")[0] |
| 1530 | assert(_experimenter == 6035143) |
| 1531 | _subtype = reader.read("!L")[0] |
| 1532 | assert(_subtype == 16) |
| 1533 | obj.status = reader.read("!L")[0] |
| 1534 | obj.vport_no = reader.read("!L")[0] |
| 1535 | return obj |
| 1536 | |
| 1537 | def __eq__(self, other): |
| 1538 | if type(self) != type(other): return False |
| 1539 | if self.version != other.version: return False |
| 1540 | if self.type != other.type: return False |
| 1541 | if self.xid != other.xid: return False |
| 1542 | if self.status != other.status: return False |
| 1543 | if self.vport_no != other.vport_no: return False |
| 1544 | return True |
| 1545 | |
| 1546 | def __ne__(self, other): |
| 1547 | return not self.__eq__(other) |
| 1548 | |
| 1549 | def __str__(self): |
| 1550 | return self.show() |
| 1551 | |
| 1552 | def show(self): |
| 1553 | import loxi.pp |
| 1554 | return loxi.pp.pp(self) |
| 1555 | |
| 1556 | def pretty_print(self, q): |
| 1557 | q.text("bsn_virtual_port_create_reply {") |
| 1558 | with q.group(): |
| 1559 | with q.indent(2): |
| 1560 | q.breakable() |
| 1561 | q.text("xid = "); |
| 1562 | if self.xid != None: |
| 1563 | q.text("%#x" % self.xid) |
| 1564 | else: |
| 1565 | q.text('None') |
| 1566 | q.text(","); q.breakable() |
| 1567 | q.text("status = "); |
| 1568 | q.text("%#x" % self.status) |
| 1569 | q.text(","); q.breakable() |
| 1570 | q.text("vport_no = "); |
| 1571 | q.text("%#x" % self.vport_no) |
| 1572 | q.breakable() |
| 1573 | q.text('}') |
| 1574 | |
| 1575 | class bsn_virtual_port_create_request(Message): |
| 1576 | version = 2 |
| 1577 | type = 4 |
| 1578 | experimenter = 6035143 |
| 1579 | subtype = 15 |
| 1580 | |
| 1581 | def __init__(self, xid=None, vport=None): |
| 1582 | self.xid = xid |
| 1583 | if vport != None: |
| 1584 | self.vport = vport |
| 1585 | else: |
| 1586 | self.vport = common.bsn_vport_q_in_q() |
| 1587 | |
| 1588 | def pack(self): |
| 1589 | packed = [] |
| 1590 | packed.append(struct.pack("!B", self.version)) |
| 1591 | packed.append(struct.pack("!B", self.type)) |
| 1592 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1593 | packed.append(struct.pack("!L", self.xid)) |
| 1594 | packed.append(struct.pack("!L", self.experimenter)) |
| 1595 | packed.append(struct.pack("!L", self.subtype)) |
| 1596 | packed.append(self.vport.pack()) |
| 1597 | length = sum([len(x) for x in packed]) |
| 1598 | packed[2] = struct.pack("!H", length) |
| 1599 | return ''.join(packed) |
| 1600 | |
| 1601 | @staticmethod |
| 1602 | def unpack(buf): |
| 1603 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1604 | obj = bsn_virtual_port_create_request() |
| 1605 | if type(buf) == loxi.generic_util.OFReader: |
| 1606 | reader = buf |
| 1607 | else: |
| 1608 | reader = loxi.generic_util.OFReader(buf) |
| 1609 | _version = reader.read("!B")[0] |
| 1610 | assert(_version == 2) |
| 1611 | _type = reader.read("!B")[0] |
| 1612 | assert(_type == 4) |
| 1613 | _length = reader.read("!H")[0] |
| 1614 | obj.xid = reader.read("!L")[0] |
| 1615 | _experimenter = reader.read("!L")[0] |
| 1616 | assert(_experimenter == 6035143) |
| 1617 | _subtype = reader.read("!L")[0] |
| 1618 | assert(_subtype == 15) |
| 1619 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 1620 | return obj |
| 1621 | |
| 1622 | def __eq__(self, other): |
| 1623 | if type(self) != type(other): return False |
| 1624 | if self.version != other.version: return False |
| 1625 | if self.type != other.type: return False |
| 1626 | if self.xid != other.xid: return False |
| 1627 | if self.vport != other.vport: return False |
| 1628 | return True |
| 1629 | |
| 1630 | def __ne__(self, other): |
| 1631 | return not self.__eq__(other) |
| 1632 | |
| 1633 | def __str__(self): |
| 1634 | return self.show() |
| 1635 | |
| 1636 | def show(self): |
| 1637 | import loxi.pp |
| 1638 | return loxi.pp.pp(self) |
| 1639 | |
| 1640 | def pretty_print(self, q): |
| 1641 | q.text("bsn_virtual_port_create_request {") |
| 1642 | with q.group(): |
| 1643 | with q.indent(2): |
| 1644 | q.breakable() |
| 1645 | q.text("xid = "); |
| 1646 | if self.xid != None: |
| 1647 | q.text("%#x" % self.xid) |
| 1648 | else: |
| 1649 | q.text('None') |
| 1650 | q.text(","); q.breakable() |
| 1651 | q.text("vport = "); |
| 1652 | q.pp(self.vport) |
| 1653 | q.breakable() |
| 1654 | q.text('}') |
| 1655 | |
| 1656 | class bsn_virtual_port_remove_reply(Message): |
| 1657 | version = 2 |
| 1658 | type = 4 |
| 1659 | experimenter = 6035143 |
| 1660 | subtype = 26 |
| 1661 | |
| 1662 | def __init__(self, xid=None, status=None): |
| 1663 | self.xid = xid |
| 1664 | if status != None: |
| 1665 | self.status = status |
| 1666 | else: |
| 1667 | self.status = 0 |
| 1668 | |
| 1669 | def pack(self): |
| 1670 | packed = [] |
| 1671 | packed.append(struct.pack("!B", self.version)) |
| 1672 | packed.append(struct.pack("!B", self.type)) |
| 1673 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1674 | packed.append(struct.pack("!L", self.xid)) |
| 1675 | packed.append(struct.pack("!L", self.experimenter)) |
| 1676 | packed.append(struct.pack("!L", self.subtype)) |
| 1677 | packed.append(struct.pack("!L", self.status)) |
| 1678 | length = sum([len(x) for x in packed]) |
| 1679 | packed[2] = struct.pack("!H", length) |
| 1680 | return ''.join(packed) |
| 1681 | |
| 1682 | @staticmethod |
| 1683 | def unpack(buf): |
| 1684 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1685 | obj = bsn_virtual_port_remove_reply() |
| 1686 | if type(buf) == loxi.generic_util.OFReader: |
| 1687 | reader = buf |
| 1688 | else: |
| 1689 | reader = loxi.generic_util.OFReader(buf) |
| 1690 | _version = reader.read("!B")[0] |
| 1691 | assert(_version == 2) |
| 1692 | _type = reader.read("!B")[0] |
| 1693 | assert(_type == 4) |
| 1694 | _length = reader.read("!H")[0] |
| 1695 | obj.xid = reader.read("!L")[0] |
| 1696 | _experimenter = reader.read("!L")[0] |
| 1697 | assert(_experimenter == 6035143) |
| 1698 | _subtype = reader.read("!L")[0] |
| 1699 | assert(_subtype == 26) |
| 1700 | obj.status = reader.read("!L")[0] |
| 1701 | return obj |
| 1702 | |
| 1703 | def __eq__(self, other): |
| 1704 | if type(self) != type(other): return False |
| 1705 | if self.version != other.version: return False |
| 1706 | if self.type != other.type: return False |
| 1707 | if self.xid != other.xid: return False |
| 1708 | if self.status != other.status: return False |
| 1709 | return True |
| 1710 | |
| 1711 | def __ne__(self, other): |
| 1712 | return not self.__eq__(other) |
| 1713 | |
| 1714 | def __str__(self): |
| 1715 | return self.show() |
| 1716 | |
| 1717 | def show(self): |
| 1718 | import loxi.pp |
| 1719 | return loxi.pp.pp(self) |
| 1720 | |
| 1721 | def pretty_print(self, q): |
| 1722 | q.text("bsn_virtual_port_remove_reply {") |
| 1723 | with q.group(): |
| 1724 | with q.indent(2): |
| 1725 | q.breakable() |
| 1726 | q.text("xid = "); |
| 1727 | if self.xid != None: |
| 1728 | q.text("%#x" % self.xid) |
| 1729 | else: |
| 1730 | q.text('None') |
| 1731 | q.text(","); q.breakable() |
| 1732 | q.text("status = "); |
| 1733 | q.text("%#x" % self.status) |
| 1734 | q.breakable() |
| 1735 | q.text('}') |
| 1736 | |
| 1737 | class bsn_virtual_port_remove_request(Message): |
| 1738 | version = 2 |
| 1739 | type = 4 |
| 1740 | experimenter = 6035143 |
| 1741 | subtype = 17 |
| 1742 | |
| 1743 | def __init__(self, xid=None, vport_no=None): |
| 1744 | self.xid = xid |
| 1745 | if vport_no != None: |
| 1746 | self.vport_no = vport_no |
| 1747 | else: |
| 1748 | self.vport_no = 0 |
| 1749 | |
| 1750 | def pack(self): |
| 1751 | packed = [] |
| 1752 | packed.append(struct.pack("!B", self.version)) |
| 1753 | packed.append(struct.pack("!B", self.type)) |
| 1754 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1755 | packed.append(struct.pack("!L", self.xid)) |
| 1756 | packed.append(struct.pack("!L", self.experimenter)) |
| 1757 | packed.append(struct.pack("!L", self.subtype)) |
| 1758 | packed.append(struct.pack("!L", self.vport_no)) |
| 1759 | length = sum([len(x) for x in packed]) |
| 1760 | packed[2] = struct.pack("!H", length) |
| 1761 | return ''.join(packed) |
| 1762 | |
| 1763 | @staticmethod |
| 1764 | def unpack(buf): |
| 1765 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1766 | obj = bsn_virtual_port_remove_request() |
| 1767 | if type(buf) == loxi.generic_util.OFReader: |
| 1768 | reader = buf |
| 1769 | else: |
| 1770 | reader = loxi.generic_util.OFReader(buf) |
| 1771 | _version = reader.read("!B")[0] |
| 1772 | assert(_version == 2) |
| 1773 | _type = reader.read("!B")[0] |
| 1774 | assert(_type == 4) |
| 1775 | _length = reader.read("!H")[0] |
| 1776 | obj.xid = reader.read("!L")[0] |
| 1777 | _experimenter = reader.read("!L")[0] |
| 1778 | assert(_experimenter == 6035143) |
| 1779 | _subtype = reader.read("!L")[0] |
| 1780 | assert(_subtype == 17) |
| 1781 | obj.vport_no = reader.read("!L")[0] |
| 1782 | return obj |
| 1783 | |
| 1784 | def __eq__(self, other): |
| 1785 | if type(self) != type(other): return False |
| 1786 | if self.version != other.version: return False |
| 1787 | if self.type != other.type: return False |
| 1788 | if self.xid != other.xid: return False |
| 1789 | if self.vport_no != other.vport_no: return False |
| 1790 | return True |
| 1791 | |
| 1792 | def __ne__(self, other): |
| 1793 | return not self.__eq__(other) |
| 1794 | |
| 1795 | def __str__(self): |
| 1796 | return self.show() |
| 1797 | |
| 1798 | def show(self): |
| 1799 | import loxi.pp |
| 1800 | return loxi.pp.pp(self) |
| 1801 | |
| 1802 | def pretty_print(self, q): |
| 1803 | q.text("bsn_virtual_port_remove_request {") |
| 1804 | with q.group(): |
| 1805 | with q.indent(2): |
| 1806 | q.breakable() |
| 1807 | q.text("xid = "); |
| 1808 | if self.xid != None: |
| 1809 | q.text("%#x" % self.xid) |
| 1810 | else: |
| 1811 | q.text('None') |
| 1812 | q.text(","); q.breakable() |
| 1813 | q.text("vport_no = "); |
| 1814 | q.text("%#x" % self.vport_no) |
| 1815 | q.breakable() |
| 1816 | q.text('}') |
| 1817 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1818 | class desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1819 | version = 2 |
| 1820 | type = 19 |
| 1821 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1822 | |
| 1823 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
| 1824 | self.xid = xid |
| 1825 | if flags != None: |
| 1826 | self.flags = flags |
| 1827 | else: |
| 1828 | self.flags = 0 |
| 1829 | if mfr_desc != None: |
| 1830 | self.mfr_desc = mfr_desc |
| 1831 | else: |
| 1832 | self.mfr_desc = "" |
| 1833 | if hw_desc != None: |
| 1834 | self.hw_desc = hw_desc |
| 1835 | else: |
| 1836 | self.hw_desc = "" |
| 1837 | if sw_desc != None: |
| 1838 | self.sw_desc = sw_desc |
| 1839 | else: |
| 1840 | self.sw_desc = "" |
| 1841 | if serial_num != None: |
| 1842 | self.serial_num = serial_num |
| 1843 | else: |
| 1844 | self.serial_num = "" |
| 1845 | if dp_desc != None: |
| 1846 | self.dp_desc = dp_desc |
| 1847 | else: |
| 1848 | self.dp_desc = "" |
| 1849 | |
| 1850 | def pack(self): |
| 1851 | packed = [] |
| 1852 | packed.append(struct.pack("!B", self.version)) |
| 1853 | packed.append(struct.pack("!B", self.type)) |
| 1854 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1855 | packed.append(struct.pack("!L", self.xid)) |
| 1856 | packed.append(struct.pack("!H", self.stats_type)) |
| 1857 | packed.append(struct.pack("!H", self.flags)) |
| 1858 | packed.append('\x00' * 4) |
| 1859 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 1860 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 1861 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 1862 | packed.append(struct.pack("!32s", self.serial_num)) |
| 1863 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 1864 | length = sum([len(x) for x in packed]) |
| 1865 | packed[2] = struct.pack("!H", length) |
| 1866 | return ''.join(packed) |
| 1867 | |
| 1868 | @staticmethod |
| 1869 | def unpack(buf): |
| 1870 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1871 | obj = desc_stats_reply() |
| 1872 | if type(buf) == loxi.generic_util.OFReader: |
| 1873 | reader = buf |
| 1874 | else: |
| 1875 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1876 | _version = reader.read("!B")[0] |
| 1877 | assert(_version == 2) |
| 1878 | _type = reader.read("!B")[0] |
| 1879 | assert(_type == 19) |
| 1880 | _length = reader.read("!H")[0] |
| 1881 | obj.xid = reader.read("!L")[0] |
| 1882 | _stats_type = reader.read("!H")[0] |
| 1883 | assert(_stats_type == 0) |
| 1884 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1885 | reader.skip(4) |
| 1886 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1887 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1888 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1889 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 1890 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1891 | return obj |
| 1892 | |
| 1893 | def __eq__(self, other): |
| 1894 | if type(self) != type(other): return False |
| 1895 | if self.version != other.version: return False |
| 1896 | if self.type != other.type: return False |
| 1897 | if self.xid != other.xid: return False |
| 1898 | if self.flags != other.flags: return False |
| 1899 | if self.mfr_desc != other.mfr_desc: return False |
| 1900 | if self.hw_desc != other.hw_desc: return False |
| 1901 | if self.sw_desc != other.sw_desc: return False |
| 1902 | if self.serial_num != other.serial_num: return False |
| 1903 | if self.dp_desc != other.dp_desc: return False |
| 1904 | return True |
| 1905 | |
| 1906 | def __ne__(self, other): |
| 1907 | return not self.__eq__(other) |
| 1908 | |
| 1909 | def __str__(self): |
| 1910 | return self.show() |
| 1911 | |
| 1912 | def show(self): |
| 1913 | import loxi.pp |
| 1914 | return loxi.pp.pp(self) |
| 1915 | |
| 1916 | def pretty_print(self, q): |
| 1917 | q.text("desc_stats_reply {") |
| 1918 | with q.group(): |
| 1919 | with q.indent(2): |
| 1920 | q.breakable() |
| 1921 | q.text("xid = "); |
| 1922 | if self.xid != None: |
| 1923 | q.text("%#x" % self.xid) |
| 1924 | else: |
| 1925 | q.text('None') |
| 1926 | q.text(","); q.breakable() |
| 1927 | q.text("flags = "); |
| 1928 | q.text("%#x" % self.flags) |
| 1929 | q.text(","); q.breakable() |
| 1930 | q.text("mfr_desc = "); |
| 1931 | q.pp(self.mfr_desc) |
| 1932 | q.text(","); q.breakable() |
| 1933 | q.text("hw_desc = "); |
| 1934 | q.pp(self.hw_desc) |
| 1935 | q.text(","); q.breakable() |
| 1936 | q.text("sw_desc = "); |
| 1937 | q.pp(self.sw_desc) |
| 1938 | q.text(","); q.breakable() |
| 1939 | q.text("serial_num = "); |
| 1940 | q.pp(self.serial_num) |
| 1941 | q.text(","); q.breakable() |
| 1942 | q.text("dp_desc = "); |
| 1943 | q.pp(self.dp_desc) |
| 1944 | q.breakable() |
| 1945 | q.text('}') |
| 1946 | |
| 1947 | class desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1948 | version = 2 |
| 1949 | type = 18 |
| 1950 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1951 | |
| 1952 | def __init__(self, xid=None, flags=None): |
| 1953 | self.xid = xid |
| 1954 | if flags != None: |
| 1955 | self.flags = flags |
| 1956 | else: |
| 1957 | self.flags = 0 |
| 1958 | |
| 1959 | def pack(self): |
| 1960 | packed = [] |
| 1961 | packed.append(struct.pack("!B", self.version)) |
| 1962 | packed.append(struct.pack("!B", self.type)) |
| 1963 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1964 | packed.append(struct.pack("!L", self.xid)) |
| 1965 | packed.append(struct.pack("!H", self.stats_type)) |
| 1966 | packed.append(struct.pack("!H", self.flags)) |
| 1967 | packed.append('\x00' * 4) |
| 1968 | length = sum([len(x) for x in packed]) |
| 1969 | packed[2] = struct.pack("!H", length) |
| 1970 | return ''.join(packed) |
| 1971 | |
| 1972 | @staticmethod |
| 1973 | def unpack(buf): |
| 1974 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1975 | obj = desc_stats_request() |
| 1976 | if type(buf) == loxi.generic_util.OFReader: |
| 1977 | reader = buf |
| 1978 | else: |
| 1979 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1980 | _version = reader.read("!B")[0] |
| 1981 | assert(_version == 2) |
| 1982 | _type = reader.read("!B")[0] |
| 1983 | assert(_type == 18) |
| 1984 | _length = reader.read("!H")[0] |
| 1985 | obj.xid = reader.read("!L")[0] |
| 1986 | _stats_type = reader.read("!H")[0] |
| 1987 | assert(_stats_type == 0) |
| 1988 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1989 | reader.skip(4) |
| 1990 | return obj |
| 1991 | |
| 1992 | def __eq__(self, other): |
| 1993 | if type(self) != type(other): return False |
| 1994 | if self.version != other.version: return False |
| 1995 | if self.type != other.type: return False |
| 1996 | if self.xid != other.xid: return False |
| 1997 | if self.flags != other.flags: return False |
| 1998 | return True |
| 1999 | |
| 2000 | def __ne__(self, other): |
| 2001 | return not self.__eq__(other) |
| 2002 | |
| 2003 | def __str__(self): |
| 2004 | return self.show() |
| 2005 | |
| 2006 | def show(self): |
| 2007 | import loxi.pp |
| 2008 | return loxi.pp.pp(self) |
| 2009 | |
| 2010 | def pretty_print(self, q): |
| 2011 | q.text("desc_stats_request {") |
| 2012 | with q.group(): |
| 2013 | with q.indent(2): |
| 2014 | q.breakable() |
| 2015 | q.text("xid = "); |
| 2016 | if self.xid != None: |
| 2017 | q.text("%#x" % self.xid) |
| 2018 | else: |
| 2019 | q.text('None') |
| 2020 | q.text(","); q.breakable() |
| 2021 | q.text("flags = "); |
| 2022 | q.text("%#x" % self.flags) |
| 2023 | q.breakable() |
| 2024 | q.text('}') |
| 2025 | |
| 2026 | class echo_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2027 | version = 2 |
| 2028 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2029 | |
| 2030 | def __init__(self, xid=None, data=None): |
| 2031 | self.xid = xid |
| 2032 | if data != None: |
| 2033 | self.data = data |
| 2034 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2035 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2036 | |
| 2037 | def pack(self): |
| 2038 | packed = [] |
| 2039 | packed.append(struct.pack("!B", self.version)) |
| 2040 | packed.append(struct.pack("!B", self.type)) |
| 2041 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2042 | packed.append(struct.pack("!L", self.xid)) |
| 2043 | packed.append(self.data) |
| 2044 | length = sum([len(x) for x in packed]) |
| 2045 | packed[2] = struct.pack("!H", length) |
| 2046 | return ''.join(packed) |
| 2047 | |
| 2048 | @staticmethod |
| 2049 | def unpack(buf): |
| 2050 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2051 | obj = echo_reply() |
| 2052 | if type(buf) == loxi.generic_util.OFReader: |
| 2053 | reader = buf |
| 2054 | else: |
| 2055 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2056 | _version = reader.read("!B")[0] |
| 2057 | assert(_version == 2) |
| 2058 | _type = reader.read("!B")[0] |
| 2059 | assert(_type == 3) |
| 2060 | _length = reader.read("!H")[0] |
| 2061 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2062 | obj.data = str(reader.read_all()) |
| 2063 | return obj |
| 2064 | |
| 2065 | def __eq__(self, other): |
| 2066 | if type(self) != type(other): return False |
| 2067 | if self.version != other.version: return False |
| 2068 | if self.type != other.type: return False |
| 2069 | if self.xid != other.xid: return False |
| 2070 | if self.data != other.data: return False |
| 2071 | return True |
| 2072 | |
| 2073 | def __ne__(self, other): |
| 2074 | return not self.__eq__(other) |
| 2075 | |
| 2076 | def __str__(self): |
| 2077 | return self.show() |
| 2078 | |
| 2079 | def show(self): |
| 2080 | import loxi.pp |
| 2081 | return loxi.pp.pp(self) |
| 2082 | |
| 2083 | def pretty_print(self, q): |
| 2084 | q.text("echo_reply {") |
| 2085 | with q.group(): |
| 2086 | with q.indent(2): |
| 2087 | q.breakable() |
| 2088 | q.text("xid = "); |
| 2089 | if self.xid != None: |
| 2090 | q.text("%#x" % self.xid) |
| 2091 | else: |
| 2092 | q.text('None') |
| 2093 | q.text(","); q.breakable() |
| 2094 | q.text("data = "); |
| 2095 | q.pp(self.data) |
| 2096 | q.breakable() |
| 2097 | q.text('}') |
| 2098 | |
| 2099 | class echo_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2100 | version = 2 |
| 2101 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2102 | |
| 2103 | def __init__(self, xid=None, data=None): |
| 2104 | self.xid = xid |
| 2105 | if data != None: |
| 2106 | self.data = data |
| 2107 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2108 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2109 | |
| 2110 | def pack(self): |
| 2111 | packed = [] |
| 2112 | packed.append(struct.pack("!B", self.version)) |
| 2113 | packed.append(struct.pack("!B", self.type)) |
| 2114 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2115 | packed.append(struct.pack("!L", self.xid)) |
| 2116 | packed.append(self.data) |
| 2117 | length = sum([len(x) for x in packed]) |
| 2118 | packed[2] = struct.pack("!H", length) |
| 2119 | return ''.join(packed) |
| 2120 | |
| 2121 | @staticmethod |
| 2122 | def unpack(buf): |
| 2123 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2124 | obj = echo_request() |
| 2125 | if type(buf) == loxi.generic_util.OFReader: |
| 2126 | reader = buf |
| 2127 | else: |
| 2128 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2129 | _version = reader.read("!B")[0] |
| 2130 | assert(_version == 2) |
| 2131 | _type = reader.read("!B")[0] |
| 2132 | assert(_type == 2) |
| 2133 | _length = reader.read("!H")[0] |
| 2134 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2135 | obj.data = str(reader.read_all()) |
| 2136 | return obj |
| 2137 | |
| 2138 | def __eq__(self, other): |
| 2139 | if type(self) != type(other): return False |
| 2140 | if self.version != other.version: return False |
| 2141 | if self.type != other.type: return False |
| 2142 | if self.xid != other.xid: return False |
| 2143 | if self.data != other.data: return False |
| 2144 | return True |
| 2145 | |
| 2146 | def __ne__(self, other): |
| 2147 | return not self.__eq__(other) |
| 2148 | |
| 2149 | def __str__(self): |
| 2150 | return self.show() |
| 2151 | |
| 2152 | def show(self): |
| 2153 | import loxi.pp |
| 2154 | return loxi.pp.pp(self) |
| 2155 | |
| 2156 | def pretty_print(self, q): |
| 2157 | q.text("echo_request {") |
| 2158 | with q.group(): |
| 2159 | with q.indent(2): |
| 2160 | q.breakable() |
| 2161 | q.text("xid = "); |
| 2162 | if self.xid != None: |
| 2163 | q.text("%#x" % self.xid) |
| 2164 | else: |
| 2165 | q.text('None') |
| 2166 | q.text(","); q.breakable() |
| 2167 | q.text("data = "); |
| 2168 | q.pp(self.data) |
| 2169 | q.breakable() |
| 2170 | q.text('}') |
| 2171 | |
| 2172 | class error_msg(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2173 | version = 2 |
| 2174 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2175 | |
| 2176 | def __init__(self, xid=None, err_type=None, code=None, data=None): |
| 2177 | self.xid = xid |
| 2178 | if err_type != None: |
| 2179 | self.err_type = err_type |
| 2180 | else: |
| 2181 | self.err_type = 0 |
| 2182 | if code != None: |
| 2183 | self.code = code |
| 2184 | else: |
| 2185 | self.code = 0 |
| 2186 | if data != None: |
| 2187 | self.data = data |
| 2188 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2189 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2190 | |
| 2191 | def pack(self): |
| 2192 | packed = [] |
| 2193 | packed.append(struct.pack("!B", self.version)) |
| 2194 | packed.append(struct.pack("!B", self.type)) |
| 2195 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2196 | packed.append(struct.pack("!L", self.xid)) |
| 2197 | packed.append(struct.pack("!H", self.err_type)) |
| 2198 | packed.append(struct.pack("!H", self.code)) |
| 2199 | packed.append(self.data) |
| 2200 | length = sum([len(x) for x in packed]) |
| 2201 | packed[2] = struct.pack("!H", length) |
| 2202 | return ''.join(packed) |
| 2203 | |
| 2204 | @staticmethod |
| 2205 | def unpack(buf): |
| 2206 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2207 | obj = error_msg() |
| 2208 | if type(buf) == loxi.generic_util.OFReader: |
| 2209 | reader = buf |
| 2210 | else: |
| 2211 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2212 | _version = reader.read("!B")[0] |
| 2213 | assert(_version == 2) |
| 2214 | _type = reader.read("!B")[0] |
| 2215 | assert(_type == 1) |
| 2216 | _length = reader.read("!H")[0] |
| 2217 | obj.xid = reader.read("!L")[0] |
| 2218 | obj.err_type = reader.read("!H")[0] |
| 2219 | obj.code = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2220 | obj.data = str(reader.read_all()) |
| 2221 | return obj |
| 2222 | |
| 2223 | def __eq__(self, other): |
| 2224 | if type(self) != type(other): return False |
| 2225 | if self.version != other.version: return False |
| 2226 | if self.type != other.type: return False |
| 2227 | if self.xid != other.xid: return False |
| 2228 | if self.err_type != other.err_type: return False |
| 2229 | if self.code != other.code: return False |
| 2230 | if self.data != other.data: return False |
| 2231 | return True |
| 2232 | |
| 2233 | def __ne__(self, other): |
| 2234 | return not self.__eq__(other) |
| 2235 | |
| 2236 | def __str__(self): |
| 2237 | return self.show() |
| 2238 | |
| 2239 | def show(self): |
| 2240 | import loxi.pp |
| 2241 | return loxi.pp.pp(self) |
| 2242 | |
| 2243 | def pretty_print(self, q): |
| 2244 | q.text("error_msg {") |
| 2245 | with q.group(): |
| 2246 | with q.indent(2): |
| 2247 | q.breakable() |
| 2248 | q.text("xid = "); |
| 2249 | if self.xid != None: |
| 2250 | q.text("%#x" % self.xid) |
| 2251 | else: |
| 2252 | q.text('None') |
| 2253 | q.text(","); q.breakable() |
| 2254 | q.text("err_type = "); |
| 2255 | q.text("%#x" % self.err_type) |
| 2256 | q.text(","); q.breakable() |
| 2257 | q.text("code = "); |
| 2258 | q.text("%#x" % self.code) |
| 2259 | q.text(","); q.breakable() |
| 2260 | q.text("data = "); |
| 2261 | q.pp(self.data) |
| 2262 | q.breakable() |
| 2263 | q.text('}') |
| 2264 | |
| 2265 | class experimenter_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2266 | version = 2 |
| 2267 | type = 19 |
| 2268 | stats_type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2269 | |
| 2270 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 2271 | self.xid = xid |
| 2272 | if flags != None: |
| 2273 | self.flags = flags |
| 2274 | else: |
| 2275 | self.flags = 0 |
| 2276 | if experimenter != None: |
| 2277 | self.experimenter = experimenter |
| 2278 | else: |
| 2279 | self.experimenter = 0 |
| 2280 | if data != None: |
| 2281 | self.data = data |
| 2282 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2283 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2284 | |
| 2285 | def pack(self): |
| 2286 | packed = [] |
| 2287 | packed.append(struct.pack("!B", self.version)) |
| 2288 | packed.append(struct.pack("!B", self.type)) |
| 2289 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2290 | packed.append(struct.pack("!L", self.xid)) |
| 2291 | packed.append(struct.pack("!H", self.stats_type)) |
| 2292 | packed.append(struct.pack("!H", self.flags)) |
| 2293 | packed.append('\x00' * 4) |
| 2294 | packed.append(struct.pack("!L", self.experimenter)) |
| 2295 | packed.append('\x00' * 4) |
| 2296 | packed.append(self.data) |
| 2297 | length = sum([len(x) for x in packed]) |
| 2298 | packed[2] = struct.pack("!H", length) |
| 2299 | return ''.join(packed) |
| 2300 | |
| 2301 | @staticmethod |
| 2302 | def unpack(buf): |
| 2303 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2304 | obj = experimenter_stats_reply() |
| 2305 | if type(buf) == loxi.generic_util.OFReader: |
| 2306 | reader = buf |
| 2307 | else: |
| 2308 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2309 | _version = reader.read("!B")[0] |
| 2310 | assert(_version == 2) |
| 2311 | _type = reader.read("!B")[0] |
| 2312 | assert(_type == 19) |
| 2313 | _length = reader.read("!H")[0] |
| 2314 | obj.xid = reader.read("!L")[0] |
| 2315 | _stats_type = reader.read("!H")[0] |
| 2316 | assert(_stats_type == 65535) |
| 2317 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2318 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2319 | obj.experimenter = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2320 | reader.skip(4) |
| 2321 | obj.data = str(reader.read_all()) |
| 2322 | return obj |
| 2323 | |
| 2324 | def __eq__(self, other): |
| 2325 | if type(self) != type(other): return False |
| 2326 | if self.version != other.version: return False |
| 2327 | if self.type != other.type: return False |
| 2328 | if self.xid != other.xid: return False |
| 2329 | if self.flags != other.flags: return False |
| 2330 | if self.experimenter != other.experimenter: return False |
| 2331 | if self.data != other.data: return False |
| 2332 | return True |
| 2333 | |
| 2334 | def __ne__(self, other): |
| 2335 | return not self.__eq__(other) |
| 2336 | |
| 2337 | def __str__(self): |
| 2338 | return self.show() |
| 2339 | |
| 2340 | def show(self): |
| 2341 | import loxi.pp |
| 2342 | return loxi.pp.pp(self) |
| 2343 | |
| 2344 | def pretty_print(self, q): |
| 2345 | q.text("experimenter_stats_reply {") |
| 2346 | with q.group(): |
| 2347 | with q.indent(2): |
| 2348 | q.breakable() |
| 2349 | q.text("xid = "); |
| 2350 | if self.xid != None: |
| 2351 | q.text("%#x" % self.xid) |
| 2352 | else: |
| 2353 | q.text('None') |
| 2354 | q.text(","); q.breakable() |
| 2355 | q.text("flags = "); |
| 2356 | q.text("%#x" % self.flags) |
| 2357 | q.text(","); q.breakable() |
| 2358 | q.text("experimenter = "); |
| 2359 | q.text("%#x" % self.experimenter) |
| 2360 | q.text(","); q.breakable() |
| 2361 | q.text("data = "); |
| 2362 | q.pp(self.data) |
| 2363 | q.breakable() |
| 2364 | q.text('}') |
| 2365 | |
| 2366 | class experimenter_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2367 | version = 2 |
| 2368 | type = 18 |
| 2369 | stats_type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2370 | |
| 2371 | def __init__(self, xid=None, flags=None, experimenter=None, data=None): |
| 2372 | self.xid = xid |
| 2373 | if flags != None: |
| 2374 | self.flags = flags |
| 2375 | else: |
| 2376 | self.flags = 0 |
| 2377 | if experimenter != None: |
| 2378 | self.experimenter = experimenter |
| 2379 | else: |
| 2380 | self.experimenter = 0 |
| 2381 | if data != None: |
| 2382 | self.data = data |
| 2383 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2384 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2385 | |
| 2386 | def pack(self): |
| 2387 | packed = [] |
| 2388 | packed.append(struct.pack("!B", self.version)) |
| 2389 | packed.append(struct.pack("!B", self.type)) |
| 2390 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2391 | packed.append(struct.pack("!L", self.xid)) |
| 2392 | packed.append(struct.pack("!H", self.stats_type)) |
| 2393 | packed.append(struct.pack("!H", self.flags)) |
| 2394 | packed.append('\x00' * 4) |
| 2395 | packed.append(struct.pack("!L", self.experimenter)) |
| 2396 | packed.append('\x00' * 4) |
| 2397 | packed.append(self.data) |
| 2398 | length = sum([len(x) for x in packed]) |
| 2399 | packed[2] = struct.pack("!H", length) |
| 2400 | return ''.join(packed) |
| 2401 | |
| 2402 | @staticmethod |
| 2403 | def unpack(buf): |
| 2404 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2405 | obj = experimenter_stats_request() |
| 2406 | if type(buf) == loxi.generic_util.OFReader: |
| 2407 | reader = buf |
| 2408 | else: |
| 2409 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2410 | _version = reader.read("!B")[0] |
| 2411 | assert(_version == 2) |
| 2412 | _type = reader.read("!B")[0] |
| 2413 | assert(_type == 18) |
| 2414 | _length = reader.read("!H")[0] |
| 2415 | obj.xid = reader.read("!L")[0] |
| 2416 | _stats_type = reader.read("!H")[0] |
| 2417 | assert(_stats_type == 65535) |
| 2418 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2419 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2420 | obj.experimenter = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2421 | reader.skip(4) |
| 2422 | obj.data = str(reader.read_all()) |
| 2423 | return obj |
| 2424 | |
| 2425 | def __eq__(self, other): |
| 2426 | if type(self) != type(other): return False |
| 2427 | if self.version != other.version: return False |
| 2428 | if self.type != other.type: return False |
| 2429 | if self.xid != other.xid: return False |
| 2430 | if self.flags != other.flags: return False |
| 2431 | if self.experimenter != other.experimenter: return False |
| 2432 | if self.data != other.data: return False |
| 2433 | return True |
| 2434 | |
| 2435 | def __ne__(self, other): |
| 2436 | return not self.__eq__(other) |
| 2437 | |
| 2438 | def __str__(self): |
| 2439 | return self.show() |
| 2440 | |
| 2441 | def show(self): |
| 2442 | import loxi.pp |
| 2443 | return loxi.pp.pp(self) |
| 2444 | |
| 2445 | def pretty_print(self, q): |
| 2446 | q.text("experimenter_stats_request {") |
| 2447 | with q.group(): |
| 2448 | with q.indent(2): |
| 2449 | q.breakable() |
| 2450 | q.text("xid = "); |
| 2451 | if self.xid != None: |
| 2452 | q.text("%#x" % self.xid) |
| 2453 | else: |
| 2454 | q.text('None') |
| 2455 | q.text(","); q.breakable() |
| 2456 | q.text("flags = "); |
| 2457 | q.text("%#x" % self.flags) |
| 2458 | q.text(","); q.breakable() |
| 2459 | q.text("experimenter = "); |
| 2460 | q.text("%#x" % self.experimenter) |
| 2461 | q.text(","); q.breakable() |
| 2462 | q.text("data = "); |
| 2463 | q.pp(self.data) |
| 2464 | q.breakable() |
| 2465 | q.text('}') |
| 2466 | |
| 2467 | class features_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2468 | version = 2 |
| 2469 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2470 | |
| 2471 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None): |
| 2472 | self.xid = xid |
| 2473 | if datapath_id != None: |
| 2474 | self.datapath_id = datapath_id |
| 2475 | else: |
| 2476 | self.datapath_id = 0 |
| 2477 | if n_buffers != None: |
| 2478 | self.n_buffers = n_buffers |
| 2479 | else: |
| 2480 | self.n_buffers = 0 |
| 2481 | if n_tables != None: |
| 2482 | self.n_tables = n_tables |
| 2483 | else: |
| 2484 | self.n_tables = 0 |
| 2485 | if capabilities != None: |
| 2486 | self.capabilities = capabilities |
| 2487 | else: |
| 2488 | self.capabilities = 0 |
| 2489 | if reserved != None: |
| 2490 | self.reserved = reserved |
| 2491 | else: |
| 2492 | self.reserved = 0 |
| 2493 | if ports != None: |
| 2494 | self.ports = ports |
| 2495 | else: |
| 2496 | self.ports = [] |
| 2497 | |
| 2498 | def pack(self): |
| 2499 | packed = [] |
| 2500 | packed.append(struct.pack("!B", self.version)) |
| 2501 | packed.append(struct.pack("!B", self.type)) |
| 2502 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2503 | packed.append(struct.pack("!L", self.xid)) |
| 2504 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 2505 | packed.append(struct.pack("!L", self.n_buffers)) |
| 2506 | packed.append(struct.pack("!B", self.n_tables)) |
| 2507 | packed.append('\x00' * 3) |
| 2508 | packed.append(struct.pack("!L", self.capabilities)) |
| 2509 | packed.append(struct.pack("!L", self.reserved)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2510 | packed.append(util.pack_list(self.ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2511 | length = sum([len(x) for x in packed]) |
| 2512 | packed[2] = struct.pack("!H", length) |
| 2513 | return ''.join(packed) |
| 2514 | |
| 2515 | @staticmethod |
| 2516 | def unpack(buf): |
| 2517 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2518 | obj = features_reply() |
| 2519 | if type(buf) == loxi.generic_util.OFReader: |
| 2520 | reader = buf |
| 2521 | else: |
| 2522 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2523 | _version = reader.read("!B")[0] |
| 2524 | assert(_version == 2) |
| 2525 | _type = reader.read("!B")[0] |
| 2526 | assert(_type == 6) |
| 2527 | _length = reader.read("!H")[0] |
| 2528 | obj.xid = reader.read("!L")[0] |
| 2529 | obj.datapath_id = reader.read("!Q")[0] |
| 2530 | obj.n_buffers = reader.read("!L")[0] |
| 2531 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2532 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2533 | obj.capabilities = reader.read("!L")[0] |
| 2534 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2535 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 2536 | return obj |
| 2537 | |
| 2538 | def __eq__(self, other): |
| 2539 | if type(self) != type(other): return False |
| 2540 | if self.version != other.version: return False |
| 2541 | if self.type != other.type: return False |
| 2542 | if self.xid != other.xid: return False |
| 2543 | if self.datapath_id != other.datapath_id: return False |
| 2544 | if self.n_buffers != other.n_buffers: return False |
| 2545 | if self.n_tables != other.n_tables: return False |
| 2546 | if self.capabilities != other.capabilities: return False |
| 2547 | if self.reserved != other.reserved: return False |
| 2548 | if self.ports != other.ports: return False |
| 2549 | return True |
| 2550 | |
| 2551 | def __ne__(self, other): |
| 2552 | return not self.__eq__(other) |
| 2553 | |
| 2554 | def __str__(self): |
| 2555 | return self.show() |
| 2556 | |
| 2557 | def show(self): |
| 2558 | import loxi.pp |
| 2559 | return loxi.pp.pp(self) |
| 2560 | |
| 2561 | def pretty_print(self, q): |
| 2562 | q.text("features_reply {") |
| 2563 | with q.group(): |
| 2564 | with q.indent(2): |
| 2565 | q.breakable() |
| 2566 | q.text("xid = "); |
| 2567 | if self.xid != None: |
| 2568 | q.text("%#x" % self.xid) |
| 2569 | else: |
| 2570 | q.text('None') |
| 2571 | q.text(","); q.breakable() |
| 2572 | q.text("datapath_id = "); |
| 2573 | q.text("%#x" % self.datapath_id) |
| 2574 | q.text(","); q.breakable() |
| 2575 | q.text("n_buffers = "); |
| 2576 | q.text("%#x" % self.n_buffers) |
| 2577 | q.text(","); q.breakable() |
| 2578 | q.text("n_tables = "); |
| 2579 | q.text("%#x" % self.n_tables) |
| 2580 | q.text(","); q.breakable() |
| 2581 | q.text("capabilities = "); |
| 2582 | q.text("%#x" % self.capabilities) |
| 2583 | q.text(","); q.breakable() |
| 2584 | q.text("reserved = "); |
| 2585 | q.text("%#x" % self.reserved) |
| 2586 | q.text(","); q.breakable() |
| 2587 | q.text("ports = "); |
| 2588 | q.pp(self.ports) |
| 2589 | q.breakable() |
| 2590 | q.text('}') |
| 2591 | |
| 2592 | class features_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2593 | version = 2 |
| 2594 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2595 | |
| 2596 | def __init__(self, xid=None): |
| 2597 | self.xid = xid |
| 2598 | |
| 2599 | def pack(self): |
| 2600 | packed = [] |
| 2601 | packed.append(struct.pack("!B", self.version)) |
| 2602 | packed.append(struct.pack("!B", self.type)) |
| 2603 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2604 | packed.append(struct.pack("!L", self.xid)) |
| 2605 | length = sum([len(x) for x in packed]) |
| 2606 | packed[2] = struct.pack("!H", length) |
| 2607 | return ''.join(packed) |
| 2608 | |
| 2609 | @staticmethod |
| 2610 | def unpack(buf): |
| 2611 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2612 | obj = features_request() |
| 2613 | if type(buf) == loxi.generic_util.OFReader: |
| 2614 | reader = buf |
| 2615 | else: |
| 2616 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2617 | _version = reader.read("!B")[0] |
| 2618 | assert(_version == 2) |
| 2619 | _type = reader.read("!B")[0] |
| 2620 | assert(_type == 5) |
| 2621 | _length = reader.read("!H")[0] |
| 2622 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2623 | return obj |
| 2624 | |
| 2625 | def __eq__(self, other): |
| 2626 | if type(self) != type(other): return False |
| 2627 | if self.version != other.version: return False |
| 2628 | if self.type != other.type: return False |
| 2629 | if self.xid != other.xid: return False |
| 2630 | return True |
| 2631 | |
| 2632 | def __ne__(self, other): |
| 2633 | return not self.__eq__(other) |
| 2634 | |
| 2635 | def __str__(self): |
| 2636 | return self.show() |
| 2637 | |
| 2638 | def show(self): |
| 2639 | import loxi.pp |
| 2640 | return loxi.pp.pp(self) |
| 2641 | |
| 2642 | def pretty_print(self, q): |
| 2643 | q.text("features_request {") |
| 2644 | with q.group(): |
| 2645 | with q.indent(2): |
| 2646 | q.breakable() |
| 2647 | q.text("xid = "); |
| 2648 | if self.xid != None: |
| 2649 | q.text("%#x" % self.xid) |
| 2650 | else: |
| 2651 | q.text('None') |
| 2652 | q.breakable() |
| 2653 | q.text('}') |
| 2654 | |
| 2655 | class flow_add(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2656 | version = 2 |
| 2657 | type = 14 |
| 2658 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2659 | |
| 2660 | 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): |
| 2661 | self.xid = xid |
| 2662 | if cookie != None: |
| 2663 | self.cookie = cookie |
| 2664 | else: |
| 2665 | self.cookie = 0 |
| 2666 | if cookie_mask != None: |
| 2667 | self.cookie_mask = cookie_mask |
| 2668 | else: |
| 2669 | self.cookie_mask = 0 |
| 2670 | if table_id != None: |
| 2671 | self.table_id = table_id |
| 2672 | else: |
| 2673 | self.table_id = 0 |
| 2674 | if idle_timeout != None: |
| 2675 | self.idle_timeout = idle_timeout |
| 2676 | else: |
| 2677 | self.idle_timeout = 0 |
| 2678 | if hard_timeout != None: |
| 2679 | self.hard_timeout = hard_timeout |
| 2680 | else: |
| 2681 | self.hard_timeout = 0 |
| 2682 | if priority != None: |
| 2683 | self.priority = priority |
| 2684 | else: |
| 2685 | self.priority = 0 |
| 2686 | if buffer_id != None: |
| 2687 | self.buffer_id = buffer_id |
| 2688 | else: |
| 2689 | self.buffer_id = 0 |
| 2690 | if out_port != None: |
| 2691 | self.out_port = out_port |
| 2692 | else: |
| 2693 | self.out_port = 0 |
| 2694 | if out_group != None: |
| 2695 | self.out_group = out_group |
| 2696 | else: |
| 2697 | self.out_group = 0 |
| 2698 | if flags != None: |
| 2699 | self.flags = flags |
| 2700 | else: |
| 2701 | self.flags = 0 |
| 2702 | if match != None: |
| 2703 | self.match = match |
| 2704 | else: |
| 2705 | self.match = common.match() |
| 2706 | if instructions != None: |
| 2707 | self.instructions = instructions |
| 2708 | else: |
| 2709 | self.instructions = [] |
| 2710 | |
| 2711 | def pack(self): |
| 2712 | packed = [] |
| 2713 | packed.append(struct.pack("!B", self.version)) |
| 2714 | packed.append(struct.pack("!B", self.type)) |
| 2715 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2716 | packed.append(struct.pack("!L", self.xid)) |
| 2717 | packed.append(struct.pack("!Q", self.cookie)) |
| 2718 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 2719 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2720 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2721 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2722 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2723 | packed.append(struct.pack("!H", self.priority)) |
| 2724 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2725 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2726 | packed.append(struct.pack("!L", self.out_group)) |
| 2727 | packed.append(struct.pack("!H", self.flags)) |
| 2728 | packed.append('\x00' * 2) |
| 2729 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2730 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2731 | length = sum([len(x) for x in packed]) |
| 2732 | packed[2] = struct.pack("!H", length) |
| 2733 | return ''.join(packed) |
| 2734 | |
| 2735 | @staticmethod |
| 2736 | def unpack(buf): |
| 2737 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2738 | obj = flow_add() |
| 2739 | if type(buf) == loxi.generic_util.OFReader: |
| 2740 | reader = buf |
| 2741 | else: |
| 2742 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2743 | _version = reader.read("!B")[0] |
| 2744 | assert(_version == 2) |
| 2745 | _type = reader.read("!B")[0] |
| 2746 | assert(_type == 14) |
| 2747 | _length = reader.read("!H")[0] |
| 2748 | obj.xid = reader.read("!L")[0] |
| 2749 | obj.cookie = reader.read("!Q")[0] |
| 2750 | obj.cookie_mask = reader.read("!Q")[0] |
| 2751 | obj.table_id = reader.read("!B")[0] |
| 2752 | __command = util.unpack_fm_cmd(reader) |
| 2753 | assert(__command == 0) |
| 2754 | obj.idle_timeout = reader.read("!H")[0] |
| 2755 | obj.hard_timeout = reader.read("!H")[0] |
| 2756 | obj.priority = reader.read("!H")[0] |
| 2757 | obj.buffer_id = reader.read("!L")[0] |
| 2758 | obj.out_port = util.unpack_port_no(reader) |
| 2759 | obj.out_group = reader.read("!L")[0] |
| 2760 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2761 | reader.skip(2) |
| 2762 | obj.match = common.match.unpack(reader) |
| 2763 | obj.instructions = instruction.unpack_list(reader) |
| 2764 | return obj |
| 2765 | |
| 2766 | def __eq__(self, other): |
| 2767 | if type(self) != type(other): return False |
| 2768 | if self.version != other.version: return False |
| 2769 | if self.type != other.type: return False |
| 2770 | if self.xid != other.xid: return False |
| 2771 | if self.cookie != other.cookie: return False |
| 2772 | if self.cookie_mask != other.cookie_mask: return False |
| 2773 | if self.table_id != other.table_id: return False |
| 2774 | if self.idle_timeout != other.idle_timeout: return False |
| 2775 | if self.hard_timeout != other.hard_timeout: return False |
| 2776 | if self.priority != other.priority: return False |
| 2777 | if self.buffer_id != other.buffer_id: return False |
| 2778 | if self.out_port != other.out_port: return False |
| 2779 | if self.out_group != other.out_group: return False |
| 2780 | if self.flags != other.flags: return False |
| 2781 | if self.match != other.match: return False |
| 2782 | if self.instructions != other.instructions: return False |
| 2783 | return True |
| 2784 | |
| 2785 | def __ne__(self, other): |
| 2786 | return not self.__eq__(other) |
| 2787 | |
| 2788 | def __str__(self): |
| 2789 | return self.show() |
| 2790 | |
| 2791 | def show(self): |
| 2792 | import loxi.pp |
| 2793 | return loxi.pp.pp(self) |
| 2794 | |
| 2795 | def pretty_print(self, q): |
| 2796 | q.text("flow_add {") |
| 2797 | with q.group(): |
| 2798 | with q.indent(2): |
| 2799 | q.breakable() |
| 2800 | q.text("xid = "); |
| 2801 | if self.xid != None: |
| 2802 | q.text("%#x" % self.xid) |
| 2803 | else: |
| 2804 | q.text('None') |
| 2805 | q.text(","); q.breakable() |
| 2806 | q.text("cookie = "); |
| 2807 | q.text("%#x" % self.cookie) |
| 2808 | q.text(","); q.breakable() |
| 2809 | q.text("cookie_mask = "); |
| 2810 | q.text("%#x" % self.cookie_mask) |
| 2811 | q.text(","); q.breakable() |
| 2812 | q.text("table_id = "); |
| 2813 | q.text("%#x" % self.table_id) |
| 2814 | q.text(","); q.breakable() |
| 2815 | q.text("idle_timeout = "); |
| 2816 | q.text("%#x" % self.idle_timeout) |
| 2817 | q.text(","); q.breakable() |
| 2818 | q.text("hard_timeout = "); |
| 2819 | q.text("%#x" % self.hard_timeout) |
| 2820 | q.text(","); q.breakable() |
| 2821 | q.text("priority = "); |
| 2822 | q.text("%#x" % self.priority) |
| 2823 | q.text(","); q.breakable() |
| 2824 | q.text("buffer_id = "); |
| 2825 | q.text("%#x" % self.buffer_id) |
| 2826 | q.text(","); q.breakable() |
| 2827 | q.text("out_port = "); |
| 2828 | q.text(util.pretty_port(self.out_port)) |
| 2829 | q.text(","); q.breakable() |
| 2830 | q.text("out_group = "); |
| 2831 | q.text("%#x" % self.out_group) |
| 2832 | q.text(","); q.breakable() |
| 2833 | q.text("flags = "); |
| 2834 | q.text("%#x" % self.flags) |
| 2835 | q.text(","); q.breakable() |
| 2836 | q.text("match = "); |
| 2837 | q.pp(self.match) |
| 2838 | q.text(","); q.breakable() |
| 2839 | q.text("instructions = "); |
| 2840 | q.pp(self.instructions) |
| 2841 | q.breakable() |
| 2842 | q.text('}') |
| 2843 | |
| 2844 | class flow_delete(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2845 | version = 2 |
| 2846 | type = 14 |
| 2847 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2848 | |
| 2849 | 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): |
| 2850 | self.xid = xid |
| 2851 | if cookie != None: |
| 2852 | self.cookie = cookie |
| 2853 | else: |
| 2854 | self.cookie = 0 |
| 2855 | if cookie_mask != None: |
| 2856 | self.cookie_mask = cookie_mask |
| 2857 | else: |
| 2858 | self.cookie_mask = 0 |
| 2859 | if table_id != None: |
| 2860 | self.table_id = table_id |
| 2861 | else: |
| 2862 | self.table_id = 0 |
| 2863 | if idle_timeout != None: |
| 2864 | self.idle_timeout = idle_timeout |
| 2865 | else: |
| 2866 | self.idle_timeout = 0 |
| 2867 | if hard_timeout != None: |
| 2868 | self.hard_timeout = hard_timeout |
| 2869 | else: |
| 2870 | self.hard_timeout = 0 |
| 2871 | if priority != None: |
| 2872 | self.priority = priority |
| 2873 | else: |
| 2874 | self.priority = 0 |
| 2875 | if buffer_id != None: |
| 2876 | self.buffer_id = buffer_id |
| 2877 | else: |
| 2878 | self.buffer_id = 0 |
| 2879 | if out_port != None: |
| 2880 | self.out_port = out_port |
| 2881 | else: |
| 2882 | self.out_port = 0 |
| 2883 | if out_group != None: |
| 2884 | self.out_group = out_group |
| 2885 | else: |
| 2886 | self.out_group = 0 |
| 2887 | if flags != None: |
| 2888 | self.flags = flags |
| 2889 | else: |
| 2890 | self.flags = 0 |
| 2891 | if match != None: |
| 2892 | self.match = match |
| 2893 | else: |
| 2894 | self.match = common.match() |
| 2895 | if instructions != None: |
| 2896 | self.instructions = instructions |
| 2897 | else: |
| 2898 | self.instructions = [] |
| 2899 | |
| 2900 | def pack(self): |
| 2901 | packed = [] |
| 2902 | packed.append(struct.pack("!B", self.version)) |
| 2903 | packed.append(struct.pack("!B", self.type)) |
| 2904 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2905 | packed.append(struct.pack("!L", self.xid)) |
| 2906 | packed.append(struct.pack("!Q", self.cookie)) |
| 2907 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 2908 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2909 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2910 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2911 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2912 | packed.append(struct.pack("!H", self.priority)) |
| 2913 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2914 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2915 | packed.append(struct.pack("!L", self.out_group)) |
| 2916 | packed.append(struct.pack("!H", self.flags)) |
| 2917 | packed.append('\x00' * 2) |
| 2918 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2919 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2920 | length = sum([len(x) for x in packed]) |
| 2921 | packed[2] = struct.pack("!H", length) |
| 2922 | return ''.join(packed) |
| 2923 | |
| 2924 | @staticmethod |
| 2925 | def unpack(buf): |
| 2926 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2927 | obj = flow_delete() |
| 2928 | if type(buf) == loxi.generic_util.OFReader: |
| 2929 | reader = buf |
| 2930 | else: |
| 2931 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2932 | _version = reader.read("!B")[0] |
| 2933 | assert(_version == 2) |
| 2934 | _type = reader.read("!B")[0] |
| 2935 | assert(_type == 14) |
| 2936 | _length = reader.read("!H")[0] |
| 2937 | obj.xid = reader.read("!L")[0] |
| 2938 | obj.cookie = reader.read("!Q")[0] |
| 2939 | obj.cookie_mask = reader.read("!Q")[0] |
| 2940 | obj.table_id = reader.read("!B")[0] |
| 2941 | __command = util.unpack_fm_cmd(reader) |
| 2942 | assert(__command == 3) |
| 2943 | obj.idle_timeout = reader.read("!H")[0] |
| 2944 | obj.hard_timeout = reader.read("!H")[0] |
| 2945 | obj.priority = reader.read("!H")[0] |
| 2946 | obj.buffer_id = reader.read("!L")[0] |
| 2947 | obj.out_port = util.unpack_port_no(reader) |
| 2948 | obj.out_group = reader.read("!L")[0] |
| 2949 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2950 | reader.skip(2) |
| 2951 | obj.match = common.match.unpack(reader) |
| 2952 | obj.instructions = instruction.unpack_list(reader) |
| 2953 | return obj |
| 2954 | |
| 2955 | def __eq__(self, other): |
| 2956 | if type(self) != type(other): return False |
| 2957 | if self.version != other.version: return False |
| 2958 | if self.type != other.type: return False |
| 2959 | if self.xid != other.xid: return False |
| 2960 | if self.cookie != other.cookie: return False |
| 2961 | if self.cookie_mask != other.cookie_mask: return False |
| 2962 | if self.table_id != other.table_id: return False |
| 2963 | if self.idle_timeout != other.idle_timeout: return False |
| 2964 | if self.hard_timeout != other.hard_timeout: return False |
| 2965 | if self.priority != other.priority: return False |
| 2966 | if self.buffer_id != other.buffer_id: return False |
| 2967 | if self.out_port != other.out_port: return False |
| 2968 | if self.out_group != other.out_group: return False |
| 2969 | if self.flags != other.flags: return False |
| 2970 | if self.match != other.match: return False |
| 2971 | if self.instructions != other.instructions: return False |
| 2972 | return True |
| 2973 | |
| 2974 | def __ne__(self, other): |
| 2975 | return not self.__eq__(other) |
| 2976 | |
| 2977 | def __str__(self): |
| 2978 | return self.show() |
| 2979 | |
| 2980 | def show(self): |
| 2981 | import loxi.pp |
| 2982 | return loxi.pp.pp(self) |
| 2983 | |
| 2984 | def pretty_print(self, q): |
| 2985 | q.text("flow_delete {") |
| 2986 | with q.group(): |
| 2987 | with q.indent(2): |
| 2988 | q.breakable() |
| 2989 | q.text("xid = "); |
| 2990 | if self.xid != None: |
| 2991 | q.text("%#x" % self.xid) |
| 2992 | else: |
| 2993 | q.text('None') |
| 2994 | q.text(","); q.breakable() |
| 2995 | q.text("cookie = "); |
| 2996 | q.text("%#x" % self.cookie) |
| 2997 | q.text(","); q.breakable() |
| 2998 | q.text("cookie_mask = "); |
| 2999 | q.text("%#x" % self.cookie_mask) |
| 3000 | q.text(","); q.breakable() |
| 3001 | q.text("table_id = "); |
| 3002 | q.text("%#x" % self.table_id) |
| 3003 | q.text(","); q.breakable() |
| 3004 | q.text("idle_timeout = "); |
| 3005 | q.text("%#x" % self.idle_timeout) |
| 3006 | q.text(","); q.breakable() |
| 3007 | q.text("hard_timeout = "); |
| 3008 | q.text("%#x" % self.hard_timeout) |
| 3009 | q.text(","); q.breakable() |
| 3010 | q.text("priority = "); |
| 3011 | q.text("%#x" % self.priority) |
| 3012 | q.text(","); q.breakable() |
| 3013 | q.text("buffer_id = "); |
| 3014 | q.text("%#x" % self.buffer_id) |
| 3015 | q.text(","); q.breakable() |
| 3016 | q.text("out_port = "); |
| 3017 | q.text(util.pretty_port(self.out_port)) |
| 3018 | q.text(","); q.breakable() |
| 3019 | q.text("out_group = "); |
| 3020 | q.text("%#x" % self.out_group) |
| 3021 | q.text(","); q.breakable() |
| 3022 | q.text("flags = "); |
| 3023 | q.text("%#x" % self.flags) |
| 3024 | q.text(","); q.breakable() |
| 3025 | q.text("match = "); |
| 3026 | q.pp(self.match) |
| 3027 | q.text(","); q.breakable() |
| 3028 | q.text("instructions = "); |
| 3029 | q.pp(self.instructions) |
| 3030 | q.breakable() |
| 3031 | q.text('}') |
| 3032 | |
| 3033 | class flow_delete_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3034 | version = 2 |
| 3035 | type = 14 |
| 3036 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3037 | |
| 3038 | 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): |
| 3039 | self.xid = xid |
| 3040 | if cookie != None: |
| 3041 | self.cookie = cookie |
| 3042 | else: |
| 3043 | self.cookie = 0 |
| 3044 | if cookie_mask != None: |
| 3045 | self.cookie_mask = cookie_mask |
| 3046 | else: |
| 3047 | self.cookie_mask = 0 |
| 3048 | if table_id != None: |
| 3049 | self.table_id = table_id |
| 3050 | else: |
| 3051 | self.table_id = 0 |
| 3052 | if idle_timeout != None: |
| 3053 | self.idle_timeout = idle_timeout |
| 3054 | else: |
| 3055 | self.idle_timeout = 0 |
| 3056 | if hard_timeout != None: |
| 3057 | self.hard_timeout = hard_timeout |
| 3058 | else: |
| 3059 | self.hard_timeout = 0 |
| 3060 | if priority != None: |
| 3061 | self.priority = priority |
| 3062 | else: |
| 3063 | self.priority = 0 |
| 3064 | if buffer_id != None: |
| 3065 | self.buffer_id = buffer_id |
| 3066 | else: |
| 3067 | self.buffer_id = 0 |
| 3068 | if out_port != None: |
| 3069 | self.out_port = out_port |
| 3070 | else: |
| 3071 | self.out_port = 0 |
| 3072 | if out_group != None: |
| 3073 | self.out_group = out_group |
| 3074 | else: |
| 3075 | self.out_group = 0 |
| 3076 | if flags != None: |
| 3077 | self.flags = flags |
| 3078 | else: |
| 3079 | self.flags = 0 |
| 3080 | if match != None: |
| 3081 | self.match = match |
| 3082 | else: |
| 3083 | self.match = common.match() |
| 3084 | if instructions != None: |
| 3085 | self.instructions = instructions |
| 3086 | else: |
| 3087 | self.instructions = [] |
| 3088 | |
| 3089 | def pack(self): |
| 3090 | packed = [] |
| 3091 | packed.append(struct.pack("!B", self.version)) |
| 3092 | packed.append(struct.pack("!B", self.type)) |
| 3093 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3094 | packed.append(struct.pack("!L", self.xid)) |
| 3095 | packed.append(struct.pack("!Q", self.cookie)) |
| 3096 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3097 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3098 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3099 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3100 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3101 | packed.append(struct.pack("!H", self.priority)) |
| 3102 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3103 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3104 | packed.append(struct.pack("!L", self.out_group)) |
| 3105 | packed.append(struct.pack("!H", self.flags)) |
| 3106 | packed.append('\x00' * 2) |
| 3107 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3108 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3109 | length = sum([len(x) for x in packed]) |
| 3110 | packed[2] = struct.pack("!H", length) |
| 3111 | return ''.join(packed) |
| 3112 | |
| 3113 | @staticmethod |
| 3114 | def unpack(buf): |
| 3115 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3116 | obj = flow_delete_strict() |
| 3117 | if type(buf) == loxi.generic_util.OFReader: |
| 3118 | reader = buf |
| 3119 | else: |
| 3120 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3121 | _version = reader.read("!B")[0] |
| 3122 | assert(_version == 2) |
| 3123 | _type = reader.read("!B")[0] |
| 3124 | assert(_type == 14) |
| 3125 | _length = reader.read("!H")[0] |
| 3126 | obj.xid = reader.read("!L")[0] |
| 3127 | obj.cookie = reader.read("!Q")[0] |
| 3128 | obj.cookie_mask = reader.read("!Q")[0] |
| 3129 | obj.table_id = reader.read("!B")[0] |
| 3130 | __command = util.unpack_fm_cmd(reader) |
| 3131 | assert(__command == 4) |
| 3132 | obj.idle_timeout = reader.read("!H")[0] |
| 3133 | obj.hard_timeout = reader.read("!H")[0] |
| 3134 | obj.priority = reader.read("!H")[0] |
| 3135 | obj.buffer_id = reader.read("!L")[0] |
| 3136 | obj.out_port = util.unpack_port_no(reader) |
| 3137 | obj.out_group = reader.read("!L")[0] |
| 3138 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3139 | reader.skip(2) |
| 3140 | obj.match = common.match.unpack(reader) |
| 3141 | obj.instructions = instruction.unpack_list(reader) |
| 3142 | return obj |
| 3143 | |
| 3144 | def __eq__(self, other): |
| 3145 | if type(self) != type(other): return False |
| 3146 | if self.version != other.version: return False |
| 3147 | if self.type != other.type: return False |
| 3148 | if self.xid != other.xid: return False |
| 3149 | if self.cookie != other.cookie: return False |
| 3150 | if self.cookie_mask != other.cookie_mask: return False |
| 3151 | if self.table_id != other.table_id: return False |
| 3152 | if self.idle_timeout != other.idle_timeout: return False |
| 3153 | if self.hard_timeout != other.hard_timeout: return False |
| 3154 | if self.priority != other.priority: return False |
| 3155 | if self.buffer_id != other.buffer_id: return False |
| 3156 | if self.out_port != other.out_port: return False |
| 3157 | if self.out_group != other.out_group: return False |
| 3158 | if self.flags != other.flags: return False |
| 3159 | if self.match != other.match: return False |
| 3160 | if self.instructions != other.instructions: return False |
| 3161 | return True |
| 3162 | |
| 3163 | def __ne__(self, other): |
| 3164 | return not self.__eq__(other) |
| 3165 | |
| 3166 | def __str__(self): |
| 3167 | return self.show() |
| 3168 | |
| 3169 | def show(self): |
| 3170 | import loxi.pp |
| 3171 | return loxi.pp.pp(self) |
| 3172 | |
| 3173 | def pretty_print(self, q): |
| 3174 | q.text("flow_delete_strict {") |
| 3175 | with q.group(): |
| 3176 | with q.indent(2): |
| 3177 | q.breakable() |
| 3178 | q.text("xid = "); |
| 3179 | if self.xid != None: |
| 3180 | q.text("%#x" % self.xid) |
| 3181 | else: |
| 3182 | q.text('None') |
| 3183 | q.text(","); q.breakable() |
| 3184 | q.text("cookie = "); |
| 3185 | q.text("%#x" % self.cookie) |
| 3186 | q.text(","); q.breakable() |
| 3187 | q.text("cookie_mask = "); |
| 3188 | q.text("%#x" % self.cookie_mask) |
| 3189 | q.text(","); q.breakable() |
| 3190 | q.text("table_id = "); |
| 3191 | q.text("%#x" % self.table_id) |
| 3192 | q.text(","); q.breakable() |
| 3193 | q.text("idle_timeout = "); |
| 3194 | q.text("%#x" % self.idle_timeout) |
| 3195 | q.text(","); q.breakable() |
| 3196 | q.text("hard_timeout = "); |
| 3197 | q.text("%#x" % self.hard_timeout) |
| 3198 | q.text(","); q.breakable() |
| 3199 | q.text("priority = "); |
| 3200 | q.text("%#x" % self.priority) |
| 3201 | q.text(","); q.breakable() |
| 3202 | q.text("buffer_id = "); |
| 3203 | q.text("%#x" % self.buffer_id) |
| 3204 | q.text(","); q.breakable() |
| 3205 | q.text("out_port = "); |
| 3206 | q.text(util.pretty_port(self.out_port)) |
| 3207 | q.text(","); q.breakable() |
| 3208 | q.text("out_group = "); |
| 3209 | q.text("%#x" % self.out_group) |
| 3210 | q.text(","); q.breakable() |
| 3211 | q.text("flags = "); |
| 3212 | q.text("%#x" % self.flags) |
| 3213 | q.text(","); q.breakable() |
| 3214 | q.text("match = "); |
| 3215 | q.pp(self.match) |
| 3216 | q.text(","); q.breakable() |
| 3217 | q.text("instructions = "); |
| 3218 | q.pp(self.instructions) |
| 3219 | q.breakable() |
| 3220 | q.text('}') |
| 3221 | |
| 3222 | class flow_modify(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3223 | version = 2 |
| 3224 | type = 14 |
| 3225 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3226 | |
| 3227 | 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): |
| 3228 | self.xid = xid |
| 3229 | if cookie != None: |
| 3230 | self.cookie = cookie |
| 3231 | else: |
| 3232 | self.cookie = 0 |
| 3233 | if cookie_mask != None: |
| 3234 | self.cookie_mask = cookie_mask |
| 3235 | else: |
| 3236 | self.cookie_mask = 0 |
| 3237 | if table_id != None: |
| 3238 | self.table_id = table_id |
| 3239 | else: |
| 3240 | self.table_id = 0 |
| 3241 | if idle_timeout != None: |
| 3242 | self.idle_timeout = idle_timeout |
| 3243 | else: |
| 3244 | self.idle_timeout = 0 |
| 3245 | if hard_timeout != None: |
| 3246 | self.hard_timeout = hard_timeout |
| 3247 | else: |
| 3248 | self.hard_timeout = 0 |
| 3249 | if priority != None: |
| 3250 | self.priority = priority |
| 3251 | else: |
| 3252 | self.priority = 0 |
| 3253 | if buffer_id != None: |
| 3254 | self.buffer_id = buffer_id |
| 3255 | else: |
| 3256 | self.buffer_id = 0 |
| 3257 | if out_port != None: |
| 3258 | self.out_port = out_port |
| 3259 | else: |
| 3260 | self.out_port = 0 |
| 3261 | if out_group != None: |
| 3262 | self.out_group = out_group |
| 3263 | else: |
| 3264 | self.out_group = 0 |
| 3265 | if flags != None: |
| 3266 | self.flags = flags |
| 3267 | else: |
| 3268 | self.flags = 0 |
| 3269 | if match != None: |
| 3270 | self.match = match |
| 3271 | else: |
| 3272 | self.match = common.match() |
| 3273 | if instructions != None: |
| 3274 | self.instructions = instructions |
| 3275 | else: |
| 3276 | self.instructions = [] |
| 3277 | |
| 3278 | def pack(self): |
| 3279 | packed = [] |
| 3280 | packed.append(struct.pack("!B", self.version)) |
| 3281 | packed.append(struct.pack("!B", self.type)) |
| 3282 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3283 | packed.append(struct.pack("!L", self.xid)) |
| 3284 | packed.append(struct.pack("!Q", self.cookie)) |
| 3285 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3286 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3287 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3288 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3289 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3290 | packed.append(struct.pack("!H", self.priority)) |
| 3291 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3292 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3293 | packed.append(struct.pack("!L", self.out_group)) |
| 3294 | packed.append(struct.pack("!H", self.flags)) |
| 3295 | packed.append('\x00' * 2) |
| 3296 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3297 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3298 | length = sum([len(x) for x in packed]) |
| 3299 | packed[2] = struct.pack("!H", length) |
| 3300 | return ''.join(packed) |
| 3301 | |
| 3302 | @staticmethod |
| 3303 | def unpack(buf): |
| 3304 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3305 | obj = flow_modify() |
| 3306 | if type(buf) == loxi.generic_util.OFReader: |
| 3307 | reader = buf |
| 3308 | else: |
| 3309 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3310 | _version = reader.read("!B")[0] |
| 3311 | assert(_version == 2) |
| 3312 | _type = reader.read("!B")[0] |
| 3313 | assert(_type == 14) |
| 3314 | _length = reader.read("!H")[0] |
| 3315 | obj.xid = reader.read("!L")[0] |
| 3316 | obj.cookie = reader.read("!Q")[0] |
| 3317 | obj.cookie_mask = reader.read("!Q")[0] |
| 3318 | obj.table_id = reader.read("!B")[0] |
| 3319 | __command = util.unpack_fm_cmd(reader) |
| 3320 | assert(__command == 1) |
| 3321 | obj.idle_timeout = reader.read("!H")[0] |
| 3322 | obj.hard_timeout = reader.read("!H")[0] |
| 3323 | obj.priority = reader.read("!H")[0] |
| 3324 | obj.buffer_id = reader.read("!L")[0] |
| 3325 | obj.out_port = util.unpack_port_no(reader) |
| 3326 | obj.out_group = reader.read("!L")[0] |
| 3327 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3328 | reader.skip(2) |
| 3329 | obj.match = common.match.unpack(reader) |
| 3330 | obj.instructions = instruction.unpack_list(reader) |
| 3331 | return obj |
| 3332 | |
| 3333 | def __eq__(self, other): |
| 3334 | if type(self) != type(other): return False |
| 3335 | if self.version != other.version: return False |
| 3336 | if self.type != other.type: return False |
| 3337 | if self.xid != other.xid: return False |
| 3338 | if self.cookie != other.cookie: return False |
| 3339 | if self.cookie_mask != other.cookie_mask: return False |
| 3340 | if self.table_id != other.table_id: return False |
| 3341 | if self.idle_timeout != other.idle_timeout: return False |
| 3342 | if self.hard_timeout != other.hard_timeout: return False |
| 3343 | if self.priority != other.priority: return False |
| 3344 | if self.buffer_id != other.buffer_id: return False |
| 3345 | if self.out_port != other.out_port: return False |
| 3346 | if self.out_group != other.out_group: return False |
| 3347 | if self.flags != other.flags: return False |
| 3348 | if self.match != other.match: return False |
| 3349 | if self.instructions != other.instructions: return False |
| 3350 | return True |
| 3351 | |
| 3352 | def __ne__(self, other): |
| 3353 | return not self.__eq__(other) |
| 3354 | |
| 3355 | def __str__(self): |
| 3356 | return self.show() |
| 3357 | |
| 3358 | def show(self): |
| 3359 | import loxi.pp |
| 3360 | return loxi.pp.pp(self) |
| 3361 | |
| 3362 | def pretty_print(self, q): |
| 3363 | q.text("flow_modify {") |
| 3364 | with q.group(): |
| 3365 | with q.indent(2): |
| 3366 | q.breakable() |
| 3367 | q.text("xid = "); |
| 3368 | if self.xid != None: |
| 3369 | q.text("%#x" % self.xid) |
| 3370 | else: |
| 3371 | q.text('None') |
| 3372 | q.text(","); q.breakable() |
| 3373 | q.text("cookie = "); |
| 3374 | q.text("%#x" % self.cookie) |
| 3375 | q.text(","); q.breakable() |
| 3376 | q.text("cookie_mask = "); |
| 3377 | q.text("%#x" % self.cookie_mask) |
| 3378 | q.text(","); q.breakable() |
| 3379 | q.text("table_id = "); |
| 3380 | q.text("%#x" % self.table_id) |
| 3381 | q.text(","); q.breakable() |
| 3382 | q.text("idle_timeout = "); |
| 3383 | q.text("%#x" % self.idle_timeout) |
| 3384 | q.text(","); q.breakable() |
| 3385 | q.text("hard_timeout = "); |
| 3386 | q.text("%#x" % self.hard_timeout) |
| 3387 | q.text(","); q.breakable() |
| 3388 | q.text("priority = "); |
| 3389 | q.text("%#x" % self.priority) |
| 3390 | q.text(","); q.breakable() |
| 3391 | q.text("buffer_id = "); |
| 3392 | q.text("%#x" % self.buffer_id) |
| 3393 | q.text(","); q.breakable() |
| 3394 | q.text("out_port = "); |
| 3395 | q.text(util.pretty_port(self.out_port)) |
| 3396 | q.text(","); q.breakable() |
| 3397 | q.text("out_group = "); |
| 3398 | q.text("%#x" % self.out_group) |
| 3399 | q.text(","); q.breakable() |
| 3400 | q.text("flags = "); |
| 3401 | q.text("%#x" % self.flags) |
| 3402 | q.text(","); q.breakable() |
| 3403 | q.text("match = "); |
| 3404 | q.pp(self.match) |
| 3405 | q.text(","); q.breakable() |
| 3406 | q.text("instructions = "); |
| 3407 | q.pp(self.instructions) |
| 3408 | q.breakable() |
| 3409 | q.text('}') |
| 3410 | |
| 3411 | class flow_modify_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3412 | version = 2 |
| 3413 | type = 14 |
| 3414 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3415 | |
| 3416 | 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): |
| 3417 | self.xid = xid |
| 3418 | if cookie != None: |
| 3419 | self.cookie = cookie |
| 3420 | else: |
| 3421 | self.cookie = 0 |
| 3422 | if cookie_mask != None: |
| 3423 | self.cookie_mask = cookie_mask |
| 3424 | else: |
| 3425 | self.cookie_mask = 0 |
| 3426 | if table_id != None: |
| 3427 | self.table_id = table_id |
| 3428 | else: |
| 3429 | self.table_id = 0 |
| 3430 | if idle_timeout != None: |
| 3431 | self.idle_timeout = idle_timeout |
| 3432 | else: |
| 3433 | self.idle_timeout = 0 |
| 3434 | if hard_timeout != None: |
| 3435 | self.hard_timeout = hard_timeout |
| 3436 | else: |
| 3437 | self.hard_timeout = 0 |
| 3438 | if priority != None: |
| 3439 | self.priority = priority |
| 3440 | else: |
| 3441 | self.priority = 0 |
| 3442 | if buffer_id != None: |
| 3443 | self.buffer_id = buffer_id |
| 3444 | else: |
| 3445 | self.buffer_id = 0 |
| 3446 | if out_port != None: |
| 3447 | self.out_port = out_port |
| 3448 | else: |
| 3449 | self.out_port = 0 |
| 3450 | if out_group != None: |
| 3451 | self.out_group = out_group |
| 3452 | else: |
| 3453 | self.out_group = 0 |
| 3454 | if flags != None: |
| 3455 | self.flags = flags |
| 3456 | else: |
| 3457 | self.flags = 0 |
| 3458 | if match != None: |
| 3459 | self.match = match |
| 3460 | else: |
| 3461 | self.match = common.match() |
| 3462 | if instructions != None: |
| 3463 | self.instructions = instructions |
| 3464 | else: |
| 3465 | self.instructions = [] |
| 3466 | |
| 3467 | def pack(self): |
| 3468 | packed = [] |
| 3469 | packed.append(struct.pack("!B", self.version)) |
| 3470 | packed.append(struct.pack("!B", self.type)) |
| 3471 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3472 | packed.append(struct.pack("!L", self.xid)) |
| 3473 | packed.append(struct.pack("!Q", self.cookie)) |
| 3474 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3475 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3476 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3477 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3478 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3479 | packed.append(struct.pack("!H", self.priority)) |
| 3480 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3481 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3482 | packed.append(struct.pack("!L", self.out_group)) |
| 3483 | packed.append(struct.pack("!H", self.flags)) |
| 3484 | packed.append('\x00' * 2) |
| 3485 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3486 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3487 | length = sum([len(x) for x in packed]) |
| 3488 | packed[2] = struct.pack("!H", length) |
| 3489 | return ''.join(packed) |
| 3490 | |
| 3491 | @staticmethod |
| 3492 | def unpack(buf): |
| 3493 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3494 | obj = flow_modify_strict() |
| 3495 | if type(buf) == loxi.generic_util.OFReader: |
| 3496 | reader = buf |
| 3497 | else: |
| 3498 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3499 | _version = reader.read("!B")[0] |
| 3500 | assert(_version == 2) |
| 3501 | _type = reader.read("!B")[0] |
| 3502 | assert(_type == 14) |
| 3503 | _length = reader.read("!H")[0] |
| 3504 | obj.xid = reader.read("!L")[0] |
| 3505 | obj.cookie = reader.read("!Q")[0] |
| 3506 | obj.cookie_mask = reader.read("!Q")[0] |
| 3507 | obj.table_id = reader.read("!B")[0] |
| 3508 | __command = util.unpack_fm_cmd(reader) |
| 3509 | assert(__command == 2) |
| 3510 | obj.idle_timeout = reader.read("!H")[0] |
| 3511 | obj.hard_timeout = reader.read("!H")[0] |
| 3512 | obj.priority = reader.read("!H")[0] |
| 3513 | obj.buffer_id = reader.read("!L")[0] |
| 3514 | obj.out_port = util.unpack_port_no(reader) |
| 3515 | obj.out_group = reader.read("!L")[0] |
| 3516 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3517 | reader.skip(2) |
| 3518 | obj.match = common.match.unpack(reader) |
| 3519 | obj.instructions = instruction.unpack_list(reader) |
| 3520 | return obj |
| 3521 | |
| 3522 | def __eq__(self, other): |
| 3523 | if type(self) != type(other): return False |
| 3524 | if self.version != other.version: return False |
| 3525 | if self.type != other.type: return False |
| 3526 | if self.xid != other.xid: return False |
| 3527 | if self.cookie != other.cookie: return False |
| 3528 | if self.cookie_mask != other.cookie_mask: return False |
| 3529 | if self.table_id != other.table_id: return False |
| 3530 | if self.idle_timeout != other.idle_timeout: return False |
| 3531 | if self.hard_timeout != other.hard_timeout: return False |
| 3532 | if self.priority != other.priority: return False |
| 3533 | if self.buffer_id != other.buffer_id: return False |
| 3534 | if self.out_port != other.out_port: return False |
| 3535 | if self.out_group != other.out_group: return False |
| 3536 | if self.flags != other.flags: return False |
| 3537 | if self.match != other.match: return False |
| 3538 | if self.instructions != other.instructions: return False |
| 3539 | return True |
| 3540 | |
| 3541 | def __ne__(self, other): |
| 3542 | return not self.__eq__(other) |
| 3543 | |
| 3544 | def __str__(self): |
| 3545 | return self.show() |
| 3546 | |
| 3547 | def show(self): |
| 3548 | import loxi.pp |
| 3549 | return loxi.pp.pp(self) |
| 3550 | |
| 3551 | def pretty_print(self, q): |
| 3552 | q.text("flow_modify_strict {") |
| 3553 | with q.group(): |
| 3554 | with q.indent(2): |
| 3555 | q.breakable() |
| 3556 | q.text("xid = "); |
| 3557 | if self.xid != None: |
| 3558 | q.text("%#x" % self.xid) |
| 3559 | else: |
| 3560 | q.text('None') |
| 3561 | q.text(","); q.breakable() |
| 3562 | q.text("cookie = "); |
| 3563 | q.text("%#x" % self.cookie) |
| 3564 | q.text(","); q.breakable() |
| 3565 | q.text("cookie_mask = "); |
| 3566 | q.text("%#x" % self.cookie_mask) |
| 3567 | q.text(","); q.breakable() |
| 3568 | q.text("table_id = "); |
| 3569 | q.text("%#x" % self.table_id) |
| 3570 | q.text(","); q.breakable() |
| 3571 | q.text("idle_timeout = "); |
| 3572 | q.text("%#x" % self.idle_timeout) |
| 3573 | q.text(","); q.breakable() |
| 3574 | q.text("hard_timeout = "); |
| 3575 | q.text("%#x" % self.hard_timeout) |
| 3576 | q.text(","); q.breakable() |
| 3577 | q.text("priority = "); |
| 3578 | q.text("%#x" % self.priority) |
| 3579 | q.text(","); q.breakable() |
| 3580 | q.text("buffer_id = "); |
| 3581 | q.text("%#x" % self.buffer_id) |
| 3582 | q.text(","); q.breakable() |
| 3583 | q.text("out_port = "); |
| 3584 | q.text(util.pretty_port(self.out_port)) |
| 3585 | q.text(","); q.breakable() |
| 3586 | q.text("out_group = "); |
| 3587 | q.text("%#x" % self.out_group) |
| 3588 | q.text(","); q.breakable() |
| 3589 | q.text("flags = "); |
| 3590 | q.text("%#x" % self.flags) |
| 3591 | q.text(","); q.breakable() |
| 3592 | q.text("match = "); |
| 3593 | q.pp(self.match) |
| 3594 | q.text(","); q.breakable() |
| 3595 | q.text("instructions = "); |
| 3596 | q.pp(self.instructions) |
| 3597 | q.breakable() |
| 3598 | q.text('}') |
| 3599 | |
| 3600 | class flow_removed(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3601 | version = 2 |
| 3602 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3603 | |
| 3604 | 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): |
| 3605 | self.xid = xid |
| 3606 | if cookie != None: |
| 3607 | self.cookie = cookie |
| 3608 | else: |
| 3609 | self.cookie = 0 |
| 3610 | if priority != None: |
| 3611 | self.priority = priority |
| 3612 | else: |
| 3613 | self.priority = 0 |
| 3614 | if reason != None: |
| 3615 | self.reason = reason |
| 3616 | else: |
| 3617 | self.reason = 0 |
| 3618 | if table_id != None: |
| 3619 | self.table_id = table_id |
| 3620 | else: |
| 3621 | self.table_id = 0 |
| 3622 | if duration_sec != None: |
| 3623 | self.duration_sec = duration_sec |
| 3624 | else: |
| 3625 | self.duration_sec = 0 |
| 3626 | if duration_nsec != None: |
| 3627 | self.duration_nsec = duration_nsec |
| 3628 | else: |
| 3629 | self.duration_nsec = 0 |
| 3630 | if idle_timeout != None: |
| 3631 | self.idle_timeout = idle_timeout |
| 3632 | else: |
| 3633 | self.idle_timeout = 0 |
| 3634 | if packet_count != None: |
| 3635 | self.packet_count = packet_count |
| 3636 | else: |
| 3637 | self.packet_count = 0 |
| 3638 | if byte_count != None: |
| 3639 | self.byte_count = byte_count |
| 3640 | else: |
| 3641 | self.byte_count = 0 |
| 3642 | if match != None: |
| 3643 | self.match = match |
| 3644 | else: |
| 3645 | self.match = common.match() |
| 3646 | |
| 3647 | def pack(self): |
| 3648 | packed = [] |
| 3649 | packed.append(struct.pack("!B", self.version)) |
| 3650 | packed.append(struct.pack("!B", self.type)) |
| 3651 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3652 | packed.append(struct.pack("!L", self.xid)) |
| 3653 | packed.append(struct.pack("!Q", self.cookie)) |
| 3654 | packed.append(struct.pack("!H", self.priority)) |
| 3655 | packed.append(struct.pack("!B", self.reason)) |
| 3656 | packed.append(struct.pack("!B", self.table_id)) |
| 3657 | packed.append(struct.pack("!L", self.duration_sec)) |
| 3658 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 3659 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3660 | packed.append('\x00' * 2) |
| 3661 | packed.append(struct.pack("!Q", self.packet_count)) |
| 3662 | packed.append(struct.pack("!Q", self.byte_count)) |
| 3663 | packed.append(self.match.pack()) |
| 3664 | length = sum([len(x) for x in packed]) |
| 3665 | packed[2] = struct.pack("!H", length) |
| 3666 | return ''.join(packed) |
| 3667 | |
| 3668 | @staticmethod |
| 3669 | def unpack(buf): |
| 3670 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3671 | obj = flow_removed() |
| 3672 | if type(buf) == loxi.generic_util.OFReader: |
| 3673 | reader = buf |
| 3674 | else: |
| 3675 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3676 | _version = reader.read("!B")[0] |
| 3677 | assert(_version == 2) |
| 3678 | _type = reader.read("!B")[0] |
| 3679 | assert(_type == 11) |
| 3680 | _length = reader.read("!H")[0] |
| 3681 | obj.xid = reader.read("!L")[0] |
| 3682 | obj.cookie = reader.read("!Q")[0] |
| 3683 | obj.priority = reader.read("!H")[0] |
| 3684 | obj.reason = reader.read("!B")[0] |
| 3685 | obj.table_id = reader.read("!B")[0] |
| 3686 | obj.duration_sec = reader.read("!L")[0] |
| 3687 | obj.duration_nsec = reader.read("!L")[0] |
| 3688 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3689 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3690 | obj.packet_count = reader.read("!Q")[0] |
| 3691 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3692 | obj.match = common.match.unpack(reader) |
| 3693 | return obj |
| 3694 | |
| 3695 | def __eq__(self, other): |
| 3696 | if type(self) != type(other): return False |
| 3697 | if self.version != other.version: return False |
| 3698 | if self.type != other.type: return False |
| 3699 | if self.xid != other.xid: return False |
| 3700 | if self.cookie != other.cookie: return False |
| 3701 | if self.priority != other.priority: return False |
| 3702 | if self.reason != other.reason: return False |
| 3703 | if self.table_id != other.table_id: return False |
| 3704 | if self.duration_sec != other.duration_sec: return False |
| 3705 | if self.duration_nsec != other.duration_nsec: return False |
| 3706 | if self.idle_timeout != other.idle_timeout: return False |
| 3707 | if self.packet_count != other.packet_count: return False |
| 3708 | if self.byte_count != other.byte_count: return False |
| 3709 | if self.match != other.match: return False |
| 3710 | return True |
| 3711 | |
| 3712 | def __ne__(self, other): |
| 3713 | return not self.__eq__(other) |
| 3714 | |
| 3715 | def __str__(self): |
| 3716 | return self.show() |
| 3717 | |
| 3718 | def show(self): |
| 3719 | import loxi.pp |
| 3720 | return loxi.pp.pp(self) |
| 3721 | |
| 3722 | def pretty_print(self, q): |
| 3723 | q.text("flow_removed {") |
| 3724 | with q.group(): |
| 3725 | with q.indent(2): |
| 3726 | q.breakable() |
| 3727 | q.text("xid = "); |
| 3728 | if self.xid != None: |
| 3729 | q.text("%#x" % self.xid) |
| 3730 | else: |
| 3731 | q.text('None') |
| 3732 | q.text(","); q.breakable() |
| 3733 | q.text("cookie = "); |
| 3734 | q.text("%#x" % self.cookie) |
| 3735 | q.text(","); q.breakable() |
| 3736 | q.text("priority = "); |
| 3737 | q.text("%#x" % self.priority) |
| 3738 | q.text(","); q.breakable() |
| 3739 | q.text("reason = "); |
| 3740 | q.text("%#x" % self.reason) |
| 3741 | q.text(","); q.breakable() |
| 3742 | q.text("table_id = "); |
| 3743 | q.text("%#x" % self.table_id) |
| 3744 | q.text(","); q.breakable() |
| 3745 | q.text("duration_sec = "); |
| 3746 | q.text("%#x" % self.duration_sec) |
| 3747 | q.text(","); q.breakable() |
| 3748 | q.text("duration_nsec = "); |
| 3749 | q.text("%#x" % self.duration_nsec) |
| 3750 | q.text(","); q.breakable() |
| 3751 | q.text("idle_timeout = "); |
| 3752 | q.text("%#x" % self.idle_timeout) |
| 3753 | q.text(","); q.breakable() |
| 3754 | q.text("packet_count = "); |
| 3755 | q.text("%#x" % self.packet_count) |
| 3756 | q.text(","); q.breakable() |
| 3757 | q.text("byte_count = "); |
| 3758 | q.text("%#x" % self.byte_count) |
| 3759 | q.text(","); q.breakable() |
| 3760 | q.text("match = "); |
| 3761 | q.pp(self.match) |
| 3762 | q.breakable() |
| 3763 | q.text('}') |
| 3764 | |
| 3765 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3766 | version = 2 |
| 3767 | type = 19 |
| 3768 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3769 | |
| 3770 | def __init__(self, xid=None, flags=None, entries=None): |
| 3771 | self.xid = xid |
| 3772 | if flags != None: |
| 3773 | self.flags = flags |
| 3774 | else: |
| 3775 | self.flags = 0 |
| 3776 | if entries != None: |
| 3777 | self.entries = entries |
| 3778 | else: |
| 3779 | self.entries = [] |
| 3780 | |
| 3781 | def pack(self): |
| 3782 | packed = [] |
| 3783 | packed.append(struct.pack("!B", self.version)) |
| 3784 | packed.append(struct.pack("!B", self.type)) |
| 3785 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3786 | packed.append(struct.pack("!L", self.xid)) |
| 3787 | packed.append(struct.pack("!H", self.stats_type)) |
| 3788 | packed.append(struct.pack("!H", self.flags)) |
| 3789 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3790 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3791 | length = sum([len(x) for x in packed]) |
| 3792 | packed[2] = struct.pack("!H", length) |
| 3793 | return ''.join(packed) |
| 3794 | |
| 3795 | @staticmethod |
| 3796 | def unpack(buf): |
| 3797 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3798 | obj = flow_stats_reply() |
| 3799 | if type(buf) == loxi.generic_util.OFReader: |
| 3800 | reader = buf |
| 3801 | else: |
| 3802 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3803 | _version = reader.read("!B")[0] |
| 3804 | assert(_version == 2) |
| 3805 | _type = reader.read("!B")[0] |
| 3806 | assert(_type == 19) |
| 3807 | _length = reader.read("!H")[0] |
| 3808 | obj.xid = reader.read("!L")[0] |
| 3809 | _stats_type = reader.read("!H")[0] |
| 3810 | assert(_stats_type == 1) |
| 3811 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3812 | reader.skip(4) |
| 3813 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
| 3814 | return obj |
| 3815 | |
| 3816 | def __eq__(self, other): |
| 3817 | if type(self) != type(other): return False |
| 3818 | if self.version != other.version: return False |
| 3819 | if self.type != other.type: return False |
| 3820 | if self.xid != other.xid: return False |
| 3821 | if self.flags != other.flags: return False |
| 3822 | if self.entries != other.entries: return False |
| 3823 | return True |
| 3824 | |
| 3825 | def __ne__(self, other): |
| 3826 | return not self.__eq__(other) |
| 3827 | |
| 3828 | def __str__(self): |
| 3829 | return self.show() |
| 3830 | |
| 3831 | def show(self): |
| 3832 | import loxi.pp |
| 3833 | return loxi.pp.pp(self) |
| 3834 | |
| 3835 | def pretty_print(self, q): |
| 3836 | q.text("flow_stats_reply {") |
| 3837 | with q.group(): |
| 3838 | with q.indent(2): |
| 3839 | q.breakable() |
| 3840 | q.text("xid = "); |
| 3841 | if self.xid != None: |
| 3842 | q.text("%#x" % self.xid) |
| 3843 | else: |
| 3844 | q.text('None') |
| 3845 | q.text(","); q.breakable() |
| 3846 | q.text("flags = "); |
| 3847 | q.text("%#x" % self.flags) |
| 3848 | q.text(","); q.breakable() |
| 3849 | q.text("entries = "); |
| 3850 | q.pp(self.entries) |
| 3851 | q.breakable() |
| 3852 | q.text('}') |
| 3853 | |
| 3854 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3855 | version = 2 |
| 3856 | type = 18 |
| 3857 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3858 | |
| 3859 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 3860 | self.xid = xid |
| 3861 | if flags != None: |
| 3862 | self.flags = flags |
| 3863 | else: |
| 3864 | self.flags = 0 |
| 3865 | if table_id != None: |
| 3866 | self.table_id = table_id |
| 3867 | else: |
| 3868 | self.table_id = 0 |
| 3869 | if out_port != None: |
| 3870 | self.out_port = out_port |
| 3871 | else: |
| 3872 | self.out_port = 0 |
| 3873 | if out_group != None: |
| 3874 | self.out_group = out_group |
| 3875 | else: |
| 3876 | self.out_group = 0 |
| 3877 | if cookie != None: |
| 3878 | self.cookie = cookie |
| 3879 | else: |
| 3880 | self.cookie = 0 |
| 3881 | if cookie_mask != None: |
| 3882 | self.cookie_mask = cookie_mask |
| 3883 | else: |
| 3884 | self.cookie_mask = 0 |
| 3885 | if match != None: |
| 3886 | self.match = match |
| 3887 | else: |
| 3888 | self.match = common.match() |
| 3889 | |
| 3890 | def pack(self): |
| 3891 | packed = [] |
| 3892 | packed.append(struct.pack("!B", self.version)) |
| 3893 | packed.append(struct.pack("!B", self.type)) |
| 3894 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3895 | packed.append(struct.pack("!L", self.xid)) |
| 3896 | packed.append(struct.pack("!H", self.stats_type)) |
| 3897 | packed.append(struct.pack("!H", self.flags)) |
| 3898 | packed.append('\x00' * 4) |
| 3899 | packed.append(struct.pack("!B", self.table_id)) |
| 3900 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3901 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3902 | packed.append(struct.pack("!L", self.out_group)) |
| 3903 | packed.append('\x00' * 4) |
| 3904 | packed.append(struct.pack("!Q", self.cookie)) |
| 3905 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3906 | packed.append(self.match.pack()) |
| 3907 | length = sum([len(x) for x in packed]) |
| 3908 | packed[2] = struct.pack("!H", length) |
| 3909 | return ''.join(packed) |
| 3910 | |
| 3911 | @staticmethod |
| 3912 | def unpack(buf): |
| 3913 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3914 | obj = flow_stats_request() |
| 3915 | if type(buf) == loxi.generic_util.OFReader: |
| 3916 | reader = buf |
| 3917 | else: |
| 3918 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3919 | _version = reader.read("!B")[0] |
| 3920 | assert(_version == 2) |
| 3921 | _type = reader.read("!B")[0] |
| 3922 | assert(_type == 18) |
| 3923 | _length = reader.read("!H")[0] |
| 3924 | obj.xid = reader.read("!L")[0] |
| 3925 | _stats_type = reader.read("!H")[0] |
| 3926 | assert(_stats_type == 1) |
| 3927 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3928 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3929 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3930 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3931 | obj.out_port = util.unpack_port_no(reader) |
| 3932 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3933 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3934 | obj.cookie = reader.read("!Q")[0] |
| 3935 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3936 | obj.match = common.match.unpack(reader) |
| 3937 | return obj |
| 3938 | |
| 3939 | def __eq__(self, other): |
| 3940 | if type(self) != type(other): return False |
| 3941 | if self.version != other.version: return False |
| 3942 | if self.type != other.type: return False |
| 3943 | if self.xid != other.xid: return False |
| 3944 | if self.flags != other.flags: return False |
| 3945 | if self.table_id != other.table_id: return False |
| 3946 | if self.out_port != other.out_port: return False |
| 3947 | if self.out_group != other.out_group: return False |
| 3948 | if self.cookie != other.cookie: return False |
| 3949 | if self.cookie_mask != other.cookie_mask: return False |
| 3950 | if self.match != other.match: return False |
| 3951 | return True |
| 3952 | |
| 3953 | def __ne__(self, other): |
| 3954 | return not self.__eq__(other) |
| 3955 | |
| 3956 | def __str__(self): |
| 3957 | return self.show() |
| 3958 | |
| 3959 | def show(self): |
| 3960 | import loxi.pp |
| 3961 | return loxi.pp.pp(self) |
| 3962 | |
| 3963 | def pretty_print(self, q): |
| 3964 | q.text("flow_stats_request {") |
| 3965 | with q.group(): |
| 3966 | with q.indent(2): |
| 3967 | q.breakable() |
| 3968 | q.text("xid = "); |
| 3969 | if self.xid != None: |
| 3970 | q.text("%#x" % self.xid) |
| 3971 | else: |
| 3972 | q.text('None') |
| 3973 | q.text(","); q.breakable() |
| 3974 | q.text("flags = "); |
| 3975 | q.text("%#x" % self.flags) |
| 3976 | q.text(","); q.breakable() |
| 3977 | q.text("table_id = "); |
| 3978 | q.text("%#x" % self.table_id) |
| 3979 | q.text(","); q.breakable() |
| 3980 | q.text("out_port = "); |
| 3981 | q.text(util.pretty_port(self.out_port)) |
| 3982 | q.text(","); q.breakable() |
| 3983 | q.text("out_group = "); |
| 3984 | q.text("%#x" % self.out_group) |
| 3985 | q.text(","); q.breakable() |
| 3986 | q.text("cookie = "); |
| 3987 | q.text("%#x" % self.cookie) |
| 3988 | q.text(","); q.breakable() |
| 3989 | q.text("cookie_mask = "); |
| 3990 | q.text("%#x" % self.cookie_mask) |
| 3991 | q.text(","); q.breakable() |
| 3992 | q.text("match = "); |
| 3993 | q.pp(self.match) |
| 3994 | q.breakable() |
| 3995 | q.text('}') |
| 3996 | |
| 3997 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3998 | version = 2 |
| 3999 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4000 | |
| 4001 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 4002 | self.xid = xid |
| 4003 | if flags != None: |
| 4004 | self.flags = flags |
| 4005 | else: |
| 4006 | self.flags = 0 |
| 4007 | if miss_send_len != None: |
| 4008 | self.miss_send_len = miss_send_len |
| 4009 | else: |
| 4010 | self.miss_send_len = 0 |
| 4011 | |
| 4012 | def pack(self): |
| 4013 | packed = [] |
| 4014 | packed.append(struct.pack("!B", self.version)) |
| 4015 | packed.append(struct.pack("!B", self.type)) |
| 4016 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4017 | packed.append(struct.pack("!L", self.xid)) |
| 4018 | packed.append(struct.pack("!H", self.flags)) |
| 4019 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 4020 | length = sum([len(x) for x in packed]) |
| 4021 | packed[2] = struct.pack("!H", length) |
| 4022 | return ''.join(packed) |
| 4023 | |
| 4024 | @staticmethod |
| 4025 | def unpack(buf): |
| 4026 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4027 | obj = get_config_reply() |
| 4028 | if type(buf) == loxi.generic_util.OFReader: |
| 4029 | reader = buf |
| 4030 | else: |
| 4031 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4032 | _version = reader.read("!B")[0] |
| 4033 | assert(_version == 2) |
| 4034 | _type = reader.read("!B")[0] |
| 4035 | assert(_type == 8) |
| 4036 | _length = reader.read("!H")[0] |
| 4037 | obj.xid = reader.read("!L")[0] |
| 4038 | obj.flags = reader.read("!H")[0] |
| 4039 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4040 | return obj |
| 4041 | |
| 4042 | def __eq__(self, other): |
| 4043 | if type(self) != type(other): return False |
| 4044 | if self.version != other.version: return False |
| 4045 | if self.type != other.type: return False |
| 4046 | if self.xid != other.xid: return False |
| 4047 | if self.flags != other.flags: return False |
| 4048 | if self.miss_send_len != other.miss_send_len: return False |
| 4049 | return True |
| 4050 | |
| 4051 | def __ne__(self, other): |
| 4052 | return not self.__eq__(other) |
| 4053 | |
| 4054 | def __str__(self): |
| 4055 | return self.show() |
| 4056 | |
| 4057 | def show(self): |
| 4058 | import loxi.pp |
| 4059 | return loxi.pp.pp(self) |
| 4060 | |
| 4061 | def pretty_print(self, q): |
| 4062 | q.text("get_config_reply {") |
| 4063 | with q.group(): |
| 4064 | with q.indent(2): |
| 4065 | q.breakable() |
| 4066 | q.text("xid = "); |
| 4067 | if self.xid != None: |
| 4068 | q.text("%#x" % self.xid) |
| 4069 | else: |
| 4070 | q.text('None') |
| 4071 | q.text(","); q.breakable() |
| 4072 | q.text("flags = "); |
| 4073 | q.text("%#x" % self.flags) |
| 4074 | q.text(","); q.breakable() |
| 4075 | q.text("miss_send_len = "); |
| 4076 | q.text("%#x" % self.miss_send_len) |
| 4077 | q.breakable() |
| 4078 | q.text('}') |
| 4079 | |
| 4080 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4081 | version = 2 |
| 4082 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4083 | |
| 4084 | def __init__(self, xid=None): |
| 4085 | self.xid = xid |
| 4086 | |
| 4087 | def pack(self): |
| 4088 | packed = [] |
| 4089 | packed.append(struct.pack("!B", self.version)) |
| 4090 | packed.append(struct.pack("!B", self.type)) |
| 4091 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4092 | packed.append(struct.pack("!L", self.xid)) |
| 4093 | length = sum([len(x) for x in packed]) |
| 4094 | packed[2] = struct.pack("!H", length) |
| 4095 | return ''.join(packed) |
| 4096 | |
| 4097 | @staticmethod |
| 4098 | def unpack(buf): |
| 4099 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4100 | obj = get_config_request() |
| 4101 | if type(buf) == loxi.generic_util.OFReader: |
| 4102 | reader = buf |
| 4103 | else: |
| 4104 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4105 | _version = reader.read("!B")[0] |
| 4106 | assert(_version == 2) |
| 4107 | _type = reader.read("!B")[0] |
| 4108 | assert(_type == 7) |
| 4109 | _length = reader.read("!H")[0] |
| 4110 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4111 | return obj |
| 4112 | |
| 4113 | def __eq__(self, other): |
| 4114 | if type(self) != type(other): return False |
| 4115 | if self.version != other.version: return False |
| 4116 | if self.type != other.type: return False |
| 4117 | if self.xid != other.xid: return False |
| 4118 | return True |
| 4119 | |
| 4120 | def __ne__(self, other): |
| 4121 | return not self.__eq__(other) |
| 4122 | |
| 4123 | def __str__(self): |
| 4124 | return self.show() |
| 4125 | |
| 4126 | def show(self): |
| 4127 | import loxi.pp |
| 4128 | return loxi.pp.pp(self) |
| 4129 | |
| 4130 | def pretty_print(self, q): |
| 4131 | q.text("get_config_request {") |
| 4132 | with q.group(): |
| 4133 | with q.indent(2): |
| 4134 | q.breakable() |
| 4135 | q.text("xid = "); |
| 4136 | if self.xid != None: |
| 4137 | q.text("%#x" % self.xid) |
| 4138 | else: |
| 4139 | q.text('None') |
| 4140 | q.breakable() |
| 4141 | q.text('}') |
| 4142 | |
| 4143 | class group_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4144 | version = 2 |
| 4145 | type = 19 |
| 4146 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4147 | |
| 4148 | def __init__(self, xid=None, flags=None, entries=None): |
| 4149 | self.xid = xid |
| 4150 | if flags != None: |
| 4151 | self.flags = flags |
| 4152 | else: |
| 4153 | self.flags = 0 |
| 4154 | if entries != None: |
| 4155 | self.entries = entries |
| 4156 | else: |
| 4157 | self.entries = [] |
| 4158 | |
| 4159 | def pack(self): |
| 4160 | packed = [] |
| 4161 | packed.append(struct.pack("!B", self.version)) |
| 4162 | packed.append(struct.pack("!B", self.type)) |
| 4163 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4164 | packed.append(struct.pack("!L", self.xid)) |
| 4165 | packed.append(struct.pack("!H", self.stats_type)) |
| 4166 | packed.append(struct.pack("!H", self.flags)) |
| 4167 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4168 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4169 | length = sum([len(x) for x in packed]) |
| 4170 | packed[2] = struct.pack("!H", length) |
| 4171 | return ''.join(packed) |
| 4172 | |
| 4173 | @staticmethod |
| 4174 | def unpack(buf): |
| 4175 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4176 | obj = group_desc_stats_reply() |
| 4177 | if type(buf) == loxi.generic_util.OFReader: |
| 4178 | reader = buf |
| 4179 | else: |
| 4180 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4181 | _version = reader.read("!B")[0] |
| 4182 | assert(_version == 2) |
| 4183 | _type = reader.read("!B")[0] |
| 4184 | assert(_type == 19) |
| 4185 | _length = reader.read("!H")[0] |
| 4186 | obj.xid = reader.read("!L")[0] |
| 4187 | _stats_type = reader.read("!H")[0] |
| 4188 | assert(_stats_type == 7) |
| 4189 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4190 | reader.skip(4) |
| 4191 | obj.entries = common.unpack_list_group_desc_stats_entry(reader) |
| 4192 | return obj |
| 4193 | |
| 4194 | def __eq__(self, other): |
| 4195 | if type(self) != type(other): return False |
| 4196 | if self.version != other.version: return False |
| 4197 | if self.type != other.type: return False |
| 4198 | if self.xid != other.xid: return False |
| 4199 | if self.flags != other.flags: return False |
| 4200 | if self.entries != other.entries: return False |
| 4201 | return True |
| 4202 | |
| 4203 | def __ne__(self, other): |
| 4204 | return not self.__eq__(other) |
| 4205 | |
| 4206 | def __str__(self): |
| 4207 | return self.show() |
| 4208 | |
| 4209 | def show(self): |
| 4210 | import loxi.pp |
| 4211 | return loxi.pp.pp(self) |
| 4212 | |
| 4213 | def pretty_print(self, q): |
| 4214 | q.text("group_desc_stats_reply {") |
| 4215 | with q.group(): |
| 4216 | with q.indent(2): |
| 4217 | q.breakable() |
| 4218 | q.text("xid = "); |
| 4219 | if self.xid != None: |
| 4220 | q.text("%#x" % self.xid) |
| 4221 | else: |
| 4222 | q.text('None') |
| 4223 | q.text(","); q.breakable() |
| 4224 | q.text("flags = "); |
| 4225 | q.text("%#x" % self.flags) |
| 4226 | q.text(","); q.breakable() |
| 4227 | q.text("entries = "); |
| 4228 | q.pp(self.entries) |
| 4229 | q.breakable() |
| 4230 | q.text('}') |
| 4231 | |
| 4232 | class group_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4233 | version = 2 |
| 4234 | type = 18 |
| 4235 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4236 | |
| 4237 | def __init__(self, xid=None, flags=None): |
| 4238 | self.xid = xid |
| 4239 | if flags != None: |
| 4240 | self.flags = flags |
| 4241 | else: |
| 4242 | self.flags = 0 |
| 4243 | |
| 4244 | def pack(self): |
| 4245 | packed = [] |
| 4246 | packed.append(struct.pack("!B", self.version)) |
| 4247 | packed.append(struct.pack("!B", self.type)) |
| 4248 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4249 | packed.append(struct.pack("!L", self.xid)) |
| 4250 | packed.append(struct.pack("!H", self.stats_type)) |
| 4251 | packed.append(struct.pack("!H", self.flags)) |
| 4252 | packed.append('\x00' * 4) |
| 4253 | length = sum([len(x) for x in packed]) |
| 4254 | packed[2] = struct.pack("!H", length) |
| 4255 | return ''.join(packed) |
| 4256 | |
| 4257 | @staticmethod |
| 4258 | def unpack(buf): |
| 4259 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4260 | obj = group_desc_stats_request() |
| 4261 | if type(buf) == loxi.generic_util.OFReader: |
| 4262 | reader = buf |
| 4263 | else: |
| 4264 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4265 | _version = reader.read("!B")[0] |
| 4266 | assert(_version == 2) |
| 4267 | _type = reader.read("!B")[0] |
| 4268 | assert(_type == 18) |
| 4269 | _length = reader.read("!H")[0] |
| 4270 | obj.xid = reader.read("!L")[0] |
| 4271 | _stats_type = reader.read("!H")[0] |
| 4272 | assert(_stats_type == 7) |
| 4273 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4274 | reader.skip(4) |
| 4275 | return obj |
| 4276 | |
| 4277 | def __eq__(self, other): |
| 4278 | if type(self) != type(other): return False |
| 4279 | if self.version != other.version: return False |
| 4280 | if self.type != other.type: return False |
| 4281 | if self.xid != other.xid: return False |
| 4282 | if self.flags != other.flags: return False |
| 4283 | return True |
| 4284 | |
| 4285 | def __ne__(self, other): |
| 4286 | return not self.__eq__(other) |
| 4287 | |
| 4288 | def __str__(self): |
| 4289 | return self.show() |
| 4290 | |
| 4291 | def show(self): |
| 4292 | import loxi.pp |
| 4293 | return loxi.pp.pp(self) |
| 4294 | |
| 4295 | def pretty_print(self, q): |
| 4296 | q.text("group_desc_stats_request {") |
| 4297 | with q.group(): |
| 4298 | with q.indent(2): |
| 4299 | q.breakable() |
| 4300 | q.text("xid = "); |
| 4301 | if self.xid != None: |
| 4302 | q.text("%#x" % self.xid) |
| 4303 | else: |
| 4304 | q.text('None') |
| 4305 | q.text(","); q.breakable() |
| 4306 | q.text("flags = "); |
| 4307 | q.text("%#x" % self.flags) |
| 4308 | q.breakable() |
| 4309 | q.text('}') |
| 4310 | |
| 4311 | class group_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4312 | version = 2 |
| 4313 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4314 | |
| 4315 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 4316 | self.xid = xid |
| 4317 | if command != None: |
| 4318 | self.command = command |
| 4319 | else: |
| 4320 | self.command = 0 |
| 4321 | if group_type != None: |
| 4322 | self.group_type = group_type |
| 4323 | else: |
| 4324 | self.group_type = 0 |
| 4325 | if group_id != None: |
| 4326 | self.group_id = group_id |
| 4327 | else: |
| 4328 | self.group_id = 0 |
| 4329 | if buckets != None: |
| 4330 | self.buckets = buckets |
| 4331 | else: |
| 4332 | self.buckets = [] |
| 4333 | |
| 4334 | def pack(self): |
| 4335 | packed = [] |
| 4336 | packed.append(struct.pack("!B", self.version)) |
| 4337 | packed.append(struct.pack("!B", self.type)) |
| 4338 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4339 | packed.append(struct.pack("!L", self.xid)) |
| 4340 | packed.append(struct.pack("!H", self.command)) |
| 4341 | packed.append(struct.pack("!B", self.group_type)) |
| 4342 | packed.append('\x00' * 1) |
| 4343 | packed.append(struct.pack("!L", self.group_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4344 | packed.append(util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4345 | length = sum([len(x) for x in packed]) |
| 4346 | packed[2] = struct.pack("!H", length) |
| 4347 | return ''.join(packed) |
| 4348 | |
| 4349 | @staticmethod |
| 4350 | def unpack(buf): |
| 4351 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4352 | obj = group_mod() |
| 4353 | if type(buf) == loxi.generic_util.OFReader: |
| 4354 | reader = buf |
| 4355 | else: |
| 4356 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4357 | _version = reader.read("!B")[0] |
| 4358 | assert(_version == 2) |
| 4359 | _type = reader.read("!B")[0] |
| 4360 | assert(_type == 15) |
| 4361 | _length = reader.read("!H")[0] |
| 4362 | obj.xid = reader.read("!L")[0] |
| 4363 | obj.command = reader.read("!H")[0] |
| 4364 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4365 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4366 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4367 | obj.buckets = common.unpack_list_bucket(reader) |
| 4368 | return obj |
| 4369 | |
| 4370 | def __eq__(self, other): |
| 4371 | if type(self) != type(other): return False |
| 4372 | if self.version != other.version: return False |
| 4373 | if self.type != other.type: return False |
| 4374 | if self.xid != other.xid: return False |
| 4375 | if self.command != other.command: return False |
| 4376 | if self.group_type != other.group_type: return False |
| 4377 | if self.group_id != other.group_id: return False |
| 4378 | if self.buckets != other.buckets: return False |
| 4379 | return True |
| 4380 | |
| 4381 | def __ne__(self, other): |
| 4382 | return not self.__eq__(other) |
| 4383 | |
| 4384 | def __str__(self): |
| 4385 | return self.show() |
| 4386 | |
| 4387 | def show(self): |
| 4388 | import loxi.pp |
| 4389 | return loxi.pp.pp(self) |
| 4390 | |
| 4391 | def pretty_print(self, q): |
| 4392 | q.text("group_mod {") |
| 4393 | with q.group(): |
| 4394 | with q.indent(2): |
| 4395 | q.breakable() |
| 4396 | q.text("xid = "); |
| 4397 | if self.xid != None: |
| 4398 | q.text("%#x" % self.xid) |
| 4399 | else: |
| 4400 | q.text('None') |
| 4401 | q.text(","); q.breakable() |
| 4402 | q.text("command = "); |
| 4403 | q.text("%#x" % self.command) |
| 4404 | q.text(","); q.breakable() |
| 4405 | q.text("group_type = "); |
| 4406 | q.text("%#x" % self.group_type) |
| 4407 | q.text(","); q.breakable() |
| 4408 | q.text("group_id = "); |
| 4409 | q.text("%#x" % self.group_id) |
| 4410 | q.text(","); q.breakable() |
| 4411 | q.text("buckets = "); |
| 4412 | q.pp(self.buckets) |
| 4413 | q.breakable() |
| 4414 | q.text('}') |
| 4415 | |
| 4416 | class group_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4417 | version = 2 |
| 4418 | type = 19 |
| 4419 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4420 | |
| 4421 | def __init__(self, xid=None, flags=None, entries=None): |
| 4422 | self.xid = xid |
| 4423 | if flags != None: |
| 4424 | self.flags = flags |
| 4425 | else: |
| 4426 | self.flags = 0 |
| 4427 | if entries != None: |
| 4428 | self.entries = entries |
| 4429 | else: |
| 4430 | self.entries = [] |
| 4431 | |
| 4432 | def pack(self): |
| 4433 | packed = [] |
| 4434 | packed.append(struct.pack("!B", self.version)) |
| 4435 | packed.append(struct.pack("!B", self.type)) |
| 4436 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4437 | packed.append(struct.pack("!L", self.xid)) |
| 4438 | packed.append(struct.pack("!H", self.stats_type)) |
| 4439 | packed.append(struct.pack("!H", self.flags)) |
| 4440 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4441 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4442 | length = sum([len(x) for x in packed]) |
| 4443 | packed[2] = struct.pack("!H", length) |
| 4444 | return ''.join(packed) |
| 4445 | |
| 4446 | @staticmethod |
| 4447 | def unpack(buf): |
| 4448 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4449 | obj = group_stats_reply() |
| 4450 | if type(buf) == loxi.generic_util.OFReader: |
| 4451 | reader = buf |
| 4452 | else: |
| 4453 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4454 | _version = reader.read("!B")[0] |
| 4455 | assert(_version == 2) |
| 4456 | _type = reader.read("!B")[0] |
| 4457 | assert(_type == 19) |
| 4458 | _length = reader.read("!H")[0] |
| 4459 | obj.xid = reader.read("!L")[0] |
| 4460 | _stats_type = reader.read("!H")[0] |
| 4461 | assert(_stats_type == 6) |
| 4462 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4463 | reader.skip(4) |
| 4464 | obj.entries = common.unpack_list_group_stats_entry(reader) |
| 4465 | return obj |
| 4466 | |
| 4467 | def __eq__(self, other): |
| 4468 | if type(self) != type(other): return False |
| 4469 | if self.version != other.version: return False |
| 4470 | if self.type != other.type: return False |
| 4471 | if self.xid != other.xid: return False |
| 4472 | if self.flags != other.flags: return False |
| 4473 | if self.entries != other.entries: return False |
| 4474 | return True |
| 4475 | |
| 4476 | def __ne__(self, other): |
| 4477 | return not self.__eq__(other) |
| 4478 | |
| 4479 | def __str__(self): |
| 4480 | return self.show() |
| 4481 | |
| 4482 | def show(self): |
| 4483 | import loxi.pp |
| 4484 | return loxi.pp.pp(self) |
| 4485 | |
| 4486 | def pretty_print(self, q): |
| 4487 | q.text("group_stats_reply {") |
| 4488 | with q.group(): |
| 4489 | with q.indent(2): |
| 4490 | q.breakable() |
| 4491 | q.text("xid = "); |
| 4492 | if self.xid != None: |
| 4493 | q.text("%#x" % self.xid) |
| 4494 | else: |
| 4495 | q.text('None') |
| 4496 | q.text(","); q.breakable() |
| 4497 | q.text("flags = "); |
| 4498 | q.text("%#x" % self.flags) |
| 4499 | q.text(","); q.breakable() |
| 4500 | q.text("entries = "); |
| 4501 | q.pp(self.entries) |
| 4502 | q.breakable() |
| 4503 | q.text('}') |
| 4504 | |
| 4505 | class group_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4506 | version = 2 |
| 4507 | type = 18 |
| 4508 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4509 | |
| 4510 | def __init__(self, xid=None, flags=None, group_id=None): |
| 4511 | self.xid = xid |
| 4512 | if flags != None: |
| 4513 | self.flags = flags |
| 4514 | else: |
| 4515 | self.flags = 0 |
| 4516 | if group_id != None: |
| 4517 | self.group_id = group_id |
| 4518 | else: |
| 4519 | self.group_id = 0 |
| 4520 | |
| 4521 | def pack(self): |
| 4522 | packed = [] |
| 4523 | packed.append(struct.pack("!B", self.version)) |
| 4524 | packed.append(struct.pack("!B", self.type)) |
| 4525 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4526 | packed.append(struct.pack("!L", self.xid)) |
| 4527 | packed.append(struct.pack("!H", self.stats_type)) |
| 4528 | packed.append(struct.pack("!H", self.flags)) |
| 4529 | packed.append('\x00' * 4) |
| 4530 | packed.append(struct.pack("!L", self.group_id)) |
| 4531 | packed.append('\x00' * 4) |
| 4532 | length = sum([len(x) for x in packed]) |
| 4533 | packed[2] = struct.pack("!H", length) |
| 4534 | return ''.join(packed) |
| 4535 | |
| 4536 | @staticmethod |
| 4537 | def unpack(buf): |
| 4538 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4539 | obj = group_stats_request() |
| 4540 | if type(buf) == loxi.generic_util.OFReader: |
| 4541 | reader = buf |
| 4542 | else: |
| 4543 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4544 | _version = reader.read("!B")[0] |
| 4545 | assert(_version == 2) |
| 4546 | _type = reader.read("!B")[0] |
| 4547 | assert(_type == 18) |
| 4548 | _length = reader.read("!H")[0] |
| 4549 | obj.xid = reader.read("!L")[0] |
| 4550 | _stats_type = reader.read("!H")[0] |
| 4551 | assert(_stats_type == 6) |
| 4552 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4553 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4554 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4555 | reader.skip(4) |
| 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.group_id != other.group_id: return False |
| 4565 | return True |
| 4566 | |
| 4567 | def __ne__(self, other): |
| 4568 | return not self.__eq__(other) |
| 4569 | |
| 4570 | def __str__(self): |
| 4571 | return self.show() |
| 4572 | |
| 4573 | def show(self): |
| 4574 | import loxi.pp |
| 4575 | return loxi.pp.pp(self) |
| 4576 | |
| 4577 | def pretty_print(self, q): |
| 4578 | q.text("group_stats_request {") |
| 4579 | with q.group(): |
| 4580 | with q.indent(2): |
| 4581 | q.breakable() |
| 4582 | q.text("xid = "); |
| 4583 | if self.xid != None: |
| 4584 | q.text("%#x" % self.xid) |
| 4585 | else: |
| 4586 | q.text('None') |
| 4587 | q.text(","); q.breakable() |
| 4588 | q.text("flags = "); |
| 4589 | q.text("%#x" % self.flags) |
| 4590 | q.text(","); q.breakable() |
| 4591 | q.text("group_id = "); |
| 4592 | q.text("%#x" % self.group_id) |
| 4593 | q.breakable() |
| 4594 | q.text('}') |
| 4595 | |
| 4596 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4597 | version = 2 |
| 4598 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4599 | |
| 4600 | def __init__(self, xid=None): |
| 4601 | self.xid = xid |
| 4602 | |
| 4603 | def pack(self): |
| 4604 | packed = [] |
| 4605 | packed.append(struct.pack("!B", self.version)) |
| 4606 | packed.append(struct.pack("!B", self.type)) |
| 4607 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4608 | packed.append(struct.pack("!L", self.xid)) |
| 4609 | length = sum([len(x) for x in packed]) |
| 4610 | packed[2] = struct.pack("!H", length) |
| 4611 | return ''.join(packed) |
| 4612 | |
| 4613 | @staticmethod |
| 4614 | def unpack(buf): |
| 4615 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4616 | obj = hello() |
| 4617 | if type(buf) == loxi.generic_util.OFReader: |
| 4618 | reader = buf |
| 4619 | else: |
| 4620 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4621 | _version = reader.read("!B")[0] |
| 4622 | assert(_version == 2) |
| 4623 | _type = reader.read("!B")[0] |
| 4624 | assert(_type == 0) |
| 4625 | _length = reader.read("!H")[0] |
| 4626 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4627 | return obj |
| 4628 | |
| 4629 | def __eq__(self, other): |
| 4630 | if type(self) != type(other): return False |
| 4631 | if self.version != other.version: return False |
| 4632 | if self.type != other.type: return False |
| 4633 | if self.xid != other.xid: return False |
| 4634 | return True |
| 4635 | |
| 4636 | def __ne__(self, other): |
| 4637 | return not self.__eq__(other) |
| 4638 | |
| 4639 | def __str__(self): |
| 4640 | return self.show() |
| 4641 | |
| 4642 | def show(self): |
| 4643 | import loxi.pp |
| 4644 | return loxi.pp.pp(self) |
| 4645 | |
| 4646 | def pretty_print(self, q): |
| 4647 | q.text("hello {") |
| 4648 | with q.group(): |
| 4649 | with q.indent(2): |
| 4650 | q.breakable() |
| 4651 | q.text("xid = "); |
| 4652 | if self.xid != None: |
| 4653 | q.text("%#x" % self.xid) |
| 4654 | else: |
| 4655 | q.text('None') |
| 4656 | q.breakable() |
| 4657 | q.text('}') |
| 4658 | |
| 4659 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4660 | version = 2 |
| 4661 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4662 | |
| 4663 | 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): |
| 4664 | self.xid = xid |
| 4665 | if buffer_id != None: |
| 4666 | self.buffer_id = buffer_id |
| 4667 | else: |
| 4668 | self.buffer_id = 0 |
| 4669 | if in_port != None: |
| 4670 | self.in_port = in_port |
| 4671 | else: |
| 4672 | self.in_port = 0 |
| 4673 | if in_phy_port != None: |
| 4674 | self.in_phy_port = in_phy_port |
| 4675 | else: |
| 4676 | self.in_phy_port = 0 |
| 4677 | if total_len != None: |
| 4678 | self.total_len = total_len |
| 4679 | else: |
| 4680 | self.total_len = 0 |
| 4681 | if reason != None: |
| 4682 | self.reason = reason |
| 4683 | else: |
| 4684 | self.reason = 0 |
| 4685 | if table_id != None: |
| 4686 | self.table_id = table_id |
| 4687 | else: |
| 4688 | self.table_id = 0 |
| 4689 | if data != None: |
| 4690 | self.data = data |
| 4691 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4692 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4693 | |
| 4694 | def pack(self): |
| 4695 | packed = [] |
| 4696 | packed.append(struct.pack("!B", self.version)) |
| 4697 | packed.append(struct.pack("!B", self.type)) |
| 4698 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4699 | packed.append(struct.pack("!L", self.xid)) |
| 4700 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4701 | packed.append(util.pack_port_no(self.in_port)) |
| 4702 | packed.append(util.pack_port_no(self.in_phy_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4703 | packed.append(struct.pack("!H", self.total_len)) |
| 4704 | packed.append(struct.pack("!B", self.reason)) |
| 4705 | packed.append(struct.pack("!B", self.table_id)) |
| 4706 | packed.append(self.data) |
| 4707 | length = sum([len(x) for x in packed]) |
| 4708 | packed[2] = struct.pack("!H", length) |
| 4709 | return ''.join(packed) |
| 4710 | |
| 4711 | @staticmethod |
| 4712 | def unpack(buf): |
| 4713 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4714 | obj = packet_in() |
| 4715 | if type(buf) == loxi.generic_util.OFReader: |
| 4716 | reader = buf |
| 4717 | else: |
| 4718 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4719 | _version = reader.read("!B")[0] |
| 4720 | assert(_version == 2) |
| 4721 | _type = reader.read("!B")[0] |
| 4722 | assert(_type == 10) |
| 4723 | _length = reader.read("!H")[0] |
| 4724 | obj.xid = reader.read("!L")[0] |
| 4725 | obj.buffer_id = reader.read("!L")[0] |
| 4726 | obj.in_port = util.unpack_port_no(reader) |
| 4727 | obj.in_phy_port = util.unpack_port_no(reader) |
| 4728 | obj.total_len = reader.read("!H")[0] |
| 4729 | obj.reason = reader.read("!B")[0] |
| 4730 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4731 | obj.data = str(reader.read_all()) |
| 4732 | return obj |
| 4733 | |
| 4734 | def __eq__(self, other): |
| 4735 | if type(self) != type(other): return False |
| 4736 | if self.version != other.version: return False |
| 4737 | if self.type != other.type: return False |
| 4738 | if self.xid != other.xid: return False |
| 4739 | if self.buffer_id != other.buffer_id: return False |
| 4740 | if self.in_port != other.in_port: return False |
| 4741 | if self.in_phy_port != other.in_phy_port: return False |
| 4742 | if self.total_len != other.total_len: return False |
| 4743 | if self.reason != other.reason: return False |
| 4744 | if self.table_id != other.table_id: return False |
| 4745 | if self.data != other.data: return False |
| 4746 | return True |
| 4747 | |
| 4748 | def __ne__(self, other): |
| 4749 | return not self.__eq__(other) |
| 4750 | |
| 4751 | def __str__(self): |
| 4752 | return self.show() |
| 4753 | |
| 4754 | def show(self): |
| 4755 | import loxi.pp |
| 4756 | return loxi.pp.pp(self) |
| 4757 | |
| 4758 | def pretty_print(self, q): |
| 4759 | q.text("packet_in {") |
| 4760 | with q.group(): |
| 4761 | with q.indent(2): |
| 4762 | q.breakable() |
| 4763 | q.text("xid = "); |
| 4764 | if self.xid != None: |
| 4765 | q.text("%#x" % self.xid) |
| 4766 | else: |
| 4767 | q.text('None') |
| 4768 | q.text(","); q.breakable() |
| 4769 | q.text("buffer_id = "); |
| 4770 | q.text("%#x" % self.buffer_id) |
| 4771 | q.text(","); q.breakable() |
| 4772 | q.text("in_port = "); |
| 4773 | q.text(util.pretty_port(self.in_port)) |
| 4774 | q.text(","); q.breakable() |
| 4775 | q.text("in_phy_port = "); |
| 4776 | q.text(util.pretty_port(self.in_phy_port)) |
| 4777 | q.text(","); q.breakable() |
| 4778 | q.text("total_len = "); |
| 4779 | q.text("%#x" % self.total_len) |
| 4780 | q.text(","); q.breakable() |
| 4781 | q.text("reason = "); |
| 4782 | q.text("%#x" % self.reason) |
| 4783 | q.text(","); q.breakable() |
| 4784 | q.text("table_id = "); |
| 4785 | q.text("%#x" % self.table_id) |
| 4786 | q.text(","); q.breakable() |
| 4787 | q.text("data = "); |
| 4788 | q.pp(self.data) |
| 4789 | q.breakable() |
| 4790 | q.text('}') |
| 4791 | |
| 4792 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4793 | version = 2 |
| 4794 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4795 | |
| 4796 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 4797 | self.xid = xid |
| 4798 | if buffer_id != None: |
| 4799 | self.buffer_id = buffer_id |
| 4800 | else: |
| 4801 | self.buffer_id = 0 |
| 4802 | if in_port != None: |
| 4803 | self.in_port = in_port |
| 4804 | else: |
| 4805 | self.in_port = 0 |
| 4806 | if actions != None: |
| 4807 | self.actions = actions |
| 4808 | else: |
| 4809 | self.actions = [] |
| 4810 | if data != None: |
| 4811 | self.data = data |
| 4812 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4813 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4814 | |
| 4815 | def pack(self): |
| 4816 | packed = [] |
| 4817 | packed.append(struct.pack("!B", self.version)) |
| 4818 | packed.append(struct.pack("!B", self.type)) |
| 4819 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4820 | packed.append(struct.pack("!L", self.xid)) |
| 4821 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4822 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4823 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 4824 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4825 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4826 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 4827 | packed.append(self.data) |
| 4828 | length = sum([len(x) for x in packed]) |
| 4829 | packed[2] = struct.pack("!H", length) |
| 4830 | return ''.join(packed) |
| 4831 | |
| 4832 | @staticmethod |
| 4833 | def unpack(buf): |
| 4834 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4835 | obj = packet_out() |
| 4836 | if type(buf) == loxi.generic_util.OFReader: |
| 4837 | reader = buf |
| 4838 | else: |
| 4839 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4840 | _version = reader.read("!B")[0] |
| 4841 | assert(_version == 2) |
| 4842 | _type = reader.read("!B")[0] |
| 4843 | assert(_type == 13) |
| 4844 | _length = reader.read("!H")[0] |
| 4845 | obj.xid = reader.read("!L")[0] |
| 4846 | obj.buffer_id = reader.read("!L")[0] |
| 4847 | obj.in_port = util.unpack_port_no(reader) |
| 4848 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4849 | reader.skip(6) |
| 4850 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 4851 | obj.data = str(reader.read_all()) |
| 4852 | return obj |
| 4853 | |
| 4854 | def __eq__(self, other): |
| 4855 | if type(self) != type(other): return False |
| 4856 | if self.version != other.version: return False |
| 4857 | if self.type != other.type: return False |
| 4858 | if self.xid != other.xid: return False |
| 4859 | if self.buffer_id != other.buffer_id: return False |
| 4860 | if self.in_port != other.in_port: return False |
| 4861 | if self.actions != other.actions: return False |
| 4862 | if self.data != other.data: return False |
| 4863 | return True |
| 4864 | |
| 4865 | def __ne__(self, other): |
| 4866 | return not self.__eq__(other) |
| 4867 | |
| 4868 | def __str__(self): |
| 4869 | return self.show() |
| 4870 | |
| 4871 | def show(self): |
| 4872 | import loxi.pp |
| 4873 | return loxi.pp.pp(self) |
| 4874 | |
| 4875 | def pretty_print(self, q): |
| 4876 | q.text("packet_out {") |
| 4877 | with q.group(): |
| 4878 | with q.indent(2): |
| 4879 | q.breakable() |
| 4880 | q.text("xid = "); |
| 4881 | if self.xid != None: |
| 4882 | q.text("%#x" % self.xid) |
| 4883 | else: |
| 4884 | q.text('None') |
| 4885 | q.text(","); q.breakable() |
| 4886 | q.text("buffer_id = "); |
| 4887 | q.text("%#x" % self.buffer_id) |
| 4888 | q.text(","); q.breakable() |
| 4889 | q.text("in_port = "); |
| 4890 | q.text(util.pretty_port(self.in_port)) |
| 4891 | q.text(","); q.breakable() |
| 4892 | q.text("actions = "); |
| 4893 | q.pp(self.actions) |
| 4894 | q.text(","); q.breakable() |
| 4895 | q.text("data = "); |
| 4896 | q.pp(self.data) |
| 4897 | q.breakable() |
| 4898 | q.text('}') |
| 4899 | |
| 4900 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4901 | version = 2 |
| 4902 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4903 | |
| 4904 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
| 4905 | self.xid = xid |
| 4906 | if port_no != None: |
| 4907 | self.port_no = port_no |
| 4908 | else: |
| 4909 | self.port_no = 0 |
| 4910 | if hw_addr != None: |
| 4911 | self.hw_addr = hw_addr |
| 4912 | else: |
| 4913 | self.hw_addr = [0,0,0,0,0,0] |
| 4914 | if config != None: |
| 4915 | self.config = config |
| 4916 | else: |
| 4917 | self.config = 0 |
| 4918 | if mask != None: |
| 4919 | self.mask = mask |
| 4920 | else: |
| 4921 | self.mask = 0 |
| 4922 | if advertise != None: |
| 4923 | self.advertise = advertise |
| 4924 | else: |
| 4925 | self.advertise = 0 |
| 4926 | |
| 4927 | def pack(self): |
| 4928 | packed = [] |
| 4929 | packed.append(struct.pack("!B", self.version)) |
| 4930 | packed.append(struct.pack("!B", self.type)) |
| 4931 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4932 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4933 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4934 | packed.append('\x00' * 4) |
| 4935 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 4936 | packed.append('\x00' * 2) |
| 4937 | packed.append(struct.pack("!L", self.config)) |
| 4938 | packed.append(struct.pack("!L", self.mask)) |
| 4939 | packed.append(struct.pack("!L", self.advertise)) |
| 4940 | packed.append('\x00' * 4) |
| 4941 | length = sum([len(x) for x in packed]) |
| 4942 | packed[2] = struct.pack("!H", length) |
| 4943 | return ''.join(packed) |
| 4944 | |
| 4945 | @staticmethod |
| 4946 | def unpack(buf): |
| 4947 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4948 | obj = port_mod() |
| 4949 | if type(buf) == loxi.generic_util.OFReader: |
| 4950 | reader = buf |
| 4951 | else: |
| 4952 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4953 | _version = reader.read("!B")[0] |
| 4954 | assert(_version == 2) |
| 4955 | _type = reader.read("!B")[0] |
| 4956 | assert(_type == 16) |
| 4957 | _length = reader.read("!H")[0] |
| 4958 | obj.xid = reader.read("!L")[0] |
| 4959 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4960 | reader.skip(4) |
| 4961 | obj.hw_addr = list(reader.read('!6B')) |
| 4962 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4963 | obj.config = reader.read("!L")[0] |
| 4964 | obj.mask = reader.read("!L")[0] |
| 4965 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4966 | reader.skip(4) |
| 4967 | return obj |
| 4968 | |
| 4969 | def __eq__(self, other): |
| 4970 | if type(self) != type(other): return False |
| 4971 | if self.version != other.version: return False |
| 4972 | if self.type != other.type: return False |
| 4973 | if self.xid != other.xid: return False |
| 4974 | if self.port_no != other.port_no: return False |
| 4975 | if self.hw_addr != other.hw_addr: return False |
| 4976 | if self.config != other.config: return False |
| 4977 | if self.mask != other.mask: return False |
| 4978 | if self.advertise != other.advertise: return False |
| 4979 | return True |
| 4980 | |
| 4981 | def __ne__(self, other): |
| 4982 | return not self.__eq__(other) |
| 4983 | |
| 4984 | def __str__(self): |
| 4985 | return self.show() |
| 4986 | |
| 4987 | def show(self): |
| 4988 | import loxi.pp |
| 4989 | return loxi.pp.pp(self) |
| 4990 | |
| 4991 | def pretty_print(self, q): |
| 4992 | q.text("port_mod {") |
| 4993 | with q.group(): |
| 4994 | with q.indent(2): |
| 4995 | q.breakable() |
| 4996 | q.text("xid = "); |
| 4997 | if self.xid != None: |
| 4998 | q.text("%#x" % self.xid) |
| 4999 | else: |
| 5000 | q.text('None') |
| 5001 | q.text(","); q.breakable() |
| 5002 | q.text("port_no = "); |
| 5003 | q.text(util.pretty_port(self.port_no)) |
| 5004 | q.text(","); q.breakable() |
| 5005 | q.text("hw_addr = "); |
| 5006 | q.text(util.pretty_mac(self.hw_addr)) |
| 5007 | q.text(","); q.breakable() |
| 5008 | q.text("config = "); |
| 5009 | q.text("%#x" % self.config) |
| 5010 | q.text(","); q.breakable() |
| 5011 | q.text("mask = "); |
| 5012 | q.text("%#x" % self.mask) |
| 5013 | q.text(","); q.breakable() |
| 5014 | q.text("advertise = "); |
| 5015 | q.text("%#x" % self.advertise) |
| 5016 | q.breakable() |
| 5017 | q.text('}') |
| 5018 | |
| 5019 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5020 | version = 2 |
| 5021 | type = 19 |
| 5022 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5023 | |
| 5024 | def __init__(self, xid=None, flags=None, entries=None): |
| 5025 | self.xid = xid |
| 5026 | if flags != None: |
| 5027 | self.flags = flags |
| 5028 | else: |
| 5029 | self.flags = 0 |
| 5030 | if entries != None: |
| 5031 | self.entries = entries |
| 5032 | else: |
| 5033 | self.entries = [] |
| 5034 | |
| 5035 | def pack(self): |
| 5036 | packed = [] |
| 5037 | packed.append(struct.pack("!B", self.version)) |
| 5038 | packed.append(struct.pack("!B", self.type)) |
| 5039 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5040 | packed.append(struct.pack("!L", self.xid)) |
| 5041 | packed.append(struct.pack("!H", self.stats_type)) |
| 5042 | packed.append(struct.pack("!H", self.flags)) |
| 5043 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5044 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5045 | length = sum([len(x) for x in packed]) |
| 5046 | packed[2] = struct.pack("!H", length) |
| 5047 | return ''.join(packed) |
| 5048 | |
| 5049 | @staticmethod |
| 5050 | def unpack(buf): |
| 5051 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5052 | obj = port_stats_reply() |
| 5053 | if type(buf) == loxi.generic_util.OFReader: |
| 5054 | reader = buf |
| 5055 | else: |
| 5056 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5057 | _version = reader.read("!B")[0] |
| 5058 | assert(_version == 2) |
| 5059 | _type = reader.read("!B")[0] |
| 5060 | assert(_type == 19) |
| 5061 | _length = reader.read("!H")[0] |
| 5062 | obj.xid = reader.read("!L")[0] |
| 5063 | _stats_type = reader.read("!H")[0] |
| 5064 | assert(_stats_type == 4) |
| 5065 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5066 | reader.skip(4) |
| 5067 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 5068 | return obj |
| 5069 | |
| 5070 | def __eq__(self, other): |
| 5071 | if type(self) != type(other): return False |
| 5072 | if self.version != other.version: return False |
| 5073 | if self.type != other.type: return False |
| 5074 | if self.xid != other.xid: return False |
| 5075 | if self.flags != other.flags: return False |
| 5076 | if self.entries != other.entries: return False |
| 5077 | return True |
| 5078 | |
| 5079 | def __ne__(self, other): |
| 5080 | return not self.__eq__(other) |
| 5081 | |
| 5082 | def __str__(self): |
| 5083 | return self.show() |
| 5084 | |
| 5085 | def show(self): |
| 5086 | import loxi.pp |
| 5087 | return loxi.pp.pp(self) |
| 5088 | |
| 5089 | def pretty_print(self, q): |
| 5090 | q.text("port_stats_reply {") |
| 5091 | with q.group(): |
| 5092 | with q.indent(2): |
| 5093 | q.breakable() |
| 5094 | q.text("xid = "); |
| 5095 | if self.xid != None: |
| 5096 | q.text("%#x" % self.xid) |
| 5097 | else: |
| 5098 | q.text('None') |
| 5099 | q.text(","); q.breakable() |
| 5100 | q.text("flags = "); |
| 5101 | q.text("%#x" % self.flags) |
| 5102 | q.text(","); q.breakable() |
| 5103 | q.text("entries = "); |
| 5104 | q.pp(self.entries) |
| 5105 | q.breakable() |
| 5106 | q.text('}') |
| 5107 | |
| 5108 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5109 | version = 2 |
| 5110 | type = 18 |
| 5111 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5112 | |
| 5113 | def __init__(self, xid=None, flags=None, port_no=None): |
| 5114 | self.xid = xid |
| 5115 | if flags != None: |
| 5116 | self.flags = flags |
| 5117 | else: |
| 5118 | self.flags = 0 |
| 5119 | if port_no != None: |
| 5120 | self.port_no = port_no |
| 5121 | else: |
| 5122 | self.port_no = 0 |
| 5123 | |
| 5124 | def pack(self): |
| 5125 | packed = [] |
| 5126 | packed.append(struct.pack("!B", self.version)) |
| 5127 | packed.append(struct.pack("!B", self.type)) |
| 5128 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5129 | packed.append(struct.pack("!L", self.xid)) |
| 5130 | packed.append(struct.pack("!H", self.stats_type)) |
| 5131 | packed.append(struct.pack("!H", self.flags)) |
| 5132 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5133 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5134 | packed.append('\x00' * 4) |
| 5135 | length = sum([len(x) for x in packed]) |
| 5136 | packed[2] = struct.pack("!H", length) |
| 5137 | return ''.join(packed) |
| 5138 | |
| 5139 | @staticmethod |
| 5140 | def unpack(buf): |
| 5141 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5142 | obj = port_stats_request() |
| 5143 | if type(buf) == loxi.generic_util.OFReader: |
| 5144 | reader = buf |
| 5145 | else: |
| 5146 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5147 | _version = reader.read("!B")[0] |
| 5148 | assert(_version == 2) |
| 5149 | _type = reader.read("!B")[0] |
| 5150 | assert(_type == 18) |
| 5151 | _length = reader.read("!H")[0] |
| 5152 | obj.xid = reader.read("!L")[0] |
| 5153 | _stats_type = reader.read("!H")[0] |
| 5154 | assert(_stats_type == 4) |
| 5155 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5156 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5157 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5158 | reader.skip(4) |
| 5159 | return obj |
| 5160 | |
| 5161 | def __eq__(self, other): |
| 5162 | if type(self) != type(other): return False |
| 5163 | if self.version != other.version: return False |
| 5164 | if self.type != other.type: return False |
| 5165 | if self.xid != other.xid: return False |
| 5166 | if self.flags != other.flags: return False |
| 5167 | if self.port_no != other.port_no: return False |
| 5168 | return True |
| 5169 | |
| 5170 | def __ne__(self, other): |
| 5171 | return not self.__eq__(other) |
| 5172 | |
| 5173 | def __str__(self): |
| 5174 | return self.show() |
| 5175 | |
| 5176 | def show(self): |
| 5177 | import loxi.pp |
| 5178 | return loxi.pp.pp(self) |
| 5179 | |
| 5180 | def pretty_print(self, q): |
| 5181 | q.text("port_stats_request {") |
| 5182 | with q.group(): |
| 5183 | with q.indent(2): |
| 5184 | q.breakable() |
| 5185 | q.text("xid = "); |
| 5186 | if self.xid != None: |
| 5187 | q.text("%#x" % self.xid) |
| 5188 | else: |
| 5189 | q.text('None') |
| 5190 | q.text(","); q.breakable() |
| 5191 | q.text("flags = "); |
| 5192 | q.text("%#x" % self.flags) |
| 5193 | q.text(","); q.breakable() |
| 5194 | q.text("port_no = "); |
| 5195 | q.text(util.pretty_port(self.port_no)) |
| 5196 | q.breakable() |
| 5197 | q.text('}') |
| 5198 | |
| 5199 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5200 | version = 2 |
| 5201 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5202 | |
| 5203 | def __init__(self, xid=None, reason=None, desc=None): |
| 5204 | self.xid = xid |
| 5205 | if reason != None: |
| 5206 | self.reason = reason |
| 5207 | else: |
| 5208 | self.reason = 0 |
| 5209 | if desc != None: |
| 5210 | self.desc = desc |
| 5211 | else: |
| 5212 | self.desc = common.port_desc() |
| 5213 | |
| 5214 | def pack(self): |
| 5215 | packed = [] |
| 5216 | packed.append(struct.pack("!B", self.version)) |
| 5217 | packed.append(struct.pack("!B", self.type)) |
| 5218 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5219 | packed.append(struct.pack("!L", self.xid)) |
| 5220 | packed.append(struct.pack("!B", self.reason)) |
| 5221 | packed.append('\x00' * 7) |
| 5222 | packed.append(self.desc.pack()) |
| 5223 | length = sum([len(x) for x in packed]) |
| 5224 | packed[2] = struct.pack("!H", length) |
| 5225 | return ''.join(packed) |
| 5226 | |
| 5227 | @staticmethod |
| 5228 | def unpack(buf): |
| 5229 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5230 | obj = port_status() |
| 5231 | if type(buf) == loxi.generic_util.OFReader: |
| 5232 | reader = buf |
| 5233 | else: |
| 5234 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5235 | _version = reader.read("!B")[0] |
| 5236 | assert(_version == 2) |
| 5237 | _type = reader.read("!B")[0] |
| 5238 | assert(_type == 12) |
| 5239 | _length = reader.read("!H")[0] |
| 5240 | obj.xid = reader.read("!L")[0] |
| 5241 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5242 | reader.skip(7) |
| 5243 | obj.desc = common.port_desc.unpack(reader) |
| 5244 | return obj |
| 5245 | |
| 5246 | def __eq__(self, other): |
| 5247 | if type(self) != type(other): return False |
| 5248 | if self.version != other.version: return False |
| 5249 | if self.type != other.type: return False |
| 5250 | if self.xid != other.xid: return False |
| 5251 | if self.reason != other.reason: return False |
| 5252 | if self.desc != other.desc: return False |
| 5253 | return True |
| 5254 | |
| 5255 | def __ne__(self, other): |
| 5256 | return not self.__eq__(other) |
| 5257 | |
| 5258 | def __str__(self): |
| 5259 | return self.show() |
| 5260 | |
| 5261 | def show(self): |
| 5262 | import loxi.pp |
| 5263 | return loxi.pp.pp(self) |
| 5264 | |
| 5265 | def pretty_print(self, q): |
| 5266 | q.text("port_status {") |
| 5267 | with q.group(): |
| 5268 | with q.indent(2): |
| 5269 | q.breakable() |
| 5270 | q.text("xid = "); |
| 5271 | if self.xid != None: |
| 5272 | q.text("%#x" % self.xid) |
| 5273 | else: |
| 5274 | q.text('None') |
| 5275 | q.text(","); q.breakable() |
| 5276 | q.text("reason = "); |
| 5277 | q.text("%#x" % self.reason) |
| 5278 | q.text(","); q.breakable() |
| 5279 | q.text("desc = "); |
| 5280 | q.pp(self.desc) |
| 5281 | q.breakable() |
| 5282 | q.text('}') |
| 5283 | |
| 5284 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5285 | version = 2 |
| 5286 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5287 | |
| 5288 | def __init__(self, xid=None, port=None, queues=None): |
| 5289 | self.xid = xid |
| 5290 | if port != None: |
| 5291 | self.port = port |
| 5292 | else: |
| 5293 | self.port = 0 |
| 5294 | if queues != None: |
| 5295 | self.queues = queues |
| 5296 | else: |
| 5297 | self.queues = [] |
| 5298 | |
| 5299 | def pack(self): |
| 5300 | packed = [] |
| 5301 | packed.append(struct.pack("!B", self.version)) |
| 5302 | packed.append(struct.pack("!B", self.type)) |
| 5303 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5304 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5305 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5306 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5307 | packed.append(util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5308 | length = sum([len(x) for x in packed]) |
| 5309 | packed[2] = struct.pack("!H", length) |
| 5310 | return ''.join(packed) |
| 5311 | |
| 5312 | @staticmethod |
| 5313 | def unpack(buf): |
| 5314 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5315 | obj = queue_get_config_reply() |
| 5316 | if type(buf) == loxi.generic_util.OFReader: |
| 5317 | reader = buf |
| 5318 | else: |
| 5319 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5320 | _version = reader.read("!B")[0] |
| 5321 | assert(_version == 2) |
| 5322 | _type = reader.read("!B")[0] |
| 5323 | assert(_type == 23) |
| 5324 | _length = reader.read("!H")[0] |
| 5325 | obj.xid = reader.read("!L")[0] |
| 5326 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5327 | reader.skip(4) |
| 5328 | obj.queues = common.unpack_list_packet_queue(reader) |
| 5329 | return obj |
| 5330 | |
| 5331 | def __eq__(self, other): |
| 5332 | if type(self) != type(other): return False |
| 5333 | if self.version != other.version: return False |
| 5334 | if self.type != other.type: return False |
| 5335 | if self.xid != other.xid: return False |
| 5336 | if self.port != other.port: return False |
| 5337 | if self.queues != other.queues: return False |
| 5338 | return True |
| 5339 | |
| 5340 | def __ne__(self, other): |
| 5341 | return not self.__eq__(other) |
| 5342 | |
| 5343 | def __str__(self): |
| 5344 | return self.show() |
| 5345 | |
| 5346 | def show(self): |
| 5347 | import loxi.pp |
| 5348 | return loxi.pp.pp(self) |
| 5349 | |
| 5350 | def pretty_print(self, q): |
| 5351 | q.text("queue_get_config_reply {") |
| 5352 | with q.group(): |
| 5353 | with q.indent(2): |
| 5354 | q.breakable() |
| 5355 | q.text("xid = "); |
| 5356 | if self.xid != None: |
| 5357 | q.text("%#x" % self.xid) |
| 5358 | else: |
| 5359 | q.text('None') |
| 5360 | q.text(","); q.breakable() |
| 5361 | q.text("port = "); |
| 5362 | q.text(util.pretty_port(self.port)) |
| 5363 | q.text(","); q.breakable() |
| 5364 | q.text("queues = "); |
| 5365 | q.pp(self.queues) |
| 5366 | q.breakable() |
| 5367 | q.text('}') |
| 5368 | |
| 5369 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5370 | version = 2 |
| 5371 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5372 | |
| 5373 | def __init__(self, xid=None, port=None): |
| 5374 | self.xid = xid |
| 5375 | if port != None: |
| 5376 | self.port = port |
| 5377 | else: |
| 5378 | self.port = 0 |
| 5379 | |
| 5380 | def pack(self): |
| 5381 | packed = [] |
| 5382 | packed.append(struct.pack("!B", self.version)) |
| 5383 | packed.append(struct.pack("!B", self.type)) |
| 5384 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5385 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5386 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5387 | packed.append('\x00' * 4) |
| 5388 | length = sum([len(x) for x in packed]) |
| 5389 | packed[2] = struct.pack("!H", length) |
| 5390 | return ''.join(packed) |
| 5391 | |
| 5392 | @staticmethod |
| 5393 | def unpack(buf): |
| 5394 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5395 | obj = queue_get_config_request() |
| 5396 | if type(buf) == loxi.generic_util.OFReader: |
| 5397 | reader = buf |
| 5398 | else: |
| 5399 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5400 | _version = reader.read("!B")[0] |
| 5401 | assert(_version == 2) |
| 5402 | _type = reader.read("!B")[0] |
| 5403 | assert(_type == 22) |
| 5404 | _length = reader.read("!H")[0] |
| 5405 | obj.xid = reader.read("!L")[0] |
| 5406 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5407 | reader.skip(4) |
| 5408 | return obj |
| 5409 | |
| 5410 | def __eq__(self, other): |
| 5411 | if type(self) != type(other): return False |
| 5412 | if self.version != other.version: return False |
| 5413 | if self.type != other.type: return False |
| 5414 | if self.xid != other.xid: return False |
| 5415 | if self.port != other.port: return False |
| 5416 | return True |
| 5417 | |
| 5418 | def __ne__(self, other): |
| 5419 | return not self.__eq__(other) |
| 5420 | |
| 5421 | def __str__(self): |
| 5422 | return self.show() |
| 5423 | |
| 5424 | def show(self): |
| 5425 | import loxi.pp |
| 5426 | return loxi.pp.pp(self) |
| 5427 | |
| 5428 | def pretty_print(self, q): |
| 5429 | q.text("queue_get_config_request {") |
| 5430 | with q.group(): |
| 5431 | with q.indent(2): |
| 5432 | q.breakable() |
| 5433 | q.text("xid = "); |
| 5434 | if self.xid != None: |
| 5435 | q.text("%#x" % self.xid) |
| 5436 | else: |
| 5437 | q.text('None') |
| 5438 | q.text(","); q.breakable() |
| 5439 | q.text("port = "); |
| 5440 | q.text(util.pretty_port(self.port)) |
| 5441 | q.breakable() |
| 5442 | q.text('}') |
| 5443 | |
| 5444 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5445 | version = 2 |
| 5446 | type = 19 |
| 5447 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5448 | |
| 5449 | def __init__(self, xid=None, flags=None, entries=None): |
| 5450 | self.xid = xid |
| 5451 | if flags != None: |
| 5452 | self.flags = flags |
| 5453 | else: |
| 5454 | self.flags = 0 |
| 5455 | if entries != None: |
| 5456 | self.entries = entries |
| 5457 | else: |
| 5458 | self.entries = [] |
| 5459 | |
| 5460 | def pack(self): |
| 5461 | packed = [] |
| 5462 | packed.append(struct.pack("!B", self.version)) |
| 5463 | packed.append(struct.pack("!B", self.type)) |
| 5464 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5465 | packed.append(struct.pack("!L", self.xid)) |
| 5466 | packed.append(struct.pack("!H", self.stats_type)) |
| 5467 | packed.append(struct.pack("!H", self.flags)) |
| 5468 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5469 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5470 | length = sum([len(x) for x in packed]) |
| 5471 | packed[2] = struct.pack("!H", length) |
| 5472 | return ''.join(packed) |
| 5473 | |
| 5474 | @staticmethod |
| 5475 | def unpack(buf): |
| 5476 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5477 | obj = queue_stats_reply() |
| 5478 | if type(buf) == loxi.generic_util.OFReader: |
| 5479 | reader = buf |
| 5480 | else: |
| 5481 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5482 | _version = reader.read("!B")[0] |
| 5483 | assert(_version == 2) |
| 5484 | _type = reader.read("!B")[0] |
| 5485 | assert(_type == 19) |
| 5486 | _length = reader.read("!H")[0] |
| 5487 | obj.xid = reader.read("!L")[0] |
| 5488 | _stats_type = reader.read("!H")[0] |
| 5489 | assert(_stats_type == 5) |
| 5490 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5491 | reader.skip(4) |
| 5492 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 5493 | return obj |
| 5494 | |
| 5495 | def __eq__(self, other): |
| 5496 | if type(self) != type(other): return False |
| 5497 | if self.version != other.version: return False |
| 5498 | if self.type != other.type: return False |
| 5499 | if self.xid != other.xid: return False |
| 5500 | if self.flags != other.flags: return False |
| 5501 | if self.entries != other.entries: return False |
| 5502 | return True |
| 5503 | |
| 5504 | def __ne__(self, other): |
| 5505 | return not self.__eq__(other) |
| 5506 | |
| 5507 | def __str__(self): |
| 5508 | return self.show() |
| 5509 | |
| 5510 | def show(self): |
| 5511 | import loxi.pp |
| 5512 | return loxi.pp.pp(self) |
| 5513 | |
| 5514 | def pretty_print(self, q): |
| 5515 | q.text("queue_stats_reply {") |
| 5516 | with q.group(): |
| 5517 | with q.indent(2): |
| 5518 | q.breakable() |
| 5519 | q.text("xid = "); |
| 5520 | if self.xid != None: |
| 5521 | q.text("%#x" % self.xid) |
| 5522 | else: |
| 5523 | q.text('None') |
| 5524 | q.text(","); q.breakable() |
| 5525 | q.text("flags = "); |
| 5526 | q.text("%#x" % self.flags) |
| 5527 | q.text(","); q.breakable() |
| 5528 | q.text("entries = "); |
| 5529 | q.pp(self.entries) |
| 5530 | q.breakable() |
| 5531 | q.text('}') |
| 5532 | |
| 5533 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5534 | version = 2 |
| 5535 | type = 18 |
| 5536 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5537 | |
| 5538 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
| 5539 | self.xid = xid |
| 5540 | if flags != None: |
| 5541 | self.flags = flags |
| 5542 | else: |
| 5543 | self.flags = 0 |
| 5544 | if port_no != None: |
| 5545 | self.port_no = port_no |
| 5546 | else: |
| 5547 | self.port_no = 0 |
| 5548 | if queue_id != None: |
| 5549 | self.queue_id = queue_id |
| 5550 | else: |
| 5551 | self.queue_id = 0 |
| 5552 | |
| 5553 | def pack(self): |
| 5554 | packed = [] |
| 5555 | packed.append(struct.pack("!B", self.version)) |
| 5556 | packed.append(struct.pack("!B", self.type)) |
| 5557 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5558 | packed.append(struct.pack("!L", self.xid)) |
| 5559 | packed.append(struct.pack("!H", self.stats_type)) |
| 5560 | packed.append(struct.pack("!H", self.flags)) |
| 5561 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5562 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5563 | packed.append(struct.pack("!L", self.queue_id)) |
| 5564 | length = sum([len(x) for x in packed]) |
| 5565 | packed[2] = struct.pack("!H", length) |
| 5566 | return ''.join(packed) |
| 5567 | |
| 5568 | @staticmethod |
| 5569 | def unpack(buf): |
| 5570 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5571 | obj = queue_stats_request() |
| 5572 | if type(buf) == loxi.generic_util.OFReader: |
| 5573 | reader = buf |
| 5574 | else: |
| 5575 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5576 | _version = reader.read("!B")[0] |
| 5577 | assert(_version == 2) |
| 5578 | _type = reader.read("!B")[0] |
| 5579 | assert(_type == 18) |
| 5580 | _length = reader.read("!H")[0] |
| 5581 | obj.xid = reader.read("!L")[0] |
| 5582 | _stats_type = reader.read("!H")[0] |
| 5583 | assert(_stats_type == 5) |
| 5584 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5585 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5586 | obj.port_no = util.unpack_port_no(reader) |
| 5587 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5588 | return obj |
| 5589 | |
| 5590 | def __eq__(self, other): |
| 5591 | if type(self) != type(other): return False |
| 5592 | if self.version != other.version: return False |
| 5593 | if self.type != other.type: return False |
| 5594 | if self.xid != other.xid: return False |
| 5595 | if self.flags != other.flags: return False |
| 5596 | if self.port_no != other.port_no: return False |
| 5597 | if self.queue_id != other.queue_id: return False |
| 5598 | return True |
| 5599 | |
| 5600 | def __ne__(self, other): |
| 5601 | return not self.__eq__(other) |
| 5602 | |
| 5603 | def __str__(self): |
| 5604 | return self.show() |
| 5605 | |
| 5606 | def show(self): |
| 5607 | import loxi.pp |
| 5608 | return loxi.pp.pp(self) |
| 5609 | |
| 5610 | def pretty_print(self, q): |
| 5611 | q.text("queue_stats_request {") |
| 5612 | with q.group(): |
| 5613 | with q.indent(2): |
| 5614 | q.breakable() |
| 5615 | q.text("xid = "); |
| 5616 | if self.xid != None: |
| 5617 | q.text("%#x" % self.xid) |
| 5618 | else: |
| 5619 | q.text('None') |
| 5620 | q.text(","); q.breakable() |
| 5621 | q.text("flags = "); |
| 5622 | q.text("%#x" % self.flags) |
| 5623 | q.text(","); q.breakable() |
| 5624 | q.text("port_no = "); |
| 5625 | q.text(util.pretty_port(self.port_no)) |
| 5626 | q.text(","); q.breakable() |
| 5627 | q.text("queue_id = "); |
| 5628 | q.text("%#x" % self.queue_id) |
| 5629 | q.breakable() |
| 5630 | q.text('}') |
| 5631 | |
| 5632 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5633 | version = 2 |
| 5634 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5635 | |
| 5636 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 5637 | self.xid = xid |
| 5638 | if flags != None: |
| 5639 | self.flags = flags |
| 5640 | else: |
| 5641 | self.flags = 0 |
| 5642 | if miss_send_len != None: |
| 5643 | self.miss_send_len = miss_send_len |
| 5644 | else: |
| 5645 | self.miss_send_len = 0 |
| 5646 | |
| 5647 | def pack(self): |
| 5648 | packed = [] |
| 5649 | packed.append(struct.pack("!B", self.version)) |
| 5650 | packed.append(struct.pack("!B", self.type)) |
| 5651 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5652 | packed.append(struct.pack("!L", self.xid)) |
| 5653 | packed.append(struct.pack("!H", self.flags)) |
| 5654 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5655 | length = sum([len(x) for x in packed]) |
| 5656 | packed[2] = struct.pack("!H", length) |
| 5657 | return ''.join(packed) |
| 5658 | |
| 5659 | @staticmethod |
| 5660 | def unpack(buf): |
| 5661 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5662 | obj = set_config() |
| 5663 | if type(buf) == loxi.generic_util.OFReader: |
| 5664 | reader = buf |
| 5665 | else: |
| 5666 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5667 | _version = reader.read("!B")[0] |
| 5668 | assert(_version == 2) |
| 5669 | _type = reader.read("!B")[0] |
| 5670 | assert(_type == 9) |
| 5671 | _length = reader.read("!H")[0] |
| 5672 | obj.xid = reader.read("!L")[0] |
| 5673 | obj.flags = reader.read("!H")[0] |
| 5674 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5675 | return obj |
| 5676 | |
| 5677 | def __eq__(self, other): |
| 5678 | if type(self) != type(other): return False |
| 5679 | if self.version != other.version: return False |
| 5680 | if self.type != other.type: return False |
| 5681 | if self.xid != other.xid: return False |
| 5682 | if self.flags != other.flags: return False |
| 5683 | if self.miss_send_len != other.miss_send_len: return False |
| 5684 | return True |
| 5685 | |
| 5686 | def __ne__(self, other): |
| 5687 | return not self.__eq__(other) |
| 5688 | |
| 5689 | def __str__(self): |
| 5690 | return self.show() |
| 5691 | |
| 5692 | def show(self): |
| 5693 | import loxi.pp |
| 5694 | return loxi.pp.pp(self) |
| 5695 | |
| 5696 | def pretty_print(self, q): |
| 5697 | q.text("set_config {") |
| 5698 | with q.group(): |
| 5699 | with q.indent(2): |
| 5700 | q.breakable() |
| 5701 | q.text("xid = "); |
| 5702 | if self.xid != None: |
| 5703 | q.text("%#x" % self.xid) |
| 5704 | else: |
| 5705 | q.text('None') |
| 5706 | q.text(","); q.breakable() |
| 5707 | q.text("flags = "); |
| 5708 | q.text("%#x" % self.flags) |
| 5709 | q.text(","); q.breakable() |
| 5710 | q.text("miss_send_len = "); |
| 5711 | q.text("%#x" % self.miss_send_len) |
| 5712 | q.breakable() |
| 5713 | q.text('}') |
| 5714 | |
| 5715 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5716 | version = 2 |
| 5717 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5718 | |
| 5719 | def __init__(self, xid=None, table_id=None, config=None): |
| 5720 | self.xid = xid |
| 5721 | if table_id != None: |
| 5722 | self.table_id = table_id |
| 5723 | else: |
| 5724 | self.table_id = 0 |
| 5725 | if config != None: |
| 5726 | self.config = config |
| 5727 | else: |
| 5728 | self.config = 0 |
| 5729 | |
| 5730 | def pack(self): |
| 5731 | packed = [] |
| 5732 | packed.append(struct.pack("!B", self.version)) |
| 5733 | packed.append(struct.pack("!B", self.type)) |
| 5734 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5735 | packed.append(struct.pack("!L", self.xid)) |
| 5736 | packed.append(struct.pack("!B", self.table_id)) |
| 5737 | packed.append('\x00' * 3) |
| 5738 | packed.append(struct.pack("!L", self.config)) |
| 5739 | length = sum([len(x) for x in packed]) |
| 5740 | packed[2] = struct.pack("!H", length) |
| 5741 | return ''.join(packed) |
| 5742 | |
| 5743 | @staticmethod |
| 5744 | def unpack(buf): |
| 5745 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5746 | obj = table_mod() |
| 5747 | if type(buf) == loxi.generic_util.OFReader: |
| 5748 | reader = buf |
| 5749 | else: |
| 5750 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5751 | _version = reader.read("!B")[0] |
| 5752 | assert(_version == 2) |
| 5753 | _type = reader.read("!B")[0] |
| 5754 | assert(_type == 17) |
| 5755 | _length = reader.read("!H")[0] |
| 5756 | obj.xid = reader.read("!L")[0] |
| 5757 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5758 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5759 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 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.table_id != other.table_id: return False |
| 5768 | if self.config != other.config: return False |
| 5769 | return True |
| 5770 | |
| 5771 | def __ne__(self, other): |
| 5772 | return not self.__eq__(other) |
| 5773 | |
| 5774 | def __str__(self): |
| 5775 | return self.show() |
| 5776 | |
| 5777 | def show(self): |
| 5778 | import loxi.pp |
| 5779 | return loxi.pp.pp(self) |
| 5780 | |
| 5781 | def pretty_print(self, q): |
| 5782 | q.text("table_mod {") |
| 5783 | with q.group(): |
| 5784 | with q.indent(2): |
| 5785 | q.breakable() |
| 5786 | q.text("xid = "); |
| 5787 | if self.xid != None: |
| 5788 | q.text("%#x" % self.xid) |
| 5789 | else: |
| 5790 | q.text('None') |
| 5791 | q.text(","); q.breakable() |
| 5792 | q.text("table_id = "); |
| 5793 | q.text("%#x" % self.table_id) |
| 5794 | q.text(","); q.breakable() |
| 5795 | q.text("config = "); |
| 5796 | q.text("%#x" % self.config) |
| 5797 | q.breakable() |
| 5798 | q.text('}') |
| 5799 | |
| 5800 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5801 | version = 2 |
| 5802 | type = 19 |
| 5803 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5804 | |
| 5805 | def __init__(self, xid=None, flags=None, entries=None): |
| 5806 | self.xid = xid |
| 5807 | if flags != None: |
| 5808 | self.flags = flags |
| 5809 | else: |
| 5810 | self.flags = 0 |
| 5811 | if entries != None: |
| 5812 | self.entries = entries |
| 5813 | else: |
| 5814 | self.entries = [] |
| 5815 | |
| 5816 | def pack(self): |
| 5817 | packed = [] |
| 5818 | packed.append(struct.pack("!B", self.version)) |
| 5819 | packed.append(struct.pack("!B", self.type)) |
| 5820 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5821 | packed.append(struct.pack("!L", self.xid)) |
| 5822 | packed.append(struct.pack("!H", self.stats_type)) |
| 5823 | packed.append(struct.pack("!H", self.flags)) |
| 5824 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5825 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5826 | length = sum([len(x) for x in packed]) |
| 5827 | packed[2] = struct.pack("!H", length) |
| 5828 | return ''.join(packed) |
| 5829 | |
| 5830 | @staticmethod |
| 5831 | def unpack(buf): |
| 5832 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5833 | obj = table_stats_reply() |
| 5834 | if type(buf) == loxi.generic_util.OFReader: |
| 5835 | reader = buf |
| 5836 | else: |
| 5837 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5838 | _version = reader.read("!B")[0] |
| 5839 | assert(_version == 2) |
| 5840 | _type = reader.read("!B")[0] |
| 5841 | assert(_type == 19) |
| 5842 | _length = reader.read("!H")[0] |
| 5843 | obj.xid = reader.read("!L")[0] |
| 5844 | _stats_type = reader.read("!H")[0] |
| 5845 | assert(_stats_type == 3) |
| 5846 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5847 | reader.skip(4) |
| 5848 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 5849 | return obj |
| 5850 | |
| 5851 | def __eq__(self, other): |
| 5852 | if type(self) != type(other): return False |
| 5853 | if self.version != other.version: return False |
| 5854 | if self.type != other.type: return False |
| 5855 | if self.xid != other.xid: return False |
| 5856 | if self.flags != other.flags: return False |
| 5857 | if self.entries != other.entries: return False |
| 5858 | return True |
| 5859 | |
| 5860 | def __ne__(self, other): |
| 5861 | return not self.__eq__(other) |
| 5862 | |
| 5863 | def __str__(self): |
| 5864 | return self.show() |
| 5865 | |
| 5866 | def show(self): |
| 5867 | import loxi.pp |
| 5868 | return loxi.pp.pp(self) |
| 5869 | |
| 5870 | def pretty_print(self, q): |
| 5871 | q.text("table_stats_reply {") |
| 5872 | with q.group(): |
| 5873 | with q.indent(2): |
| 5874 | q.breakable() |
| 5875 | q.text("xid = "); |
| 5876 | if self.xid != None: |
| 5877 | q.text("%#x" % self.xid) |
| 5878 | else: |
| 5879 | q.text('None') |
| 5880 | q.text(","); q.breakable() |
| 5881 | q.text("flags = "); |
| 5882 | q.text("%#x" % self.flags) |
| 5883 | q.text(","); q.breakable() |
| 5884 | q.text("entries = "); |
| 5885 | q.pp(self.entries) |
| 5886 | q.breakable() |
| 5887 | q.text('}') |
| 5888 | |
| 5889 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5890 | version = 2 |
| 5891 | type = 18 |
| 5892 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5893 | |
| 5894 | def __init__(self, xid=None, flags=None): |
| 5895 | self.xid = xid |
| 5896 | if flags != None: |
| 5897 | self.flags = flags |
| 5898 | else: |
| 5899 | self.flags = 0 |
| 5900 | |
| 5901 | def pack(self): |
| 5902 | packed = [] |
| 5903 | packed.append(struct.pack("!B", self.version)) |
| 5904 | packed.append(struct.pack("!B", self.type)) |
| 5905 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5906 | packed.append(struct.pack("!L", self.xid)) |
| 5907 | packed.append(struct.pack("!H", self.stats_type)) |
| 5908 | packed.append(struct.pack("!H", self.flags)) |
| 5909 | packed.append('\x00' * 4) |
| 5910 | length = sum([len(x) for x in packed]) |
| 5911 | packed[2] = struct.pack("!H", length) |
| 5912 | return ''.join(packed) |
| 5913 | |
| 5914 | @staticmethod |
| 5915 | def unpack(buf): |
| 5916 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5917 | obj = table_stats_request() |
| 5918 | if type(buf) == loxi.generic_util.OFReader: |
| 5919 | reader = buf |
| 5920 | else: |
| 5921 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5922 | _version = reader.read("!B")[0] |
| 5923 | assert(_version == 2) |
| 5924 | _type = reader.read("!B")[0] |
| 5925 | assert(_type == 18) |
| 5926 | _length = reader.read("!H")[0] |
| 5927 | obj.xid = reader.read("!L")[0] |
| 5928 | _stats_type = reader.read("!H")[0] |
| 5929 | assert(_stats_type == 3) |
| 5930 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5931 | reader.skip(4) |
| 5932 | return obj |
| 5933 | |
| 5934 | def __eq__(self, other): |
| 5935 | if type(self) != type(other): return False |
| 5936 | if self.version != other.version: return False |
| 5937 | if self.type != other.type: return False |
| 5938 | if self.xid != other.xid: return False |
| 5939 | if self.flags != other.flags: return False |
| 5940 | return True |
| 5941 | |
| 5942 | def __ne__(self, other): |
| 5943 | return not self.__eq__(other) |
| 5944 | |
| 5945 | def __str__(self): |
| 5946 | return self.show() |
| 5947 | |
| 5948 | def show(self): |
| 5949 | import loxi.pp |
| 5950 | return loxi.pp.pp(self) |
| 5951 | |
| 5952 | def pretty_print(self, q): |
| 5953 | q.text("table_stats_request {") |
| 5954 | with q.group(): |
| 5955 | with q.indent(2): |
| 5956 | q.breakable() |
| 5957 | q.text("xid = "); |
| 5958 | if self.xid != None: |
| 5959 | q.text("%#x" % self.xid) |
| 5960 | else: |
| 5961 | q.text('None') |
| 5962 | q.text(","); q.breakable() |
| 5963 | q.text("flags = "); |
| 5964 | q.text("%#x" % self.flags) |
| 5965 | q.breakable() |
| 5966 | q.text('}') |
| 5967 | |
| 5968 | |
| 5969 | def parse_header(buf): |
| 5970 | if len(buf) < 8: |
| 5971 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 5972 | return struct.unpack_from("!BBHL", buf) |
| 5973 | |
| 5974 | def parse_message(buf): |
| 5975 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 5976 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 5977 | 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] | 5978 | if len(buf) != msg_len: |
| 5979 | raise loxi.ProtocolError("incorrect message size") |
| 5980 | if msg_type in parsers: |
| 5981 | return parsers[msg_type](buf) |
| 5982 | else: |
| 5983 | raise loxi.ProtocolError("unexpected message type") |
| 5984 | |
| 5985 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 5986 | if len(buf) < 25 + 1: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5987 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 5988 | # Technically uint16_t for OF 1.0 |
| 5989 | cmd, = struct.unpack_from("!B", buf, 25) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5990 | if cmd in flow_mod_parsers: |
| 5991 | return flow_mod_parsers[cmd](buf) |
| 5992 | else: |
| 5993 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 5994 | |
| 5995 | def parse_stats_reply(buf): |
| 5996 | if len(buf) < 8 + 2: |
| 5997 | raise loxi.ProtocolError("message too short") |
| 5998 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 5999 | if stats_type in stats_reply_parsers: |
| 6000 | return stats_reply_parsers[stats_type](buf) |
| 6001 | else: |
| 6002 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 6003 | |
| 6004 | def parse_stats_request(buf): |
| 6005 | if len(buf) < 8 + 2: |
| 6006 | raise loxi.ProtocolError("message too short") |
| 6007 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 6008 | if stats_type in stats_request_parsers: |
| 6009 | return stats_request_parsers[stats_type](buf) |
| 6010 | else: |
| 6011 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 6012 | |
| 6013 | def parse_experimenter(buf): |
| 6014 | if len(buf) < 16: |
| 6015 | raise loxi.ProtocolError("experimenter message too short") |
| 6016 | |
| 6017 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 6018 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 6019 | subtype, = struct.unpack_from("!L", buf, 12) |
| 6020 | elif experimenter == 0x00002320: # Nicira |
| 6021 | subtype, = struct.unpack_from("!L", buf, 12) |
| 6022 | else: |
| 6023 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 6024 | |
| 6025 | if subtype in experimenter_parsers[experimenter]: |
| 6026 | return experimenter_parsers[experimenter][subtype](buf) |
| 6027 | else: |
| 6028 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 6029 | |
| 6030 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6031 | const.OFPT_HELLO : hello.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6032 | const.OFPT_ERROR : error_msg.unpack, |
| 6033 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 6034 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
| 6035 | const.OFPT_EXPERIMENTER : parse_experimenter, |
| 6036 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 6037 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 6038 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 6039 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6040 | const.OFPT_SET_CONFIG : set_config.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6041 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 6042 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 6043 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 6044 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 6045 | const.OFPT_FLOW_MOD : parse_flow_mod, |
| 6046 | const.OFPT_GROUP_MOD : group_mod.unpack, |
| 6047 | const.OFPT_PORT_MOD : port_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6048 | const.OFPT_TABLE_MOD : table_mod.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6049 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 6050 | const.OFPT_STATS_REPLY : parse_stats_reply, |
| 6051 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 6052 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 6053 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 6054 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6055 | } |
| 6056 | |
| 6057 | flow_mod_parsers = { |
| 6058 | const.OFPFC_ADD : flow_add.unpack, |
| 6059 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 6060 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 6061 | const.OFPFC_DELETE : flow_delete.unpack, |
| 6062 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 6063 | } |
| 6064 | |
| 6065 | stats_reply_parsers = { |
| 6066 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 6067 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 6068 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 6069 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 6070 | const.OFPST_PORT : port_stats_reply.unpack, |
| 6071 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
| 6072 | const.OFPST_EXPERIMENTER : experimenter_stats_reply.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 6073 | const.OFPST_GROUP : group_stats_reply.unpack, |
| 6074 | const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6075 | } |
| 6076 | |
| 6077 | stats_request_parsers = { |
| 6078 | const.OFPST_DESC : desc_stats_request.unpack, |
| 6079 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 6080 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 6081 | const.OFPST_TABLE : table_stats_request.unpack, |
| 6082 | const.OFPST_PORT : port_stats_request.unpack, |
| 6083 | const.OFPST_QUEUE : queue_stats_request.unpack, |
| 6084 | const.OFPST_EXPERIMENTER : experimenter_stats_request.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 6085 | const.OFPST_GROUP : group_stats_request.unpack, |
| 6086 | const.OFPST_GROUP_DESC : group_desc_stats_request.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6087 | } |
| 6088 | |
| 6089 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6090 | 6035143 : { |
| 6091 | 22: bsn_bw_clear_data_reply.unpack, |
| 6092 | 21: bsn_bw_clear_data_request.unpack, |
| 6093 | 20: bsn_bw_enable_get_reply.unpack, |
| 6094 | 19: bsn_bw_enable_get_request.unpack, |
| 6095 | 23: bsn_bw_enable_set_reply.unpack, |
| 6096 | 18: bsn_bw_enable_set_request.unpack, |
| 6097 | 10: bsn_get_interfaces_reply.unpack, |
| 6098 | 9: bsn_get_interfaces_request.unpack, |
| 6099 | 5: bsn_get_mirroring_reply.unpack, |
| 6100 | 4: bsn_get_mirroring_request.unpack, |
| 6101 | 3: bsn_set_mirroring.unpack, |
| 6102 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 6103 | 11: bsn_set_pktin_suppression_request.unpack, |
| 6104 | 16: bsn_virtual_port_create_reply.unpack, |
| 6105 | 15: bsn_virtual_port_create_request.unpack, |
| 6106 | 26: bsn_virtual_port_remove_reply.unpack, |
| 6107 | 17: bsn_virtual_port_remove_request.unpack, |
| 6108 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6109 | } |