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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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 == 3) |
| 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 = 3 |
| 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, subtype=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 subtype != None: |
| 2281 | self.subtype = subtype |
| 2282 | else: |
| 2283 | self.subtype = 0 |
| 2284 | if data != None: |
| 2285 | self.data = data |
| 2286 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2287 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2288 | |
| 2289 | def pack(self): |
| 2290 | packed = [] |
| 2291 | packed.append(struct.pack("!B", self.version)) |
| 2292 | packed.append(struct.pack("!B", self.type)) |
| 2293 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2294 | packed.append(struct.pack("!L", self.xid)) |
| 2295 | packed.append(struct.pack("!H", self.stats_type)) |
| 2296 | packed.append(struct.pack("!H", self.flags)) |
| 2297 | packed.append('\x00' * 4) |
| 2298 | packed.append(struct.pack("!L", self.experimenter)) |
| 2299 | packed.append(struct.pack("!L", self.subtype)) |
| 2300 | packed.append(self.data) |
| 2301 | length = sum([len(x) for x in packed]) |
| 2302 | packed[2] = struct.pack("!H", length) |
| 2303 | return ''.join(packed) |
| 2304 | |
| 2305 | @staticmethod |
| 2306 | def unpack(buf): |
| 2307 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2308 | obj = experimenter_stats_reply() |
| 2309 | if type(buf) == loxi.generic_util.OFReader: |
| 2310 | reader = buf |
| 2311 | else: |
| 2312 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2313 | _version = reader.read("!B")[0] |
| 2314 | assert(_version == 3) |
| 2315 | _type = reader.read("!B")[0] |
| 2316 | assert(_type == 19) |
| 2317 | _length = reader.read("!H")[0] |
| 2318 | obj.xid = reader.read("!L")[0] |
| 2319 | _stats_type = reader.read("!H")[0] |
| 2320 | assert(_stats_type == 65535) |
| 2321 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2322 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2323 | obj.experimenter = reader.read("!L")[0] |
| 2324 | obj.subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2325 | obj.data = str(reader.read_all()) |
| 2326 | return obj |
| 2327 | |
| 2328 | def __eq__(self, other): |
| 2329 | if type(self) != type(other): return False |
| 2330 | if self.version != other.version: return False |
| 2331 | if self.type != other.type: return False |
| 2332 | if self.xid != other.xid: return False |
| 2333 | if self.flags != other.flags: return False |
| 2334 | if self.experimenter != other.experimenter: return False |
| 2335 | if self.subtype != other.subtype: return False |
| 2336 | if self.data != other.data: return False |
| 2337 | return True |
| 2338 | |
| 2339 | def __ne__(self, other): |
| 2340 | return not self.__eq__(other) |
| 2341 | |
| 2342 | def __str__(self): |
| 2343 | return self.show() |
| 2344 | |
| 2345 | def show(self): |
| 2346 | import loxi.pp |
| 2347 | return loxi.pp.pp(self) |
| 2348 | |
| 2349 | def pretty_print(self, q): |
| 2350 | q.text("experimenter_stats_reply {") |
| 2351 | with q.group(): |
| 2352 | with q.indent(2): |
| 2353 | q.breakable() |
| 2354 | q.text("xid = "); |
| 2355 | if self.xid != None: |
| 2356 | q.text("%#x" % self.xid) |
| 2357 | else: |
| 2358 | q.text('None') |
| 2359 | q.text(","); q.breakable() |
| 2360 | q.text("flags = "); |
| 2361 | q.text("%#x" % self.flags) |
| 2362 | q.text(","); q.breakable() |
| 2363 | q.text("experimenter = "); |
| 2364 | q.text("%#x" % self.experimenter) |
| 2365 | q.text(","); q.breakable() |
| 2366 | q.text("subtype = "); |
| 2367 | q.text("%#x" % self.subtype) |
| 2368 | q.text(","); q.breakable() |
| 2369 | q.text("data = "); |
| 2370 | q.pp(self.data) |
| 2371 | q.breakable() |
| 2372 | q.text('}') |
| 2373 | |
| 2374 | class experimenter_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2375 | version = 3 |
| 2376 | type = 18 |
| 2377 | stats_type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2378 | |
| 2379 | def __init__(self, xid=None, flags=None, experimenter=None, subtype=None, data=None): |
| 2380 | self.xid = xid |
| 2381 | if flags != None: |
| 2382 | self.flags = flags |
| 2383 | else: |
| 2384 | self.flags = 0 |
| 2385 | if experimenter != None: |
| 2386 | self.experimenter = experimenter |
| 2387 | else: |
| 2388 | self.experimenter = 0 |
| 2389 | if subtype != None: |
| 2390 | self.subtype = subtype |
| 2391 | else: |
| 2392 | self.subtype = 0 |
| 2393 | if data != None: |
| 2394 | self.data = data |
| 2395 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2396 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2397 | |
| 2398 | def pack(self): |
| 2399 | packed = [] |
| 2400 | packed.append(struct.pack("!B", self.version)) |
| 2401 | packed.append(struct.pack("!B", self.type)) |
| 2402 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2403 | packed.append(struct.pack("!L", self.xid)) |
| 2404 | packed.append(struct.pack("!H", self.stats_type)) |
| 2405 | packed.append(struct.pack("!H", self.flags)) |
| 2406 | packed.append('\x00' * 4) |
| 2407 | packed.append(struct.pack("!L", self.experimenter)) |
| 2408 | packed.append(struct.pack("!L", self.subtype)) |
| 2409 | packed.append(self.data) |
| 2410 | length = sum([len(x) for x in packed]) |
| 2411 | packed[2] = struct.pack("!H", length) |
| 2412 | return ''.join(packed) |
| 2413 | |
| 2414 | @staticmethod |
| 2415 | def unpack(buf): |
| 2416 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2417 | obj = experimenter_stats_request() |
| 2418 | if type(buf) == loxi.generic_util.OFReader: |
| 2419 | reader = buf |
| 2420 | else: |
| 2421 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2422 | _version = reader.read("!B")[0] |
| 2423 | assert(_version == 3) |
| 2424 | _type = reader.read("!B")[0] |
| 2425 | assert(_type == 18) |
| 2426 | _length = reader.read("!H")[0] |
| 2427 | obj.xid = reader.read("!L")[0] |
| 2428 | _stats_type = reader.read("!H")[0] |
| 2429 | assert(_stats_type == 65535) |
| 2430 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2431 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2432 | obj.experimenter = reader.read("!L")[0] |
| 2433 | obj.subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2434 | obj.data = str(reader.read_all()) |
| 2435 | return obj |
| 2436 | |
| 2437 | def __eq__(self, other): |
| 2438 | if type(self) != type(other): return False |
| 2439 | if self.version != other.version: return False |
| 2440 | if self.type != other.type: return False |
| 2441 | if self.xid != other.xid: return False |
| 2442 | if self.flags != other.flags: return False |
| 2443 | if self.experimenter != other.experimenter: return False |
| 2444 | if self.subtype != other.subtype: return False |
| 2445 | if self.data != other.data: return False |
| 2446 | return True |
| 2447 | |
| 2448 | def __ne__(self, other): |
| 2449 | return not self.__eq__(other) |
| 2450 | |
| 2451 | def __str__(self): |
| 2452 | return self.show() |
| 2453 | |
| 2454 | def show(self): |
| 2455 | import loxi.pp |
| 2456 | return loxi.pp.pp(self) |
| 2457 | |
| 2458 | def pretty_print(self, q): |
| 2459 | q.text("experimenter_stats_request {") |
| 2460 | with q.group(): |
| 2461 | with q.indent(2): |
| 2462 | q.breakable() |
| 2463 | q.text("xid = "); |
| 2464 | if self.xid != None: |
| 2465 | q.text("%#x" % self.xid) |
| 2466 | else: |
| 2467 | q.text('None') |
| 2468 | q.text(","); q.breakable() |
| 2469 | q.text("flags = "); |
| 2470 | q.text("%#x" % self.flags) |
| 2471 | q.text(","); q.breakable() |
| 2472 | q.text("experimenter = "); |
| 2473 | q.text("%#x" % self.experimenter) |
| 2474 | q.text(","); q.breakable() |
| 2475 | q.text("subtype = "); |
| 2476 | q.text("%#x" % self.subtype) |
| 2477 | q.text(","); q.breakable() |
| 2478 | q.text("data = "); |
| 2479 | q.pp(self.data) |
| 2480 | q.breakable() |
| 2481 | q.text('}') |
| 2482 | |
| 2483 | class features_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2484 | version = 3 |
| 2485 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2486 | |
| 2487 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, reserved=None, ports=None): |
| 2488 | self.xid = xid |
| 2489 | if datapath_id != None: |
| 2490 | self.datapath_id = datapath_id |
| 2491 | else: |
| 2492 | self.datapath_id = 0 |
| 2493 | if n_buffers != None: |
| 2494 | self.n_buffers = n_buffers |
| 2495 | else: |
| 2496 | self.n_buffers = 0 |
| 2497 | if n_tables != None: |
| 2498 | self.n_tables = n_tables |
| 2499 | else: |
| 2500 | self.n_tables = 0 |
| 2501 | if capabilities != None: |
| 2502 | self.capabilities = capabilities |
| 2503 | else: |
| 2504 | self.capabilities = 0 |
| 2505 | if reserved != None: |
| 2506 | self.reserved = reserved |
| 2507 | else: |
| 2508 | self.reserved = 0 |
| 2509 | if ports != None: |
| 2510 | self.ports = ports |
| 2511 | else: |
| 2512 | self.ports = [] |
| 2513 | |
| 2514 | def pack(self): |
| 2515 | packed = [] |
| 2516 | packed.append(struct.pack("!B", self.version)) |
| 2517 | packed.append(struct.pack("!B", self.type)) |
| 2518 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2519 | packed.append(struct.pack("!L", self.xid)) |
| 2520 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 2521 | packed.append(struct.pack("!L", self.n_buffers)) |
| 2522 | packed.append(struct.pack("!B", self.n_tables)) |
| 2523 | packed.append('\x00' * 3) |
| 2524 | packed.append(struct.pack("!L", self.capabilities)) |
| 2525 | packed.append(struct.pack("!L", self.reserved)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2526 | packed.append(util.pack_list(self.ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2527 | length = sum([len(x) for x in packed]) |
| 2528 | packed[2] = struct.pack("!H", length) |
| 2529 | return ''.join(packed) |
| 2530 | |
| 2531 | @staticmethod |
| 2532 | def unpack(buf): |
| 2533 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2534 | obj = features_reply() |
| 2535 | if type(buf) == loxi.generic_util.OFReader: |
| 2536 | reader = buf |
| 2537 | else: |
| 2538 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2539 | _version = reader.read("!B")[0] |
| 2540 | assert(_version == 3) |
| 2541 | _type = reader.read("!B")[0] |
| 2542 | assert(_type == 6) |
| 2543 | _length = reader.read("!H")[0] |
| 2544 | obj.xid = reader.read("!L")[0] |
| 2545 | obj.datapath_id = reader.read("!Q")[0] |
| 2546 | obj.n_buffers = reader.read("!L")[0] |
| 2547 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2548 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2549 | obj.capabilities = reader.read("!L")[0] |
| 2550 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2551 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 2552 | return obj |
| 2553 | |
| 2554 | def __eq__(self, other): |
| 2555 | if type(self) != type(other): return False |
| 2556 | if self.version != other.version: return False |
| 2557 | if self.type != other.type: return False |
| 2558 | if self.xid != other.xid: return False |
| 2559 | if self.datapath_id != other.datapath_id: return False |
| 2560 | if self.n_buffers != other.n_buffers: return False |
| 2561 | if self.n_tables != other.n_tables: return False |
| 2562 | if self.capabilities != other.capabilities: return False |
| 2563 | if self.reserved != other.reserved: return False |
| 2564 | if self.ports != other.ports: return False |
| 2565 | return True |
| 2566 | |
| 2567 | def __ne__(self, other): |
| 2568 | return not self.__eq__(other) |
| 2569 | |
| 2570 | def __str__(self): |
| 2571 | return self.show() |
| 2572 | |
| 2573 | def show(self): |
| 2574 | import loxi.pp |
| 2575 | return loxi.pp.pp(self) |
| 2576 | |
| 2577 | def pretty_print(self, q): |
| 2578 | q.text("features_reply {") |
| 2579 | with q.group(): |
| 2580 | with q.indent(2): |
| 2581 | q.breakable() |
| 2582 | q.text("xid = "); |
| 2583 | if self.xid != None: |
| 2584 | q.text("%#x" % self.xid) |
| 2585 | else: |
| 2586 | q.text('None') |
| 2587 | q.text(","); q.breakable() |
| 2588 | q.text("datapath_id = "); |
| 2589 | q.text("%#x" % self.datapath_id) |
| 2590 | q.text(","); q.breakable() |
| 2591 | q.text("n_buffers = "); |
| 2592 | q.text("%#x" % self.n_buffers) |
| 2593 | q.text(","); q.breakable() |
| 2594 | q.text("n_tables = "); |
| 2595 | q.text("%#x" % self.n_tables) |
| 2596 | q.text(","); q.breakable() |
| 2597 | q.text("capabilities = "); |
| 2598 | q.text("%#x" % self.capabilities) |
| 2599 | q.text(","); q.breakable() |
| 2600 | q.text("reserved = "); |
| 2601 | q.text("%#x" % self.reserved) |
| 2602 | q.text(","); q.breakable() |
| 2603 | q.text("ports = "); |
| 2604 | q.pp(self.ports) |
| 2605 | q.breakable() |
| 2606 | q.text('}') |
| 2607 | |
| 2608 | class features_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2609 | version = 3 |
| 2610 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2611 | |
| 2612 | def __init__(self, xid=None): |
| 2613 | self.xid = xid |
| 2614 | |
| 2615 | def pack(self): |
| 2616 | packed = [] |
| 2617 | packed.append(struct.pack("!B", self.version)) |
| 2618 | packed.append(struct.pack("!B", self.type)) |
| 2619 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2620 | packed.append(struct.pack("!L", self.xid)) |
| 2621 | length = sum([len(x) for x in packed]) |
| 2622 | packed[2] = struct.pack("!H", length) |
| 2623 | return ''.join(packed) |
| 2624 | |
| 2625 | @staticmethod |
| 2626 | def unpack(buf): |
| 2627 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2628 | obj = features_request() |
| 2629 | if type(buf) == loxi.generic_util.OFReader: |
| 2630 | reader = buf |
| 2631 | else: |
| 2632 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2633 | _version = reader.read("!B")[0] |
| 2634 | assert(_version == 3) |
| 2635 | _type = reader.read("!B")[0] |
| 2636 | assert(_type == 5) |
| 2637 | _length = reader.read("!H")[0] |
| 2638 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2639 | return obj |
| 2640 | |
| 2641 | def __eq__(self, other): |
| 2642 | if type(self) != type(other): return False |
| 2643 | if self.version != other.version: return False |
| 2644 | if self.type != other.type: return False |
| 2645 | if self.xid != other.xid: return False |
| 2646 | return True |
| 2647 | |
| 2648 | def __ne__(self, other): |
| 2649 | return not self.__eq__(other) |
| 2650 | |
| 2651 | def __str__(self): |
| 2652 | return self.show() |
| 2653 | |
| 2654 | def show(self): |
| 2655 | import loxi.pp |
| 2656 | return loxi.pp.pp(self) |
| 2657 | |
| 2658 | def pretty_print(self, q): |
| 2659 | q.text("features_request {") |
| 2660 | with q.group(): |
| 2661 | with q.indent(2): |
| 2662 | q.breakable() |
| 2663 | q.text("xid = "); |
| 2664 | if self.xid != None: |
| 2665 | q.text("%#x" % self.xid) |
| 2666 | else: |
| 2667 | q.text('None') |
| 2668 | q.breakable() |
| 2669 | q.text('}') |
| 2670 | |
| 2671 | class flow_add(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2672 | version = 3 |
| 2673 | type = 14 |
| 2674 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2675 | |
| 2676 | 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): |
| 2677 | self.xid = xid |
| 2678 | if cookie != None: |
| 2679 | self.cookie = cookie |
| 2680 | else: |
| 2681 | self.cookie = 0 |
| 2682 | if cookie_mask != None: |
| 2683 | self.cookie_mask = cookie_mask |
| 2684 | else: |
| 2685 | self.cookie_mask = 0 |
| 2686 | if table_id != None: |
| 2687 | self.table_id = table_id |
| 2688 | else: |
| 2689 | self.table_id = 0 |
| 2690 | if idle_timeout != None: |
| 2691 | self.idle_timeout = idle_timeout |
| 2692 | else: |
| 2693 | self.idle_timeout = 0 |
| 2694 | if hard_timeout != None: |
| 2695 | self.hard_timeout = hard_timeout |
| 2696 | else: |
| 2697 | self.hard_timeout = 0 |
| 2698 | if priority != None: |
| 2699 | self.priority = priority |
| 2700 | else: |
| 2701 | self.priority = 0 |
| 2702 | if buffer_id != None: |
| 2703 | self.buffer_id = buffer_id |
| 2704 | else: |
| 2705 | self.buffer_id = 0 |
| 2706 | if out_port != None: |
| 2707 | self.out_port = out_port |
| 2708 | else: |
| 2709 | self.out_port = 0 |
| 2710 | if out_group != None: |
| 2711 | self.out_group = out_group |
| 2712 | else: |
| 2713 | self.out_group = 0 |
| 2714 | if flags != None: |
| 2715 | self.flags = flags |
| 2716 | else: |
| 2717 | self.flags = 0 |
| 2718 | if match != None: |
| 2719 | self.match = match |
| 2720 | else: |
| 2721 | self.match = common.match() |
| 2722 | if instructions != None: |
| 2723 | self.instructions = instructions |
| 2724 | else: |
| 2725 | self.instructions = [] |
| 2726 | |
| 2727 | def pack(self): |
| 2728 | packed = [] |
| 2729 | packed.append(struct.pack("!B", self.version)) |
| 2730 | packed.append(struct.pack("!B", self.type)) |
| 2731 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2732 | packed.append(struct.pack("!L", self.xid)) |
| 2733 | packed.append(struct.pack("!Q", self.cookie)) |
| 2734 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 2735 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2736 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2737 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2738 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2739 | packed.append(struct.pack("!H", self.priority)) |
| 2740 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2741 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2742 | packed.append(struct.pack("!L", self.out_group)) |
| 2743 | packed.append(struct.pack("!H", self.flags)) |
| 2744 | packed.append('\x00' * 2) |
| 2745 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2746 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2747 | length = sum([len(x) for x in packed]) |
| 2748 | packed[2] = struct.pack("!H", length) |
| 2749 | return ''.join(packed) |
| 2750 | |
| 2751 | @staticmethod |
| 2752 | def unpack(buf): |
| 2753 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2754 | obj = flow_add() |
| 2755 | if type(buf) == loxi.generic_util.OFReader: |
| 2756 | reader = buf |
| 2757 | else: |
| 2758 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2759 | _version = reader.read("!B")[0] |
| 2760 | assert(_version == 3) |
| 2761 | _type = reader.read("!B")[0] |
| 2762 | assert(_type == 14) |
| 2763 | _length = reader.read("!H")[0] |
| 2764 | obj.xid = reader.read("!L")[0] |
| 2765 | obj.cookie = reader.read("!Q")[0] |
| 2766 | obj.cookie_mask = reader.read("!Q")[0] |
| 2767 | obj.table_id = reader.read("!B")[0] |
| 2768 | __command = util.unpack_fm_cmd(reader) |
| 2769 | assert(__command == 0) |
| 2770 | obj.idle_timeout = reader.read("!H")[0] |
| 2771 | obj.hard_timeout = reader.read("!H")[0] |
| 2772 | obj.priority = reader.read("!H")[0] |
| 2773 | obj.buffer_id = reader.read("!L")[0] |
| 2774 | obj.out_port = util.unpack_port_no(reader) |
| 2775 | obj.out_group = reader.read("!L")[0] |
| 2776 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2777 | reader.skip(2) |
| 2778 | obj.match = common.match.unpack(reader) |
| 2779 | obj.instructions = instruction.unpack_list(reader) |
| 2780 | return obj |
| 2781 | |
| 2782 | def __eq__(self, other): |
| 2783 | if type(self) != type(other): return False |
| 2784 | if self.version != other.version: return False |
| 2785 | if self.type != other.type: return False |
| 2786 | if self.xid != other.xid: return False |
| 2787 | if self.cookie != other.cookie: return False |
| 2788 | if self.cookie_mask != other.cookie_mask: return False |
| 2789 | if self.table_id != other.table_id: return False |
| 2790 | if self.idle_timeout != other.idle_timeout: return False |
| 2791 | if self.hard_timeout != other.hard_timeout: return False |
| 2792 | if self.priority != other.priority: return False |
| 2793 | if self.buffer_id != other.buffer_id: return False |
| 2794 | if self.out_port != other.out_port: return False |
| 2795 | if self.out_group != other.out_group: return False |
| 2796 | if self.flags != other.flags: return False |
| 2797 | if self.match != other.match: return False |
| 2798 | if self.instructions != other.instructions: return False |
| 2799 | return True |
| 2800 | |
| 2801 | def __ne__(self, other): |
| 2802 | return not self.__eq__(other) |
| 2803 | |
| 2804 | def __str__(self): |
| 2805 | return self.show() |
| 2806 | |
| 2807 | def show(self): |
| 2808 | import loxi.pp |
| 2809 | return loxi.pp.pp(self) |
| 2810 | |
| 2811 | def pretty_print(self, q): |
| 2812 | q.text("flow_add {") |
| 2813 | with q.group(): |
| 2814 | with q.indent(2): |
| 2815 | q.breakable() |
| 2816 | q.text("xid = "); |
| 2817 | if self.xid != None: |
| 2818 | q.text("%#x" % self.xid) |
| 2819 | else: |
| 2820 | q.text('None') |
| 2821 | q.text(","); q.breakable() |
| 2822 | q.text("cookie = "); |
| 2823 | q.text("%#x" % self.cookie) |
| 2824 | q.text(","); q.breakable() |
| 2825 | q.text("cookie_mask = "); |
| 2826 | q.text("%#x" % self.cookie_mask) |
| 2827 | q.text(","); q.breakable() |
| 2828 | q.text("table_id = "); |
| 2829 | q.text("%#x" % self.table_id) |
| 2830 | q.text(","); q.breakable() |
| 2831 | q.text("idle_timeout = "); |
| 2832 | q.text("%#x" % self.idle_timeout) |
| 2833 | q.text(","); q.breakable() |
| 2834 | q.text("hard_timeout = "); |
| 2835 | q.text("%#x" % self.hard_timeout) |
| 2836 | q.text(","); q.breakable() |
| 2837 | q.text("priority = "); |
| 2838 | q.text("%#x" % self.priority) |
| 2839 | q.text(","); q.breakable() |
| 2840 | q.text("buffer_id = "); |
| 2841 | q.text("%#x" % self.buffer_id) |
| 2842 | q.text(","); q.breakable() |
| 2843 | q.text("out_port = "); |
| 2844 | q.text(util.pretty_port(self.out_port)) |
| 2845 | q.text(","); q.breakable() |
| 2846 | q.text("out_group = "); |
| 2847 | q.text("%#x" % self.out_group) |
| 2848 | q.text(","); q.breakable() |
| 2849 | q.text("flags = "); |
| 2850 | q.text("%#x" % self.flags) |
| 2851 | q.text(","); q.breakable() |
| 2852 | q.text("match = "); |
| 2853 | q.pp(self.match) |
| 2854 | q.text(","); q.breakable() |
| 2855 | q.text("instructions = "); |
| 2856 | q.pp(self.instructions) |
| 2857 | q.breakable() |
| 2858 | q.text('}') |
| 2859 | |
| 2860 | class flow_delete(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2861 | version = 3 |
| 2862 | type = 14 |
| 2863 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2864 | |
| 2865 | 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): |
| 2866 | self.xid = xid |
| 2867 | if cookie != None: |
| 2868 | self.cookie = cookie |
| 2869 | else: |
| 2870 | self.cookie = 0 |
| 2871 | if cookie_mask != None: |
| 2872 | self.cookie_mask = cookie_mask |
| 2873 | else: |
| 2874 | self.cookie_mask = 0 |
| 2875 | if table_id != None: |
| 2876 | self.table_id = table_id |
| 2877 | else: |
| 2878 | self.table_id = 0 |
| 2879 | if idle_timeout != None: |
| 2880 | self.idle_timeout = idle_timeout |
| 2881 | else: |
| 2882 | self.idle_timeout = 0 |
| 2883 | if hard_timeout != None: |
| 2884 | self.hard_timeout = hard_timeout |
| 2885 | else: |
| 2886 | self.hard_timeout = 0 |
| 2887 | if priority != None: |
| 2888 | self.priority = priority |
| 2889 | else: |
| 2890 | self.priority = 0 |
| 2891 | if buffer_id != None: |
| 2892 | self.buffer_id = buffer_id |
| 2893 | else: |
| 2894 | self.buffer_id = 0 |
| 2895 | if out_port != None: |
| 2896 | self.out_port = out_port |
| 2897 | else: |
| 2898 | self.out_port = 0 |
| 2899 | if out_group != None: |
| 2900 | self.out_group = out_group |
| 2901 | else: |
| 2902 | self.out_group = 0 |
| 2903 | if flags != None: |
| 2904 | self.flags = flags |
| 2905 | else: |
| 2906 | self.flags = 0 |
| 2907 | if match != None: |
| 2908 | self.match = match |
| 2909 | else: |
| 2910 | self.match = common.match() |
| 2911 | if instructions != None: |
| 2912 | self.instructions = instructions |
| 2913 | else: |
| 2914 | self.instructions = [] |
| 2915 | |
| 2916 | def pack(self): |
| 2917 | packed = [] |
| 2918 | packed.append(struct.pack("!B", self.version)) |
| 2919 | packed.append(struct.pack("!B", self.type)) |
| 2920 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2921 | packed.append(struct.pack("!L", self.xid)) |
| 2922 | packed.append(struct.pack("!Q", self.cookie)) |
| 2923 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 2924 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2925 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2926 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 2927 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 2928 | packed.append(struct.pack("!H", self.priority)) |
| 2929 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2930 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2931 | packed.append(struct.pack("!L", self.out_group)) |
| 2932 | packed.append(struct.pack("!H", self.flags)) |
| 2933 | packed.append('\x00' * 2) |
| 2934 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2935 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2936 | length = sum([len(x) for x in packed]) |
| 2937 | packed[2] = struct.pack("!H", length) |
| 2938 | return ''.join(packed) |
| 2939 | |
| 2940 | @staticmethod |
| 2941 | def unpack(buf): |
| 2942 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2943 | obj = flow_delete() |
| 2944 | if type(buf) == loxi.generic_util.OFReader: |
| 2945 | reader = buf |
| 2946 | else: |
| 2947 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2948 | _version = reader.read("!B")[0] |
| 2949 | assert(_version == 3) |
| 2950 | _type = reader.read("!B")[0] |
| 2951 | assert(_type == 14) |
| 2952 | _length = reader.read("!H")[0] |
| 2953 | obj.xid = reader.read("!L")[0] |
| 2954 | obj.cookie = reader.read("!Q")[0] |
| 2955 | obj.cookie_mask = reader.read("!Q")[0] |
| 2956 | obj.table_id = reader.read("!B")[0] |
| 2957 | __command = util.unpack_fm_cmd(reader) |
| 2958 | assert(__command == 3) |
| 2959 | obj.idle_timeout = reader.read("!H")[0] |
| 2960 | obj.hard_timeout = reader.read("!H")[0] |
| 2961 | obj.priority = reader.read("!H")[0] |
| 2962 | obj.buffer_id = reader.read("!L")[0] |
| 2963 | obj.out_port = util.unpack_port_no(reader) |
| 2964 | obj.out_group = reader.read("!L")[0] |
| 2965 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2966 | reader.skip(2) |
| 2967 | obj.match = common.match.unpack(reader) |
| 2968 | obj.instructions = instruction.unpack_list(reader) |
| 2969 | return obj |
| 2970 | |
| 2971 | def __eq__(self, other): |
| 2972 | if type(self) != type(other): return False |
| 2973 | if self.version != other.version: return False |
| 2974 | if self.type != other.type: return False |
| 2975 | if self.xid != other.xid: return False |
| 2976 | if self.cookie != other.cookie: return False |
| 2977 | if self.cookie_mask != other.cookie_mask: return False |
| 2978 | if self.table_id != other.table_id: return False |
| 2979 | if self.idle_timeout != other.idle_timeout: return False |
| 2980 | if self.hard_timeout != other.hard_timeout: return False |
| 2981 | if self.priority != other.priority: return False |
| 2982 | if self.buffer_id != other.buffer_id: return False |
| 2983 | if self.out_port != other.out_port: return False |
| 2984 | if self.out_group != other.out_group: return False |
| 2985 | if self.flags != other.flags: return False |
| 2986 | if self.match != other.match: return False |
| 2987 | if self.instructions != other.instructions: return False |
| 2988 | return True |
| 2989 | |
| 2990 | def __ne__(self, other): |
| 2991 | return not self.__eq__(other) |
| 2992 | |
| 2993 | def __str__(self): |
| 2994 | return self.show() |
| 2995 | |
| 2996 | def show(self): |
| 2997 | import loxi.pp |
| 2998 | return loxi.pp.pp(self) |
| 2999 | |
| 3000 | def pretty_print(self, q): |
| 3001 | q.text("flow_delete {") |
| 3002 | with q.group(): |
| 3003 | with q.indent(2): |
| 3004 | q.breakable() |
| 3005 | q.text("xid = "); |
| 3006 | if self.xid != None: |
| 3007 | q.text("%#x" % self.xid) |
| 3008 | else: |
| 3009 | q.text('None') |
| 3010 | q.text(","); q.breakable() |
| 3011 | q.text("cookie = "); |
| 3012 | q.text("%#x" % self.cookie) |
| 3013 | q.text(","); q.breakable() |
| 3014 | q.text("cookie_mask = "); |
| 3015 | q.text("%#x" % self.cookie_mask) |
| 3016 | q.text(","); q.breakable() |
| 3017 | q.text("table_id = "); |
| 3018 | q.text("%#x" % self.table_id) |
| 3019 | q.text(","); q.breakable() |
| 3020 | q.text("idle_timeout = "); |
| 3021 | q.text("%#x" % self.idle_timeout) |
| 3022 | q.text(","); q.breakable() |
| 3023 | q.text("hard_timeout = "); |
| 3024 | q.text("%#x" % self.hard_timeout) |
| 3025 | q.text(","); q.breakable() |
| 3026 | q.text("priority = "); |
| 3027 | q.text("%#x" % self.priority) |
| 3028 | q.text(","); q.breakable() |
| 3029 | q.text("buffer_id = "); |
| 3030 | q.text("%#x" % self.buffer_id) |
| 3031 | q.text(","); q.breakable() |
| 3032 | q.text("out_port = "); |
| 3033 | q.text(util.pretty_port(self.out_port)) |
| 3034 | q.text(","); q.breakable() |
| 3035 | q.text("out_group = "); |
| 3036 | q.text("%#x" % self.out_group) |
| 3037 | q.text(","); q.breakable() |
| 3038 | q.text("flags = "); |
| 3039 | q.text("%#x" % self.flags) |
| 3040 | q.text(","); q.breakable() |
| 3041 | q.text("match = "); |
| 3042 | q.pp(self.match) |
| 3043 | q.text(","); q.breakable() |
| 3044 | q.text("instructions = "); |
| 3045 | q.pp(self.instructions) |
| 3046 | q.breakable() |
| 3047 | q.text('}') |
| 3048 | |
| 3049 | class flow_delete_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3050 | version = 3 |
| 3051 | type = 14 |
| 3052 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3053 | |
| 3054 | 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): |
| 3055 | self.xid = xid |
| 3056 | if cookie != None: |
| 3057 | self.cookie = cookie |
| 3058 | else: |
| 3059 | self.cookie = 0 |
| 3060 | if cookie_mask != None: |
| 3061 | self.cookie_mask = cookie_mask |
| 3062 | else: |
| 3063 | self.cookie_mask = 0 |
| 3064 | if table_id != None: |
| 3065 | self.table_id = table_id |
| 3066 | else: |
| 3067 | self.table_id = 0 |
| 3068 | if idle_timeout != None: |
| 3069 | self.idle_timeout = idle_timeout |
| 3070 | else: |
| 3071 | self.idle_timeout = 0 |
| 3072 | if hard_timeout != None: |
| 3073 | self.hard_timeout = hard_timeout |
| 3074 | else: |
| 3075 | self.hard_timeout = 0 |
| 3076 | if priority != None: |
| 3077 | self.priority = priority |
| 3078 | else: |
| 3079 | self.priority = 0 |
| 3080 | if buffer_id != None: |
| 3081 | self.buffer_id = buffer_id |
| 3082 | else: |
| 3083 | self.buffer_id = 0 |
| 3084 | if out_port != None: |
| 3085 | self.out_port = out_port |
| 3086 | else: |
| 3087 | self.out_port = 0 |
| 3088 | if out_group != None: |
| 3089 | self.out_group = out_group |
| 3090 | else: |
| 3091 | self.out_group = 0 |
| 3092 | if flags != None: |
| 3093 | self.flags = flags |
| 3094 | else: |
| 3095 | self.flags = 0 |
| 3096 | if match != None: |
| 3097 | self.match = match |
| 3098 | else: |
| 3099 | self.match = common.match() |
| 3100 | if instructions != None: |
| 3101 | self.instructions = instructions |
| 3102 | else: |
| 3103 | self.instructions = [] |
| 3104 | |
| 3105 | def pack(self): |
| 3106 | packed = [] |
| 3107 | packed.append(struct.pack("!B", self.version)) |
| 3108 | packed.append(struct.pack("!B", self.type)) |
| 3109 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3110 | packed.append(struct.pack("!L", self.xid)) |
| 3111 | packed.append(struct.pack("!Q", self.cookie)) |
| 3112 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3113 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3114 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3115 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3116 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3117 | packed.append(struct.pack("!H", self.priority)) |
| 3118 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3119 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3120 | packed.append(struct.pack("!L", self.out_group)) |
| 3121 | packed.append(struct.pack("!H", self.flags)) |
| 3122 | packed.append('\x00' * 2) |
| 3123 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3124 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3125 | length = sum([len(x) for x in packed]) |
| 3126 | packed[2] = struct.pack("!H", length) |
| 3127 | return ''.join(packed) |
| 3128 | |
| 3129 | @staticmethod |
| 3130 | def unpack(buf): |
| 3131 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3132 | obj = flow_delete_strict() |
| 3133 | if type(buf) == loxi.generic_util.OFReader: |
| 3134 | reader = buf |
| 3135 | else: |
| 3136 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3137 | _version = reader.read("!B")[0] |
| 3138 | assert(_version == 3) |
| 3139 | _type = reader.read("!B")[0] |
| 3140 | assert(_type == 14) |
| 3141 | _length = reader.read("!H")[0] |
| 3142 | obj.xid = reader.read("!L")[0] |
| 3143 | obj.cookie = reader.read("!Q")[0] |
| 3144 | obj.cookie_mask = reader.read("!Q")[0] |
| 3145 | obj.table_id = reader.read("!B")[0] |
| 3146 | __command = util.unpack_fm_cmd(reader) |
| 3147 | assert(__command == 4) |
| 3148 | obj.idle_timeout = reader.read("!H")[0] |
| 3149 | obj.hard_timeout = reader.read("!H")[0] |
| 3150 | obj.priority = reader.read("!H")[0] |
| 3151 | obj.buffer_id = reader.read("!L")[0] |
| 3152 | obj.out_port = util.unpack_port_no(reader) |
| 3153 | obj.out_group = reader.read("!L")[0] |
| 3154 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3155 | reader.skip(2) |
| 3156 | obj.match = common.match.unpack(reader) |
| 3157 | obj.instructions = instruction.unpack_list(reader) |
| 3158 | return obj |
| 3159 | |
| 3160 | def __eq__(self, other): |
| 3161 | if type(self) != type(other): return False |
| 3162 | if self.version != other.version: return False |
| 3163 | if self.type != other.type: return False |
| 3164 | if self.xid != other.xid: return False |
| 3165 | if self.cookie != other.cookie: return False |
| 3166 | if self.cookie_mask != other.cookie_mask: return False |
| 3167 | if self.table_id != other.table_id: return False |
| 3168 | if self.idle_timeout != other.idle_timeout: return False |
| 3169 | if self.hard_timeout != other.hard_timeout: return False |
| 3170 | if self.priority != other.priority: return False |
| 3171 | if self.buffer_id != other.buffer_id: return False |
| 3172 | if self.out_port != other.out_port: return False |
| 3173 | if self.out_group != other.out_group: return False |
| 3174 | if self.flags != other.flags: return False |
| 3175 | if self.match != other.match: return False |
| 3176 | if self.instructions != other.instructions: return False |
| 3177 | return True |
| 3178 | |
| 3179 | def __ne__(self, other): |
| 3180 | return not self.__eq__(other) |
| 3181 | |
| 3182 | def __str__(self): |
| 3183 | return self.show() |
| 3184 | |
| 3185 | def show(self): |
| 3186 | import loxi.pp |
| 3187 | return loxi.pp.pp(self) |
| 3188 | |
| 3189 | def pretty_print(self, q): |
| 3190 | q.text("flow_delete_strict {") |
| 3191 | with q.group(): |
| 3192 | with q.indent(2): |
| 3193 | q.breakable() |
| 3194 | q.text("xid = "); |
| 3195 | if self.xid != None: |
| 3196 | q.text("%#x" % self.xid) |
| 3197 | else: |
| 3198 | q.text('None') |
| 3199 | q.text(","); q.breakable() |
| 3200 | q.text("cookie = "); |
| 3201 | q.text("%#x" % self.cookie) |
| 3202 | q.text(","); q.breakable() |
| 3203 | q.text("cookie_mask = "); |
| 3204 | q.text("%#x" % self.cookie_mask) |
| 3205 | q.text(","); q.breakable() |
| 3206 | q.text("table_id = "); |
| 3207 | q.text("%#x" % self.table_id) |
| 3208 | q.text(","); q.breakable() |
| 3209 | q.text("idle_timeout = "); |
| 3210 | q.text("%#x" % self.idle_timeout) |
| 3211 | q.text(","); q.breakable() |
| 3212 | q.text("hard_timeout = "); |
| 3213 | q.text("%#x" % self.hard_timeout) |
| 3214 | q.text(","); q.breakable() |
| 3215 | q.text("priority = "); |
| 3216 | q.text("%#x" % self.priority) |
| 3217 | q.text(","); q.breakable() |
| 3218 | q.text("buffer_id = "); |
| 3219 | q.text("%#x" % self.buffer_id) |
| 3220 | q.text(","); q.breakable() |
| 3221 | q.text("out_port = "); |
| 3222 | q.text(util.pretty_port(self.out_port)) |
| 3223 | q.text(","); q.breakable() |
| 3224 | q.text("out_group = "); |
| 3225 | q.text("%#x" % self.out_group) |
| 3226 | q.text(","); q.breakable() |
| 3227 | q.text("flags = "); |
| 3228 | q.text("%#x" % self.flags) |
| 3229 | q.text(","); q.breakable() |
| 3230 | q.text("match = "); |
| 3231 | q.pp(self.match) |
| 3232 | q.text(","); q.breakable() |
| 3233 | q.text("instructions = "); |
| 3234 | q.pp(self.instructions) |
| 3235 | q.breakable() |
| 3236 | q.text('}') |
| 3237 | |
| 3238 | class flow_modify(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3239 | version = 3 |
| 3240 | type = 14 |
| 3241 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3242 | |
| 3243 | 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): |
| 3244 | self.xid = xid |
| 3245 | if cookie != None: |
| 3246 | self.cookie = cookie |
| 3247 | else: |
| 3248 | self.cookie = 0 |
| 3249 | if cookie_mask != None: |
| 3250 | self.cookie_mask = cookie_mask |
| 3251 | else: |
| 3252 | self.cookie_mask = 0 |
| 3253 | if table_id != None: |
| 3254 | self.table_id = table_id |
| 3255 | else: |
| 3256 | self.table_id = 0 |
| 3257 | if idle_timeout != None: |
| 3258 | self.idle_timeout = idle_timeout |
| 3259 | else: |
| 3260 | self.idle_timeout = 0 |
| 3261 | if hard_timeout != None: |
| 3262 | self.hard_timeout = hard_timeout |
| 3263 | else: |
| 3264 | self.hard_timeout = 0 |
| 3265 | if priority != None: |
| 3266 | self.priority = priority |
| 3267 | else: |
| 3268 | self.priority = 0 |
| 3269 | if buffer_id != None: |
| 3270 | self.buffer_id = buffer_id |
| 3271 | else: |
| 3272 | self.buffer_id = 0 |
| 3273 | if out_port != None: |
| 3274 | self.out_port = out_port |
| 3275 | else: |
| 3276 | self.out_port = 0 |
| 3277 | if out_group != None: |
| 3278 | self.out_group = out_group |
| 3279 | else: |
| 3280 | self.out_group = 0 |
| 3281 | if flags != None: |
| 3282 | self.flags = flags |
| 3283 | else: |
| 3284 | self.flags = 0 |
| 3285 | if match != None: |
| 3286 | self.match = match |
| 3287 | else: |
| 3288 | self.match = common.match() |
| 3289 | if instructions != None: |
| 3290 | self.instructions = instructions |
| 3291 | else: |
| 3292 | self.instructions = [] |
| 3293 | |
| 3294 | def pack(self): |
| 3295 | packed = [] |
| 3296 | packed.append(struct.pack("!B", self.version)) |
| 3297 | packed.append(struct.pack("!B", self.type)) |
| 3298 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3299 | packed.append(struct.pack("!L", self.xid)) |
| 3300 | packed.append(struct.pack("!Q", self.cookie)) |
| 3301 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3302 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3303 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3304 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3305 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3306 | packed.append(struct.pack("!H", self.priority)) |
| 3307 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3308 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3309 | packed.append(struct.pack("!L", self.out_group)) |
| 3310 | packed.append(struct.pack("!H", self.flags)) |
| 3311 | packed.append('\x00' * 2) |
| 3312 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3313 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3314 | length = sum([len(x) for x in packed]) |
| 3315 | packed[2] = struct.pack("!H", length) |
| 3316 | return ''.join(packed) |
| 3317 | |
| 3318 | @staticmethod |
| 3319 | def unpack(buf): |
| 3320 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3321 | obj = flow_modify() |
| 3322 | if type(buf) == loxi.generic_util.OFReader: |
| 3323 | reader = buf |
| 3324 | else: |
| 3325 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3326 | _version = reader.read("!B")[0] |
| 3327 | assert(_version == 3) |
| 3328 | _type = reader.read("!B")[0] |
| 3329 | assert(_type == 14) |
| 3330 | _length = reader.read("!H")[0] |
| 3331 | obj.xid = reader.read("!L")[0] |
| 3332 | obj.cookie = reader.read("!Q")[0] |
| 3333 | obj.cookie_mask = reader.read("!Q")[0] |
| 3334 | obj.table_id = reader.read("!B")[0] |
| 3335 | __command = util.unpack_fm_cmd(reader) |
| 3336 | assert(__command == 1) |
| 3337 | obj.idle_timeout = reader.read("!H")[0] |
| 3338 | obj.hard_timeout = reader.read("!H")[0] |
| 3339 | obj.priority = reader.read("!H")[0] |
| 3340 | obj.buffer_id = reader.read("!L")[0] |
| 3341 | obj.out_port = util.unpack_port_no(reader) |
| 3342 | obj.out_group = reader.read("!L")[0] |
| 3343 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3344 | reader.skip(2) |
| 3345 | obj.match = common.match.unpack(reader) |
| 3346 | obj.instructions = instruction.unpack_list(reader) |
| 3347 | return obj |
| 3348 | |
| 3349 | def __eq__(self, other): |
| 3350 | if type(self) != type(other): return False |
| 3351 | if self.version != other.version: return False |
| 3352 | if self.type != other.type: return False |
| 3353 | if self.xid != other.xid: return False |
| 3354 | if self.cookie != other.cookie: return False |
| 3355 | if self.cookie_mask != other.cookie_mask: return False |
| 3356 | if self.table_id != other.table_id: return False |
| 3357 | if self.idle_timeout != other.idle_timeout: return False |
| 3358 | if self.hard_timeout != other.hard_timeout: return False |
| 3359 | if self.priority != other.priority: return False |
| 3360 | if self.buffer_id != other.buffer_id: return False |
| 3361 | if self.out_port != other.out_port: return False |
| 3362 | if self.out_group != other.out_group: return False |
| 3363 | if self.flags != other.flags: return False |
| 3364 | if self.match != other.match: return False |
| 3365 | if self.instructions != other.instructions: return False |
| 3366 | return True |
| 3367 | |
| 3368 | def __ne__(self, other): |
| 3369 | return not self.__eq__(other) |
| 3370 | |
| 3371 | def __str__(self): |
| 3372 | return self.show() |
| 3373 | |
| 3374 | def show(self): |
| 3375 | import loxi.pp |
| 3376 | return loxi.pp.pp(self) |
| 3377 | |
| 3378 | def pretty_print(self, q): |
| 3379 | q.text("flow_modify {") |
| 3380 | with q.group(): |
| 3381 | with q.indent(2): |
| 3382 | q.breakable() |
| 3383 | q.text("xid = "); |
| 3384 | if self.xid != None: |
| 3385 | q.text("%#x" % self.xid) |
| 3386 | else: |
| 3387 | q.text('None') |
| 3388 | q.text(","); q.breakable() |
| 3389 | q.text("cookie = "); |
| 3390 | q.text("%#x" % self.cookie) |
| 3391 | q.text(","); q.breakable() |
| 3392 | q.text("cookie_mask = "); |
| 3393 | q.text("%#x" % self.cookie_mask) |
| 3394 | q.text(","); q.breakable() |
| 3395 | q.text("table_id = "); |
| 3396 | q.text("%#x" % self.table_id) |
| 3397 | q.text(","); q.breakable() |
| 3398 | q.text("idle_timeout = "); |
| 3399 | q.text("%#x" % self.idle_timeout) |
| 3400 | q.text(","); q.breakable() |
| 3401 | q.text("hard_timeout = "); |
| 3402 | q.text("%#x" % self.hard_timeout) |
| 3403 | q.text(","); q.breakable() |
| 3404 | q.text("priority = "); |
| 3405 | q.text("%#x" % self.priority) |
| 3406 | q.text(","); q.breakable() |
| 3407 | q.text("buffer_id = "); |
| 3408 | q.text("%#x" % self.buffer_id) |
| 3409 | q.text(","); q.breakable() |
| 3410 | q.text("out_port = "); |
| 3411 | q.text(util.pretty_port(self.out_port)) |
| 3412 | q.text(","); q.breakable() |
| 3413 | q.text("out_group = "); |
| 3414 | q.text("%#x" % self.out_group) |
| 3415 | q.text(","); q.breakable() |
| 3416 | q.text("flags = "); |
| 3417 | q.text("%#x" % self.flags) |
| 3418 | q.text(","); q.breakable() |
| 3419 | q.text("match = "); |
| 3420 | q.pp(self.match) |
| 3421 | q.text(","); q.breakable() |
| 3422 | q.text("instructions = "); |
| 3423 | q.pp(self.instructions) |
| 3424 | q.breakable() |
| 3425 | q.text('}') |
| 3426 | |
| 3427 | class flow_modify_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3428 | version = 3 |
| 3429 | type = 14 |
| 3430 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3431 | |
| 3432 | 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): |
| 3433 | self.xid = xid |
| 3434 | if cookie != None: |
| 3435 | self.cookie = cookie |
| 3436 | else: |
| 3437 | self.cookie = 0 |
| 3438 | if cookie_mask != None: |
| 3439 | self.cookie_mask = cookie_mask |
| 3440 | else: |
| 3441 | self.cookie_mask = 0 |
| 3442 | if table_id != None: |
| 3443 | self.table_id = table_id |
| 3444 | else: |
| 3445 | self.table_id = 0 |
| 3446 | if idle_timeout != None: |
| 3447 | self.idle_timeout = idle_timeout |
| 3448 | else: |
| 3449 | self.idle_timeout = 0 |
| 3450 | if hard_timeout != None: |
| 3451 | self.hard_timeout = hard_timeout |
| 3452 | else: |
| 3453 | self.hard_timeout = 0 |
| 3454 | if priority != None: |
| 3455 | self.priority = priority |
| 3456 | else: |
| 3457 | self.priority = 0 |
| 3458 | if buffer_id != None: |
| 3459 | self.buffer_id = buffer_id |
| 3460 | else: |
| 3461 | self.buffer_id = 0 |
| 3462 | if out_port != None: |
| 3463 | self.out_port = out_port |
| 3464 | else: |
| 3465 | self.out_port = 0 |
| 3466 | if out_group != None: |
| 3467 | self.out_group = out_group |
| 3468 | else: |
| 3469 | self.out_group = 0 |
| 3470 | if flags != None: |
| 3471 | self.flags = flags |
| 3472 | else: |
| 3473 | self.flags = 0 |
| 3474 | if match != None: |
| 3475 | self.match = match |
| 3476 | else: |
| 3477 | self.match = common.match() |
| 3478 | if instructions != None: |
| 3479 | self.instructions = instructions |
| 3480 | else: |
| 3481 | self.instructions = [] |
| 3482 | |
| 3483 | def pack(self): |
| 3484 | packed = [] |
| 3485 | packed.append(struct.pack("!B", self.version)) |
| 3486 | packed.append(struct.pack("!B", self.type)) |
| 3487 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3488 | packed.append(struct.pack("!L", self.xid)) |
| 3489 | packed.append(struct.pack("!Q", self.cookie)) |
| 3490 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3491 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3492 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3493 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3494 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3495 | packed.append(struct.pack("!H", self.priority)) |
| 3496 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3497 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3498 | packed.append(struct.pack("!L", self.out_group)) |
| 3499 | packed.append(struct.pack("!H", self.flags)) |
| 3500 | packed.append('\x00' * 2) |
| 3501 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3502 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3503 | length = sum([len(x) for x in packed]) |
| 3504 | packed[2] = struct.pack("!H", length) |
| 3505 | return ''.join(packed) |
| 3506 | |
| 3507 | @staticmethod |
| 3508 | def unpack(buf): |
| 3509 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3510 | obj = flow_modify_strict() |
| 3511 | if type(buf) == loxi.generic_util.OFReader: |
| 3512 | reader = buf |
| 3513 | else: |
| 3514 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3515 | _version = reader.read("!B")[0] |
| 3516 | assert(_version == 3) |
| 3517 | _type = reader.read("!B")[0] |
| 3518 | assert(_type == 14) |
| 3519 | _length = reader.read("!H")[0] |
| 3520 | obj.xid = reader.read("!L")[0] |
| 3521 | obj.cookie = reader.read("!Q")[0] |
| 3522 | obj.cookie_mask = reader.read("!Q")[0] |
| 3523 | obj.table_id = reader.read("!B")[0] |
| 3524 | __command = util.unpack_fm_cmd(reader) |
| 3525 | assert(__command == 2) |
| 3526 | obj.idle_timeout = reader.read("!H")[0] |
| 3527 | obj.hard_timeout = reader.read("!H")[0] |
| 3528 | obj.priority = reader.read("!H")[0] |
| 3529 | obj.buffer_id = reader.read("!L")[0] |
| 3530 | obj.out_port = util.unpack_port_no(reader) |
| 3531 | obj.out_group = reader.read("!L")[0] |
| 3532 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3533 | reader.skip(2) |
| 3534 | obj.match = common.match.unpack(reader) |
| 3535 | obj.instructions = instruction.unpack_list(reader) |
| 3536 | return obj |
| 3537 | |
| 3538 | def __eq__(self, other): |
| 3539 | if type(self) != type(other): return False |
| 3540 | if self.version != other.version: return False |
| 3541 | if self.type != other.type: return False |
| 3542 | if self.xid != other.xid: return False |
| 3543 | if self.cookie != other.cookie: return False |
| 3544 | if self.cookie_mask != other.cookie_mask: return False |
| 3545 | if self.table_id != other.table_id: return False |
| 3546 | if self.idle_timeout != other.idle_timeout: return False |
| 3547 | if self.hard_timeout != other.hard_timeout: return False |
| 3548 | if self.priority != other.priority: return False |
| 3549 | if self.buffer_id != other.buffer_id: return False |
| 3550 | if self.out_port != other.out_port: return False |
| 3551 | if self.out_group != other.out_group: return False |
| 3552 | if self.flags != other.flags: return False |
| 3553 | if self.match != other.match: return False |
| 3554 | if self.instructions != other.instructions: return False |
| 3555 | return True |
| 3556 | |
| 3557 | def __ne__(self, other): |
| 3558 | return not self.__eq__(other) |
| 3559 | |
| 3560 | def __str__(self): |
| 3561 | return self.show() |
| 3562 | |
| 3563 | def show(self): |
| 3564 | import loxi.pp |
| 3565 | return loxi.pp.pp(self) |
| 3566 | |
| 3567 | def pretty_print(self, q): |
| 3568 | q.text("flow_modify_strict {") |
| 3569 | with q.group(): |
| 3570 | with q.indent(2): |
| 3571 | q.breakable() |
| 3572 | q.text("xid = "); |
| 3573 | if self.xid != None: |
| 3574 | q.text("%#x" % self.xid) |
| 3575 | else: |
| 3576 | q.text('None') |
| 3577 | q.text(","); q.breakable() |
| 3578 | q.text("cookie = "); |
| 3579 | q.text("%#x" % self.cookie) |
| 3580 | q.text(","); q.breakable() |
| 3581 | q.text("cookie_mask = "); |
| 3582 | q.text("%#x" % self.cookie_mask) |
| 3583 | q.text(","); q.breakable() |
| 3584 | q.text("table_id = "); |
| 3585 | q.text("%#x" % self.table_id) |
| 3586 | q.text(","); q.breakable() |
| 3587 | q.text("idle_timeout = "); |
| 3588 | q.text("%#x" % self.idle_timeout) |
| 3589 | q.text(","); q.breakable() |
| 3590 | q.text("hard_timeout = "); |
| 3591 | q.text("%#x" % self.hard_timeout) |
| 3592 | q.text(","); q.breakable() |
| 3593 | q.text("priority = "); |
| 3594 | q.text("%#x" % self.priority) |
| 3595 | q.text(","); q.breakable() |
| 3596 | q.text("buffer_id = "); |
| 3597 | q.text("%#x" % self.buffer_id) |
| 3598 | q.text(","); q.breakable() |
| 3599 | q.text("out_port = "); |
| 3600 | q.text(util.pretty_port(self.out_port)) |
| 3601 | q.text(","); q.breakable() |
| 3602 | q.text("out_group = "); |
| 3603 | q.text("%#x" % self.out_group) |
| 3604 | q.text(","); q.breakable() |
| 3605 | q.text("flags = "); |
| 3606 | q.text("%#x" % self.flags) |
| 3607 | q.text(","); q.breakable() |
| 3608 | q.text("match = "); |
| 3609 | q.pp(self.match) |
| 3610 | q.text(","); q.breakable() |
| 3611 | q.text("instructions = "); |
| 3612 | q.pp(self.instructions) |
| 3613 | q.breakable() |
| 3614 | q.text('}') |
| 3615 | |
| 3616 | class flow_removed(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3617 | version = 3 |
| 3618 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3619 | |
| 3620 | def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, hard_timeout=None, packet_count=None, byte_count=None, match=None): |
| 3621 | self.xid = xid |
| 3622 | if cookie != None: |
| 3623 | self.cookie = cookie |
| 3624 | else: |
| 3625 | self.cookie = 0 |
| 3626 | if priority != None: |
| 3627 | self.priority = priority |
| 3628 | else: |
| 3629 | self.priority = 0 |
| 3630 | if reason != None: |
| 3631 | self.reason = reason |
| 3632 | else: |
| 3633 | self.reason = 0 |
| 3634 | if table_id != None: |
| 3635 | self.table_id = table_id |
| 3636 | else: |
| 3637 | self.table_id = 0 |
| 3638 | if duration_sec != None: |
| 3639 | self.duration_sec = duration_sec |
| 3640 | else: |
| 3641 | self.duration_sec = 0 |
| 3642 | if duration_nsec != None: |
| 3643 | self.duration_nsec = duration_nsec |
| 3644 | else: |
| 3645 | self.duration_nsec = 0 |
| 3646 | if idle_timeout != None: |
| 3647 | self.idle_timeout = idle_timeout |
| 3648 | else: |
| 3649 | self.idle_timeout = 0 |
| 3650 | if hard_timeout != None: |
| 3651 | self.hard_timeout = hard_timeout |
| 3652 | else: |
| 3653 | self.hard_timeout = 0 |
| 3654 | if packet_count != None: |
| 3655 | self.packet_count = packet_count |
| 3656 | else: |
| 3657 | self.packet_count = 0 |
| 3658 | if byte_count != None: |
| 3659 | self.byte_count = byte_count |
| 3660 | else: |
| 3661 | self.byte_count = 0 |
| 3662 | if match != None: |
| 3663 | self.match = match |
| 3664 | else: |
| 3665 | self.match = common.match() |
| 3666 | |
| 3667 | def pack(self): |
| 3668 | packed = [] |
| 3669 | packed.append(struct.pack("!B", self.version)) |
| 3670 | packed.append(struct.pack("!B", self.type)) |
| 3671 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3672 | packed.append(struct.pack("!L", self.xid)) |
| 3673 | packed.append(struct.pack("!Q", self.cookie)) |
| 3674 | packed.append(struct.pack("!H", self.priority)) |
| 3675 | packed.append(struct.pack("!B", self.reason)) |
| 3676 | packed.append(struct.pack("!B", self.table_id)) |
| 3677 | packed.append(struct.pack("!L", self.duration_sec)) |
| 3678 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 3679 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3680 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3681 | packed.append(struct.pack("!Q", self.packet_count)) |
| 3682 | packed.append(struct.pack("!Q", self.byte_count)) |
| 3683 | packed.append(self.match.pack()) |
| 3684 | length = sum([len(x) for x in packed]) |
| 3685 | packed[2] = struct.pack("!H", length) |
| 3686 | return ''.join(packed) |
| 3687 | |
| 3688 | @staticmethod |
| 3689 | def unpack(buf): |
| 3690 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3691 | obj = flow_removed() |
| 3692 | if type(buf) == loxi.generic_util.OFReader: |
| 3693 | reader = buf |
| 3694 | else: |
| 3695 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3696 | _version = reader.read("!B")[0] |
| 3697 | assert(_version == 3) |
| 3698 | _type = reader.read("!B")[0] |
| 3699 | assert(_type == 11) |
| 3700 | _length = reader.read("!H")[0] |
| 3701 | obj.xid = reader.read("!L")[0] |
| 3702 | obj.cookie = reader.read("!Q")[0] |
| 3703 | obj.priority = reader.read("!H")[0] |
| 3704 | obj.reason = reader.read("!B")[0] |
| 3705 | obj.table_id = reader.read("!B")[0] |
| 3706 | obj.duration_sec = reader.read("!L")[0] |
| 3707 | obj.duration_nsec = reader.read("!L")[0] |
| 3708 | obj.idle_timeout = reader.read("!H")[0] |
| 3709 | obj.hard_timeout = reader.read("!H")[0] |
| 3710 | obj.packet_count = reader.read("!Q")[0] |
| 3711 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3712 | obj.match = common.match.unpack(reader) |
| 3713 | return obj |
| 3714 | |
| 3715 | def __eq__(self, other): |
| 3716 | if type(self) != type(other): return False |
| 3717 | if self.version != other.version: return False |
| 3718 | if self.type != other.type: return False |
| 3719 | if self.xid != other.xid: return False |
| 3720 | if self.cookie != other.cookie: return False |
| 3721 | if self.priority != other.priority: return False |
| 3722 | if self.reason != other.reason: return False |
| 3723 | if self.table_id != other.table_id: return False |
| 3724 | if self.duration_sec != other.duration_sec: return False |
| 3725 | if self.duration_nsec != other.duration_nsec: return False |
| 3726 | if self.idle_timeout != other.idle_timeout: return False |
| 3727 | if self.hard_timeout != other.hard_timeout: return False |
| 3728 | if self.packet_count != other.packet_count: return False |
| 3729 | if self.byte_count != other.byte_count: return False |
| 3730 | if self.match != other.match: return False |
| 3731 | return True |
| 3732 | |
| 3733 | def __ne__(self, other): |
| 3734 | return not self.__eq__(other) |
| 3735 | |
| 3736 | def __str__(self): |
| 3737 | return self.show() |
| 3738 | |
| 3739 | def show(self): |
| 3740 | import loxi.pp |
| 3741 | return loxi.pp.pp(self) |
| 3742 | |
| 3743 | def pretty_print(self, q): |
| 3744 | q.text("flow_removed {") |
| 3745 | with q.group(): |
| 3746 | with q.indent(2): |
| 3747 | q.breakable() |
| 3748 | q.text("xid = "); |
| 3749 | if self.xid != None: |
| 3750 | q.text("%#x" % self.xid) |
| 3751 | else: |
| 3752 | q.text('None') |
| 3753 | q.text(","); q.breakable() |
| 3754 | q.text("cookie = "); |
| 3755 | q.text("%#x" % self.cookie) |
| 3756 | q.text(","); q.breakable() |
| 3757 | q.text("priority = "); |
| 3758 | q.text("%#x" % self.priority) |
| 3759 | q.text(","); q.breakable() |
| 3760 | q.text("reason = "); |
| 3761 | q.text("%#x" % self.reason) |
| 3762 | q.text(","); q.breakable() |
| 3763 | q.text("table_id = "); |
| 3764 | q.text("%#x" % self.table_id) |
| 3765 | q.text(","); q.breakable() |
| 3766 | q.text("duration_sec = "); |
| 3767 | q.text("%#x" % self.duration_sec) |
| 3768 | q.text(","); q.breakable() |
| 3769 | q.text("duration_nsec = "); |
| 3770 | q.text("%#x" % self.duration_nsec) |
| 3771 | q.text(","); q.breakable() |
| 3772 | q.text("idle_timeout = "); |
| 3773 | q.text("%#x" % self.idle_timeout) |
| 3774 | q.text(","); q.breakable() |
| 3775 | q.text("hard_timeout = "); |
| 3776 | q.text("%#x" % self.hard_timeout) |
| 3777 | q.text(","); q.breakable() |
| 3778 | q.text("packet_count = "); |
| 3779 | q.text("%#x" % self.packet_count) |
| 3780 | q.text(","); q.breakable() |
| 3781 | q.text("byte_count = "); |
| 3782 | q.text("%#x" % self.byte_count) |
| 3783 | q.text(","); q.breakable() |
| 3784 | q.text("match = "); |
| 3785 | q.pp(self.match) |
| 3786 | q.breakable() |
| 3787 | q.text('}') |
| 3788 | |
| 3789 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3790 | version = 3 |
| 3791 | type = 19 |
| 3792 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3793 | |
| 3794 | def __init__(self, xid=None, flags=None, entries=None): |
| 3795 | self.xid = xid |
| 3796 | if flags != None: |
| 3797 | self.flags = flags |
| 3798 | else: |
| 3799 | self.flags = 0 |
| 3800 | if entries != None: |
| 3801 | self.entries = entries |
| 3802 | else: |
| 3803 | self.entries = [] |
| 3804 | |
| 3805 | def pack(self): |
| 3806 | packed = [] |
| 3807 | packed.append(struct.pack("!B", self.version)) |
| 3808 | packed.append(struct.pack("!B", self.type)) |
| 3809 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3810 | packed.append(struct.pack("!L", self.xid)) |
| 3811 | packed.append(struct.pack("!H", self.stats_type)) |
| 3812 | packed.append(struct.pack("!H", self.flags)) |
| 3813 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3814 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3815 | length = sum([len(x) for x in packed]) |
| 3816 | packed[2] = struct.pack("!H", length) |
| 3817 | return ''.join(packed) |
| 3818 | |
| 3819 | @staticmethod |
| 3820 | def unpack(buf): |
| 3821 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3822 | obj = flow_stats_reply() |
| 3823 | if type(buf) == loxi.generic_util.OFReader: |
| 3824 | reader = buf |
| 3825 | else: |
| 3826 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3827 | _version = reader.read("!B")[0] |
| 3828 | assert(_version == 3) |
| 3829 | _type = reader.read("!B")[0] |
| 3830 | assert(_type == 19) |
| 3831 | _length = reader.read("!H")[0] |
| 3832 | obj.xid = reader.read("!L")[0] |
| 3833 | _stats_type = reader.read("!H")[0] |
| 3834 | assert(_stats_type == 1) |
| 3835 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3836 | reader.skip(4) |
| 3837 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
| 3838 | return obj |
| 3839 | |
| 3840 | def __eq__(self, other): |
| 3841 | if type(self) != type(other): return False |
| 3842 | if self.version != other.version: return False |
| 3843 | if self.type != other.type: return False |
| 3844 | if self.xid != other.xid: return False |
| 3845 | if self.flags != other.flags: return False |
| 3846 | if self.entries != other.entries: return False |
| 3847 | return True |
| 3848 | |
| 3849 | def __ne__(self, other): |
| 3850 | return not self.__eq__(other) |
| 3851 | |
| 3852 | def __str__(self): |
| 3853 | return self.show() |
| 3854 | |
| 3855 | def show(self): |
| 3856 | import loxi.pp |
| 3857 | return loxi.pp.pp(self) |
| 3858 | |
| 3859 | def pretty_print(self, q): |
| 3860 | q.text("flow_stats_reply {") |
| 3861 | with q.group(): |
| 3862 | with q.indent(2): |
| 3863 | q.breakable() |
| 3864 | q.text("xid = "); |
| 3865 | if self.xid != None: |
| 3866 | q.text("%#x" % self.xid) |
| 3867 | else: |
| 3868 | q.text('None') |
| 3869 | q.text(","); q.breakable() |
| 3870 | q.text("flags = "); |
| 3871 | q.text("%#x" % self.flags) |
| 3872 | q.text(","); q.breakable() |
| 3873 | q.text("entries = "); |
| 3874 | q.pp(self.entries) |
| 3875 | q.breakable() |
| 3876 | q.text('}') |
| 3877 | |
| 3878 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3879 | version = 3 |
| 3880 | type = 18 |
| 3881 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3882 | |
| 3883 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 3884 | self.xid = xid |
| 3885 | if flags != None: |
| 3886 | self.flags = flags |
| 3887 | else: |
| 3888 | self.flags = 0 |
| 3889 | if table_id != None: |
| 3890 | self.table_id = table_id |
| 3891 | else: |
| 3892 | self.table_id = 0 |
| 3893 | if out_port != None: |
| 3894 | self.out_port = out_port |
| 3895 | else: |
| 3896 | self.out_port = 0 |
| 3897 | if out_group != None: |
| 3898 | self.out_group = out_group |
| 3899 | else: |
| 3900 | self.out_group = 0 |
| 3901 | if cookie != None: |
| 3902 | self.cookie = cookie |
| 3903 | else: |
| 3904 | self.cookie = 0 |
| 3905 | if cookie_mask != None: |
| 3906 | self.cookie_mask = cookie_mask |
| 3907 | else: |
| 3908 | self.cookie_mask = 0 |
| 3909 | if match != None: |
| 3910 | self.match = match |
| 3911 | else: |
| 3912 | self.match = common.match() |
| 3913 | |
| 3914 | def pack(self): |
| 3915 | packed = [] |
| 3916 | packed.append(struct.pack("!B", self.version)) |
| 3917 | packed.append(struct.pack("!B", self.type)) |
| 3918 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3919 | packed.append(struct.pack("!L", self.xid)) |
| 3920 | packed.append(struct.pack("!H", self.stats_type)) |
| 3921 | packed.append(struct.pack("!H", self.flags)) |
| 3922 | packed.append('\x00' * 4) |
| 3923 | packed.append(struct.pack("!B", self.table_id)) |
| 3924 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3925 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3926 | packed.append(struct.pack("!L", self.out_group)) |
| 3927 | packed.append('\x00' * 4) |
| 3928 | packed.append(struct.pack("!Q", self.cookie)) |
| 3929 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3930 | packed.append(self.match.pack()) |
| 3931 | length = sum([len(x) for x in packed]) |
| 3932 | packed[2] = struct.pack("!H", length) |
| 3933 | return ''.join(packed) |
| 3934 | |
| 3935 | @staticmethod |
| 3936 | def unpack(buf): |
| 3937 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3938 | obj = flow_stats_request() |
| 3939 | if type(buf) == loxi.generic_util.OFReader: |
| 3940 | reader = buf |
| 3941 | else: |
| 3942 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3943 | _version = reader.read("!B")[0] |
| 3944 | assert(_version == 3) |
| 3945 | _type = reader.read("!B")[0] |
| 3946 | assert(_type == 18) |
| 3947 | _length = reader.read("!H")[0] |
| 3948 | obj.xid = reader.read("!L")[0] |
| 3949 | _stats_type = reader.read("!H")[0] |
| 3950 | assert(_stats_type == 1) |
| 3951 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3952 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3953 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3954 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3955 | obj.out_port = util.unpack_port_no(reader) |
| 3956 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3957 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3958 | obj.cookie = reader.read("!Q")[0] |
| 3959 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3960 | obj.match = common.match.unpack(reader) |
| 3961 | return obj |
| 3962 | |
| 3963 | def __eq__(self, other): |
| 3964 | if type(self) != type(other): return False |
| 3965 | if self.version != other.version: return False |
| 3966 | if self.type != other.type: return False |
| 3967 | if self.xid != other.xid: return False |
| 3968 | if self.flags != other.flags: return False |
| 3969 | if self.table_id != other.table_id: return False |
| 3970 | if self.out_port != other.out_port: return False |
| 3971 | if self.out_group != other.out_group: return False |
| 3972 | if self.cookie != other.cookie: return False |
| 3973 | if self.cookie_mask != other.cookie_mask: return False |
| 3974 | if self.match != other.match: return False |
| 3975 | return True |
| 3976 | |
| 3977 | def __ne__(self, other): |
| 3978 | return not self.__eq__(other) |
| 3979 | |
| 3980 | def __str__(self): |
| 3981 | return self.show() |
| 3982 | |
| 3983 | def show(self): |
| 3984 | import loxi.pp |
| 3985 | return loxi.pp.pp(self) |
| 3986 | |
| 3987 | def pretty_print(self, q): |
| 3988 | q.text("flow_stats_request {") |
| 3989 | with q.group(): |
| 3990 | with q.indent(2): |
| 3991 | q.breakable() |
| 3992 | q.text("xid = "); |
| 3993 | if self.xid != None: |
| 3994 | q.text("%#x" % self.xid) |
| 3995 | else: |
| 3996 | q.text('None') |
| 3997 | q.text(","); q.breakable() |
| 3998 | q.text("flags = "); |
| 3999 | q.text("%#x" % self.flags) |
| 4000 | q.text(","); q.breakable() |
| 4001 | q.text("table_id = "); |
| 4002 | q.text("%#x" % self.table_id) |
| 4003 | q.text(","); q.breakable() |
| 4004 | q.text("out_port = "); |
| 4005 | q.text(util.pretty_port(self.out_port)) |
| 4006 | q.text(","); q.breakable() |
| 4007 | q.text("out_group = "); |
| 4008 | q.text("%#x" % self.out_group) |
| 4009 | q.text(","); q.breakable() |
| 4010 | q.text("cookie = "); |
| 4011 | q.text("%#x" % self.cookie) |
| 4012 | q.text(","); q.breakable() |
| 4013 | q.text("cookie_mask = "); |
| 4014 | q.text("%#x" % self.cookie_mask) |
| 4015 | q.text(","); q.breakable() |
| 4016 | q.text("match = "); |
| 4017 | q.pp(self.match) |
| 4018 | q.breakable() |
| 4019 | q.text('}') |
| 4020 | |
| 4021 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4022 | version = 3 |
| 4023 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4024 | |
| 4025 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 4026 | self.xid = xid |
| 4027 | if flags != None: |
| 4028 | self.flags = flags |
| 4029 | else: |
| 4030 | self.flags = 0 |
| 4031 | if miss_send_len != None: |
| 4032 | self.miss_send_len = miss_send_len |
| 4033 | else: |
| 4034 | self.miss_send_len = 0 |
| 4035 | |
| 4036 | def pack(self): |
| 4037 | packed = [] |
| 4038 | packed.append(struct.pack("!B", self.version)) |
| 4039 | packed.append(struct.pack("!B", self.type)) |
| 4040 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4041 | packed.append(struct.pack("!L", self.xid)) |
| 4042 | packed.append(struct.pack("!H", self.flags)) |
| 4043 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 4044 | length = sum([len(x) for x in packed]) |
| 4045 | packed[2] = struct.pack("!H", length) |
| 4046 | return ''.join(packed) |
| 4047 | |
| 4048 | @staticmethod |
| 4049 | def unpack(buf): |
| 4050 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4051 | obj = get_config_reply() |
| 4052 | if type(buf) == loxi.generic_util.OFReader: |
| 4053 | reader = buf |
| 4054 | else: |
| 4055 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4056 | _version = reader.read("!B")[0] |
| 4057 | assert(_version == 3) |
| 4058 | _type = reader.read("!B")[0] |
| 4059 | assert(_type == 8) |
| 4060 | _length = reader.read("!H")[0] |
| 4061 | obj.xid = reader.read("!L")[0] |
| 4062 | obj.flags = reader.read("!H")[0] |
| 4063 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4064 | return obj |
| 4065 | |
| 4066 | def __eq__(self, other): |
| 4067 | if type(self) != type(other): return False |
| 4068 | if self.version != other.version: return False |
| 4069 | if self.type != other.type: return False |
| 4070 | if self.xid != other.xid: return False |
| 4071 | if self.flags != other.flags: return False |
| 4072 | if self.miss_send_len != other.miss_send_len: return False |
| 4073 | return True |
| 4074 | |
| 4075 | def __ne__(self, other): |
| 4076 | return not self.__eq__(other) |
| 4077 | |
| 4078 | def __str__(self): |
| 4079 | return self.show() |
| 4080 | |
| 4081 | def show(self): |
| 4082 | import loxi.pp |
| 4083 | return loxi.pp.pp(self) |
| 4084 | |
| 4085 | def pretty_print(self, q): |
| 4086 | q.text("get_config_reply {") |
| 4087 | with q.group(): |
| 4088 | with q.indent(2): |
| 4089 | q.breakable() |
| 4090 | q.text("xid = "); |
| 4091 | if self.xid != None: |
| 4092 | q.text("%#x" % self.xid) |
| 4093 | else: |
| 4094 | q.text('None') |
| 4095 | q.text(","); q.breakable() |
| 4096 | q.text("flags = "); |
| 4097 | q.text("%#x" % self.flags) |
| 4098 | q.text(","); q.breakable() |
| 4099 | q.text("miss_send_len = "); |
| 4100 | q.text("%#x" % self.miss_send_len) |
| 4101 | q.breakable() |
| 4102 | q.text('}') |
| 4103 | |
| 4104 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4105 | version = 3 |
| 4106 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4107 | |
| 4108 | def __init__(self, xid=None): |
| 4109 | self.xid = xid |
| 4110 | |
| 4111 | def pack(self): |
| 4112 | packed = [] |
| 4113 | packed.append(struct.pack("!B", self.version)) |
| 4114 | packed.append(struct.pack("!B", self.type)) |
| 4115 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4116 | packed.append(struct.pack("!L", self.xid)) |
| 4117 | length = sum([len(x) for x in packed]) |
| 4118 | packed[2] = struct.pack("!H", length) |
| 4119 | return ''.join(packed) |
| 4120 | |
| 4121 | @staticmethod |
| 4122 | def unpack(buf): |
| 4123 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4124 | obj = get_config_request() |
| 4125 | if type(buf) == loxi.generic_util.OFReader: |
| 4126 | reader = buf |
| 4127 | else: |
| 4128 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4129 | _version = reader.read("!B")[0] |
| 4130 | assert(_version == 3) |
| 4131 | _type = reader.read("!B")[0] |
| 4132 | assert(_type == 7) |
| 4133 | _length = reader.read("!H")[0] |
| 4134 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4135 | return obj |
| 4136 | |
| 4137 | def __eq__(self, other): |
| 4138 | if type(self) != type(other): return False |
| 4139 | if self.version != other.version: return False |
| 4140 | if self.type != other.type: return False |
| 4141 | if self.xid != other.xid: return False |
| 4142 | return True |
| 4143 | |
| 4144 | def __ne__(self, other): |
| 4145 | return not self.__eq__(other) |
| 4146 | |
| 4147 | def __str__(self): |
| 4148 | return self.show() |
| 4149 | |
| 4150 | def show(self): |
| 4151 | import loxi.pp |
| 4152 | return loxi.pp.pp(self) |
| 4153 | |
| 4154 | def pretty_print(self, q): |
| 4155 | q.text("get_config_request {") |
| 4156 | with q.group(): |
| 4157 | with q.indent(2): |
| 4158 | q.breakable() |
| 4159 | q.text("xid = "); |
| 4160 | if self.xid != None: |
| 4161 | q.text("%#x" % self.xid) |
| 4162 | else: |
| 4163 | q.text('None') |
| 4164 | q.breakable() |
| 4165 | q.text('}') |
| 4166 | |
| 4167 | class group_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4168 | version = 3 |
| 4169 | type = 19 |
| 4170 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4171 | |
| 4172 | def __init__(self, xid=None, flags=None, entries=None): |
| 4173 | self.xid = xid |
| 4174 | if flags != None: |
| 4175 | self.flags = flags |
| 4176 | else: |
| 4177 | self.flags = 0 |
| 4178 | if entries != None: |
| 4179 | self.entries = entries |
| 4180 | else: |
| 4181 | self.entries = [] |
| 4182 | |
| 4183 | def pack(self): |
| 4184 | packed = [] |
| 4185 | packed.append(struct.pack("!B", self.version)) |
| 4186 | packed.append(struct.pack("!B", self.type)) |
| 4187 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4188 | packed.append(struct.pack("!L", self.xid)) |
| 4189 | packed.append(struct.pack("!H", self.stats_type)) |
| 4190 | packed.append(struct.pack("!H", self.flags)) |
| 4191 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4192 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4193 | length = sum([len(x) for x in packed]) |
| 4194 | packed[2] = struct.pack("!H", length) |
| 4195 | return ''.join(packed) |
| 4196 | |
| 4197 | @staticmethod |
| 4198 | def unpack(buf): |
| 4199 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4200 | obj = group_desc_stats_reply() |
| 4201 | if type(buf) == loxi.generic_util.OFReader: |
| 4202 | reader = buf |
| 4203 | else: |
| 4204 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4205 | _version = reader.read("!B")[0] |
| 4206 | assert(_version == 3) |
| 4207 | _type = reader.read("!B")[0] |
| 4208 | assert(_type == 19) |
| 4209 | _length = reader.read("!H")[0] |
| 4210 | obj.xid = reader.read("!L")[0] |
| 4211 | _stats_type = reader.read("!H")[0] |
| 4212 | assert(_stats_type == 7) |
| 4213 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4214 | reader.skip(4) |
| 4215 | obj.entries = common.unpack_list_group_desc_stats_entry(reader) |
| 4216 | return obj |
| 4217 | |
| 4218 | def __eq__(self, other): |
| 4219 | if type(self) != type(other): return False |
| 4220 | if self.version != other.version: return False |
| 4221 | if self.type != other.type: return False |
| 4222 | if self.xid != other.xid: return False |
| 4223 | if self.flags != other.flags: return False |
| 4224 | if self.entries != other.entries: return False |
| 4225 | return True |
| 4226 | |
| 4227 | def __ne__(self, other): |
| 4228 | return not self.__eq__(other) |
| 4229 | |
| 4230 | def __str__(self): |
| 4231 | return self.show() |
| 4232 | |
| 4233 | def show(self): |
| 4234 | import loxi.pp |
| 4235 | return loxi.pp.pp(self) |
| 4236 | |
| 4237 | def pretty_print(self, q): |
| 4238 | q.text("group_desc_stats_reply {") |
| 4239 | with q.group(): |
| 4240 | with q.indent(2): |
| 4241 | q.breakable() |
| 4242 | q.text("xid = "); |
| 4243 | if self.xid != None: |
| 4244 | q.text("%#x" % self.xid) |
| 4245 | else: |
| 4246 | q.text('None') |
| 4247 | q.text(","); q.breakable() |
| 4248 | q.text("flags = "); |
| 4249 | q.text("%#x" % self.flags) |
| 4250 | q.text(","); q.breakable() |
| 4251 | q.text("entries = "); |
| 4252 | q.pp(self.entries) |
| 4253 | q.breakable() |
| 4254 | q.text('}') |
| 4255 | |
| 4256 | class group_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4257 | version = 3 |
| 4258 | type = 18 |
| 4259 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4260 | |
| 4261 | def __init__(self, xid=None, flags=None): |
| 4262 | self.xid = xid |
| 4263 | if flags != None: |
| 4264 | self.flags = flags |
| 4265 | else: |
| 4266 | self.flags = 0 |
| 4267 | |
| 4268 | def pack(self): |
| 4269 | packed = [] |
| 4270 | packed.append(struct.pack("!B", self.version)) |
| 4271 | packed.append(struct.pack("!B", self.type)) |
| 4272 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4273 | packed.append(struct.pack("!L", self.xid)) |
| 4274 | packed.append(struct.pack("!H", self.stats_type)) |
| 4275 | packed.append(struct.pack("!H", self.flags)) |
| 4276 | packed.append('\x00' * 4) |
| 4277 | length = sum([len(x) for x in packed]) |
| 4278 | packed[2] = struct.pack("!H", length) |
| 4279 | return ''.join(packed) |
| 4280 | |
| 4281 | @staticmethod |
| 4282 | def unpack(buf): |
| 4283 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4284 | obj = group_desc_stats_request() |
| 4285 | if type(buf) == loxi.generic_util.OFReader: |
| 4286 | reader = buf |
| 4287 | else: |
| 4288 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4289 | _version = reader.read("!B")[0] |
| 4290 | assert(_version == 3) |
| 4291 | _type = reader.read("!B")[0] |
| 4292 | assert(_type == 18) |
| 4293 | _length = reader.read("!H")[0] |
| 4294 | obj.xid = reader.read("!L")[0] |
| 4295 | _stats_type = reader.read("!H")[0] |
| 4296 | assert(_stats_type == 7) |
| 4297 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4298 | reader.skip(4) |
| 4299 | return obj |
| 4300 | |
| 4301 | def __eq__(self, other): |
| 4302 | if type(self) != type(other): return False |
| 4303 | if self.version != other.version: return False |
| 4304 | if self.type != other.type: return False |
| 4305 | if self.xid != other.xid: return False |
| 4306 | if self.flags != other.flags: return False |
| 4307 | return True |
| 4308 | |
| 4309 | def __ne__(self, other): |
| 4310 | return not self.__eq__(other) |
| 4311 | |
| 4312 | def __str__(self): |
| 4313 | return self.show() |
| 4314 | |
| 4315 | def show(self): |
| 4316 | import loxi.pp |
| 4317 | return loxi.pp.pp(self) |
| 4318 | |
| 4319 | def pretty_print(self, q): |
| 4320 | q.text("group_desc_stats_request {") |
| 4321 | with q.group(): |
| 4322 | with q.indent(2): |
| 4323 | q.breakable() |
| 4324 | q.text("xid = "); |
| 4325 | if self.xid != None: |
| 4326 | q.text("%#x" % self.xid) |
| 4327 | else: |
| 4328 | q.text('None') |
| 4329 | q.text(","); q.breakable() |
| 4330 | q.text("flags = "); |
| 4331 | q.text("%#x" % self.flags) |
| 4332 | q.breakable() |
| 4333 | q.text('}') |
| 4334 | |
| 4335 | class group_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4336 | version = 3 |
| 4337 | type = 19 |
| 4338 | stats_type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4339 | |
| 4340 | def __init__(self, xid=None, flags=None, types=None, capabilities=None, max_groups_all=None, max_groups_select=None, max_groups_indirect=None, max_groups_ff=None, actions_all=None, actions_select=None, actions_indirect=None, actions_ff=None): |
| 4341 | self.xid = xid |
| 4342 | if flags != None: |
| 4343 | self.flags = flags |
| 4344 | else: |
| 4345 | self.flags = 0 |
| 4346 | if types != None: |
| 4347 | self.types = types |
| 4348 | else: |
| 4349 | self.types = 0 |
| 4350 | if capabilities != None: |
| 4351 | self.capabilities = capabilities |
| 4352 | else: |
| 4353 | self.capabilities = 0 |
| 4354 | if max_groups_all != None: |
| 4355 | self.max_groups_all = max_groups_all |
| 4356 | else: |
| 4357 | self.max_groups_all = 0 |
| 4358 | if max_groups_select != None: |
| 4359 | self.max_groups_select = max_groups_select |
| 4360 | else: |
| 4361 | self.max_groups_select = 0 |
| 4362 | if max_groups_indirect != None: |
| 4363 | self.max_groups_indirect = max_groups_indirect |
| 4364 | else: |
| 4365 | self.max_groups_indirect = 0 |
| 4366 | if max_groups_ff != None: |
| 4367 | self.max_groups_ff = max_groups_ff |
| 4368 | else: |
| 4369 | self.max_groups_ff = 0 |
| 4370 | if actions_all != None: |
| 4371 | self.actions_all = actions_all |
| 4372 | else: |
| 4373 | self.actions_all = 0 |
| 4374 | if actions_select != None: |
| 4375 | self.actions_select = actions_select |
| 4376 | else: |
| 4377 | self.actions_select = 0 |
| 4378 | if actions_indirect != None: |
| 4379 | self.actions_indirect = actions_indirect |
| 4380 | else: |
| 4381 | self.actions_indirect = 0 |
| 4382 | if actions_ff != None: |
| 4383 | self.actions_ff = actions_ff |
| 4384 | else: |
| 4385 | self.actions_ff = 0 |
| 4386 | |
| 4387 | def pack(self): |
| 4388 | packed = [] |
| 4389 | packed.append(struct.pack("!B", self.version)) |
| 4390 | packed.append(struct.pack("!B", self.type)) |
| 4391 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4392 | packed.append(struct.pack("!L", self.xid)) |
| 4393 | packed.append(struct.pack("!H", self.stats_type)) |
| 4394 | packed.append(struct.pack("!H", self.flags)) |
| 4395 | packed.append('\x00' * 4) |
| 4396 | packed.append(struct.pack("!L", self.types)) |
| 4397 | packed.append(struct.pack("!L", self.capabilities)) |
| 4398 | packed.append(struct.pack("!L", self.max_groups_all)) |
| 4399 | packed.append(struct.pack("!L", self.max_groups_select)) |
| 4400 | packed.append(struct.pack("!L", self.max_groups_indirect)) |
| 4401 | packed.append(struct.pack("!L", self.max_groups_ff)) |
| 4402 | packed.append(struct.pack("!L", self.actions_all)) |
| 4403 | packed.append(struct.pack("!L", self.actions_select)) |
| 4404 | packed.append(struct.pack("!L", self.actions_indirect)) |
| 4405 | packed.append(struct.pack("!L", self.actions_ff)) |
| 4406 | length = sum([len(x) for x in packed]) |
| 4407 | packed[2] = struct.pack("!H", length) |
| 4408 | return ''.join(packed) |
| 4409 | |
| 4410 | @staticmethod |
| 4411 | def unpack(buf): |
| 4412 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4413 | obj = group_features_stats_reply() |
| 4414 | if type(buf) == loxi.generic_util.OFReader: |
| 4415 | reader = buf |
| 4416 | else: |
| 4417 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4418 | _version = reader.read("!B")[0] |
| 4419 | assert(_version == 3) |
| 4420 | _type = reader.read("!B")[0] |
| 4421 | assert(_type == 19) |
| 4422 | _length = reader.read("!H")[0] |
| 4423 | obj.xid = reader.read("!L")[0] |
| 4424 | _stats_type = reader.read("!H")[0] |
| 4425 | assert(_stats_type == 8) |
| 4426 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4427 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4428 | obj.types = reader.read("!L")[0] |
| 4429 | obj.capabilities = reader.read("!L")[0] |
| 4430 | obj.max_groups_all = reader.read("!L")[0] |
| 4431 | obj.max_groups_select = reader.read("!L")[0] |
| 4432 | obj.max_groups_indirect = reader.read("!L")[0] |
| 4433 | obj.max_groups_ff = reader.read("!L")[0] |
| 4434 | obj.actions_all = reader.read("!L")[0] |
| 4435 | obj.actions_select = reader.read("!L")[0] |
| 4436 | obj.actions_indirect = reader.read("!L")[0] |
| 4437 | obj.actions_ff = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4438 | return obj |
| 4439 | |
| 4440 | def __eq__(self, other): |
| 4441 | if type(self) != type(other): return False |
| 4442 | if self.version != other.version: return False |
| 4443 | if self.type != other.type: return False |
| 4444 | if self.xid != other.xid: return False |
| 4445 | if self.flags != other.flags: return False |
| 4446 | if self.types != other.types: return False |
| 4447 | if self.capabilities != other.capabilities: return False |
| 4448 | if self.max_groups_all != other.max_groups_all: return False |
| 4449 | if self.max_groups_select != other.max_groups_select: return False |
| 4450 | if self.max_groups_indirect != other.max_groups_indirect: return False |
| 4451 | if self.max_groups_ff != other.max_groups_ff: return False |
| 4452 | if self.actions_all != other.actions_all: return False |
| 4453 | if self.actions_select != other.actions_select: return False |
| 4454 | if self.actions_indirect != other.actions_indirect: return False |
| 4455 | if self.actions_ff != other.actions_ff: return False |
| 4456 | return True |
| 4457 | |
| 4458 | def __ne__(self, other): |
| 4459 | return not self.__eq__(other) |
| 4460 | |
| 4461 | def __str__(self): |
| 4462 | return self.show() |
| 4463 | |
| 4464 | def show(self): |
| 4465 | import loxi.pp |
| 4466 | return loxi.pp.pp(self) |
| 4467 | |
| 4468 | def pretty_print(self, q): |
| 4469 | q.text("group_features_stats_reply {") |
| 4470 | with q.group(): |
| 4471 | with q.indent(2): |
| 4472 | q.breakable() |
| 4473 | q.text("xid = "); |
| 4474 | if self.xid != None: |
| 4475 | q.text("%#x" % self.xid) |
| 4476 | else: |
| 4477 | q.text('None') |
| 4478 | q.text(","); q.breakable() |
| 4479 | q.text("flags = "); |
| 4480 | q.text("%#x" % self.flags) |
| 4481 | q.text(","); q.breakable() |
| 4482 | q.text("types = "); |
| 4483 | q.text("%#x" % self.types) |
| 4484 | q.text(","); q.breakable() |
| 4485 | q.text("capabilities = "); |
| 4486 | q.text("%#x" % self.capabilities) |
| 4487 | q.text(","); q.breakable() |
| 4488 | q.text("max_groups_all = "); |
| 4489 | q.text("%#x" % self.max_groups_all) |
| 4490 | q.text(","); q.breakable() |
| 4491 | q.text("max_groups_select = "); |
| 4492 | q.text("%#x" % self.max_groups_select) |
| 4493 | q.text(","); q.breakable() |
| 4494 | q.text("max_groups_indirect = "); |
| 4495 | q.text("%#x" % self.max_groups_indirect) |
| 4496 | q.text(","); q.breakable() |
| 4497 | q.text("max_groups_ff = "); |
| 4498 | q.text("%#x" % self.max_groups_ff) |
| 4499 | q.text(","); q.breakable() |
| 4500 | q.text("actions_all = "); |
| 4501 | q.text("%#x" % self.actions_all) |
| 4502 | q.text(","); q.breakable() |
| 4503 | q.text("actions_select = "); |
| 4504 | q.text("%#x" % self.actions_select) |
| 4505 | q.text(","); q.breakable() |
| 4506 | q.text("actions_indirect = "); |
| 4507 | q.text("%#x" % self.actions_indirect) |
| 4508 | q.text(","); q.breakable() |
| 4509 | q.text("actions_ff = "); |
| 4510 | q.text("%#x" % self.actions_ff) |
| 4511 | q.breakable() |
| 4512 | q.text('}') |
| 4513 | |
| 4514 | class group_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4515 | version = 3 |
| 4516 | type = 18 |
| 4517 | stats_type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4518 | |
| 4519 | def __init__(self, xid=None, flags=None): |
| 4520 | self.xid = xid |
| 4521 | if flags != None: |
| 4522 | self.flags = flags |
| 4523 | else: |
| 4524 | self.flags = 0 |
| 4525 | |
| 4526 | def pack(self): |
| 4527 | packed = [] |
| 4528 | packed.append(struct.pack("!B", self.version)) |
| 4529 | packed.append(struct.pack("!B", self.type)) |
| 4530 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4531 | packed.append(struct.pack("!L", self.xid)) |
| 4532 | packed.append(struct.pack("!H", self.stats_type)) |
| 4533 | packed.append(struct.pack("!H", self.flags)) |
| 4534 | packed.append('\x00' * 4) |
| 4535 | length = sum([len(x) for x in packed]) |
| 4536 | packed[2] = struct.pack("!H", length) |
| 4537 | return ''.join(packed) |
| 4538 | |
| 4539 | @staticmethod |
| 4540 | def unpack(buf): |
| 4541 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4542 | obj = group_features_stats_request() |
| 4543 | if type(buf) == loxi.generic_util.OFReader: |
| 4544 | reader = buf |
| 4545 | else: |
| 4546 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4547 | _version = reader.read("!B")[0] |
| 4548 | assert(_version == 3) |
| 4549 | _type = reader.read("!B")[0] |
| 4550 | assert(_type == 18) |
| 4551 | _length = reader.read("!H")[0] |
| 4552 | obj.xid = reader.read("!L")[0] |
| 4553 | _stats_type = reader.read("!H")[0] |
| 4554 | assert(_stats_type == 8) |
| 4555 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4556 | reader.skip(4) |
| 4557 | return obj |
| 4558 | |
| 4559 | def __eq__(self, other): |
| 4560 | if type(self) != type(other): return False |
| 4561 | if self.version != other.version: return False |
| 4562 | if self.type != other.type: return False |
| 4563 | if self.xid != other.xid: return False |
| 4564 | if self.flags != other.flags: 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_features_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.breakable() |
| 4591 | q.text('}') |
| 4592 | |
| 4593 | class group_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4594 | version = 3 |
| 4595 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4596 | |
| 4597 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 4598 | self.xid = xid |
| 4599 | if command != None: |
| 4600 | self.command = command |
| 4601 | else: |
| 4602 | self.command = 0 |
| 4603 | if group_type != None: |
| 4604 | self.group_type = group_type |
| 4605 | else: |
| 4606 | self.group_type = 0 |
| 4607 | if group_id != None: |
| 4608 | self.group_id = group_id |
| 4609 | else: |
| 4610 | self.group_id = 0 |
| 4611 | if buckets != None: |
| 4612 | self.buckets = buckets |
| 4613 | else: |
| 4614 | self.buckets = [] |
| 4615 | |
| 4616 | def pack(self): |
| 4617 | packed = [] |
| 4618 | packed.append(struct.pack("!B", self.version)) |
| 4619 | packed.append(struct.pack("!B", self.type)) |
| 4620 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4621 | packed.append(struct.pack("!L", self.xid)) |
| 4622 | packed.append(struct.pack("!H", self.command)) |
| 4623 | packed.append(struct.pack("!B", self.group_type)) |
| 4624 | packed.append('\x00' * 1) |
| 4625 | packed.append(struct.pack("!L", self.group_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4626 | packed.append(util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4627 | length = sum([len(x) for x in packed]) |
| 4628 | packed[2] = struct.pack("!H", length) |
| 4629 | return ''.join(packed) |
| 4630 | |
| 4631 | @staticmethod |
| 4632 | def unpack(buf): |
| 4633 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4634 | obj = group_mod() |
| 4635 | if type(buf) == loxi.generic_util.OFReader: |
| 4636 | reader = buf |
| 4637 | else: |
| 4638 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4639 | _version = reader.read("!B")[0] |
| 4640 | assert(_version == 3) |
| 4641 | _type = reader.read("!B")[0] |
| 4642 | assert(_type == 15) |
| 4643 | _length = reader.read("!H")[0] |
| 4644 | obj.xid = reader.read("!L")[0] |
| 4645 | obj.command = reader.read("!H")[0] |
| 4646 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4647 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4648 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4649 | obj.buckets = common.unpack_list_bucket(reader) |
| 4650 | return obj |
| 4651 | |
| 4652 | def __eq__(self, other): |
| 4653 | if type(self) != type(other): return False |
| 4654 | if self.version != other.version: return False |
| 4655 | if self.type != other.type: return False |
| 4656 | if self.xid != other.xid: return False |
| 4657 | if self.command != other.command: return False |
| 4658 | if self.group_type != other.group_type: return False |
| 4659 | if self.group_id != other.group_id: return False |
| 4660 | if self.buckets != other.buckets: return False |
| 4661 | return True |
| 4662 | |
| 4663 | def __ne__(self, other): |
| 4664 | return not self.__eq__(other) |
| 4665 | |
| 4666 | def __str__(self): |
| 4667 | return self.show() |
| 4668 | |
| 4669 | def show(self): |
| 4670 | import loxi.pp |
| 4671 | return loxi.pp.pp(self) |
| 4672 | |
| 4673 | def pretty_print(self, q): |
| 4674 | q.text("group_mod {") |
| 4675 | with q.group(): |
| 4676 | with q.indent(2): |
| 4677 | q.breakable() |
| 4678 | q.text("xid = "); |
| 4679 | if self.xid != None: |
| 4680 | q.text("%#x" % self.xid) |
| 4681 | else: |
| 4682 | q.text('None') |
| 4683 | q.text(","); q.breakable() |
| 4684 | q.text("command = "); |
| 4685 | q.text("%#x" % self.command) |
| 4686 | q.text(","); q.breakable() |
| 4687 | q.text("group_type = "); |
| 4688 | q.text("%#x" % self.group_type) |
| 4689 | q.text(","); q.breakable() |
| 4690 | q.text("group_id = "); |
| 4691 | q.text("%#x" % self.group_id) |
| 4692 | q.text(","); q.breakable() |
| 4693 | q.text("buckets = "); |
| 4694 | q.pp(self.buckets) |
| 4695 | q.breakable() |
| 4696 | q.text('}') |
| 4697 | |
| 4698 | class group_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4699 | version = 3 |
| 4700 | type = 19 |
| 4701 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4702 | |
| 4703 | def __init__(self, xid=None, flags=None, entries=None): |
| 4704 | self.xid = xid |
| 4705 | if flags != None: |
| 4706 | self.flags = flags |
| 4707 | else: |
| 4708 | self.flags = 0 |
| 4709 | if entries != None: |
| 4710 | self.entries = entries |
| 4711 | else: |
| 4712 | self.entries = [] |
| 4713 | |
| 4714 | def pack(self): |
| 4715 | packed = [] |
| 4716 | packed.append(struct.pack("!B", self.version)) |
| 4717 | packed.append(struct.pack("!B", self.type)) |
| 4718 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4719 | packed.append(struct.pack("!L", self.xid)) |
| 4720 | packed.append(struct.pack("!H", self.stats_type)) |
| 4721 | packed.append(struct.pack("!H", self.flags)) |
| 4722 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4723 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4724 | length = sum([len(x) for x in packed]) |
| 4725 | packed[2] = struct.pack("!H", length) |
| 4726 | return ''.join(packed) |
| 4727 | |
| 4728 | @staticmethod |
| 4729 | def unpack(buf): |
| 4730 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4731 | obj = group_stats_reply() |
| 4732 | if type(buf) == loxi.generic_util.OFReader: |
| 4733 | reader = buf |
| 4734 | else: |
| 4735 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4736 | _version = reader.read("!B")[0] |
| 4737 | assert(_version == 3) |
| 4738 | _type = reader.read("!B")[0] |
| 4739 | assert(_type == 19) |
| 4740 | _length = reader.read("!H")[0] |
| 4741 | obj.xid = reader.read("!L")[0] |
| 4742 | _stats_type = reader.read("!H")[0] |
| 4743 | assert(_stats_type == 6) |
| 4744 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4745 | reader.skip(4) |
| 4746 | obj.entries = common.unpack_list_group_stats_entry(reader) |
| 4747 | return obj |
| 4748 | |
| 4749 | def __eq__(self, other): |
| 4750 | if type(self) != type(other): return False |
| 4751 | if self.version != other.version: return False |
| 4752 | if self.type != other.type: return False |
| 4753 | if self.xid != other.xid: return False |
| 4754 | if self.flags != other.flags: return False |
| 4755 | if self.entries != other.entries: return False |
| 4756 | return True |
| 4757 | |
| 4758 | def __ne__(self, other): |
| 4759 | return not self.__eq__(other) |
| 4760 | |
| 4761 | def __str__(self): |
| 4762 | return self.show() |
| 4763 | |
| 4764 | def show(self): |
| 4765 | import loxi.pp |
| 4766 | return loxi.pp.pp(self) |
| 4767 | |
| 4768 | def pretty_print(self, q): |
| 4769 | q.text("group_stats_reply {") |
| 4770 | with q.group(): |
| 4771 | with q.indent(2): |
| 4772 | q.breakable() |
| 4773 | q.text("xid = "); |
| 4774 | if self.xid != None: |
| 4775 | q.text("%#x" % self.xid) |
| 4776 | else: |
| 4777 | q.text('None') |
| 4778 | q.text(","); q.breakable() |
| 4779 | q.text("flags = "); |
| 4780 | q.text("%#x" % self.flags) |
| 4781 | q.text(","); q.breakable() |
| 4782 | q.text("entries = "); |
| 4783 | q.pp(self.entries) |
| 4784 | q.breakable() |
| 4785 | q.text('}') |
| 4786 | |
| 4787 | class group_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4788 | version = 3 |
| 4789 | type = 18 |
| 4790 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4791 | |
| 4792 | def __init__(self, xid=None, flags=None, group_id=None): |
| 4793 | self.xid = xid |
| 4794 | if flags != None: |
| 4795 | self.flags = flags |
| 4796 | else: |
| 4797 | self.flags = 0 |
| 4798 | if group_id != None: |
| 4799 | self.group_id = group_id |
| 4800 | else: |
| 4801 | self.group_id = 0 |
| 4802 | |
| 4803 | def pack(self): |
| 4804 | packed = [] |
| 4805 | packed.append(struct.pack("!B", self.version)) |
| 4806 | packed.append(struct.pack("!B", self.type)) |
| 4807 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4808 | packed.append(struct.pack("!L", self.xid)) |
| 4809 | packed.append(struct.pack("!H", self.stats_type)) |
| 4810 | packed.append(struct.pack("!H", self.flags)) |
| 4811 | packed.append('\x00' * 4) |
| 4812 | packed.append(struct.pack("!L", self.group_id)) |
| 4813 | packed.append('\x00' * 4) |
| 4814 | length = sum([len(x) for x in packed]) |
| 4815 | packed[2] = struct.pack("!H", length) |
| 4816 | return ''.join(packed) |
| 4817 | |
| 4818 | @staticmethod |
| 4819 | def unpack(buf): |
| 4820 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4821 | obj = group_stats_request() |
| 4822 | if type(buf) == loxi.generic_util.OFReader: |
| 4823 | reader = buf |
| 4824 | else: |
| 4825 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4826 | _version = reader.read("!B")[0] |
| 4827 | assert(_version == 3) |
| 4828 | _type = reader.read("!B")[0] |
| 4829 | assert(_type == 18) |
| 4830 | _length = reader.read("!H")[0] |
| 4831 | obj.xid = reader.read("!L")[0] |
| 4832 | _stats_type = reader.read("!H")[0] |
| 4833 | assert(_stats_type == 6) |
| 4834 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4835 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4836 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4837 | reader.skip(4) |
| 4838 | return obj |
| 4839 | |
| 4840 | def __eq__(self, other): |
| 4841 | if type(self) != type(other): return False |
| 4842 | if self.version != other.version: return False |
| 4843 | if self.type != other.type: return False |
| 4844 | if self.xid != other.xid: return False |
| 4845 | if self.flags != other.flags: return False |
| 4846 | if self.group_id != other.group_id: return False |
| 4847 | return True |
| 4848 | |
| 4849 | def __ne__(self, other): |
| 4850 | return not self.__eq__(other) |
| 4851 | |
| 4852 | def __str__(self): |
| 4853 | return self.show() |
| 4854 | |
| 4855 | def show(self): |
| 4856 | import loxi.pp |
| 4857 | return loxi.pp.pp(self) |
| 4858 | |
| 4859 | def pretty_print(self, q): |
| 4860 | q.text("group_stats_request {") |
| 4861 | with q.group(): |
| 4862 | with q.indent(2): |
| 4863 | q.breakable() |
| 4864 | q.text("xid = "); |
| 4865 | if self.xid != None: |
| 4866 | q.text("%#x" % self.xid) |
| 4867 | else: |
| 4868 | q.text('None') |
| 4869 | q.text(","); q.breakable() |
| 4870 | q.text("flags = "); |
| 4871 | q.text("%#x" % self.flags) |
| 4872 | q.text(","); q.breakable() |
| 4873 | q.text("group_id = "); |
| 4874 | q.text("%#x" % self.group_id) |
| 4875 | q.breakable() |
| 4876 | q.text('}') |
| 4877 | |
| 4878 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4879 | version = 3 |
| 4880 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4881 | |
| 4882 | def __init__(self, xid=None): |
| 4883 | self.xid = xid |
| 4884 | |
| 4885 | def pack(self): |
| 4886 | packed = [] |
| 4887 | packed.append(struct.pack("!B", self.version)) |
| 4888 | packed.append(struct.pack("!B", self.type)) |
| 4889 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4890 | packed.append(struct.pack("!L", self.xid)) |
| 4891 | length = sum([len(x) for x in packed]) |
| 4892 | packed[2] = struct.pack("!H", length) |
| 4893 | return ''.join(packed) |
| 4894 | |
| 4895 | @staticmethod |
| 4896 | def unpack(buf): |
| 4897 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4898 | obj = hello() |
| 4899 | if type(buf) == loxi.generic_util.OFReader: |
| 4900 | reader = buf |
| 4901 | else: |
| 4902 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4903 | _version = reader.read("!B")[0] |
| 4904 | assert(_version == 3) |
| 4905 | _type = reader.read("!B")[0] |
| 4906 | assert(_type == 0) |
| 4907 | _length = reader.read("!H")[0] |
| 4908 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4909 | return obj |
| 4910 | |
| 4911 | def __eq__(self, other): |
| 4912 | if type(self) != type(other): return False |
| 4913 | if self.version != other.version: return False |
| 4914 | if self.type != other.type: return False |
| 4915 | if self.xid != other.xid: return False |
| 4916 | return True |
| 4917 | |
| 4918 | def __ne__(self, other): |
| 4919 | return not self.__eq__(other) |
| 4920 | |
| 4921 | def __str__(self): |
| 4922 | return self.show() |
| 4923 | |
| 4924 | def show(self): |
| 4925 | import loxi.pp |
| 4926 | return loxi.pp.pp(self) |
| 4927 | |
| 4928 | def pretty_print(self, q): |
| 4929 | q.text("hello {") |
| 4930 | with q.group(): |
| 4931 | with q.indent(2): |
| 4932 | q.breakable() |
| 4933 | q.text("xid = "); |
| 4934 | if self.xid != None: |
| 4935 | q.text("%#x" % self.xid) |
| 4936 | else: |
| 4937 | q.text('None') |
| 4938 | q.breakable() |
| 4939 | q.text('}') |
| 4940 | |
| 4941 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4942 | version = 3 |
| 4943 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4944 | |
| 4945 | def __init__(self, xid=None, buffer_id=None, total_len=None, reason=None, table_id=None, match=None, data=None): |
| 4946 | self.xid = xid |
| 4947 | if buffer_id != None: |
| 4948 | self.buffer_id = buffer_id |
| 4949 | else: |
| 4950 | self.buffer_id = 0 |
| 4951 | if total_len != None: |
| 4952 | self.total_len = total_len |
| 4953 | else: |
| 4954 | self.total_len = 0 |
| 4955 | if reason != None: |
| 4956 | self.reason = reason |
| 4957 | else: |
| 4958 | self.reason = 0 |
| 4959 | if table_id != None: |
| 4960 | self.table_id = table_id |
| 4961 | else: |
| 4962 | self.table_id = 0 |
| 4963 | if match != None: |
| 4964 | self.match = match |
| 4965 | else: |
| 4966 | self.match = common.match() |
| 4967 | if data != None: |
| 4968 | self.data = data |
| 4969 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4970 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4971 | |
| 4972 | def pack(self): |
| 4973 | packed = [] |
| 4974 | packed.append(struct.pack("!B", self.version)) |
| 4975 | packed.append(struct.pack("!B", self.type)) |
| 4976 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4977 | packed.append(struct.pack("!L", self.xid)) |
| 4978 | packed.append(struct.pack("!L", self.buffer_id)) |
| 4979 | packed.append(struct.pack("!H", self.total_len)) |
| 4980 | packed.append(struct.pack("!B", self.reason)) |
| 4981 | packed.append(struct.pack("!B", self.table_id)) |
| 4982 | packed.append(self.match.pack()) |
| 4983 | packed.append('\x00' * 2) |
| 4984 | packed.append(self.data) |
| 4985 | length = sum([len(x) for x in packed]) |
| 4986 | packed[2] = struct.pack("!H", length) |
| 4987 | return ''.join(packed) |
| 4988 | |
| 4989 | @staticmethod |
| 4990 | def unpack(buf): |
| 4991 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4992 | obj = packet_in() |
| 4993 | if type(buf) == loxi.generic_util.OFReader: |
| 4994 | reader = buf |
| 4995 | else: |
| 4996 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4997 | _version = reader.read("!B")[0] |
| 4998 | assert(_version == 3) |
| 4999 | _type = reader.read("!B")[0] |
| 5000 | assert(_type == 10) |
| 5001 | _length = reader.read("!H")[0] |
| 5002 | obj.xid = reader.read("!L")[0] |
| 5003 | obj.buffer_id = reader.read("!L")[0] |
| 5004 | obj.total_len = reader.read("!H")[0] |
| 5005 | obj.reason = reader.read("!B")[0] |
| 5006 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5007 | obj.match = common.match.unpack(reader) |
| 5008 | reader.skip(2) |
| 5009 | obj.data = str(reader.read_all()) |
| 5010 | return obj |
| 5011 | |
| 5012 | def __eq__(self, other): |
| 5013 | if type(self) != type(other): return False |
| 5014 | if self.version != other.version: return False |
| 5015 | if self.type != other.type: return False |
| 5016 | if self.xid != other.xid: return False |
| 5017 | if self.buffer_id != other.buffer_id: return False |
| 5018 | if self.total_len != other.total_len: return False |
| 5019 | if self.reason != other.reason: return False |
| 5020 | if self.table_id != other.table_id: return False |
| 5021 | if self.match != other.match: return False |
| 5022 | if self.data != other.data: return False |
| 5023 | return True |
| 5024 | |
| 5025 | def __ne__(self, other): |
| 5026 | return not self.__eq__(other) |
| 5027 | |
| 5028 | def __str__(self): |
| 5029 | return self.show() |
| 5030 | |
| 5031 | def show(self): |
| 5032 | import loxi.pp |
| 5033 | return loxi.pp.pp(self) |
| 5034 | |
| 5035 | def pretty_print(self, q): |
| 5036 | q.text("packet_in {") |
| 5037 | with q.group(): |
| 5038 | with q.indent(2): |
| 5039 | q.breakable() |
| 5040 | q.text("xid = "); |
| 5041 | if self.xid != None: |
| 5042 | q.text("%#x" % self.xid) |
| 5043 | else: |
| 5044 | q.text('None') |
| 5045 | q.text(","); q.breakable() |
| 5046 | q.text("buffer_id = "); |
| 5047 | q.text("%#x" % self.buffer_id) |
| 5048 | q.text(","); q.breakable() |
| 5049 | q.text("total_len = "); |
| 5050 | q.text("%#x" % self.total_len) |
| 5051 | q.text(","); q.breakable() |
| 5052 | q.text("reason = "); |
| 5053 | q.text("%#x" % self.reason) |
| 5054 | q.text(","); q.breakable() |
| 5055 | q.text("table_id = "); |
| 5056 | q.text("%#x" % self.table_id) |
| 5057 | q.text(","); q.breakable() |
| 5058 | q.text("match = "); |
| 5059 | q.pp(self.match) |
| 5060 | q.text(","); q.breakable() |
| 5061 | q.text("data = "); |
| 5062 | q.pp(self.data) |
| 5063 | q.breakable() |
| 5064 | q.text('}') |
| 5065 | |
| 5066 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5067 | version = 3 |
| 5068 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5069 | |
| 5070 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 5071 | self.xid = xid |
| 5072 | if buffer_id != None: |
| 5073 | self.buffer_id = buffer_id |
| 5074 | else: |
| 5075 | self.buffer_id = 0 |
| 5076 | if in_port != None: |
| 5077 | self.in_port = in_port |
| 5078 | else: |
| 5079 | self.in_port = 0 |
| 5080 | if actions != None: |
| 5081 | self.actions = actions |
| 5082 | else: |
| 5083 | self.actions = [] |
| 5084 | if data != None: |
| 5085 | self.data = data |
| 5086 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5087 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5088 | |
| 5089 | def pack(self): |
| 5090 | packed = [] |
| 5091 | packed.append(struct.pack("!B", self.version)) |
| 5092 | packed.append(struct.pack("!B", self.type)) |
| 5093 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5094 | packed.append(struct.pack("!L", self.xid)) |
| 5095 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5096 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5097 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 5098 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5099 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5100 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 5101 | packed.append(self.data) |
| 5102 | length = sum([len(x) for x in packed]) |
| 5103 | packed[2] = struct.pack("!H", length) |
| 5104 | return ''.join(packed) |
| 5105 | |
| 5106 | @staticmethod |
| 5107 | def unpack(buf): |
| 5108 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5109 | obj = packet_out() |
| 5110 | if type(buf) == loxi.generic_util.OFReader: |
| 5111 | reader = buf |
| 5112 | else: |
| 5113 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5114 | _version = reader.read("!B")[0] |
| 5115 | assert(_version == 3) |
| 5116 | _type = reader.read("!B")[0] |
| 5117 | assert(_type == 13) |
| 5118 | _length = reader.read("!H")[0] |
| 5119 | obj.xid = reader.read("!L")[0] |
| 5120 | obj.buffer_id = reader.read("!L")[0] |
| 5121 | obj.in_port = util.unpack_port_no(reader) |
| 5122 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5123 | reader.skip(6) |
| 5124 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 5125 | obj.data = str(reader.read_all()) |
| 5126 | return obj |
| 5127 | |
| 5128 | def __eq__(self, other): |
| 5129 | if type(self) != type(other): return False |
| 5130 | if self.version != other.version: return False |
| 5131 | if self.type != other.type: return False |
| 5132 | if self.xid != other.xid: return False |
| 5133 | if self.buffer_id != other.buffer_id: return False |
| 5134 | if self.in_port != other.in_port: return False |
| 5135 | if self.actions != other.actions: return False |
| 5136 | if self.data != other.data: return False |
| 5137 | return True |
| 5138 | |
| 5139 | def __ne__(self, other): |
| 5140 | return not self.__eq__(other) |
| 5141 | |
| 5142 | def __str__(self): |
| 5143 | return self.show() |
| 5144 | |
| 5145 | def show(self): |
| 5146 | import loxi.pp |
| 5147 | return loxi.pp.pp(self) |
| 5148 | |
| 5149 | def pretty_print(self, q): |
| 5150 | q.text("packet_out {") |
| 5151 | with q.group(): |
| 5152 | with q.indent(2): |
| 5153 | q.breakable() |
| 5154 | q.text("xid = "); |
| 5155 | if self.xid != None: |
| 5156 | q.text("%#x" % self.xid) |
| 5157 | else: |
| 5158 | q.text('None') |
| 5159 | q.text(","); q.breakable() |
| 5160 | q.text("buffer_id = "); |
| 5161 | q.text("%#x" % self.buffer_id) |
| 5162 | q.text(","); q.breakable() |
| 5163 | q.text("in_port = "); |
| 5164 | q.text(util.pretty_port(self.in_port)) |
| 5165 | q.text(","); q.breakable() |
| 5166 | q.text("actions = "); |
| 5167 | q.pp(self.actions) |
| 5168 | q.text(","); q.breakable() |
| 5169 | q.text("data = "); |
| 5170 | q.pp(self.data) |
| 5171 | q.breakable() |
| 5172 | q.text('}') |
| 5173 | |
| 5174 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5175 | version = 3 |
| 5176 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5177 | |
| 5178 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
| 5179 | self.xid = xid |
| 5180 | if port_no != None: |
| 5181 | self.port_no = port_no |
| 5182 | else: |
| 5183 | self.port_no = 0 |
| 5184 | if hw_addr != None: |
| 5185 | self.hw_addr = hw_addr |
| 5186 | else: |
| 5187 | self.hw_addr = [0,0,0,0,0,0] |
| 5188 | if config != None: |
| 5189 | self.config = config |
| 5190 | else: |
| 5191 | self.config = 0 |
| 5192 | if mask != None: |
| 5193 | self.mask = mask |
| 5194 | else: |
| 5195 | self.mask = 0 |
| 5196 | if advertise != None: |
| 5197 | self.advertise = advertise |
| 5198 | else: |
| 5199 | self.advertise = 0 |
| 5200 | |
| 5201 | def pack(self): |
| 5202 | packed = [] |
| 5203 | packed.append(struct.pack("!B", self.version)) |
| 5204 | packed.append(struct.pack("!B", self.type)) |
| 5205 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5206 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5207 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5208 | packed.append('\x00' * 4) |
| 5209 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 5210 | packed.append('\x00' * 2) |
| 5211 | packed.append(struct.pack("!L", self.config)) |
| 5212 | packed.append(struct.pack("!L", self.mask)) |
| 5213 | packed.append(struct.pack("!L", self.advertise)) |
| 5214 | packed.append('\x00' * 4) |
| 5215 | length = sum([len(x) for x in packed]) |
| 5216 | packed[2] = struct.pack("!H", length) |
| 5217 | return ''.join(packed) |
| 5218 | |
| 5219 | @staticmethod |
| 5220 | def unpack(buf): |
| 5221 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5222 | obj = port_mod() |
| 5223 | if type(buf) == loxi.generic_util.OFReader: |
| 5224 | reader = buf |
| 5225 | else: |
| 5226 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5227 | _version = reader.read("!B")[0] |
| 5228 | assert(_version == 3) |
| 5229 | _type = reader.read("!B")[0] |
| 5230 | assert(_type == 16) |
| 5231 | _length = reader.read("!H")[0] |
| 5232 | obj.xid = reader.read("!L")[0] |
| 5233 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5234 | reader.skip(4) |
| 5235 | obj.hw_addr = list(reader.read('!6B')) |
| 5236 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5237 | obj.config = reader.read("!L")[0] |
| 5238 | obj.mask = reader.read("!L")[0] |
| 5239 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5240 | reader.skip(4) |
| 5241 | return obj |
| 5242 | |
| 5243 | def __eq__(self, other): |
| 5244 | if type(self) != type(other): return False |
| 5245 | if self.version != other.version: return False |
| 5246 | if self.type != other.type: return False |
| 5247 | if self.xid != other.xid: return False |
| 5248 | if self.port_no != other.port_no: return False |
| 5249 | if self.hw_addr != other.hw_addr: return False |
| 5250 | if self.config != other.config: return False |
| 5251 | if self.mask != other.mask: return False |
| 5252 | if self.advertise != other.advertise: 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_mod {") |
| 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("port_no = "); |
| 5277 | q.text(util.pretty_port(self.port_no)) |
| 5278 | q.text(","); q.breakable() |
| 5279 | q.text("hw_addr = "); |
| 5280 | q.text(util.pretty_mac(self.hw_addr)) |
| 5281 | q.text(","); q.breakable() |
| 5282 | q.text("config = "); |
| 5283 | q.text("%#x" % self.config) |
| 5284 | q.text(","); q.breakable() |
| 5285 | q.text("mask = "); |
| 5286 | q.text("%#x" % self.mask) |
| 5287 | q.text(","); q.breakable() |
| 5288 | q.text("advertise = "); |
| 5289 | q.text("%#x" % self.advertise) |
| 5290 | q.breakable() |
| 5291 | q.text('}') |
| 5292 | |
| 5293 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5294 | version = 3 |
| 5295 | type = 19 |
| 5296 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5297 | |
| 5298 | def __init__(self, xid=None, flags=None, entries=None): |
| 5299 | self.xid = xid |
| 5300 | if flags != None: |
| 5301 | self.flags = flags |
| 5302 | else: |
| 5303 | self.flags = 0 |
| 5304 | if entries != None: |
| 5305 | self.entries = entries |
| 5306 | else: |
| 5307 | self.entries = [] |
| 5308 | |
| 5309 | def pack(self): |
| 5310 | packed = [] |
| 5311 | packed.append(struct.pack("!B", self.version)) |
| 5312 | packed.append(struct.pack("!B", self.type)) |
| 5313 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5314 | packed.append(struct.pack("!L", self.xid)) |
| 5315 | packed.append(struct.pack("!H", self.stats_type)) |
| 5316 | packed.append(struct.pack("!H", self.flags)) |
| 5317 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5318 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5319 | length = sum([len(x) for x in packed]) |
| 5320 | packed[2] = struct.pack("!H", length) |
| 5321 | return ''.join(packed) |
| 5322 | |
| 5323 | @staticmethod |
| 5324 | def unpack(buf): |
| 5325 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5326 | obj = port_stats_reply() |
| 5327 | if type(buf) == loxi.generic_util.OFReader: |
| 5328 | reader = buf |
| 5329 | else: |
| 5330 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5331 | _version = reader.read("!B")[0] |
| 5332 | assert(_version == 3) |
| 5333 | _type = reader.read("!B")[0] |
| 5334 | assert(_type == 19) |
| 5335 | _length = reader.read("!H")[0] |
| 5336 | obj.xid = reader.read("!L")[0] |
| 5337 | _stats_type = reader.read("!H")[0] |
| 5338 | assert(_stats_type == 4) |
| 5339 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5340 | reader.skip(4) |
| 5341 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 5342 | return obj |
| 5343 | |
| 5344 | def __eq__(self, other): |
| 5345 | if type(self) != type(other): return False |
| 5346 | if self.version != other.version: return False |
| 5347 | if self.type != other.type: return False |
| 5348 | if self.xid != other.xid: return False |
| 5349 | if self.flags != other.flags: return False |
| 5350 | if self.entries != other.entries: return False |
| 5351 | return True |
| 5352 | |
| 5353 | def __ne__(self, other): |
| 5354 | return not self.__eq__(other) |
| 5355 | |
| 5356 | def __str__(self): |
| 5357 | return self.show() |
| 5358 | |
| 5359 | def show(self): |
| 5360 | import loxi.pp |
| 5361 | return loxi.pp.pp(self) |
| 5362 | |
| 5363 | def pretty_print(self, q): |
| 5364 | q.text("port_stats_reply {") |
| 5365 | with q.group(): |
| 5366 | with q.indent(2): |
| 5367 | q.breakable() |
| 5368 | q.text("xid = "); |
| 5369 | if self.xid != None: |
| 5370 | q.text("%#x" % self.xid) |
| 5371 | else: |
| 5372 | q.text('None') |
| 5373 | q.text(","); q.breakable() |
| 5374 | q.text("flags = "); |
| 5375 | q.text("%#x" % self.flags) |
| 5376 | q.text(","); q.breakable() |
| 5377 | q.text("entries = "); |
| 5378 | q.pp(self.entries) |
| 5379 | q.breakable() |
| 5380 | q.text('}') |
| 5381 | |
| 5382 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5383 | version = 3 |
| 5384 | type = 18 |
| 5385 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5386 | |
| 5387 | def __init__(self, xid=None, flags=None, port_no=None): |
| 5388 | self.xid = xid |
| 5389 | if flags != None: |
| 5390 | self.flags = flags |
| 5391 | else: |
| 5392 | self.flags = 0 |
| 5393 | if port_no != None: |
| 5394 | self.port_no = port_no |
| 5395 | else: |
| 5396 | self.port_no = 0 |
| 5397 | |
| 5398 | def pack(self): |
| 5399 | packed = [] |
| 5400 | packed.append(struct.pack("!B", self.version)) |
| 5401 | packed.append(struct.pack("!B", self.type)) |
| 5402 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5403 | packed.append(struct.pack("!L", self.xid)) |
| 5404 | packed.append(struct.pack("!H", self.stats_type)) |
| 5405 | packed.append(struct.pack("!H", self.flags)) |
| 5406 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5407 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5408 | packed.append('\x00' * 4) |
| 5409 | length = sum([len(x) for x in packed]) |
| 5410 | packed[2] = struct.pack("!H", length) |
| 5411 | return ''.join(packed) |
| 5412 | |
| 5413 | @staticmethod |
| 5414 | def unpack(buf): |
| 5415 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5416 | obj = port_stats_request() |
| 5417 | if type(buf) == loxi.generic_util.OFReader: |
| 5418 | reader = buf |
| 5419 | else: |
| 5420 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5421 | _version = reader.read("!B")[0] |
| 5422 | assert(_version == 3) |
| 5423 | _type = reader.read("!B")[0] |
| 5424 | assert(_type == 18) |
| 5425 | _length = reader.read("!H")[0] |
| 5426 | obj.xid = reader.read("!L")[0] |
| 5427 | _stats_type = reader.read("!H")[0] |
| 5428 | assert(_stats_type == 4) |
| 5429 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5430 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5431 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5432 | reader.skip(4) |
| 5433 | return obj |
| 5434 | |
| 5435 | def __eq__(self, other): |
| 5436 | if type(self) != type(other): return False |
| 5437 | if self.version != other.version: return False |
| 5438 | if self.type != other.type: return False |
| 5439 | if self.xid != other.xid: return False |
| 5440 | if self.flags != other.flags: return False |
| 5441 | if self.port_no != other.port_no: return False |
| 5442 | return True |
| 5443 | |
| 5444 | def __ne__(self, other): |
| 5445 | return not self.__eq__(other) |
| 5446 | |
| 5447 | def __str__(self): |
| 5448 | return self.show() |
| 5449 | |
| 5450 | def show(self): |
| 5451 | import loxi.pp |
| 5452 | return loxi.pp.pp(self) |
| 5453 | |
| 5454 | def pretty_print(self, q): |
| 5455 | q.text("port_stats_request {") |
| 5456 | with q.group(): |
| 5457 | with q.indent(2): |
| 5458 | q.breakable() |
| 5459 | q.text("xid = "); |
| 5460 | if self.xid != None: |
| 5461 | q.text("%#x" % self.xid) |
| 5462 | else: |
| 5463 | q.text('None') |
| 5464 | q.text(","); q.breakable() |
| 5465 | q.text("flags = "); |
| 5466 | q.text("%#x" % self.flags) |
| 5467 | q.text(","); q.breakable() |
| 5468 | q.text("port_no = "); |
| 5469 | q.text(util.pretty_port(self.port_no)) |
| 5470 | q.breakable() |
| 5471 | q.text('}') |
| 5472 | |
| 5473 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5474 | version = 3 |
| 5475 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5476 | |
| 5477 | def __init__(self, xid=None, reason=None, desc=None): |
| 5478 | self.xid = xid |
| 5479 | if reason != None: |
| 5480 | self.reason = reason |
| 5481 | else: |
| 5482 | self.reason = 0 |
| 5483 | if desc != None: |
| 5484 | self.desc = desc |
| 5485 | else: |
| 5486 | self.desc = common.port_desc() |
| 5487 | |
| 5488 | def pack(self): |
| 5489 | packed = [] |
| 5490 | packed.append(struct.pack("!B", self.version)) |
| 5491 | packed.append(struct.pack("!B", self.type)) |
| 5492 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5493 | packed.append(struct.pack("!L", self.xid)) |
| 5494 | packed.append(struct.pack("!B", self.reason)) |
| 5495 | packed.append('\x00' * 7) |
| 5496 | packed.append(self.desc.pack()) |
| 5497 | length = sum([len(x) for x in packed]) |
| 5498 | packed[2] = struct.pack("!H", length) |
| 5499 | return ''.join(packed) |
| 5500 | |
| 5501 | @staticmethod |
| 5502 | def unpack(buf): |
| 5503 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5504 | obj = port_status() |
| 5505 | if type(buf) == loxi.generic_util.OFReader: |
| 5506 | reader = buf |
| 5507 | else: |
| 5508 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5509 | _version = reader.read("!B")[0] |
| 5510 | assert(_version == 3) |
| 5511 | _type = reader.read("!B")[0] |
| 5512 | assert(_type == 12) |
| 5513 | _length = reader.read("!H")[0] |
| 5514 | obj.xid = reader.read("!L")[0] |
| 5515 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5516 | reader.skip(7) |
| 5517 | obj.desc = common.port_desc.unpack(reader) |
| 5518 | return obj |
| 5519 | |
| 5520 | def __eq__(self, other): |
| 5521 | if type(self) != type(other): return False |
| 5522 | if self.version != other.version: return False |
| 5523 | if self.type != other.type: return False |
| 5524 | if self.xid != other.xid: return False |
| 5525 | if self.reason != other.reason: return False |
| 5526 | if self.desc != other.desc: return False |
| 5527 | return True |
| 5528 | |
| 5529 | def __ne__(self, other): |
| 5530 | return not self.__eq__(other) |
| 5531 | |
| 5532 | def __str__(self): |
| 5533 | return self.show() |
| 5534 | |
| 5535 | def show(self): |
| 5536 | import loxi.pp |
| 5537 | return loxi.pp.pp(self) |
| 5538 | |
| 5539 | def pretty_print(self, q): |
| 5540 | q.text("port_status {") |
| 5541 | with q.group(): |
| 5542 | with q.indent(2): |
| 5543 | q.breakable() |
| 5544 | q.text("xid = "); |
| 5545 | if self.xid != None: |
| 5546 | q.text("%#x" % self.xid) |
| 5547 | else: |
| 5548 | q.text('None') |
| 5549 | q.text(","); q.breakable() |
| 5550 | q.text("reason = "); |
| 5551 | q.text("%#x" % self.reason) |
| 5552 | q.text(","); q.breakable() |
| 5553 | q.text("desc = "); |
| 5554 | q.pp(self.desc) |
| 5555 | q.breakable() |
| 5556 | q.text('}') |
| 5557 | |
| 5558 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5559 | version = 3 |
| 5560 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5561 | |
| 5562 | def __init__(self, xid=None, port=None, queues=None): |
| 5563 | self.xid = xid |
| 5564 | if port != None: |
| 5565 | self.port = port |
| 5566 | else: |
| 5567 | self.port = 0 |
| 5568 | if queues != None: |
| 5569 | self.queues = queues |
| 5570 | else: |
| 5571 | self.queues = [] |
| 5572 | |
| 5573 | def pack(self): |
| 5574 | packed = [] |
| 5575 | packed.append(struct.pack("!B", self.version)) |
| 5576 | packed.append(struct.pack("!B", self.type)) |
| 5577 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5578 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5579 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5580 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5581 | packed.append(util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5582 | length = sum([len(x) for x in packed]) |
| 5583 | packed[2] = struct.pack("!H", length) |
| 5584 | return ''.join(packed) |
| 5585 | |
| 5586 | @staticmethod |
| 5587 | def unpack(buf): |
| 5588 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5589 | obj = queue_get_config_reply() |
| 5590 | if type(buf) == loxi.generic_util.OFReader: |
| 5591 | reader = buf |
| 5592 | else: |
| 5593 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5594 | _version = reader.read("!B")[0] |
| 5595 | assert(_version == 3) |
| 5596 | _type = reader.read("!B")[0] |
| 5597 | assert(_type == 23) |
| 5598 | _length = reader.read("!H")[0] |
| 5599 | obj.xid = reader.read("!L")[0] |
| 5600 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5601 | reader.skip(4) |
| 5602 | obj.queues = common.unpack_list_packet_queue(reader) |
| 5603 | return obj |
| 5604 | |
| 5605 | def __eq__(self, other): |
| 5606 | if type(self) != type(other): return False |
| 5607 | if self.version != other.version: return False |
| 5608 | if self.type != other.type: return False |
| 5609 | if self.xid != other.xid: return False |
| 5610 | if self.port != other.port: return False |
| 5611 | if self.queues != other.queues: return False |
| 5612 | return True |
| 5613 | |
| 5614 | def __ne__(self, other): |
| 5615 | return not self.__eq__(other) |
| 5616 | |
| 5617 | def __str__(self): |
| 5618 | return self.show() |
| 5619 | |
| 5620 | def show(self): |
| 5621 | import loxi.pp |
| 5622 | return loxi.pp.pp(self) |
| 5623 | |
| 5624 | def pretty_print(self, q): |
| 5625 | q.text("queue_get_config_reply {") |
| 5626 | with q.group(): |
| 5627 | with q.indent(2): |
| 5628 | q.breakable() |
| 5629 | q.text("xid = "); |
| 5630 | if self.xid != None: |
| 5631 | q.text("%#x" % self.xid) |
| 5632 | else: |
| 5633 | q.text('None') |
| 5634 | q.text(","); q.breakable() |
| 5635 | q.text("port = "); |
| 5636 | q.text(util.pretty_port(self.port)) |
| 5637 | q.text(","); q.breakable() |
| 5638 | q.text("queues = "); |
| 5639 | q.pp(self.queues) |
| 5640 | q.breakable() |
| 5641 | q.text('}') |
| 5642 | |
| 5643 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5644 | version = 3 |
| 5645 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5646 | |
| 5647 | def __init__(self, xid=None, port=None): |
| 5648 | self.xid = xid |
| 5649 | if port != None: |
| 5650 | self.port = port |
| 5651 | else: |
| 5652 | self.port = 0 |
| 5653 | |
| 5654 | def pack(self): |
| 5655 | packed = [] |
| 5656 | packed.append(struct.pack("!B", self.version)) |
| 5657 | packed.append(struct.pack("!B", self.type)) |
| 5658 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5659 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5660 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5661 | packed.append('\x00' * 4) |
| 5662 | length = sum([len(x) for x in packed]) |
| 5663 | packed[2] = struct.pack("!H", length) |
| 5664 | return ''.join(packed) |
| 5665 | |
| 5666 | @staticmethod |
| 5667 | def unpack(buf): |
| 5668 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5669 | obj = queue_get_config_request() |
| 5670 | if type(buf) == loxi.generic_util.OFReader: |
| 5671 | reader = buf |
| 5672 | else: |
| 5673 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5674 | _version = reader.read("!B")[0] |
| 5675 | assert(_version == 3) |
| 5676 | _type = reader.read("!B")[0] |
| 5677 | assert(_type == 22) |
| 5678 | _length = reader.read("!H")[0] |
| 5679 | obj.xid = reader.read("!L")[0] |
| 5680 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5681 | reader.skip(4) |
| 5682 | return obj |
| 5683 | |
| 5684 | def __eq__(self, other): |
| 5685 | if type(self) != type(other): return False |
| 5686 | if self.version != other.version: return False |
| 5687 | if self.type != other.type: return False |
| 5688 | if self.xid != other.xid: return False |
| 5689 | if self.port != other.port: return False |
| 5690 | return True |
| 5691 | |
| 5692 | def __ne__(self, other): |
| 5693 | return not self.__eq__(other) |
| 5694 | |
| 5695 | def __str__(self): |
| 5696 | return self.show() |
| 5697 | |
| 5698 | def show(self): |
| 5699 | import loxi.pp |
| 5700 | return loxi.pp.pp(self) |
| 5701 | |
| 5702 | def pretty_print(self, q): |
| 5703 | q.text("queue_get_config_request {") |
| 5704 | with q.group(): |
| 5705 | with q.indent(2): |
| 5706 | q.breakable() |
| 5707 | q.text("xid = "); |
| 5708 | if self.xid != None: |
| 5709 | q.text("%#x" % self.xid) |
| 5710 | else: |
| 5711 | q.text('None') |
| 5712 | q.text(","); q.breakable() |
| 5713 | q.text("port = "); |
| 5714 | q.text(util.pretty_port(self.port)) |
| 5715 | q.breakable() |
| 5716 | q.text('}') |
| 5717 | |
| 5718 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5719 | version = 3 |
| 5720 | type = 19 |
| 5721 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5722 | |
| 5723 | def __init__(self, xid=None, flags=None, entries=None): |
| 5724 | self.xid = xid |
| 5725 | if flags != None: |
| 5726 | self.flags = flags |
| 5727 | else: |
| 5728 | self.flags = 0 |
| 5729 | if entries != None: |
| 5730 | self.entries = entries |
| 5731 | else: |
| 5732 | self.entries = [] |
| 5733 | |
| 5734 | def pack(self): |
| 5735 | packed = [] |
| 5736 | packed.append(struct.pack("!B", self.version)) |
| 5737 | packed.append(struct.pack("!B", self.type)) |
| 5738 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5739 | packed.append(struct.pack("!L", self.xid)) |
| 5740 | packed.append(struct.pack("!H", self.stats_type)) |
| 5741 | packed.append(struct.pack("!H", self.flags)) |
| 5742 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5743 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5744 | length = sum([len(x) for x in packed]) |
| 5745 | packed[2] = struct.pack("!H", length) |
| 5746 | return ''.join(packed) |
| 5747 | |
| 5748 | @staticmethod |
| 5749 | def unpack(buf): |
| 5750 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5751 | obj = queue_stats_reply() |
| 5752 | if type(buf) == loxi.generic_util.OFReader: |
| 5753 | reader = buf |
| 5754 | else: |
| 5755 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5756 | _version = reader.read("!B")[0] |
| 5757 | assert(_version == 3) |
| 5758 | _type = reader.read("!B")[0] |
| 5759 | assert(_type == 19) |
| 5760 | _length = reader.read("!H")[0] |
| 5761 | obj.xid = reader.read("!L")[0] |
| 5762 | _stats_type = reader.read("!H")[0] |
| 5763 | assert(_stats_type == 5) |
| 5764 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5765 | reader.skip(4) |
| 5766 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 5767 | return obj |
| 5768 | |
| 5769 | def __eq__(self, other): |
| 5770 | if type(self) != type(other): return False |
| 5771 | if self.version != other.version: return False |
| 5772 | if self.type != other.type: return False |
| 5773 | if self.xid != other.xid: return False |
| 5774 | if self.flags != other.flags: return False |
| 5775 | if self.entries != other.entries: return False |
| 5776 | return True |
| 5777 | |
| 5778 | def __ne__(self, other): |
| 5779 | return not self.__eq__(other) |
| 5780 | |
| 5781 | def __str__(self): |
| 5782 | return self.show() |
| 5783 | |
| 5784 | def show(self): |
| 5785 | import loxi.pp |
| 5786 | return loxi.pp.pp(self) |
| 5787 | |
| 5788 | def pretty_print(self, q): |
| 5789 | q.text("queue_stats_reply {") |
| 5790 | with q.group(): |
| 5791 | with q.indent(2): |
| 5792 | q.breakable() |
| 5793 | q.text("xid = "); |
| 5794 | if self.xid != None: |
| 5795 | q.text("%#x" % self.xid) |
| 5796 | else: |
| 5797 | q.text('None') |
| 5798 | q.text(","); q.breakable() |
| 5799 | q.text("flags = "); |
| 5800 | q.text("%#x" % self.flags) |
| 5801 | q.text(","); q.breakable() |
| 5802 | q.text("entries = "); |
| 5803 | q.pp(self.entries) |
| 5804 | q.breakable() |
| 5805 | q.text('}') |
| 5806 | |
| 5807 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5808 | version = 3 |
| 5809 | type = 18 |
| 5810 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5811 | |
| 5812 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
| 5813 | self.xid = xid |
| 5814 | if flags != None: |
| 5815 | self.flags = flags |
| 5816 | else: |
| 5817 | self.flags = 0 |
| 5818 | if port_no != None: |
| 5819 | self.port_no = port_no |
| 5820 | else: |
| 5821 | self.port_no = 0 |
| 5822 | if queue_id != None: |
| 5823 | self.queue_id = queue_id |
| 5824 | else: |
| 5825 | self.queue_id = 0 |
| 5826 | |
| 5827 | def pack(self): |
| 5828 | packed = [] |
| 5829 | packed.append(struct.pack("!B", self.version)) |
| 5830 | packed.append(struct.pack("!B", self.type)) |
| 5831 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5832 | packed.append(struct.pack("!L", self.xid)) |
| 5833 | packed.append(struct.pack("!H", self.stats_type)) |
| 5834 | packed.append(struct.pack("!H", self.flags)) |
| 5835 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5836 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5837 | packed.append(struct.pack("!L", self.queue_id)) |
| 5838 | length = sum([len(x) for x in packed]) |
| 5839 | packed[2] = struct.pack("!H", length) |
| 5840 | return ''.join(packed) |
| 5841 | |
| 5842 | @staticmethod |
| 5843 | def unpack(buf): |
| 5844 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5845 | obj = queue_stats_request() |
| 5846 | if type(buf) == loxi.generic_util.OFReader: |
| 5847 | reader = buf |
| 5848 | else: |
| 5849 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5850 | _version = reader.read("!B")[0] |
| 5851 | assert(_version == 3) |
| 5852 | _type = reader.read("!B")[0] |
| 5853 | assert(_type == 18) |
| 5854 | _length = reader.read("!H")[0] |
| 5855 | obj.xid = reader.read("!L")[0] |
| 5856 | _stats_type = reader.read("!H")[0] |
| 5857 | assert(_stats_type == 5) |
| 5858 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5859 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5860 | obj.port_no = util.unpack_port_no(reader) |
| 5861 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5862 | return obj |
| 5863 | |
| 5864 | def __eq__(self, other): |
| 5865 | if type(self) != type(other): return False |
| 5866 | if self.version != other.version: return False |
| 5867 | if self.type != other.type: return False |
| 5868 | if self.xid != other.xid: return False |
| 5869 | if self.flags != other.flags: return False |
| 5870 | if self.port_no != other.port_no: return False |
| 5871 | if self.queue_id != other.queue_id: return False |
| 5872 | return True |
| 5873 | |
| 5874 | def __ne__(self, other): |
| 5875 | return not self.__eq__(other) |
| 5876 | |
| 5877 | def __str__(self): |
| 5878 | return self.show() |
| 5879 | |
| 5880 | def show(self): |
| 5881 | import loxi.pp |
| 5882 | return loxi.pp.pp(self) |
| 5883 | |
| 5884 | def pretty_print(self, q): |
| 5885 | q.text("queue_stats_request {") |
| 5886 | with q.group(): |
| 5887 | with q.indent(2): |
| 5888 | q.breakable() |
| 5889 | q.text("xid = "); |
| 5890 | if self.xid != None: |
| 5891 | q.text("%#x" % self.xid) |
| 5892 | else: |
| 5893 | q.text('None') |
| 5894 | q.text(","); q.breakable() |
| 5895 | q.text("flags = "); |
| 5896 | q.text("%#x" % self.flags) |
| 5897 | q.text(","); q.breakable() |
| 5898 | q.text("port_no = "); |
| 5899 | q.text(util.pretty_port(self.port_no)) |
| 5900 | q.text(","); q.breakable() |
| 5901 | q.text("queue_id = "); |
| 5902 | q.text("%#x" % self.queue_id) |
| 5903 | q.breakable() |
| 5904 | q.text('}') |
| 5905 | |
| 5906 | class role_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5907 | version = 3 |
| 5908 | type = 25 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5909 | |
| 5910 | def __init__(self, xid=None, data=None): |
| 5911 | self.xid = xid |
| 5912 | if data != None: |
| 5913 | self.data = data |
| 5914 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5915 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5916 | |
| 5917 | def pack(self): |
| 5918 | packed = [] |
| 5919 | packed.append(struct.pack("!B", self.version)) |
| 5920 | packed.append(struct.pack("!B", self.type)) |
| 5921 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5922 | packed.append(struct.pack("!L", self.xid)) |
| 5923 | packed.append(self.data) |
| 5924 | length = sum([len(x) for x in packed]) |
| 5925 | packed[2] = struct.pack("!H", length) |
| 5926 | return ''.join(packed) |
| 5927 | |
| 5928 | @staticmethod |
| 5929 | def unpack(buf): |
| 5930 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5931 | obj = role_reply() |
| 5932 | if type(buf) == loxi.generic_util.OFReader: |
| 5933 | reader = buf |
| 5934 | else: |
| 5935 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5936 | _version = reader.read("!B")[0] |
| 5937 | assert(_version == 3) |
| 5938 | _type = reader.read("!B")[0] |
| 5939 | assert(_type == 25) |
| 5940 | _length = reader.read("!H")[0] |
| 5941 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5942 | obj.data = str(reader.read_all()) |
| 5943 | return obj |
| 5944 | |
| 5945 | def __eq__(self, other): |
| 5946 | if type(self) != type(other): return False |
| 5947 | if self.version != other.version: return False |
| 5948 | if self.type != other.type: return False |
| 5949 | if self.xid != other.xid: return False |
| 5950 | if self.data != other.data: return False |
| 5951 | return True |
| 5952 | |
| 5953 | def __ne__(self, other): |
| 5954 | return not self.__eq__(other) |
| 5955 | |
| 5956 | def __str__(self): |
| 5957 | return self.show() |
| 5958 | |
| 5959 | def show(self): |
| 5960 | import loxi.pp |
| 5961 | return loxi.pp.pp(self) |
| 5962 | |
| 5963 | def pretty_print(self, q): |
| 5964 | q.text("role_reply {") |
| 5965 | with q.group(): |
| 5966 | with q.indent(2): |
| 5967 | q.breakable() |
| 5968 | q.text("xid = "); |
| 5969 | if self.xid != None: |
| 5970 | q.text("%#x" % self.xid) |
| 5971 | else: |
| 5972 | q.text('None') |
| 5973 | q.text(","); q.breakable() |
| 5974 | q.text("data = "); |
| 5975 | q.pp(self.data) |
| 5976 | q.breakable() |
| 5977 | q.text('}') |
| 5978 | |
| 5979 | class role_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5980 | version = 3 |
| 5981 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5982 | |
| 5983 | def __init__(self, xid=None, role=None, generation_id=None): |
| 5984 | self.xid = xid |
| 5985 | if role != None: |
| 5986 | self.role = role |
| 5987 | else: |
| 5988 | self.role = 0 |
| 5989 | if generation_id != None: |
| 5990 | self.generation_id = generation_id |
| 5991 | else: |
| 5992 | self.generation_id = 0 |
| 5993 | |
| 5994 | def pack(self): |
| 5995 | packed = [] |
| 5996 | packed.append(struct.pack("!B", self.version)) |
| 5997 | packed.append(struct.pack("!B", self.type)) |
| 5998 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5999 | packed.append(struct.pack("!L", self.xid)) |
| 6000 | packed.append(struct.pack("!L", self.role)) |
| 6001 | packed.append('\x00' * 4) |
| 6002 | packed.append(struct.pack("!Q", self.generation_id)) |
| 6003 | length = sum([len(x) for x in packed]) |
| 6004 | packed[2] = struct.pack("!H", length) |
| 6005 | return ''.join(packed) |
| 6006 | |
| 6007 | @staticmethod |
| 6008 | def unpack(buf): |
| 6009 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6010 | obj = role_request() |
| 6011 | if type(buf) == loxi.generic_util.OFReader: |
| 6012 | reader = buf |
| 6013 | else: |
| 6014 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6015 | _version = reader.read("!B")[0] |
| 6016 | assert(_version == 3) |
| 6017 | _type = reader.read("!B")[0] |
| 6018 | assert(_type == 24) |
| 6019 | _length = reader.read("!H")[0] |
| 6020 | obj.xid = reader.read("!L")[0] |
| 6021 | obj.role = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6022 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6023 | obj.generation_id = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6024 | return obj |
| 6025 | |
| 6026 | def __eq__(self, other): |
| 6027 | if type(self) != type(other): return False |
| 6028 | if self.version != other.version: return False |
| 6029 | if self.type != other.type: return False |
| 6030 | if self.xid != other.xid: return False |
| 6031 | if self.role != other.role: return False |
| 6032 | if self.generation_id != other.generation_id: return False |
| 6033 | return True |
| 6034 | |
| 6035 | def __ne__(self, other): |
| 6036 | return not self.__eq__(other) |
| 6037 | |
| 6038 | def __str__(self): |
| 6039 | return self.show() |
| 6040 | |
| 6041 | def show(self): |
| 6042 | import loxi.pp |
| 6043 | return loxi.pp.pp(self) |
| 6044 | |
| 6045 | def pretty_print(self, q): |
| 6046 | q.text("role_request {") |
| 6047 | with q.group(): |
| 6048 | with q.indent(2): |
| 6049 | q.breakable() |
| 6050 | q.text("xid = "); |
| 6051 | if self.xid != None: |
| 6052 | q.text("%#x" % self.xid) |
| 6053 | else: |
| 6054 | q.text('None') |
| 6055 | q.text(","); q.breakable() |
| 6056 | q.text("role = "); |
| 6057 | q.text("%#x" % self.role) |
| 6058 | q.text(","); q.breakable() |
| 6059 | q.text("generation_id = "); |
| 6060 | q.text("%#x" % self.generation_id) |
| 6061 | q.breakable() |
| 6062 | q.text('}') |
| 6063 | |
| 6064 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6065 | version = 3 |
| 6066 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6067 | |
| 6068 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 6069 | self.xid = xid |
| 6070 | if flags != None: |
| 6071 | self.flags = flags |
| 6072 | else: |
| 6073 | self.flags = 0 |
| 6074 | if miss_send_len != None: |
| 6075 | self.miss_send_len = miss_send_len |
| 6076 | else: |
| 6077 | self.miss_send_len = 0 |
| 6078 | |
| 6079 | def pack(self): |
| 6080 | packed = [] |
| 6081 | packed.append(struct.pack("!B", self.version)) |
| 6082 | packed.append(struct.pack("!B", self.type)) |
| 6083 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6084 | packed.append(struct.pack("!L", self.xid)) |
| 6085 | packed.append(struct.pack("!H", self.flags)) |
| 6086 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 6087 | length = sum([len(x) for x in packed]) |
| 6088 | packed[2] = struct.pack("!H", length) |
| 6089 | return ''.join(packed) |
| 6090 | |
| 6091 | @staticmethod |
| 6092 | def unpack(buf): |
| 6093 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6094 | obj = set_config() |
| 6095 | if type(buf) == loxi.generic_util.OFReader: |
| 6096 | reader = buf |
| 6097 | else: |
| 6098 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6099 | _version = reader.read("!B")[0] |
| 6100 | assert(_version == 3) |
| 6101 | _type = reader.read("!B")[0] |
| 6102 | assert(_type == 9) |
| 6103 | _length = reader.read("!H")[0] |
| 6104 | obj.xid = reader.read("!L")[0] |
| 6105 | obj.flags = reader.read("!H")[0] |
| 6106 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6107 | return obj |
| 6108 | |
| 6109 | def __eq__(self, other): |
| 6110 | if type(self) != type(other): return False |
| 6111 | if self.version != other.version: return False |
| 6112 | if self.type != other.type: return False |
| 6113 | if self.xid != other.xid: return False |
| 6114 | if self.flags != other.flags: return False |
| 6115 | if self.miss_send_len != other.miss_send_len: return False |
| 6116 | return True |
| 6117 | |
| 6118 | def __ne__(self, other): |
| 6119 | return not self.__eq__(other) |
| 6120 | |
| 6121 | def __str__(self): |
| 6122 | return self.show() |
| 6123 | |
| 6124 | def show(self): |
| 6125 | import loxi.pp |
| 6126 | return loxi.pp.pp(self) |
| 6127 | |
| 6128 | def pretty_print(self, q): |
| 6129 | q.text("set_config {") |
| 6130 | with q.group(): |
| 6131 | with q.indent(2): |
| 6132 | q.breakable() |
| 6133 | q.text("xid = "); |
| 6134 | if self.xid != None: |
| 6135 | q.text("%#x" % self.xid) |
| 6136 | else: |
| 6137 | q.text('None') |
| 6138 | q.text(","); q.breakable() |
| 6139 | q.text("flags = "); |
| 6140 | q.text("%#x" % self.flags) |
| 6141 | q.text(","); q.breakable() |
| 6142 | q.text("miss_send_len = "); |
| 6143 | q.text("%#x" % self.miss_send_len) |
| 6144 | q.breakable() |
| 6145 | q.text('}') |
| 6146 | |
| 6147 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6148 | version = 3 |
| 6149 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6150 | |
| 6151 | def __init__(self, xid=None, table_id=None, config=None): |
| 6152 | self.xid = xid |
| 6153 | if table_id != None: |
| 6154 | self.table_id = table_id |
| 6155 | else: |
| 6156 | self.table_id = 0 |
| 6157 | if config != None: |
| 6158 | self.config = config |
| 6159 | else: |
| 6160 | self.config = 0 |
| 6161 | |
| 6162 | def pack(self): |
| 6163 | packed = [] |
| 6164 | packed.append(struct.pack("!B", self.version)) |
| 6165 | packed.append(struct.pack("!B", self.type)) |
| 6166 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6167 | packed.append(struct.pack("!L", self.xid)) |
| 6168 | packed.append(struct.pack("!B", self.table_id)) |
| 6169 | packed.append('\x00' * 3) |
| 6170 | packed.append(struct.pack("!L", self.config)) |
| 6171 | length = sum([len(x) for x in packed]) |
| 6172 | packed[2] = struct.pack("!H", length) |
| 6173 | return ''.join(packed) |
| 6174 | |
| 6175 | @staticmethod |
| 6176 | def unpack(buf): |
| 6177 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6178 | obj = table_mod() |
| 6179 | if type(buf) == loxi.generic_util.OFReader: |
| 6180 | reader = buf |
| 6181 | else: |
| 6182 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6183 | _version = reader.read("!B")[0] |
| 6184 | assert(_version == 3) |
| 6185 | _type = reader.read("!B")[0] |
| 6186 | assert(_type == 17) |
| 6187 | _length = reader.read("!H")[0] |
| 6188 | obj.xid = reader.read("!L")[0] |
| 6189 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6190 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6191 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6192 | return obj |
| 6193 | |
| 6194 | def __eq__(self, other): |
| 6195 | if type(self) != type(other): return False |
| 6196 | if self.version != other.version: return False |
| 6197 | if self.type != other.type: return False |
| 6198 | if self.xid != other.xid: return False |
| 6199 | if self.table_id != other.table_id: return False |
| 6200 | if self.config != other.config: return False |
| 6201 | return True |
| 6202 | |
| 6203 | def __ne__(self, other): |
| 6204 | return not self.__eq__(other) |
| 6205 | |
| 6206 | def __str__(self): |
| 6207 | return self.show() |
| 6208 | |
| 6209 | def show(self): |
| 6210 | import loxi.pp |
| 6211 | return loxi.pp.pp(self) |
| 6212 | |
| 6213 | def pretty_print(self, q): |
| 6214 | q.text("table_mod {") |
| 6215 | with q.group(): |
| 6216 | with q.indent(2): |
| 6217 | q.breakable() |
| 6218 | q.text("xid = "); |
| 6219 | if self.xid != None: |
| 6220 | q.text("%#x" % self.xid) |
| 6221 | else: |
| 6222 | q.text('None') |
| 6223 | q.text(","); q.breakable() |
| 6224 | q.text("table_id = "); |
| 6225 | q.text("%#x" % self.table_id) |
| 6226 | q.text(","); q.breakable() |
| 6227 | q.text("config = "); |
| 6228 | q.text("%#x" % self.config) |
| 6229 | q.breakable() |
| 6230 | q.text('}') |
| 6231 | |
| 6232 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6233 | version = 3 |
| 6234 | type = 19 |
| 6235 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6236 | |
| 6237 | def __init__(self, xid=None, flags=None, entries=None): |
| 6238 | self.xid = xid |
| 6239 | if flags != None: |
| 6240 | self.flags = flags |
| 6241 | else: |
| 6242 | self.flags = 0 |
| 6243 | if entries != None: |
| 6244 | self.entries = entries |
| 6245 | else: |
| 6246 | self.entries = [] |
| 6247 | |
| 6248 | def pack(self): |
| 6249 | packed = [] |
| 6250 | packed.append(struct.pack("!B", self.version)) |
| 6251 | packed.append(struct.pack("!B", self.type)) |
| 6252 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6253 | packed.append(struct.pack("!L", self.xid)) |
| 6254 | packed.append(struct.pack("!H", self.stats_type)) |
| 6255 | packed.append(struct.pack("!H", self.flags)) |
| 6256 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6257 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6258 | length = sum([len(x) for x in packed]) |
| 6259 | packed[2] = struct.pack("!H", length) |
| 6260 | return ''.join(packed) |
| 6261 | |
| 6262 | @staticmethod |
| 6263 | def unpack(buf): |
| 6264 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6265 | obj = table_stats_reply() |
| 6266 | if type(buf) == loxi.generic_util.OFReader: |
| 6267 | reader = buf |
| 6268 | else: |
| 6269 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6270 | _version = reader.read("!B")[0] |
| 6271 | assert(_version == 3) |
| 6272 | _type = reader.read("!B")[0] |
| 6273 | assert(_type == 19) |
| 6274 | _length = reader.read("!H")[0] |
| 6275 | obj.xid = reader.read("!L")[0] |
| 6276 | _stats_type = reader.read("!H")[0] |
| 6277 | assert(_stats_type == 3) |
| 6278 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6279 | reader.skip(4) |
| 6280 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 6281 | return obj |
| 6282 | |
| 6283 | def __eq__(self, other): |
| 6284 | if type(self) != type(other): return False |
| 6285 | if self.version != other.version: return False |
| 6286 | if self.type != other.type: return False |
| 6287 | if self.xid != other.xid: return False |
| 6288 | if self.flags != other.flags: return False |
| 6289 | if self.entries != other.entries: return False |
| 6290 | return True |
| 6291 | |
| 6292 | def __ne__(self, other): |
| 6293 | return not self.__eq__(other) |
| 6294 | |
| 6295 | def __str__(self): |
| 6296 | return self.show() |
| 6297 | |
| 6298 | def show(self): |
| 6299 | import loxi.pp |
| 6300 | return loxi.pp.pp(self) |
| 6301 | |
| 6302 | def pretty_print(self, q): |
| 6303 | q.text("table_stats_reply {") |
| 6304 | with q.group(): |
| 6305 | with q.indent(2): |
| 6306 | q.breakable() |
| 6307 | q.text("xid = "); |
| 6308 | if self.xid != None: |
| 6309 | q.text("%#x" % self.xid) |
| 6310 | else: |
| 6311 | q.text('None') |
| 6312 | q.text(","); q.breakable() |
| 6313 | q.text("flags = "); |
| 6314 | q.text("%#x" % self.flags) |
| 6315 | q.text(","); q.breakable() |
| 6316 | q.text("entries = "); |
| 6317 | q.pp(self.entries) |
| 6318 | q.breakable() |
| 6319 | q.text('}') |
| 6320 | |
| 6321 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6322 | version = 3 |
| 6323 | type = 18 |
| 6324 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6325 | |
| 6326 | def __init__(self, xid=None, flags=None): |
| 6327 | self.xid = xid |
| 6328 | if flags != None: |
| 6329 | self.flags = flags |
| 6330 | else: |
| 6331 | self.flags = 0 |
| 6332 | |
| 6333 | def pack(self): |
| 6334 | packed = [] |
| 6335 | packed.append(struct.pack("!B", self.version)) |
| 6336 | packed.append(struct.pack("!B", self.type)) |
| 6337 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6338 | packed.append(struct.pack("!L", self.xid)) |
| 6339 | packed.append(struct.pack("!H", self.stats_type)) |
| 6340 | packed.append(struct.pack("!H", self.flags)) |
| 6341 | packed.append('\x00' * 4) |
| 6342 | length = sum([len(x) for x in packed]) |
| 6343 | packed[2] = struct.pack("!H", length) |
| 6344 | return ''.join(packed) |
| 6345 | |
| 6346 | @staticmethod |
| 6347 | def unpack(buf): |
| 6348 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6349 | obj = table_stats_request() |
| 6350 | if type(buf) == loxi.generic_util.OFReader: |
| 6351 | reader = buf |
| 6352 | else: |
| 6353 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6354 | _version = reader.read("!B")[0] |
| 6355 | assert(_version == 3) |
| 6356 | _type = reader.read("!B")[0] |
| 6357 | assert(_type == 18) |
| 6358 | _length = reader.read("!H")[0] |
| 6359 | obj.xid = reader.read("!L")[0] |
| 6360 | _stats_type = reader.read("!H")[0] |
| 6361 | assert(_stats_type == 3) |
| 6362 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6363 | reader.skip(4) |
| 6364 | return obj |
| 6365 | |
| 6366 | def __eq__(self, other): |
| 6367 | if type(self) != type(other): return False |
| 6368 | if self.version != other.version: return False |
| 6369 | if self.type != other.type: return False |
| 6370 | if self.xid != other.xid: return False |
| 6371 | if self.flags != other.flags: return False |
| 6372 | return True |
| 6373 | |
| 6374 | def __ne__(self, other): |
| 6375 | return not self.__eq__(other) |
| 6376 | |
| 6377 | def __str__(self): |
| 6378 | return self.show() |
| 6379 | |
| 6380 | def show(self): |
| 6381 | import loxi.pp |
| 6382 | return loxi.pp.pp(self) |
| 6383 | |
| 6384 | def pretty_print(self, q): |
| 6385 | q.text("table_stats_request {") |
| 6386 | with q.group(): |
| 6387 | with q.indent(2): |
| 6388 | q.breakable() |
| 6389 | q.text("xid = "); |
| 6390 | if self.xid != None: |
| 6391 | q.text("%#x" % self.xid) |
| 6392 | else: |
| 6393 | q.text('None') |
| 6394 | q.text(","); q.breakable() |
| 6395 | q.text("flags = "); |
| 6396 | q.text("%#x" % self.flags) |
| 6397 | q.breakable() |
| 6398 | q.text('}') |
| 6399 | |
| 6400 | |
| 6401 | def parse_header(buf): |
| 6402 | if len(buf) < 8: |
| 6403 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 6404 | return struct.unpack_from("!BBHL", buf) |
| 6405 | |
| 6406 | def parse_message(buf): |
| 6407 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 6408 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 6409 | 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] | 6410 | if len(buf) != msg_len: |
| 6411 | raise loxi.ProtocolError("incorrect message size") |
| 6412 | if msg_type in parsers: |
| 6413 | return parsers[msg_type](buf) |
| 6414 | else: |
| 6415 | raise loxi.ProtocolError("unexpected message type") |
| 6416 | |
| 6417 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 6418 | if len(buf) < 25 + 1: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6419 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 6420 | # Technically uint16_t for OF 1.0 |
| 6421 | cmd, = struct.unpack_from("!B", buf, 25) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6422 | if cmd in flow_mod_parsers: |
| 6423 | return flow_mod_parsers[cmd](buf) |
| 6424 | else: |
| 6425 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 6426 | |
| 6427 | def parse_stats_reply(buf): |
| 6428 | if len(buf) < 8 + 2: |
| 6429 | raise loxi.ProtocolError("message too short") |
| 6430 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 6431 | if stats_type in stats_reply_parsers: |
| 6432 | return stats_reply_parsers[stats_type](buf) |
| 6433 | else: |
| 6434 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 6435 | |
| 6436 | def parse_stats_request(buf): |
| 6437 | if len(buf) < 8 + 2: |
| 6438 | raise loxi.ProtocolError("message too short") |
| 6439 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 6440 | if stats_type in stats_request_parsers: |
| 6441 | return stats_request_parsers[stats_type](buf) |
| 6442 | else: |
| 6443 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 6444 | |
| 6445 | def parse_experimenter(buf): |
| 6446 | if len(buf) < 16: |
| 6447 | raise loxi.ProtocolError("experimenter message too short") |
| 6448 | |
| 6449 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 6450 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 6451 | subtype, = struct.unpack_from("!L", buf, 12) |
| 6452 | elif experimenter == 0x00002320: # Nicira |
| 6453 | subtype, = struct.unpack_from("!L", buf, 12) |
| 6454 | else: |
| 6455 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 6456 | |
| 6457 | if subtype in experimenter_parsers[experimenter]: |
| 6458 | return experimenter_parsers[experimenter][subtype](buf) |
| 6459 | else: |
| 6460 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 6461 | |
| 6462 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6463 | const.OFPT_HELLO : hello.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6464 | const.OFPT_ERROR : error_msg.unpack, |
| 6465 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 6466 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
| 6467 | const.OFPT_EXPERIMENTER : parse_experimenter, |
| 6468 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 6469 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 6470 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 6471 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6472 | const.OFPT_SET_CONFIG : set_config.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6473 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 6474 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 6475 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 6476 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 6477 | const.OFPT_FLOW_MOD : parse_flow_mod, |
| 6478 | const.OFPT_GROUP_MOD : group_mod.unpack, |
| 6479 | const.OFPT_PORT_MOD : port_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6480 | const.OFPT_TABLE_MOD : table_mod.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6481 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 6482 | const.OFPT_STATS_REPLY : parse_stats_reply, |
| 6483 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 6484 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 6485 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 6486 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
| 6487 | const.OFPT_ROLE_REQUEST : role_request.unpack, |
| 6488 | const.OFPT_ROLE_REPLY : role_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6489 | } |
| 6490 | |
| 6491 | flow_mod_parsers = { |
| 6492 | const.OFPFC_ADD : flow_add.unpack, |
| 6493 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 6494 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 6495 | const.OFPFC_DELETE : flow_delete.unpack, |
| 6496 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 6497 | } |
| 6498 | |
| 6499 | stats_reply_parsers = { |
| 6500 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 6501 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 6502 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 6503 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 6504 | const.OFPST_PORT : port_stats_reply.unpack, |
| 6505 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
| 6506 | const.OFPST_EXPERIMENTER : experimenter_stats_reply.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 6507 | const.OFPST_GROUP : group_stats_reply.unpack, |
| 6508 | const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack, |
| 6509 | const.OFPST_GROUP_FEATURES : group_features_stats_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6510 | } |
| 6511 | |
| 6512 | stats_request_parsers = { |
| 6513 | const.OFPST_DESC : desc_stats_request.unpack, |
| 6514 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 6515 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 6516 | const.OFPST_TABLE : table_stats_request.unpack, |
| 6517 | const.OFPST_PORT : port_stats_request.unpack, |
| 6518 | const.OFPST_QUEUE : queue_stats_request.unpack, |
| 6519 | const.OFPST_EXPERIMENTER : experimenter_stats_request.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 6520 | const.OFPST_GROUP : group_stats_request.unpack, |
| 6521 | const.OFPST_GROUP_DESC : group_desc_stats_request.unpack, |
| 6522 | const.OFPST_GROUP_FEATURES : group_features_stats_request.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6523 | } |
| 6524 | |
| 6525 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6526 | 6035143 : { |
| 6527 | 22: bsn_bw_clear_data_reply.unpack, |
| 6528 | 21: bsn_bw_clear_data_request.unpack, |
| 6529 | 20: bsn_bw_enable_get_reply.unpack, |
| 6530 | 19: bsn_bw_enable_get_request.unpack, |
| 6531 | 23: bsn_bw_enable_set_reply.unpack, |
| 6532 | 18: bsn_bw_enable_set_request.unpack, |
| 6533 | 10: bsn_get_interfaces_reply.unpack, |
| 6534 | 9: bsn_get_interfaces_request.unpack, |
| 6535 | 5: bsn_get_mirroring_reply.unpack, |
| 6536 | 4: bsn_get_mirroring_request.unpack, |
| 6537 | 3: bsn_set_mirroring.unpack, |
| 6538 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 6539 | 11: bsn_set_pktin_suppression_request.unpack, |
| 6540 | 16: bsn_virtual_port_create_reply.unpack, |
| 6541 | 15: bsn_virtual_port_create_request.unpack, |
| 6542 | 26: bsn_virtual_port_remove_reply.unpack, |
| 6543 | 17: bsn_virtual_port_remove_request.unpack, |
| 6544 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6545 | } |