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