Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5 | |
| 6 | # Automatically generated by LOXI from template message.py |
| 7 | # Do not modify |
| 8 | |
| 9 | import struct |
| 10 | import loxi |
| 11 | import const |
| 12 | import common |
| 13 | import action # for unpack_list |
| 14 | import instruction # for unpack_list |
| 15 | import util |
| 16 | import loxi.generic_util |
| 17 | |
| 18 | class Message(object): |
| 19 | version = const.OFP_VERSION |
| 20 | type = None # override in subclass |
| 21 | xid = None |
| 22 | |
| 23 | class aggregate_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 24 | version = 2 |
| 25 | type = 19 |
| 26 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 27 | |
| 28 | def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None): |
| 29 | self.xid = xid |
| 30 | if flags != None: |
| 31 | self.flags = flags |
| 32 | else: |
| 33 | self.flags = 0 |
| 34 | if packet_count != None: |
| 35 | self.packet_count = packet_count |
| 36 | else: |
| 37 | self.packet_count = 0 |
| 38 | if byte_count != None: |
| 39 | self.byte_count = byte_count |
| 40 | else: |
| 41 | self.byte_count = 0 |
| 42 | if flow_count != None: |
| 43 | self.flow_count = flow_count |
| 44 | else: |
| 45 | self.flow_count = 0 |
| 46 | |
| 47 | def pack(self): |
| 48 | packed = [] |
| 49 | packed.append(struct.pack("!B", self.version)) |
| 50 | packed.append(struct.pack("!B", self.type)) |
| 51 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 52 | packed.append(struct.pack("!L", self.xid)) |
| 53 | packed.append(struct.pack("!H", self.stats_type)) |
| 54 | packed.append(struct.pack("!H", self.flags)) |
| 55 | packed.append('\x00' * 4) |
| 56 | packed.append(struct.pack("!Q", self.packet_count)) |
| 57 | packed.append(struct.pack("!Q", self.byte_count)) |
| 58 | packed.append(struct.pack("!L", self.flow_count)) |
| 59 | packed.append('\x00' * 4) |
| 60 | length = sum([len(x) for x in packed]) |
| 61 | packed[2] = struct.pack("!H", length) |
| 62 | return ''.join(packed) |
| 63 | |
| 64 | @staticmethod |
| 65 | def unpack(buf): |
| 66 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 67 | obj = aggregate_stats_reply() |
| 68 | if type(buf) == loxi.generic_util.OFReader: |
| 69 | reader = buf |
| 70 | else: |
| 71 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 72 | _version = reader.read("!B")[0] |
| 73 | assert(_version == 2) |
| 74 | _type = reader.read("!B")[0] |
| 75 | assert(_type == 19) |
| 76 | _length = reader.read("!H")[0] |
| 77 | obj.xid = reader.read("!L")[0] |
| 78 | _stats_type = reader.read("!H")[0] |
| 79 | assert(_stats_type == 2) |
| 80 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 81 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 82 | obj.packet_count = reader.read("!Q")[0] |
| 83 | obj.byte_count = reader.read("!Q")[0] |
| 84 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 85 | reader.skip(4) |
| 86 | return obj |
| 87 | |
| 88 | def __eq__(self, other): |
| 89 | if type(self) != type(other): return False |
| 90 | if self.version != other.version: return False |
| 91 | if self.type != other.type: return False |
| 92 | if self.xid != other.xid: return False |
| 93 | if self.flags != other.flags: return False |
| 94 | if self.packet_count != other.packet_count: return False |
| 95 | if self.byte_count != other.byte_count: return False |
| 96 | if self.flow_count != other.flow_count: return False |
| 97 | return True |
| 98 | |
| 99 | def __ne__(self, other): |
| 100 | return not self.__eq__(other) |
| 101 | |
| 102 | def __str__(self): |
| 103 | return self.show() |
| 104 | |
| 105 | def show(self): |
| 106 | import loxi.pp |
| 107 | return loxi.pp.pp(self) |
| 108 | |
| 109 | def pretty_print(self, q): |
| 110 | q.text("aggregate_stats_reply {") |
| 111 | with q.group(): |
| 112 | with q.indent(2): |
| 113 | q.breakable() |
| 114 | q.text("xid = "); |
| 115 | if self.xid != None: |
| 116 | q.text("%#x" % self.xid) |
| 117 | else: |
| 118 | q.text('None') |
| 119 | q.text(","); q.breakable() |
| 120 | q.text("flags = "); |
| 121 | q.text("%#x" % self.flags) |
| 122 | q.text(","); q.breakable() |
| 123 | q.text("packet_count = "); |
| 124 | q.text("%#x" % self.packet_count) |
| 125 | q.text(","); q.breakable() |
| 126 | q.text("byte_count = "); |
| 127 | q.text("%#x" % self.byte_count) |
| 128 | q.text(","); q.breakable() |
| 129 | q.text("flow_count = "); |
| 130 | q.text("%#x" % self.flow_count) |
| 131 | q.breakable() |
| 132 | q.text('}') |
| 133 | |
| 134 | class aggregate_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 135 | version = 2 |
| 136 | type = 18 |
| 137 | stats_type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 138 | |
| 139 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 140 | self.xid = xid |
| 141 | if flags != None: |
| 142 | self.flags = flags |
| 143 | else: |
| 144 | self.flags = 0 |
| 145 | if table_id != None: |
| 146 | self.table_id = table_id |
| 147 | else: |
| 148 | self.table_id = 0 |
| 149 | if out_port != None: |
| 150 | self.out_port = out_port |
| 151 | else: |
| 152 | self.out_port = 0 |
| 153 | if out_group != None: |
| 154 | self.out_group = out_group |
| 155 | else: |
| 156 | self.out_group = 0 |
| 157 | if cookie != None: |
| 158 | self.cookie = cookie |
| 159 | else: |
| 160 | self.cookie = 0 |
| 161 | if cookie_mask != None: |
| 162 | self.cookie_mask = cookie_mask |
| 163 | else: |
| 164 | self.cookie_mask = 0 |
| 165 | if match != None: |
| 166 | self.match = match |
| 167 | else: |
| 168 | self.match = common.match() |
| 169 | |
| 170 | def pack(self): |
| 171 | packed = [] |
| 172 | packed.append(struct.pack("!B", self.version)) |
| 173 | packed.append(struct.pack("!B", self.type)) |
| 174 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 175 | packed.append(struct.pack("!L", self.xid)) |
| 176 | packed.append(struct.pack("!H", self.stats_type)) |
| 177 | packed.append(struct.pack("!H", self.flags)) |
| 178 | packed.append('\x00' * 4) |
| 179 | packed.append(struct.pack("!B", self.table_id)) |
| 180 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 181 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 182 | packed.append(struct.pack("!L", self.out_group)) |
| 183 | packed.append('\x00' * 4) |
| 184 | packed.append(struct.pack("!Q", self.cookie)) |
| 185 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 186 | packed.append(self.match.pack()) |
| 187 | length = sum([len(x) for x in packed]) |
| 188 | packed[2] = struct.pack("!H", length) |
| 189 | return ''.join(packed) |
| 190 | |
| 191 | @staticmethod |
| 192 | def unpack(buf): |
| 193 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 194 | obj = aggregate_stats_request() |
| 195 | if type(buf) == loxi.generic_util.OFReader: |
| 196 | reader = buf |
| 197 | else: |
| 198 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 199 | _version = reader.read("!B")[0] |
| 200 | assert(_version == 2) |
| 201 | _type = reader.read("!B")[0] |
| 202 | assert(_type == 18) |
| 203 | _length = reader.read("!H")[0] |
| 204 | obj.xid = reader.read("!L")[0] |
| 205 | _stats_type = reader.read("!H")[0] |
| 206 | assert(_stats_type == 2) |
| 207 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 208 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 209 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 210 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 211 | obj.out_port = util.unpack_port_no(reader) |
| 212 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 213 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 214 | obj.cookie = reader.read("!Q")[0] |
| 215 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 216 | obj.match = common.match.unpack(reader) |
| 217 | return obj |
| 218 | |
| 219 | def __eq__(self, other): |
| 220 | if type(self) != type(other): return False |
| 221 | if self.version != other.version: return False |
| 222 | if self.type != other.type: return False |
| 223 | if self.xid != other.xid: return False |
| 224 | if self.flags != other.flags: return False |
| 225 | if self.table_id != other.table_id: return False |
| 226 | if self.out_port != other.out_port: return False |
| 227 | if self.out_group != other.out_group: return False |
| 228 | if self.cookie != other.cookie: return False |
| 229 | if self.cookie_mask != other.cookie_mask: return False |
| 230 | if self.match != other.match: return False |
| 231 | return True |
| 232 | |
| 233 | def __ne__(self, other): |
| 234 | return not self.__eq__(other) |
| 235 | |
| 236 | def __str__(self): |
| 237 | return self.show() |
| 238 | |
| 239 | def show(self): |
| 240 | import loxi.pp |
| 241 | return loxi.pp.pp(self) |
| 242 | |
| 243 | def pretty_print(self, q): |
| 244 | q.text("aggregate_stats_request {") |
| 245 | with q.group(): |
| 246 | with q.indent(2): |
| 247 | q.breakable() |
| 248 | q.text("xid = "); |
| 249 | if self.xid != None: |
| 250 | q.text("%#x" % self.xid) |
| 251 | else: |
| 252 | q.text('None') |
| 253 | q.text(","); q.breakable() |
| 254 | q.text("flags = "); |
| 255 | q.text("%#x" % self.flags) |
| 256 | q.text(","); q.breakable() |
| 257 | q.text("table_id = "); |
| 258 | q.text("%#x" % self.table_id) |
| 259 | q.text(","); q.breakable() |
| 260 | q.text("out_port = "); |
| 261 | q.text(util.pretty_port(self.out_port)) |
| 262 | q.text(","); q.breakable() |
| 263 | q.text("out_group = "); |
| 264 | q.text("%#x" % self.out_group) |
| 265 | q.text(","); q.breakable() |
| 266 | q.text("cookie = "); |
| 267 | q.text("%#x" % self.cookie) |
| 268 | q.text(","); q.breakable() |
| 269 | q.text("cookie_mask = "); |
| 270 | q.text("%#x" % self.cookie_mask) |
| 271 | q.text(","); q.breakable() |
| 272 | q.text("match = "); |
| 273 | q.pp(self.match) |
| 274 | q.breakable() |
| 275 | q.text('}') |
| 276 | |
| 277 | class barrier_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 278 | version = 2 |
| 279 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 280 | |
| 281 | def __init__(self, xid=None): |
| 282 | self.xid = xid |
| 283 | |
| 284 | def pack(self): |
| 285 | packed = [] |
| 286 | packed.append(struct.pack("!B", self.version)) |
| 287 | packed.append(struct.pack("!B", self.type)) |
| 288 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 289 | packed.append(struct.pack("!L", self.xid)) |
| 290 | length = sum([len(x) for x in packed]) |
| 291 | packed[2] = struct.pack("!H", length) |
| 292 | return ''.join(packed) |
| 293 | |
| 294 | @staticmethod |
| 295 | def unpack(buf): |
| 296 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 297 | obj = barrier_reply() |
| 298 | if type(buf) == loxi.generic_util.OFReader: |
| 299 | reader = buf |
| 300 | else: |
| 301 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 302 | _version = reader.read("!B")[0] |
| 303 | assert(_version == 2) |
| 304 | _type = reader.read("!B")[0] |
| 305 | assert(_type == 21) |
| 306 | _length = reader.read("!H")[0] |
| 307 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 308 | return obj |
| 309 | |
| 310 | def __eq__(self, other): |
| 311 | if type(self) != type(other): return False |
| 312 | if self.version != other.version: return False |
| 313 | if self.type != other.type: return False |
| 314 | if self.xid != other.xid: return False |
| 315 | return True |
| 316 | |
| 317 | def __ne__(self, other): |
| 318 | return not self.__eq__(other) |
| 319 | |
| 320 | def __str__(self): |
| 321 | return self.show() |
| 322 | |
| 323 | def show(self): |
| 324 | import loxi.pp |
| 325 | return loxi.pp.pp(self) |
| 326 | |
| 327 | def pretty_print(self, q): |
| 328 | q.text("barrier_reply {") |
| 329 | with q.group(): |
| 330 | with q.indent(2): |
| 331 | q.breakable() |
| 332 | q.text("xid = "); |
| 333 | if self.xid != None: |
| 334 | q.text("%#x" % self.xid) |
| 335 | else: |
| 336 | q.text('None') |
| 337 | q.breakable() |
| 338 | q.text('}') |
| 339 | |
| 340 | class barrier_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 341 | version = 2 |
| 342 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 343 | |
| 344 | def __init__(self, xid=None): |
| 345 | self.xid = xid |
| 346 | |
| 347 | def pack(self): |
| 348 | packed = [] |
| 349 | packed.append(struct.pack("!B", self.version)) |
| 350 | packed.append(struct.pack("!B", self.type)) |
| 351 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 352 | packed.append(struct.pack("!L", self.xid)) |
| 353 | length = sum([len(x) for x in packed]) |
| 354 | packed[2] = struct.pack("!H", length) |
| 355 | return ''.join(packed) |
| 356 | |
| 357 | @staticmethod |
| 358 | def unpack(buf): |
| 359 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 360 | obj = barrier_request() |
| 361 | if type(buf) == loxi.generic_util.OFReader: |
| 362 | reader = buf |
| 363 | else: |
| 364 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 365 | _version = reader.read("!B")[0] |
| 366 | assert(_version == 2) |
| 367 | _type = reader.read("!B")[0] |
| 368 | assert(_type == 20) |
| 369 | _length = reader.read("!H")[0] |
| 370 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 371 | return obj |
| 372 | |
| 373 | def __eq__(self, other): |
| 374 | if type(self) != type(other): return False |
| 375 | if self.version != other.version: return False |
| 376 | if self.type != other.type: return False |
| 377 | if self.xid != other.xid: return False |
| 378 | return True |
| 379 | |
| 380 | def __ne__(self, other): |
| 381 | return not self.__eq__(other) |
| 382 | |
| 383 | def __str__(self): |
| 384 | return self.show() |
| 385 | |
| 386 | def show(self): |
| 387 | import loxi.pp |
| 388 | return loxi.pp.pp(self) |
| 389 | |
| 390 | def pretty_print(self, q): |
| 391 | q.text("barrier_request {") |
| 392 | with q.group(): |
| 393 | with q.indent(2): |
| 394 | q.breakable() |
| 395 | q.text("xid = "); |
| 396 | if self.xid != None: |
| 397 | q.text("%#x" % self.xid) |
| 398 | else: |
| 399 | q.text('None') |
| 400 | q.breakable() |
| 401 | q.text('}') |
| 402 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 403 | class bsn_bw_clear_data_reply(Message): |
| 404 | version = 2 |
| 405 | type = 4 |
| 406 | experimenter = 6035143 |
| 407 | subtype = 22 |
| 408 | |
| 409 | def __init__(self, xid=None, status=None): |
| 410 | self.xid = xid |
| 411 | if status != None: |
| 412 | self.status = status |
| 413 | else: |
| 414 | self.status = 0 |
| 415 | |
| 416 | def pack(self): |
| 417 | packed = [] |
| 418 | packed.append(struct.pack("!B", self.version)) |
| 419 | packed.append(struct.pack("!B", self.type)) |
| 420 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 421 | packed.append(struct.pack("!L", self.xid)) |
| 422 | packed.append(struct.pack("!L", self.experimenter)) |
| 423 | packed.append(struct.pack("!L", self.subtype)) |
| 424 | packed.append(struct.pack("!L", self.status)) |
| 425 | length = sum([len(x) for x in packed]) |
| 426 | packed[2] = struct.pack("!H", length) |
| 427 | return ''.join(packed) |
| 428 | |
| 429 | @staticmethod |
| 430 | def unpack(buf): |
| 431 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 432 | obj = bsn_bw_clear_data_reply() |
| 433 | if type(buf) == loxi.generic_util.OFReader: |
| 434 | reader = buf |
| 435 | else: |
| 436 | reader = loxi.generic_util.OFReader(buf) |
| 437 | _version = reader.read("!B")[0] |
| 438 | assert(_version == 2) |
| 439 | _type = reader.read("!B")[0] |
| 440 | assert(_type == 4) |
| 441 | _length = reader.read("!H")[0] |
| 442 | obj.xid = reader.read("!L")[0] |
| 443 | _experimenter = reader.read("!L")[0] |
| 444 | assert(_experimenter == 6035143) |
| 445 | _subtype = reader.read("!L")[0] |
| 446 | assert(_subtype == 22) |
| 447 | obj.status = reader.read("!L")[0] |
| 448 | return obj |
| 449 | |
| 450 | def __eq__(self, other): |
| 451 | if type(self) != type(other): return False |
| 452 | if self.version != other.version: return False |
| 453 | if self.type != other.type: return False |
| 454 | if self.xid != other.xid: return False |
| 455 | if self.status != other.status: return False |
| 456 | return True |
| 457 | |
| 458 | def __ne__(self, other): |
| 459 | return not self.__eq__(other) |
| 460 | |
| 461 | def __str__(self): |
| 462 | return self.show() |
| 463 | |
| 464 | def show(self): |
| 465 | import loxi.pp |
| 466 | return loxi.pp.pp(self) |
| 467 | |
| 468 | def pretty_print(self, q): |
| 469 | q.text("bsn_bw_clear_data_reply {") |
| 470 | with q.group(): |
| 471 | with q.indent(2): |
| 472 | q.breakable() |
| 473 | q.text("xid = "); |
| 474 | if self.xid != None: |
| 475 | q.text("%#x" % self.xid) |
| 476 | else: |
| 477 | q.text('None') |
| 478 | q.text(","); q.breakable() |
| 479 | q.text("status = "); |
| 480 | q.text("%#x" % self.status) |
| 481 | q.breakable() |
| 482 | q.text('}') |
| 483 | |
| 484 | class bsn_bw_clear_data_request(Message): |
| 485 | version = 2 |
| 486 | type = 4 |
| 487 | experimenter = 6035143 |
| 488 | subtype = 21 |
| 489 | |
| 490 | def __init__(self, xid=None): |
| 491 | self.xid = xid |
| 492 | |
| 493 | def pack(self): |
| 494 | packed = [] |
| 495 | packed.append(struct.pack("!B", self.version)) |
| 496 | packed.append(struct.pack("!B", self.type)) |
| 497 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 498 | packed.append(struct.pack("!L", self.xid)) |
| 499 | packed.append(struct.pack("!L", self.experimenter)) |
| 500 | packed.append(struct.pack("!L", self.subtype)) |
| 501 | length = sum([len(x) for x in packed]) |
| 502 | packed[2] = struct.pack("!H", length) |
| 503 | return ''.join(packed) |
| 504 | |
| 505 | @staticmethod |
| 506 | def unpack(buf): |
| 507 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 508 | obj = bsn_bw_clear_data_request() |
| 509 | if type(buf) == loxi.generic_util.OFReader: |
| 510 | reader = buf |
| 511 | else: |
| 512 | reader = loxi.generic_util.OFReader(buf) |
| 513 | _version = reader.read("!B")[0] |
| 514 | assert(_version == 2) |
| 515 | _type = reader.read("!B")[0] |
| 516 | assert(_type == 4) |
| 517 | _length = reader.read("!H")[0] |
| 518 | obj.xid = reader.read("!L")[0] |
| 519 | _experimenter = reader.read("!L")[0] |
| 520 | assert(_experimenter == 6035143) |
| 521 | _subtype = reader.read("!L")[0] |
| 522 | assert(_subtype == 21) |
| 523 | return obj |
| 524 | |
| 525 | def __eq__(self, other): |
| 526 | if type(self) != type(other): return False |
| 527 | if self.version != other.version: return False |
| 528 | if self.type != other.type: return False |
| 529 | if self.xid != other.xid: return False |
| 530 | return True |
| 531 | |
| 532 | def __ne__(self, other): |
| 533 | return not self.__eq__(other) |
| 534 | |
| 535 | def __str__(self): |
| 536 | return self.show() |
| 537 | |
| 538 | def show(self): |
| 539 | import loxi.pp |
| 540 | return loxi.pp.pp(self) |
| 541 | |
| 542 | def pretty_print(self, q): |
| 543 | q.text("bsn_bw_clear_data_request {") |
| 544 | with q.group(): |
| 545 | with q.indent(2): |
| 546 | q.breakable() |
| 547 | q.text("xid = "); |
| 548 | if self.xid != None: |
| 549 | q.text("%#x" % self.xid) |
| 550 | else: |
| 551 | q.text('None') |
| 552 | q.breakable() |
| 553 | q.text('}') |
| 554 | |
| 555 | class bsn_bw_enable_get_reply(Message): |
| 556 | version = 2 |
| 557 | type = 4 |
| 558 | experimenter = 6035143 |
| 559 | subtype = 20 |
| 560 | |
| 561 | def __init__(self, xid=None, enabled=None): |
| 562 | self.xid = xid |
| 563 | if enabled != None: |
| 564 | self.enabled = enabled |
| 565 | else: |
| 566 | self.enabled = 0 |
| 567 | |
| 568 | def pack(self): |
| 569 | packed = [] |
| 570 | packed.append(struct.pack("!B", self.version)) |
| 571 | packed.append(struct.pack("!B", self.type)) |
| 572 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 573 | packed.append(struct.pack("!L", self.xid)) |
| 574 | packed.append(struct.pack("!L", self.experimenter)) |
| 575 | packed.append(struct.pack("!L", self.subtype)) |
| 576 | packed.append(struct.pack("!L", self.enabled)) |
| 577 | length = sum([len(x) for x in packed]) |
| 578 | packed[2] = struct.pack("!H", length) |
| 579 | return ''.join(packed) |
| 580 | |
| 581 | @staticmethod |
| 582 | def unpack(buf): |
| 583 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 584 | obj = bsn_bw_enable_get_reply() |
| 585 | if type(buf) == loxi.generic_util.OFReader: |
| 586 | reader = buf |
| 587 | else: |
| 588 | reader = loxi.generic_util.OFReader(buf) |
| 589 | _version = reader.read("!B")[0] |
| 590 | assert(_version == 2) |
| 591 | _type = reader.read("!B")[0] |
| 592 | assert(_type == 4) |
| 593 | _length = reader.read("!H")[0] |
| 594 | obj.xid = reader.read("!L")[0] |
| 595 | _experimenter = reader.read("!L")[0] |
| 596 | assert(_experimenter == 6035143) |
| 597 | _subtype = reader.read("!L")[0] |
| 598 | assert(_subtype == 20) |
| 599 | obj.enabled = reader.read("!L")[0] |
| 600 | return obj |
| 601 | |
| 602 | def __eq__(self, other): |
| 603 | if type(self) != type(other): return False |
| 604 | if self.version != other.version: return False |
| 605 | if self.type != other.type: return False |
| 606 | if self.xid != other.xid: return False |
| 607 | if self.enabled != other.enabled: return False |
| 608 | return True |
| 609 | |
| 610 | def __ne__(self, other): |
| 611 | return not self.__eq__(other) |
| 612 | |
| 613 | def __str__(self): |
| 614 | return self.show() |
| 615 | |
| 616 | def show(self): |
| 617 | import loxi.pp |
| 618 | return loxi.pp.pp(self) |
| 619 | |
| 620 | def pretty_print(self, q): |
| 621 | q.text("bsn_bw_enable_get_reply {") |
| 622 | with q.group(): |
| 623 | with q.indent(2): |
| 624 | q.breakable() |
| 625 | q.text("xid = "); |
| 626 | if self.xid != None: |
| 627 | q.text("%#x" % self.xid) |
| 628 | else: |
| 629 | q.text('None') |
| 630 | q.text(","); q.breakable() |
| 631 | q.text("enabled = "); |
| 632 | q.text("%#x" % self.enabled) |
| 633 | q.breakable() |
| 634 | q.text('}') |
| 635 | |
| 636 | class bsn_bw_enable_get_request(Message): |
| 637 | version = 2 |
| 638 | type = 4 |
| 639 | experimenter = 6035143 |
| 640 | subtype = 19 |
| 641 | |
| 642 | def __init__(self, xid=None): |
| 643 | self.xid = xid |
| 644 | |
| 645 | def pack(self): |
| 646 | packed = [] |
| 647 | packed.append(struct.pack("!B", self.version)) |
| 648 | packed.append(struct.pack("!B", self.type)) |
| 649 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 650 | packed.append(struct.pack("!L", self.xid)) |
| 651 | packed.append(struct.pack("!L", self.experimenter)) |
| 652 | packed.append(struct.pack("!L", self.subtype)) |
| 653 | length = sum([len(x) for x in packed]) |
| 654 | packed[2] = struct.pack("!H", length) |
| 655 | return ''.join(packed) |
| 656 | |
| 657 | @staticmethod |
| 658 | def unpack(buf): |
| 659 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 660 | obj = bsn_bw_enable_get_request() |
| 661 | if type(buf) == loxi.generic_util.OFReader: |
| 662 | reader = buf |
| 663 | else: |
| 664 | reader = loxi.generic_util.OFReader(buf) |
| 665 | _version = reader.read("!B")[0] |
| 666 | assert(_version == 2) |
| 667 | _type = reader.read("!B")[0] |
| 668 | assert(_type == 4) |
| 669 | _length = reader.read("!H")[0] |
| 670 | obj.xid = reader.read("!L")[0] |
| 671 | _experimenter = reader.read("!L")[0] |
| 672 | assert(_experimenter == 6035143) |
| 673 | _subtype = reader.read("!L")[0] |
| 674 | assert(_subtype == 19) |
| 675 | return obj |
| 676 | |
| 677 | def __eq__(self, other): |
| 678 | if type(self) != type(other): return False |
| 679 | if self.version != other.version: return False |
| 680 | if self.type != other.type: return False |
| 681 | if self.xid != other.xid: return False |
| 682 | return True |
| 683 | |
| 684 | def __ne__(self, other): |
| 685 | return not self.__eq__(other) |
| 686 | |
| 687 | def __str__(self): |
| 688 | return self.show() |
| 689 | |
| 690 | def show(self): |
| 691 | import loxi.pp |
| 692 | return loxi.pp.pp(self) |
| 693 | |
| 694 | def pretty_print(self, q): |
| 695 | q.text("bsn_bw_enable_get_request {") |
| 696 | with q.group(): |
| 697 | with q.indent(2): |
| 698 | q.breakable() |
| 699 | q.text("xid = "); |
| 700 | if self.xid != None: |
| 701 | q.text("%#x" % self.xid) |
| 702 | else: |
| 703 | q.text('None') |
| 704 | q.breakable() |
| 705 | q.text('}') |
| 706 | |
| 707 | class bsn_bw_enable_set_reply(Message): |
| 708 | version = 2 |
| 709 | type = 4 |
| 710 | experimenter = 6035143 |
| 711 | subtype = 23 |
| 712 | |
| 713 | def __init__(self, xid=None, enable=None, status=None): |
| 714 | self.xid = xid |
| 715 | if enable != None: |
| 716 | self.enable = enable |
| 717 | else: |
| 718 | self.enable = 0 |
| 719 | if status != None: |
| 720 | self.status = status |
| 721 | else: |
| 722 | self.status = 0 |
| 723 | |
| 724 | def pack(self): |
| 725 | packed = [] |
| 726 | packed.append(struct.pack("!B", self.version)) |
| 727 | packed.append(struct.pack("!B", self.type)) |
| 728 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 729 | packed.append(struct.pack("!L", self.xid)) |
| 730 | packed.append(struct.pack("!L", self.experimenter)) |
| 731 | packed.append(struct.pack("!L", self.subtype)) |
| 732 | packed.append(struct.pack("!L", self.enable)) |
| 733 | packed.append(struct.pack("!L", self.status)) |
| 734 | length = sum([len(x) for x in packed]) |
| 735 | packed[2] = struct.pack("!H", length) |
| 736 | return ''.join(packed) |
| 737 | |
| 738 | @staticmethod |
| 739 | def unpack(buf): |
| 740 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 741 | obj = bsn_bw_enable_set_reply() |
| 742 | if type(buf) == loxi.generic_util.OFReader: |
| 743 | reader = buf |
| 744 | else: |
| 745 | reader = loxi.generic_util.OFReader(buf) |
| 746 | _version = reader.read("!B")[0] |
| 747 | assert(_version == 2) |
| 748 | _type = reader.read("!B")[0] |
| 749 | assert(_type == 4) |
| 750 | _length = reader.read("!H")[0] |
| 751 | obj.xid = reader.read("!L")[0] |
| 752 | _experimenter = reader.read("!L")[0] |
| 753 | assert(_experimenter == 6035143) |
| 754 | _subtype = reader.read("!L")[0] |
| 755 | assert(_subtype == 23) |
| 756 | obj.enable = reader.read("!L")[0] |
| 757 | obj.status = reader.read("!L")[0] |
| 758 | return obj |
| 759 | |
| 760 | def __eq__(self, other): |
| 761 | if type(self) != type(other): return False |
| 762 | if self.version != other.version: return False |
| 763 | if self.type != other.type: return False |
| 764 | if self.xid != other.xid: return False |
| 765 | if self.enable != other.enable: return False |
| 766 | if self.status != other.status: return False |
| 767 | return True |
| 768 | |
| 769 | def __ne__(self, other): |
| 770 | return not self.__eq__(other) |
| 771 | |
| 772 | def __str__(self): |
| 773 | return self.show() |
| 774 | |
| 775 | def show(self): |
| 776 | import loxi.pp |
| 777 | return loxi.pp.pp(self) |
| 778 | |
| 779 | def pretty_print(self, q): |
| 780 | q.text("bsn_bw_enable_set_reply {") |
| 781 | with q.group(): |
| 782 | with q.indent(2): |
| 783 | q.breakable() |
| 784 | q.text("xid = "); |
| 785 | if self.xid != None: |
| 786 | q.text("%#x" % self.xid) |
| 787 | else: |
| 788 | q.text('None') |
| 789 | q.text(","); q.breakable() |
| 790 | q.text("enable = "); |
| 791 | q.text("%#x" % self.enable) |
| 792 | q.text(","); q.breakable() |
| 793 | q.text("status = "); |
| 794 | q.text("%#x" % self.status) |
| 795 | q.breakable() |
| 796 | q.text('}') |
| 797 | |
| 798 | class bsn_bw_enable_set_request(Message): |
| 799 | version = 2 |
| 800 | type = 4 |
| 801 | experimenter = 6035143 |
| 802 | subtype = 18 |
| 803 | |
| 804 | def __init__(self, xid=None, enable=None): |
| 805 | self.xid = xid |
| 806 | if enable != None: |
| 807 | self.enable = enable |
| 808 | else: |
| 809 | self.enable = 0 |
| 810 | |
| 811 | def pack(self): |
| 812 | packed = [] |
| 813 | packed.append(struct.pack("!B", self.version)) |
| 814 | packed.append(struct.pack("!B", self.type)) |
| 815 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 816 | packed.append(struct.pack("!L", self.xid)) |
| 817 | packed.append(struct.pack("!L", self.experimenter)) |
| 818 | packed.append(struct.pack("!L", self.subtype)) |
| 819 | packed.append(struct.pack("!L", self.enable)) |
| 820 | length = sum([len(x) for x in packed]) |
| 821 | packed[2] = struct.pack("!H", length) |
| 822 | return ''.join(packed) |
| 823 | |
| 824 | @staticmethod |
| 825 | def unpack(buf): |
| 826 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 827 | obj = bsn_bw_enable_set_request() |
| 828 | if type(buf) == loxi.generic_util.OFReader: |
| 829 | reader = buf |
| 830 | else: |
| 831 | reader = loxi.generic_util.OFReader(buf) |
| 832 | _version = reader.read("!B")[0] |
| 833 | assert(_version == 2) |
| 834 | _type = reader.read("!B")[0] |
| 835 | assert(_type == 4) |
| 836 | _length = reader.read("!H")[0] |
| 837 | obj.xid = reader.read("!L")[0] |
| 838 | _experimenter = reader.read("!L")[0] |
| 839 | assert(_experimenter == 6035143) |
| 840 | _subtype = reader.read("!L")[0] |
| 841 | assert(_subtype == 18) |
| 842 | obj.enable = reader.read("!L")[0] |
| 843 | return obj |
| 844 | |
| 845 | def __eq__(self, other): |
| 846 | if type(self) != type(other): return False |
| 847 | if self.version != other.version: return False |
| 848 | if self.type != other.type: return False |
| 849 | if self.xid != other.xid: return False |
| 850 | if self.enable != other.enable: return False |
| 851 | return True |
| 852 | |
| 853 | def __ne__(self, other): |
| 854 | return not self.__eq__(other) |
| 855 | |
| 856 | def __str__(self): |
| 857 | return self.show() |
| 858 | |
| 859 | def show(self): |
| 860 | import loxi.pp |
| 861 | return loxi.pp.pp(self) |
| 862 | |
| 863 | def pretty_print(self, q): |
| 864 | q.text("bsn_bw_enable_set_request {") |
| 865 | with q.group(): |
| 866 | with q.indent(2): |
| 867 | q.breakable() |
| 868 | q.text("xid = "); |
| 869 | if self.xid != None: |
| 870 | q.text("%#x" % self.xid) |
| 871 | else: |
| 872 | q.text('None') |
| 873 | q.text(","); q.breakable() |
| 874 | q.text("enable = "); |
| 875 | q.text("%#x" % self.enable) |
| 876 | q.breakable() |
| 877 | q.text('}') |
| 878 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 879 | class bsn_get_interfaces_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 880 | version = 2 |
| 881 | type = 4 |
| 882 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 883 | subtype = 10 |
| 884 | |
| 885 | def __init__(self, xid=None, interfaces=None): |
| 886 | self.xid = xid |
| 887 | if interfaces != None: |
| 888 | self.interfaces = interfaces |
| 889 | else: |
| 890 | self.interfaces = [] |
| 891 | |
| 892 | def pack(self): |
| 893 | packed = [] |
| 894 | packed.append(struct.pack("!B", self.version)) |
| 895 | packed.append(struct.pack("!B", self.type)) |
| 896 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 897 | packed.append(struct.pack("!L", self.xid)) |
| 898 | packed.append(struct.pack("!L", self.experimenter)) |
| 899 | packed.append(struct.pack("!L", self.subtype)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 900 | packed.append(util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 901 | length = sum([len(x) for x in packed]) |
| 902 | packed[2] = struct.pack("!H", length) |
| 903 | return ''.join(packed) |
| 904 | |
| 905 | @staticmethod |
| 906 | def unpack(buf): |
| 907 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 908 | obj = bsn_get_interfaces_reply() |
| 909 | if type(buf) == loxi.generic_util.OFReader: |
| 910 | reader = buf |
| 911 | else: |
| 912 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 913 | _version = reader.read("!B")[0] |
| 914 | assert(_version == 2) |
| 915 | _type = reader.read("!B")[0] |
| 916 | assert(_type == 4) |
| 917 | _length = reader.read("!H")[0] |
| 918 | obj.xid = reader.read("!L")[0] |
| 919 | _experimenter = reader.read("!L")[0] |
| 920 | assert(_experimenter == 6035143) |
| 921 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 922 | assert(_subtype == 10) |
| 923 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
| 924 | return obj |
| 925 | |
| 926 | def __eq__(self, other): |
| 927 | if type(self) != type(other): return False |
| 928 | if self.version != other.version: return False |
| 929 | if self.type != other.type: return False |
| 930 | if self.xid != other.xid: return False |
| 931 | if self.interfaces != other.interfaces: return False |
| 932 | return True |
| 933 | |
| 934 | def __ne__(self, other): |
| 935 | return not self.__eq__(other) |
| 936 | |
| 937 | def __str__(self): |
| 938 | return self.show() |
| 939 | |
| 940 | def show(self): |
| 941 | import loxi.pp |
| 942 | return loxi.pp.pp(self) |
| 943 | |
| 944 | def pretty_print(self, q): |
| 945 | q.text("bsn_get_interfaces_reply {") |
| 946 | with q.group(): |
| 947 | with q.indent(2): |
| 948 | q.breakable() |
| 949 | q.text("xid = "); |
| 950 | if self.xid != None: |
| 951 | q.text("%#x" % self.xid) |
| 952 | else: |
| 953 | q.text('None') |
| 954 | q.text(","); q.breakable() |
| 955 | q.text("interfaces = "); |
| 956 | q.pp(self.interfaces) |
| 957 | q.breakable() |
| 958 | q.text('}') |
| 959 | |
| 960 | class bsn_get_interfaces_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 961 | version = 2 |
| 962 | type = 4 |
| 963 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 964 | subtype = 9 |
| 965 | |
| 966 | def __init__(self, xid=None): |
| 967 | self.xid = xid |
| 968 | |
| 969 | def pack(self): |
| 970 | packed = [] |
| 971 | packed.append(struct.pack("!B", self.version)) |
| 972 | packed.append(struct.pack("!B", self.type)) |
| 973 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 974 | packed.append(struct.pack("!L", self.xid)) |
| 975 | packed.append(struct.pack("!L", self.experimenter)) |
| 976 | packed.append(struct.pack("!L", self.subtype)) |
| 977 | length = sum([len(x) for x in packed]) |
| 978 | packed[2] = struct.pack("!H", length) |
| 979 | return ''.join(packed) |
| 980 | |
| 981 | @staticmethod |
| 982 | def unpack(buf): |
| 983 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 984 | obj = bsn_get_interfaces_request() |
| 985 | if type(buf) == loxi.generic_util.OFReader: |
| 986 | reader = buf |
| 987 | else: |
| 988 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 989 | _version = reader.read("!B")[0] |
| 990 | assert(_version == 2) |
| 991 | _type = reader.read("!B")[0] |
| 992 | assert(_type == 4) |
| 993 | _length = reader.read("!H")[0] |
| 994 | obj.xid = reader.read("!L")[0] |
| 995 | _experimenter = reader.read("!L")[0] |
| 996 | assert(_experimenter == 6035143) |
| 997 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 998 | assert(_subtype == 9) |
| 999 | return obj |
| 1000 | |
| 1001 | def __eq__(self, other): |
| 1002 | if type(self) != type(other): return False |
| 1003 | if self.version != other.version: return False |
| 1004 | if self.type != other.type: return False |
| 1005 | if self.xid != other.xid: return False |
| 1006 | return True |
| 1007 | |
| 1008 | def __ne__(self, other): |
| 1009 | return not self.__eq__(other) |
| 1010 | |
| 1011 | def __str__(self): |
| 1012 | return self.show() |
| 1013 | |
| 1014 | def show(self): |
| 1015 | import loxi.pp |
| 1016 | return loxi.pp.pp(self) |
| 1017 | |
| 1018 | def pretty_print(self, q): |
| 1019 | q.text("bsn_get_interfaces_request {") |
| 1020 | with q.group(): |
| 1021 | with q.indent(2): |
| 1022 | q.breakable() |
| 1023 | q.text("xid = "); |
| 1024 | if self.xid != None: |
| 1025 | q.text("%#x" % self.xid) |
| 1026 | else: |
| 1027 | q.text('None') |
| 1028 | q.breakable() |
| 1029 | q.text('}') |
| 1030 | |
| 1031 | class bsn_get_mirroring_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1032 | version = 2 |
| 1033 | type = 4 |
| 1034 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1035 | subtype = 5 |
| 1036 | |
| 1037 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1038 | self.xid = xid |
| 1039 | if report_mirror_ports != None: |
| 1040 | self.report_mirror_ports = report_mirror_ports |
| 1041 | else: |
| 1042 | self.report_mirror_ports = 0 |
| 1043 | |
| 1044 | def pack(self): |
| 1045 | packed = [] |
| 1046 | packed.append(struct.pack("!B", self.version)) |
| 1047 | packed.append(struct.pack("!B", self.type)) |
| 1048 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1049 | packed.append(struct.pack("!L", self.xid)) |
| 1050 | packed.append(struct.pack("!L", self.experimenter)) |
| 1051 | packed.append(struct.pack("!L", self.subtype)) |
| 1052 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1053 | packed.append('\x00' * 3) |
| 1054 | length = sum([len(x) for x in packed]) |
| 1055 | packed[2] = struct.pack("!H", length) |
| 1056 | return ''.join(packed) |
| 1057 | |
| 1058 | @staticmethod |
| 1059 | def unpack(buf): |
| 1060 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1061 | obj = bsn_get_mirroring_reply() |
| 1062 | if type(buf) == loxi.generic_util.OFReader: |
| 1063 | reader = buf |
| 1064 | else: |
| 1065 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1066 | _version = reader.read("!B")[0] |
| 1067 | assert(_version == 2) |
| 1068 | _type = reader.read("!B")[0] |
| 1069 | assert(_type == 4) |
| 1070 | _length = reader.read("!H")[0] |
| 1071 | obj.xid = reader.read("!L")[0] |
| 1072 | _experimenter = reader.read("!L")[0] |
| 1073 | assert(_experimenter == 6035143) |
| 1074 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1075 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1076 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1077 | reader.skip(3) |
| 1078 | return obj |
| 1079 | |
| 1080 | def __eq__(self, other): |
| 1081 | if type(self) != type(other): return False |
| 1082 | if self.version != other.version: return False |
| 1083 | if self.type != other.type: return False |
| 1084 | if self.xid != other.xid: return False |
| 1085 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1086 | return True |
| 1087 | |
| 1088 | def __ne__(self, other): |
| 1089 | return not self.__eq__(other) |
| 1090 | |
| 1091 | def __str__(self): |
| 1092 | return self.show() |
| 1093 | |
| 1094 | def show(self): |
| 1095 | import loxi.pp |
| 1096 | return loxi.pp.pp(self) |
| 1097 | |
| 1098 | def pretty_print(self, q): |
| 1099 | q.text("bsn_get_mirroring_reply {") |
| 1100 | with q.group(): |
| 1101 | with q.indent(2): |
| 1102 | q.breakable() |
| 1103 | q.text("xid = "); |
| 1104 | if self.xid != None: |
| 1105 | q.text("%#x" % self.xid) |
| 1106 | else: |
| 1107 | q.text('None') |
| 1108 | q.text(","); q.breakable() |
| 1109 | q.text("report_mirror_ports = "); |
| 1110 | q.text("%#x" % self.report_mirror_ports) |
| 1111 | q.breakable() |
| 1112 | q.text('}') |
| 1113 | |
| 1114 | class bsn_get_mirroring_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1115 | version = 2 |
| 1116 | type = 4 |
| 1117 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1118 | subtype = 4 |
| 1119 | |
| 1120 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1121 | self.xid = xid |
| 1122 | if report_mirror_ports != None: |
| 1123 | self.report_mirror_ports = report_mirror_ports |
| 1124 | else: |
| 1125 | self.report_mirror_ports = 0 |
| 1126 | |
| 1127 | def pack(self): |
| 1128 | packed = [] |
| 1129 | packed.append(struct.pack("!B", self.version)) |
| 1130 | packed.append(struct.pack("!B", self.type)) |
| 1131 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1132 | packed.append(struct.pack("!L", self.xid)) |
| 1133 | packed.append(struct.pack("!L", self.experimenter)) |
| 1134 | packed.append(struct.pack("!L", self.subtype)) |
| 1135 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1136 | packed.append('\x00' * 3) |
| 1137 | length = sum([len(x) for x in packed]) |
| 1138 | packed[2] = struct.pack("!H", length) |
| 1139 | return ''.join(packed) |
| 1140 | |
| 1141 | @staticmethod |
| 1142 | def unpack(buf): |
| 1143 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1144 | obj = bsn_get_mirroring_request() |
| 1145 | if type(buf) == loxi.generic_util.OFReader: |
| 1146 | reader = buf |
| 1147 | else: |
| 1148 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1149 | _version = reader.read("!B")[0] |
| 1150 | assert(_version == 2) |
| 1151 | _type = reader.read("!B")[0] |
| 1152 | assert(_type == 4) |
| 1153 | _length = reader.read("!H")[0] |
| 1154 | obj.xid = reader.read("!L")[0] |
| 1155 | _experimenter = reader.read("!L")[0] |
| 1156 | assert(_experimenter == 6035143) |
| 1157 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1158 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1159 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1160 | reader.skip(3) |
| 1161 | return obj |
| 1162 | |
| 1163 | def __eq__(self, other): |
| 1164 | if type(self) != type(other): return False |
| 1165 | if self.version != other.version: return False |
| 1166 | if self.type != other.type: return False |
| 1167 | if self.xid != other.xid: return False |
| 1168 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1169 | return True |
| 1170 | |
| 1171 | def __ne__(self, other): |
| 1172 | return not self.__eq__(other) |
| 1173 | |
| 1174 | def __str__(self): |
| 1175 | return self.show() |
| 1176 | |
| 1177 | def show(self): |
| 1178 | import loxi.pp |
| 1179 | return loxi.pp.pp(self) |
| 1180 | |
| 1181 | def pretty_print(self, q): |
| 1182 | q.text("bsn_get_mirroring_request {") |
| 1183 | with q.group(): |
| 1184 | with q.indent(2): |
| 1185 | q.breakable() |
| 1186 | q.text("xid = "); |
| 1187 | if self.xid != None: |
| 1188 | q.text("%#x" % self.xid) |
| 1189 | else: |
| 1190 | q.text('None') |
| 1191 | q.text(","); q.breakable() |
| 1192 | q.text("report_mirror_ports = "); |
| 1193 | q.text("%#x" % self.report_mirror_ports) |
| 1194 | q.breakable() |
| 1195 | q.text('}') |
| 1196 | |
| 1197 | class bsn_set_mirroring(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1198 | version = 2 |
| 1199 | type = 4 |
| 1200 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1201 | subtype = 3 |
| 1202 | |
| 1203 | def __init__(self, xid=None, report_mirror_ports=None): |
| 1204 | self.xid = xid |
| 1205 | if report_mirror_ports != None: |
| 1206 | self.report_mirror_ports = report_mirror_ports |
| 1207 | else: |
| 1208 | self.report_mirror_ports = 0 |
| 1209 | |
| 1210 | def pack(self): |
| 1211 | packed = [] |
| 1212 | packed.append(struct.pack("!B", self.version)) |
| 1213 | packed.append(struct.pack("!B", self.type)) |
| 1214 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1215 | packed.append(struct.pack("!L", self.xid)) |
| 1216 | packed.append(struct.pack("!L", self.experimenter)) |
| 1217 | packed.append(struct.pack("!L", self.subtype)) |
| 1218 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 1219 | packed.append('\x00' * 3) |
| 1220 | length = sum([len(x) for x in packed]) |
| 1221 | packed[2] = struct.pack("!H", length) |
| 1222 | return ''.join(packed) |
| 1223 | |
| 1224 | @staticmethod |
| 1225 | def unpack(buf): |
| 1226 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1227 | obj = bsn_set_mirroring() |
| 1228 | if type(buf) == loxi.generic_util.OFReader: |
| 1229 | reader = buf |
| 1230 | else: |
| 1231 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1232 | _version = reader.read("!B")[0] |
| 1233 | assert(_version == 2) |
| 1234 | _type = reader.read("!B")[0] |
| 1235 | assert(_type == 4) |
| 1236 | _length = reader.read("!H")[0] |
| 1237 | obj.xid = reader.read("!L")[0] |
| 1238 | _experimenter = reader.read("!L")[0] |
| 1239 | assert(_experimenter == 6035143) |
| 1240 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1241 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1242 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1243 | reader.skip(3) |
| 1244 | return obj |
| 1245 | |
| 1246 | def __eq__(self, other): |
| 1247 | if type(self) != type(other): return False |
| 1248 | if self.version != other.version: return False |
| 1249 | if self.type != other.type: return False |
| 1250 | if self.xid != other.xid: return False |
| 1251 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 1252 | return True |
| 1253 | |
| 1254 | def __ne__(self, other): |
| 1255 | return not self.__eq__(other) |
| 1256 | |
| 1257 | def __str__(self): |
| 1258 | return self.show() |
| 1259 | |
| 1260 | def show(self): |
| 1261 | import loxi.pp |
| 1262 | return loxi.pp.pp(self) |
| 1263 | |
| 1264 | def pretty_print(self, q): |
| 1265 | q.text("bsn_set_mirroring {") |
| 1266 | with q.group(): |
| 1267 | with q.indent(2): |
| 1268 | q.breakable() |
| 1269 | q.text("xid = "); |
| 1270 | if self.xid != None: |
| 1271 | q.text("%#x" % self.xid) |
| 1272 | else: |
| 1273 | q.text('None') |
| 1274 | q.text(","); q.breakable() |
| 1275 | q.text("report_mirror_ports = "); |
| 1276 | q.text("%#x" % self.report_mirror_ports) |
| 1277 | q.breakable() |
| 1278 | q.text('}') |
| 1279 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1280 | class bsn_set_pktin_suppression_reply(Message): |
| 1281 | version = 2 |
| 1282 | type = 4 |
| 1283 | experimenter = 6035143 |
| 1284 | subtype = 25 |
| 1285 | |
| 1286 | def __init__(self, xid=None, status=None): |
| 1287 | self.xid = xid |
| 1288 | if status != None: |
| 1289 | self.status = status |
| 1290 | else: |
| 1291 | self.status = 0 |
| 1292 | |
| 1293 | def pack(self): |
| 1294 | packed = [] |
| 1295 | packed.append(struct.pack("!B", self.version)) |
| 1296 | packed.append(struct.pack("!B", self.type)) |
| 1297 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1298 | packed.append(struct.pack("!L", self.xid)) |
| 1299 | packed.append(struct.pack("!L", self.experimenter)) |
| 1300 | packed.append(struct.pack("!L", self.subtype)) |
| 1301 | packed.append(struct.pack("!L", self.status)) |
| 1302 | length = sum([len(x) for x in packed]) |
| 1303 | packed[2] = struct.pack("!H", length) |
| 1304 | return ''.join(packed) |
| 1305 | |
| 1306 | @staticmethod |
| 1307 | def unpack(buf): |
| 1308 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1309 | obj = bsn_set_pktin_suppression_reply() |
| 1310 | if type(buf) == loxi.generic_util.OFReader: |
| 1311 | reader = buf |
| 1312 | else: |
| 1313 | reader = loxi.generic_util.OFReader(buf) |
| 1314 | _version = reader.read("!B")[0] |
| 1315 | assert(_version == 2) |
| 1316 | _type = reader.read("!B")[0] |
| 1317 | assert(_type == 4) |
| 1318 | _length = reader.read("!H")[0] |
| 1319 | obj.xid = reader.read("!L")[0] |
| 1320 | _experimenter = reader.read("!L")[0] |
| 1321 | assert(_experimenter == 6035143) |
| 1322 | _subtype = reader.read("!L")[0] |
| 1323 | assert(_subtype == 25) |
| 1324 | obj.status = reader.read("!L")[0] |
| 1325 | return obj |
| 1326 | |
| 1327 | def __eq__(self, other): |
| 1328 | if type(self) != type(other): return False |
| 1329 | if self.version != other.version: return False |
| 1330 | if self.type != other.type: return False |
| 1331 | if self.xid != other.xid: return False |
| 1332 | if self.status != other.status: return False |
| 1333 | return True |
| 1334 | |
| 1335 | def __ne__(self, other): |
| 1336 | return not self.__eq__(other) |
| 1337 | |
| 1338 | def __str__(self): |
| 1339 | return self.show() |
| 1340 | |
| 1341 | def show(self): |
| 1342 | import loxi.pp |
| 1343 | return loxi.pp.pp(self) |
| 1344 | |
| 1345 | def pretty_print(self, q): |
| 1346 | q.text("bsn_set_pktin_suppression_reply {") |
| 1347 | with q.group(): |
| 1348 | with q.indent(2): |
| 1349 | q.breakable() |
| 1350 | q.text("xid = "); |
| 1351 | if self.xid != None: |
| 1352 | q.text("%#x" % self.xid) |
| 1353 | else: |
| 1354 | q.text('None') |
| 1355 | q.text(","); q.breakable() |
| 1356 | q.text("status = "); |
| 1357 | q.text("%#x" % self.status) |
| 1358 | q.breakable() |
| 1359 | q.text('}') |
| 1360 | |
| 1361 | class bsn_set_pktin_suppression_request(Message): |
| 1362 | version = 2 |
| 1363 | type = 4 |
| 1364 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1365 | subtype = 11 |
| 1366 | |
| 1367 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
| 1368 | self.xid = xid |
| 1369 | if enabled != None: |
| 1370 | self.enabled = enabled |
| 1371 | else: |
| 1372 | self.enabled = 0 |
| 1373 | if idle_timeout != None: |
| 1374 | self.idle_timeout = idle_timeout |
| 1375 | else: |
| 1376 | self.idle_timeout = 0 |
| 1377 | if hard_timeout != None: |
| 1378 | self.hard_timeout = hard_timeout |
| 1379 | else: |
| 1380 | self.hard_timeout = 0 |
| 1381 | if priority != None: |
| 1382 | self.priority = priority |
| 1383 | else: |
| 1384 | self.priority = 0 |
| 1385 | if cookie != None: |
| 1386 | self.cookie = cookie |
| 1387 | else: |
| 1388 | self.cookie = 0 |
| 1389 | |
| 1390 | def pack(self): |
| 1391 | packed = [] |
| 1392 | packed.append(struct.pack("!B", self.version)) |
| 1393 | packed.append(struct.pack("!B", self.type)) |
| 1394 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1395 | packed.append(struct.pack("!L", self.xid)) |
| 1396 | packed.append(struct.pack("!L", self.experimenter)) |
| 1397 | packed.append(struct.pack("!L", self.subtype)) |
| 1398 | packed.append(struct.pack("!B", self.enabled)) |
| 1399 | packed.append('\x00' * 1) |
| 1400 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 1401 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 1402 | packed.append(struct.pack("!H", self.priority)) |
| 1403 | packed.append(struct.pack("!Q", self.cookie)) |
| 1404 | length = sum([len(x) for x in packed]) |
| 1405 | packed[2] = struct.pack("!H", length) |
| 1406 | return ''.join(packed) |
| 1407 | |
| 1408 | @staticmethod |
| 1409 | def unpack(buf): |
| 1410 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1411 | obj = bsn_set_pktin_suppression_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1412 | if type(buf) == loxi.generic_util.OFReader: |
| 1413 | reader = buf |
| 1414 | else: |
| 1415 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1416 | _version = reader.read("!B")[0] |
| 1417 | assert(_version == 2) |
| 1418 | _type = reader.read("!B")[0] |
| 1419 | assert(_type == 4) |
| 1420 | _length = reader.read("!H")[0] |
| 1421 | obj.xid = reader.read("!L")[0] |
| 1422 | _experimenter = reader.read("!L")[0] |
| 1423 | assert(_experimenter == 6035143) |
| 1424 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1425 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1426 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1427 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1428 | obj.idle_timeout = reader.read("!H")[0] |
| 1429 | obj.hard_timeout = reader.read("!H")[0] |
| 1430 | obj.priority = reader.read("!H")[0] |
| 1431 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1432 | return obj |
| 1433 | |
| 1434 | def __eq__(self, other): |
| 1435 | if type(self) != type(other): return False |
| 1436 | if self.version != other.version: return False |
| 1437 | if self.type != other.type: return False |
| 1438 | if self.xid != other.xid: return False |
| 1439 | if self.enabled != other.enabled: return False |
| 1440 | if self.idle_timeout != other.idle_timeout: return False |
| 1441 | if self.hard_timeout != other.hard_timeout: return False |
| 1442 | if self.priority != other.priority: return False |
| 1443 | if self.cookie != other.cookie: return False |
| 1444 | return True |
| 1445 | |
| 1446 | def __ne__(self, other): |
| 1447 | return not self.__eq__(other) |
| 1448 | |
| 1449 | def __str__(self): |
| 1450 | return self.show() |
| 1451 | |
| 1452 | def show(self): |
| 1453 | import loxi.pp |
| 1454 | return loxi.pp.pp(self) |
| 1455 | |
| 1456 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1457 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1458 | with q.group(): |
| 1459 | with q.indent(2): |
| 1460 | q.breakable() |
| 1461 | q.text("xid = "); |
| 1462 | if self.xid != None: |
| 1463 | q.text("%#x" % self.xid) |
| 1464 | else: |
| 1465 | q.text('None') |
| 1466 | q.text(","); q.breakable() |
| 1467 | q.text("enabled = "); |
| 1468 | q.text("%#x" % self.enabled) |
| 1469 | q.text(","); q.breakable() |
| 1470 | q.text("idle_timeout = "); |
| 1471 | q.text("%#x" % self.idle_timeout) |
| 1472 | q.text(","); q.breakable() |
| 1473 | q.text("hard_timeout = "); |
| 1474 | q.text("%#x" % self.hard_timeout) |
| 1475 | q.text(","); q.breakable() |
| 1476 | q.text("priority = "); |
| 1477 | q.text("%#x" % self.priority) |
| 1478 | q.text(","); q.breakable() |
| 1479 | q.text("cookie = "); |
| 1480 | q.text("%#x" % self.cookie) |
| 1481 | q.breakable() |
| 1482 | q.text('}') |
| 1483 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1484 | class bsn_virtual_port_create_reply(Message): |
| 1485 | version = 2 |
| 1486 | type = 4 |
| 1487 | experimenter = 6035143 |
| 1488 | subtype = 16 |
| 1489 | |
| 1490 | def __init__(self, xid=None, status=None, vport_no=None): |
| 1491 | self.xid = xid |
| 1492 | if status != None: |
| 1493 | self.status = status |
| 1494 | else: |
| 1495 | self.status = 0 |
| 1496 | if vport_no != None: |
| 1497 | self.vport_no = vport_no |
| 1498 | else: |
| 1499 | self.vport_no = 0 |
| 1500 | |
| 1501 | def pack(self): |
| 1502 | packed = [] |
| 1503 | packed.append(struct.pack("!B", self.version)) |
| 1504 | packed.append(struct.pack("!B", self.type)) |
| 1505 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1506 | packed.append(struct.pack("!L", self.xid)) |
| 1507 | packed.append(struct.pack("!L", self.experimenter)) |
| 1508 | packed.append(struct.pack("!L", self.subtype)) |
| 1509 | packed.append(struct.pack("!L", self.status)) |
| 1510 | packed.append(struct.pack("!L", self.vport_no)) |
| 1511 | length = sum([len(x) for x in packed]) |
| 1512 | packed[2] = struct.pack("!H", length) |
| 1513 | return ''.join(packed) |
| 1514 | |
| 1515 | @staticmethod |
| 1516 | def unpack(buf): |
| 1517 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1518 | obj = bsn_virtual_port_create_reply() |
| 1519 | if type(buf) == loxi.generic_util.OFReader: |
| 1520 | reader = buf |
| 1521 | else: |
| 1522 | reader = loxi.generic_util.OFReader(buf) |
| 1523 | _version = reader.read("!B")[0] |
| 1524 | assert(_version == 2) |
| 1525 | _type = reader.read("!B")[0] |
| 1526 | assert(_type == 4) |
| 1527 | _length = reader.read("!H")[0] |
| 1528 | obj.xid = reader.read("!L")[0] |
| 1529 | _experimenter = reader.read("!L")[0] |
| 1530 | assert(_experimenter == 6035143) |
| 1531 | _subtype = reader.read("!L")[0] |
| 1532 | assert(_subtype == 16) |
| 1533 | obj.status = reader.read("!L")[0] |
| 1534 | obj.vport_no = reader.read("!L")[0] |
| 1535 | return obj |
| 1536 | |
| 1537 | def __eq__(self, other): |
| 1538 | if type(self) != type(other): return False |
| 1539 | if self.version != other.version: return False |
| 1540 | if self.type != other.type: return False |
| 1541 | if self.xid != other.xid: return False |
| 1542 | if self.status != other.status: return False |
| 1543 | if self.vport_no != other.vport_no: return False |
| 1544 | return True |
| 1545 | |
| 1546 | def __ne__(self, other): |
| 1547 | return not self.__eq__(other) |
| 1548 | |
| 1549 | def __str__(self): |
| 1550 | return self.show() |
| 1551 | |
| 1552 | def show(self): |
| 1553 | import loxi.pp |
| 1554 | return loxi.pp.pp(self) |
| 1555 | |
| 1556 | def pretty_print(self, q): |
| 1557 | q.text("bsn_virtual_port_create_reply {") |
| 1558 | with q.group(): |
| 1559 | with q.indent(2): |
| 1560 | q.breakable() |
| 1561 | q.text("xid = "); |
| 1562 | if self.xid != None: |
| 1563 | q.text("%#x" % self.xid) |
| 1564 | else: |
| 1565 | q.text('None') |
| 1566 | q.text(","); q.breakable() |
| 1567 | q.text("status = "); |
| 1568 | q.text("%#x" % self.status) |
| 1569 | q.text(","); q.breakable() |
| 1570 | q.text("vport_no = "); |
| 1571 | q.text("%#x" % self.vport_no) |
| 1572 | q.breakable() |
| 1573 | q.text('}') |
| 1574 | |
| 1575 | class bsn_virtual_port_create_request(Message): |
| 1576 | version = 2 |
| 1577 | type = 4 |
| 1578 | experimenter = 6035143 |
| 1579 | subtype = 15 |
| 1580 | |
| 1581 | def __init__(self, xid=None, vport=None): |
| 1582 | self.xid = xid |
| 1583 | if vport != None: |
| 1584 | self.vport = vport |
| 1585 | else: |
| 1586 | self.vport = common.bsn_vport_q_in_q() |
| 1587 | |
| 1588 | def pack(self): |
| 1589 | packed = [] |
| 1590 | packed.append(struct.pack("!B", self.version)) |
| 1591 | packed.append(struct.pack("!B", self.type)) |
| 1592 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1593 | packed.append(struct.pack("!L", self.xid)) |
| 1594 | packed.append(struct.pack("!L", self.experimenter)) |
| 1595 | packed.append(struct.pack("!L", self.subtype)) |
| 1596 | packed.append(self.vport.pack()) |
| 1597 | length = sum([len(x) for x in packed]) |
| 1598 | packed[2] = struct.pack("!H", length) |
| 1599 | return ''.join(packed) |
| 1600 | |
| 1601 | @staticmethod |
| 1602 | def unpack(buf): |
| 1603 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1604 | obj = bsn_virtual_port_create_request() |
| 1605 | if type(buf) == loxi.generic_util.OFReader: |
| 1606 | reader = buf |
| 1607 | else: |
| 1608 | reader = loxi.generic_util.OFReader(buf) |
| 1609 | _version = reader.read("!B")[0] |
| 1610 | assert(_version == 2) |
| 1611 | _type = reader.read("!B")[0] |
| 1612 | assert(_type == 4) |
| 1613 | _length = reader.read("!H")[0] |
| 1614 | obj.xid = reader.read("!L")[0] |
| 1615 | _experimenter = reader.read("!L")[0] |
| 1616 | assert(_experimenter == 6035143) |
| 1617 | _subtype = reader.read("!L")[0] |
| 1618 | assert(_subtype == 15) |
| 1619 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 1620 | return obj |
| 1621 | |
| 1622 | def __eq__(self, other): |
| 1623 | if type(self) != type(other): return False |
| 1624 | if self.version != other.version: return False |
| 1625 | if self.type != other.type: return False |
| 1626 | if self.xid != other.xid: return False |
| 1627 | if self.vport != other.vport: return False |
| 1628 | return True |
| 1629 | |
| 1630 | def __ne__(self, other): |
| 1631 | return not self.__eq__(other) |
| 1632 | |
| 1633 | def __str__(self): |
| 1634 | return self.show() |
| 1635 | |
| 1636 | def show(self): |
| 1637 | import loxi.pp |
| 1638 | return loxi.pp.pp(self) |
| 1639 | |
| 1640 | def pretty_print(self, q): |
| 1641 | q.text("bsn_virtual_port_create_request {") |
| 1642 | with q.group(): |
| 1643 | with q.indent(2): |
| 1644 | q.breakable() |
| 1645 | q.text("xid = "); |
| 1646 | if self.xid != None: |
| 1647 | q.text("%#x" % self.xid) |
| 1648 | else: |
| 1649 | q.text('None') |
| 1650 | q.text(","); q.breakable() |
| 1651 | q.text("vport = "); |
| 1652 | q.pp(self.vport) |
| 1653 | q.breakable() |
| 1654 | q.text('}') |
| 1655 | |
| 1656 | class bsn_virtual_port_remove_reply(Message): |
| 1657 | version = 2 |
| 1658 | type = 4 |
| 1659 | experimenter = 6035143 |
| 1660 | subtype = 26 |
| 1661 | |
| 1662 | def __init__(self, xid=None, status=None): |
| 1663 | self.xid = xid |
| 1664 | if status != None: |
| 1665 | self.status = status |
| 1666 | else: |
| 1667 | self.status = 0 |
| 1668 | |
| 1669 | def pack(self): |
| 1670 | packed = [] |
| 1671 | packed.append(struct.pack("!B", self.version)) |
| 1672 | packed.append(struct.pack("!B", self.type)) |
| 1673 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1674 | packed.append(struct.pack("!L", self.xid)) |
| 1675 | packed.append(struct.pack("!L", self.experimenter)) |
| 1676 | packed.append(struct.pack("!L", self.subtype)) |
| 1677 | packed.append(struct.pack("!L", self.status)) |
| 1678 | length = sum([len(x) for x in packed]) |
| 1679 | packed[2] = struct.pack("!H", length) |
| 1680 | return ''.join(packed) |
| 1681 | |
| 1682 | @staticmethod |
| 1683 | def unpack(buf): |
| 1684 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1685 | obj = bsn_virtual_port_remove_reply() |
| 1686 | if type(buf) == loxi.generic_util.OFReader: |
| 1687 | reader = buf |
| 1688 | else: |
| 1689 | reader = loxi.generic_util.OFReader(buf) |
| 1690 | _version = reader.read("!B")[0] |
| 1691 | assert(_version == 2) |
| 1692 | _type = reader.read("!B")[0] |
| 1693 | assert(_type == 4) |
| 1694 | _length = reader.read("!H")[0] |
| 1695 | obj.xid = reader.read("!L")[0] |
| 1696 | _experimenter = reader.read("!L")[0] |
| 1697 | assert(_experimenter == 6035143) |
| 1698 | _subtype = reader.read("!L")[0] |
| 1699 | assert(_subtype == 26) |
| 1700 | obj.status = reader.read("!L")[0] |
| 1701 | return obj |
| 1702 | |
| 1703 | def __eq__(self, other): |
| 1704 | if type(self) != type(other): return False |
| 1705 | if self.version != other.version: return False |
| 1706 | if self.type != other.type: return False |
| 1707 | if self.xid != other.xid: return False |
| 1708 | if self.status != other.status: return False |
| 1709 | return True |
| 1710 | |
| 1711 | def __ne__(self, other): |
| 1712 | return not self.__eq__(other) |
| 1713 | |
| 1714 | def __str__(self): |
| 1715 | return self.show() |
| 1716 | |
| 1717 | def show(self): |
| 1718 | import loxi.pp |
| 1719 | return loxi.pp.pp(self) |
| 1720 | |
| 1721 | def pretty_print(self, q): |
| 1722 | q.text("bsn_virtual_port_remove_reply {") |
| 1723 | with q.group(): |
| 1724 | with q.indent(2): |
| 1725 | q.breakable() |
| 1726 | q.text("xid = "); |
| 1727 | if self.xid != None: |
| 1728 | q.text("%#x" % self.xid) |
| 1729 | else: |
| 1730 | q.text('None') |
| 1731 | q.text(","); q.breakable() |
| 1732 | q.text("status = "); |
| 1733 | q.text("%#x" % self.status) |
| 1734 | q.breakable() |
| 1735 | q.text('}') |
| 1736 | |
| 1737 | class bsn_virtual_port_remove_request(Message): |
| 1738 | version = 2 |
| 1739 | type = 4 |
| 1740 | experimenter = 6035143 |
| 1741 | subtype = 17 |
| 1742 | |
| 1743 | def __init__(self, xid=None, vport_no=None): |
| 1744 | self.xid = xid |
| 1745 | if vport_no != None: |
| 1746 | self.vport_no = vport_no |
| 1747 | else: |
| 1748 | self.vport_no = 0 |
| 1749 | |
| 1750 | def pack(self): |
| 1751 | packed = [] |
| 1752 | packed.append(struct.pack("!B", self.version)) |
| 1753 | packed.append(struct.pack("!B", self.type)) |
| 1754 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1755 | packed.append(struct.pack("!L", self.xid)) |
| 1756 | packed.append(struct.pack("!L", self.experimenter)) |
| 1757 | packed.append(struct.pack("!L", self.subtype)) |
| 1758 | packed.append(struct.pack("!L", self.vport_no)) |
| 1759 | length = sum([len(x) for x in packed]) |
| 1760 | packed[2] = struct.pack("!H", length) |
| 1761 | return ''.join(packed) |
| 1762 | |
| 1763 | @staticmethod |
| 1764 | def unpack(buf): |
| 1765 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1766 | obj = bsn_virtual_port_remove_request() |
| 1767 | if type(buf) == loxi.generic_util.OFReader: |
| 1768 | reader = buf |
| 1769 | else: |
| 1770 | reader = loxi.generic_util.OFReader(buf) |
| 1771 | _version = reader.read("!B")[0] |
| 1772 | assert(_version == 2) |
| 1773 | _type = reader.read("!B")[0] |
| 1774 | assert(_type == 4) |
| 1775 | _length = reader.read("!H")[0] |
| 1776 | obj.xid = reader.read("!L")[0] |
| 1777 | _experimenter = reader.read("!L")[0] |
| 1778 | assert(_experimenter == 6035143) |
| 1779 | _subtype = reader.read("!L")[0] |
| 1780 | assert(_subtype == 17) |
| 1781 | obj.vport_no = reader.read("!L")[0] |
| 1782 | return obj |
| 1783 | |
| 1784 | def __eq__(self, other): |
| 1785 | if type(self) != type(other): return False |
| 1786 | if self.version != other.version: return False |
| 1787 | if self.type != other.type: return False |
| 1788 | if self.xid != other.xid: return False |
| 1789 | if self.vport_no != other.vport_no: return False |
| 1790 | return True |
| 1791 | |
| 1792 | def __ne__(self, other): |
| 1793 | return not self.__eq__(other) |
| 1794 | |
| 1795 | def __str__(self): |
| 1796 | return self.show() |
| 1797 | |
| 1798 | def show(self): |
| 1799 | import loxi.pp |
| 1800 | return loxi.pp.pp(self) |
| 1801 | |
| 1802 | def pretty_print(self, q): |
| 1803 | q.text("bsn_virtual_port_remove_request {") |
| 1804 | with q.group(): |
| 1805 | with q.indent(2): |
| 1806 | q.breakable() |
| 1807 | q.text("xid = "); |
| 1808 | if self.xid != None: |
| 1809 | q.text("%#x" % self.xid) |
| 1810 | else: |
| 1811 | q.text('None') |
| 1812 | q.text(","); q.breakable() |
| 1813 | q.text("vport_no = "); |
| 1814 | q.text("%#x" % self.vport_no) |
| 1815 | q.breakable() |
| 1816 | q.text('}') |
| 1817 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1818 | class desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1819 | version = 2 |
| 1820 | type = 19 |
| 1821 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1822 | |
| 1823 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
| 1824 | self.xid = xid |
| 1825 | if flags != None: |
| 1826 | self.flags = flags |
| 1827 | else: |
| 1828 | self.flags = 0 |
| 1829 | if mfr_desc != None: |
| 1830 | self.mfr_desc = mfr_desc |
| 1831 | else: |
| 1832 | self.mfr_desc = "" |
| 1833 | if hw_desc != None: |
| 1834 | self.hw_desc = hw_desc |
| 1835 | else: |
| 1836 | self.hw_desc = "" |
| 1837 | if sw_desc != None: |
| 1838 | self.sw_desc = sw_desc |
| 1839 | else: |
| 1840 | self.sw_desc = "" |
| 1841 | if serial_num != None: |
| 1842 | self.serial_num = serial_num |
| 1843 | else: |
| 1844 | self.serial_num = "" |
| 1845 | if dp_desc != None: |
| 1846 | self.dp_desc = dp_desc |
| 1847 | else: |
| 1848 | self.dp_desc = "" |
| 1849 | |
| 1850 | def pack(self): |
| 1851 | packed = [] |
| 1852 | packed.append(struct.pack("!B", self.version)) |
| 1853 | packed.append(struct.pack("!B", self.type)) |
| 1854 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1855 | packed.append(struct.pack("!L", self.xid)) |
| 1856 | packed.append(struct.pack("!H", self.stats_type)) |
| 1857 | packed.append(struct.pack("!H", self.flags)) |
| 1858 | packed.append('\x00' * 4) |
| 1859 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 1860 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 1861 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 1862 | packed.append(struct.pack("!32s", self.serial_num)) |
| 1863 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 1864 | length = sum([len(x) for x in packed]) |
| 1865 | packed[2] = struct.pack("!H", length) |
| 1866 | return ''.join(packed) |
| 1867 | |
| 1868 | @staticmethod |
| 1869 | def unpack(buf): |
| 1870 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1871 | obj = desc_stats_reply() |
| 1872 | if type(buf) == loxi.generic_util.OFReader: |
| 1873 | reader = buf |
| 1874 | else: |
| 1875 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1876 | _version = reader.read("!B")[0] |
| 1877 | assert(_version == 2) |
| 1878 | _type = reader.read("!B")[0] |
| 1879 | assert(_type == 19) |
| 1880 | _length = reader.read("!H")[0] |
| 1881 | obj.xid = reader.read("!L")[0] |
| 1882 | _stats_type = reader.read("!H")[0] |
| 1883 | assert(_stats_type == 0) |
| 1884 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1885 | reader.skip(4) |
| 1886 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1887 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1888 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1889 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 1890 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 1891 | return obj |
| 1892 | |
| 1893 | def __eq__(self, other): |
| 1894 | if type(self) != type(other): return False |
| 1895 | if self.version != other.version: return False |
| 1896 | if self.type != other.type: return False |
| 1897 | if self.xid != other.xid: return False |
| 1898 | if self.flags != other.flags: return False |
| 1899 | if self.mfr_desc != other.mfr_desc: return False |
| 1900 | if self.hw_desc != other.hw_desc: return False |
| 1901 | if self.sw_desc != other.sw_desc: return False |
| 1902 | if self.serial_num != other.serial_num: return False |
| 1903 | if self.dp_desc != other.dp_desc: return False |
| 1904 | return True |
| 1905 | |
| 1906 | def __ne__(self, other): |
| 1907 | return not self.__eq__(other) |
| 1908 | |
| 1909 | def __str__(self): |
| 1910 | return self.show() |
| 1911 | |
| 1912 | def show(self): |
| 1913 | import loxi.pp |
| 1914 | return loxi.pp.pp(self) |
| 1915 | |
| 1916 | def pretty_print(self, q): |
| 1917 | q.text("desc_stats_reply {") |
| 1918 | with q.group(): |
| 1919 | with q.indent(2): |
| 1920 | q.breakable() |
| 1921 | q.text("xid = "); |
| 1922 | if self.xid != None: |
| 1923 | q.text("%#x" % self.xid) |
| 1924 | else: |
| 1925 | q.text('None') |
| 1926 | q.text(","); q.breakable() |
| 1927 | q.text("flags = "); |
| 1928 | q.text("%#x" % self.flags) |
| 1929 | q.text(","); q.breakable() |
| 1930 | q.text("mfr_desc = "); |
| 1931 | q.pp(self.mfr_desc) |
| 1932 | q.text(","); q.breakable() |
| 1933 | q.text("hw_desc = "); |
| 1934 | q.pp(self.hw_desc) |
| 1935 | q.text(","); q.breakable() |
| 1936 | q.text("sw_desc = "); |
| 1937 | q.pp(self.sw_desc) |
| 1938 | q.text(","); q.breakable() |
| 1939 | q.text("serial_num = "); |
| 1940 | q.pp(self.serial_num) |
| 1941 | q.text(","); q.breakable() |
| 1942 | q.text("dp_desc = "); |
| 1943 | q.pp(self.dp_desc) |
| 1944 | q.breakable() |
| 1945 | q.text('}') |
| 1946 | |
| 1947 | class desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1948 | version = 2 |
| 1949 | type = 18 |
| 1950 | stats_type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1951 | |
| 1952 | def __init__(self, xid=None, flags=None): |
| 1953 | self.xid = xid |
| 1954 | if flags != None: |
| 1955 | self.flags = flags |
| 1956 | else: |
| 1957 | self.flags = 0 |
| 1958 | |
| 1959 | def pack(self): |
| 1960 | packed = [] |
| 1961 | packed.append(struct.pack("!B", self.version)) |
| 1962 | packed.append(struct.pack("!B", self.type)) |
| 1963 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1964 | packed.append(struct.pack("!L", self.xid)) |
| 1965 | packed.append(struct.pack("!H", self.stats_type)) |
| 1966 | packed.append(struct.pack("!H", self.flags)) |
| 1967 | packed.append('\x00' * 4) |
| 1968 | length = sum([len(x) for x in packed]) |
| 1969 | packed[2] = struct.pack("!H", length) |
| 1970 | return ''.join(packed) |
| 1971 | |
| 1972 | @staticmethod |
| 1973 | def unpack(buf): |
| 1974 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1975 | obj = desc_stats_request() |
| 1976 | if type(buf) == loxi.generic_util.OFReader: |
| 1977 | reader = buf |
| 1978 | else: |
| 1979 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1980 | _version = reader.read("!B")[0] |
| 1981 | assert(_version == 2) |
| 1982 | _type = reader.read("!B")[0] |
| 1983 | assert(_type == 18) |
| 1984 | _length = reader.read("!H")[0] |
| 1985 | obj.xid = reader.read("!L")[0] |
| 1986 | _stats_type = reader.read("!H")[0] |
| 1987 | assert(_stats_type == 0) |
| 1988 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1989 | reader.skip(4) |
| 1990 | return obj |
| 1991 | |
| 1992 | def __eq__(self, other): |
| 1993 | if type(self) != type(other): return False |
| 1994 | if self.version != other.version: return False |
| 1995 | if self.type != other.type: return False |
| 1996 | if self.xid != other.xid: return False |
| 1997 | if self.flags != other.flags: return False |
| 1998 | return True |
| 1999 | |
| 2000 | def __ne__(self, other): |
| 2001 | return not self.__eq__(other) |
| 2002 | |
| 2003 | def __str__(self): |
| 2004 | return self.show() |
| 2005 | |
| 2006 | def show(self): |
| 2007 | import loxi.pp |
| 2008 | return loxi.pp.pp(self) |
| 2009 | |
| 2010 | def pretty_print(self, q): |
| 2011 | q.text("desc_stats_request {") |
| 2012 | with q.group(): |
| 2013 | with q.indent(2): |
| 2014 | q.breakable() |
| 2015 | q.text("xid = "); |
| 2016 | if self.xid != None: |
| 2017 | q.text("%#x" % self.xid) |
| 2018 | else: |
| 2019 | q.text('None') |
| 2020 | q.text(","); q.breakable() |
| 2021 | q.text("flags = "); |
| 2022 | q.text("%#x" % self.flags) |
| 2023 | q.breakable() |
| 2024 | q.text('}') |
| 2025 | |
| 2026 | class echo_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2027 | version = 2 |
| 2028 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2029 | |
| 2030 | def __init__(self, xid=None, data=None): |
| 2031 | self.xid = xid |
| 2032 | if data != None: |
| 2033 | self.data = data |
| 2034 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2035 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2036 | |
| 2037 | def pack(self): |
| 2038 | packed = [] |
| 2039 | packed.append(struct.pack("!B", self.version)) |
| 2040 | packed.append(struct.pack("!B", self.type)) |
| 2041 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2042 | packed.append(struct.pack("!L", self.xid)) |
| 2043 | packed.append(self.data) |
| 2044 | length = sum([len(x) for x in packed]) |
| 2045 | packed[2] = struct.pack("!H", length) |
| 2046 | return ''.join(packed) |
| 2047 | |
| 2048 | @staticmethod |
| 2049 | def unpack(buf): |
| 2050 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2051 | obj = echo_reply() |
| 2052 | if type(buf) == loxi.generic_util.OFReader: |
| 2053 | reader = buf |
| 2054 | else: |
| 2055 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2056 | _version = reader.read("!B")[0] |
| 2057 | assert(_version == 2) |
| 2058 | _type = reader.read("!B")[0] |
| 2059 | assert(_type == 3) |
| 2060 | _length = reader.read("!H")[0] |
| 2061 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2062 | obj.data = str(reader.read_all()) |
| 2063 | return obj |
| 2064 | |
| 2065 | def __eq__(self, other): |
| 2066 | if type(self) != type(other): return False |
| 2067 | if self.version != other.version: return False |
| 2068 | if self.type != other.type: return False |
| 2069 | if self.xid != other.xid: return False |
| 2070 | if self.data != other.data: return False |
| 2071 | return True |
| 2072 | |
| 2073 | def __ne__(self, other): |
| 2074 | return not self.__eq__(other) |
| 2075 | |
| 2076 | def __str__(self): |
| 2077 | return self.show() |
| 2078 | |
| 2079 | def show(self): |
| 2080 | import loxi.pp |
| 2081 | return loxi.pp.pp(self) |
| 2082 | |
| 2083 | def pretty_print(self, q): |
| 2084 | q.text("echo_reply {") |
| 2085 | with q.group(): |
| 2086 | with q.indent(2): |
| 2087 | q.breakable() |
| 2088 | q.text("xid = "); |
| 2089 | if self.xid != None: |
| 2090 | q.text("%#x" % self.xid) |
| 2091 | else: |
| 2092 | q.text('None') |
| 2093 | q.text(","); q.breakable() |
| 2094 | q.text("data = "); |
| 2095 | q.pp(self.data) |
| 2096 | q.breakable() |
| 2097 | q.text('}') |
| 2098 | |
| 2099 | class echo_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2100 | version = 2 |
| 2101 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2102 | |
| 2103 | def __init__(self, xid=None, data=None): |
| 2104 | self.xid = xid |
| 2105 | if data != None: |
| 2106 | self.data = data |
| 2107 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2108 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2109 | |
| 2110 | def pack(self): |
| 2111 | packed = [] |
| 2112 | packed.append(struct.pack("!B", self.version)) |
| 2113 | packed.append(struct.pack("!B", self.type)) |
| 2114 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2115 | packed.append(struct.pack("!L", self.xid)) |
| 2116 | packed.append(self.data) |
| 2117 | length = sum([len(x) for x in packed]) |
| 2118 | packed[2] = struct.pack("!H", length) |
| 2119 | return ''.join(packed) |
| 2120 | |
| 2121 | @staticmethod |
| 2122 | def unpack(buf): |
| 2123 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2124 | obj = echo_request() |
| 2125 | if type(buf) == loxi.generic_util.OFReader: |
| 2126 | reader = buf |
| 2127 | else: |
| 2128 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2129 | _version = reader.read("!B")[0] |
| 2130 | assert(_version == 2) |
| 2131 | _type = reader.read("!B")[0] |
| 2132 | assert(_type == 2) |
| 2133 | _length = reader.read("!H")[0] |
| 2134 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2135 | obj.data = str(reader.read_all()) |
| 2136 | return obj |
| 2137 | |
| 2138 | def __eq__(self, other): |
| 2139 | if type(self) != type(other): return False |
| 2140 | if self.version != other.version: return False |
| 2141 | if self.type != other.type: return False |
| 2142 | if self.xid != other.xid: return False |
| 2143 | if self.data != other.data: return False |
| 2144 | return True |
| 2145 | |
| 2146 | def __ne__(self, other): |
| 2147 | return not self.__eq__(other) |
| 2148 | |
| 2149 | def __str__(self): |
| 2150 | return self.show() |
| 2151 | |
| 2152 | def show(self): |
| 2153 | import loxi.pp |
| 2154 | return loxi.pp.pp(self) |
| 2155 | |
| 2156 | def pretty_print(self, q): |
| 2157 | q.text("echo_request {") |
| 2158 | with q.group(): |
| 2159 | with q.indent(2): |
| 2160 | q.breakable() |
| 2161 | q.text("xid = "); |
| 2162 | if self.xid != None: |
| 2163 | q.text("%#x" % self.xid) |
| 2164 | else: |
| 2165 | q.text('None') |
| 2166 | q.text(","); q.breakable() |
| 2167 | q.text("data = "); |
| 2168 | q.pp(self.data) |
| 2169 | q.breakable() |
| 2170 | q.text('}') |
| 2171 | |
| 2172 | class error_msg(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2173 | version = 2 |
| 2174 | type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2175 | |
| 2176 | def __init__(self, xid=None, err_type=None, code=None, data=None): |
| 2177 | self.xid = xid |
| 2178 | if err_type != None: |
| 2179 | self.err_type = err_type |
| 2180 | else: |
| 2181 | self.err_type = 0 |
| 2182 | if code != None: |
| 2183 | self.code = code |
| 2184 | else: |
| 2185 | self.code = 0 |
| 2186 | if data != None: |
| 2187 | self.data = data |
| 2188 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2189 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2190 | |
| 2191 | def pack(self): |
| 2192 | packed = [] |
| 2193 | packed.append(struct.pack("!B", self.version)) |
| 2194 | packed.append(struct.pack("!B", self.type)) |
| 2195 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2196 | packed.append(struct.pack("!L", self.xid)) |
| 2197 | packed.append(struct.pack("!H", self.err_type)) |
| 2198 | packed.append(struct.pack("!H", self.code)) |
| 2199 | packed.append(self.data) |
| 2200 | length = sum([len(x) for x in packed]) |
| 2201 | packed[2] = struct.pack("!H", length) |
| 2202 | return ''.join(packed) |
| 2203 | |
| 2204 | @staticmethod |
| 2205 | def unpack(buf): |
| 2206 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2207 | obj = error_msg() |
| 2208 | if type(buf) == loxi.generic_util.OFReader: |
| 2209 | reader = buf |
| 2210 | else: |
| 2211 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2212 | _version = reader.read("!B")[0] |
| 2213 | assert(_version == 2) |
| 2214 | _type = reader.read("!B")[0] |
| 2215 | assert(_type == 1) |
| 2216 | _length = reader.read("!H")[0] |
| 2217 | obj.xid = reader.read("!L")[0] |
| 2218 | obj.err_type = reader.read("!H")[0] |
| 2219 | obj.code = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2220 | obj.data = str(reader.read_all()) |
| 2221 | return obj |
| 2222 | |
| 2223 | def __eq__(self, other): |
| 2224 | if type(self) != type(other): return False |
| 2225 | if self.version != other.version: return False |
| 2226 | if self.type != other.type: return False |
| 2227 | if self.xid != other.xid: return False |
| 2228 | if self.err_type != other.err_type: return False |
| 2229 | if self.code != other.code: return False |
| 2230 | if self.data != other.data: return False |
| 2231 | return True |
| 2232 | |
| 2233 | def __ne__(self, other): |
| 2234 | return not self.__eq__(other) |
| 2235 | |
| 2236 | def __str__(self): |
| 2237 | return self.show() |
| 2238 | |
| 2239 | def show(self): |
| 2240 | import loxi.pp |
| 2241 | return loxi.pp.pp(self) |
| 2242 | |
| 2243 | def pretty_print(self, q): |
| 2244 | q.text("error_msg {") |
| 2245 | with q.group(): |
| 2246 | with q.indent(2): |
| 2247 | q.breakable() |
| 2248 | q.text("xid = "); |
| 2249 | if self.xid != None: |
| 2250 | q.text("%#x" % self.xid) |
| 2251 | else: |
| 2252 | q.text('None') |
| 2253 | q.text(","); q.breakable() |
| 2254 | q.text("err_type = "); |
| 2255 | q.text("%#x" % self.err_type) |
| 2256 | q.text(","); q.breakable() |
| 2257 | q.text("code = "); |
| 2258 | q.text("%#x" % self.code) |
| 2259 | q.text(","); q.breakable() |
| 2260 | q.text("data = "); |
| 2261 | q.pp(self.data) |
| 2262 | q.breakable() |
| 2263 | q.text('}') |
| 2264 | |
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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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 == 2) |
| 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 = 2 |
| 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, 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 packet_count != None: |
| 3433 | self.packet_count = packet_count |
| 3434 | else: |
| 3435 | self.packet_count = 0 |
| 3436 | if byte_count != None: |
| 3437 | self.byte_count = byte_count |
| 3438 | else: |
| 3439 | self.byte_count = 0 |
| 3440 | if match != None: |
| 3441 | self.match = match |
| 3442 | else: |
| 3443 | self.match = common.match() |
| 3444 | |
| 3445 | def pack(self): |
| 3446 | packed = [] |
| 3447 | packed.append(struct.pack("!B", self.version)) |
| 3448 | packed.append(struct.pack("!B", self.type)) |
| 3449 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3450 | packed.append(struct.pack("!L", self.xid)) |
| 3451 | packed.append(struct.pack("!Q", self.cookie)) |
| 3452 | packed.append(struct.pack("!H", self.priority)) |
| 3453 | packed.append(struct.pack("!B", self.reason)) |
| 3454 | packed.append(struct.pack("!B", self.table_id)) |
| 3455 | packed.append(struct.pack("!L", self.duration_sec)) |
| 3456 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 3457 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3458 | packed.append('\x00' * 2) |
| 3459 | packed.append(struct.pack("!Q", self.packet_count)) |
| 3460 | packed.append(struct.pack("!Q", self.byte_count)) |
| 3461 | packed.append(self.match.pack()) |
| 3462 | length = sum([len(x) for x in packed]) |
| 3463 | packed[2] = struct.pack("!H", length) |
| 3464 | return ''.join(packed) |
| 3465 | |
| 3466 | @staticmethod |
| 3467 | def unpack(buf): |
| 3468 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3469 | obj = flow_removed() |
| 3470 | if type(buf) == loxi.generic_util.OFReader: |
| 3471 | reader = buf |
| 3472 | else: |
| 3473 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3474 | _version = reader.read("!B")[0] |
| 3475 | assert(_version == 2) |
| 3476 | _type = reader.read("!B")[0] |
| 3477 | assert(_type == 11) |
| 3478 | _length = reader.read("!H")[0] |
| 3479 | obj.xid = reader.read("!L")[0] |
| 3480 | obj.cookie = reader.read("!Q")[0] |
| 3481 | obj.priority = reader.read("!H")[0] |
| 3482 | obj.reason = reader.read("!B")[0] |
| 3483 | obj.table_id = reader.read("!B")[0] |
| 3484 | obj.duration_sec = reader.read("!L")[0] |
| 3485 | obj.duration_nsec = reader.read("!L")[0] |
| 3486 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3487 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3488 | obj.packet_count = reader.read("!Q")[0] |
| 3489 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3490 | obj.match = common.match.unpack(reader) |
| 3491 | return obj |
| 3492 | |
| 3493 | def __eq__(self, other): |
| 3494 | if type(self) != type(other): return False |
| 3495 | if self.version != other.version: return False |
| 3496 | if self.type != other.type: return False |
| 3497 | if self.xid != other.xid: return False |
| 3498 | if self.cookie != other.cookie: return False |
| 3499 | if self.priority != other.priority: return False |
| 3500 | if self.reason != other.reason: return False |
| 3501 | if self.table_id != other.table_id: return False |
| 3502 | if self.duration_sec != other.duration_sec: return False |
| 3503 | if self.duration_nsec != other.duration_nsec: return False |
| 3504 | if self.idle_timeout != other.idle_timeout: return False |
| 3505 | if self.packet_count != other.packet_count: return False |
| 3506 | if self.byte_count != other.byte_count: return False |
| 3507 | if self.match != other.match: return False |
| 3508 | return True |
| 3509 | |
| 3510 | def __ne__(self, other): |
| 3511 | return not self.__eq__(other) |
| 3512 | |
| 3513 | def __str__(self): |
| 3514 | return self.show() |
| 3515 | |
| 3516 | def show(self): |
| 3517 | import loxi.pp |
| 3518 | return loxi.pp.pp(self) |
| 3519 | |
| 3520 | def pretty_print(self, q): |
| 3521 | q.text("flow_removed {") |
| 3522 | with q.group(): |
| 3523 | with q.indent(2): |
| 3524 | q.breakable() |
| 3525 | q.text("xid = "); |
| 3526 | if self.xid != None: |
| 3527 | q.text("%#x" % self.xid) |
| 3528 | else: |
| 3529 | q.text('None') |
| 3530 | q.text(","); q.breakable() |
| 3531 | q.text("cookie = "); |
| 3532 | q.text("%#x" % self.cookie) |
| 3533 | q.text(","); q.breakable() |
| 3534 | q.text("priority = "); |
| 3535 | q.text("%#x" % self.priority) |
| 3536 | q.text(","); q.breakable() |
| 3537 | q.text("reason = "); |
| 3538 | q.text("%#x" % self.reason) |
| 3539 | q.text(","); q.breakable() |
| 3540 | q.text("table_id = "); |
| 3541 | q.text("%#x" % self.table_id) |
| 3542 | q.text(","); q.breakable() |
| 3543 | q.text("duration_sec = "); |
| 3544 | q.text("%#x" % self.duration_sec) |
| 3545 | q.text(","); q.breakable() |
| 3546 | q.text("duration_nsec = "); |
| 3547 | q.text("%#x" % self.duration_nsec) |
| 3548 | q.text(","); q.breakable() |
| 3549 | q.text("idle_timeout = "); |
| 3550 | q.text("%#x" % self.idle_timeout) |
| 3551 | q.text(","); q.breakable() |
| 3552 | q.text("packet_count = "); |
| 3553 | q.text("%#x" % self.packet_count) |
| 3554 | q.text(","); q.breakable() |
| 3555 | q.text("byte_count = "); |
| 3556 | q.text("%#x" % self.byte_count) |
| 3557 | q.text(","); q.breakable() |
| 3558 | q.text("match = "); |
| 3559 | q.pp(self.match) |
| 3560 | q.breakable() |
| 3561 | q.text('}') |
| 3562 | |
| 3563 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3564 | version = 2 |
| 3565 | type = 19 |
| 3566 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3567 | |
| 3568 | def __init__(self, xid=None, flags=None, entries=None): |
| 3569 | self.xid = xid |
| 3570 | if flags != None: |
| 3571 | self.flags = flags |
| 3572 | else: |
| 3573 | self.flags = 0 |
| 3574 | if entries != None: |
| 3575 | self.entries = entries |
| 3576 | else: |
| 3577 | self.entries = [] |
| 3578 | |
| 3579 | def pack(self): |
| 3580 | packed = [] |
| 3581 | packed.append(struct.pack("!B", self.version)) |
| 3582 | packed.append(struct.pack("!B", self.type)) |
| 3583 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3584 | packed.append(struct.pack("!L", self.xid)) |
| 3585 | packed.append(struct.pack("!H", self.stats_type)) |
| 3586 | packed.append(struct.pack("!H", self.flags)) |
| 3587 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3588 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3589 | length = sum([len(x) for x in packed]) |
| 3590 | packed[2] = struct.pack("!H", length) |
| 3591 | return ''.join(packed) |
| 3592 | |
| 3593 | @staticmethod |
| 3594 | def unpack(buf): |
| 3595 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3596 | obj = flow_stats_reply() |
| 3597 | if type(buf) == loxi.generic_util.OFReader: |
| 3598 | reader = buf |
| 3599 | else: |
| 3600 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3601 | _version = reader.read("!B")[0] |
| 3602 | assert(_version == 2) |
| 3603 | _type = reader.read("!B")[0] |
| 3604 | assert(_type == 19) |
| 3605 | _length = reader.read("!H")[0] |
| 3606 | obj.xid = reader.read("!L")[0] |
| 3607 | _stats_type = reader.read("!H")[0] |
| 3608 | assert(_stats_type == 1) |
| 3609 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3610 | reader.skip(4) |
| 3611 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
| 3612 | return obj |
| 3613 | |
| 3614 | def __eq__(self, other): |
| 3615 | if type(self) != type(other): return False |
| 3616 | if self.version != other.version: return False |
| 3617 | if self.type != other.type: return False |
| 3618 | if self.xid != other.xid: return False |
| 3619 | if self.flags != other.flags: return False |
| 3620 | if self.entries != other.entries: return False |
| 3621 | return True |
| 3622 | |
| 3623 | def __ne__(self, other): |
| 3624 | return not self.__eq__(other) |
| 3625 | |
| 3626 | def __str__(self): |
| 3627 | return self.show() |
| 3628 | |
| 3629 | def show(self): |
| 3630 | import loxi.pp |
| 3631 | return loxi.pp.pp(self) |
| 3632 | |
| 3633 | def pretty_print(self, q): |
| 3634 | q.text("flow_stats_reply {") |
| 3635 | with q.group(): |
| 3636 | with q.indent(2): |
| 3637 | q.breakable() |
| 3638 | q.text("xid = "); |
| 3639 | if self.xid != None: |
| 3640 | q.text("%#x" % self.xid) |
| 3641 | else: |
| 3642 | q.text('None') |
| 3643 | q.text(","); q.breakable() |
| 3644 | q.text("flags = "); |
| 3645 | q.text("%#x" % self.flags) |
| 3646 | q.text(","); q.breakable() |
| 3647 | q.text("entries = "); |
| 3648 | q.pp(self.entries) |
| 3649 | q.breakable() |
| 3650 | q.text('}') |
| 3651 | |
| 3652 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3653 | version = 2 |
| 3654 | type = 18 |
| 3655 | stats_type = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3656 | |
| 3657 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 3658 | self.xid = xid |
| 3659 | if flags != None: |
| 3660 | self.flags = flags |
| 3661 | else: |
| 3662 | self.flags = 0 |
| 3663 | if table_id != None: |
| 3664 | self.table_id = table_id |
| 3665 | else: |
| 3666 | self.table_id = 0 |
| 3667 | if out_port != None: |
| 3668 | self.out_port = out_port |
| 3669 | else: |
| 3670 | self.out_port = 0 |
| 3671 | if out_group != None: |
| 3672 | self.out_group = out_group |
| 3673 | else: |
| 3674 | self.out_group = 0 |
| 3675 | if cookie != None: |
| 3676 | self.cookie = cookie |
| 3677 | else: |
| 3678 | self.cookie = 0 |
| 3679 | if cookie_mask != None: |
| 3680 | self.cookie_mask = cookie_mask |
| 3681 | else: |
| 3682 | self.cookie_mask = 0 |
| 3683 | if match != None: |
| 3684 | self.match = match |
| 3685 | else: |
| 3686 | self.match = common.match() |
| 3687 | |
| 3688 | def pack(self): |
| 3689 | packed = [] |
| 3690 | packed.append(struct.pack("!B", self.version)) |
| 3691 | packed.append(struct.pack("!B", self.type)) |
| 3692 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3693 | packed.append(struct.pack("!L", self.xid)) |
| 3694 | packed.append(struct.pack("!H", self.stats_type)) |
| 3695 | packed.append(struct.pack("!H", self.flags)) |
| 3696 | packed.append('\x00' * 4) |
| 3697 | packed.append(struct.pack("!B", self.table_id)) |
| 3698 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3699 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3700 | packed.append(struct.pack("!L", self.out_group)) |
| 3701 | packed.append('\x00' * 4) |
| 3702 | packed.append(struct.pack("!Q", self.cookie)) |
| 3703 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 3704 | packed.append(self.match.pack()) |
| 3705 | length = sum([len(x) for x in packed]) |
| 3706 | packed[2] = struct.pack("!H", length) |
| 3707 | return ''.join(packed) |
| 3708 | |
| 3709 | @staticmethod |
| 3710 | def unpack(buf): |
| 3711 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3712 | obj = flow_stats_request() |
| 3713 | if type(buf) == loxi.generic_util.OFReader: |
| 3714 | reader = buf |
| 3715 | else: |
| 3716 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3717 | _version = reader.read("!B")[0] |
| 3718 | assert(_version == 2) |
| 3719 | _type = reader.read("!B")[0] |
| 3720 | assert(_type == 18) |
| 3721 | _length = reader.read("!H")[0] |
| 3722 | obj.xid = reader.read("!L")[0] |
| 3723 | _stats_type = reader.read("!H")[0] |
| 3724 | assert(_stats_type == 1) |
| 3725 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3726 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3727 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3728 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3729 | obj.out_port = util.unpack_port_no(reader) |
| 3730 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3731 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3732 | obj.cookie = reader.read("!Q")[0] |
| 3733 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3734 | obj.match = common.match.unpack(reader) |
| 3735 | return obj |
| 3736 | |
| 3737 | def __eq__(self, other): |
| 3738 | if type(self) != type(other): return False |
| 3739 | if self.version != other.version: return False |
| 3740 | if self.type != other.type: return False |
| 3741 | if self.xid != other.xid: return False |
| 3742 | if self.flags != other.flags: return False |
| 3743 | if self.table_id != other.table_id: return False |
| 3744 | if self.out_port != other.out_port: return False |
| 3745 | if self.out_group != other.out_group: return False |
| 3746 | if self.cookie != other.cookie: return False |
| 3747 | if self.cookie_mask != other.cookie_mask: return False |
| 3748 | if self.match != other.match: return False |
| 3749 | return True |
| 3750 | |
| 3751 | def __ne__(self, other): |
| 3752 | return not self.__eq__(other) |
| 3753 | |
| 3754 | def __str__(self): |
| 3755 | return self.show() |
| 3756 | |
| 3757 | def show(self): |
| 3758 | import loxi.pp |
| 3759 | return loxi.pp.pp(self) |
| 3760 | |
| 3761 | def pretty_print(self, q): |
| 3762 | q.text("flow_stats_request {") |
| 3763 | with q.group(): |
| 3764 | with q.indent(2): |
| 3765 | q.breakable() |
| 3766 | q.text("xid = "); |
| 3767 | if self.xid != None: |
| 3768 | q.text("%#x" % self.xid) |
| 3769 | else: |
| 3770 | q.text('None') |
| 3771 | q.text(","); q.breakable() |
| 3772 | q.text("flags = "); |
| 3773 | q.text("%#x" % self.flags) |
| 3774 | q.text(","); q.breakable() |
| 3775 | q.text("table_id = "); |
| 3776 | q.text("%#x" % self.table_id) |
| 3777 | q.text(","); q.breakable() |
| 3778 | q.text("out_port = "); |
| 3779 | q.text(util.pretty_port(self.out_port)) |
| 3780 | q.text(","); q.breakable() |
| 3781 | q.text("out_group = "); |
| 3782 | q.text("%#x" % self.out_group) |
| 3783 | q.text(","); q.breakable() |
| 3784 | q.text("cookie = "); |
| 3785 | q.text("%#x" % self.cookie) |
| 3786 | q.text(","); q.breakable() |
| 3787 | q.text("cookie_mask = "); |
| 3788 | q.text("%#x" % self.cookie_mask) |
| 3789 | q.text(","); q.breakable() |
| 3790 | q.text("match = "); |
| 3791 | q.pp(self.match) |
| 3792 | q.breakable() |
| 3793 | q.text('}') |
| 3794 | |
| 3795 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3796 | version = 2 |
| 3797 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3798 | |
| 3799 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 3800 | self.xid = xid |
| 3801 | if flags != None: |
| 3802 | self.flags = flags |
| 3803 | else: |
| 3804 | self.flags = 0 |
| 3805 | if miss_send_len != None: |
| 3806 | self.miss_send_len = miss_send_len |
| 3807 | else: |
| 3808 | self.miss_send_len = 0 |
| 3809 | |
| 3810 | def pack(self): |
| 3811 | packed = [] |
| 3812 | packed.append(struct.pack("!B", self.version)) |
| 3813 | packed.append(struct.pack("!B", self.type)) |
| 3814 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3815 | packed.append(struct.pack("!L", self.xid)) |
| 3816 | packed.append(struct.pack("!H", self.flags)) |
| 3817 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 3818 | length = sum([len(x) for x in packed]) |
| 3819 | packed[2] = struct.pack("!H", length) |
| 3820 | return ''.join(packed) |
| 3821 | |
| 3822 | @staticmethod |
| 3823 | def unpack(buf): |
| 3824 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3825 | obj = get_config_reply() |
| 3826 | if type(buf) == loxi.generic_util.OFReader: |
| 3827 | reader = buf |
| 3828 | else: |
| 3829 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3830 | _version = reader.read("!B")[0] |
| 3831 | assert(_version == 2) |
| 3832 | _type = reader.read("!B")[0] |
| 3833 | assert(_type == 8) |
| 3834 | _length = reader.read("!H")[0] |
| 3835 | obj.xid = reader.read("!L")[0] |
| 3836 | obj.flags = reader.read("!H")[0] |
| 3837 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3838 | return obj |
| 3839 | |
| 3840 | def __eq__(self, other): |
| 3841 | if type(self) != type(other): return False |
| 3842 | if self.version != other.version: return False |
| 3843 | if self.type != other.type: return False |
| 3844 | if self.xid != other.xid: return False |
| 3845 | if self.flags != other.flags: return False |
| 3846 | if self.miss_send_len != other.miss_send_len: return False |
| 3847 | return True |
| 3848 | |
| 3849 | def __ne__(self, other): |
| 3850 | return not self.__eq__(other) |
| 3851 | |
| 3852 | def __str__(self): |
| 3853 | return self.show() |
| 3854 | |
| 3855 | def show(self): |
| 3856 | import loxi.pp |
| 3857 | return loxi.pp.pp(self) |
| 3858 | |
| 3859 | def pretty_print(self, q): |
| 3860 | q.text("get_config_reply {") |
| 3861 | with q.group(): |
| 3862 | with q.indent(2): |
| 3863 | q.breakable() |
| 3864 | q.text("xid = "); |
| 3865 | if self.xid != None: |
| 3866 | q.text("%#x" % self.xid) |
| 3867 | else: |
| 3868 | q.text('None') |
| 3869 | q.text(","); q.breakable() |
| 3870 | q.text("flags = "); |
| 3871 | q.text("%#x" % self.flags) |
| 3872 | q.text(","); q.breakable() |
| 3873 | q.text("miss_send_len = "); |
| 3874 | q.text("%#x" % self.miss_send_len) |
| 3875 | q.breakable() |
| 3876 | q.text('}') |
| 3877 | |
| 3878 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3879 | version = 2 |
| 3880 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3881 | |
| 3882 | def __init__(self, xid=None): |
| 3883 | self.xid = xid |
| 3884 | |
| 3885 | def pack(self): |
| 3886 | packed = [] |
| 3887 | packed.append(struct.pack("!B", self.version)) |
| 3888 | packed.append(struct.pack("!B", self.type)) |
| 3889 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3890 | packed.append(struct.pack("!L", self.xid)) |
| 3891 | length = sum([len(x) for x in packed]) |
| 3892 | packed[2] = struct.pack("!H", length) |
| 3893 | return ''.join(packed) |
| 3894 | |
| 3895 | @staticmethod |
| 3896 | def unpack(buf): |
| 3897 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3898 | obj = get_config_request() |
| 3899 | if type(buf) == loxi.generic_util.OFReader: |
| 3900 | reader = buf |
| 3901 | else: |
| 3902 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3903 | _version = reader.read("!B")[0] |
| 3904 | assert(_version == 2) |
| 3905 | _type = reader.read("!B")[0] |
| 3906 | assert(_type == 7) |
| 3907 | _length = reader.read("!H")[0] |
| 3908 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3909 | return obj |
| 3910 | |
| 3911 | def __eq__(self, other): |
| 3912 | if type(self) != type(other): return False |
| 3913 | if self.version != other.version: return False |
| 3914 | if self.type != other.type: return False |
| 3915 | if self.xid != other.xid: return False |
| 3916 | return True |
| 3917 | |
| 3918 | def __ne__(self, other): |
| 3919 | return not self.__eq__(other) |
| 3920 | |
| 3921 | def __str__(self): |
| 3922 | return self.show() |
| 3923 | |
| 3924 | def show(self): |
| 3925 | import loxi.pp |
| 3926 | return loxi.pp.pp(self) |
| 3927 | |
| 3928 | def pretty_print(self, q): |
| 3929 | q.text("get_config_request {") |
| 3930 | with q.group(): |
| 3931 | with q.indent(2): |
| 3932 | q.breakable() |
| 3933 | q.text("xid = "); |
| 3934 | if self.xid != None: |
| 3935 | q.text("%#x" % self.xid) |
| 3936 | else: |
| 3937 | q.text('None') |
| 3938 | q.breakable() |
| 3939 | q.text('}') |
| 3940 | |
| 3941 | class group_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3942 | version = 2 |
| 3943 | type = 19 |
| 3944 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3945 | |
| 3946 | def __init__(self, xid=None, flags=None, entries=None): |
| 3947 | self.xid = xid |
| 3948 | if flags != None: |
| 3949 | self.flags = flags |
| 3950 | else: |
| 3951 | self.flags = 0 |
| 3952 | if entries != None: |
| 3953 | self.entries = entries |
| 3954 | else: |
| 3955 | self.entries = [] |
| 3956 | |
| 3957 | def pack(self): |
| 3958 | packed = [] |
| 3959 | packed.append(struct.pack("!B", self.version)) |
| 3960 | packed.append(struct.pack("!B", self.type)) |
| 3961 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3962 | packed.append(struct.pack("!L", self.xid)) |
| 3963 | packed.append(struct.pack("!H", self.stats_type)) |
| 3964 | packed.append(struct.pack("!H", self.flags)) |
| 3965 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3966 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3967 | length = sum([len(x) for x in packed]) |
| 3968 | packed[2] = struct.pack("!H", length) |
| 3969 | return ''.join(packed) |
| 3970 | |
| 3971 | @staticmethod |
| 3972 | def unpack(buf): |
| 3973 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3974 | obj = group_desc_stats_reply() |
| 3975 | if type(buf) == loxi.generic_util.OFReader: |
| 3976 | reader = buf |
| 3977 | else: |
| 3978 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3979 | _version = reader.read("!B")[0] |
| 3980 | assert(_version == 2) |
| 3981 | _type = reader.read("!B")[0] |
| 3982 | assert(_type == 19) |
| 3983 | _length = reader.read("!H")[0] |
| 3984 | obj.xid = reader.read("!L")[0] |
| 3985 | _stats_type = reader.read("!H")[0] |
| 3986 | assert(_stats_type == 7) |
| 3987 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3988 | reader.skip(4) |
| 3989 | obj.entries = common.unpack_list_group_desc_stats_entry(reader) |
| 3990 | return obj |
| 3991 | |
| 3992 | def __eq__(self, other): |
| 3993 | if type(self) != type(other): return False |
| 3994 | if self.version != other.version: return False |
| 3995 | if self.type != other.type: return False |
| 3996 | if self.xid != other.xid: return False |
| 3997 | if self.flags != other.flags: return False |
| 3998 | if self.entries != other.entries: return False |
| 3999 | return True |
| 4000 | |
| 4001 | def __ne__(self, other): |
| 4002 | return not self.__eq__(other) |
| 4003 | |
| 4004 | def __str__(self): |
| 4005 | return self.show() |
| 4006 | |
| 4007 | def show(self): |
| 4008 | import loxi.pp |
| 4009 | return loxi.pp.pp(self) |
| 4010 | |
| 4011 | def pretty_print(self, q): |
| 4012 | q.text("group_desc_stats_reply {") |
| 4013 | with q.group(): |
| 4014 | with q.indent(2): |
| 4015 | q.breakable() |
| 4016 | q.text("xid = "); |
| 4017 | if self.xid != None: |
| 4018 | q.text("%#x" % self.xid) |
| 4019 | else: |
| 4020 | q.text('None') |
| 4021 | q.text(","); q.breakable() |
| 4022 | q.text("flags = "); |
| 4023 | q.text("%#x" % self.flags) |
| 4024 | q.text(","); q.breakable() |
| 4025 | q.text("entries = "); |
| 4026 | q.pp(self.entries) |
| 4027 | q.breakable() |
| 4028 | q.text('}') |
| 4029 | |
| 4030 | class group_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4031 | version = 2 |
| 4032 | type = 18 |
| 4033 | stats_type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4034 | |
| 4035 | def __init__(self, xid=None, flags=None): |
| 4036 | self.xid = xid |
| 4037 | if flags != None: |
| 4038 | self.flags = flags |
| 4039 | else: |
| 4040 | self.flags = 0 |
| 4041 | |
| 4042 | def pack(self): |
| 4043 | packed = [] |
| 4044 | packed.append(struct.pack("!B", self.version)) |
| 4045 | packed.append(struct.pack("!B", self.type)) |
| 4046 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4047 | packed.append(struct.pack("!L", self.xid)) |
| 4048 | packed.append(struct.pack("!H", self.stats_type)) |
| 4049 | packed.append(struct.pack("!H", self.flags)) |
| 4050 | packed.append('\x00' * 4) |
| 4051 | length = sum([len(x) for x in packed]) |
| 4052 | packed[2] = struct.pack("!H", length) |
| 4053 | return ''.join(packed) |
| 4054 | |
| 4055 | @staticmethod |
| 4056 | def unpack(buf): |
| 4057 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4058 | obj = group_desc_stats_request() |
| 4059 | if type(buf) == loxi.generic_util.OFReader: |
| 4060 | reader = buf |
| 4061 | else: |
| 4062 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4063 | _version = reader.read("!B")[0] |
| 4064 | assert(_version == 2) |
| 4065 | _type = reader.read("!B")[0] |
| 4066 | assert(_type == 18) |
| 4067 | _length = reader.read("!H")[0] |
| 4068 | obj.xid = reader.read("!L")[0] |
| 4069 | _stats_type = reader.read("!H")[0] |
| 4070 | assert(_stats_type == 7) |
| 4071 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4072 | reader.skip(4) |
| 4073 | return obj |
| 4074 | |
| 4075 | def __eq__(self, other): |
| 4076 | if type(self) != type(other): return False |
| 4077 | if self.version != other.version: return False |
| 4078 | if self.type != other.type: return False |
| 4079 | if self.xid != other.xid: return False |
| 4080 | if self.flags != other.flags: return False |
| 4081 | return True |
| 4082 | |
| 4083 | def __ne__(self, other): |
| 4084 | return not self.__eq__(other) |
| 4085 | |
| 4086 | def __str__(self): |
| 4087 | return self.show() |
| 4088 | |
| 4089 | def show(self): |
| 4090 | import loxi.pp |
| 4091 | return loxi.pp.pp(self) |
| 4092 | |
| 4093 | def pretty_print(self, q): |
| 4094 | q.text("group_desc_stats_request {") |
| 4095 | with q.group(): |
| 4096 | with q.indent(2): |
| 4097 | q.breakable() |
| 4098 | q.text("xid = "); |
| 4099 | if self.xid != None: |
| 4100 | q.text("%#x" % self.xid) |
| 4101 | else: |
| 4102 | q.text('None') |
| 4103 | q.text(","); q.breakable() |
| 4104 | q.text("flags = "); |
| 4105 | q.text("%#x" % self.flags) |
| 4106 | q.breakable() |
| 4107 | q.text('}') |
| 4108 | |
| 4109 | class group_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4110 | version = 2 |
| 4111 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4112 | |
| 4113 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 4114 | self.xid = xid |
| 4115 | if command != None: |
| 4116 | self.command = command |
| 4117 | else: |
| 4118 | self.command = 0 |
| 4119 | if group_type != None: |
| 4120 | self.group_type = group_type |
| 4121 | else: |
| 4122 | self.group_type = 0 |
| 4123 | if group_id != None: |
| 4124 | self.group_id = group_id |
| 4125 | else: |
| 4126 | self.group_id = 0 |
| 4127 | if buckets != None: |
| 4128 | self.buckets = buckets |
| 4129 | else: |
| 4130 | self.buckets = [] |
| 4131 | |
| 4132 | def pack(self): |
| 4133 | packed = [] |
| 4134 | packed.append(struct.pack("!B", self.version)) |
| 4135 | packed.append(struct.pack("!B", self.type)) |
| 4136 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4137 | packed.append(struct.pack("!L", self.xid)) |
| 4138 | packed.append(struct.pack("!H", self.command)) |
| 4139 | packed.append(struct.pack("!B", self.group_type)) |
| 4140 | packed.append('\x00' * 1) |
| 4141 | packed.append(struct.pack("!L", self.group_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4142 | packed.append(util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4143 | length = sum([len(x) for x in packed]) |
| 4144 | packed[2] = struct.pack("!H", length) |
| 4145 | return ''.join(packed) |
| 4146 | |
| 4147 | @staticmethod |
| 4148 | def unpack(buf): |
| 4149 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4150 | obj = group_mod() |
| 4151 | if type(buf) == loxi.generic_util.OFReader: |
| 4152 | reader = buf |
| 4153 | else: |
| 4154 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4155 | _version = reader.read("!B")[0] |
| 4156 | assert(_version == 2) |
| 4157 | _type = reader.read("!B")[0] |
| 4158 | assert(_type == 15) |
| 4159 | _length = reader.read("!H")[0] |
| 4160 | obj.xid = reader.read("!L")[0] |
| 4161 | obj.command = reader.read("!H")[0] |
| 4162 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4163 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4164 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4165 | obj.buckets = common.unpack_list_bucket(reader) |
| 4166 | return obj |
| 4167 | |
| 4168 | def __eq__(self, other): |
| 4169 | if type(self) != type(other): return False |
| 4170 | if self.version != other.version: return False |
| 4171 | if self.type != other.type: return False |
| 4172 | if self.xid != other.xid: return False |
| 4173 | if self.command != other.command: return False |
| 4174 | if self.group_type != other.group_type: return False |
| 4175 | if self.group_id != other.group_id: return False |
| 4176 | if self.buckets != other.buckets: return False |
| 4177 | return True |
| 4178 | |
| 4179 | def __ne__(self, other): |
| 4180 | return not self.__eq__(other) |
| 4181 | |
| 4182 | def __str__(self): |
| 4183 | return self.show() |
| 4184 | |
| 4185 | def show(self): |
| 4186 | import loxi.pp |
| 4187 | return loxi.pp.pp(self) |
| 4188 | |
| 4189 | def pretty_print(self, q): |
| 4190 | q.text("group_mod {") |
| 4191 | with q.group(): |
| 4192 | with q.indent(2): |
| 4193 | q.breakable() |
| 4194 | q.text("xid = "); |
| 4195 | if self.xid != None: |
| 4196 | q.text("%#x" % self.xid) |
| 4197 | else: |
| 4198 | q.text('None') |
| 4199 | q.text(","); q.breakable() |
| 4200 | q.text("command = "); |
| 4201 | q.text("%#x" % self.command) |
| 4202 | q.text(","); q.breakable() |
| 4203 | q.text("group_type = "); |
| 4204 | q.text("%#x" % self.group_type) |
| 4205 | q.text(","); q.breakable() |
| 4206 | q.text("group_id = "); |
| 4207 | q.text("%#x" % self.group_id) |
| 4208 | q.text(","); q.breakable() |
| 4209 | q.text("buckets = "); |
| 4210 | q.pp(self.buckets) |
| 4211 | q.breakable() |
| 4212 | q.text('}') |
| 4213 | |
| 4214 | class group_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4215 | version = 2 |
| 4216 | type = 19 |
| 4217 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4218 | |
| 4219 | def __init__(self, xid=None, flags=None, entries=None): |
| 4220 | self.xid = xid |
| 4221 | if flags != None: |
| 4222 | self.flags = flags |
| 4223 | else: |
| 4224 | self.flags = 0 |
| 4225 | if entries != None: |
| 4226 | self.entries = entries |
| 4227 | else: |
| 4228 | self.entries = [] |
| 4229 | |
| 4230 | def pack(self): |
| 4231 | packed = [] |
| 4232 | packed.append(struct.pack("!B", self.version)) |
| 4233 | packed.append(struct.pack("!B", self.type)) |
| 4234 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4235 | packed.append(struct.pack("!L", self.xid)) |
| 4236 | packed.append(struct.pack("!H", self.stats_type)) |
| 4237 | packed.append(struct.pack("!H", self.flags)) |
| 4238 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4239 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4240 | length = sum([len(x) for x in packed]) |
| 4241 | packed[2] = struct.pack("!H", length) |
| 4242 | return ''.join(packed) |
| 4243 | |
| 4244 | @staticmethod |
| 4245 | def unpack(buf): |
| 4246 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4247 | obj = group_stats_reply() |
| 4248 | if type(buf) == loxi.generic_util.OFReader: |
| 4249 | reader = buf |
| 4250 | else: |
| 4251 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4252 | _version = reader.read("!B")[0] |
| 4253 | assert(_version == 2) |
| 4254 | _type = reader.read("!B")[0] |
| 4255 | assert(_type == 19) |
| 4256 | _length = reader.read("!H")[0] |
| 4257 | obj.xid = reader.read("!L")[0] |
| 4258 | _stats_type = reader.read("!H")[0] |
| 4259 | assert(_stats_type == 6) |
| 4260 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4261 | reader.skip(4) |
| 4262 | obj.entries = common.unpack_list_group_stats_entry(reader) |
| 4263 | return obj |
| 4264 | |
| 4265 | def __eq__(self, other): |
| 4266 | if type(self) != type(other): return False |
| 4267 | if self.version != other.version: return False |
| 4268 | if self.type != other.type: return False |
| 4269 | if self.xid != other.xid: return False |
| 4270 | if self.flags != other.flags: return False |
| 4271 | if self.entries != other.entries: return False |
| 4272 | return True |
| 4273 | |
| 4274 | def __ne__(self, other): |
| 4275 | return not self.__eq__(other) |
| 4276 | |
| 4277 | def __str__(self): |
| 4278 | return self.show() |
| 4279 | |
| 4280 | def show(self): |
| 4281 | import loxi.pp |
| 4282 | return loxi.pp.pp(self) |
| 4283 | |
| 4284 | def pretty_print(self, q): |
| 4285 | q.text("group_stats_reply {") |
| 4286 | with q.group(): |
| 4287 | with q.indent(2): |
| 4288 | q.breakable() |
| 4289 | q.text("xid = "); |
| 4290 | if self.xid != None: |
| 4291 | q.text("%#x" % self.xid) |
| 4292 | else: |
| 4293 | q.text('None') |
| 4294 | q.text(","); q.breakable() |
| 4295 | q.text("flags = "); |
| 4296 | q.text("%#x" % self.flags) |
| 4297 | q.text(","); q.breakable() |
| 4298 | q.text("entries = "); |
| 4299 | q.pp(self.entries) |
| 4300 | q.breakable() |
| 4301 | q.text('}') |
| 4302 | |
| 4303 | class group_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4304 | version = 2 |
| 4305 | type = 18 |
| 4306 | stats_type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4307 | |
| 4308 | def __init__(self, xid=None, flags=None, group_id=None): |
| 4309 | self.xid = xid |
| 4310 | if flags != None: |
| 4311 | self.flags = flags |
| 4312 | else: |
| 4313 | self.flags = 0 |
| 4314 | if group_id != None: |
| 4315 | self.group_id = group_id |
| 4316 | else: |
| 4317 | self.group_id = 0 |
| 4318 | |
| 4319 | def pack(self): |
| 4320 | packed = [] |
| 4321 | packed.append(struct.pack("!B", self.version)) |
| 4322 | packed.append(struct.pack("!B", self.type)) |
| 4323 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4324 | packed.append(struct.pack("!L", self.xid)) |
| 4325 | packed.append(struct.pack("!H", self.stats_type)) |
| 4326 | packed.append(struct.pack("!H", self.flags)) |
| 4327 | packed.append('\x00' * 4) |
| 4328 | packed.append(struct.pack("!L", self.group_id)) |
| 4329 | packed.append('\x00' * 4) |
| 4330 | length = sum([len(x) for x in packed]) |
| 4331 | packed[2] = struct.pack("!H", length) |
| 4332 | return ''.join(packed) |
| 4333 | |
| 4334 | @staticmethod |
| 4335 | def unpack(buf): |
| 4336 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4337 | obj = group_stats_request() |
| 4338 | if type(buf) == loxi.generic_util.OFReader: |
| 4339 | reader = buf |
| 4340 | else: |
| 4341 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4342 | _version = reader.read("!B")[0] |
| 4343 | assert(_version == 2) |
| 4344 | _type = reader.read("!B")[0] |
| 4345 | assert(_type == 18) |
| 4346 | _length = reader.read("!H")[0] |
| 4347 | obj.xid = reader.read("!L")[0] |
| 4348 | _stats_type = reader.read("!H")[0] |
| 4349 | assert(_stats_type == 6) |
| 4350 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4351 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4352 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4353 | reader.skip(4) |
| 4354 | return obj |
| 4355 | |
| 4356 | def __eq__(self, other): |
| 4357 | if type(self) != type(other): return False |
| 4358 | if self.version != other.version: return False |
| 4359 | if self.type != other.type: return False |
| 4360 | if self.xid != other.xid: return False |
| 4361 | if self.flags != other.flags: return False |
| 4362 | if self.group_id != other.group_id: return False |
| 4363 | return True |
| 4364 | |
| 4365 | def __ne__(self, other): |
| 4366 | return not self.__eq__(other) |
| 4367 | |
| 4368 | def __str__(self): |
| 4369 | return self.show() |
| 4370 | |
| 4371 | def show(self): |
| 4372 | import loxi.pp |
| 4373 | return loxi.pp.pp(self) |
| 4374 | |
| 4375 | def pretty_print(self, q): |
| 4376 | q.text("group_stats_request {") |
| 4377 | with q.group(): |
| 4378 | with q.indent(2): |
| 4379 | q.breakable() |
| 4380 | q.text("xid = "); |
| 4381 | if self.xid != None: |
| 4382 | q.text("%#x" % self.xid) |
| 4383 | else: |
| 4384 | q.text('None') |
| 4385 | q.text(","); q.breakable() |
| 4386 | q.text("flags = "); |
| 4387 | q.text("%#x" % self.flags) |
| 4388 | q.text(","); q.breakable() |
| 4389 | q.text("group_id = "); |
| 4390 | q.text("%#x" % self.group_id) |
| 4391 | q.breakable() |
| 4392 | q.text('}') |
| 4393 | |
| 4394 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4395 | version = 2 |
| 4396 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4397 | |
| 4398 | def __init__(self, xid=None): |
| 4399 | self.xid = xid |
| 4400 | |
| 4401 | def pack(self): |
| 4402 | packed = [] |
| 4403 | packed.append(struct.pack("!B", self.version)) |
| 4404 | packed.append(struct.pack("!B", self.type)) |
| 4405 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4406 | packed.append(struct.pack("!L", self.xid)) |
| 4407 | length = sum([len(x) for x in packed]) |
| 4408 | packed[2] = struct.pack("!H", length) |
| 4409 | return ''.join(packed) |
| 4410 | |
| 4411 | @staticmethod |
| 4412 | def unpack(buf): |
| 4413 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4414 | obj = hello() |
| 4415 | if type(buf) == loxi.generic_util.OFReader: |
| 4416 | reader = buf |
| 4417 | else: |
| 4418 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4419 | _version = reader.read("!B")[0] |
| 4420 | assert(_version == 2) |
| 4421 | _type = reader.read("!B")[0] |
| 4422 | assert(_type == 0) |
| 4423 | _length = reader.read("!H")[0] |
| 4424 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4425 | return obj |
| 4426 | |
| 4427 | def __eq__(self, other): |
| 4428 | if type(self) != type(other): return False |
| 4429 | if self.version != other.version: return False |
| 4430 | if self.type != other.type: return False |
| 4431 | if self.xid != other.xid: return False |
| 4432 | return True |
| 4433 | |
| 4434 | def __ne__(self, other): |
| 4435 | return not self.__eq__(other) |
| 4436 | |
| 4437 | def __str__(self): |
| 4438 | return self.show() |
| 4439 | |
| 4440 | def show(self): |
| 4441 | import loxi.pp |
| 4442 | return loxi.pp.pp(self) |
| 4443 | |
| 4444 | def pretty_print(self, q): |
| 4445 | q.text("hello {") |
| 4446 | with q.group(): |
| 4447 | with q.indent(2): |
| 4448 | q.breakable() |
| 4449 | q.text("xid = "); |
| 4450 | if self.xid != None: |
| 4451 | q.text("%#x" % self.xid) |
| 4452 | else: |
| 4453 | q.text('None') |
| 4454 | q.breakable() |
| 4455 | q.text('}') |
| 4456 | |
| 4457 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4458 | version = 2 |
| 4459 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4460 | |
| 4461 | def __init__(self, xid=None, buffer_id=None, in_port=None, in_phy_port=None, total_len=None, reason=None, table_id=None, data=None): |
| 4462 | self.xid = xid |
| 4463 | if buffer_id != None: |
| 4464 | self.buffer_id = buffer_id |
| 4465 | else: |
| 4466 | self.buffer_id = 0 |
| 4467 | if in_port != None: |
| 4468 | self.in_port = in_port |
| 4469 | else: |
| 4470 | self.in_port = 0 |
| 4471 | if in_phy_port != None: |
| 4472 | self.in_phy_port = in_phy_port |
| 4473 | else: |
| 4474 | self.in_phy_port = 0 |
| 4475 | if total_len != None: |
| 4476 | self.total_len = total_len |
| 4477 | else: |
| 4478 | self.total_len = 0 |
| 4479 | if reason != None: |
| 4480 | self.reason = reason |
| 4481 | else: |
| 4482 | self.reason = 0 |
| 4483 | if table_id != None: |
| 4484 | self.table_id = table_id |
| 4485 | else: |
| 4486 | self.table_id = 0 |
| 4487 | if data != None: |
| 4488 | self.data = data |
| 4489 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4490 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4491 | |
| 4492 | def pack(self): |
| 4493 | packed = [] |
| 4494 | packed.append(struct.pack("!B", self.version)) |
| 4495 | packed.append(struct.pack("!B", self.type)) |
| 4496 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4497 | packed.append(struct.pack("!L", self.xid)) |
| 4498 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4499 | packed.append(util.pack_port_no(self.in_port)) |
| 4500 | packed.append(util.pack_port_no(self.in_phy_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4501 | packed.append(struct.pack("!H", self.total_len)) |
| 4502 | packed.append(struct.pack("!B", self.reason)) |
| 4503 | packed.append(struct.pack("!B", self.table_id)) |
| 4504 | packed.append(self.data) |
| 4505 | length = sum([len(x) for x in packed]) |
| 4506 | packed[2] = struct.pack("!H", length) |
| 4507 | return ''.join(packed) |
| 4508 | |
| 4509 | @staticmethod |
| 4510 | def unpack(buf): |
| 4511 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4512 | obj = packet_in() |
| 4513 | if type(buf) == loxi.generic_util.OFReader: |
| 4514 | reader = buf |
| 4515 | else: |
| 4516 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4517 | _version = reader.read("!B")[0] |
| 4518 | assert(_version == 2) |
| 4519 | _type = reader.read("!B")[0] |
| 4520 | assert(_type == 10) |
| 4521 | _length = reader.read("!H")[0] |
| 4522 | obj.xid = reader.read("!L")[0] |
| 4523 | obj.buffer_id = reader.read("!L")[0] |
| 4524 | obj.in_port = util.unpack_port_no(reader) |
| 4525 | obj.in_phy_port = util.unpack_port_no(reader) |
| 4526 | obj.total_len = reader.read("!H")[0] |
| 4527 | obj.reason = reader.read("!B")[0] |
| 4528 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4529 | obj.data = str(reader.read_all()) |
| 4530 | return obj |
| 4531 | |
| 4532 | def __eq__(self, other): |
| 4533 | if type(self) != type(other): return False |
| 4534 | if self.version != other.version: return False |
| 4535 | if self.type != other.type: return False |
| 4536 | if self.xid != other.xid: return False |
| 4537 | if self.buffer_id != other.buffer_id: return False |
| 4538 | if self.in_port != other.in_port: return False |
| 4539 | if self.in_phy_port != other.in_phy_port: return False |
| 4540 | if self.total_len != other.total_len: return False |
| 4541 | if self.reason != other.reason: return False |
| 4542 | if self.table_id != other.table_id: return False |
| 4543 | if self.data != other.data: return False |
| 4544 | return True |
| 4545 | |
| 4546 | def __ne__(self, other): |
| 4547 | return not self.__eq__(other) |
| 4548 | |
| 4549 | def __str__(self): |
| 4550 | return self.show() |
| 4551 | |
| 4552 | def show(self): |
| 4553 | import loxi.pp |
| 4554 | return loxi.pp.pp(self) |
| 4555 | |
| 4556 | def pretty_print(self, q): |
| 4557 | q.text("packet_in {") |
| 4558 | with q.group(): |
| 4559 | with q.indent(2): |
| 4560 | q.breakable() |
| 4561 | q.text("xid = "); |
| 4562 | if self.xid != None: |
| 4563 | q.text("%#x" % self.xid) |
| 4564 | else: |
| 4565 | q.text('None') |
| 4566 | q.text(","); q.breakable() |
| 4567 | q.text("buffer_id = "); |
| 4568 | q.text("%#x" % self.buffer_id) |
| 4569 | q.text(","); q.breakable() |
| 4570 | q.text("in_port = "); |
| 4571 | q.text(util.pretty_port(self.in_port)) |
| 4572 | q.text(","); q.breakable() |
| 4573 | q.text("in_phy_port = "); |
| 4574 | q.text(util.pretty_port(self.in_phy_port)) |
| 4575 | q.text(","); q.breakable() |
| 4576 | q.text("total_len = "); |
| 4577 | q.text("%#x" % self.total_len) |
| 4578 | q.text(","); q.breakable() |
| 4579 | q.text("reason = "); |
| 4580 | q.text("%#x" % self.reason) |
| 4581 | q.text(","); q.breakable() |
| 4582 | q.text("table_id = "); |
| 4583 | q.text("%#x" % self.table_id) |
| 4584 | q.text(","); q.breakable() |
| 4585 | q.text("data = "); |
| 4586 | q.pp(self.data) |
| 4587 | q.breakable() |
| 4588 | q.text('}') |
| 4589 | |
| 4590 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4591 | version = 2 |
| 4592 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4593 | |
| 4594 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 4595 | self.xid = xid |
| 4596 | if buffer_id != None: |
| 4597 | self.buffer_id = buffer_id |
| 4598 | else: |
| 4599 | self.buffer_id = 0 |
| 4600 | if in_port != None: |
| 4601 | self.in_port = in_port |
| 4602 | else: |
| 4603 | self.in_port = 0 |
| 4604 | if actions != None: |
| 4605 | self.actions = actions |
| 4606 | else: |
| 4607 | self.actions = [] |
| 4608 | if data != None: |
| 4609 | self.data = data |
| 4610 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4611 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4612 | |
| 4613 | def pack(self): |
| 4614 | packed = [] |
| 4615 | packed.append(struct.pack("!B", self.version)) |
| 4616 | packed.append(struct.pack("!B", self.type)) |
| 4617 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4618 | packed.append(struct.pack("!L", self.xid)) |
| 4619 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4620 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4621 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 4622 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4623 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4624 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 4625 | packed.append(self.data) |
| 4626 | length = sum([len(x) for x in packed]) |
| 4627 | packed[2] = struct.pack("!H", length) |
| 4628 | return ''.join(packed) |
| 4629 | |
| 4630 | @staticmethod |
| 4631 | def unpack(buf): |
| 4632 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4633 | obj = packet_out() |
| 4634 | if type(buf) == loxi.generic_util.OFReader: |
| 4635 | reader = buf |
| 4636 | else: |
| 4637 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4638 | _version = reader.read("!B")[0] |
| 4639 | assert(_version == 2) |
| 4640 | _type = reader.read("!B")[0] |
| 4641 | assert(_type == 13) |
| 4642 | _length = reader.read("!H")[0] |
| 4643 | obj.xid = reader.read("!L")[0] |
| 4644 | obj.buffer_id = reader.read("!L")[0] |
| 4645 | obj.in_port = util.unpack_port_no(reader) |
| 4646 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4647 | reader.skip(6) |
| 4648 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 4649 | obj.data = str(reader.read_all()) |
| 4650 | return obj |
| 4651 | |
| 4652 | def __eq__(self, other): |
| 4653 | if type(self) != type(other): return False |
| 4654 | if self.version != other.version: return False |
| 4655 | if self.type != other.type: return False |
| 4656 | if self.xid != other.xid: return False |
| 4657 | if self.buffer_id != other.buffer_id: return False |
| 4658 | if self.in_port != other.in_port: return False |
| 4659 | if self.actions != other.actions: return False |
| 4660 | if self.data != other.data: return False |
| 4661 | return True |
| 4662 | |
| 4663 | def __ne__(self, other): |
| 4664 | return not self.__eq__(other) |
| 4665 | |
| 4666 | def __str__(self): |
| 4667 | return self.show() |
| 4668 | |
| 4669 | def show(self): |
| 4670 | import loxi.pp |
| 4671 | return loxi.pp.pp(self) |
| 4672 | |
| 4673 | def pretty_print(self, q): |
| 4674 | q.text("packet_out {") |
| 4675 | with q.group(): |
| 4676 | with q.indent(2): |
| 4677 | q.breakable() |
| 4678 | q.text("xid = "); |
| 4679 | if self.xid != None: |
| 4680 | q.text("%#x" % self.xid) |
| 4681 | else: |
| 4682 | q.text('None') |
| 4683 | q.text(","); q.breakable() |
| 4684 | q.text("buffer_id = "); |
| 4685 | q.text("%#x" % self.buffer_id) |
| 4686 | q.text(","); q.breakable() |
| 4687 | q.text("in_port = "); |
| 4688 | q.text(util.pretty_port(self.in_port)) |
| 4689 | q.text(","); q.breakable() |
| 4690 | q.text("actions = "); |
| 4691 | q.pp(self.actions) |
| 4692 | q.text(","); q.breakable() |
| 4693 | q.text("data = "); |
| 4694 | q.pp(self.data) |
| 4695 | q.breakable() |
| 4696 | q.text('}') |
| 4697 | |
| 4698 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4699 | version = 2 |
| 4700 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4701 | |
| 4702 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
| 4703 | self.xid = xid |
| 4704 | if port_no != None: |
| 4705 | self.port_no = port_no |
| 4706 | else: |
| 4707 | self.port_no = 0 |
| 4708 | if hw_addr != None: |
| 4709 | self.hw_addr = hw_addr |
| 4710 | else: |
| 4711 | self.hw_addr = [0,0,0,0,0,0] |
| 4712 | if config != None: |
| 4713 | self.config = config |
| 4714 | else: |
| 4715 | self.config = 0 |
| 4716 | if mask != None: |
| 4717 | self.mask = mask |
| 4718 | else: |
| 4719 | self.mask = 0 |
| 4720 | if advertise != None: |
| 4721 | self.advertise = advertise |
| 4722 | else: |
| 4723 | self.advertise = 0 |
| 4724 | |
| 4725 | def pack(self): |
| 4726 | packed = [] |
| 4727 | packed.append(struct.pack("!B", self.version)) |
| 4728 | packed.append(struct.pack("!B", self.type)) |
| 4729 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4730 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4731 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4732 | packed.append('\x00' * 4) |
| 4733 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 4734 | packed.append('\x00' * 2) |
| 4735 | packed.append(struct.pack("!L", self.config)) |
| 4736 | packed.append(struct.pack("!L", self.mask)) |
| 4737 | packed.append(struct.pack("!L", self.advertise)) |
| 4738 | packed.append('\x00' * 4) |
| 4739 | length = sum([len(x) for x in packed]) |
| 4740 | packed[2] = struct.pack("!H", length) |
| 4741 | return ''.join(packed) |
| 4742 | |
| 4743 | @staticmethod |
| 4744 | def unpack(buf): |
| 4745 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4746 | obj = port_mod() |
| 4747 | if type(buf) == loxi.generic_util.OFReader: |
| 4748 | reader = buf |
| 4749 | else: |
| 4750 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4751 | _version = reader.read("!B")[0] |
| 4752 | assert(_version == 2) |
| 4753 | _type = reader.read("!B")[0] |
| 4754 | assert(_type == 16) |
| 4755 | _length = reader.read("!H")[0] |
| 4756 | obj.xid = reader.read("!L")[0] |
| 4757 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4758 | reader.skip(4) |
| 4759 | obj.hw_addr = list(reader.read('!6B')) |
| 4760 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4761 | obj.config = reader.read("!L")[0] |
| 4762 | obj.mask = reader.read("!L")[0] |
| 4763 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4764 | reader.skip(4) |
| 4765 | return obj |
| 4766 | |
| 4767 | def __eq__(self, other): |
| 4768 | if type(self) != type(other): return False |
| 4769 | if self.version != other.version: return False |
| 4770 | if self.type != other.type: return False |
| 4771 | if self.xid != other.xid: return False |
| 4772 | if self.port_no != other.port_no: return False |
| 4773 | if self.hw_addr != other.hw_addr: return False |
| 4774 | if self.config != other.config: return False |
| 4775 | if self.mask != other.mask: return False |
| 4776 | if self.advertise != other.advertise: return False |
| 4777 | return True |
| 4778 | |
| 4779 | def __ne__(self, other): |
| 4780 | return not self.__eq__(other) |
| 4781 | |
| 4782 | def __str__(self): |
| 4783 | return self.show() |
| 4784 | |
| 4785 | def show(self): |
| 4786 | import loxi.pp |
| 4787 | return loxi.pp.pp(self) |
| 4788 | |
| 4789 | def pretty_print(self, q): |
| 4790 | q.text("port_mod {") |
| 4791 | with q.group(): |
| 4792 | with q.indent(2): |
| 4793 | q.breakable() |
| 4794 | q.text("xid = "); |
| 4795 | if self.xid != None: |
| 4796 | q.text("%#x" % self.xid) |
| 4797 | else: |
| 4798 | q.text('None') |
| 4799 | q.text(","); q.breakable() |
| 4800 | q.text("port_no = "); |
| 4801 | q.text(util.pretty_port(self.port_no)) |
| 4802 | q.text(","); q.breakable() |
| 4803 | q.text("hw_addr = "); |
| 4804 | q.text(util.pretty_mac(self.hw_addr)) |
| 4805 | q.text(","); q.breakable() |
| 4806 | q.text("config = "); |
| 4807 | q.text("%#x" % self.config) |
| 4808 | q.text(","); q.breakable() |
| 4809 | q.text("mask = "); |
| 4810 | q.text("%#x" % self.mask) |
| 4811 | q.text(","); q.breakable() |
| 4812 | q.text("advertise = "); |
| 4813 | q.text("%#x" % self.advertise) |
| 4814 | q.breakable() |
| 4815 | q.text('}') |
| 4816 | |
| 4817 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4818 | version = 2 |
| 4819 | type = 19 |
| 4820 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4821 | |
| 4822 | def __init__(self, xid=None, flags=None, entries=None): |
| 4823 | self.xid = xid |
| 4824 | if flags != None: |
| 4825 | self.flags = flags |
| 4826 | else: |
| 4827 | self.flags = 0 |
| 4828 | if entries != None: |
| 4829 | self.entries = entries |
| 4830 | else: |
| 4831 | self.entries = [] |
| 4832 | |
| 4833 | def pack(self): |
| 4834 | packed = [] |
| 4835 | packed.append(struct.pack("!B", self.version)) |
| 4836 | packed.append(struct.pack("!B", self.type)) |
| 4837 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4838 | packed.append(struct.pack("!L", self.xid)) |
| 4839 | packed.append(struct.pack("!H", self.stats_type)) |
| 4840 | packed.append(struct.pack("!H", self.flags)) |
| 4841 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4842 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4843 | length = sum([len(x) for x in packed]) |
| 4844 | packed[2] = struct.pack("!H", length) |
| 4845 | return ''.join(packed) |
| 4846 | |
| 4847 | @staticmethod |
| 4848 | def unpack(buf): |
| 4849 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4850 | obj = port_stats_reply() |
| 4851 | if type(buf) == loxi.generic_util.OFReader: |
| 4852 | reader = buf |
| 4853 | else: |
| 4854 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4855 | _version = reader.read("!B")[0] |
| 4856 | assert(_version == 2) |
| 4857 | _type = reader.read("!B")[0] |
| 4858 | assert(_type == 19) |
| 4859 | _length = reader.read("!H")[0] |
| 4860 | obj.xid = reader.read("!L")[0] |
| 4861 | _stats_type = reader.read("!H")[0] |
| 4862 | assert(_stats_type == 4) |
| 4863 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4864 | reader.skip(4) |
| 4865 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 4866 | return obj |
| 4867 | |
| 4868 | def __eq__(self, other): |
| 4869 | if type(self) != type(other): return False |
| 4870 | if self.version != other.version: return False |
| 4871 | if self.type != other.type: return False |
| 4872 | if self.xid != other.xid: return False |
| 4873 | if self.flags != other.flags: return False |
| 4874 | if self.entries != other.entries: return False |
| 4875 | return True |
| 4876 | |
| 4877 | def __ne__(self, other): |
| 4878 | return not self.__eq__(other) |
| 4879 | |
| 4880 | def __str__(self): |
| 4881 | return self.show() |
| 4882 | |
| 4883 | def show(self): |
| 4884 | import loxi.pp |
| 4885 | return loxi.pp.pp(self) |
| 4886 | |
| 4887 | def pretty_print(self, q): |
| 4888 | q.text("port_stats_reply {") |
| 4889 | with q.group(): |
| 4890 | with q.indent(2): |
| 4891 | q.breakable() |
| 4892 | q.text("xid = "); |
| 4893 | if self.xid != None: |
| 4894 | q.text("%#x" % self.xid) |
| 4895 | else: |
| 4896 | q.text('None') |
| 4897 | q.text(","); q.breakable() |
| 4898 | q.text("flags = "); |
| 4899 | q.text("%#x" % self.flags) |
| 4900 | q.text(","); q.breakable() |
| 4901 | q.text("entries = "); |
| 4902 | q.pp(self.entries) |
| 4903 | q.breakable() |
| 4904 | q.text('}') |
| 4905 | |
| 4906 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4907 | version = 2 |
| 4908 | type = 18 |
| 4909 | stats_type = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4910 | |
| 4911 | def __init__(self, xid=None, flags=None, port_no=None): |
| 4912 | self.xid = xid |
| 4913 | if flags != None: |
| 4914 | self.flags = flags |
| 4915 | else: |
| 4916 | self.flags = 0 |
| 4917 | if port_no != None: |
| 4918 | self.port_no = port_no |
| 4919 | else: |
| 4920 | self.port_no = 0 |
| 4921 | |
| 4922 | def pack(self): |
| 4923 | packed = [] |
| 4924 | packed.append(struct.pack("!B", self.version)) |
| 4925 | packed.append(struct.pack("!B", self.type)) |
| 4926 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4927 | packed.append(struct.pack("!L", self.xid)) |
| 4928 | packed.append(struct.pack("!H", self.stats_type)) |
| 4929 | packed.append(struct.pack("!H", self.flags)) |
| 4930 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4931 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4932 | packed.append('\x00' * 4) |
| 4933 | length = sum([len(x) for x in packed]) |
| 4934 | packed[2] = struct.pack("!H", length) |
| 4935 | return ''.join(packed) |
| 4936 | |
| 4937 | @staticmethod |
| 4938 | def unpack(buf): |
| 4939 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4940 | obj = port_stats_request() |
| 4941 | if type(buf) == loxi.generic_util.OFReader: |
| 4942 | reader = buf |
| 4943 | else: |
| 4944 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4945 | _version = reader.read("!B")[0] |
| 4946 | assert(_version == 2) |
| 4947 | _type = reader.read("!B")[0] |
| 4948 | assert(_type == 18) |
| 4949 | _length = reader.read("!H")[0] |
| 4950 | obj.xid = reader.read("!L")[0] |
| 4951 | _stats_type = reader.read("!H")[0] |
| 4952 | assert(_stats_type == 4) |
| 4953 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4954 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4955 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4956 | reader.skip(4) |
| 4957 | return obj |
| 4958 | |
| 4959 | def __eq__(self, other): |
| 4960 | if type(self) != type(other): return False |
| 4961 | if self.version != other.version: return False |
| 4962 | if self.type != other.type: return False |
| 4963 | if self.xid != other.xid: return False |
| 4964 | if self.flags != other.flags: return False |
| 4965 | if self.port_no != other.port_no: return False |
| 4966 | return True |
| 4967 | |
| 4968 | def __ne__(self, other): |
| 4969 | return not self.__eq__(other) |
| 4970 | |
| 4971 | def __str__(self): |
| 4972 | return self.show() |
| 4973 | |
| 4974 | def show(self): |
| 4975 | import loxi.pp |
| 4976 | return loxi.pp.pp(self) |
| 4977 | |
| 4978 | def pretty_print(self, q): |
| 4979 | q.text("port_stats_request {") |
| 4980 | with q.group(): |
| 4981 | with q.indent(2): |
| 4982 | q.breakable() |
| 4983 | q.text("xid = "); |
| 4984 | if self.xid != None: |
| 4985 | q.text("%#x" % self.xid) |
| 4986 | else: |
| 4987 | q.text('None') |
| 4988 | q.text(","); q.breakable() |
| 4989 | q.text("flags = "); |
| 4990 | q.text("%#x" % self.flags) |
| 4991 | q.text(","); q.breakable() |
| 4992 | q.text("port_no = "); |
| 4993 | q.text(util.pretty_port(self.port_no)) |
| 4994 | q.breakable() |
| 4995 | q.text('}') |
| 4996 | |
| 4997 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4998 | version = 2 |
| 4999 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5000 | |
| 5001 | def __init__(self, xid=None, reason=None, desc=None): |
| 5002 | self.xid = xid |
| 5003 | if reason != None: |
| 5004 | self.reason = reason |
| 5005 | else: |
| 5006 | self.reason = 0 |
| 5007 | if desc != None: |
| 5008 | self.desc = desc |
| 5009 | else: |
| 5010 | self.desc = common.port_desc() |
| 5011 | |
| 5012 | def pack(self): |
| 5013 | packed = [] |
| 5014 | packed.append(struct.pack("!B", self.version)) |
| 5015 | packed.append(struct.pack("!B", self.type)) |
| 5016 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5017 | packed.append(struct.pack("!L", self.xid)) |
| 5018 | packed.append(struct.pack("!B", self.reason)) |
| 5019 | packed.append('\x00' * 7) |
| 5020 | packed.append(self.desc.pack()) |
| 5021 | length = sum([len(x) for x in packed]) |
| 5022 | packed[2] = struct.pack("!H", length) |
| 5023 | return ''.join(packed) |
| 5024 | |
| 5025 | @staticmethod |
| 5026 | def unpack(buf): |
| 5027 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5028 | obj = port_status() |
| 5029 | if type(buf) == loxi.generic_util.OFReader: |
| 5030 | reader = buf |
| 5031 | else: |
| 5032 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5033 | _version = reader.read("!B")[0] |
| 5034 | assert(_version == 2) |
| 5035 | _type = reader.read("!B")[0] |
| 5036 | assert(_type == 12) |
| 5037 | _length = reader.read("!H")[0] |
| 5038 | obj.xid = reader.read("!L")[0] |
| 5039 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5040 | reader.skip(7) |
| 5041 | obj.desc = common.port_desc.unpack(reader) |
| 5042 | return obj |
| 5043 | |
| 5044 | def __eq__(self, other): |
| 5045 | if type(self) != type(other): return False |
| 5046 | if self.version != other.version: return False |
| 5047 | if self.type != other.type: return False |
| 5048 | if self.xid != other.xid: return False |
| 5049 | if self.reason != other.reason: return False |
| 5050 | if self.desc != other.desc: return False |
| 5051 | return True |
| 5052 | |
| 5053 | def __ne__(self, other): |
| 5054 | return not self.__eq__(other) |
| 5055 | |
| 5056 | def __str__(self): |
| 5057 | return self.show() |
| 5058 | |
| 5059 | def show(self): |
| 5060 | import loxi.pp |
| 5061 | return loxi.pp.pp(self) |
| 5062 | |
| 5063 | def pretty_print(self, q): |
| 5064 | q.text("port_status {") |
| 5065 | with q.group(): |
| 5066 | with q.indent(2): |
| 5067 | q.breakable() |
| 5068 | q.text("xid = "); |
| 5069 | if self.xid != None: |
| 5070 | q.text("%#x" % self.xid) |
| 5071 | else: |
| 5072 | q.text('None') |
| 5073 | q.text(","); q.breakable() |
| 5074 | q.text("reason = "); |
| 5075 | q.text("%#x" % self.reason) |
| 5076 | q.text(","); q.breakable() |
| 5077 | q.text("desc = "); |
| 5078 | q.pp(self.desc) |
| 5079 | q.breakable() |
| 5080 | q.text('}') |
| 5081 | |
| 5082 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5083 | version = 2 |
| 5084 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5085 | |
| 5086 | def __init__(self, xid=None, port=None, queues=None): |
| 5087 | self.xid = xid |
| 5088 | if port != None: |
| 5089 | self.port = port |
| 5090 | else: |
| 5091 | self.port = 0 |
| 5092 | if queues != None: |
| 5093 | self.queues = queues |
| 5094 | else: |
| 5095 | self.queues = [] |
| 5096 | |
| 5097 | def pack(self): |
| 5098 | packed = [] |
| 5099 | packed.append(struct.pack("!B", self.version)) |
| 5100 | packed.append(struct.pack("!B", self.type)) |
| 5101 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5102 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5103 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5104 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5105 | packed.append(util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5106 | length = sum([len(x) for x in packed]) |
| 5107 | packed[2] = struct.pack("!H", length) |
| 5108 | return ''.join(packed) |
| 5109 | |
| 5110 | @staticmethod |
| 5111 | def unpack(buf): |
| 5112 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5113 | obj = queue_get_config_reply() |
| 5114 | if type(buf) == loxi.generic_util.OFReader: |
| 5115 | reader = buf |
| 5116 | else: |
| 5117 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5118 | _version = reader.read("!B")[0] |
| 5119 | assert(_version == 2) |
| 5120 | _type = reader.read("!B")[0] |
| 5121 | assert(_type == 23) |
| 5122 | _length = reader.read("!H")[0] |
| 5123 | obj.xid = reader.read("!L")[0] |
| 5124 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5125 | reader.skip(4) |
| 5126 | obj.queues = common.unpack_list_packet_queue(reader) |
| 5127 | return obj |
| 5128 | |
| 5129 | def __eq__(self, other): |
| 5130 | if type(self) != type(other): return False |
| 5131 | if self.version != other.version: return False |
| 5132 | if self.type != other.type: return False |
| 5133 | if self.xid != other.xid: return False |
| 5134 | if self.port != other.port: return False |
| 5135 | if self.queues != other.queues: return False |
| 5136 | return True |
| 5137 | |
| 5138 | def __ne__(self, other): |
| 5139 | return not self.__eq__(other) |
| 5140 | |
| 5141 | def __str__(self): |
| 5142 | return self.show() |
| 5143 | |
| 5144 | def show(self): |
| 5145 | import loxi.pp |
| 5146 | return loxi.pp.pp(self) |
| 5147 | |
| 5148 | def pretty_print(self, q): |
| 5149 | q.text("queue_get_config_reply {") |
| 5150 | with q.group(): |
| 5151 | with q.indent(2): |
| 5152 | q.breakable() |
| 5153 | q.text("xid = "); |
| 5154 | if self.xid != None: |
| 5155 | q.text("%#x" % self.xid) |
| 5156 | else: |
| 5157 | q.text('None') |
| 5158 | q.text(","); q.breakable() |
| 5159 | q.text("port = "); |
| 5160 | q.text(util.pretty_port(self.port)) |
| 5161 | q.text(","); q.breakable() |
| 5162 | q.text("queues = "); |
| 5163 | q.pp(self.queues) |
| 5164 | q.breakable() |
| 5165 | q.text('}') |
| 5166 | |
| 5167 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5168 | version = 2 |
| 5169 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5170 | |
| 5171 | def __init__(self, xid=None, port=None): |
| 5172 | self.xid = xid |
| 5173 | if port != None: |
| 5174 | self.port = port |
| 5175 | else: |
| 5176 | self.port = 0 |
| 5177 | |
| 5178 | def pack(self): |
| 5179 | packed = [] |
| 5180 | packed.append(struct.pack("!B", self.version)) |
| 5181 | packed.append(struct.pack("!B", self.type)) |
| 5182 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5183 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5184 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5185 | packed.append('\x00' * 4) |
| 5186 | length = sum([len(x) for x in packed]) |
| 5187 | packed[2] = struct.pack("!H", length) |
| 5188 | return ''.join(packed) |
| 5189 | |
| 5190 | @staticmethod |
| 5191 | def unpack(buf): |
| 5192 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5193 | obj = queue_get_config_request() |
| 5194 | if type(buf) == loxi.generic_util.OFReader: |
| 5195 | reader = buf |
| 5196 | else: |
| 5197 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5198 | _version = reader.read("!B")[0] |
| 5199 | assert(_version == 2) |
| 5200 | _type = reader.read("!B")[0] |
| 5201 | assert(_type == 22) |
| 5202 | _length = reader.read("!H")[0] |
| 5203 | obj.xid = reader.read("!L")[0] |
| 5204 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5205 | reader.skip(4) |
| 5206 | return obj |
| 5207 | |
| 5208 | def __eq__(self, other): |
| 5209 | if type(self) != type(other): return False |
| 5210 | if self.version != other.version: return False |
| 5211 | if self.type != other.type: return False |
| 5212 | if self.xid != other.xid: return False |
| 5213 | if self.port != other.port: return False |
| 5214 | return True |
| 5215 | |
| 5216 | def __ne__(self, other): |
| 5217 | return not self.__eq__(other) |
| 5218 | |
| 5219 | def __str__(self): |
| 5220 | return self.show() |
| 5221 | |
| 5222 | def show(self): |
| 5223 | import loxi.pp |
| 5224 | return loxi.pp.pp(self) |
| 5225 | |
| 5226 | def pretty_print(self, q): |
| 5227 | q.text("queue_get_config_request {") |
| 5228 | with q.group(): |
| 5229 | with q.indent(2): |
| 5230 | q.breakable() |
| 5231 | q.text("xid = "); |
| 5232 | if self.xid != None: |
| 5233 | q.text("%#x" % self.xid) |
| 5234 | else: |
| 5235 | q.text('None') |
| 5236 | q.text(","); q.breakable() |
| 5237 | q.text("port = "); |
| 5238 | q.text(util.pretty_port(self.port)) |
| 5239 | q.breakable() |
| 5240 | q.text('}') |
| 5241 | |
| 5242 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5243 | version = 2 |
| 5244 | type = 19 |
| 5245 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5246 | |
| 5247 | def __init__(self, xid=None, flags=None, entries=None): |
| 5248 | self.xid = xid |
| 5249 | if flags != None: |
| 5250 | self.flags = flags |
| 5251 | else: |
| 5252 | self.flags = 0 |
| 5253 | if entries != None: |
| 5254 | self.entries = entries |
| 5255 | else: |
| 5256 | self.entries = [] |
| 5257 | |
| 5258 | def pack(self): |
| 5259 | packed = [] |
| 5260 | packed.append(struct.pack("!B", self.version)) |
| 5261 | packed.append(struct.pack("!B", self.type)) |
| 5262 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5263 | packed.append(struct.pack("!L", self.xid)) |
| 5264 | packed.append(struct.pack("!H", self.stats_type)) |
| 5265 | packed.append(struct.pack("!H", self.flags)) |
| 5266 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5267 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5268 | length = sum([len(x) for x in packed]) |
| 5269 | packed[2] = struct.pack("!H", length) |
| 5270 | return ''.join(packed) |
| 5271 | |
| 5272 | @staticmethod |
| 5273 | def unpack(buf): |
| 5274 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5275 | obj = queue_stats_reply() |
| 5276 | if type(buf) == loxi.generic_util.OFReader: |
| 5277 | reader = buf |
| 5278 | else: |
| 5279 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5280 | _version = reader.read("!B")[0] |
| 5281 | assert(_version == 2) |
| 5282 | _type = reader.read("!B")[0] |
| 5283 | assert(_type == 19) |
| 5284 | _length = reader.read("!H")[0] |
| 5285 | obj.xid = reader.read("!L")[0] |
| 5286 | _stats_type = reader.read("!H")[0] |
| 5287 | assert(_stats_type == 5) |
| 5288 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5289 | reader.skip(4) |
| 5290 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 5291 | return obj |
| 5292 | |
| 5293 | def __eq__(self, other): |
| 5294 | if type(self) != type(other): return False |
| 5295 | if self.version != other.version: return False |
| 5296 | if self.type != other.type: return False |
| 5297 | if self.xid != other.xid: return False |
| 5298 | if self.flags != other.flags: return False |
| 5299 | if self.entries != other.entries: return False |
| 5300 | return True |
| 5301 | |
| 5302 | def __ne__(self, other): |
| 5303 | return not self.__eq__(other) |
| 5304 | |
| 5305 | def __str__(self): |
| 5306 | return self.show() |
| 5307 | |
| 5308 | def show(self): |
| 5309 | import loxi.pp |
| 5310 | return loxi.pp.pp(self) |
| 5311 | |
| 5312 | def pretty_print(self, q): |
| 5313 | q.text("queue_stats_reply {") |
| 5314 | with q.group(): |
| 5315 | with q.indent(2): |
| 5316 | q.breakable() |
| 5317 | q.text("xid = "); |
| 5318 | if self.xid != None: |
| 5319 | q.text("%#x" % self.xid) |
| 5320 | else: |
| 5321 | q.text('None') |
| 5322 | q.text(","); q.breakable() |
| 5323 | q.text("flags = "); |
| 5324 | q.text("%#x" % self.flags) |
| 5325 | q.text(","); q.breakable() |
| 5326 | q.text("entries = "); |
| 5327 | q.pp(self.entries) |
| 5328 | q.breakable() |
| 5329 | q.text('}') |
| 5330 | |
| 5331 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5332 | version = 2 |
| 5333 | type = 18 |
| 5334 | stats_type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5335 | |
| 5336 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
| 5337 | self.xid = xid |
| 5338 | if flags != None: |
| 5339 | self.flags = flags |
| 5340 | else: |
| 5341 | self.flags = 0 |
| 5342 | if port_no != None: |
| 5343 | self.port_no = port_no |
| 5344 | else: |
| 5345 | self.port_no = 0 |
| 5346 | if queue_id != None: |
| 5347 | self.queue_id = queue_id |
| 5348 | else: |
| 5349 | self.queue_id = 0 |
| 5350 | |
| 5351 | def pack(self): |
| 5352 | packed = [] |
| 5353 | packed.append(struct.pack("!B", self.version)) |
| 5354 | packed.append(struct.pack("!B", self.type)) |
| 5355 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5356 | packed.append(struct.pack("!L", self.xid)) |
| 5357 | packed.append(struct.pack("!H", self.stats_type)) |
| 5358 | packed.append(struct.pack("!H", self.flags)) |
| 5359 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5360 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5361 | packed.append(struct.pack("!L", self.queue_id)) |
| 5362 | length = sum([len(x) for x in packed]) |
| 5363 | packed[2] = struct.pack("!H", length) |
| 5364 | return ''.join(packed) |
| 5365 | |
| 5366 | @staticmethod |
| 5367 | def unpack(buf): |
| 5368 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5369 | obj = queue_stats_request() |
| 5370 | if type(buf) == loxi.generic_util.OFReader: |
| 5371 | reader = buf |
| 5372 | else: |
| 5373 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5374 | _version = reader.read("!B")[0] |
| 5375 | assert(_version == 2) |
| 5376 | _type = reader.read("!B")[0] |
| 5377 | assert(_type == 18) |
| 5378 | _length = reader.read("!H")[0] |
| 5379 | obj.xid = reader.read("!L")[0] |
| 5380 | _stats_type = reader.read("!H")[0] |
| 5381 | assert(_stats_type == 5) |
| 5382 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5383 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5384 | obj.port_no = util.unpack_port_no(reader) |
| 5385 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5386 | return obj |
| 5387 | |
| 5388 | def __eq__(self, other): |
| 5389 | if type(self) != type(other): return False |
| 5390 | if self.version != other.version: return False |
| 5391 | if self.type != other.type: return False |
| 5392 | if self.xid != other.xid: return False |
| 5393 | if self.flags != other.flags: return False |
| 5394 | if self.port_no != other.port_no: return False |
| 5395 | if self.queue_id != other.queue_id: return False |
| 5396 | return True |
| 5397 | |
| 5398 | def __ne__(self, other): |
| 5399 | return not self.__eq__(other) |
| 5400 | |
| 5401 | def __str__(self): |
| 5402 | return self.show() |
| 5403 | |
| 5404 | def show(self): |
| 5405 | import loxi.pp |
| 5406 | return loxi.pp.pp(self) |
| 5407 | |
| 5408 | def pretty_print(self, q): |
| 5409 | q.text("queue_stats_request {") |
| 5410 | with q.group(): |
| 5411 | with q.indent(2): |
| 5412 | q.breakable() |
| 5413 | q.text("xid = "); |
| 5414 | if self.xid != None: |
| 5415 | q.text("%#x" % self.xid) |
| 5416 | else: |
| 5417 | q.text('None') |
| 5418 | q.text(","); q.breakable() |
| 5419 | q.text("flags = "); |
| 5420 | q.text("%#x" % self.flags) |
| 5421 | q.text(","); q.breakable() |
| 5422 | q.text("port_no = "); |
| 5423 | q.text(util.pretty_port(self.port_no)) |
| 5424 | q.text(","); q.breakable() |
| 5425 | q.text("queue_id = "); |
| 5426 | q.text("%#x" % self.queue_id) |
| 5427 | q.breakable() |
| 5428 | q.text('}') |
| 5429 | |
| 5430 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5431 | version = 2 |
| 5432 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5433 | |
| 5434 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 5435 | self.xid = xid |
| 5436 | if flags != None: |
| 5437 | self.flags = flags |
| 5438 | else: |
| 5439 | self.flags = 0 |
| 5440 | if miss_send_len != None: |
| 5441 | self.miss_send_len = miss_send_len |
| 5442 | else: |
| 5443 | self.miss_send_len = 0 |
| 5444 | |
| 5445 | def pack(self): |
| 5446 | packed = [] |
| 5447 | packed.append(struct.pack("!B", self.version)) |
| 5448 | packed.append(struct.pack("!B", self.type)) |
| 5449 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5450 | packed.append(struct.pack("!L", self.xid)) |
| 5451 | packed.append(struct.pack("!H", self.flags)) |
| 5452 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5453 | length = sum([len(x) for x in packed]) |
| 5454 | packed[2] = struct.pack("!H", length) |
| 5455 | return ''.join(packed) |
| 5456 | |
| 5457 | @staticmethod |
| 5458 | def unpack(buf): |
| 5459 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5460 | obj = set_config() |
| 5461 | if type(buf) == loxi.generic_util.OFReader: |
| 5462 | reader = buf |
| 5463 | else: |
| 5464 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5465 | _version = reader.read("!B")[0] |
| 5466 | assert(_version == 2) |
| 5467 | _type = reader.read("!B")[0] |
| 5468 | assert(_type == 9) |
| 5469 | _length = reader.read("!H")[0] |
| 5470 | obj.xid = reader.read("!L")[0] |
| 5471 | obj.flags = reader.read("!H")[0] |
| 5472 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5473 | return obj |
| 5474 | |
| 5475 | def __eq__(self, other): |
| 5476 | if type(self) != type(other): return False |
| 5477 | if self.version != other.version: return False |
| 5478 | if self.type != other.type: return False |
| 5479 | if self.xid != other.xid: return False |
| 5480 | if self.flags != other.flags: return False |
| 5481 | if self.miss_send_len != other.miss_send_len: return False |
| 5482 | return True |
| 5483 | |
| 5484 | def __ne__(self, other): |
| 5485 | return not self.__eq__(other) |
| 5486 | |
| 5487 | def __str__(self): |
| 5488 | return self.show() |
| 5489 | |
| 5490 | def show(self): |
| 5491 | import loxi.pp |
| 5492 | return loxi.pp.pp(self) |
| 5493 | |
| 5494 | def pretty_print(self, q): |
| 5495 | q.text("set_config {") |
| 5496 | with q.group(): |
| 5497 | with q.indent(2): |
| 5498 | q.breakable() |
| 5499 | q.text("xid = "); |
| 5500 | if self.xid != None: |
| 5501 | q.text("%#x" % self.xid) |
| 5502 | else: |
| 5503 | q.text('None') |
| 5504 | q.text(","); q.breakable() |
| 5505 | q.text("flags = "); |
| 5506 | q.text("%#x" % self.flags) |
| 5507 | q.text(","); q.breakable() |
| 5508 | q.text("miss_send_len = "); |
| 5509 | q.text("%#x" % self.miss_send_len) |
| 5510 | q.breakable() |
| 5511 | q.text('}') |
| 5512 | |
| 5513 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5514 | version = 2 |
| 5515 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5516 | |
| 5517 | def __init__(self, xid=None, table_id=None, config=None): |
| 5518 | self.xid = xid |
| 5519 | if table_id != None: |
| 5520 | self.table_id = table_id |
| 5521 | else: |
| 5522 | self.table_id = 0 |
| 5523 | if config != None: |
| 5524 | self.config = config |
| 5525 | else: |
| 5526 | self.config = 0 |
| 5527 | |
| 5528 | def pack(self): |
| 5529 | packed = [] |
| 5530 | packed.append(struct.pack("!B", self.version)) |
| 5531 | packed.append(struct.pack("!B", self.type)) |
| 5532 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5533 | packed.append(struct.pack("!L", self.xid)) |
| 5534 | packed.append(struct.pack("!B", self.table_id)) |
| 5535 | packed.append('\x00' * 3) |
| 5536 | packed.append(struct.pack("!L", self.config)) |
| 5537 | length = sum([len(x) for x in packed]) |
| 5538 | packed[2] = struct.pack("!H", length) |
| 5539 | return ''.join(packed) |
| 5540 | |
| 5541 | @staticmethod |
| 5542 | def unpack(buf): |
| 5543 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5544 | obj = table_mod() |
| 5545 | if type(buf) == loxi.generic_util.OFReader: |
| 5546 | reader = buf |
| 5547 | else: |
| 5548 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5549 | _version = reader.read("!B")[0] |
| 5550 | assert(_version == 2) |
| 5551 | _type = reader.read("!B")[0] |
| 5552 | assert(_type == 17) |
| 5553 | _length = reader.read("!H")[0] |
| 5554 | obj.xid = reader.read("!L")[0] |
| 5555 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5556 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5557 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5558 | return obj |
| 5559 | |
| 5560 | def __eq__(self, other): |
| 5561 | if type(self) != type(other): return False |
| 5562 | if self.version != other.version: return False |
| 5563 | if self.type != other.type: return False |
| 5564 | if self.xid != other.xid: return False |
| 5565 | if self.table_id != other.table_id: return False |
| 5566 | if self.config != other.config: return False |
| 5567 | return True |
| 5568 | |
| 5569 | def __ne__(self, other): |
| 5570 | return not self.__eq__(other) |
| 5571 | |
| 5572 | def __str__(self): |
| 5573 | return self.show() |
| 5574 | |
| 5575 | def show(self): |
| 5576 | import loxi.pp |
| 5577 | return loxi.pp.pp(self) |
| 5578 | |
| 5579 | def pretty_print(self, q): |
| 5580 | q.text("table_mod {") |
| 5581 | with q.group(): |
| 5582 | with q.indent(2): |
| 5583 | q.breakable() |
| 5584 | q.text("xid = "); |
| 5585 | if self.xid != None: |
| 5586 | q.text("%#x" % self.xid) |
| 5587 | else: |
| 5588 | q.text('None') |
| 5589 | q.text(","); q.breakable() |
| 5590 | q.text("table_id = "); |
| 5591 | q.text("%#x" % self.table_id) |
| 5592 | q.text(","); q.breakable() |
| 5593 | q.text("config = "); |
| 5594 | q.text("%#x" % self.config) |
| 5595 | q.breakable() |
| 5596 | q.text('}') |
| 5597 | |
| 5598 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5599 | version = 2 |
| 5600 | type = 19 |
| 5601 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5602 | |
| 5603 | def __init__(self, xid=None, flags=None, entries=None): |
| 5604 | self.xid = xid |
| 5605 | if flags != None: |
| 5606 | self.flags = flags |
| 5607 | else: |
| 5608 | self.flags = 0 |
| 5609 | if entries != None: |
| 5610 | self.entries = entries |
| 5611 | else: |
| 5612 | self.entries = [] |
| 5613 | |
| 5614 | def pack(self): |
| 5615 | packed = [] |
| 5616 | packed.append(struct.pack("!B", self.version)) |
| 5617 | packed.append(struct.pack("!B", self.type)) |
| 5618 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5619 | packed.append(struct.pack("!L", self.xid)) |
| 5620 | packed.append(struct.pack("!H", self.stats_type)) |
| 5621 | packed.append(struct.pack("!H", self.flags)) |
| 5622 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5623 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5624 | length = sum([len(x) for x in packed]) |
| 5625 | packed[2] = struct.pack("!H", length) |
| 5626 | return ''.join(packed) |
| 5627 | |
| 5628 | @staticmethod |
| 5629 | def unpack(buf): |
| 5630 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5631 | obj = table_stats_reply() |
| 5632 | if type(buf) == loxi.generic_util.OFReader: |
| 5633 | reader = buf |
| 5634 | else: |
| 5635 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5636 | _version = reader.read("!B")[0] |
| 5637 | assert(_version == 2) |
| 5638 | _type = reader.read("!B")[0] |
| 5639 | assert(_type == 19) |
| 5640 | _length = reader.read("!H")[0] |
| 5641 | obj.xid = reader.read("!L")[0] |
| 5642 | _stats_type = reader.read("!H")[0] |
| 5643 | assert(_stats_type == 3) |
| 5644 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5645 | reader.skip(4) |
| 5646 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 5647 | return obj |
| 5648 | |
| 5649 | def __eq__(self, other): |
| 5650 | if type(self) != type(other): return False |
| 5651 | if self.version != other.version: return False |
| 5652 | if self.type != other.type: return False |
| 5653 | if self.xid != other.xid: return False |
| 5654 | if self.flags != other.flags: return False |
| 5655 | if self.entries != other.entries: return False |
| 5656 | return True |
| 5657 | |
| 5658 | def __ne__(self, other): |
| 5659 | return not self.__eq__(other) |
| 5660 | |
| 5661 | def __str__(self): |
| 5662 | return self.show() |
| 5663 | |
| 5664 | def show(self): |
| 5665 | import loxi.pp |
| 5666 | return loxi.pp.pp(self) |
| 5667 | |
| 5668 | def pretty_print(self, q): |
| 5669 | q.text("table_stats_reply {") |
| 5670 | with q.group(): |
| 5671 | with q.indent(2): |
| 5672 | q.breakable() |
| 5673 | q.text("xid = "); |
| 5674 | if self.xid != None: |
| 5675 | q.text("%#x" % self.xid) |
| 5676 | else: |
| 5677 | q.text('None') |
| 5678 | q.text(","); q.breakable() |
| 5679 | q.text("flags = "); |
| 5680 | q.text("%#x" % self.flags) |
| 5681 | q.text(","); q.breakable() |
| 5682 | q.text("entries = "); |
| 5683 | q.pp(self.entries) |
| 5684 | q.breakable() |
| 5685 | q.text('}') |
| 5686 | |
| 5687 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5688 | version = 2 |
| 5689 | type = 18 |
| 5690 | stats_type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5691 | |
| 5692 | def __init__(self, xid=None, flags=None): |
| 5693 | self.xid = xid |
| 5694 | if flags != None: |
| 5695 | self.flags = flags |
| 5696 | else: |
| 5697 | self.flags = 0 |
| 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(struct.pack("!H", self.stats_type)) |
| 5706 | packed.append(struct.pack("!H", self.flags)) |
| 5707 | packed.append('\x00' * 4) |
| 5708 | length = sum([len(x) for x in packed]) |
| 5709 | packed[2] = struct.pack("!H", length) |
| 5710 | return ''.join(packed) |
| 5711 | |
| 5712 | @staticmethod |
| 5713 | def unpack(buf): |
| 5714 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5715 | obj = table_stats_request() |
| 5716 | if type(buf) == loxi.generic_util.OFReader: |
| 5717 | reader = buf |
| 5718 | else: |
| 5719 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5720 | _version = reader.read("!B")[0] |
| 5721 | assert(_version == 2) |
| 5722 | _type = reader.read("!B")[0] |
| 5723 | assert(_type == 18) |
| 5724 | _length = reader.read("!H")[0] |
| 5725 | obj.xid = reader.read("!L")[0] |
| 5726 | _stats_type = reader.read("!H")[0] |
| 5727 | assert(_stats_type == 3) |
| 5728 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5729 | reader.skip(4) |
| 5730 | return obj |
| 5731 | |
| 5732 | def __eq__(self, other): |
| 5733 | if type(self) != type(other): return False |
| 5734 | if self.version != other.version: return False |
| 5735 | if self.type != other.type: return False |
| 5736 | if self.xid != other.xid: return False |
| 5737 | if self.flags != other.flags: return False |
| 5738 | return True |
| 5739 | |
| 5740 | def __ne__(self, other): |
| 5741 | return not self.__eq__(other) |
| 5742 | |
| 5743 | def __str__(self): |
| 5744 | return self.show() |
| 5745 | |
| 5746 | def show(self): |
| 5747 | import loxi.pp |
| 5748 | return loxi.pp.pp(self) |
| 5749 | |
| 5750 | def pretty_print(self, q): |
| 5751 | q.text("table_stats_request {") |
| 5752 | with q.group(): |
| 5753 | with q.indent(2): |
| 5754 | q.breakable() |
| 5755 | q.text("xid = "); |
| 5756 | if self.xid != None: |
| 5757 | q.text("%#x" % self.xid) |
| 5758 | else: |
| 5759 | q.text('None') |
| 5760 | q.text(","); q.breakable() |
| 5761 | q.text("flags = "); |
| 5762 | q.text("%#x" % self.flags) |
| 5763 | q.breakable() |
| 5764 | q.text('}') |
| 5765 | |
| 5766 | |
| 5767 | def parse_header(buf): |
| 5768 | if len(buf) < 8: |
| 5769 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 5770 | return struct.unpack_from("!BBHL", buf) |
| 5771 | |
| 5772 | def parse_message(buf): |
| 5773 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 5774 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 5775 | 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] | 5776 | if len(buf) != msg_len: |
| 5777 | raise loxi.ProtocolError("incorrect message size") |
| 5778 | if msg_type in parsers: |
| 5779 | return parsers[msg_type](buf) |
| 5780 | else: |
| 5781 | raise loxi.ProtocolError("unexpected message type") |
| 5782 | |
| 5783 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 5784 | if len(buf) < 25 + 1: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5785 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 5786 | # Technically uint16_t for OF 1.0 |
| 5787 | cmd, = struct.unpack_from("!B", buf, 25) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5788 | if cmd in flow_mod_parsers: |
| 5789 | return flow_mod_parsers[cmd](buf) |
| 5790 | else: |
| 5791 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 5792 | |
| 5793 | def parse_stats_reply(buf): |
| 5794 | if len(buf) < 8 + 2: |
| 5795 | raise loxi.ProtocolError("message too short") |
| 5796 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 5797 | if stats_type in stats_reply_parsers: |
| 5798 | return stats_reply_parsers[stats_type](buf) |
| 5799 | else: |
| 5800 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 5801 | |
| 5802 | def parse_stats_request(buf): |
| 5803 | if len(buf) < 8 + 2: |
| 5804 | raise loxi.ProtocolError("message too short") |
| 5805 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 5806 | if stats_type in stats_request_parsers: |
| 5807 | return stats_request_parsers[stats_type](buf) |
| 5808 | else: |
| 5809 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 5810 | |
| 5811 | def parse_experimenter(buf): |
| 5812 | if len(buf) < 16: |
| 5813 | raise loxi.ProtocolError("experimenter message too short") |
| 5814 | |
| 5815 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 5816 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 5817 | subtype, = struct.unpack_from("!L", buf, 12) |
| 5818 | elif experimenter == 0x00002320: # Nicira |
| 5819 | subtype, = struct.unpack_from("!L", buf, 12) |
| 5820 | else: |
| 5821 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 5822 | |
| 5823 | if subtype in experimenter_parsers[experimenter]: |
| 5824 | return experimenter_parsers[experimenter][subtype](buf) |
| 5825 | else: |
| 5826 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 5827 | |
| 5828 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5829 | const.OFPT_HELLO : hello.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5830 | const.OFPT_ERROR : error_msg.unpack, |
| 5831 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 5832 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
| 5833 | const.OFPT_EXPERIMENTER : parse_experimenter, |
| 5834 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 5835 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 5836 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 5837 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5838 | const.OFPT_SET_CONFIG : set_config.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5839 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 5840 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 5841 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 5842 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 5843 | const.OFPT_FLOW_MOD : parse_flow_mod, |
| 5844 | const.OFPT_GROUP_MOD : group_mod.unpack, |
| 5845 | const.OFPT_PORT_MOD : port_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5846 | const.OFPT_TABLE_MOD : table_mod.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5847 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 5848 | const.OFPT_STATS_REPLY : parse_stats_reply, |
| 5849 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 5850 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 5851 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 5852 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5853 | } |
| 5854 | |
| 5855 | flow_mod_parsers = { |
| 5856 | const.OFPFC_ADD : flow_add.unpack, |
| 5857 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 5858 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 5859 | const.OFPFC_DELETE : flow_delete.unpack, |
| 5860 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 5861 | } |
| 5862 | |
| 5863 | stats_reply_parsers = { |
| 5864 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 5865 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 5866 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 5867 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 5868 | const.OFPST_PORT : port_stats_reply.unpack, |
| 5869 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 5870 | const.OFPST_GROUP : group_stats_reply.unpack, |
| 5871 | const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5872 | } |
| 5873 | |
| 5874 | stats_request_parsers = { |
| 5875 | const.OFPST_DESC : desc_stats_request.unpack, |
| 5876 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 5877 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 5878 | const.OFPST_TABLE : table_stats_request.unpack, |
| 5879 | const.OFPST_PORT : port_stats_request.unpack, |
| 5880 | const.OFPST_QUEUE : queue_stats_request.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 5881 | const.OFPST_GROUP : group_stats_request.unpack, |
| 5882 | const.OFPST_GROUP_DESC : group_desc_stats_request.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5883 | } |
| 5884 | |
| 5885 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5886 | 6035143 : { |
| 5887 | 22: bsn_bw_clear_data_reply.unpack, |
| 5888 | 21: bsn_bw_clear_data_request.unpack, |
| 5889 | 20: bsn_bw_enable_get_reply.unpack, |
| 5890 | 19: bsn_bw_enable_get_request.unpack, |
| 5891 | 23: bsn_bw_enable_set_reply.unpack, |
| 5892 | 18: bsn_bw_enable_set_request.unpack, |
| 5893 | 10: bsn_get_interfaces_reply.unpack, |
| 5894 | 9: bsn_get_interfaces_request.unpack, |
| 5895 | 5: bsn_get_mirroring_reply.unpack, |
| 5896 | 4: bsn_get_mirroring_request.unpack, |
| 5897 | 3: bsn_set_mirroring.unpack, |
| 5898 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 5899 | 11: bsn_set_pktin_suppression_request.unpack, |
| 5900 | 16: bsn_virtual_port_create_reply.unpack, |
| 5901 | 15: bsn_virtual_port_create_request.unpack, |
| 5902 | 26: bsn_virtual_port_remove_reply.unpack, |
| 5903 | 17: bsn_virtual_port_remove_request.unpack, |
| 5904 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5905 | } |