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 meter_band # for unpack_list |
| 16 | import util |
| 17 | import loxi.generic_util |
| 18 | |
| 19 | class Message(object): |
| 20 | version = const.OFP_VERSION |
| 21 | type = None # override in subclass |
| 22 | xid = None |
| 23 | |
| 24 | class aggregate_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 25 | version = 4 |
| 26 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 27 | stats_type = 2 |
| 28 | |
| 29 | def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None): |
| 30 | self.xid = xid |
| 31 | if flags != None: |
| 32 | self.flags = flags |
| 33 | else: |
| 34 | self.flags = 0 |
| 35 | if packet_count != None: |
| 36 | self.packet_count = packet_count |
| 37 | else: |
| 38 | self.packet_count = 0 |
| 39 | if byte_count != None: |
| 40 | self.byte_count = byte_count |
| 41 | else: |
| 42 | self.byte_count = 0 |
| 43 | if flow_count != None: |
| 44 | self.flow_count = flow_count |
| 45 | else: |
| 46 | self.flow_count = 0 |
| 47 | |
| 48 | def pack(self): |
| 49 | packed = [] |
| 50 | packed.append(struct.pack("!B", self.version)) |
| 51 | packed.append(struct.pack("!B", self.type)) |
| 52 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 53 | packed.append(struct.pack("!L", self.xid)) |
| 54 | packed.append(struct.pack("!H", self.stats_type)) |
| 55 | packed.append(struct.pack("!H", self.flags)) |
| 56 | packed.append('\x00' * 4) |
| 57 | packed.append(struct.pack("!Q", self.packet_count)) |
| 58 | packed.append(struct.pack("!Q", self.byte_count)) |
| 59 | packed.append(struct.pack("!L", self.flow_count)) |
| 60 | packed.append('\x00' * 4) |
| 61 | length = sum([len(x) for x in packed]) |
| 62 | packed[2] = struct.pack("!H", length) |
| 63 | return ''.join(packed) |
| 64 | |
| 65 | @staticmethod |
| 66 | def unpack(buf): |
| 67 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 68 | obj = aggregate_stats_reply() |
| 69 | if type(buf) == loxi.generic_util.OFReader: |
| 70 | reader = buf |
| 71 | else: |
| 72 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 73 | _version = reader.read("!B")[0] |
| 74 | assert(_version == 4) |
| 75 | _type = reader.read("!B")[0] |
| 76 | assert(_type == 19) |
| 77 | _length = reader.read("!H")[0] |
| 78 | obj.xid = reader.read("!L")[0] |
| 79 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 80 | assert(_stats_type == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 81 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 82 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 83 | obj.packet_count = reader.read("!Q")[0] |
| 84 | obj.byte_count = reader.read("!Q")[0] |
| 85 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 86 | reader.skip(4) |
| 87 | return obj |
| 88 | |
| 89 | def __eq__(self, other): |
| 90 | if type(self) != type(other): return False |
| 91 | if self.version != other.version: return False |
| 92 | if self.type != other.type: return False |
| 93 | if self.xid != other.xid: return False |
| 94 | if self.flags != other.flags: return False |
| 95 | if self.packet_count != other.packet_count: return False |
| 96 | if self.byte_count != other.byte_count: return False |
| 97 | if self.flow_count != other.flow_count: return False |
| 98 | return True |
| 99 | |
| 100 | def __ne__(self, other): |
| 101 | return not self.__eq__(other) |
| 102 | |
| 103 | def __str__(self): |
| 104 | return self.show() |
| 105 | |
| 106 | def show(self): |
| 107 | import loxi.pp |
| 108 | return loxi.pp.pp(self) |
| 109 | |
| 110 | def pretty_print(self, q): |
| 111 | q.text("aggregate_stats_reply {") |
| 112 | with q.group(): |
| 113 | with q.indent(2): |
| 114 | q.breakable() |
| 115 | q.text("xid = "); |
| 116 | if self.xid != None: |
| 117 | q.text("%#x" % self.xid) |
| 118 | else: |
| 119 | q.text('None') |
| 120 | q.text(","); q.breakable() |
| 121 | q.text("flags = "); |
| 122 | q.text("%#x" % self.flags) |
| 123 | q.text(","); q.breakable() |
| 124 | q.text("packet_count = "); |
| 125 | q.text("%#x" % self.packet_count) |
| 126 | q.text(","); q.breakable() |
| 127 | q.text("byte_count = "); |
| 128 | q.text("%#x" % self.byte_count) |
| 129 | q.text(","); q.breakable() |
| 130 | q.text("flow_count = "); |
| 131 | q.text("%#x" % self.flow_count) |
| 132 | q.breakable() |
| 133 | q.text('}') |
| 134 | |
| 135 | class aggregate_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 136 | version = 4 |
| 137 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 138 | stats_type = 2 |
| 139 | |
| 140 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 141 | self.xid = xid |
| 142 | if flags != None: |
| 143 | self.flags = flags |
| 144 | else: |
| 145 | self.flags = 0 |
| 146 | if table_id != None: |
| 147 | self.table_id = table_id |
| 148 | else: |
| 149 | self.table_id = 0 |
| 150 | if out_port != None: |
| 151 | self.out_port = out_port |
| 152 | else: |
| 153 | self.out_port = 0 |
| 154 | if out_group != None: |
| 155 | self.out_group = out_group |
| 156 | else: |
| 157 | self.out_group = 0 |
| 158 | if cookie != None: |
| 159 | self.cookie = cookie |
| 160 | else: |
| 161 | self.cookie = 0 |
| 162 | if cookie_mask != None: |
| 163 | self.cookie_mask = cookie_mask |
| 164 | else: |
| 165 | self.cookie_mask = 0 |
| 166 | if match != None: |
| 167 | self.match = match |
| 168 | else: |
| 169 | self.match = common.match() |
| 170 | |
| 171 | def pack(self): |
| 172 | packed = [] |
| 173 | packed.append(struct.pack("!B", self.version)) |
| 174 | packed.append(struct.pack("!B", self.type)) |
| 175 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 176 | packed.append(struct.pack("!L", self.xid)) |
| 177 | packed.append(struct.pack("!H", self.stats_type)) |
| 178 | packed.append(struct.pack("!H", self.flags)) |
| 179 | packed.append('\x00' * 4) |
| 180 | packed.append(struct.pack("!B", self.table_id)) |
| 181 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 182 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 183 | packed.append(struct.pack("!L", self.out_group)) |
| 184 | packed.append('\x00' * 4) |
| 185 | packed.append(struct.pack("!Q", self.cookie)) |
| 186 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 187 | packed.append(self.match.pack()) |
| 188 | length = sum([len(x) for x in packed]) |
| 189 | packed[2] = struct.pack("!H", length) |
| 190 | return ''.join(packed) |
| 191 | |
| 192 | @staticmethod |
| 193 | def unpack(buf): |
| 194 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 195 | obj = aggregate_stats_request() |
| 196 | if type(buf) == loxi.generic_util.OFReader: |
| 197 | reader = buf |
| 198 | else: |
| 199 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 200 | _version = reader.read("!B")[0] |
| 201 | assert(_version == 4) |
| 202 | _type = reader.read("!B")[0] |
| 203 | assert(_type == 18) |
| 204 | _length = reader.read("!H")[0] |
| 205 | obj.xid = reader.read("!L")[0] |
| 206 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 207 | assert(_stats_type == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 208 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 209 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 210 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 211 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 212 | obj.out_port = util.unpack_port_no(reader) |
| 213 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 214 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 215 | obj.cookie = reader.read("!Q")[0] |
| 216 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 217 | obj.match = common.match.unpack(reader) |
| 218 | return obj |
| 219 | |
| 220 | def __eq__(self, other): |
| 221 | if type(self) != type(other): return False |
| 222 | if self.version != other.version: return False |
| 223 | if self.type != other.type: return False |
| 224 | if self.xid != other.xid: return False |
| 225 | if self.flags != other.flags: return False |
| 226 | if self.table_id != other.table_id: return False |
| 227 | if self.out_port != other.out_port: return False |
| 228 | if self.out_group != other.out_group: return False |
| 229 | if self.cookie != other.cookie: return False |
| 230 | if self.cookie_mask != other.cookie_mask: return False |
| 231 | if self.match != other.match: return False |
| 232 | return True |
| 233 | |
| 234 | def __ne__(self, other): |
| 235 | return not self.__eq__(other) |
| 236 | |
| 237 | def __str__(self): |
| 238 | return self.show() |
| 239 | |
| 240 | def show(self): |
| 241 | import loxi.pp |
| 242 | return loxi.pp.pp(self) |
| 243 | |
| 244 | def pretty_print(self, q): |
| 245 | q.text("aggregate_stats_request {") |
| 246 | with q.group(): |
| 247 | with q.indent(2): |
| 248 | q.breakable() |
| 249 | q.text("xid = "); |
| 250 | if self.xid != None: |
| 251 | q.text("%#x" % self.xid) |
| 252 | else: |
| 253 | q.text('None') |
| 254 | q.text(","); q.breakable() |
| 255 | q.text("flags = "); |
| 256 | q.text("%#x" % self.flags) |
| 257 | q.text(","); q.breakable() |
| 258 | q.text("table_id = "); |
| 259 | q.text("%#x" % self.table_id) |
| 260 | q.text(","); q.breakable() |
| 261 | q.text("out_port = "); |
| 262 | q.text(util.pretty_port(self.out_port)) |
| 263 | q.text(","); q.breakable() |
| 264 | q.text("out_group = "); |
| 265 | q.text("%#x" % self.out_group) |
| 266 | q.text(","); q.breakable() |
| 267 | q.text("cookie = "); |
| 268 | q.text("%#x" % self.cookie) |
| 269 | q.text(","); q.breakable() |
| 270 | q.text("cookie_mask = "); |
| 271 | q.text("%#x" % self.cookie_mask) |
| 272 | q.text(","); q.breakable() |
| 273 | q.text("match = "); |
| 274 | q.pp(self.match) |
| 275 | q.breakable() |
| 276 | q.text('}') |
| 277 | |
| 278 | class async_get_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 279 | version = 4 |
| 280 | type = 27 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 281 | |
| 282 | def __init__(self, xid=None, packet_in_mask_equal_master=None, packet_in_mask_slave=None, port_status_mask_equal_master=None, port_status_mask_slave=None, flow_removed_mask_equal_master=None, flow_removed_mask_slave=None): |
| 283 | self.xid = xid |
| 284 | if packet_in_mask_equal_master != None: |
| 285 | self.packet_in_mask_equal_master = packet_in_mask_equal_master |
| 286 | else: |
| 287 | self.packet_in_mask_equal_master = 0 |
| 288 | if packet_in_mask_slave != None: |
| 289 | self.packet_in_mask_slave = packet_in_mask_slave |
| 290 | else: |
| 291 | self.packet_in_mask_slave = 0 |
| 292 | if port_status_mask_equal_master != None: |
| 293 | self.port_status_mask_equal_master = port_status_mask_equal_master |
| 294 | else: |
| 295 | self.port_status_mask_equal_master = 0 |
| 296 | if port_status_mask_slave != None: |
| 297 | self.port_status_mask_slave = port_status_mask_slave |
| 298 | else: |
| 299 | self.port_status_mask_slave = 0 |
| 300 | if flow_removed_mask_equal_master != None: |
| 301 | self.flow_removed_mask_equal_master = flow_removed_mask_equal_master |
| 302 | else: |
| 303 | self.flow_removed_mask_equal_master = 0 |
| 304 | if flow_removed_mask_slave != None: |
| 305 | self.flow_removed_mask_slave = flow_removed_mask_slave |
| 306 | else: |
| 307 | self.flow_removed_mask_slave = 0 |
| 308 | |
| 309 | def pack(self): |
| 310 | packed = [] |
| 311 | packed.append(struct.pack("!B", self.version)) |
| 312 | packed.append(struct.pack("!B", self.type)) |
| 313 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 314 | packed.append(struct.pack("!L", self.xid)) |
| 315 | packed.append(struct.pack("!L", self.packet_in_mask_equal_master)) |
| 316 | packed.append(struct.pack("!L", self.packet_in_mask_slave)) |
| 317 | packed.append(struct.pack("!L", self.port_status_mask_equal_master)) |
| 318 | packed.append(struct.pack("!L", self.port_status_mask_slave)) |
| 319 | packed.append(struct.pack("!L", self.flow_removed_mask_equal_master)) |
| 320 | packed.append(struct.pack("!L", self.flow_removed_mask_slave)) |
| 321 | length = sum([len(x) for x in packed]) |
| 322 | packed[2] = struct.pack("!H", length) |
| 323 | return ''.join(packed) |
| 324 | |
| 325 | @staticmethod |
| 326 | def unpack(buf): |
| 327 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 328 | obj = async_get_reply() |
| 329 | if type(buf) == loxi.generic_util.OFReader: |
| 330 | reader = buf |
| 331 | else: |
| 332 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 333 | _version = reader.read("!B")[0] |
| 334 | assert(_version == 4) |
| 335 | _type = reader.read("!B")[0] |
| 336 | assert(_type == 27) |
| 337 | _length = reader.read("!H")[0] |
| 338 | obj.xid = reader.read("!L")[0] |
| 339 | obj.packet_in_mask_equal_master = reader.read("!L")[0] |
| 340 | obj.packet_in_mask_slave = reader.read("!L")[0] |
| 341 | obj.port_status_mask_equal_master = reader.read("!L")[0] |
| 342 | obj.port_status_mask_slave = reader.read("!L")[0] |
| 343 | obj.flow_removed_mask_equal_master = reader.read("!L")[0] |
| 344 | obj.flow_removed_mask_slave = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 345 | return obj |
| 346 | |
| 347 | def __eq__(self, other): |
| 348 | if type(self) != type(other): return False |
| 349 | if self.version != other.version: return False |
| 350 | if self.type != other.type: return False |
| 351 | if self.xid != other.xid: return False |
| 352 | if self.packet_in_mask_equal_master != other.packet_in_mask_equal_master: return False |
| 353 | if self.packet_in_mask_slave != other.packet_in_mask_slave: return False |
| 354 | if self.port_status_mask_equal_master != other.port_status_mask_equal_master: return False |
| 355 | if self.port_status_mask_slave != other.port_status_mask_slave: return False |
| 356 | if self.flow_removed_mask_equal_master != other.flow_removed_mask_equal_master: return False |
| 357 | if self.flow_removed_mask_slave != other.flow_removed_mask_slave: return False |
| 358 | return True |
| 359 | |
| 360 | def __ne__(self, other): |
| 361 | return not self.__eq__(other) |
| 362 | |
| 363 | def __str__(self): |
| 364 | return self.show() |
| 365 | |
| 366 | def show(self): |
| 367 | import loxi.pp |
| 368 | return loxi.pp.pp(self) |
| 369 | |
| 370 | def pretty_print(self, q): |
| 371 | q.text("async_get_reply {") |
| 372 | with q.group(): |
| 373 | with q.indent(2): |
| 374 | q.breakable() |
| 375 | q.text("xid = "); |
| 376 | if self.xid != None: |
| 377 | q.text("%#x" % self.xid) |
| 378 | else: |
| 379 | q.text('None') |
| 380 | q.text(","); q.breakable() |
| 381 | q.text("packet_in_mask_equal_master = "); |
| 382 | q.text("%#x" % self.packet_in_mask_equal_master) |
| 383 | q.text(","); q.breakable() |
| 384 | q.text("packet_in_mask_slave = "); |
| 385 | q.text("%#x" % self.packet_in_mask_slave) |
| 386 | q.text(","); q.breakable() |
| 387 | q.text("port_status_mask_equal_master = "); |
| 388 | q.text("%#x" % self.port_status_mask_equal_master) |
| 389 | q.text(","); q.breakable() |
| 390 | q.text("port_status_mask_slave = "); |
| 391 | q.text("%#x" % self.port_status_mask_slave) |
| 392 | q.text(","); q.breakable() |
| 393 | q.text("flow_removed_mask_equal_master = "); |
| 394 | q.text("%#x" % self.flow_removed_mask_equal_master) |
| 395 | q.text(","); q.breakable() |
| 396 | q.text("flow_removed_mask_slave = "); |
| 397 | q.text("%#x" % self.flow_removed_mask_slave) |
| 398 | q.breakable() |
| 399 | q.text('}') |
| 400 | |
| 401 | class async_get_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 402 | version = 4 |
| 403 | type = 26 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 404 | |
| 405 | def __init__(self, xid=None, packet_in_mask_equal_master=None, packet_in_mask_slave=None, port_status_mask_equal_master=None, port_status_mask_slave=None, flow_removed_mask_equal_master=None, flow_removed_mask_slave=None): |
| 406 | self.xid = xid |
| 407 | if packet_in_mask_equal_master != None: |
| 408 | self.packet_in_mask_equal_master = packet_in_mask_equal_master |
| 409 | else: |
| 410 | self.packet_in_mask_equal_master = 0 |
| 411 | if packet_in_mask_slave != None: |
| 412 | self.packet_in_mask_slave = packet_in_mask_slave |
| 413 | else: |
| 414 | self.packet_in_mask_slave = 0 |
| 415 | if port_status_mask_equal_master != None: |
| 416 | self.port_status_mask_equal_master = port_status_mask_equal_master |
| 417 | else: |
| 418 | self.port_status_mask_equal_master = 0 |
| 419 | if port_status_mask_slave != None: |
| 420 | self.port_status_mask_slave = port_status_mask_slave |
| 421 | else: |
| 422 | self.port_status_mask_slave = 0 |
| 423 | if flow_removed_mask_equal_master != None: |
| 424 | self.flow_removed_mask_equal_master = flow_removed_mask_equal_master |
| 425 | else: |
| 426 | self.flow_removed_mask_equal_master = 0 |
| 427 | if flow_removed_mask_slave != None: |
| 428 | self.flow_removed_mask_slave = flow_removed_mask_slave |
| 429 | else: |
| 430 | self.flow_removed_mask_slave = 0 |
| 431 | |
| 432 | def pack(self): |
| 433 | packed = [] |
| 434 | packed.append(struct.pack("!B", self.version)) |
| 435 | packed.append(struct.pack("!B", self.type)) |
| 436 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 437 | packed.append(struct.pack("!L", self.xid)) |
| 438 | packed.append(struct.pack("!L", self.packet_in_mask_equal_master)) |
| 439 | packed.append(struct.pack("!L", self.packet_in_mask_slave)) |
| 440 | packed.append(struct.pack("!L", self.port_status_mask_equal_master)) |
| 441 | packed.append(struct.pack("!L", self.port_status_mask_slave)) |
| 442 | packed.append(struct.pack("!L", self.flow_removed_mask_equal_master)) |
| 443 | packed.append(struct.pack("!L", self.flow_removed_mask_slave)) |
| 444 | length = sum([len(x) for x in packed]) |
| 445 | packed[2] = struct.pack("!H", length) |
| 446 | return ''.join(packed) |
| 447 | |
| 448 | @staticmethod |
| 449 | def unpack(buf): |
| 450 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 451 | obj = async_get_request() |
| 452 | if type(buf) == loxi.generic_util.OFReader: |
| 453 | reader = buf |
| 454 | else: |
| 455 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 456 | _version = reader.read("!B")[0] |
| 457 | assert(_version == 4) |
| 458 | _type = reader.read("!B")[0] |
| 459 | assert(_type == 26) |
| 460 | _length = reader.read("!H")[0] |
| 461 | obj.xid = reader.read("!L")[0] |
| 462 | obj.packet_in_mask_equal_master = reader.read("!L")[0] |
| 463 | obj.packet_in_mask_slave = reader.read("!L")[0] |
| 464 | obj.port_status_mask_equal_master = reader.read("!L")[0] |
| 465 | obj.port_status_mask_slave = reader.read("!L")[0] |
| 466 | obj.flow_removed_mask_equal_master = reader.read("!L")[0] |
| 467 | obj.flow_removed_mask_slave = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 468 | return obj |
| 469 | |
| 470 | def __eq__(self, other): |
| 471 | if type(self) != type(other): return False |
| 472 | if self.version != other.version: return False |
| 473 | if self.type != other.type: return False |
| 474 | if self.xid != other.xid: return False |
| 475 | if self.packet_in_mask_equal_master != other.packet_in_mask_equal_master: return False |
| 476 | if self.packet_in_mask_slave != other.packet_in_mask_slave: return False |
| 477 | if self.port_status_mask_equal_master != other.port_status_mask_equal_master: return False |
| 478 | if self.port_status_mask_slave != other.port_status_mask_slave: return False |
| 479 | if self.flow_removed_mask_equal_master != other.flow_removed_mask_equal_master: return False |
| 480 | if self.flow_removed_mask_slave != other.flow_removed_mask_slave: return False |
| 481 | return True |
| 482 | |
| 483 | def __ne__(self, other): |
| 484 | return not self.__eq__(other) |
| 485 | |
| 486 | def __str__(self): |
| 487 | return self.show() |
| 488 | |
| 489 | def show(self): |
| 490 | import loxi.pp |
| 491 | return loxi.pp.pp(self) |
| 492 | |
| 493 | def pretty_print(self, q): |
| 494 | q.text("async_get_request {") |
| 495 | with q.group(): |
| 496 | with q.indent(2): |
| 497 | q.breakable() |
| 498 | q.text("xid = "); |
| 499 | if self.xid != None: |
| 500 | q.text("%#x" % self.xid) |
| 501 | else: |
| 502 | q.text('None') |
| 503 | q.text(","); q.breakable() |
| 504 | q.text("packet_in_mask_equal_master = "); |
| 505 | q.text("%#x" % self.packet_in_mask_equal_master) |
| 506 | q.text(","); q.breakable() |
| 507 | q.text("packet_in_mask_slave = "); |
| 508 | q.text("%#x" % self.packet_in_mask_slave) |
| 509 | q.text(","); q.breakable() |
| 510 | q.text("port_status_mask_equal_master = "); |
| 511 | q.text("%#x" % self.port_status_mask_equal_master) |
| 512 | q.text(","); q.breakable() |
| 513 | q.text("port_status_mask_slave = "); |
| 514 | q.text("%#x" % self.port_status_mask_slave) |
| 515 | q.text(","); q.breakable() |
| 516 | q.text("flow_removed_mask_equal_master = "); |
| 517 | q.text("%#x" % self.flow_removed_mask_equal_master) |
| 518 | q.text(","); q.breakable() |
| 519 | q.text("flow_removed_mask_slave = "); |
| 520 | q.text("%#x" % self.flow_removed_mask_slave) |
| 521 | q.breakable() |
| 522 | q.text('}') |
| 523 | |
| 524 | class async_set(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 525 | version = 4 |
| 526 | type = 28 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 527 | |
| 528 | def __init__(self, xid=None, packet_in_mask_equal_master=None, packet_in_mask_slave=None, port_status_mask_equal_master=None, port_status_mask_slave=None, flow_removed_mask_equal_master=None, flow_removed_mask_slave=None): |
| 529 | self.xid = xid |
| 530 | if packet_in_mask_equal_master != None: |
| 531 | self.packet_in_mask_equal_master = packet_in_mask_equal_master |
| 532 | else: |
| 533 | self.packet_in_mask_equal_master = 0 |
| 534 | if packet_in_mask_slave != None: |
| 535 | self.packet_in_mask_slave = packet_in_mask_slave |
| 536 | else: |
| 537 | self.packet_in_mask_slave = 0 |
| 538 | if port_status_mask_equal_master != None: |
| 539 | self.port_status_mask_equal_master = port_status_mask_equal_master |
| 540 | else: |
| 541 | self.port_status_mask_equal_master = 0 |
| 542 | if port_status_mask_slave != None: |
| 543 | self.port_status_mask_slave = port_status_mask_slave |
| 544 | else: |
| 545 | self.port_status_mask_slave = 0 |
| 546 | if flow_removed_mask_equal_master != None: |
| 547 | self.flow_removed_mask_equal_master = flow_removed_mask_equal_master |
| 548 | else: |
| 549 | self.flow_removed_mask_equal_master = 0 |
| 550 | if flow_removed_mask_slave != None: |
| 551 | self.flow_removed_mask_slave = flow_removed_mask_slave |
| 552 | else: |
| 553 | self.flow_removed_mask_slave = 0 |
| 554 | |
| 555 | def pack(self): |
| 556 | packed = [] |
| 557 | packed.append(struct.pack("!B", self.version)) |
| 558 | packed.append(struct.pack("!B", self.type)) |
| 559 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 560 | packed.append(struct.pack("!L", self.xid)) |
| 561 | packed.append(struct.pack("!L", self.packet_in_mask_equal_master)) |
| 562 | packed.append(struct.pack("!L", self.packet_in_mask_slave)) |
| 563 | packed.append(struct.pack("!L", self.port_status_mask_equal_master)) |
| 564 | packed.append(struct.pack("!L", self.port_status_mask_slave)) |
| 565 | packed.append(struct.pack("!L", self.flow_removed_mask_equal_master)) |
| 566 | packed.append(struct.pack("!L", self.flow_removed_mask_slave)) |
| 567 | length = sum([len(x) for x in packed]) |
| 568 | packed[2] = struct.pack("!H", length) |
| 569 | return ''.join(packed) |
| 570 | |
| 571 | @staticmethod |
| 572 | def unpack(buf): |
| 573 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 574 | obj = async_set() |
| 575 | if type(buf) == loxi.generic_util.OFReader: |
| 576 | reader = buf |
| 577 | else: |
| 578 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 579 | _version = reader.read("!B")[0] |
| 580 | assert(_version == 4) |
| 581 | _type = reader.read("!B")[0] |
| 582 | assert(_type == 28) |
| 583 | _length = reader.read("!H")[0] |
| 584 | obj.xid = reader.read("!L")[0] |
| 585 | obj.packet_in_mask_equal_master = reader.read("!L")[0] |
| 586 | obj.packet_in_mask_slave = reader.read("!L")[0] |
| 587 | obj.port_status_mask_equal_master = reader.read("!L")[0] |
| 588 | obj.port_status_mask_slave = reader.read("!L")[0] |
| 589 | obj.flow_removed_mask_equal_master = reader.read("!L")[0] |
| 590 | obj.flow_removed_mask_slave = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 591 | return obj |
| 592 | |
| 593 | def __eq__(self, other): |
| 594 | if type(self) != type(other): return False |
| 595 | if self.version != other.version: return False |
| 596 | if self.type != other.type: return False |
| 597 | if self.xid != other.xid: return False |
| 598 | if self.packet_in_mask_equal_master != other.packet_in_mask_equal_master: return False |
| 599 | if self.packet_in_mask_slave != other.packet_in_mask_slave: return False |
| 600 | if self.port_status_mask_equal_master != other.port_status_mask_equal_master: return False |
| 601 | if self.port_status_mask_slave != other.port_status_mask_slave: return False |
| 602 | if self.flow_removed_mask_equal_master != other.flow_removed_mask_equal_master: return False |
| 603 | if self.flow_removed_mask_slave != other.flow_removed_mask_slave: return False |
| 604 | return True |
| 605 | |
| 606 | def __ne__(self, other): |
| 607 | return not self.__eq__(other) |
| 608 | |
| 609 | def __str__(self): |
| 610 | return self.show() |
| 611 | |
| 612 | def show(self): |
| 613 | import loxi.pp |
| 614 | return loxi.pp.pp(self) |
| 615 | |
| 616 | def pretty_print(self, q): |
| 617 | q.text("async_set {") |
| 618 | with q.group(): |
| 619 | with q.indent(2): |
| 620 | q.breakable() |
| 621 | q.text("xid = "); |
| 622 | if self.xid != None: |
| 623 | q.text("%#x" % self.xid) |
| 624 | else: |
| 625 | q.text('None') |
| 626 | q.text(","); q.breakable() |
| 627 | q.text("packet_in_mask_equal_master = "); |
| 628 | q.text("%#x" % self.packet_in_mask_equal_master) |
| 629 | q.text(","); q.breakable() |
| 630 | q.text("packet_in_mask_slave = "); |
| 631 | q.text("%#x" % self.packet_in_mask_slave) |
| 632 | q.text(","); q.breakable() |
| 633 | q.text("port_status_mask_equal_master = "); |
| 634 | q.text("%#x" % self.port_status_mask_equal_master) |
| 635 | q.text(","); q.breakable() |
| 636 | q.text("port_status_mask_slave = "); |
| 637 | q.text("%#x" % self.port_status_mask_slave) |
| 638 | q.text(","); q.breakable() |
| 639 | q.text("flow_removed_mask_equal_master = "); |
| 640 | q.text("%#x" % self.flow_removed_mask_equal_master) |
| 641 | q.text(","); q.breakable() |
| 642 | q.text("flow_removed_mask_slave = "); |
| 643 | q.text("%#x" % self.flow_removed_mask_slave) |
| 644 | q.breakable() |
| 645 | q.text('}') |
| 646 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 647 | class bad_action_error_msg(Message): |
| 648 | version = 4 |
| 649 | type = 1 |
| 650 | err_type = 2 |
| 651 | |
| 652 | def __init__(self, xid=None, code=None, data=None): |
| 653 | self.xid = xid |
| 654 | if code != None: |
| 655 | self.code = code |
| 656 | else: |
| 657 | self.code = 0 |
| 658 | if data != None: |
| 659 | self.data = data |
| 660 | else: |
| 661 | self.data = '' |
| 662 | |
| 663 | def pack(self): |
| 664 | packed = [] |
| 665 | packed.append(struct.pack("!B", self.version)) |
| 666 | packed.append(struct.pack("!B", self.type)) |
| 667 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 668 | packed.append(struct.pack("!L", self.xid)) |
| 669 | packed.append(struct.pack("!H", self.err_type)) |
| 670 | packed.append(struct.pack("!H", self.code)) |
| 671 | packed.append(self.data) |
| 672 | length = sum([len(x) for x in packed]) |
| 673 | packed[2] = struct.pack("!H", length) |
| 674 | return ''.join(packed) |
| 675 | |
| 676 | @staticmethod |
| 677 | def unpack(buf): |
| 678 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 679 | obj = bad_action_error_msg() |
| 680 | if type(buf) == loxi.generic_util.OFReader: |
| 681 | reader = buf |
| 682 | else: |
| 683 | reader = loxi.generic_util.OFReader(buf) |
| 684 | _version = reader.read("!B")[0] |
| 685 | assert(_version == 4) |
| 686 | _type = reader.read("!B")[0] |
| 687 | assert(_type == 1) |
| 688 | _length = reader.read("!H")[0] |
| 689 | obj.xid = reader.read("!L")[0] |
| 690 | _err_type = reader.read("!H")[0] |
| 691 | assert(_err_type == 2) |
| 692 | obj.code = reader.read("!H")[0] |
| 693 | obj.data = str(reader.read_all()) |
| 694 | return obj |
| 695 | |
| 696 | def __eq__(self, other): |
| 697 | if type(self) != type(other): return False |
| 698 | if self.version != other.version: return False |
| 699 | if self.type != other.type: return False |
| 700 | if self.xid != other.xid: return False |
| 701 | if self.code != other.code: return False |
| 702 | if self.data != other.data: return False |
| 703 | return True |
| 704 | |
| 705 | def __ne__(self, other): |
| 706 | return not self.__eq__(other) |
| 707 | |
| 708 | def __str__(self): |
| 709 | return self.show() |
| 710 | |
| 711 | def show(self): |
| 712 | import loxi.pp |
| 713 | return loxi.pp.pp(self) |
| 714 | |
| 715 | def pretty_print(self, q): |
| 716 | q.text("bad_action_error_msg {") |
| 717 | with q.group(): |
| 718 | with q.indent(2): |
| 719 | q.breakable() |
| 720 | q.text("xid = "); |
| 721 | if self.xid != None: |
| 722 | q.text("%#x" % self.xid) |
| 723 | else: |
| 724 | q.text('None') |
| 725 | q.text(","); q.breakable() |
| 726 | q.text("code = "); |
| 727 | q.text("%#x" % self.code) |
| 728 | q.text(","); q.breakable() |
| 729 | q.text("data = "); |
| 730 | q.pp(self.data) |
| 731 | q.breakable() |
| 732 | q.text('}') |
| 733 | |
| 734 | class bad_instruction_error_msg(Message): |
| 735 | version = 4 |
| 736 | type = 1 |
| 737 | err_type = 3 |
| 738 | |
| 739 | def __init__(self, xid=None, code=None, data=None): |
| 740 | self.xid = xid |
| 741 | if code != None: |
| 742 | self.code = code |
| 743 | else: |
| 744 | self.code = 0 |
| 745 | if data != None: |
| 746 | self.data = data |
| 747 | else: |
| 748 | self.data = '' |
| 749 | |
| 750 | def pack(self): |
| 751 | packed = [] |
| 752 | packed.append(struct.pack("!B", self.version)) |
| 753 | packed.append(struct.pack("!B", self.type)) |
| 754 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 755 | packed.append(struct.pack("!L", self.xid)) |
| 756 | packed.append(struct.pack("!H", self.err_type)) |
| 757 | packed.append(struct.pack("!H", self.code)) |
| 758 | packed.append(self.data) |
| 759 | length = sum([len(x) for x in packed]) |
| 760 | packed[2] = struct.pack("!H", length) |
| 761 | return ''.join(packed) |
| 762 | |
| 763 | @staticmethod |
| 764 | def unpack(buf): |
| 765 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 766 | obj = bad_instruction_error_msg() |
| 767 | if type(buf) == loxi.generic_util.OFReader: |
| 768 | reader = buf |
| 769 | else: |
| 770 | reader = loxi.generic_util.OFReader(buf) |
| 771 | _version = reader.read("!B")[0] |
| 772 | assert(_version == 4) |
| 773 | _type = reader.read("!B")[0] |
| 774 | assert(_type == 1) |
| 775 | _length = reader.read("!H")[0] |
| 776 | obj.xid = reader.read("!L")[0] |
| 777 | _err_type = reader.read("!H")[0] |
| 778 | assert(_err_type == 3) |
| 779 | obj.code = reader.read("!H")[0] |
| 780 | obj.data = str(reader.read_all()) |
| 781 | return obj |
| 782 | |
| 783 | def __eq__(self, other): |
| 784 | if type(self) != type(other): return False |
| 785 | if self.version != other.version: return False |
| 786 | if self.type != other.type: return False |
| 787 | if self.xid != other.xid: return False |
| 788 | if self.code != other.code: return False |
| 789 | if self.data != other.data: return False |
| 790 | return True |
| 791 | |
| 792 | def __ne__(self, other): |
| 793 | return not self.__eq__(other) |
| 794 | |
| 795 | def __str__(self): |
| 796 | return self.show() |
| 797 | |
| 798 | def show(self): |
| 799 | import loxi.pp |
| 800 | return loxi.pp.pp(self) |
| 801 | |
| 802 | def pretty_print(self, q): |
| 803 | q.text("bad_instruction_error_msg {") |
| 804 | with q.group(): |
| 805 | with q.indent(2): |
| 806 | q.breakable() |
| 807 | q.text("xid = "); |
| 808 | if self.xid != None: |
| 809 | q.text("%#x" % self.xid) |
| 810 | else: |
| 811 | q.text('None') |
| 812 | q.text(","); q.breakable() |
| 813 | q.text("code = "); |
| 814 | q.text("%#x" % self.code) |
| 815 | q.text(","); q.breakable() |
| 816 | q.text("data = "); |
| 817 | q.pp(self.data) |
| 818 | q.breakable() |
| 819 | q.text('}') |
| 820 | |
| 821 | class bad_match_error_msg(Message): |
| 822 | version = 4 |
| 823 | type = 1 |
| 824 | err_type = 4 |
| 825 | |
| 826 | def __init__(self, xid=None, code=None, data=None): |
| 827 | self.xid = xid |
| 828 | if code != None: |
| 829 | self.code = code |
| 830 | else: |
| 831 | self.code = 0 |
| 832 | if data != None: |
| 833 | self.data = data |
| 834 | else: |
| 835 | self.data = '' |
| 836 | |
| 837 | def pack(self): |
| 838 | packed = [] |
| 839 | packed.append(struct.pack("!B", self.version)) |
| 840 | packed.append(struct.pack("!B", self.type)) |
| 841 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 842 | packed.append(struct.pack("!L", self.xid)) |
| 843 | packed.append(struct.pack("!H", self.err_type)) |
| 844 | packed.append(struct.pack("!H", self.code)) |
| 845 | packed.append(self.data) |
| 846 | length = sum([len(x) for x in packed]) |
| 847 | packed[2] = struct.pack("!H", length) |
| 848 | return ''.join(packed) |
| 849 | |
| 850 | @staticmethod |
| 851 | def unpack(buf): |
| 852 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 853 | obj = bad_match_error_msg() |
| 854 | if type(buf) == loxi.generic_util.OFReader: |
| 855 | reader = buf |
| 856 | else: |
| 857 | reader = loxi.generic_util.OFReader(buf) |
| 858 | _version = reader.read("!B")[0] |
| 859 | assert(_version == 4) |
| 860 | _type = reader.read("!B")[0] |
| 861 | assert(_type == 1) |
| 862 | _length = reader.read("!H")[0] |
| 863 | obj.xid = reader.read("!L")[0] |
| 864 | _err_type = reader.read("!H")[0] |
| 865 | assert(_err_type == 4) |
| 866 | obj.code = reader.read("!H")[0] |
| 867 | obj.data = str(reader.read_all()) |
| 868 | return obj |
| 869 | |
| 870 | def __eq__(self, other): |
| 871 | if type(self) != type(other): return False |
| 872 | if self.version != other.version: return False |
| 873 | if self.type != other.type: return False |
| 874 | if self.xid != other.xid: return False |
| 875 | if self.code != other.code: return False |
| 876 | if self.data != other.data: return False |
| 877 | return True |
| 878 | |
| 879 | def __ne__(self, other): |
| 880 | return not self.__eq__(other) |
| 881 | |
| 882 | def __str__(self): |
| 883 | return self.show() |
| 884 | |
| 885 | def show(self): |
| 886 | import loxi.pp |
| 887 | return loxi.pp.pp(self) |
| 888 | |
| 889 | def pretty_print(self, q): |
| 890 | q.text("bad_match_error_msg {") |
| 891 | with q.group(): |
| 892 | with q.indent(2): |
| 893 | q.breakable() |
| 894 | q.text("xid = "); |
| 895 | if self.xid != None: |
| 896 | q.text("%#x" % self.xid) |
| 897 | else: |
| 898 | q.text('None') |
| 899 | q.text(","); q.breakable() |
| 900 | q.text("code = "); |
| 901 | q.text("%#x" % self.code) |
| 902 | q.text(","); q.breakable() |
| 903 | q.text("data = "); |
| 904 | q.pp(self.data) |
| 905 | q.breakable() |
| 906 | q.text('}') |
| 907 | |
| 908 | class bad_request_error_msg(Message): |
| 909 | version = 4 |
| 910 | type = 1 |
| 911 | err_type = 1 |
| 912 | |
| 913 | def __init__(self, xid=None, code=None, data=None): |
| 914 | self.xid = xid |
| 915 | if code != None: |
| 916 | self.code = code |
| 917 | else: |
| 918 | self.code = 0 |
| 919 | if data != None: |
| 920 | self.data = data |
| 921 | else: |
| 922 | self.data = '' |
| 923 | |
| 924 | def pack(self): |
| 925 | packed = [] |
| 926 | packed.append(struct.pack("!B", self.version)) |
| 927 | packed.append(struct.pack("!B", self.type)) |
| 928 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 929 | packed.append(struct.pack("!L", self.xid)) |
| 930 | packed.append(struct.pack("!H", self.err_type)) |
| 931 | packed.append(struct.pack("!H", self.code)) |
| 932 | packed.append(self.data) |
| 933 | length = sum([len(x) for x in packed]) |
| 934 | packed[2] = struct.pack("!H", length) |
| 935 | return ''.join(packed) |
| 936 | |
| 937 | @staticmethod |
| 938 | def unpack(buf): |
| 939 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 940 | obj = bad_request_error_msg() |
| 941 | if type(buf) == loxi.generic_util.OFReader: |
| 942 | reader = buf |
| 943 | else: |
| 944 | reader = loxi.generic_util.OFReader(buf) |
| 945 | _version = reader.read("!B")[0] |
| 946 | assert(_version == 4) |
| 947 | _type = reader.read("!B")[0] |
| 948 | assert(_type == 1) |
| 949 | _length = reader.read("!H")[0] |
| 950 | obj.xid = reader.read("!L")[0] |
| 951 | _err_type = reader.read("!H")[0] |
| 952 | assert(_err_type == 1) |
| 953 | obj.code = reader.read("!H")[0] |
| 954 | obj.data = str(reader.read_all()) |
| 955 | return obj |
| 956 | |
| 957 | def __eq__(self, other): |
| 958 | if type(self) != type(other): return False |
| 959 | if self.version != other.version: return False |
| 960 | if self.type != other.type: return False |
| 961 | if self.xid != other.xid: return False |
| 962 | if self.code != other.code: return False |
| 963 | if self.data != other.data: return False |
| 964 | return True |
| 965 | |
| 966 | def __ne__(self, other): |
| 967 | return not self.__eq__(other) |
| 968 | |
| 969 | def __str__(self): |
| 970 | return self.show() |
| 971 | |
| 972 | def show(self): |
| 973 | import loxi.pp |
| 974 | return loxi.pp.pp(self) |
| 975 | |
| 976 | def pretty_print(self, q): |
| 977 | q.text("bad_request_error_msg {") |
| 978 | with q.group(): |
| 979 | with q.indent(2): |
| 980 | q.breakable() |
| 981 | q.text("xid = "); |
| 982 | if self.xid != None: |
| 983 | q.text("%#x" % self.xid) |
| 984 | else: |
| 985 | q.text('None') |
| 986 | q.text(","); q.breakable() |
| 987 | q.text("code = "); |
| 988 | q.text("%#x" % self.code) |
| 989 | q.text(","); q.breakable() |
| 990 | q.text("data = "); |
| 991 | q.pp(self.data) |
| 992 | q.breakable() |
| 993 | q.text('}') |
| 994 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 995 | class barrier_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 996 | version = 4 |
| 997 | type = 21 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 998 | |
| 999 | def __init__(self, xid=None): |
| 1000 | self.xid = xid |
| 1001 | |
| 1002 | def pack(self): |
| 1003 | packed = [] |
| 1004 | packed.append(struct.pack("!B", self.version)) |
| 1005 | packed.append(struct.pack("!B", self.type)) |
| 1006 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1007 | packed.append(struct.pack("!L", self.xid)) |
| 1008 | length = sum([len(x) for x in packed]) |
| 1009 | packed[2] = struct.pack("!H", length) |
| 1010 | return ''.join(packed) |
| 1011 | |
| 1012 | @staticmethod |
| 1013 | def unpack(buf): |
| 1014 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1015 | obj = barrier_reply() |
| 1016 | if type(buf) == loxi.generic_util.OFReader: |
| 1017 | reader = buf |
| 1018 | else: |
| 1019 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1020 | _version = reader.read("!B")[0] |
| 1021 | assert(_version == 4) |
| 1022 | _type = reader.read("!B")[0] |
| 1023 | assert(_type == 21) |
| 1024 | _length = reader.read("!H")[0] |
| 1025 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1026 | return obj |
| 1027 | |
| 1028 | def __eq__(self, other): |
| 1029 | if type(self) != type(other): return False |
| 1030 | if self.version != other.version: return False |
| 1031 | if self.type != other.type: return False |
| 1032 | if self.xid != other.xid: return False |
| 1033 | return True |
| 1034 | |
| 1035 | def __ne__(self, other): |
| 1036 | return not self.__eq__(other) |
| 1037 | |
| 1038 | def __str__(self): |
| 1039 | return self.show() |
| 1040 | |
| 1041 | def show(self): |
| 1042 | import loxi.pp |
| 1043 | return loxi.pp.pp(self) |
| 1044 | |
| 1045 | def pretty_print(self, q): |
| 1046 | q.text("barrier_reply {") |
| 1047 | with q.group(): |
| 1048 | with q.indent(2): |
| 1049 | q.breakable() |
| 1050 | q.text("xid = "); |
| 1051 | if self.xid != None: |
| 1052 | q.text("%#x" % self.xid) |
| 1053 | else: |
| 1054 | q.text('None') |
| 1055 | q.breakable() |
| 1056 | q.text('}') |
| 1057 | |
| 1058 | class barrier_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1059 | version = 4 |
| 1060 | type = 20 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1061 | |
| 1062 | def __init__(self, xid=None): |
| 1063 | self.xid = xid |
| 1064 | |
| 1065 | def pack(self): |
| 1066 | packed = [] |
| 1067 | packed.append(struct.pack("!B", self.version)) |
| 1068 | packed.append(struct.pack("!B", self.type)) |
| 1069 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1070 | packed.append(struct.pack("!L", self.xid)) |
| 1071 | length = sum([len(x) for x in packed]) |
| 1072 | packed[2] = struct.pack("!H", length) |
| 1073 | return ''.join(packed) |
| 1074 | |
| 1075 | @staticmethod |
| 1076 | def unpack(buf): |
| 1077 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1078 | obj = barrier_request() |
| 1079 | if type(buf) == loxi.generic_util.OFReader: |
| 1080 | reader = buf |
| 1081 | else: |
| 1082 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1083 | _version = reader.read("!B")[0] |
| 1084 | assert(_version == 4) |
| 1085 | _type = reader.read("!B")[0] |
| 1086 | assert(_type == 20) |
| 1087 | _length = reader.read("!H")[0] |
| 1088 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1089 | return obj |
| 1090 | |
| 1091 | def __eq__(self, other): |
| 1092 | if type(self) != type(other): return False |
| 1093 | if self.version != other.version: return False |
| 1094 | if self.type != other.type: return False |
| 1095 | if self.xid != other.xid: return False |
| 1096 | return True |
| 1097 | |
| 1098 | def __ne__(self, other): |
| 1099 | return not self.__eq__(other) |
| 1100 | |
| 1101 | def __str__(self): |
| 1102 | return self.show() |
| 1103 | |
| 1104 | def show(self): |
| 1105 | import loxi.pp |
| 1106 | return loxi.pp.pp(self) |
| 1107 | |
| 1108 | def pretty_print(self, q): |
| 1109 | q.text("barrier_request {") |
| 1110 | with q.group(): |
| 1111 | with q.indent(2): |
| 1112 | q.breakable() |
| 1113 | q.text("xid = "); |
| 1114 | if self.xid != None: |
| 1115 | q.text("%#x" % self.xid) |
| 1116 | else: |
| 1117 | q.text('None') |
| 1118 | q.breakable() |
| 1119 | q.text('}') |
| 1120 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1121 | class bsn_bw_clear_data_reply(Message): |
| 1122 | version = 4 |
| 1123 | type = 4 |
| 1124 | experimenter = 6035143 |
| 1125 | subtype = 22 |
| 1126 | |
| 1127 | def __init__(self, xid=None, status=None): |
| 1128 | self.xid = xid |
| 1129 | if status != None: |
| 1130 | self.status = status |
| 1131 | else: |
| 1132 | self.status = 0 |
| 1133 | |
| 1134 | def pack(self): |
| 1135 | packed = [] |
| 1136 | packed.append(struct.pack("!B", self.version)) |
| 1137 | packed.append(struct.pack("!B", self.type)) |
| 1138 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1139 | packed.append(struct.pack("!L", self.xid)) |
| 1140 | packed.append(struct.pack("!L", self.experimenter)) |
| 1141 | packed.append(struct.pack("!L", self.subtype)) |
| 1142 | packed.append(struct.pack("!L", self.status)) |
| 1143 | length = sum([len(x) for x in packed]) |
| 1144 | packed[2] = struct.pack("!H", length) |
| 1145 | return ''.join(packed) |
| 1146 | |
| 1147 | @staticmethod |
| 1148 | def unpack(buf): |
| 1149 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1150 | obj = bsn_bw_clear_data_reply() |
| 1151 | if type(buf) == loxi.generic_util.OFReader: |
| 1152 | reader = buf |
| 1153 | else: |
| 1154 | reader = loxi.generic_util.OFReader(buf) |
| 1155 | _version = reader.read("!B")[0] |
| 1156 | assert(_version == 4) |
| 1157 | _type = reader.read("!B")[0] |
| 1158 | assert(_type == 4) |
| 1159 | _length = reader.read("!H")[0] |
| 1160 | obj.xid = reader.read("!L")[0] |
| 1161 | _experimenter = reader.read("!L")[0] |
| 1162 | assert(_experimenter == 6035143) |
| 1163 | _subtype = reader.read("!L")[0] |
| 1164 | assert(_subtype == 22) |
| 1165 | obj.status = reader.read("!L")[0] |
| 1166 | return obj |
| 1167 | |
| 1168 | def __eq__(self, other): |
| 1169 | if type(self) != type(other): return False |
| 1170 | if self.version != other.version: return False |
| 1171 | if self.type != other.type: return False |
| 1172 | if self.xid != other.xid: return False |
| 1173 | if self.status != other.status: return False |
| 1174 | return True |
| 1175 | |
| 1176 | def __ne__(self, other): |
| 1177 | return not self.__eq__(other) |
| 1178 | |
| 1179 | def __str__(self): |
| 1180 | return self.show() |
| 1181 | |
| 1182 | def show(self): |
| 1183 | import loxi.pp |
| 1184 | return loxi.pp.pp(self) |
| 1185 | |
| 1186 | def pretty_print(self, q): |
| 1187 | q.text("bsn_bw_clear_data_reply {") |
| 1188 | with q.group(): |
| 1189 | with q.indent(2): |
| 1190 | q.breakable() |
| 1191 | q.text("xid = "); |
| 1192 | if self.xid != None: |
| 1193 | q.text("%#x" % self.xid) |
| 1194 | else: |
| 1195 | q.text('None') |
| 1196 | q.text(","); q.breakable() |
| 1197 | q.text("status = "); |
| 1198 | q.text("%#x" % self.status) |
| 1199 | q.breakable() |
| 1200 | q.text('}') |
| 1201 | |
| 1202 | class bsn_bw_clear_data_request(Message): |
| 1203 | version = 4 |
| 1204 | type = 4 |
| 1205 | experimenter = 6035143 |
| 1206 | subtype = 21 |
| 1207 | |
| 1208 | def __init__(self, xid=None): |
| 1209 | self.xid = xid |
| 1210 | |
| 1211 | def pack(self): |
| 1212 | packed = [] |
| 1213 | packed.append(struct.pack("!B", self.version)) |
| 1214 | packed.append(struct.pack("!B", self.type)) |
| 1215 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1216 | packed.append(struct.pack("!L", self.xid)) |
| 1217 | packed.append(struct.pack("!L", self.experimenter)) |
| 1218 | packed.append(struct.pack("!L", self.subtype)) |
| 1219 | length = sum([len(x) for x in packed]) |
| 1220 | packed[2] = struct.pack("!H", length) |
| 1221 | return ''.join(packed) |
| 1222 | |
| 1223 | @staticmethod |
| 1224 | def unpack(buf): |
| 1225 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1226 | obj = bsn_bw_clear_data_request() |
| 1227 | if type(buf) == loxi.generic_util.OFReader: |
| 1228 | reader = buf |
| 1229 | else: |
| 1230 | reader = loxi.generic_util.OFReader(buf) |
| 1231 | _version = reader.read("!B")[0] |
| 1232 | assert(_version == 4) |
| 1233 | _type = reader.read("!B")[0] |
| 1234 | assert(_type == 4) |
| 1235 | _length = reader.read("!H")[0] |
| 1236 | obj.xid = reader.read("!L")[0] |
| 1237 | _experimenter = reader.read("!L")[0] |
| 1238 | assert(_experimenter == 6035143) |
| 1239 | _subtype = reader.read("!L")[0] |
| 1240 | assert(_subtype == 21) |
| 1241 | return obj |
| 1242 | |
| 1243 | def __eq__(self, other): |
| 1244 | if type(self) != type(other): return False |
| 1245 | if self.version != other.version: return False |
| 1246 | if self.type != other.type: return False |
| 1247 | if self.xid != other.xid: return False |
| 1248 | return True |
| 1249 | |
| 1250 | def __ne__(self, other): |
| 1251 | return not self.__eq__(other) |
| 1252 | |
| 1253 | def __str__(self): |
| 1254 | return self.show() |
| 1255 | |
| 1256 | def show(self): |
| 1257 | import loxi.pp |
| 1258 | return loxi.pp.pp(self) |
| 1259 | |
| 1260 | def pretty_print(self, q): |
| 1261 | q.text("bsn_bw_clear_data_request {") |
| 1262 | with q.group(): |
| 1263 | with q.indent(2): |
| 1264 | q.breakable() |
| 1265 | q.text("xid = "); |
| 1266 | if self.xid != None: |
| 1267 | q.text("%#x" % self.xid) |
| 1268 | else: |
| 1269 | q.text('None') |
| 1270 | q.breakable() |
| 1271 | q.text('}') |
| 1272 | |
| 1273 | class bsn_bw_enable_get_reply(Message): |
| 1274 | version = 4 |
| 1275 | type = 4 |
| 1276 | experimenter = 6035143 |
| 1277 | subtype = 20 |
| 1278 | |
| 1279 | def __init__(self, xid=None, enabled=None): |
| 1280 | self.xid = xid |
| 1281 | if enabled != None: |
| 1282 | self.enabled = enabled |
| 1283 | else: |
| 1284 | self.enabled = 0 |
| 1285 | |
| 1286 | def pack(self): |
| 1287 | packed = [] |
| 1288 | packed.append(struct.pack("!B", self.version)) |
| 1289 | packed.append(struct.pack("!B", self.type)) |
| 1290 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1291 | packed.append(struct.pack("!L", self.xid)) |
| 1292 | packed.append(struct.pack("!L", self.experimenter)) |
| 1293 | packed.append(struct.pack("!L", self.subtype)) |
| 1294 | packed.append(struct.pack("!L", self.enabled)) |
| 1295 | length = sum([len(x) for x in packed]) |
| 1296 | packed[2] = struct.pack("!H", length) |
| 1297 | return ''.join(packed) |
| 1298 | |
| 1299 | @staticmethod |
| 1300 | def unpack(buf): |
| 1301 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1302 | obj = bsn_bw_enable_get_reply() |
| 1303 | if type(buf) == loxi.generic_util.OFReader: |
| 1304 | reader = buf |
| 1305 | else: |
| 1306 | reader = loxi.generic_util.OFReader(buf) |
| 1307 | _version = reader.read("!B")[0] |
| 1308 | assert(_version == 4) |
| 1309 | _type = reader.read("!B")[0] |
| 1310 | assert(_type == 4) |
| 1311 | _length = reader.read("!H")[0] |
| 1312 | obj.xid = reader.read("!L")[0] |
| 1313 | _experimenter = reader.read("!L")[0] |
| 1314 | assert(_experimenter == 6035143) |
| 1315 | _subtype = reader.read("!L")[0] |
| 1316 | assert(_subtype == 20) |
| 1317 | obj.enabled = reader.read("!L")[0] |
| 1318 | return obj |
| 1319 | |
| 1320 | def __eq__(self, other): |
| 1321 | if type(self) != type(other): return False |
| 1322 | if self.version != other.version: return False |
| 1323 | if self.type != other.type: return False |
| 1324 | if self.xid != other.xid: return False |
| 1325 | if self.enabled != other.enabled: return False |
| 1326 | return True |
| 1327 | |
| 1328 | def __ne__(self, other): |
| 1329 | return not self.__eq__(other) |
| 1330 | |
| 1331 | def __str__(self): |
| 1332 | return self.show() |
| 1333 | |
| 1334 | def show(self): |
| 1335 | import loxi.pp |
| 1336 | return loxi.pp.pp(self) |
| 1337 | |
| 1338 | def pretty_print(self, q): |
| 1339 | q.text("bsn_bw_enable_get_reply {") |
| 1340 | with q.group(): |
| 1341 | with q.indent(2): |
| 1342 | q.breakable() |
| 1343 | q.text("xid = "); |
| 1344 | if self.xid != None: |
| 1345 | q.text("%#x" % self.xid) |
| 1346 | else: |
| 1347 | q.text('None') |
| 1348 | q.text(","); q.breakable() |
| 1349 | q.text("enabled = "); |
| 1350 | q.text("%#x" % self.enabled) |
| 1351 | q.breakable() |
| 1352 | q.text('}') |
| 1353 | |
| 1354 | class bsn_bw_enable_get_request(Message): |
| 1355 | version = 4 |
| 1356 | type = 4 |
| 1357 | experimenter = 6035143 |
| 1358 | subtype = 19 |
| 1359 | |
| 1360 | def __init__(self, xid=None): |
| 1361 | self.xid = xid |
| 1362 | |
| 1363 | def pack(self): |
| 1364 | packed = [] |
| 1365 | packed.append(struct.pack("!B", self.version)) |
| 1366 | packed.append(struct.pack("!B", self.type)) |
| 1367 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1368 | packed.append(struct.pack("!L", self.xid)) |
| 1369 | packed.append(struct.pack("!L", self.experimenter)) |
| 1370 | packed.append(struct.pack("!L", self.subtype)) |
| 1371 | length = sum([len(x) for x in packed]) |
| 1372 | packed[2] = struct.pack("!H", length) |
| 1373 | return ''.join(packed) |
| 1374 | |
| 1375 | @staticmethod |
| 1376 | def unpack(buf): |
| 1377 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1378 | obj = bsn_bw_enable_get_request() |
| 1379 | if type(buf) == loxi.generic_util.OFReader: |
| 1380 | reader = buf |
| 1381 | else: |
| 1382 | reader = loxi.generic_util.OFReader(buf) |
| 1383 | _version = reader.read("!B")[0] |
| 1384 | assert(_version == 4) |
| 1385 | _type = reader.read("!B")[0] |
| 1386 | assert(_type == 4) |
| 1387 | _length = reader.read("!H")[0] |
| 1388 | obj.xid = reader.read("!L")[0] |
| 1389 | _experimenter = reader.read("!L")[0] |
| 1390 | assert(_experimenter == 6035143) |
| 1391 | _subtype = reader.read("!L")[0] |
| 1392 | assert(_subtype == 19) |
| 1393 | return obj |
| 1394 | |
| 1395 | def __eq__(self, other): |
| 1396 | if type(self) != type(other): return False |
| 1397 | if self.version != other.version: return False |
| 1398 | if self.type != other.type: return False |
| 1399 | if self.xid != other.xid: return False |
| 1400 | return True |
| 1401 | |
| 1402 | def __ne__(self, other): |
| 1403 | return not self.__eq__(other) |
| 1404 | |
| 1405 | def __str__(self): |
| 1406 | return self.show() |
| 1407 | |
| 1408 | def show(self): |
| 1409 | import loxi.pp |
| 1410 | return loxi.pp.pp(self) |
| 1411 | |
| 1412 | def pretty_print(self, q): |
| 1413 | q.text("bsn_bw_enable_get_request {") |
| 1414 | with q.group(): |
| 1415 | with q.indent(2): |
| 1416 | q.breakable() |
| 1417 | q.text("xid = "); |
| 1418 | if self.xid != None: |
| 1419 | q.text("%#x" % self.xid) |
| 1420 | else: |
| 1421 | q.text('None') |
| 1422 | q.breakable() |
| 1423 | q.text('}') |
| 1424 | |
| 1425 | class bsn_bw_enable_set_reply(Message): |
| 1426 | version = 4 |
| 1427 | type = 4 |
| 1428 | experimenter = 6035143 |
| 1429 | subtype = 23 |
| 1430 | |
| 1431 | def __init__(self, xid=None, enable=None, status=None): |
| 1432 | self.xid = xid |
| 1433 | if enable != None: |
| 1434 | self.enable = enable |
| 1435 | else: |
| 1436 | self.enable = 0 |
| 1437 | if status != None: |
| 1438 | self.status = status |
| 1439 | else: |
| 1440 | self.status = 0 |
| 1441 | |
| 1442 | def pack(self): |
| 1443 | packed = [] |
| 1444 | packed.append(struct.pack("!B", self.version)) |
| 1445 | packed.append(struct.pack("!B", self.type)) |
| 1446 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1447 | packed.append(struct.pack("!L", self.xid)) |
| 1448 | packed.append(struct.pack("!L", self.experimenter)) |
| 1449 | packed.append(struct.pack("!L", self.subtype)) |
| 1450 | packed.append(struct.pack("!L", self.enable)) |
| 1451 | packed.append(struct.pack("!L", self.status)) |
| 1452 | length = sum([len(x) for x in packed]) |
| 1453 | packed[2] = struct.pack("!H", length) |
| 1454 | return ''.join(packed) |
| 1455 | |
| 1456 | @staticmethod |
| 1457 | def unpack(buf): |
| 1458 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1459 | obj = bsn_bw_enable_set_reply() |
| 1460 | if type(buf) == loxi.generic_util.OFReader: |
| 1461 | reader = buf |
| 1462 | else: |
| 1463 | reader = loxi.generic_util.OFReader(buf) |
| 1464 | _version = reader.read("!B")[0] |
| 1465 | assert(_version == 4) |
| 1466 | _type = reader.read("!B")[0] |
| 1467 | assert(_type == 4) |
| 1468 | _length = reader.read("!H")[0] |
| 1469 | obj.xid = reader.read("!L")[0] |
| 1470 | _experimenter = reader.read("!L")[0] |
| 1471 | assert(_experimenter == 6035143) |
| 1472 | _subtype = reader.read("!L")[0] |
| 1473 | assert(_subtype == 23) |
| 1474 | obj.enable = reader.read("!L")[0] |
| 1475 | obj.status = reader.read("!L")[0] |
| 1476 | return obj |
| 1477 | |
| 1478 | def __eq__(self, other): |
| 1479 | if type(self) != type(other): return False |
| 1480 | if self.version != other.version: return False |
| 1481 | if self.type != other.type: return False |
| 1482 | if self.xid != other.xid: return False |
| 1483 | if self.enable != other.enable: return False |
| 1484 | if self.status != other.status: return False |
| 1485 | return True |
| 1486 | |
| 1487 | def __ne__(self, other): |
| 1488 | return not self.__eq__(other) |
| 1489 | |
| 1490 | def __str__(self): |
| 1491 | return self.show() |
| 1492 | |
| 1493 | def show(self): |
| 1494 | import loxi.pp |
| 1495 | return loxi.pp.pp(self) |
| 1496 | |
| 1497 | def pretty_print(self, q): |
| 1498 | q.text("bsn_bw_enable_set_reply {") |
| 1499 | with q.group(): |
| 1500 | with q.indent(2): |
| 1501 | q.breakable() |
| 1502 | q.text("xid = "); |
| 1503 | if self.xid != None: |
| 1504 | q.text("%#x" % self.xid) |
| 1505 | else: |
| 1506 | q.text('None') |
| 1507 | q.text(","); q.breakable() |
| 1508 | q.text("enable = "); |
| 1509 | q.text("%#x" % self.enable) |
| 1510 | q.text(","); q.breakable() |
| 1511 | q.text("status = "); |
| 1512 | q.text("%#x" % self.status) |
| 1513 | q.breakable() |
| 1514 | q.text('}') |
| 1515 | |
| 1516 | class bsn_bw_enable_set_request(Message): |
| 1517 | version = 4 |
| 1518 | type = 4 |
| 1519 | experimenter = 6035143 |
| 1520 | subtype = 18 |
| 1521 | |
| 1522 | def __init__(self, xid=None, enable=None): |
| 1523 | self.xid = xid |
| 1524 | if enable != None: |
| 1525 | self.enable = enable |
| 1526 | else: |
| 1527 | self.enable = 0 |
| 1528 | |
| 1529 | def pack(self): |
| 1530 | packed = [] |
| 1531 | packed.append(struct.pack("!B", self.version)) |
| 1532 | packed.append(struct.pack("!B", self.type)) |
| 1533 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1534 | packed.append(struct.pack("!L", self.xid)) |
| 1535 | packed.append(struct.pack("!L", self.experimenter)) |
| 1536 | packed.append(struct.pack("!L", self.subtype)) |
| 1537 | packed.append(struct.pack("!L", self.enable)) |
| 1538 | length = sum([len(x) for x in packed]) |
| 1539 | packed[2] = struct.pack("!H", length) |
| 1540 | return ''.join(packed) |
| 1541 | |
| 1542 | @staticmethod |
| 1543 | def unpack(buf): |
| 1544 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1545 | obj = bsn_bw_enable_set_request() |
| 1546 | if type(buf) == loxi.generic_util.OFReader: |
| 1547 | reader = buf |
| 1548 | else: |
| 1549 | reader = loxi.generic_util.OFReader(buf) |
| 1550 | _version = reader.read("!B")[0] |
| 1551 | assert(_version == 4) |
| 1552 | _type = reader.read("!B")[0] |
| 1553 | assert(_type == 4) |
| 1554 | _length = reader.read("!H")[0] |
| 1555 | obj.xid = reader.read("!L")[0] |
| 1556 | _experimenter = reader.read("!L")[0] |
| 1557 | assert(_experimenter == 6035143) |
| 1558 | _subtype = reader.read("!L")[0] |
| 1559 | assert(_subtype == 18) |
| 1560 | obj.enable = reader.read("!L")[0] |
| 1561 | return obj |
| 1562 | |
| 1563 | def __eq__(self, other): |
| 1564 | if type(self) != type(other): return False |
| 1565 | if self.version != other.version: return False |
| 1566 | if self.type != other.type: return False |
| 1567 | if self.xid != other.xid: return False |
| 1568 | if self.enable != other.enable: return False |
| 1569 | return True |
| 1570 | |
| 1571 | def __ne__(self, other): |
| 1572 | return not self.__eq__(other) |
| 1573 | |
| 1574 | def __str__(self): |
| 1575 | return self.show() |
| 1576 | |
| 1577 | def show(self): |
| 1578 | import loxi.pp |
| 1579 | return loxi.pp.pp(self) |
| 1580 | |
| 1581 | def pretty_print(self, q): |
| 1582 | q.text("bsn_bw_enable_set_request {") |
| 1583 | with q.group(): |
| 1584 | with q.indent(2): |
| 1585 | q.breakable() |
| 1586 | q.text("xid = "); |
| 1587 | if self.xid != None: |
| 1588 | q.text("%#x" % self.xid) |
| 1589 | else: |
| 1590 | q.text('None') |
| 1591 | q.text(","); q.breakable() |
| 1592 | q.text("enable = "); |
| 1593 | q.text("%#x" % self.enable) |
| 1594 | q.breakable() |
| 1595 | q.text('}') |
| 1596 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 1597 | class bsn_flow_idle(Message): |
| 1598 | version = 4 |
| 1599 | type = 4 |
| 1600 | experimenter = 6035143 |
| 1601 | subtype = 40 |
| 1602 | |
| 1603 | def __init__(self, xid=None, cookie=None, priority=None, table_id=None, match=None): |
| 1604 | self.xid = xid |
| 1605 | if cookie != None: |
| 1606 | self.cookie = cookie |
| 1607 | else: |
| 1608 | self.cookie = 0 |
| 1609 | if priority != None: |
| 1610 | self.priority = priority |
| 1611 | else: |
| 1612 | self.priority = 0 |
| 1613 | if table_id != None: |
| 1614 | self.table_id = table_id |
| 1615 | else: |
| 1616 | self.table_id = 0 |
| 1617 | if match != None: |
| 1618 | self.match = match |
| 1619 | else: |
| 1620 | self.match = common.match() |
| 1621 | |
| 1622 | def pack(self): |
| 1623 | packed = [] |
| 1624 | packed.append(struct.pack("!B", self.version)) |
| 1625 | packed.append(struct.pack("!B", self.type)) |
| 1626 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1627 | packed.append(struct.pack("!L", self.xid)) |
| 1628 | packed.append(struct.pack("!L", self.experimenter)) |
| 1629 | packed.append(struct.pack("!L", self.subtype)) |
| 1630 | packed.append(struct.pack("!Q", self.cookie)) |
| 1631 | packed.append(struct.pack("!H", self.priority)) |
| 1632 | packed.append(struct.pack("!B", self.table_id)) |
| 1633 | packed.append('\x00' * 5) |
| 1634 | packed.append(self.match.pack()) |
| 1635 | length = sum([len(x) for x in packed]) |
| 1636 | packed[2] = struct.pack("!H", length) |
| 1637 | return ''.join(packed) |
| 1638 | |
| 1639 | @staticmethod |
| 1640 | def unpack(buf): |
| 1641 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1642 | obj = bsn_flow_idle() |
| 1643 | if type(buf) == loxi.generic_util.OFReader: |
| 1644 | reader = buf |
| 1645 | else: |
| 1646 | reader = loxi.generic_util.OFReader(buf) |
| 1647 | _version = reader.read("!B")[0] |
| 1648 | assert(_version == 4) |
| 1649 | _type = reader.read("!B")[0] |
| 1650 | assert(_type == 4) |
| 1651 | _length = reader.read("!H")[0] |
| 1652 | obj.xid = reader.read("!L")[0] |
| 1653 | _experimenter = reader.read("!L")[0] |
| 1654 | assert(_experimenter == 6035143) |
| 1655 | _subtype = reader.read("!L")[0] |
| 1656 | assert(_subtype == 40) |
| 1657 | obj.cookie = reader.read("!Q")[0] |
| 1658 | obj.priority = reader.read("!H")[0] |
| 1659 | obj.table_id = reader.read("!B")[0] |
| 1660 | reader.skip(5) |
| 1661 | obj.match = common.match.unpack(reader) |
| 1662 | return obj |
| 1663 | |
| 1664 | def __eq__(self, other): |
| 1665 | if type(self) != type(other): return False |
| 1666 | if self.version != other.version: return False |
| 1667 | if self.type != other.type: return False |
| 1668 | if self.xid != other.xid: return False |
| 1669 | if self.cookie != other.cookie: return False |
| 1670 | if self.priority != other.priority: return False |
| 1671 | if self.table_id != other.table_id: return False |
| 1672 | if self.match != other.match: return False |
| 1673 | return True |
| 1674 | |
| 1675 | def __ne__(self, other): |
| 1676 | return not self.__eq__(other) |
| 1677 | |
| 1678 | def __str__(self): |
| 1679 | return self.show() |
| 1680 | |
| 1681 | def show(self): |
| 1682 | import loxi.pp |
| 1683 | return loxi.pp.pp(self) |
| 1684 | |
| 1685 | def pretty_print(self, q): |
| 1686 | q.text("bsn_flow_idle {") |
| 1687 | with q.group(): |
| 1688 | with q.indent(2): |
| 1689 | q.breakable() |
| 1690 | q.text("xid = "); |
| 1691 | if self.xid != None: |
| 1692 | q.text("%#x" % self.xid) |
| 1693 | else: |
| 1694 | q.text('None') |
| 1695 | q.text(","); q.breakable() |
| 1696 | q.text("cookie = "); |
| 1697 | q.text("%#x" % self.cookie) |
| 1698 | q.text(","); q.breakable() |
| 1699 | q.text("priority = "); |
| 1700 | q.text("%#x" % self.priority) |
| 1701 | q.text(","); q.breakable() |
| 1702 | q.text("table_id = "); |
| 1703 | q.text("%#x" % self.table_id) |
| 1704 | q.text(","); q.breakable() |
| 1705 | q.text("match = "); |
| 1706 | q.pp(self.match) |
| 1707 | q.breakable() |
| 1708 | q.text('}') |
| 1709 | |
| 1710 | class bsn_flow_idle_enable_get_reply(Message): |
| 1711 | version = 4 |
| 1712 | type = 4 |
| 1713 | experimenter = 6035143 |
| 1714 | subtype = 39 |
| 1715 | |
| 1716 | def __init__(self, xid=None, enabled=None): |
| 1717 | self.xid = xid |
| 1718 | if enabled != None: |
| 1719 | self.enabled = enabled |
| 1720 | else: |
| 1721 | self.enabled = 0 |
| 1722 | |
| 1723 | def pack(self): |
| 1724 | packed = [] |
| 1725 | packed.append(struct.pack("!B", self.version)) |
| 1726 | packed.append(struct.pack("!B", self.type)) |
| 1727 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1728 | packed.append(struct.pack("!L", self.xid)) |
| 1729 | packed.append(struct.pack("!L", self.experimenter)) |
| 1730 | packed.append(struct.pack("!L", self.subtype)) |
| 1731 | packed.append(struct.pack("!L", self.enabled)) |
| 1732 | length = sum([len(x) for x in packed]) |
| 1733 | packed[2] = struct.pack("!H", length) |
| 1734 | return ''.join(packed) |
| 1735 | |
| 1736 | @staticmethod |
| 1737 | def unpack(buf): |
| 1738 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1739 | obj = bsn_flow_idle_enable_get_reply() |
| 1740 | if type(buf) == loxi.generic_util.OFReader: |
| 1741 | reader = buf |
| 1742 | else: |
| 1743 | reader = loxi.generic_util.OFReader(buf) |
| 1744 | _version = reader.read("!B")[0] |
| 1745 | assert(_version == 4) |
| 1746 | _type = reader.read("!B")[0] |
| 1747 | assert(_type == 4) |
| 1748 | _length = reader.read("!H")[0] |
| 1749 | obj.xid = reader.read("!L")[0] |
| 1750 | _experimenter = reader.read("!L")[0] |
| 1751 | assert(_experimenter == 6035143) |
| 1752 | _subtype = reader.read("!L")[0] |
| 1753 | assert(_subtype == 39) |
| 1754 | obj.enabled = reader.read("!L")[0] |
| 1755 | return obj |
| 1756 | |
| 1757 | def __eq__(self, other): |
| 1758 | if type(self) != type(other): return False |
| 1759 | if self.version != other.version: return False |
| 1760 | if self.type != other.type: return False |
| 1761 | if self.xid != other.xid: return False |
| 1762 | if self.enabled != other.enabled: return False |
| 1763 | return True |
| 1764 | |
| 1765 | def __ne__(self, other): |
| 1766 | return not self.__eq__(other) |
| 1767 | |
| 1768 | def __str__(self): |
| 1769 | return self.show() |
| 1770 | |
| 1771 | def show(self): |
| 1772 | import loxi.pp |
| 1773 | return loxi.pp.pp(self) |
| 1774 | |
| 1775 | def pretty_print(self, q): |
| 1776 | q.text("bsn_flow_idle_enable_get_reply {") |
| 1777 | with q.group(): |
| 1778 | with q.indent(2): |
| 1779 | q.breakable() |
| 1780 | q.text("xid = "); |
| 1781 | if self.xid != None: |
| 1782 | q.text("%#x" % self.xid) |
| 1783 | else: |
| 1784 | q.text('None') |
| 1785 | q.text(","); q.breakable() |
| 1786 | q.text("enabled = "); |
| 1787 | q.text("%#x" % self.enabled) |
| 1788 | q.breakable() |
| 1789 | q.text('}') |
| 1790 | |
| 1791 | class bsn_flow_idle_enable_get_request(Message): |
| 1792 | version = 4 |
| 1793 | type = 4 |
| 1794 | experimenter = 6035143 |
| 1795 | subtype = 38 |
| 1796 | |
| 1797 | def __init__(self, xid=None): |
| 1798 | self.xid = xid |
| 1799 | |
| 1800 | def pack(self): |
| 1801 | packed = [] |
| 1802 | packed.append(struct.pack("!B", self.version)) |
| 1803 | packed.append(struct.pack("!B", self.type)) |
| 1804 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1805 | packed.append(struct.pack("!L", self.xid)) |
| 1806 | packed.append(struct.pack("!L", self.experimenter)) |
| 1807 | packed.append(struct.pack("!L", self.subtype)) |
| 1808 | length = sum([len(x) for x in packed]) |
| 1809 | packed[2] = struct.pack("!H", length) |
| 1810 | return ''.join(packed) |
| 1811 | |
| 1812 | @staticmethod |
| 1813 | def unpack(buf): |
| 1814 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1815 | obj = bsn_flow_idle_enable_get_request() |
| 1816 | if type(buf) == loxi.generic_util.OFReader: |
| 1817 | reader = buf |
| 1818 | else: |
| 1819 | reader = loxi.generic_util.OFReader(buf) |
| 1820 | _version = reader.read("!B")[0] |
| 1821 | assert(_version == 4) |
| 1822 | _type = reader.read("!B")[0] |
| 1823 | assert(_type == 4) |
| 1824 | _length = reader.read("!H")[0] |
| 1825 | obj.xid = reader.read("!L")[0] |
| 1826 | _experimenter = reader.read("!L")[0] |
| 1827 | assert(_experimenter == 6035143) |
| 1828 | _subtype = reader.read("!L")[0] |
| 1829 | assert(_subtype == 38) |
| 1830 | return obj |
| 1831 | |
| 1832 | def __eq__(self, other): |
| 1833 | if type(self) != type(other): return False |
| 1834 | if self.version != other.version: return False |
| 1835 | if self.type != other.type: return False |
| 1836 | if self.xid != other.xid: return False |
| 1837 | return True |
| 1838 | |
| 1839 | def __ne__(self, other): |
| 1840 | return not self.__eq__(other) |
| 1841 | |
| 1842 | def __str__(self): |
| 1843 | return self.show() |
| 1844 | |
| 1845 | def show(self): |
| 1846 | import loxi.pp |
| 1847 | return loxi.pp.pp(self) |
| 1848 | |
| 1849 | def pretty_print(self, q): |
| 1850 | q.text("bsn_flow_idle_enable_get_request {") |
| 1851 | with q.group(): |
| 1852 | with q.indent(2): |
| 1853 | q.breakable() |
| 1854 | q.text("xid = "); |
| 1855 | if self.xid != None: |
| 1856 | q.text("%#x" % self.xid) |
| 1857 | else: |
| 1858 | q.text('None') |
| 1859 | q.breakable() |
| 1860 | q.text('}') |
| 1861 | |
| 1862 | class bsn_flow_idle_enable_set_reply(Message): |
| 1863 | version = 4 |
| 1864 | type = 4 |
| 1865 | experimenter = 6035143 |
| 1866 | subtype = 37 |
| 1867 | |
| 1868 | def __init__(self, xid=None, enable=None, status=None): |
| 1869 | self.xid = xid |
| 1870 | if enable != None: |
| 1871 | self.enable = enable |
| 1872 | else: |
| 1873 | self.enable = 0 |
| 1874 | if status != None: |
| 1875 | self.status = status |
| 1876 | else: |
| 1877 | self.status = 0 |
| 1878 | |
| 1879 | def pack(self): |
| 1880 | packed = [] |
| 1881 | packed.append(struct.pack("!B", self.version)) |
| 1882 | packed.append(struct.pack("!B", self.type)) |
| 1883 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1884 | packed.append(struct.pack("!L", self.xid)) |
| 1885 | packed.append(struct.pack("!L", self.experimenter)) |
| 1886 | packed.append(struct.pack("!L", self.subtype)) |
| 1887 | packed.append(struct.pack("!L", self.enable)) |
| 1888 | packed.append(struct.pack("!L", self.status)) |
| 1889 | length = sum([len(x) for x in packed]) |
| 1890 | packed[2] = struct.pack("!H", length) |
| 1891 | return ''.join(packed) |
| 1892 | |
| 1893 | @staticmethod |
| 1894 | def unpack(buf): |
| 1895 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1896 | obj = bsn_flow_idle_enable_set_reply() |
| 1897 | if type(buf) == loxi.generic_util.OFReader: |
| 1898 | reader = buf |
| 1899 | else: |
| 1900 | reader = loxi.generic_util.OFReader(buf) |
| 1901 | _version = reader.read("!B")[0] |
| 1902 | assert(_version == 4) |
| 1903 | _type = reader.read("!B")[0] |
| 1904 | assert(_type == 4) |
| 1905 | _length = reader.read("!H")[0] |
| 1906 | obj.xid = reader.read("!L")[0] |
| 1907 | _experimenter = reader.read("!L")[0] |
| 1908 | assert(_experimenter == 6035143) |
| 1909 | _subtype = reader.read("!L")[0] |
| 1910 | assert(_subtype == 37) |
| 1911 | obj.enable = reader.read("!L")[0] |
| 1912 | obj.status = reader.read("!L")[0] |
| 1913 | return obj |
| 1914 | |
| 1915 | def __eq__(self, other): |
| 1916 | if type(self) != type(other): return False |
| 1917 | if self.version != other.version: return False |
| 1918 | if self.type != other.type: return False |
| 1919 | if self.xid != other.xid: return False |
| 1920 | if self.enable != other.enable: return False |
| 1921 | if self.status != other.status: return False |
| 1922 | return True |
| 1923 | |
| 1924 | def __ne__(self, other): |
| 1925 | return not self.__eq__(other) |
| 1926 | |
| 1927 | def __str__(self): |
| 1928 | return self.show() |
| 1929 | |
| 1930 | def show(self): |
| 1931 | import loxi.pp |
| 1932 | return loxi.pp.pp(self) |
| 1933 | |
| 1934 | def pretty_print(self, q): |
| 1935 | q.text("bsn_flow_idle_enable_set_reply {") |
| 1936 | with q.group(): |
| 1937 | with q.indent(2): |
| 1938 | q.breakable() |
| 1939 | q.text("xid = "); |
| 1940 | if self.xid != None: |
| 1941 | q.text("%#x" % self.xid) |
| 1942 | else: |
| 1943 | q.text('None') |
| 1944 | q.text(","); q.breakable() |
| 1945 | q.text("enable = "); |
| 1946 | q.text("%#x" % self.enable) |
| 1947 | q.text(","); q.breakable() |
| 1948 | q.text("status = "); |
| 1949 | q.text("%#x" % self.status) |
| 1950 | q.breakable() |
| 1951 | q.text('}') |
| 1952 | |
| 1953 | class bsn_flow_idle_enable_set_request(Message): |
| 1954 | version = 4 |
| 1955 | type = 4 |
| 1956 | experimenter = 6035143 |
| 1957 | subtype = 36 |
| 1958 | |
| 1959 | def __init__(self, xid=None, enable=None): |
| 1960 | self.xid = xid |
| 1961 | if enable != None: |
| 1962 | self.enable = enable |
| 1963 | else: |
| 1964 | self.enable = 0 |
| 1965 | |
| 1966 | def pack(self): |
| 1967 | packed = [] |
| 1968 | packed.append(struct.pack("!B", self.version)) |
| 1969 | packed.append(struct.pack("!B", self.type)) |
| 1970 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1971 | packed.append(struct.pack("!L", self.xid)) |
| 1972 | packed.append(struct.pack("!L", self.experimenter)) |
| 1973 | packed.append(struct.pack("!L", self.subtype)) |
| 1974 | packed.append(struct.pack("!L", self.enable)) |
| 1975 | length = sum([len(x) for x in packed]) |
| 1976 | packed[2] = struct.pack("!H", length) |
| 1977 | return ''.join(packed) |
| 1978 | |
| 1979 | @staticmethod |
| 1980 | def unpack(buf): |
| 1981 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1982 | obj = bsn_flow_idle_enable_set_request() |
| 1983 | if type(buf) == loxi.generic_util.OFReader: |
| 1984 | reader = buf |
| 1985 | else: |
| 1986 | reader = loxi.generic_util.OFReader(buf) |
| 1987 | _version = reader.read("!B")[0] |
| 1988 | assert(_version == 4) |
| 1989 | _type = reader.read("!B")[0] |
| 1990 | assert(_type == 4) |
| 1991 | _length = reader.read("!H")[0] |
| 1992 | obj.xid = reader.read("!L")[0] |
| 1993 | _experimenter = reader.read("!L")[0] |
| 1994 | assert(_experimenter == 6035143) |
| 1995 | _subtype = reader.read("!L")[0] |
| 1996 | assert(_subtype == 36) |
| 1997 | obj.enable = reader.read("!L")[0] |
| 1998 | return obj |
| 1999 | |
| 2000 | def __eq__(self, other): |
| 2001 | if type(self) != type(other): return False |
| 2002 | if self.version != other.version: return False |
| 2003 | if self.type != other.type: return False |
| 2004 | if self.xid != other.xid: return False |
| 2005 | if self.enable != other.enable: return False |
| 2006 | return True |
| 2007 | |
| 2008 | def __ne__(self, other): |
| 2009 | return not self.__eq__(other) |
| 2010 | |
| 2011 | def __str__(self): |
| 2012 | return self.show() |
| 2013 | |
| 2014 | def show(self): |
| 2015 | import loxi.pp |
| 2016 | return loxi.pp.pp(self) |
| 2017 | |
| 2018 | def pretty_print(self, q): |
| 2019 | q.text("bsn_flow_idle_enable_set_request {") |
| 2020 | with q.group(): |
| 2021 | with q.indent(2): |
| 2022 | q.breakable() |
| 2023 | q.text("xid = "); |
| 2024 | if self.xid != None: |
| 2025 | q.text("%#x" % self.xid) |
| 2026 | else: |
| 2027 | q.text('None') |
| 2028 | q.text(","); q.breakable() |
| 2029 | q.text("enable = "); |
| 2030 | q.text("%#x" % self.enable) |
| 2031 | q.breakable() |
| 2032 | q.text('}') |
| 2033 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2034 | class bsn_get_interfaces_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2035 | version = 4 |
| 2036 | type = 4 |
| 2037 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2038 | subtype = 10 |
| 2039 | |
| 2040 | def __init__(self, xid=None, interfaces=None): |
| 2041 | self.xid = xid |
| 2042 | if interfaces != None: |
| 2043 | self.interfaces = interfaces |
| 2044 | else: |
| 2045 | self.interfaces = [] |
| 2046 | |
| 2047 | def pack(self): |
| 2048 | packed = [] |
| 2049 | packed.append(struct.pack("!B", self.version)) |
| 2050 | packed.append(struct.pack("!B", self.type)) |
| 2051 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2052 | packed.append(struct.pack("!L", self.xid)) |
| 2053 | packed.append(struct.pack("!L", self.experimenter)) |
| 2054 | packed.append(struct.pack("!L", self.subtype)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2055 | packed.append(util.pack_list(self.interfaces)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2056 | length = sum([len(x) for x in packed]) |
| 2057 | packed[2] = struct.pack("!H", length) |
| 2058 | return ''.join(packed) |
| 2059 | |
| 2060 | @staticmethod |
| 2061 | def unpack(buf): |
| 2062 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2063 | obj = bsn_get_interfaces_reply() |
| 2064 | if type(buf) == loxi.generic_util.OFReader: |
| 2065 | reader = buf |
| 2066 | else: |
| 2067 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2068 | _version = reader.read("!B")[0] |
| 2069 | assert(_version == 4) |
| 2070 | _type = reader.read("!B")[0] |
| 2071 | assert(_type == 4) |
| 2072 | _length = reader.read("!H")[0] |
| 2073 | obj.xid = reader.read("!L")[0] |
| 2074 | _experimenter = reader.read("!L")[0] |
| 2075 | assert(_experimenter == 6035143) |
| 2076 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2077 | assert(_subtype == 10) |
| 2078 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
| 2079 | return obj |
| 2080 | |
| 2081 | def __eq__(self, other): |
| 2082 | if type(self) != type(other): return False |
| 2083 | if self.version != other.version: return False |
| 2084 | if self.type != other.type: return False |
| 2085 | if self.xid != other.xid: return False |
| 2086 | if self.interfaces != other.interfaces: return False |
| 2087 | return True |
| 2088 | |
| 2089 | def __ne__(self, other): |
| 2090 | return not self.__eq__(other) |
| 2091 | |
| 2092 | def __str__(self): |
| 2093 | return self.show() |
| 2094 | |
| 2095 | def show(self): |
| 2096 | import loxi.pp |
| 2097 | return loxi.pp.pp(self) |
| 2098 | |
| 2099 | def pretty_print(self, q): |
| 2100 | q.text("bsn_get_interfaces_reply {") |
| 2101 | with q.group(): |
| 2102 | with q.indent(2): |
| 2103 | q.breakable() |
| 2104 | q.text("xid = "); |
| 2105 | if self.xid != None: |
| 2106 | q.text("%#x" % self.xid) |
| 2107 | else: |
| 2108 | q.text('None') |
| 2109 | q.text(","); q.breakable() |
| 2110 | q.text("interfaces = "); |
| 2111 | q.pp(self.interfaces) |
| 2112 | q.breakable() |
| 2113 | q.text('}') |
| 2114 | |
| 2115 | class bsn_get_interfaces_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2116 | version = 4 |
| 2117 | type = 4 |
| 2118 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2119 | subtype = 9 |
| 2120 | |
| 2121 | def __init__(self, xid=None): |
| 2122 | self.xid = xid |
| 2123 | |
| 2124 | def pack(self): |
| 2125 | packed = [] |
| 2126 | packed.append(struct.pack("!B", self.version)) |
| 2127 | packed.append(struct.pack("!B", self.type)) |
| 2128 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2129 | packed.append(struct.pack("!L", self.xid)) |
| 2130 | packed.append(struct.pack("!L", self.experimenter)) |
| 2131 | packed.append(struct.pack("!L", self.subtype)) |
| 2132 | length = sum([len(x) for x in packed]) |
| 2133 | packed[2] = struct.pack("!H", length) |
| 2134 | return ''.join(packed) |
| 2135 | |
| 2136 | @staticmethod |
| 2137 | def unpack(buf): |
| 2138 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2139 | obj = bsn_get_interfaces_request() |
| 2140 | if type(buf) == loxi.generic_util.OFReader: |
| 2141 | reader = buf |
| 2142 | else: |
| 2143 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2144 | _version = reader.read("!B")[0] |
| 2145 | assert(_version == 4) |
| 2146 | _type = reader.read("!B")[0] |
| 2147 | assert(_type == 4) |
| 2148 | _length = reader.read("!H")[0] |
| 2149 | obj.xid = reader.read("!L")[0] |
| 2150 | _experimenter = reader.read("!L")[0] |
| 2151 | assert(_experimenter == 6035143) |
| 2152 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2153 | assert(_subtype == 9) |
| 2154 | return obj |
| 2155 | |
| 2156 | def __eq__(self, other): |
| 2157 | if type(self) != type(other): return False |
| 2158 | if self.version != other.version: return False |
| 2159 | if self.type != other.type: return False |
| 2160 | if self.xid != other.xid: return False |
| 2161 | return True |
| 2162 | |
| 2163 | def __ne__(self, other): |
| 2164 | return not self.__eq__(other) |
| 2165 | |
| 2166 | def __str__(self): |
| 2167 | return self.show() |
| 2168 | |
| 2169 | def show(self): |
| 2170 | import loxi.pp |
| 2171 | return loxi.pp.pp(self) |
| 2172 | |
| 2173 | def pretty_print(self, q): |
| 2174 | q.text("bsn_get_interfaces_request {") |
| 2175 | with q.group(): |
| 2176 | with q.indent(2): |
| 2177 | q.breakable() |
| 2178 | q.text("xid = "); |
| 2179 | if self.xid != None: |
| 2180 | q.text("%#x" % self.xid) |
| 2181 | else: |
| 2182 | q.text('None') |
| 2183 | q.breakable() |
| 2184 | q.text('}') |
| 2185 | |
| 2186 | class bsn_get_mirroring_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2187 | version = 4 |
| 2188 | type = 4 |
| 2189 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2190 | subtype = 5 |
| 2191 | |
| 2192 | def __init__(self, xid=None, report_mirror_ports=None): |
| 2193 | self.xid = xid |
| 2194 | if report_mirror_ports != None: |
| 2195 | self.report_mirror_ports = report_mirror_ports |
| 2196 | else: |
| 2197 | self.report_mirror_ports = 0 |
| 2198 | |
| 2199 | def pack(self): |
| 2200 | packed = [] |
| 2201 | packed.append(struct.pack("!B", self.version)) |
| 2202 | packed.append(struct.pack("!B", self.type)) |
| 2203 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2204 | packed.append(struct.pack("!L", self.xid)) |
| 2205 | packed.append(struct.pack("!L", self.experimenter)) |
| 2206 | packed.append(struct.pack("!L", self.subtype)) |
| 2207 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2208 | packed.append('\x00' * 3) |
| 2209 | length = sum([len(x) for x in packed]) |
| 2210 | packed[2] = struct.pack("!H", length) |
| 2211 | return ''.join(packed) |
| 2212 | |
| 2213 | @staticmethod |
| 2214 | def unpack(buf): |
| 2215 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2216 | obj = bsn_get_mirroring_reply() |
| 2217 | if type(buf) == loxi.generic_util.OFReader: |
| 2218 | reader = buf |
| 2219 | else: |
| 2220 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2221 | _version = reader.read("!B")[0] |
| 2222 | assert(_version == 4) |
| 2223 | _type = reader.read("!B")[0] |
| 2224 | assert(_type == 4) |
| 2225 | _length = reader.read("!H")[0] |
| 2226 | obj.xid = reader.read("!L")[0] |
| 2227 | _experimenter = reader.read("!L")[0] |
| 2228 | assert(_experimenter == 6035143) |
| 2229 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2230 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2231 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2232 | reader.skip(3) |
| 2233 | return obj |
| 2234 | |
| 2235 | def __eq__(self, other): |
| 2236 | if type(self) != type(other): return False |
| 2237 | if self.version != other.version: return False |
| 2238 | if self.type != other.type: return False |
| 2239 | if self.xid != other.xid: return False |
| 2240 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2241 | return True |
| 2242 | |
| 2243 | def __ne__(self, other): |
| 2244 | return not self.__eq__(other) |
| 2245 | |
| 2246 | def __str__(self): |
| 2247 | return self.show() |
| 2248 | |
| 2249 | def show(self): |
| 2250 | import loxi.pp |
| 2251 | return loxi.pp.pp(self) |
| 2252 | |
| 2253 | def pretty_print(self, q): |
| 2254 | q.text("bsn_get_mirroring_reply {") |
| 2255 | with q.group(): |
| 2256 | with q.indent(2): |
| 2257 | q.breakable() |
| 2258 | q.text("xid = "); |
| 2259 | if self.xid != None: |
| 2260 | q.text("%#x" % self.xid) |
| 2261 | else: |
| 2262 | q.text('None') |
| 2263 | q.text(","); q.breakable() |
| 2264 | q.text("report_mirror_ports = "); |
| 2265 | q.text("%#x" % self.report_mirror_ports) |
| 2266 | q.breakable() |
| 2267 | q.text('}') |
| 2268 | |
| 2269 | class bsn_get_mirroring_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2270 | version = 4 |
| 2271 | type = 4 |
| 2272 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2273 | subtype = 4 |
| 2274 | |
| 2275 | def __init__(self, xid=None, report_mirror_ports=None): |
| 2276 | self.xid = xid |
| 2277 | if report_mirror_ports != None: |
| 2278 | self.report_mirror_ports = report_mirror_ports |
| 2279 | else: |
| 2280 | self.report_mirror_ports = 0 |
| 2281 | |
| 2282 | def pack(self): |
| 2283 | packed = [] |
| 2284 | packed.append(struct.pack("!B", self.version)) |
| 2285 | packed.append(struct.pack("!B", self.type)) |
| 2286 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2287 | packed.append(struct.pack("!L", self.xid)) |
| 2288 | packed.append(struct.pack("!L", self.experimenter)) |
| 2289 | packed.append(struct.pack("!L", self.subtype)) |
| 2290 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2291 | packed.append('\x00' * 3) |
| 2292 | length = sum([len(x) for x in packed]) |
| 2293 | packed[2] = struct.pack("!H", length) |
| 2294 | return ''.join(packed) |
| 2295 | |
| 2296 | @staticmethod |
| 2297 | def unpack(buf): |
| 2298 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2299 | obj = bsn_get_mirroring_request() |
| 2300 | if type(buf) == loxi.generic_util.OFReader: |
| 2301 | reader = buf |
| 2302 | else: |
| 2303 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2304 | _version = reader.read("!B")[0] |
| 2305 | assert(_version == 4) |
| 2306 | _type = reader.read("!B")[0] |
| 2307 | assert(_type == 4) |
| 2308 | _length = reader.read("!H")[0] |
| 2309 | obj.xid = reader.read("!L")[0] |
| 2310 | _experimenter = reader.read("!L")[0] |
| 2311 | assert(_experimenter == 6035143) |
| 2312 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2313 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2314 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2315 | reader.skip(3) |
| 2316 | return obj |
| 2317 | |
| 2318 | def __eq__(self, other): |
| 2319 | if type(self) != type(other): return False |
| 2320 | if self.version != other.version: return False |
| 2321 | if self.type != other.type: return False |
| 2322 | if self.xid != other.xid: return False |
| 2323 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2324 | return True |
| 2325 | |
| 2326 | def __ne__(self, other): |
| 2327 | return not self.__eq__(other) |
| 2328 | |
| 2329 | def __str__(self): |
| 2330 | return self.show() |
| 2331 | |
| 2332 | def show(self): |
| 2333 | import loxi.pp |
| 2334 | return loxi.pp.pp(self) |
| 2335 | |
| 2336 | def pretty_print(self, q): |
| 2337 | q.text("bsn_get_mirroring_request {") |
| 2338 | with q.group(): |
| 2339 | with q.indent(2): |
| 2340 | q.breakable() |
| 2341 | q.text("xid = "); |
| 2342 | if self.xid != None: |
| 2343 | q.text("%#x" % self.xid) |
| 2344 | else: |
| 2345 | q.text('None') |
| 2346 | q.text(","); q.breakable() |
| 2347 | q.text("report_mirror_ports = "); |
| 2348 | q.text("%#x" % self.report_mirror_ports) |
| 2349 | q.breakable() |
| 2350 | q.text('}') |
| 2351 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2352 | class bsn_lacp_convergence_notif(Message): |
| 2353 | version = 4 |
| 2354 | type = 4 |
| 2355 | experimenter = 6035143 |
| 2356 | subtype = 43 |
| 2357 | |
| 2358 | def __init__(self, xid=None, convergence_status=None, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None, partner_sys_priority=None, partner_sys_mac=None, partner_port_priority=None, partner_port_num=None, partner_key=None): |
| 2359 | self.xid = xid |
| 2360 | if convergence_status != None: |
| 2361 | self.convergence_status = convergence_status |
| 2362 | else: |
| 2363 | self.convergence_status = 0 |
| 2364 | if port_no != None: |
| 2365 | self.port_no = port_no |
| 2366 | else: |
| 2367 | self.port_no = 0 |
| 2368 | if actor_sys_priority != None: |
| 2369 | self.actor_sys_priority = actor_sys_priority |
| 2370 | else: |
| 2371 | self.actor_sys_priority = 0 |
| 2372 | if actor_sys_mac != None: |
| 2373 | self.actor_sys_mac = actor_sys_mac |
| 2374 | else: |
| 2375 | self.actor_sys_mac = [0,0,0,0,0,0] |
| 2376 | if actor_port_priority != None: |
| 2377 | self.actor_port_priority = actor_port_priority |
| 2378 | else: |
| 2379 | self.actor_port_priority = 0 |
| 2380 | if actor_port_num != None: |
| 2381 | self.actor_port_num = actor_port_num |
| 2382 | else: |
| 2383 | self.actor_port_num = 0 |
| 2384 | if actor_key != None: |
| 2385 | self.actor_key = actor_key |
| 2386 | else: |
| 2387 | self.actor_key = 0 |
| 2388 | if partner_sys_priority != None: |
| 2389 | self.partner_sys_priority = partner_sys_priority |
| 2390 | else: |
| 2391 | self.partner_sys_priority = 0 |
| 2392 | if partner_sys_mac != None: |
| 2393 | self.partner_sys_mac = partner_sys_mac |
| 2394 | else: |
| 2395 | self.partner_sys_mac = [0,0,0,0,0,0] |
| 2396 | if partner_port_priority != None: |
| 2397 | self.partner_port_priority = partner_port_priority |
| 2398 | else: |
| 2399 | self.partner_port_priority = 0 |
| 2400 | if partner_port_num != None: |
| 2401 | self.partner_port_num = partner_port_num |
| 2402 | else: |
| 2403 | self.partner_port_num = 0 |
| 2404 | if partner_key != None: |
| 2405 | self.partner_key = partner_key |
| 2406 | else: |
| 2407 | self.partner_key = 0 |
| 2408 | |
| 2409 | def pack(self): |
| 2410 | packed = [] |
| 2411 | packed.append(struct.pack("!B", self.version)) |
| 2412 | packed.append(struct.pack("!B", self.type)) |
| 2413 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2414 | packed.append(struct.pack("!L", self.xid)) |
| 2415 | packed.append(struct.pack("!L", self.experimenter)) |
| 2416 | packed.append(struct.pack("!L", self.subtype)) |
| 2417 | packed.append(struct.pack("!B", self.convergence_status)) |
| 2418 | packed.append('\x00' * 3) |
| 2419 | packed.append(util.pack_port_no(self.port_no)) |
| 2420 | packed.append(struct.pack("!H", self.actor_sys_priority)) |
| 2421 | packed.append(struct.pack("!6B", *self.actor_sys_mac)) |
| 2422 | packed.append(struct.pack("!H", self.actor_port_priority)) |
| 2423 | packed.append(struct.pack("!H", self.actor_port_num)) |
| 2424 | packed.append(struct.pack("!H", self.actor_key)) |
| 2425 | packed.append(struct.pack("!H", self.partner_sys_priority)) |
| 2426 | packed.append(struct.pack("!6B", *self.partner_sys_mac)) |
| 2427 | packed.append(struct.pack("!H", self.partner_port_priority)) |
| 2428 | packed.append(struct.pack("!H", self.partner_port_num)) |
| 2429 | packed.append(struct.pack("!H", self.partner_key)) |
| 2430 | length = sum([len(x) for x in packed]) |
| 2431 | packed[2] = struct.pack("!H", length) |
| 2432 | return ''.join(packed) |
| 2433 | |
| 2434 | @staticmethod |
| 2435 | def unpack(buf): |
| 2436 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2437 | obj = bsn_lacp_convergence_notif() |
| 2438 | if type(buf) == loxi.generic_util.OFReader: |
| 2439 | reader = buf |
| 2440 | else: |
| 2441 | reader = loxi.generic_util.OFReader(buf) |
| 2442 | _version = reader.read("!B")[0] |
| 2443 | assert(_version == 4) |
| 2444 | _type = reader.read("!B")[0] |
| 2445 | assert(_type == 4) |
| 2446 | _length = reader.read("!H")[0] |
| 2447 | obj.xid = reader.read("!L")[0] |
| 2448 | _experimenter = reader.read("!L")[0] |
| 2449 | assert(_experimenter == 6035143) |
| 2450 | _subtype = reader.read("!L")[0] |
| 2451 | assert(_subtype == 43) |
| 2452 | obj.convergence_status = reader.read("!B")[0] |
| 2453 | reader.skip(3) |
| 2454 | obj.port_no = util.unpack_port_no(reader) |
| 2455 | obj.actor_sys_priority = reader.read("!H")[0] |
| 2456 | obj.actor_sys_mac = list(reader.read('!6B')) |
| 2457 | obj.actor_port_priority = reader.read("!H")[0] |
| 2458 | obj.actor_port_num = reader.read("!H")[0] |
| 2459 | obj.actor_key = reader.read("!H")[0] |
| 2460 | obj.partner_sys_priority = reader.read("!H")[0] |
| 2461 | obj.partner_sys_mac = list(reader.read('!6B')) |
| 2462 | obj.partner_port_priority = reader.read("!H")[0] |
| 2463 | obj.partner_port_num = reader.read("!H")[0] |
| 2464 | obj.partner_key = reader.read("!H")[0] |
| 2465 | return obj |
| 2466 | |
| 2467 | def __eq__(self, other): |
| 2468 | if type(self) != type(other): return False |
| 2469 | if self.version != other.version: return False |
| 2470 | if self.type != other.type: return False |
| 2471 | if self.xid != other.xid: return False |
| 2472 | if self.convergence_status != other.convergence_status: return False |
| 2473 | if self.port_no != other.port_no: return False |
| 2474 | if self.actor_sys_priority != other.actor_sys_priority: return False |
| 2475 | if self.actor_sys_mac != other.actor_sys_mac: return False |
| 2476 | if self.actor_port_priority != other.actor_port_priority: return False |
| 2477 | if self.actor_port_num != other.actor_port_num: return False |
| 2478 | if self.actor_key != other.actor_key: return False |
| 2479 | if self.partner_sys_priority != other.partner_sys_priority: return False |
| 2480 | if self.partner_sys_mac != other.partner_sys_mac: return False |
| 2481 | if self.partner_port_priority != other.partner_port_priority: return False |
| 2482 | if self.partner_port_num != other.partner_port_num: return False |
| 2483 | if self.partner_key != other.partner_key: return False |
| 2484 | return True |
| 2485 | |
| 2486 | def __ne__(self, other): |
| 2487 | return not self.__eq__(other) |
| 2488 | |
| 2489 | def __str__(self): |
| 2490 | return self.show() |
| 2491 | |
| 2492 | def show(self): |
| 2493 | import loxi.pp |
| 2494 | return loxi.pp.pp(self) |
| 2495 | |
| 2496 | def pretty_print(self, q): |
| 2497 | q.text("bsn_lacp_convergence_notif {") |
| 2498 | with q.group(): |
| 2499 | with q.indent(2): |
| 2500 | q.breakable() |
| 2501 | q.text("xid = "); |
| 2502 | if self.xid != None: |
| 2503 | q.text("%#x" % self.xid) |
| 2504 | else: |
| 2505 | q.text('None') |
| 2506 | q.text(","); q.breakable() |
| 2507 | q.text("convergence_status = "); |
| 2508 | q.text("%#x" % self.convergence_status) |
| 2509 | q.text(","); q.breakable() |
| 2510 | q.text("port_no = "); |
| 2511 | q.text(util.pretty_port(self.port_no)) |
| 2512 | q.text(","); q.breakable() |
| 2513 | q.text("actor_sys_priority = "); |
| 2514 | q.text("%#x" % self.actor_sys_priority) |
| 2515 | q.text(","); q.breakable() |
| 2516 | q.text("actor_sys_mac = "); |
| 2517 | q.text(util.pretty_mac(self.actor_sys_mac)) |
| 2518 | q.text(","); q.breakable() |
| 2519 | q.text("actor_port_priority = "); |
| 2520 | q.text("%#x" % self.actor_port_priority) |
| 2521 | q.text(","); q.breakable() |
| 2522 | q.text("actor_port_num = "); |
| 2523 | q.text("%#x" % self.actor_port_num) |
| 2524 | q.text(","); q.breakable() |
| 2525 | q.text("actor_key = "); |
| 2526 | q.text("%#x" % self.actor_key) |
| 2527 | q.text(","); q.breakable() |
| 2528 | q.text("partner_sys_priority = "); |
| 2529 | q.text("%#x" % self.partner_sys_priority) |
| 2530 | q.text(","); q.breakable() |
| 2531 | q.text("partner_sys_mac = "); |
| 2532 | q.text(util.pretty_mac(self.partner_sys_mac)) |
| 2533 | q.text(","); q.breakable() |
| 2534 | q.text("partner_port_priority = "); |
| 2535 | q.text("%#x" % self.partner_port_priority) |
| 2536 | q.text(","); q.breakable() |
| 2537 | q.text("partner_port_num = "); |
| 2538 | q.text("%#x" % self.partner_port_num) |
| 2539 | q.text(","); q.breakable() |
| 2540 | q.text("partner_key = "); |
| 2541 | q.text("%#x" % self.partner_key) |
| 2542 | q.breakable() |
| 2543 | q.text('}') |
| 2544 | |
| 2545 | class bsn_lacp_stats_reply(Message): |
| 2546 | version = 4 |
| 2547 | type = 19 |
| 2548 | stats_type = 65535 |
| 2549 | experimenter = 6035143 |
| 2550 | subtype = 1 |
| 2551 | |
| 2552 | def __init__(self, xid=None, flags=None, entries=None): |
| 2553 | self.xid = xid |
| 2554 | if flags != None: |
| 2555 | self.flags = flags |
| 2556 | else: |
| 2557 | self.flags = 0 |
| 2558 | if entries != None: |
| 2559 | self.entries = entries |
| 2560 | else: |
| 2561 | self.entries = [] |
| 2562 | |
| 2563 | def pack(self): |
| 2564 | packed = [] |
| 2565 | packed.append(struct.pack("!B", self.version)) |
| 2566 | packed.append(struct.pack("!B", self.type)) |
| 2567 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2568 | packed.append(struct.pack("!L", self.xid)) |
| 2569 | packed.append(struct.pack("!H", self.stats_type)) |
| 2570 | packed.append(struct.pack("!H", self.flags)) |
| 2571 | packed.append('\x00' * 4) |
| 2572 | packed.append(struct.pack("!L", self.experimenter)) |
| 2573 | packed.append(struct.pack("!L", self.subtype)) |
| 2574 | packed.append(util.pack_list(self.entries)) |
| 2575 | length = sum([len(x) for x in packed]) |
| 2576 | packed[2] = struct.pack("!H", length) |
| 2577 | return ''.join(packed) |
| 2578 | |
| 2579 | @staticmethod |
| 2580 | def unpack(buf): |
| 2581 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2582 | obj = bsn_lacp_stats_reply() |
| 2583 | if type(buf) == loxi.generic_util.OFReader: |
| 2584 | reader = buf |
| 2585 | else: |
| 2586 | reader = loxi.generic_util.OFReader(buf) |
| 2587 | _version = reader.read("!B")[0] |
| 2588 | assert(_version == 4) |
| 2589 | _type = reader.read("!B")[0] |
| 2590 | assert(_type == 19) |
| 2591 | _length = reader.read("!H")[0] |
| 2592 | obj.xid = reader.read("!L")[0] |
| 2593 | _stats_type = reader.read("!H")[0] |
| 2594 | assert(_stats_type == 65535) |
| 2595 | obj.flags = reader.read("!H")[0] |
| 2596 | reader.skip(4) |
| 2597 | _experimenter = reader.read("!L")[0] |
| 2598 | assert(_experimenter == 6035143) |
| 2599 | _subtype = reader.read("!L")[0] |
| 2600 | assert(_subtype == 1) |
| 2601 | obj.entries = loxi.generic_util.unpack_list(reader, common.bsn_lacp_stats_entry.unpack) |
| 2602 | return obj |
| 2603 | |
| 2604 | def __eq__(self, other): |
| 2605 | if type(self) != type(other): return False |
| 2606 | if self.version != other.version: return False |
| 2607 | if self.type != other.type: return False |
| 2608 | if self.xid != other.xid: return False |
| 2609 | if self.flags != other.flags: return False |
| 2610 | if self.entries != other.entries: return False |
| 2611 | return True |
| 2612 | |
| 2613 | def __ne__(self, other): |
| 2614 | return not self.__eq__(other) |
| 2615 | |
| 2616 | def __str__(self): |
| 2617 | return self.show() |
| 2618 | |
| 2619 | def show(self): |
| 2620 | import loxi.pp |
| 2621 | return loxi.pp.pp(self) |
| 2622 | |
| 2623 | def pretty_print(self, q): |
| 2624 | q.text("bsn_lacp_stats_reply {") |
| 2625 | with q.group(): |
| 2626 | with q.indent(2): |
| 2627 | q.breakable() |
| 2628 | q.text("xid = "); |
| 2629 | if self.xid != None: |
| 2630 | q.text("%#x" % self.xid) |
| 2631 | else: |
| 2632 | q.text('None') |
| 2633 | q.text(","); q.breakable() |
| 2634 | q.text("flags = "); |
| 2635 | q.text("%#x" % self.flags) |
| 2636 | q.text(","); q.breakable() |
| 2637 | q.text("entries = "); |
| 2638 | q.pp(self.entries) |
| 2639 | q.breakable() |
| 2640 | q.text('}') |
| 2641 | |
| 2642 | class bsn_lacp_stats_request(Message): |
| 2643 | version = 4 |
| 2644 | type = 18 |
| 2645 | stats_type = 65535 |
| 2646 | experimenter = 6035143 |
| 2647 | subtype = 1 |
| 2648 | |
| 2649 | def __init__(self, xid=None, flags=None): |
| 2650 | self.xid = xid |
| 2651 | if flags != None: |
| 2652 | self.flags = flags |
| 2653 | else: |
| 2654 | self.flags = 0 |
| 2655 | |
| 2656 | def pack(self): |
| 2657 | packed = [] |
| 2658 | packed.append(struct.pack("!B", self.version)) |
| 2659 | packed.append(struct.pack("!B", self.type)) |
| 2660 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2661 | packed.append(struct.pack("!L", self.xid)) |
| 2662 | packed.append(struct.pack("!H", self.stats_type)) |
| 2663 | packed.append(struct.pack("!H", self.flags)) |
| 2664 | packed.append('\x00' * 4) |
| 2665 | packed.append(struct.pack("!L", self.experimenter)) |
| 2666 | packed.append(struct.pack("!L", self.subtype)) |
| 2667 | length = sum([len(x) for x in packed]) |
| 2668 | packed[2] = struct.pack("!H", length) |
| 2669 | return ''.join(packed) |
| 2670 | |
| 2671 | @staticmethod |
| 2672 | def unpack(buf): |
| 2673 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2674 | obj = bsn_lacp_stats_request() |
| 2675 | if type(buf) == loxi.generic_util.OFReader: |
| 2676 | reader = buf |
| 2677 | else: |
| 2678 | reader = loxi.generic_util.OFReader(buf) |
| 2679 | _version = reader.read("!B")[0] |
| 2680 | assert(_version == 4) |
| 2681 | _type = reader.read("!B")[0] |
| 2682 | assert(_type == 18) |
| 2683 | _length = reader.read("!H")[0] |
| 2684 | obj.xid = reader.read("!L")[0] |
| 2685 | _stats_type = reader.read("!H")[0] |
| 2686 | assert(_stats_type == 65535) |
| 2687 | obj.flags = reader.read("!H")[0] |
| 2688 | reader.skip(4) |
| 2689 | _experimenter = reader.read("!L")[0] |
| 2690 | assert(_experimenter == 6035143) |
| 2691 | _subtype = reader.read("!L")[0] |
| 2692 | assert(_subtype == 1) |
| 2693 | return obj |
| 2694 | |
| 2695 | def __eq__(self, other): |
| 2696 | if type(self) != type(other): return False |
| 2697 | if self.version != other.version: return False |
| 2698 | if self.type != other.type: return False |
| 2699 | if self.xid != other.xid: return False |
| 2700 | if self.flags != other.flags: return False |
| 2701 | return True |
| 2702 | |
| 2703 | def __ne__(self, other): |
| 2704 | return not self.__eq__(other) |
| 2705 | |
| 2706 | def __str__(self): |
| 2707 | return self.show() |
| 2708 | |
| 2709 | def show(self): |
| 2710 | import loxi.pp |
| 2711 | return loxi.pp.pp(self) |
| 2712 | |
| 2713 | def pretty_print(self, q): |
| 2714 | q.text("bsn_lacp_stats_request {") |
| 2715 | with q.group(): |
| 2716 | with q.indent(2): |
| 2717 | q.breakable() |
| 2718 | q.text("xid = "); |
| 2719 | if self.xid != None: |
| 2720 | q.text("%#x" % self.xid) |
| 2721 | else: |
| 2722 | q.text('None') |
| 2723 | q.text(","); q.breakable() |
| 2724 | q.text("flags = "); |
| 2725 | q.text("%#x" % self.flags) |
| 2726 | q.breakable() |
| 2727 | q.text('}') |
| 2728 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2729 | class bsn_pdu_rx_reply(Message): |
| 2730 | version = 4 |
| 2731 | type = 4 |
| 2732 | experimenter = 6035143 |
| 2733 | subtype = 34 |
| 2734 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2735 | def __init__(self, xid=None, status=None, port_no=None, slot_num=None): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2736 | self.xid = xid |
| 2737 | if status != None: |
| 2738 | self.status = status |
| 2739 | else: |
| 2740 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2741 | if port_no != None: |
| 2742 | self.port_no = port_no |
| 2743 | else: |
| 2744 | self.port_no = 0 |
| 2745 | if slot_num != None: |
| 2746 | self.slot_num = slot_num |
| 2747 | else: |
| 2748 | self.slot_num = 0 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2749 | |
| 2750 | def pack(self): |
| 2751 | packed = [] |
| 2752 | packed.append(struct.pack("!B", self.version)) |
| 2753 | packed.append(struct.pack("!B", self.type)) |
| 2754 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2755 | packed.append(struct.pack("!L", self.xid)) |
| 2756 | packed.append(struct.pack("!L", self.experimenter)) |
| 2757 | packed.append(struct.pack("!L", self.subtype)) |
| 2758 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2759 | packed.append(util.pack_port_no(self.port_no)) |
| 2760 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2761 | length = sum([len(x) for x in packed]) |
| 2762 | packed[2] = struct.pack("!H", length) |
| 2763 | return ''.join(packed) |
| 2764 | |
| 2765 | @staticmethod |
| 2766 | def unpack(buf): |
| 2767 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2768 | obj = bsn_pdu_rx_reply() |
| 2769 | if type(buf) == loxi.generic_util.OFReader: |
| 2770 | reader = buf |
| 2771 | else: |
| 2772 | reader = loxi.generic_util.OFReader(buf) |
| 2773 | _version = reader.read("!B")[0] |
| 2774 | assert(_version == 4) |
| 2775 | _type = reader.read("!B")[0] |
| 2776 | assert(_type == 4) |
| 2777 | _length = reader.read("!H")[0] |
| 2778 | obj.xid = reader.read("!L")[0] |
| 2779 | _experimenter = reader.read("!L")[0] |
| 2780 | assert(_experimenter == 6035143) |
| 2781 | _subtype = reader.read("!L")[0] |
| 2782 | assert(_subtype == 34) |
| 2783 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2784 | obj.port_no = util.unpack_port_no(reader) |
| 2785 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2786 | return obj |
| 2787 | |
| 2788 | def __eq__(self, other): |
| 2789 | if type(self) != type(other): return False |
| 2790 | if self.version != other.version: return False |
| 2791 | if self.type != other.type: return False |
| 2792 | if self.xid != other.xid: return False |
| 2793 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2794 | if self.port_no != other.port_no: return False |
| 2795 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2796 | return True |
| 2797 | |
| 2798 | def __ne__(self, other): |
| 2799 | return not self.__eq__(other) |
| 2800 | |
| 2801 | def __str__(self): |
| 2802 | return self.show() |
| 2803 | |
| 2804 | def show(self): |
| 2805 | import loxi.pp |
| 2806 | return loxi.pp.pp(self) |
| 2807 | |
| 2808 | def pretty_print(self, q): |
| 2809 | q.text("bsn_pdu_rx_reply {") |
| 2810 | with q.group(): |
| 2811 | with q.indent(2): |
| 2812 | q.breakable() |
| 2813 | q.text("xid = "); |
| 2814 | if self.xid != None: |
| 2815 | q.text("%#x" % self.xid) |
| 2816 | else: |
| 2817 | q.text('None') |
| 2818 | q.text(","); q.breakable() |
| 2819 | q.text("status = "); |
| 2820 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 2821 | q.text(","); q.breakable() |
| 2822 | q.text("port_no = "); |
| 2823 | q.text(util.pretty_port(self.port_no)) |
| 2824 | q.text(","); q.breakable() |
| 2825 | q.text("slot_num = "); |
| 2826 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2827 | q.breakable() |
| 2828 | q.text('}') |
| 2829 | |
| 2830 | class bsn_pdu_rx_request(Message): |
| 2831 | version = 4 |
| 2832 | type = 4 |
| 2833 | experimenter = 6035143 |
| 2834 | subtype = 33 |
| 2835 | |
| 2836 | def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None): |
| 2837 | self.xid = xid |
| 2838 | if timeout_ms != None: |
| 2839 | self.timeout_ms = timeout_ms |
| 2840 | else: |
| 2841 | self.timeout_ms = 0 |
| 2842 | if port_no != None: |
| 2843 | self.port_no = port_no |
| 2844 | else: |
| 2845 | self.port_no = 0 |
| 2846 | if slot_num != None: |
| 2847 | self.slot_num = slot_num |
| 2848 | else: |
| 2849 | self.slot_num = 0 |
| 2850 | if data != None: |
| 2851 | self.data = data |
| 2852 | else: |
| 2853 | self.data = '' |
| 2854 | |
| 2855 | def pack(self): |
| 2856 | packed = [] |
| 2857 | packed.append(struct.pack("!B", self.version)) |
| 2858 | packed.append(struct.pack("!B", self.type)) |
| 2859 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2860 | packed.append(struct.pack("!L", self.xid)) |
| 2861 | packed.append(struct.pack("!L", self.experimenter)) |
| 2862 | packed.append(struct.pack("!L", self.subtype)) |
| 2863 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 2864 | packed.append(util.pack_port_no(self.port_no)) |
| 2865 | packed.append(struct.pack("!B", self.slot_num)) |
| 2866 | packed.append('\x00' * 3) |
| 2867 | packed.append(self.data) |
| 2868 | length = sum([len(x) for x in packed]) |
| 2869 | packed[2] = struct.pack("!H", length) |
| 2870 | return ''.join(packed) |
| 2871 | |
| 2872 | @staticmethod |
| 2873 | def unpack(buf): |
| 2874 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2875 | obj = bsn_pdu_rx_request() |
| 2876 | if type(buf) == loxi.generic_util.OFReader: |
| 2877 | reader = buf |
| 2878 | else: |
| 2879 | reader = loxi.generic_util.OFReader(buf) |
| 2880 | _version = reader.read("!B")[0] |
| 2881 | assert(_version == 4) |
| 2882 | _type = reader.read("!B")[0] |
| 2883 | assert(_type == 4) |
| 2884 | _length = reader.read("!H")[0] |
| 2885 | obj.xid = reader.read("!L")[0] |
| 2886 | _experimenter = reader.read("!L")[0] |
| 2887 | assert(_experimenter == 6035143) |
| 2888 | _subtype = reader.read("!L")[0] |
| 2889 | assert(_subtype == 33) |
| 2890 | obj.timeout_ms = reader.read("!L")[0] |
| 2891 | obj.port_no = util.unpack_port_no(reader) |
| 2892 | obj.slot_num = reader.read("!B")[0] |
| 2893 | reader.skip(3) |
| 2894 | obj.data = str(reader.read_all()) |
| 2895 | return obj |
| 2896 | |
| 2897 | def __eq__(self, other): |
| 2898 | if type(self) != type(other): return False |
| 2899 | if self.version != other.version: return False |
| 2900 | if self.type != other.type: return False |
| 2901 | if self.xid != other.xid: return False |
| 2902 | if self.timeout_ms != other.timeout_ms: return False |
| 2903 | if self.port_no != other.port_no: return False |
| 2904 | if self.slot_num != other.slot_num: return False |
| 2905 | if self.data != other.data: return False |
| 2906 | return True |
| 2907 | |
| 2908 | def __ne__(self, other): |
| 2909 | return not self.__eq__(other) |
| 2910 | |
| 2911 | def __str__(self): |
| 2912 | return self.show() |
| 2913 | |
| 2914 | def show(self): |
| 2915 | import loxi.pp |
| 2916 | return loxi.pp.pp(self) |
| 2917 | |
| 2918 | def pretty_print(self, q): |
| 2919 | q.text("bsn_pdu_rx_request {") |
| 2920 | with q.group(): |
| 2921 | with q.indent(2): |
| 2922 | q.breakable() |
| 2923 | q.text("xid = "); |
| 2924 | if self.xid != None: |
| 2925 | q.text("%#x" % self.xid) |
| 2926 | else: |
| 2927 | q.text('None') |
| 2928 | q.text(","); q.breakable() |
| 2929 | q.text("timeout_ms = "); |
| 2930 | q.text("%#x" % self.timeout_ms) |
| 2931 | q.text(","); q.breakable() |
| 2932 | q.text("port_no = "); |
| 2933 | q.text(util.pretty_port(self.port_no)) |
| 2934 | q.text(","); q.breakable() |
| 2935 | q.text("slot_num = "); |
| 2936 | q.text("%#x" % self.slot_num) |
| 2937 | q.text(","); q.breakable() |
| 2938 | q.text("data = "); |
| 2939 | q.pp(self.data) |
| 2940 | q.breakable() |
| 2941 | q.text('}') |
| 2942 | |
| 2943 | class bsn_pdu_rx_timeout(Message): |
| 2944 | version = 4 |
| 2945 | type = 4 |
| 2946 | experimenter = 6035143 |
| 2947 | subtype = 35 |
| 2948 | |
| 2949 | def __init__(self, xid=None, port_no=None, slot_num=None): |
| 2950 | self.xid = xid |
| 2951 | if port_no != None: |
| 2952 | self.port_no = port_no |
| 2953 | else: |
| 2954 | self.port_no = 0 |
| 2955 | if slot_num != None: |
| 2956 | self.slot_num = slot_num |
| 2957 | else: |
| 2958 | self.slot_num = 0 |
| 2959 | |
| 2960 | def pack(self): |
| 2961 | packed = [] |
| 2962 | packed.append(struct.pack("!B", self.version)) |
| 2963 | packed.append(struct.pack("!B", self.type)) |
| 2964 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2965 | packed.append(struct.pack("!L", self.xid)) |
| 2966 | packed.append(struct.pack("!L", self.experimenter)) |
| 2967 | packed.append(struct.pack("!L", self.subtype)) |
| 2968 | packed.append(util.pack_port_no(self.port_no)) |
| 2969 | packed.append(struct.pack("!B", self.slot_num)) |
| 2970 | length = sum([len(x) for x in packed]) |
| 2971 | packed[2] = struct.pack("!H", length) |
| 2972 | return ''.join(packed) |
| 2973 | |
| 2974 | @staticmethod |
| 2975 | def unpack(buf): |
| 2976 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2977 | obj = bsn_pdu_rx_timeout() |
| 2978 | if type(buf) == loxi.generic_util.OFReader: |
| 2979 | reader = buf |
| 2980 | else: |
| 2981 | reader = loxi.generic_util.OFReader(buf) |
| 2982 | _version = reader.read("!B")[0] |
| 2983 | assert(_version == 4) |
| 2984 | _type = reader.read("!B")[0] |
| 2985 | assert(_type == 4) |
| 2986 | _length = reader.read("!H")[0] |
| 2987 | obj.xid = reader.read("!L")[0] |
| 2988 | _experimenter = reader.read("!L")[0] |
| 2989 | assert(_experimenter == 6035143) |
| 2990 | _subtype = reader.read("!L")[0] |
| 2991 | assert(_subtype == 35) |
| 2992 | obj.port_no = util.unpack_port_no(reader) |
| 2993 | obj.slot_num = reader.read("!B")[0] |
| 2994 | return obj |
| 2995 | |
| 2996 | def __eq__(self, other): |
| 2997 | if type(self) != type(other): return False |
| 2998 | if self.version != other.version: return False |
| 2999 | if self.type != other.type: return False |
| 3000 | if self.xid != other.xid: return False |
| 3001 | if self.port_no != other.port_no: return False |
| 3002 | if self.slot_num != other.slot_num: return False |
| 3003 | return True |
| 3004 | |
| 3005 | def __ne__(self, other): |
| 3006 | return not self.__eq__(other) |
| 3007 | |
| 3008 | def __str__(self): |
| 3009 | return self.show() |
| 3010 | |
| 3011 | def show(self): |
| 3012 | import loxi.pp |
| 3013 | return loxi.pp.pp(self) |
| 3014 | |
| 3015 | def pretty_print(self, q): |
| 3016 | q.text("bsn_pdu_rx_timeout {") |
| 3017 | with q.group(): |
| 3018 | with q.indent(2): |
| 3019 | q.breakable() |
| 3020 | q.text("xid = "); |
| 3021 | if self.xid != None: |
| 3022 | q.text("%#x" % self.xid) |
| 3023 | else: |
| 3024 | q.text('None') |
| 3025 | q.text(","); q.breakable() |
| 3026 | q.text("port_no = "); |
| 3027 | q.text(util.pretty_port(self.port_no)) |
| 3028 | q.text(","); q.breakable() |
| 3029 | q.text("slot_num = "); |
| 3030 | q.text("%#x" % self.slot_num) |
| 3031 | q.breakable() |
| 3032 | q.text('}') |
| 3033 | |
| 3034 | class bsn_pdu_tx_reply(Message): |
| 3035 | version = 4 |
| 3036 | type = 4 |
| 3037 | experimenter = 6035143 |
| 3038 | subtype = 32 |
| 3039 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3040 | def __init__(self, xid=None, status=None, port_no=None, slot_num=None): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3041 | self.xid = xid |
| 3042 | if status != None: |
| 3043 | self.status = status |
| 3044 | else: |
| 3045 | self.status = 0 |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3046 | if port_no != None: |
| 3047 | self.port_no = port_no |
| 3048 | else: |
| 3049 | self.port_no = 0 |
| 3050 | if slot_num != None: |
| 3051 | self.slot_num = slot_num |
| 3052 | else: |
| 3053 | self.slot_num = 0 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3054 | |
| 3055 | def pack(self): |
| 3056 | packed = [] |
| 3057 | packed.append(struct.pack("!B", self.version)) |
| 3058 | packed.append(struct.pack("!B", self.type)) |
| 3059 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3060 | packed.append(struct.pack("!L", self.xid)) |
| 3061 | packed.append(struct.pack("!L", self.experimenter)) |
| 3062 | packed.append(struct.pack("!L", self.subtype)) |
| 3063 | packed.append(struct.pack("!L", self.status)) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3064 | packed.append(util.pack_port_no(self.port_no)) |
| 3065 | packed.append(struct.pack("!B", self.slot_num)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3066 | length = sum([len(x) for x in packed]) |
| 3067 | packed[2] = struct.pack("!H", length) |
| 3068 | return ''.join(packed) |
| 3069 | |
| 3070 | @staticmethod |
| 3071 | def unpack(buf): |
| 3072 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3073 | obj = bsn_pdu_tx_reply() |
| 3074 | if type(buf) == loxi.generic_util.OFReader: |
| 3075 | reader = buf |
| 3076 | else: |
| 3077 | reader = loxi.generic_util.OFReader(buf) |
| 3078 | _version = reader.read("!B")[0] |
| 3079 | assert(_version == 4) |
| 3080 | _type = reader.read("!B")[0] |
| 3081 | assert(_type == 4) |
| 3082 | _length = reader.read("!H")[0] |
| 3083 | obj.xid = reader.read("!L")[0] |
| 3084 | _experimenter = reader.read("!L")[0] |
| 3085 | assert(_experimenter == 6035143) |
| 3086 | _subtype = reader.read("!L")[0] |
| 3087 | assert(_subtype == 32) |
| 3088 | obj.status = reader.read("!L")[0] |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3089 | obj.port_no = util.unpack_port_no(reader) |
| 3090 | obj.slot_num = reader.read("!B")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3091 | return obj |
| 3092 | |
| 3093 | def __eq__(self, other): |
| 3094 | if type(self) != type(other): return False |
| 3095 | if self.version != other.version: return False |
| 3096 | if self.type != other.type: return False |
| 3097 | if self.xid != other.xid: return False |
| 3098 | if self.status != other.status: return False |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3099 | if self.port_no != other.port_no: return False |
| 3100 | if self.slot_num != other.slot_num: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3101 | return True |
| 3102 | |
| 3103 | def __ne__(self, other): |
| 3104 | return not self.__eq__(other) |
| 3105 | |
| 3106 | def __str__(self): |
| 3107 | return self.show() |
| 3108 | |
| 3109 | def show(self): |
| 3110 | import loxi.pp |
| 3111 | return loxi.pp.pp(self) |
| 3112 | |
| 3113 | def pretty_print(self, q): |
| 3114 | q.text("bsn_pdu_tx_reply {") |
| 3115 | with q.group(): |
| 3116 | with q.indent(2): |
| 3117 | q.breakable() |
| 3118 | q.text("xid = "); |
| 3119 | if self.xid != None: |
| 3120 | q.text("%#x" % self.xid) |
| 3121 | else: |
| 3122 | q.text('None') |
| 3123 | q.text(","); q.breakable() |
| 3124 | q.text("status = "); |
| 3125 | q.text("%#x" % self.status) |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3126 | q.text(","); q.breakable() |
| 3127 | q.text("port_no = "); |
| 3128 | q.text(util.pretty_port(self.port_no)) |
| 3129 | q.text(","); q.breakable() |
| 3130 | q.text("slot_num = "); |
| 3131 | q.text("%#x" % self.slot_num) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3132 | q.breakable() |
| 3133 | q.text('}') |
| 3134 | |
| 3135 | class bsn_pdu_tx_request(Message): |
| 3136 | version = 4 |
| 3137 | type = 4 |
| 3138 | experimenter = 6035143 |
| 3139 | subtype = 31 |
| 3140 | |
| 3141 | def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None): |
| 3142 | self.xid = xid |
| 3143 | if tx_interval_ms != None: |
| 3144 | self.tx_interval_ms = tx_interval_ms |
| 3145 | else: |
| 3146 | self.tx_interval_ms = 0 |
| 3147 | if port_no != None: |
| 3148 | self.port_no = port_no |
| 3149 | else: |
| 3150 | self.port_no = 0 |
| 3151 | if slot_num != None: |
| 3152 | self.slot_num = slot_num |
| 3153 | else: |
| 3154 | self.slot_num = 0 |
| 3155 | if data != None: |
| 3156 | self.data = data |
| 3157 | else: |
| 3158 | self.data = '' |
| 3159 | |
| 3160 | def pack(self): |
| 3161 | packed = [] |
| 3162 | packed.append(struct.pack("!B", self.version)) |
| 3163 | packed.append(struct.pack("!B", self.type)) |
| 3164 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3165 | packed.append(struct.pack("!L", self.xid)) |
| 3166 | packed.append(struct.pack("!L", self.experimenter)) |
| 3167 | packed.append(struct.pack("!L", self.subtype)) |
| 3168 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 3169 | packed.append(util.pack_port_no(self.port_no)) |
| 3170 | packed.append(struct.pack("!B", self.slot_num)) |
| 3171 | packed.append('\x00' * 3) |
| 3172 | packed.append(self.data) |
| 3173 | length = sum([len(x) for x in packed]) |
| 3174 | packed[2] = struct.pack("!H", length) |
| 3175 | return ''.join(packed) |
| 3176 | |
| 3177 | @staticmethod |
| 3178 | def unpack(buf): |
| 3179 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3180 | obj = bsn_pdu_tx_request() |
| 3181 | if type(buf) == loxi.generic_util.OFReader: |
| 3182 | reader = buf |
| 3183 | else: |
| 3184 | reader = loxi.generic_util.OFReader(buf) |
| 3185 | _version = reader.read("!B")[0] |
| 3186 | assert(_version == 4) |
| 3187 | _type = reader.read("!B")[0] |
| 3188 | assert(_type == 4) |
| 3189 | _length = reader.read("!H")[0] |
| 3190 | obj.xid = reader.read("!L")[0] |
| 3191 | _experimenter = reader.read("!L")[0] |
| 3192 | assert(_experimenter == 6035143) |
| 3193 | _subtype = reader.read("!L")[0] |
| 3194 | assert(_subtype == 31) |
| 3195 | obj.tx_interval_ms = reader.read("!L")[0] |
| 3196 | obj.port_no = util.unpack_port_no(reader) |
| 3197 | obj.slot_num = reader.read("!B")[0] |
| 3198 | reader.skip(3) |
| 3199 | obj.data = str(reader.read_all()) |
| 3200 | return obj |
| 3201 | |
| 3202 | def __eq__(self, other): |
| 3203 | if type(self) != type(other): return False |
| 3204 | if self.version != other.version: return False |
| 3205 | if self.type != other.type: return False |
| 3206 | if self.xid != other.xid: return False |
| 3207 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 3208 | if self.port_no != other.port_no: return False |
| 3209 | if self.slot_num != other.slot_num: return False |
| 3210 | if self.data != other.data: return False |
| 3211 | return True |
| 3212 | |
| 3213 | def __ne__(self, other): |
| 3214 | return not self.__eq__(other) |
| 3215 | |
| 3216 | def __str__(self): |
| 3217 | return self.show() |
| 3218 | |
| 3219 | def show(self): |
| 3220 | import loxi.pp |
| 3221 | return loxi.pp.pp(self) |
| 3222 | |
| 3223 | def pretty_print(self, q): |
| 3224 | q.text("bsn_pdu_tx_request {") |
| 3225 | with q.group(): |
| 3226 | with q.indent(2): |
| 3227 | q.breakable() |
| 3228 | q.text("xid = "); |
| 3229 | if self.xid != None: |
| 3230 | q.text("%#x" % self.xid) |
| 3231 | else: |
| 3232 | q.text('None') |
| 3233 | q.text(","); q.breakable() |
| 3234 | q.text("tx_interval_ms = "); |
| 3235 | q.text("%#x" % self.tx_interval_ms) |
| 3236 | q.text(","); q.breakable() |
| 3237 | q.text("port_no = "); |
| 3238 | q.text(util.pretty_port(self.port_no)) |
| 3239 | q.text(","); q.breakable() |
| 3240 | q.text("slot_num = "); |
| 3241 | q.text("%#x" % self.slot_num) |
| 3242 | q.text(","); q.breakable() |
| 3243 | q.text("data = "); |
| 3244 | q.pp(self.data) |
| 3245 | q.breakable() |
| 3246 | q.text('}') |
| 3247 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3248 | class bsn_set_lacp_reply(Message): |
| 3249 | version = 4 |
| 3250 | type = 4 |
| 3251 | experimenter = 6035143 |
| 3252 | subtype = 42 |
| 3253 | |
| 3254 | def __init__(self, xid=None, status=None, port_no=None): |
| 3255 | self.xid = xid |
| 3256 | if status != None: |
| 3257 | self.status = status |
| 3258 | else: |
| 3259 | self.status = 0 |
| 3260 | if port_no != None: |
| 3261 | self.port_no = port_no |
| 3262 | else: |
| 3263 | self.port_no = 0 |
| 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("!L", self.experimenter)) |
| 3272 | packed.append(struct.pack("!L", self.subtype)) |
| 3273 | packed.append(struct.pack("!L", self.status)) |
| 3274 | packed.append(util.pack_port_no(self.port_no)) |
| 3275 | length = sum([len(x) for x in packed]) |
| 3276 | packed[2] = struct.pack("!H", length) |
| 3277 | return ''.join(packed) |
| 3278 | |
| 3279 | @staticmethod |
| 3280 | def unpack(buf): |
| 3281 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3282 | obj = bsn_set_lacp_reply() |
| 3283 | if type(buf) == loxi.generic_util.OFReader: |
| 3284 | reader = buf |
| 3285 | else: |
| 3286 | reader = loxi.generic_util.OFReader(buf) |
| 3287 | _version = reader.read("!B")[0] |
| 3288 | assert(_version == 4) |
| 3289 | _type = reader.read("!B")[0] |
| 3290 | assert(_type == 4) |
| 3291 | _length = reader.read("!H")[0] |
| 3292 | obj.xid = reader.read("!L")[0] |
| 3293 | _experimenter = reader.read("!L")[0] |
| 3294 | assert(_experimenter == 6035143) |
| 3295 | _subtype = reader.read("!L")[0] |
| 3296 | assert(_subtype == 42) |
| 3297 | obj.status = reader.read("!L")[0] |
| 3298 | obj.port_no = util.unpack_port_no(reader) |
| 3299 | return obj |
| 3300 | |
| 3301 | def __eq__(self, other): |
| 3302 | if type(self) != type(other): return False |
| 3303 | if self.version != other.version: return False |
| 3304 | if self.type != other.type: return False |
| 3305 | if self.xid != other.xid: return False |
| 3306 | if self.status != other.status: return False |
| 3307 | if self.port_no != other.port_no: return False |
| 3308 | return True |
| 3309 | |
| 3310 | def __ne__(self, other): |
| 3311 | return not self.__eq__(other) |
| 3312 | |
| 3313 | def __str__(self): |
| 3314 | return self.show() |
| 3315 | |
| 3316 | def show(self): |
| 3317 | import loxi.pp |
| 3318 | return loxi.pp.pp(self) |
| 3319 | |
| 3320 | def pretty_print(self, q): |
| 3321 | q.text("bsn_set_lacp_reply {") |
| 3322 | with q.group(): |
| 3323 | with q.indent(2): |
| 3324 | q.breakable() |
| 3325 | q.text("xid = "); |
| 3326 | if self.xid != None: |
| 3327 | q.text("%#x" % self.xid) |
| 3328 | else: |
| 3329 | q.text('None') |
| 3330 | q.text(","); q.breakable() |
| 3331 | q.text("status = "); |
| 3332 | q.text("%#x" % self.status) |
| 3333 | q.text(","); q.breakable() |
| 3334 | q.text("port_no = "); |
| 3335 | q.text(util.pretty_port(self.port_no)) |
| 3336 | q.breakable() |
| 3337 | q.text('}') |
| 3338 | |
| 3339 | class bsn_set_lacp_request(Message): |
| 3340 | version = 4 |
| 3341 | type = 4 |
| 3342 | experimenter = 6035143 |
| 3343 | subtype = 41 |
| 3344 | |
| 3345 | def __init__(self, xid=None, enabled=None, port_no=None, actor_sys_priority=None, actor_sys_mac=None, actor_port_priority=None, actor_port_num=None, actor_key=None): |
| 3346 | self.xid = xid |
| 3347 | if enabled != None: |
| 3348 | self.enabled = enabled |
| 3349 | else: |
| 3350 | self.enabled = 0 |
| 3351 | if port_no != None: |
| 3352 | self.port_no = port_no |
| 3353 | else: |
| 3354 | self.port_no = 0 |
| 3355 | if actor_sys_priority != None: |
| 3356 | self.actor_sys_priority = actor_sys_priority |
| 3357 | else: |
| 3358 | self.actor_sys_priority = 0 |
| 3359 | if actor_sys_mac != None: |
| 3360 | self.actor_sys_mac = actor_sys_mac |
| 3361 | else: |
| 3362 | self.actor_sys_mac = [0,0,0,0,0,0] |
| 3363 | if actor_port_priority != None: |
| 3364 | self.actor_port_priority = actor_port_priority |
| 3365 | else: |
| 3366 | self.actor_port_priority = 0 |
| 3367 | if actor_port_num != None: |
| 3368 | self.actor_port_num = actor_port_num |
| 3369 | else: |
| 3370 | self.actor_port_num = 0 |
| 3371 | if actor_key != None: |
| 3372 | self.actor_key = actor_key |
| 3373 | else: |
| 3374 | self.actor_key = 0 |
| 3375 | |
| 3376 | def pack(self): |
| 3377 | packed = [] |
| 3378 | packed.append(struct.pack("!B", self.version)) |
| 3379 | packed.append(struct.pack("!B", self.type)) |
| 3380 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3381 | packed.append(struct.pack("!L", self.xid)) |
| 3382 | packed.append(struct.pack("!L", self.experimenter)) |
| 3383 | packed.append(struct.pack("!L", self.subtype)) |
| 3384 | packed.append(struct.pack("!B", self.enabled)) |
| 3385 | packed.append('\x00' * 3) |
| 3386 | packed.append(util.pack_port_no(self.port_no)) |
| 3387 | packed.append(struct.pack("!H", self.actor_sys_priority)) |
| 3388 | packed.append(struct.pack("!6B", *self.actor_sys_mac)) |
| 3389 | packed.append(struct.pack("!H", self.actor_port_priority)) |
| 3390 | packed.append(struct.pack("!H", self.actor_port_num)) |
| 3391 | packed.append(struct.pack("!H", self.actor_key)) |
| 3392 | length = sum([len(x) for x in packed]) |
| 3393 | packed[2] = struct.pack("!H", length) |
| 3394 | return ''.join(packed) |
| 3395 | |
| 3396 | @staticmethod |
| 3397 | def unpack(buf): |
| 3398 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3399 | obj = bsn_set_lacp_request() |
| 3400 | if type(buf) == loxi.generic_util.OFReader: |
| 3401 | reader = buf |
| 3402 | else: |
| 3403 | reader = loxi.generic_util.OFReader(buf) |
| 3404 | _version = reader.read("!B")[0] |
| 3405 | assert(_version == 4) |
| 3406 | _type = reader.read("!B")[0] |
| 3407 | assert(_type == 4) |
| 3408 | _length = reader.read("!H")[0] |
| 3409 | obj.xid = reader.read("!L")[0] |
| 3410 | _experimenter = reader.read("!L")[0] |
| 3411 | assert(_experimenter == 6035143) |
| 3412 | _subtype = reader.read("!L")[0] |
| 3413 | assert(_subtype == 41) |
| 3414 | obj.enabled = reader.read("!B")[0] |
| 3415 | reader.skip(3) |
| 3416 | obj.port_no = util.unpack_port_no(reader) |
| 3417 | obj.actor_sys_priority = reader.read("!H")[0] |
| 3418 | obj.actor_sys_mac = list(reader.read('!6B')) |
| 3419 | obj.actor_port_priority = reader.read("!H")[0] |
| 3420 | obj.actor_port_num = reader.read("!H")[0] |
| 3421 | obj.actor_key = reader.read("!H")[0] |
| 3422 | return obj |
| 3423 | |
| 3424 | def __eq__(self, other): |
| 3425 | if type(self) != type(other): return False |
| 3426 | if self.version != other.version: return False |
| 3427 | if self.type != other.type: return False |
| 3428 | if self.xid != other.xid: return False |
| 3429 | if self.enabled != other.enabled: return False |
| 3430 | if self.port_no != other.port_no: return False |
| 3431 | if self.actor_sys_priority != other.actor_sys_priority: return False |
| 3432 | if self.actor_sys_mac != other.actor_sys_mac: return False |
| 3433 | if self.actor_port_priority != other.actor_port_priority: return False |
| 3434 | if self.actor_port_num != other.actor_port_num: return False |
| 3435 | if self.actor_key != other.actor_key: return False |
| 3436 | return True |
| 3437 | |
| 3438 | def __ne__(self, other): |
| 3439 | return not self.__eq__(other) |
| 3440 | |
| 3441 | def __str__(self): |
| 3442 | return self.show() |
| 3443 | |
| 3444 | def show(self): |
| 3445 | import loxi.pp |
| 3446 | return loxi.pp.pp(self) |
| 3447 | |
| 3448 | def pretty_print(self, q): |
| 3449 | q.text("bsn_set_lacp_request {") |
| 3450 | with q.group(): |
| 3451 | with q.indent(2): |
| 3452 | q.breakable() |
| 3453 | q.text("xid = "); |
| 3454 | if self.xid != None: |
| 3455 | q.text("%#x" % self.xid) |
| 3456 | else: |
| 3457 | q.text('None') |
| 3458 | q.text(","); q.breakable() |
| 3459 | q.text("enabled = "); |
| 3460 | q.text("%#x" % self.enabled) |
| 3461 | q.text(","); q.breakable() |
| 3462 | q.text("port_no = "); |
| 3463 | q.text(util.pretty_port(self.port_no)) |
| 3464 | q.text(","); q.breakable() |
| 3465 | q.text("actor_sys_priority = "); |
| 3466 | q.text("%#x" % self.actor_sys_priority) |
| 3467 | q.text(","); q.breakable() |
| 3468 | q.text("actor_sys_mac = "); |
| 3469 | q.text(util.pretty_mac(self.actor_sys_mac)) |
| 3470 | q.text(","); q.breakable() |
| 3471 | q.text("actor_port_priority = "); |
| 3472 | q.text("%#x" % self.actor_port_priority) |
| 3473 | q.text(","); q.breakable() |
| 3474 | q.text("actor_port_num = "); |
| 3475 | q.text("%#x" % self.actor_port_num) |
| 3476 | q.text(","); q.breakable() |
| 3477 | q.text("actor_key = "); |
| 3478 | q.text("%#x" % self.actor_key) |
| 3479 | q.breakable() |
| 3480 | q.text('}') |
| 3481 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3482 | class bsn_set_mirroring(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3483 | version = 4 |
| 3484 | type = 4 |
| 3485 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3486 | subtype = 3 |
| 3487 | |
| 3488 | def __init__(self, xid=None, report_mirror_ports=None): |
| 3489 | self.xid = xid |
| 3490 | if report_mirror_ports != None: |
| 3491 | self.report_mirror_ports = report_mirror_ports |
| 3492 | else: |
| 3493 | self.report_mirror_ports = 0 |
| 3494 | |
| 3495 | def pack(self): |
| 3496 | packed = [] |
| 3497 | packed.append(struct.pack("!B", self.version)) |
| 3498 | packed.append(struct.pack("!B", self.type)) |
| 3499 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3500 | packed.append(struct.pack("!L", self.xid)) |
| 3501 | packed.append(struct.pack("!L", self.experimenter)) |
| 3502 | packed.append(struct.pack("!L", self.subtype)) |
| 3503 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 3504 | packed.append('\x00' * 3) |
| 3505 | length = sum([len(x) for x in packed]) |
| 3506 | packed[2] = struct.pack("!H", length) |
| 3507 | return ''.join(packed) |
| 3508 | |
| 3509 | @staticmethod |
| 3510 | def unpack(buf): |
| 3511 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3512 | obj = bsn_set_mirroring() |
| 3513 | if type(buf) == loxi.generic_util.OFReader: |
| 3514 | reader = buf |
| 3515 | else: |
| 3516 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3517 | _version = reader.read("!B")[0] |
| 3518 | assert(_version == 4) |
| 3519 | _type = reader.read("!B")[0] |
| 3520 | assert(_type == 4) |
| 3521 | _length = reader.read("!H")[0] |
| 3522 | obj.xid = reader.read("!L")[0] |
| 3523 | _experimenter = reader.read("!L")[0] |
| 3524 | assert(_experimenter == 6035143) |
| 3525 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3526 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3527 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3528 | reader.skip(3) |
| 3529 | return obj |
| 3530 | |
| 3531 | def __eq__(self, other): |
| 3532 | if type(self) != type(other): return False |
| 3533 | if self.version != other.version: return False |
| 3534 | if self.type != other.type: return False |
| 3535 | if self.xid != other.xid: return False |
| 3536 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 3537 | return True |
| 3538 | |
| 3539 | def __ne__(self, other): |
| 3540 | return not self.__eq__(other) |
| 3541 | |
| 3542 | def __str__(self): |
| 3543 | return self.show() |
| 3544 | |
| 3545 | def show(self): |
| 3546 | import loxi.pp |
| 3547 | return loxi.pp.pp(self) |
| 3548 | |
| 3549 | def pretty_print(self, q): |
| 3550 | q.text("bsn_set_mirroring {") |
| 3551 | with q.group(): |
| 3552 | with q.indent(2): |
| 3553 | q.breakable() |
| 3554 | q.text("xid = "); |
| 3555 | if self.xid != None: |
| 3556 | q.text("%#x" % self.xid) |
| 3557 | else: |
| 3558 | q.text('None') |
| 3559 | q.text(","); q.breakable() |
| 3560 | q.text("report_mirror_ports = "); |
| 3561 | q.text("%#x" % self.report_mirror_ports) |
| 3562 | q.breakable() |
| 3563 | q.text('}') |
| 3564 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3565 | class bsn_set_pktin_suppression_reply(Message): |
| 3566 | version = 4 |
| 3567 | type = 4 |
| 3568 | experimenter = 6035143 |
| 3569 | subtype = 25 |
| 3570 | |
| 3571 | def __init__(self, xid=None, status=None): |
| 3572 | self.xid = xid |
| 3573 | if status != None: |
| 3574 | self.status = status |
| 3575 | else: |
| 3576 | self.status = 0 |
| 3577 | |
| 3578 | def pack(self): |
| 3579 | packed = [] |
| 3580 | packed.append(struct.pack("!B", self.version)) |
| 3581 | packed.append(struct.pack("!B", self.type)) |
| 3582 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3583 | packed.append(struct.pack("!L", self.xid)) |
| 3584 | packed.append(struct.pack("!L", self.experimenter)) |
| 3585 | packed.append(struct.pack("!L", self.subtype)) |
| 3586 | packed.append(struct.pack("!L", self.status)) |
| 3587 | length = sum([len(x) for x in packed]) |
| 3588 | packed[2] = struct.pack("!H", length) |
| 3589 | return ''.join(packed) |
| 3590 | |
| 3591 | @staticmethod |
| 3592 | def unpack(buf): |
| 3593 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3594 | obj = bsn_set_pktin_suppression_reply() |
| 3595 | if type(buf) == loxi.generic_util.OFReader: |
| 3596 | reader = buf |
| 3597 | else: |
| 3598 | reader = loxi.generic_util.OFReader(buf) |
| 3599 | _version = reader.read("!B")[0] |
| 3600 | assert(_version == 4) |
| 3601 | _type = reader.read("!B")[0] |
| 3602 | assert(_type == 4) |
| 3603 | _length = reader.read("!H")[0] |
| 3604 | obj.xid = reader.read("!L")[0] |
| 3605 | _experimenter = reader.read("!L")[0] |
| 3606 | assert(_experimenter == 6035143) |
| 3607 | _subtype = reader.read("!L")[0] |
| 3608 | assert(_subtype == 25) |
| 3609 | obj.status = reader.read("!L")[0] |
| 3610 | return obj |
| 3611 | |
| 3612 | def __eq__(self, other): |
| 3613 | if type(self) != type(other): return False |
| 3614 | if self.version != other.version: return False |
| 3615 | if self.type != other.type: return False |
| 3616 | if self.xid != other.xid: return False |
| 3617 | if self.status != other.status: return False |
| 3618 | return True |
| 3619 | |
| 3620 | def __ne__(self, other): |
| 3621 | return not self.__eq__(other) |
| 3622 | |
| 3623 | def __str__(self): |
| 3624 | return self.show() |
| 3625 | |
| 3626 | def show(self): |
| 3627 | import loxi.pp |
| 3628 | return loxi.pp.pp(self) |
| 3629 | |
| 3630 | def pretty_print(self, q): |
| 3631 | q.text("bsn_set_pktin_suppression_reply {") |
| 3632 | with q.group(): |
| 3633 | with q.indent(2): |
| 3634 | q.breakable() |
| 3635 | q.text("xid = "); |
| 3636 | if self.xid != None: |
| 3637 | q.text("%#x" % self.xid) |
| 3638 | else: |
| 3639 | q.text('None') |
| 3640 | q.text(","); q.breakable() |
| 3641 | q.text("status = "); |
| 3642 | q.text("%#x" % self.status) |
| 3643 | q.breakable() |
| 3644 | q.text('}') |
| 3645 | |
| 3646 | class bsn_set_pktin_suppression_request(Message): |
| 3647 | version = 4 |
| 3648 | type = 4 |
| 3649 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3650 | subtype = 11 |
| 3651 | |
| 3652 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
| 3653 | self.xid = xid |
| 3654 | if enabled != None: |
| 3655 | self.enabled = enabled |
| 3656 | else: |
| 3657 | self.enabled = 0 |
| 3658 | if idle_timeout != None: |
| 3659 | self.idle_timeout = idle_timeout |
| 3660 | else: |
| 3661 | self.idle_timeout = 0 |
| 3662 | if hard_timeout != None: |
| 3663 | self.hard_timeout = hard_timeout |
| 3664 | else: |
| 3665 | self.hard_timeout = 0 |
| 3666 | if priority != None: |
| 3667 | self.priority = priority |
| 3668 | else: |
| 3669 | self.priority = 0 |
| 3670 | if cookie != None: |
| 3671 | self.cookie = cookie |
| 3672 | else: |
| 3673 | self.cookie = 0 |
| 3674 | |
| 3675 | def pack(self): |
| 3676 | packed = [] |
| 3677 | packed.append(struct.pack("!B", self.version)) |
| 3678 | packed.append(struct.pack("!B", self.type)) |
| 3679 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3680 | packed.append(struct.pack("!L", self.xid)) |
| 3681 | packed.append(struct.pack("!L", self.experimenter)) |
| 3682 | packed.append(struct.pack("!L", self.subtype)) |
| 3683 | packed.append(struct.pack("!B", self.enabled)) |
| 3684 | packed.append('\x00' * 1) |
| 3685 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3686 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3687 | packed.append(struct.pack("!H", self.priority)) |
| 3688 | packed.append(struct.pack("!Q", self.cookie)) |
| 3689 | length = sum([len(x) for x in packed]) |
| 3690 | packed[2] = struct.pack("!H", length) |
| 3691 | return ''.join(packed) |
| 3692 | |
| 3693 | @staticmethod |
| 3694 | def unpack(buf): |
| 3695 | 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] | 3696 | obj = bsn_set_pktin_suppression_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3697 | if type(buf) == loxi.generic_util.OFReader: |
| 3698 | reader = buf |
| 3699 | else: |
| 3700 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3701 | _version = reader.read("!B")[0] |
| 3702 | assert(_version == 4) |
| 3703 | _type = reader.read("!B")[0] |
| 3704 | assert(_type == 4) |
| 3705 | _length = reader.read("!H")[0] |
| 3706 | obj.xid = reader.read("!L")[0] |
| 3707 | _experimenter = reader.read("!L")[0] |
| 3708 | assert(_experimenter == 6035143) |
| 3709 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3710 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3711 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3712 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3713 | obj.idle_timeout = reader.read("!H")[0] |
| 3714 | obj.hard_timeout = reader.read("!H")[0] |
| 3715 | obj.priority = reader.read("!H")[0] |
| 3716 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3717 | return obj |
| 3718 | |
| 3719 | def __eq__(self, other): |
| 3720 | if type(self) != type(other): return False |
| 3721 | if self.version != other.version: return False |
| 3722 | if self.type != other.type: return False |
| 3723 | if self.xid != other.xid: return False |
| 3724 | if self.enabled != other.enabled: return False |
| 3725 | if self.idle_timeout != other.idle_timeout: return False |
| 3726 | if self.hard_timeout != other.hard_timeout: return False |
| 3727 | if self.priority != other.priority: return False |
| 3728 | if self.cookie != other.cookie: return False |
| 3729 | return True |
| 3730 | |
| 3731 | def __ne__(self, other): |
| 3732 | return not self.__eq__(other) |
| 3733 | |
| 3734 | def __str__(self): |
| 3735 | return self.show() |
| 3736 | |
| 3737 | def show(self): |
| 3738 | import loxi.pp |
| 3739 | return loxi.pp.pp(self) |
| 3740 | |
| 3741 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3742 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3743 | with q.group(): |
| 3744 | with q.indent(2): |
| 3745 | q.breakable() |
| 3746 | q.text("xid = "); |
| 3747 | if self.xid != None: |
| 3748 | q.text("%#x" % self.xid) |
| 3749 | else: |
| 3750 | q.text('None') |
| 3751 | q.text(","); q.breakable() |
| 3752 | q.text("enabled = "); |
| 3753 | q.text("%#x" % self.enabled) |
| 3754 | q.text(","); q.breakable() |
| 3755 | q.text("idle_timeout = "); |
| 3756 | q.text("%#x" % self.idle_timeout) |
| 3757 | q.text(","); q.breakable() |
| 3758 | q.text("hard_timeout = "); |
| 3759 | q.text("%#x" % self.hard_timeout) |
| 3760 | q.text(","); q.breakable() |
| 3761 | q.text("priority = "); |
| 3762 | q.text("%#x" % self.priority) |
| 3763 | q.text(","); q.breakable() |
| 3764 | q.text("cookie = "); |
| 3765 | q.text("%#x" % self.cookie) |
| 3766 | q.breakable() |
| 3767 | q.text('}') |
| 3768 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 3769 | class bsn_time_reply(Message): |
| 3770 | version = 4 |
| 3771 | type = 4 |
| 3772 | experimenter = 6035143 |
| 3773 | subtype = 45 |
| 3774 | |
| 3775 | def __init__(self, xid=None, time_ms=None): |
| 3776 | self.xid = xid |
| 3777 | if time_ms != None: |
| 3778 | self.time_ms = time_ms |
| 3779 | else: |
| 3780 | self.time_ms = 0 |
| 3781 | |
| 3782 | def pack(self): |
| 3783 | packed = [] |
| 3784 | packed.append(struct.pack("!B", self.version)) |
| 3785 | packed.append(struct.pack("!B", self.type)) |
| 3786 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3787 | packed.append(struct.pack("!L", self.xid)) |
| 3788 | packed.append(struct.pack("!L", self.experimenter)) |
| 3789 | packed.append(struct.pack("!L", self.subtype)) |
| 3790 | packed.append(struct.pack("!Q", self.time_ms)) |
| 3791 | length = sum([len(x) for x in packed]) |
| 3792 | packed[2] = struct.pack("!H", length) |
| 3793 | return ''.join(packed) |
| 3794 | |
| 3795 | @staticmethod |
| 3796 | def unpack(buf): |
| 3797 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3798 | obj = bsn_time_reply() |
| 3799 | if type(buf) == loxi.generic_util.OFReader: |
| 3800 | reader = buf |
| 3801 | else: |
| 3802 | reader = loxi.generic_util.OFReader(buf) |
| 3803 | _version = reader.read("!B")[0] |
| 3804 | assert(_version == 4) |
| 3805 | _type = reader.read("!B")[0] |
| 3806 | assert(_type == 4) |
| 3807 | _length = reader.read("!H")[0] |
| 3808 | obj.xid = reader.read("!L")[0] |
| 3809 | _experimenter = reader.read("!L")[0] |
| 3810 | assert(_experimenter == 6035143) |
| 3811 | _subtype = reader.read("!L")[0] |
| 3812 | assert(_subtype == 45) |
| 3813 | obj.time_ms = reader.read("!Q")[0] |
| 3814 | return obj |
| 3815 | |
| 3816 | def __eq__(self, other): |
| 3817 | if type(self) != type(other): return False |
| 3818 | if self.version != other.version: return False |
| 3819 | if self.type != other.type: return False |
| 3820 | if self.xid != other.xid: return False |
| 3821 | if self.time_ms != other.time_ms: return False |
| 3822 | return True |
| 3823 | |
| 3824 | def __ne__(self, other): |
| 3825 | return not self.__eq__(other) |
| 3826 | |
| 3827 | def __str__(self): |
| 3828 | return self.show() |
| 3829 | |
| 3830 | def show(self): |
| 3831 | import loxi.pp |
| 3832 | return loxi.pp.pp(self) |
| 3833 | |
| 3834 | def pretty_print(self, q): |
| 3835 | q.text("bsn_time_reply {") |
| 3836 | with q.group(): |
| 3837 | with q.indent(2): |
| 3838 | q.breakable() |
| 3839 | q.text("xid = "); |
| 3840 | if self.xid != None: |
| 3841 | q.text("%#x" % self.xid) |
| 3842 | else: |
| 3843 | q.text('None') |
| 3844 | q.text(","); q.breakable() |
| 3845 | q.text("time_ms = "); |
| 3846 | q.text("%#x" % self.time_ms) |
| 3847 | q.breakable() |
| 3848 | q.text('}') |
| 3849 | |
| 3850 | class bsn_time_request(Message): |
| 3851 | version = 4 |
| 3852 | type = 4 |
| 3853 | experimenter = 6035143 |
| 3854 | subtype = 44 |
| 3855 | |
| 3856 | def __init__(self, xid=None): |
| 3857 | self.xid = xid |
| 3858 | |
| 3859 | def pack(self): |
| 3860 | packed = [] |
| 3861 | packed.append(struct.pack("!B", self.version)) |
| 3862 | packed.append(struct.pack("!B", self.type)) |
| 3863 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3864 | packed.append(struct.pack("!L", self.xid)) |
| 3865 | packed.append(struct.pack("!L", self.experimenter)) |
| 3866 | packed.append(struct.pack("!L", self.subtype)) |
| 3867 | length = sum([len(x) for x in packed]) |
| 3868 | packed[2] = struct.pack("!H", length) |
| 3869 | return ''.join(packed) |
| 3870 | |
| 3871 | @staticmethod |
| 3872 | def unpack(buf): |
| 3873 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3874 | obj = bsn_time_request() |
| 3875 | if type(buf) == loxi.generic_util.OFReader: |
| 3876 | reader = buf |
| 3877 | else: |
| 3878 | reader = loxi.generic_util.OFReader(buf) |
| 3879 | _version = reader.read("!B")[0] |
| 3880 | assert(_version == 4) |
| 3881 | _type = reader.read("!B")[0] |
| 3882 | assert(_type == 4) |
| 3883 | _length = reader.read("!H")[0] |
| 3884 | obj.xid = reader.read("!L")[0] |
| 3885 | _experimenter = reader.read("!L")[0] |
| 3886 | assert(_experimenter == 6035143) |
| 3887 | _subtype = reader.read("!L")[0] |
| 3888 | assert(_subtype == 44) |
| 3889 | return obj |
| 3890 | |
| 3891 | def __eq__(self, other): |
| 3892 | if type(self) != type(other): return False |
| 3893 | if self.version != other.version: return False |
| 3894 | if self.type != other.type: return False |
| 3895 | if self.xid != other.xid: return False |
| 3896 | return True |
| 3897 | |
| 3898 | def __ne__(self, other): |
| 3899 | return not self.__eq__(other) |
| 3900 | |
| 3901 | def __str__(self): |
| 3902 | return self.show() |
| 3903 | |
| 3904 | def show(self): |
| 3905 | import loxi.pp |
| 3906 | return loxi.pp.pp(self) |
| 3907 | |
| 3908 | def pretty_print(self, q): |
| 3909 | q.text("bsn_time_request {") |
| 3910 | with q.group(): |
| 3911 | with q.indent(2): |
| 3912 | q.breakable() |
| 3913 | q.text("xid = "); |
| 3914 | if self.xid != None: |
| 3915 | q.text("%#x" % self.xid) |
| 3916 | else: |
| 3917 | q.text('None') |
| 3918 | q.breakable() |
| 3919 | q.text('}') |
| 3920 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3921 | class bsn_virtual_port_create_reply(Message): |
| 3922 | version = 4 |
| 3923 | type = 4 |
| 3924 | experimenter = 6035143 |
| 3925 | subtype = 16 |
| 3926 | |
| 3927 | def __init__(self, xid=None, status=None, vport_no=None): |
| 3928 | self.xid = xid |
| 3929 | if status != None: |
| 3930 | self.status = status |
| 3931 | else: |
| 3932 | self.status = 0 |
| 3933 | if vport_no != None: |
| 3934 | self.vport_no = vport_no |
| 3935 | else: |
| 3936 | self.vport_no = 0 |
| 3937 | |
| 3938 | def pack(self): |
| 3939 | packed = [] |
| 3940 | packed.append(struct.pack("!B", self.version)) |
| 3941 | packed.append(struct.pack("!B", self.type)) |
| 3942 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3943 | packed.append(struct.pack("!L", self.xid)) |
| 3944 | packed.append(struct.pack("!L", self.experimenter)) |
| 3945 | packed.append(struct.pack("!L", self.subtype)) |
| 3946 | packed.append(struct.pack("!L", self.status)) |
| 3947 | packed.append(struct.pack("!L", self.vport_no)) |
| 3948 | length = sum([len(x) for x in packed]) |
| 3949 | packed[2] = struct.pack("!H", length) |
| 3950 | return ''.join(packed) |
| 3951 | |
| 3952 | @staticmethod |
| 3953 | def unpack(buf): |
| 3954 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3955 | obj = bsn_virtual_port_create_reply() |
| 3956 | if type(buf) == loxi.generic_util.OFReader: |
| 3957 | reader = buf |
| 3958 | else: |
| 3959 | reader = loxi.generic_util.OFReader(buf) |
| 3960 | _version = reader.read("!B")[0] |
| 3961 | assert(_version == 4) |
| 3962 | _type = reader.read("!B")[0] |
| 3963 | assert(_type == 4) |
| 3964 | _length = reader.read("!H")[0] |
| 3965 | obj.xid = reader.read("!L")[0] |
| 3966 | _experimenter = reader.read("!L")[0] |
| 3967 | assert(_experimenter == 6035143) |
| 3968 | _subtype = reader.read("!L")[0] |
| 3969 | assert(_subtype == 16) |
| 3970 | obj.status = reader.read("!L")[0] |
| 3971 | obj.vport_no = reader.read("!L")[0] |
| 3972 | return obj |
| 3973 | |
| 3974 | def __eq__(self, other): |
| 3975 | if type(self) != type(other): return False |
| 3976 | if self.version != other.version: return False |
| 3977 | if self.type != other.type: return False |
| 3978 | if self.xid != other.xid: return False |
| 3979 | if self.status != other.status: return False |
| 3980 | if self.vport_no != other.vport_no: return False |
| 3981 | return True |
| 3982 | |
| 3983 | def __ne__(self, other): |
| 3984 | return not self.__eq__(other) |
| 3985 | |
| 3986 | def __str__(self): |
| 3987 | return self.show() |
| 3988 | |
| 3989 | def show(self): |
| 3990 | import loxi.pp |
| 3991 | return loxi.pp.pp(self) |
| 3992 | |
| 3993 | def pretty_print(self, q): |
| 3994 | q.text("bsn_virtual_port_create_reply {") |
| 3995 | with q.group(): |
| 3996 | with q.indent(2): |
| 3997 | q.breakable() |
| 3998 | q.text("xid = "); |
| 3999 | if self.xid != None: |
| 4000 | q.text("%#x" % self.xid) |
| 4001 | else: |
| 4002 | q.text('None') |
| 4003 | q.text(","); q.breakable() |
| 4004 | q.text("status = "); |
| 4005 | q.text("%#x" % self.status) |
| 4006 | q.text(","); q.breakable() |
| 4007 | q.text("vport_no = "); |
| 4008 | q.text("%#x" % self.vport_no) |
| 4009 | q.breakable() |
| 4010 | q.text('}') |
| 4011 | |
| 4012 | class bsn_virtual_port_create_request(Message): |
| 4013 | version = 4 |
| 4014 | type = 4 |
| 4015 | experimenter = 6035143 |
| 4016 | subtype = 15 |
| 4017 | |
| 4018 | def __init__(self, xid=None, vport=None): |
| 4019 | self.xid = xid |
| 4020 | if vport != None: |
| 4021 | self.vport = vport |
| 4022 | else: |
| 4023 | self.vport = common.bsn_vport_q_in_q() |
| 4024 | |
| 4025 | def pack(self): |
| 4026 | packed = [] |
| 4027 | packed.append(struct.pack("!B", self.version)) |
| 4028 | packed.append(struct.pack("!B", self.type)) |
| 4029 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4030 | packed.append(struct.pack("!L", self.xid)) |
| 4031 | packed.append(struct.pack("!L", self.experimenter)) |
| 4032 | packed.append(struct.pack("!L", self.subtype)) |
| 4033 | packed.append(self.vport.pack()) |
| 4034 | length = sum([len(x) for x in packed]) |
| 4035 | packed[2] = struct.pack("!H", length) |
| 4036 | return ''.join(packed) |
| 4037 | |
| 4038 | @staticmethod |
| 4039 | def unpack(buf): |
| 4040 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4041 | obj = bsn_virtual_port_create_request() |
| 4042 | if type(buf) == loxi.generic_util.OFReader: |
| 4043 | reader = buf |
| 4044 | else: |
| 4045 | reader = loxi.generic_util.OFReader(buf) |
| 4046 | _version = reader.read("!B")[0] |
| 4047 | assert(_version == 4) |
| 4048 | _type = reader.read("!B")[0] |
| 4049 | assert(_type == 4) |
| 4050 | _length = reader.read("!H")[0] |
| 4051 | obj.xid = reader.read("!L")[0] |
| 4052 | _experimenter = reader.read("!L")[0] |
| 4053 | assert(_experimenter == 6035143) |
| 4054 | _subtype = reader.read("!L")[0] |
| 4055 | assert(_subtype == 15) |
| 4056 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 4057 | return obj |
| 4058 | |
| 4059 | def __eq__(self, other): |
| 4060 | if type(self) != type(other): return False |
| 4061 | if self.version != other.version: return False |
| 4062 | if self.type != other.type: return False |
| 4063 | if self.xid != other.xid: return False |
| 4064 | if self.vport != other.vport: return False |
| 4065 | return True |
| 4066 | |
| 4067 | def __ne__(self, other): |
| 4068 | return not self.__eq__(other) |
| 4069 | |
| 4070 | def __str__(self): |
| 4071 | return self.show() |
| 4072 | |
| 4073 | def show(self): |
| 4074 | import loxi.pp |
| 4075 | return loxi.pp.pp(self) |
| 4076 | |
| 4077 | def pretty_print(self, q): |
| 4078 | q.text("bsn_virtual_port_create_request {") |
| 4079 | with q.group(): |
| 4080 | with q.indent(2): |
| 4081 | q.breakable() |
| 4082 | q.text("xid = "); |
| 4083 | if self.xid != None: |
| 4084 | q.text("%#x" % self.xid) |
| 4085 | else: |
| 4086 | q.text('None') |
| 4087 | q.text(","); q.breakable() |
| 4088 | q.text("vport = "); |
| 4089 | q.pp(self.vport) |
| 4090 | q.breakable() |
| 4091 | q.text('}') |
| 4092 | |
| 4093 | class bsn_virtual_port_remove_reply(Message): |
| 4094 | version = 4 |
| 4095 | type = 4 |
| 4096 | experimenter = 6035143 |
| 4097 | subtype = 26 |
| 4098 | |
| 4099 | def __init__(self, xid=None, status=None): |
| 4100 | self.xid = xid |
| 4101 | if status != None: |
| 4102 | self.status = status |
| 4103 | else: |
| 4104 | self.status = 0 |
| 4105 | |
| 4106 | def pack(self): |
| 4107 | packed = [] |
| 4108 | packed.append(struct.pack("!B", self.version)) |
| 4109 | packed.append(struct.pack("!B", self.type)) |
| 4110 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4111 | packed.append(struct.pack("!L", self.xid)) |
| 4112 | packed.append(struct.pack("!L", self.experimenter)) |
| 4113 | packed.append(struct.pack("!L", self.subtype)) |
| 4114 | packed.append(struct.pack("!L", self.status)) |
| 4115 | length = sum([len(x) for x in packed]) |
| 4116 | packed[2] = struct.pack("!H", length) |
| 4117 | return ''.join(packed) |
| 4118 | |
| 4119 | @staticmethod |
| 4120 | def unpack(buf): |
| 4121 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4122 | obj = bsn_virtual_port_remove_reply() |
| 4123 | if type(buf) == loxi.generic_util.OFReader: |
| 4124 | reader = buf |
| 4125 | else: |
| 4126 | reader = loxi.generic_util.OFReader(buf) |
| 4127 | _version = reader.read("!B")[0] |
| 4128 | assert(_version == 4) |
| 4129 | _type = reader.read("!B")[0] |
| 4130 | assert(_type == 4) |
| 4131 | _length = reader.read("!H")[0] |
| 4132 | obj.xid = reader.read("!L")[0] |
| 4133 | _experimenter = reader.read("!L")[0] |
| 4134 | assert(_experimenter == 6035143) |
| 4135 | _subtype = reader.read("!L")[0] |
| 4136 | assert(_subtype == 26) |
| 4137 | obj.status = reader.read("!L")[0] |
| 4138 | return obj |
| 4139 | |
| 4140 | def __eq__(self, other): |
| 4141 | if type(self) != type(other): return False |
| 4142 | if self.version != other.version: return False |
| 4143 | if self.type != other.type: return False |
| 4144 | if self.xid != other.xid: return False |
| 4145 | if self.status != other.status: return False |
| 4146 | return True |
| 4147 | |
| 4148 | def __ne__(self, other): |
| 4149 | return not self.__eq__(other) |
| 4150 | |
| 4151 | def __str__(self): |
| 4152 | return self.show() |
| 4153 | |
| 4154 | def show(self): |
| 4155 | import loxi.pp |
| 4156 | return loxi.pp.pp(self) |
| 4157 | |
| 4158 | def pretty_print(self, q): |
| 4159 | q.text("bsn_virtual_port_remove_reply {") |
| 4160 | with q.group(): |
| 4161 | with q.indent(2): |
| 4162 | q.breakable() |
| 4163 | q.text("xid = "); |
| 4164 | if self.xid != None: |
| 4165 | q.text("%#x" % self.xid) |
| 4166 | else: |
| 4167 | q.text('None') |
| 4168 | q.text(","); q.breakable() |
| 4169 | q.text("status = "); |
| 4170 | q.text("%#x" % self.status) |
| 4171 | q.breakable() |
| 4172 | q.text('}') |
| 4173 | |
| 4174 | class bsn_virtual_port_remove_request(Message): |
| 4175 | version = 4 |
| 4176 | type = 4 |
| 4177 | experimenter = 6035143 |
| 4178 | subtype = 17 |
| 4179 | |
| 4180 | def __init__(self, xid=None, vport_no=None): |
| 4181 | self.xid = xid |
| 4182 | if vport_no != None: |
| 4183 | self.vport_no = vport_no |
| 4184 | else: |
| 4185 | self.vport_no = 0 |
| 4186 | |
| 4187 | def pack(self): |
| 4188 | packed = [] |
| 4189 | packed.append(struct.pack("!B", self.version)) |
| 4190 | packed.append(struct.pack("!B", self.type)) |
| 4191 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4192 | packed.append(struct.pack("!L", self.xid)) |
| 4193 | packed.append(struct.pack("!L", self.experimenter)) |
| 4194 | packed.append(struct.pack("!L", self.subtype)) |
| 4195 | packed.append(struct.pack("!L", self.vport_no)) |
| 4196 | length = sum([len(x) for x in packed]) |
| 4197 | packed[2] = struct.pack("!H", length) |
| 4198 | return ''.join(packed) |
| 4199 | |
| 4200 | @staticmethod |
| 4201 | def unpack(buf): |
| 4202 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4203 | obj = bsn_virtual_port_remove_request() |
| 4204 | if type(buf) == loxi.generic_util.OFReader: |
| 4205 | reader = buf |
| 4206 | else: |
| 4207 | reader = loxi.generic_util.OFReader(buf) |
| 4208 | _version = reader.read("!B")[0] |
| 4209 | assert(_version == 4) |
| 4210 | _type = reader.read("!B")[0] |
| 4211 | assert(_type == 4) |
| 4212 | _length = reader.read("!H")[0] |
| 4213 | obj.xid = reader.read("!L")[0] |
| 4214 | _experimenter = reader.read("!L")[0] |
| 4215 | assert(_experimenter == 6035143) |
| 4216 | _subtype = reader.read("!L")[0] |
| 4217 | assert(_subtype == 17) |
| 4218 | obj.vport_no = reader.read("!L")[0] |
| 4219 | return obj |
| 4220 | |
| 4221 | def __eq__(self, other): |
| 4222 | if type(self) != type(other): return False |
| 4223 | if self.version != other.version: return False |
| 4224 | if self.type != other.type: return False |
| 4225 | if self.xid != other.xid: return False |
| 4226 | if self.vport_no != other.vport_no: return False |
| 4227 | return True |
| 4228 | |
| 4229 | def __ne__(self, other): |
| 4230 | return not self.__eq__(other) |
| 4231 | |
| 4232 | def __str__(self): |
| 4233 | return self.show() |
| 4234 | |
| 4235 | def show(self): |
| 4236 | import loxi.pp |
| 4237 | return loxi.pp.pp(self) |
| 4238 | |
| 4239 | def pretty_print(self, q): |
| 4240 | q.text("bsn_virtual_port_remove_request {") |
| 4241 | with q.group(): |
| 4242 | with q.indent(2): |
| 4243 | q.breakable() |
| 4244 | q.text("xid = "); |
| 4245 | if self.xid != None: |
| 4246 | q.text("%#x" % self.xid) |
| 4247 | else: |
| 4248 | q.text('None') |
| 4249 | q.text(","); q.breakable() |
| 4250 | q.text("vport_no = "); |
| 4251 | q.text("%#x" % self.vport_no) |
| 4252 | q.breakable() |
| 4253 | q.text('}') |
| 4254 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4255 | class desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4256 | version = 4 |
| 4257 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4258 | stats_type = 0 |
| 4259 | |
| 4260 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
| 4261 | self.xid = xid |
| 4262 | if flags != None: |
| 4263 | self.flags = flags |
| 4264 | else: |
| 4265 | self.flags = 0 |
| 4266 | if mfr_desc != None: |
| 4267 | self.mfr_desc = mfr_desc |
| 4268 | else: |
| 4269 | self.mfr_desc = "" |
| 4270 | if hw_desc != None: |
| 4271 | self.hw_desc = hw_desc |
| 4272 | else: |
| 4273 | self.hw_desc = "" |
| 4274 | if sw_desc != None: |
| 4275 | self.sw_desc = sw_desc |
| 4276 | else: |
| 4277 | self.sw_desc = "" |
| 4278 | if serial_num != None: |
| 4279 | self.serial_num = serial_num |
| 4280 | else: |
| 4281 | self.serial_num = "" |
| 4282 | if dp_desc != None: |
| 4283 | self.dp_desc = dp_desc |
| 4284 | else: |
| 4285 | self.dp_desc = "" |
| 4286 | |
| 4287 | def pack(self): |
| 4288 | packed = [] |
| 4289 | packed.append(struct.pack("!B", self.version)) |
| 4290 | packed.append(struct.pack("!B", self.type)) |
| 4291 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4292 | packed.append(struct.pack("!L", self.xid)) |
| 4293 | packed.append(struct.pack("!H", self.stats_type)) |
| 4294 | packed.append(struct.pack("!H", self.flags)) |
| 4295 | packed.append('\x00' * 4) |
| 4296 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 4297 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 4298 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 4299 | packed.append(struct.pack("!32s", self.serial_num)) |
| 4300 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 4301 | length = sum([len(x) for x in packed]) |
| 4302 | packed[2] = struct.pack("!H", length) |
| 4303 | return ''.join(packed) |
| 4304 | |
| 4305 | @staticmethod |
| 4306 | def unpack(buf): |
| 4307 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4308 | obj = desc_stats_reply() |
| 4309 | if type(buf) == loxi.generic_util.OFReader: |
| 4310 | reader = buf |
| 4311 | else: |
| 4312 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4313 | _version = reader.read("!B")[0] |
| 4314 | assert(_version == 4) |
| 4315 | _type = reader.read("!B")[0] |
| 4316 | assert(_type == 19) |
| 4317 | _length = reader.read("!H")[0] |
| 4318 | obj.xid = reader.read("!L")[0] |
| 4319 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4320 | assert(_stats_type == 0) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4321 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4322 | reader.skip(4) |
| 4323 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4324 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4325 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4326 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 4327 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 4328 | return obj |
| 4329 | |
| 4330 | def __eq__(self, other): |
| 4331 | if type(self) != type(other): return False |
| 4332 | if self.version != other.version: return False |
| 4333 | if self.type != other.type: return False |
| 4334 | if self.xid != other.xid: return False |
| 4335 | if self.flags != other.flags: return False |
| 4336 | if self.mfr_desc != other.mfr_desc: return False |
| 4337 | if self.hw_desc != other.hw_desc: return False |
| 4338 | if self.sw_desc != other.sw_desc: return False |
| 4339 | if self.serial_num != other.serial_num: return False |
| 4340 | if self.dp_desc != other.dp_desc: return False |
| 4341 | return True |
| 4342 | |
| 4343 | def __ne__(self, other): |
| 4344 | return not self.__eq__(other) |
| 4345 | |
| 4346 | def __str__(self): |
| 4347 | return self.show() |
| 4348 | |
| 4349 | def show(self): |
| 4350 | import loxi.pp |
| 4351 | return loxi.pp.pp(self) |
| 4352 | |
| 4353 | def pretty_print(self, q): |
| 4354 | q.text("desc_stats_reply {") |
| 4355 | with q.group(): |
| 4356 | with q.indent(2): |
| 4357 | q.breakable() |
| 4358 | q.text("xid = "); |
| 4359 | if self.xid != None: |
| 4360 | q.text("%#x" % self.xid) |
| 4361 | else: |
| 4362 | q.text('None') |
| 4363 | q.text(","); q.breakable() |
| 4364 | q.text("flags = "); |
| 4365 | q.text("%#x" % self.flags) |
| 4366 | q.text(","); q.breakable() |
| 4367 | q.text("mfr_desc = "); |
| 4368 | q.pp(self.mfr_desc) |
| 4369 | q.text(","); q.breakable() |
| 4370 | q.text("hw_desc = "); |
| 4371 | q.pp(self.hw_desc) |
| 4372 | q.text(","); q.breakable() |
| 4373 | q.text("sw_desc = "); |
| 4374 | q.pp(self.sw_desc) |
| 4375 | q.text(","); q.breakable() |
| 4376 | q.text("serial_num = "); |
| 4377 | q.pp(self.serial_num) |
| 4378 | q.text(","); q.breakable() |
| 4379 | q.text("dp_desc = "); |
| 4380 | q.pp(self.dp_desc) |
| 4381 | q.breakable() |
| 4382 | q.text('}') |
| 4383 | |
| 4384 | class desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4385 | version = 4 |
| 4386 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4387 | stats_type = 0 |
| 4388 | |
| 4389 | def __init__(self, xid=None, flags=None): |
| 4390 | self.xid = xid |
| 4391 | if flags != None: |
| 4392 | self.flags = flags |
| 4393 | else: |
| 4394 | self.flags = 0 |
| 4395 | |
| 4396 | def pack(self): |
| 4397 | packed = [] |
| 4398 | packed.append(struct.pack("!B", self.version)) |
| 4399 | packed.append(struct.pack("!B", self.type)) |
| 4400 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4401 | packed.append(struct.pack("!L", self.xid)) |
| 4402 | packed.append(struct.pack("!H", self.stats_type)) |
| 4403 | packed.append(struct.pack("!H", self.flags)) |
| 4404 | packed.append('\x00' * 4) |
| 4405 | length = sum([len(x) for x in packed]) |
| 4406 | packed[2] = struct.pack("!H", length) |
| 4407 | return ''.join(packed) |
| 4408 | |
| 4409 | @staticmethod |
| 4410 | def unpack(buf): |
| 4411 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4412 | obj = desc_stats_request() |
| 4413 | if type(buf) == loxi.generic_util.OFReader: |
| 4414 | reader = buf |
| 4415 | else: |
| 4416 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4417 | _version = reader.read("!B")[0] |
| 4418 | assert(_version == 4) |
| 4419 | _type = reader.read("!B")[0] |
| 4420 | assert(_type == 18) |
| 4421 | _length = reader.read("!H")[0] |
| 4422 | obj.xid = reader.read("!L")[0] |
| 4423 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4424 | assert(_stats_type == 0) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4425 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4426 | reader.skip(4) |
| 4427 | return obj |
| 4428 | |
| 4429 | def __eq__(self, other): |
| 4430 | if type(self) != type(other): return False |
| 4431 | if self.version != other.version: return False |
| 4432 | if self.type != other.type: return False |
| 4433 | if self.xid != other.xid: return False |
| 4434 | if self.flags != other.flags: return False |
| 4435 | return True |
| 4436 | |
| 4437 | def __ne__(self, other): |
| 4438 | return not self.__eq__(other) |
| 4439 | |
| 4440 | def __str__(self): |
| 4441 | return self.show() |
| 4442 | |
| 4443 | def show(self): |
| 4444 | import loxi.pp |
| 4445 | return loxi.pp.pp(self) |
| 4446 | |
| 4447 | def pretty_print(self, q): |
| 4448 | q.text("desc_stats_request {") |
| 4449 | with q.group(): |
| 4450 | with q.indent(2): |
| 4451 | q.breakable() |
| 4452 | q.text("xid = "); |
| 4453 | if self.xid != None: |
| 4454 | q.text("%#x" % self.xid) |
| 4455 | else: |
| 4456 | q.text('None') |
| 4457 | q.text(","); q.breakable() |
| 4458 | q.text("flags = "); |
| 4459 | q.text("%#x" % self.flags) |
| 4460 | q.breakable() |
| 4461 | q.text('}') |
| 4462 | |
| 4463 | class echo_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4464 | version = 4 |
| 4465 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4466 | |
| 4467 | def __init__(self, xid=None, data=None): |
| 4468 | self.xid = xid |
| 4469 | if data != None: |
| 4470 | self.data = data |
| 4471 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4472 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4473 | |
| 4474 | def pack(self): |
| 4475 | packed = [] |
| 4476 | packed.append(struct.pack("!B", self.version)) |
| 4477 | packed.append(struct.pack("!B", self.type)) |
| 4478 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4479 | packed.append(struct.pack("!L", self.xid)) |
| 4480 | packed.append(self.data) |
| 4481 | length = sum([len(x) for x in packed]) |
| 4482 | packed[2] = struct.pack("!H", length) |
| 4483 | return ''.join(packed) |
| 4484 | |
| 4485 | @staticmethod |
| 4486 | def unpack(buf): |
| 4487 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4488 | obj = echo_reply() |
| 4489 | if type(buf) == loxi.generic_util.OFReader: |
| 4490 | reader = buf |
| 4491 | else: |
| 4492 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4493 | _version = reader.read("!B")[0] |
| 4494 | assert(_version == 4) |
| 4495 | _type = reader.read("!B")[0] |
| 4496 | assert(_type == 3) |
| 4497 | _length = reader.read("!H")[0] |
| 4498 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4499 | obj.data = str(reader.read_all()) |
| 4500 | return obj |
| 4501 | |
| 4502 | def __eq__(self, other): |
| 4503 | if type(self) != type(other): return False |
| 4504 | if self.version != other.version: return False |
| 4505 | if self.type != other.type: return False |
| 4506 | if self.xid != other.xid: return False |
| 4507 | if self.data != other.data: return False |
| 4508 | return True |
| 4509 | |
| 4510 | def __ne__(self, other): |
| 4511 | return not self.__eq__(other) |
| 4512 | |
| 4513 | def __str__(self): |
| 4514 | return self.show() |
| 4515 | |
| 4516 | def show(self): |
| 4517 | import loxi.pp |
| 4518 | return loxi.pp.pp(self) |
| 4519 | |
| 4520 | def pretty_print(self, q): |
| 4521 | q.text("echo_reply {") |
| 4522 | with q.group(): |
| 4523 | with q.indent(2): |
| 4524 | q.breakable() |
| 4525 | q.text("xid = "); |
| 4526 | if self.xid != None: |
| 4527 | q.text("%#x" % self.xid) |
| 4528 | else: |
| 4529 | q.text('None') |
| 4530 | q.text(","); q.breakable() |
| 4531 | q.text("data = "); |
| 4532 | q.pp(self.data) |
| 4533 | q.breakable() |
| 4534 | q.text('}') |
| 4535 | |
| 4536 | class echo_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4537 | version = 4 |
| 4538 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4539 | |
| 4540 | def __init__(self, xid=None, data=None): |
| 4541 | self.xid = xid |
| 4542 | if data != None: |
| 4543 | self.data = data |
| 4544 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4545 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4546 | |
| 4547 | def pack(self): |
| 4548 | packed = [] |
| 4549 | packed.append(struct.pack("!B", self.version)) |
| 4550 | packed.append(struct.pack("!B", self.type)) |
| 4551 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4552 | packed.append(struct.pack("!L", self.xid)) |
| 4553 | packed.append(self.data) |
| 4554 | length = sum([len(x) for x in packed]) |
| 4555 | packed[2] = struct.pack("!H", length) |
| 4556 | return ''.join(packed) |
| 4557 | |
| 4558 | @staticmethod |
| 4559 | def unpack(buf): |
| 4560 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4561 | obj = echo_request() |
| 4562 | if type(buf) == loxi.generic_util.OFReader: |
| 4563 | reader = buf |
| 4564 | else: |
| 4565 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4566 | _version = reader.read("!B")[0] |
| 4567 | assert(_version == 4) |
| 4568 | _type = reader.read("!B")[0] |
| 4569 | assert(_type == 2) |
| 4570 | _length = reader.read("!H")[0] |
| 4571 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4572 | obj.data = str(reader.read_all()) |
| 4573 | return obj |
| 4574 | |
| 4575 | def __eq__(self, other): |
| 4576 | if type(self) != type(other): return False |
| 4577 | if self.version != other.version: return False |
| 4578 | if self.type != other.type: return False |
| 4579 | if self.xid != other.xid: return False |
| 4580 | if self.data != other.data: return False |
| 4581 | return True |
| 4582 | |
| 4583 | def __ne__(self, other): |
| 4584 | return not self.__eq__(other) |
| 4585 | |
| 4586 | def __str__(self): |
| 4587 | return self.show() |
| 4588 | |
| 4589 | def show(self): |
| 4590 | import loxi.pp |
| 4591 | return loxi.pp.pp(self) |
| 4592 | |
| 4593 | def pretty_print(self, q): |
| 4594 | q.text("echo_request {") |
| 4595 | with q.group(): |
| 4596 | with q.indent(2): |
| 4597 | q.breakable() |
| 4598 | q.text("xid = "); |
| 4599 | if self.xid != None: |
| 4600 | q.text("%#x" % self.xid) |
| 4601 | else: |
| 4602 | q.text('None') |
| 4603 | q.text(","); q.breakable() |
| 4604 | q.text("data = "); |
| 4605 | q.pp(self.data) |
| 4606 | q.breakable() |
| 4607 | q.text('}') |
| 4608 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4609 | class experimenter_error_msg(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4610 | version = 4 |
| 4611 | type = 1 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4612 | err_type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4613 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4614 | def __init__(self, xid=None, subtype=None, experimenter=None, data=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4615 | self.xid = xid |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4616 | if subtype != None: |
| 4617 | self.subtype = subtype |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4618 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4619 | self.subtype = 0 |
| 4620 | if experimenter != None: |
| 4621 | self.experimenter = experimenter |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4622 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4623 | self.experimenter = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4624 | if data != None: |
| 4625 | self.data = data |
| 4626 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4627 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4628 | |
| 4629 | def pack(self): |
| 4630 | packed = [] |
| 4631 | packed.append(struct.pack("!B", self.version)) |
| 4632 | packed.append(struct.pack("!B", self.type)) |
| 4633 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4634 | packed.append(struct.pack("!L", self.xid)) |
| 4635 | packed.append(struct.pack("!H", self.err_type)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4636 | packed.append(struct.pack("!H", self.subtype)) |
| 4637 | packed.append(struct.pack("!L", self.experimenter)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4638 | packed.append(self.data) |
| 4639 | length = sum([len(x) for x in packed]) |
| 4640 | packed[2] = struct.pack("!H", length) |
| 4641 | return ''.join(packed) |
| 4642 | |
| 4643 | @staticmethod |
| 4644 | def unpack(buf): |
| 4645 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4646 | obj = experimenter_error_msg() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4647 | if type(buf) == loxi.generic_util.OFReader: |
| 4648 | reader = buf |
| 4649 | else: |
| 4650 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4651 | _version = reader.read("!B")[0] |
| 4652 | assert(_version == 4) |
| 4653 | _type = reader.read("!B")[0] |
| 4654 | assert(_type == 1) |
| 4655 | _length = reader.read("!H")[0] |
| 4656 | obj.xid = reader.read("!L")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4657 | _err_type = reader.read("!H")[0] |
| 4658 | assert(_err_type == 65535) |
| 4659 | obj.subtype = reader.read("!H")[0] |
| 4660 | obj.experimenter = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4661 | obj.data = str(reader.read_all()) |
| 4662 | return obj |
| 4663 | |
| 4664 | def __eq__(self, other): |
| 4665 | if type(self) != type(other): return False |
| 4666 | if self.version != other.version: return False |
| 4667 | if self.type != other.type: return False |
| 4668 | if self.xid != other.xid: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4669 | if self.subtype != other.subtype: return False |
| 4670 | if self.experimenter != other.experimenter: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4671 | if self.data != other.data: return False |
| 4672 | return True |
| 4673 | |
| 4674 | def __ne__(self, other): |
| 4675 | return not self.__eq__(other) |
| 4676 | |
| 4677 | def __str__(self): |
| 4678 | return self.show() |
| 4679 | |
| 4680 | def show(self): |
| 4681 | import loxi.pp |
| 4682 | return loxi.pp.pp(self) |
| 4683 | |
| 4684 | def pretty_print(self, q): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4685 | q.text("experimenter_error_msg {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4686 | with q.group(): |
| 4687 | with q.indent(2): |
| 4688 | q.breakable() |
| 4689 | q.text("xid = "); |
| 4690 | if self.xid != None: |
| 4691 | q.text("%#x" % self.xid) |
| 4692 | else: |
| 4693 | q.text('None') |
| 4694 | q.text(","); q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4695 | q.text("subtype = "); |
| 4696 | q.text("%#x" % self.subtype) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4697 | q.text(","); q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4698 | q.text("experimenter = "); |
| 4699 | q.text("%#x" % self.experimenter) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4700 | q.text(","); q.breakable() |
| 4701 | q.text("data = "); |
| 4702 | q.pp(self.data) |
| 4703 | q.breakable() |
| 4704 | q.text('}') |
| 4705 | |
| 4706 | class features_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4707 | version = 4 |
| 4708 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4709 | |
| 4710 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, auxiliary_id=None, capabilities=None, reserved=None): |
| 4711 | self.xid = xid |
| 4712 | if datapath_id != None: |
| 4713 | self.datapath_id = datapath_id |
| 4714 | else: |
| 4715 | self.datapath_id = 0 |
| 4716 | if n_buffers != None: |
| 4717 | self.n_buffers = n_buffers |
| 4718 | else: |
| 4719 | self.n_buffers = 0 |
| 4720 | if n_tables != None: |
| 4721 | self.n_tables = n_tables |
| 4722 | else: |
| 4723 | self.n_tables = 0 |
| 4724 | if auxiliary_id != None: |
| 4725 | self.auxiliary_id = auxiliary_id |
| 4726 | else: |
| 4727 | self.auxiliary_id = 0 |
| 4728 | if capabilities != None: |
| 4729 | self.capabilities = capabilities |
| 4730 | else: |
| 4731 | self.capabilities = 0 |
| 4732 | if reserved != None: |
| 4733 | self.reserved = reserved |
| 4734 | else: |
| 4735 | self.reserved = 0 |
| 4736 | |
| 4737 | def pack(self): |
| 4738 | packed = [] |
| 4739 | packed.append(struct.pack("!B", self.version)) |
| 4740 | packed.append(struct.pack("!B", self.type)) |
| 4741 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4742 | packed.append(struct.pack("!L", self.xid)) |
| 4743 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 4744 | packed.append(struct.pack("!L", self.n_buffers)) |
| 4745 | packed.append(struct.pack("!B", self.n_tables)) |
| 4746 | packed.append(struct.pack("!B", self.auxiliary_id)) |
| 4747 | packed.append('\x00' * 2) |
| 4748 | packed.append(struct.pack("!L", self.capabilities)) |
| 4749 | packed.append(struct.pack("!L", self.reserved)) |
| 4750 | length = sum([len(x) for x in packed]) |
| 4751 | packed[2] = struct.pack("!H", length) |
| 4752 | return ''.join(packed) |
| 4753 | |
| 4754 | @staticmethod |
| 4755 | def unpack(buf): |
| 4756 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4757 | obj = features_reply() |
| 4758 | if type(buf) == loxi.generic_util.OFReader: |
| 4759 | reader = buf |
| 4760 | else: |
| 4761 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4762 | _version = reader.read("!B")[0] |
| 4763 | assert(_version == 4) |
| 4764 | _type = reader.read("!B")[0] |
| 4765 | assert(_type == 6) |
| 4766 | _length = reader.read("!H")[0] |
| 4767 | obj.xid = reader.read("!L")[0] |
| 4768 | obj.datapath_id = reader.read("!Q")[0] |
| 4769 | obj.n_buffers = reader.read("!L")[0] |
| 4770 | obj.n_tables = reader.read("!B")[0] |
| 4771 | obj.auxiliary_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4772 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4773 | obj.capabilities = reader.read("!L")[0] |
| 4774 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4775 | return obj |
| 4776 | |
| 4777 | def __eq__(self, other): |
| 4778 | if type(self) != type(other): return False |
| 4779 | if self.version != other.version: return False |
| 4780 | if self.type != other.type: return False |
| 4781 | if self.xid != other.xid: return False |
| 4782 | if self.datapath_id != other.datapath_id: return False |
| 4783 | if self.n_buffers != other.n_buffers: return False |
| 4784 | if self.n_tables != other.n_tables: return False |
| 4785 | if self.auxiliary_id != other.auxiliary_id: return False |
| 4786 | if self.capabilities != other.capabilities: return False |
| 4787 | if self.reserved != other.reserved: return False |
| 4788 | return True |
| 4789 | |
| 4790 | def __ne__(self, other): |
| 4791 | return not self.__eq__(other) |
| 4792 | |
| 4793 | def __str__(self): |
| 4794 | return self.show() |
| 4795 | |
| 4796 | def show(self): |
| 4797 | import loxi.pp |
| 4798 | return loxi.pp.pp(self) |
| 4799 | |
| 4800 | def pretty_print(self, q): |
| 4801 | q.text("features_reply {") |
| 4802 | with q.group(): |
| 4803 | with q.indent(2): |
| 4804 | q.breakable() |
| 4805 | q.text("xid = "); |
| 4806 | if self.xid != None: |
| 4807 | q.text("%#x" % self.xid) |
| 4808 | else: |
| 4809 | q.text('None') |
| 4810 | q.text(","); q.breakable() |
| 4811 | q.text("datapath_id = "); |
| 4812 | q.text("%#x" % self.datapath_id) |
| 4813 | q.text(","); q.breakable() |
| 4814 | q.text("n_buffers = "); |
| 4815 | q.text("%#x" % self.n_buffers) |
| 4816 | q.text(","); q.breakable() |
| 4817 | q.text("n_tables = "); |
| 4818 | q.text("%#x" % self.n_tables) |
| 4819 | q.text(","); q.breakable() |
| 4820 | q.text("auxiliary_id = "); |
| 4821 | q.text("%#x" % self.auxiliary_id) |
| 4822 | q.text(","); q.breakable() |
| 4823 | q.text("capabilities = "); |
| 4824 | q.text("%#x" % self.capabilities) |
| 4825 | q.text(","); q.breakable() |
| 4826 | q.text("reserved = "); |
| 4827 | q.text("%#x" % self.reserved) |
| 4828 | q.breakable() |
| 4829 | q.text('}') |
| 4830 | |
| 4831 | class features_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4832 | version = 4 |
| 4833 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4834 | |
| 4835 | def __init__(self, xid=None): |
| 4836 | self.xid = xid |
| 4837 | |
| 4838 | def pack(self): |
| 4839 | packed = [] |
| 4840 | packed.append(struct.pack("!B", self.version)) |
| 4841 | packed.append(struct.pack("!B", self.type)) |
| 4842 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4843 | packed.append(struct.pack("!L", self.xid)) |
| 4844 | length = sum([len(x) for x in packed]) |
| 4845 | packed[2] = struct.pack("!H", length) |
| 4846 | return ''.join(packed) |
| 4847 | |
| 4848 | @staticmethod |
| 4849 | def unpack(buf): |
| 4850 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4851 | obj = features_request() |
| 4852 | if type(buf) == loxi.generic_util.OFReader: |
| 4853 | reader = buf |
| 4854 | else: |
| 4855 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4856 | _version = reader.read("!B")[0] |
| 4857 | assert(_version == 4) |
| 4858 | _type = reader.read("!B")[0] |
| 4859 | assert(_type == 5) |
| 4860 | _length = reader.read("!H")[0] |
| 4861 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4862 | return obj |
| 4863 | |
| 4864 | def __eq__(self, other): |
| 4865 | if type(self) != type(other): return False |
| 4866 | if self.version != other.version: return False |
| 4867 | if self.type != other.type: return False |
| 4868 | if self.xid != other.xid: return False |
| 4869 | return True |
| 4870 | |
| 4871 | def __ne__(self, other): |
| 4872 | return not self.__eq__(other) |
| 4873 | |
| 4874 | def __str__(self): |
| 4875 | return self.show() |
| 4876 | |
| 4877 | def show(self): |
| 4878 | import loxi.pp |
| 4879 | return loxi.pp.pp(self) |
| 4880 | |
| 4881 | def pretty_print(self, q): |
| 4882 | q.text("features_request {") |
| 4883 | with q.group(): |
| 4884 | with q.indent(2): |
| 4885 | q.breakable() |
| 4886 | q.text("xid = "); |
| 4887 | if self.xid != None: |
| 4888 | q.text("%#x" % self.xid) |
| 4889 | else: |
| 4890 | q.text('None') |
| 4891 | q.breakable() |
| 4892 | q.text('}') |
| 4893 | |
| 4894 | class flow_add(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4895 | version = 4 |
| 4896 | type = 14 |
| 4897 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4898 | |
| 4899 | 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): |
| 4900 | self.xid = xid |
| 4901 | if cookie != None: |
| 4902 | self.cookie = cookie |
| 4903 | else: |
| 4904 | self.cookie = 0 |
| 4905 | if cookie_mask != None: |
| 4906 | self.cookie_mask = cookie_mask |
| 4907 | else: |
| 4908 | self.cookie_mask = 0 |
| 4909 | if table_id != None: |
| 4910 | self.table_id = table_id |
| 4911 | else: |
| 4912 | self.table_id = 0 |
| 4913 | if idle_timeout != None: |
| 4914 | self.idle_timeout = idle_timeout |
| 4915 | else: |
| 4916 | self.idle_timeout = 0 |
| 4917 | if hard_timeout != None: |
| 4918 | self.hard_timeout = hard_timeout |
| 4919 | else: |
| 4920 | self.hard_timeout = 0 |
| 4921 | if priority != None: |
| 4922 | self.priority = priority |
| 4923 | else: |
| 4924 | self.priority = 0 |
| 4925 | if buffer_id != None: |
| 4926 | self.buffer_id = buffer_id |
| 4927 | else: |
| 4928 | self.buffer_id = 0 |
| 4929 | if out_port != None: |
| 4930 | self.out_port = out_port |
| 4931 | else: |
| 4932 | self.out_port = 0 |
| 4933 | if out_group != None: |
| 4934 | self.out_group = out_group |
| 4935 | else: |
| 4936 | self.out_group = 0 |
| 4937 | if flags != None: |
| 4938 | self.flags = flags |
| 4939 | else: |
| 4940 | self.flags = 0 |
| 4941 | if match != None: |
| 4942 | self.match = match |
| 4943 | else: |
| 4944 | self.match = common.match() |
| 4945 | if instructions != None: |
| 4946 | self.instructions = instructions |
| 4947 | else: |
| 4948 | self.instructions = [] |
| 4949 | |
| 4950 | def pack(self): |
| 4951 | packed = [] |
| 4952 | packed.append(struct.pack("!B", self.version)) |
| 4953 | packed.append(struct.pack("!B", self.type)) |
| 4954 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4955 | packed.append(struct.pack("!L", self.xid)) |
| 4956 | packed.append(struct.pack("!Q", self.cookie)) |
| 4957 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4958 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4959 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4960 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4961 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4962 | packed.append(struct.pack("!H", self.priority)) |
| 4963 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4964 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4965 | packed.append(struct.pack("!L", self.out_group)) |
| 4966 | packed.append(struct.pack("!H", self.flags)) |
| 4967 | packed.append('\x00' * 2) |
| 4968 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4969 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4970 | length = sum([len(x) for x in packed]) |
| 4971 | packed[2] = struct.pack("!H", length) |
| 4972 | return ''.join(packed) |
| 4973 | |
| 4974 | @staticmethod |
| 4975 | def unpack(buf): |
| 4976 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4977 | obj = flow_add() |
| 4978 | if type(buf) == loxi.generic_util.OFReader: |
| 4979 | reader = buf |
| 4980 | else: |
| 4981 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4982 | _version = reader.read("!B")[0] |
| 4983 | assert(_version == 4) |
| 4984 | _type = reader.read("!B")[0] |
| 4985 | assert(_type == 14) |
| 4986 | _length = reader.read("!H")[0] |
| 4987 | obj.xid = reader.read("!L")[0] |
| 4988 | obj.cookie = reader.read("!Q")[0] |
| 4989 | obj.cookie_mask = reader.read("!Q")[0] |
| 4990 | obj.table_id = reader.read("!B")[0] |
| 4991 | __command = util.unpack_fm_cmd(reader) |
| 4992 | assert(__command == 0) |
| 4993 | obj.idle_timeout = reader.read("!H")[0] |
| 4994 | obj.hard_timeout = reader.read("!H")[0] |
| 4995 | obj.priority = reader.read("!H")[0] |
| 4996 | obj.buffer_id = reader.read("!L")[0] |
| 4997 | obj.out_port = util.unpack_port_no(reader) |
| 4998 | obj.out_group = reader.read("!L")[0] |
| 4999 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5000 | reader.skip(2) |
| 5001 | obj.match = common.match.unpack(reader) |
| 5002 | obj.instructions = instruction.unpack_list(reader) |
| 5003 | return obj |
| 5004 | |
| 5005 | def __eq__(self, other): |
| 5006 | if type(self) != type(other): return False |
| 5007 | if self.version != other.version: return False |
| 5008 | if self.type != other.type: return False |
| 5009 | if self.xid != other.xid: return False |
| 5010 | if self.cookie != other.cookie: return False |
| 5011 | if self.cookie_mask != other.cookie_mask: return False |
| 5012 | if self.table_id != other.table_id: return False |
| 5013 | if self.idle_timeout != other.idle_timeout: return False |
| 5014 | if self.hard_timeout != other.hard_timeout: return False |
| 5015 | if self.priority != other.priority: return False |
| 5016 | if self.buffer_id != other.buffer_id: return False |
| 5017 | if self.out_port != other.out_port: return False |
| 5018 | if self.out_group != other.out_group: return False |
| 5019 | if self.flags != other.flags: return False |
| 5020 | if self.match != other.match: return False |
| 5021 | if self.instructions != other.instructions: return False |
| 5022 | return True |
| 5023 | |
| 5024 | def __ne__(self, other): |
| 5025 | return not self.__eq__(other) |
| 5026 | |
| 5027 | def __str__(self): |
| 5028 | return self.show() |
| 5029 | |
| 5030 | def show(self): |
| 5031 | import loxi.pp |
| 5032 | return loxi.pp.pp(self) |
| 5033 | |
| 5034 | def pretty_print(self, q): |
| 5035 | q.text("flow_add {") |
| 5036 | with q.group(): |
| 5037 | with q.indent(2): |
| 5038 | q.breakable() |
| 5039 | q.text("xid = "); |
| 5040 | if self.xid != None: |
| 5041 | q.text("%#x" % self.xid) |
| 5042 | else: |
| 5043 | q.text('None') |
| 5044 | q.text(","); q.breakable() |
| 5045 | q.text("cookie = "); |
| 5046 | q.text("%#x" % self.cookie) |
| 5047 | q.text(","); q.breakable() |
| 5048 | q.text("cookie_mask = "); |
| 5049 | q.text("%#x" % self.cookie_mask) |
| 5050 | q.text(","); q.breakable() |
| 5051 | q.text("table_id = "); |
| 5052 | q.text("%#x" % self.table_id) |
| 5053 | q.text(","); q.breakable() |
| 5054 | q.text("idle_timeout = "); |
| 5055 | q.text("%#x" % self.idle_timeout) |
| 5056 | q.text(","); q.breakable() |
| 5057 | q.text("hard_timeout = "); |
| 5058 | q.text("%#x" % self.hard_timeout) |
| 5059 | q.text(","); q.breakable() |
| 5060 | q.text("priority = "); |
| 5061 | q.text("%#x" % self.priority) |
| 5062 | q.text(","); q.breakable() |
| 5063 | q.text("buffer_id = "); |
| 5064 | q.text("%#x" % self.buffer_id) |
| 5065 | q.text(","); q.breakable() |
| 5066 | q.text("out_port = "); |
| 5067 | q.text(util.pretty_port(self.out_port)) |
| 5068 | q.text(","); q.breakable() |
| 5069 | q.text("out_group = "); |
| 5070 | q.text("%#x" % self.out_group) |
| 5071 | q.text(","); q.breakable() |
| 5072 | q.text("flags = "); |
| 5073 | q.text("%#x" % self.flags) |
| 5074 | q.text(","); q.breakable() |
| 5075 | q.text("match = "); |
| 5076 | q.pp(self.match) |
| 5077 | q.text(","); q.breakable() |
| 5078 | q.text("instructions = "); |
| 5079 | q.pp(self.instructions) |
| 5080 | q.breakable() |
| 5081 | q.text('}') |
| 5082 | |
| 5083 | class flow_delete(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5084 | version = 4 |
| 5085 | type = 14 |
| 5086 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5087 | |
| 5088 | 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): |
| 5089 | self.xid = xid |
| 5090 | if cookie != None: |
| 5091 | self.cookie = cookie |
| 5092 | else: |
| 5093 | self.cookie = 0 |
| 5094 | if cookie_mask != None: |
| 5095 | self.cookie_mask = cookie_mask |
| 5096 | else: |
| 5097 | self.cookie_mask = 0 |
| 5098 | if table_id != None: |
| 5099 | self.table_id = table_id |
| 5100 | else: |
| 5101 | self.table_id = 0 |
| 5102 | if idle_timeout != None: |
| 5103 | self.idle_timeout = idle_timeout |
| 5104 | else: |
| 5105 | self.idle_timeout = 0 |
| 5106 | if hard_timeout != None: |
| 5107 | self.hard_timeout = hard_timeout |
| 5108 | else: |
| 5109 | self.hard_timeout = 0 |
| 5110 | if priority != None: |
| 5111 | self.priority = priority |
| 5112 | else: |
| 5113 | self.priority = 0 |
| 5114 | if buffer_id != None: |
| 5115 | self.buffer_id = buffer_id |
| 5116 | else: |
| 5117 | self.buffer_id = 0 |
| 5118 | if out_port != None: |
| 5119 | self.out_port = out_port |
| 5120 | else: |
| 5121 | self.out_port = 0 |
| 5122 | if out_group != None: |
| 5123 | self.out_group = out_group |
| 5124 | else: |
| 5125 | self.out_group = 0 |
| 5126 | if flags != None: |
| 5127 | self.flags = flags |
| 5128 | else: |
| 5129 | self.flags = 0 |
| 5130 | if match != None: |
| 5131 | self.match = match |
| 5132 | else: |
| 5133 | self.match = common.match() |
| 5134 | if instructions != None: |
| 5135 | self.instructions = instructions |
| 5136 | else: |
| 5137 | self.instructions = [] |
| 5138 | |
| 5139 | def pack(self): |
| 5140 | packed = [] |
| 5141 | packed.append(struct.pack("!B", self.version)) |
| 5142 | packed.append(struct.pack("!B", self.type)) |
| 5143 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5144 | packed.append(struct.pack("!L", self.xid)) |
| 5145 | packed.append(struct.pack("!Q", self.cookie)) |
| 5146 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5147 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5148 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5149 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5150 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5151 | packed.append(struct.pack("!H", self.priority)) |
| 5152 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5153 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5154 | packed.append(struct.pack("!L", self.out_group)) |
| 5155 | packed.append(struct.pack("!H", self.flags)) |
| 5156 | packed.append('\x00' * 2) |
| 5157 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5158 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5159 | length = sum([len(x) for x in packed]) |
| 5160 | packed[2] = struct.pack("!H", length) |
| 5161 | return ''.join(packed) |
| 5162 | |
| 5163 | @staticmethod |
| 5164 | def unpack(buf): |
| 5165 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5166 | obj = flow_delete() |
| 5167 | if type(buf) == loxi.generic_util.OFReader: |
| 5168 | reader = buf |
| 5169 | else: |
| 5170 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5171 | _version = reader.read("!B")[0] |
| 5172 | assert(_version == 4) |
| 5173 | _type = reader.read("!B")[0] |
| 5174 | assert(_type == 14) |
| 5175 | _length = reader.read("!H")[0] |
| 5176 | obj.xid = reader.read("!L")[0] |
| 5177 | obj.cookie = reader.read("!Q")[0] |
| 5178 | obj.cookie_mask = reader.read("!Q")[0] |
| 5179 | obj.table_id = reader.read("!B")[0] |
| 5180 | __command = util.unpack_fm_cmd(reader) |
| 5181 | assert(__command == 3) |
| 5182 | obj.idle_timeout = reader.read("!H")[0] |
| 5183 | obj.hard_timeout = reader.read("!H")[0] |
| 5184 | obj.priority = reader.read("!H")[0] |
| 5185 | obj.buffer_id = reader.read("!L")[0] |
| 5186 | obj.out_port = util.unpack_port_no(reader) |
| 5187 | obj.out_group = reader.read("!L")[0] |
| 5188 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5189 | reader.skip(2) |
| 5190 | obj.match = common.match.unpack(reader) |
| 5191 | obj.instructions = instruction.unpack_list(reader) |
| 5192 | return obj |
| 5193 | |
| 5194 | def __eq__(self, other): |
| 5195 | if type(self) != type(other): return False |
| 5196 | if self.version != other.version: return False |
| 5197 | if self.type != other.type: return False |
| 5198 | if self.xid != other.xid: return False |
| 5199 | if self.cookie != other.cookie: return False |
| 5200 | if self.cookie_mask != other.cookie_mask: return False |
| 5201 | if self.table_id != other.table_id: return False |
| 5202 | if self.idle_timeout != other.idle_timeout: return False |
| 5203 | if self.hard_timeout != other.hard_timeout: return False |
| 5204 | if self.priority != other.priority: return False |
| 5205 | if self.buffer_id != other.buffer_id: return False |
| 5206 | if self.out_port != other.out_port: return False |
| 5207 | if self.out_group != other.out_group: return False |
| 5208 | if self.flags != other.flags: return False |
| 5209 | if self.match != other.match: return False |
| 5210 | if self.instructions != other.instructions: return False |
| 5211 | return True |
| 5212 | |
| 5213 | def __ne__(self, other): |
| 5214 | return not self.__eq__(other) |
| 5215 | |
| 5216 | def __str__(self): |
| 5217 | return self.show() |
| 5218 | |
| 5219 | def show(self): |
| 5220 | import loxi.pp |
| 5221 | return loxi.pp.pp(self) |
| 5222 | |
| 5223 | def pretty_print(self, q): |
| 5224 | q.text("flow_delete {") |
| 5225 | with q.group(): |
| 5226 | with q.indent(2): |
| 5227 | q.breakable() |
| 5228 | q.text("xid = "); |
| 5229 | if self.xid != None: |
| 5230 | q.text("%#x" % self.xid) |
| 5231 | else: |
| 5232 | q.text('None') |
| 5233 | q.text(","); q.breakable() |
| 5234 | q.text("cookie = "); |
| 5235 | q.text("%#x" % self.cookie) |
| 5236 | q.text(","); q.breakable() |
| 5237 | q.text("cookie_mask = "); |
| 5238 | q.text("%#x" % self.cookie_mask) |
| 5239 | q.text(","); q.breakable() |
| 5240 | q.text("table_id = "); |
| 5241 | q.text("%#x" % self.table_id) |
| 5242 | q.text(","); q.breakable() |
| 5243 | q.text("idle_timeout = "); |
| 5244 | q.text("%#x" % self.idle_timeout) |
| 5245 | q.text(","); q.breakable() |
| 5246 | q.text("hard_timeout = "); |
| 5247 | q.text("%#x" % self.hard_timeout) |
| 5248 | q.text(","); q.breakable() |
| 5249 | q.text("priority = "); |
| 5250 | q.text("%#x" % self.priority) |
| 5251 | q.text(","); q.breakable() |
| 5252 | q.text("buffer_id = "); |
| 5253 | q.text("%#x" % self.buffer_id) |
| 5254 | q.text(","); q.breakable() |
| 5255 | q.text("out_port = "); |
| 5256 | q.text(util.pretty_port(self.out_port)) |
| 5257 | q.text(","); q.breakable() |
| 5258 | q.text("out_group = "); |
| 5259 | q.text("%#x" % self.out_group) |
| 5260 | q.text(","); q.breakable() |
| 5261 | q.text("flags = "); |
| 5262 | q.text("%#x" % self.flags) |
| 5263 | q.text(","); q.breakable() |
| 5264 | q.text("match = "); |
| 5265 | q.pp(self.match) |
| 5266 | q.text(","); q.breakable() |
| 5267 | q.text("instructions = "); |
| 5268 | q.pp(self.instructions) |
| 5269 | q.breakable() |
| 5270 | q.text('}') |
| 5271 | |
| 5272 | class flow_delete_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5273 | version = 4 |
| 5274 | type = 14 |
| 5275 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5276 | |
| 5277 | 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): |
| 5278 | self.xid = xid |
| 5279 | if cookie != None: |
| 5280 | self.cookie = cookie |
| 5281 | else: |
| 5282 | self.cookie = 0 |
| 5283 | if cookie_mask != None: |
| 5284 | self.cookie_mask = cookie_mask |
| 5285 | else: |
| 5286 | self.cookie_mask = 0 |
| 5287 | if table_id != None: |
| 5288 | self.table_id = table_id |
| 5289 | else: |
| 5290 | self.table_id = 0 |
| 5291 | if idle_timeout != None: |
| 5292 | self.idle_timeout = idle_timeout |
| 5293 | else: |
| 5294 | self.idle_timeout = 0 |
| 5295 | if hard_timeout != None: |
| 5296 | self.hard_timeout = hard_timeout |
| 5297 | else: |
| 5298 | self.hard_timeout = 0 |
| 5299 | if priority != None: |
| 5300 | self.priority = priority |
| 5301 | else: |
| 5302 | self.priority = 0 |
| 5303 | if buffer_id != None: |
| 5304 | self.buffer_id = buffer_id |
| 5305 | else: |
| 5306 | self.buffer_id = 0 |
| 5307 | if out_port != None: |
| 5308 | self.out_port = out_port |
| 5309 | else: |
| 5310 | self.out_port = 0 |
| 5311 | if out_group != None: |
| 5312 | self.out_group = out_group |
| 5313 | else: |
| 5314 | self.out_group = 0 |
| 5315 | if flags != None: |
| 5316 | self.flags = flags |
| 5317 | else: |
| 5318 | self.flags = 0 |
| 5319 | if match != None: |
| 5320 | self.match = match |
| 5321 | else: |
| 5322 | self.match = common.match() |
| 5323 | if instructions != None: |
| 5324 | self.instructions = instructions |
| 5325 | else: |
| 5326 | self.instructions = [] |
| 5327 | |
| 5328 | def pack(self): |
| 5329 | packed = [] |
| 5330 | packed.append(struct.pack("!B", self.version)) |
| 5331 | packed.append(struct.pack("!B", self.type)) |
| 5332 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5333 | packed.append(struct.pack("!L", self.xid)) |
| 5334 | packed.append(struct.pack("!Q", self.cookie)) |
| 5335 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5336 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5337 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5338 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5339 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5340 | packed.append(struct.pack("!H", self.priority)) |
| 5341 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5342 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5343 | packed.append(struct.pack("!L", self.out_group)) |
| 5344 | packed.append(struct.pack("!H", self.flags)) |
| 5345 | packed.append('\x00' * 2) |
| 5346 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5347 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5348 | length = sum([len(x) for x in packed]) |
| 5349 | packed[2] = struct.pack("!H", length) |
| 5350 | return ''.join(packed) |
| 5351 | |
| 5352 | @staticmethod |
| 5353 | def unpack(buf): |
| 5354 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5355 | obj = flow_delete_strict() |
| 5356 | if type(buf) == loxi.generic_util.OFReader: |
| 5357 | reader = buf |
| 5358 | else: |
| 5359 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5360 | _version = reader.read("!B")[0] |
| 5361 | assert(_version == 4) |
| 5362 | _type = reader.read("!B")[0] |
| 5363 | assert(_type == 14) |
| 5364 | _length = reader.read("!H")[0] |
| 5365 | obj.xid = reader.read("!L")[0] |
| 5366 | obj.cookie = reader.read("!Q")[0] |
| 5367 | obj.cookie_mask = reader.read("!Q")[0] |
| 5368 | obj.table_id = reader.read("!B")[0] |
| 5369 | __command = util.unpack_fm_cmd(reader) |
| 5370 | assert(__command == 4) |
| 5371 | obj.idle_timeout = reader.read("!H")[0] |
| 5372 | obj.hard_timeout = reader.read("!H")[0] |
| 5373 | obj.priority = reader.read("!H")[0] |
| 5374 | obj.buffer_id = reader.read("!L")[0] |
| 5375 | obj.out_port = util.unpack_port_no(reader) |
| 5376 | obj.out_group = reader.read("!L")[0] |
| 5377 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5378 | reader.skip(2) |
| 5379 | obj.match = common.match.unpack(reader) |
| 5380 | obj.instructions = instruction.unpack_list(reader) |
| 5381 | return obj |
| 5382 | |
| 5383 | def __eq__(self, other): |
| 5384 | if type(self) != type(other): return False |
| 5385 | if self.version != other.version: return False |
| 5386 | if self.type != other.type: return False |
| 5387 | if self.xid != other.xid: return False |
| 5388 | if self.cookie != other.cookie: return False |
| 5389 | if self.cookie_mask != other.cookie_mask: return False |
| 5390 | if self.table_id != other.table_id: return False |
| 5391 | if self.idle_timeout != other.idle_timeout: return False |
| 5392 | if self.hard_timeout != other.hard_timeout: return False |
| 5393 | if self.priority != other.priority: return False |
| 5394 | if self.buffer_id != other.buffer_id: return False |
| 5395 | if self.out_port != other.out_port: return False |
| 5396 | if self.out_group != other.out_group: return False |
| 5397 | if self.flags != other.flags: return False |
| 5398 | if self.match != other.match: return False |
| 5399 | if self.instructions != other.instructions: return False |
| 5400 | return True |
| 5401 | |
| 5402 | def __ne__(self, other): |
| 5403 | return not self.__eq__(other) |
| 5404 | |
| 5405 | def __str__(self): |
| 5406 | return self.show() |
| 5407 | |
| 5408 | def show(self): |
| 5409 | import loxi.pp |
| 5410 | return loxi.pp.pp(self) |
| 5411 | |
| 5412 | def pretty_print(self, q): |
| 5413 | q.text("flow_delete_strict {") |
| 5414 | with q.group(): |
| 5415 | with q.indent(2): |
| 5416 | q.breakable() |
| 5417 | q.text("xid = "); |
| 5418 | if self.xid != None: |
| 5419 | q.text("%#x" % self.xid) |
| 5420 | else: |
| 5421 | q.text('None') |
| 5422 | q.text(","); q.breakable() |
| 5423 | q.text("cookie = "); |
| 5424 | q.text("%#x" % self.cookie) |
| 5425 | q.text(","); q.breakable() |
| 5426 | q.text("cookie_mask = "); |
| 5427 | q.text("%#x" % self.cookie_mask) |
| 5428 | q.text(","); q.breakable() |
| 5429 | q.text("table_id = "); |
| 5430 | q.text("%#x" % self.table_id) |
| 5431 | q.text(","); q.breakable() |
| 5432 | q.text("idle_timeout = "); |
| 5433 | q.text("%#x" % self.idle_timeout) |
| 5434 | q.text(","); q.breakable() |
| 5435 | q.text("hard_timeout = "); |
| 5436 | q.text("%#x" % self.hard_timeout) |
| 5437 | q.text(","); q.breakable() |
| 5438 | q.text("priority = "); |
| 5439 | q.text("%#x" % self.priority) |
| 5440 | q.text(","); q.breakable() |
| 5441 | q.text("buffer_id = "); |
| 5442 | q.text("%#x" % self.buffer_id) |
| 5443 | q.text(","); q.breakable() |
| 5444 | q.text("out_port = "); |
| 5445 | q.text(util.pretty_port(self.out_port)) |
| 5446 | q.text(","); q.breakable() |
| 5447 | q.text("out_group = "); |
| 5448 | q.text("%#x" % self.out_group) |
| 5449 | q.text(","); q.breakable() |
| 5450 | q.text("flags = "); |
| 5451 | q.text("%#x" % self.flags) |
| 5452 | q.text(","); q.breakable() |
| 5453 | q.text("match = "); |
| 5454 | q.pp(self.match) |
| 5455 | q.text(","); q.breakable() |
| 5456 | q.text("instructions = "); |
| 5457 | q.pp(self.instructions) |
| 5458 | q.breakable() |
| 5459 | q.text('}') |
| 5460 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 5461 | class flow_mod_failed_error_msg(Message): |
| 5462 | version = 4 |
| 5463 | type = 1 |
| 5464 | err_type = 5 |
| 5465 | |
| 5466 | def __init__(self, xid=None, code=None, data=None): |
| 5467 | self.xid = xid |
| 5468 | if code != None: |
| 5469 | self.code = code |
| 5470 | else: |
| 5471 | self.code = 0 |
| 5472 | if data != None: |
| 5473 | self.data = data |
| 5474 | else: |
| 5475 | self.data = '' |
| 5476 | |
| 5477 | def pack(self): |
| 5478 | packed = [] |
| 5479 | packed.append(struct.pack("!B", self.version)) |
| 5480 | packed.append(struct.pack("!B", self.type)) |
| 5481 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5482 | packed.append(struct.pack("!L", self.xid)) |
| 5483 | packed.append(struct.pack("!H", self.err_type)) |
| 5484 | packed.append(struct.pack("!H", self.code)) |
| 5485 | packed.append(self.data) |
| 5486 | length = sum([len(x) for x in packed]) |
| 5487 | packed[2] = struct.pack("!H", length) |
| 5488 | return ''.join(packed) |
| 5489 | |
| 5490 | @staticmethod |
| 5491 | def unpack(buf): |
| 5492 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5493 | obj = flow_mod_failed_error_msg() |
| 5494 | if type(buf) == loxi.generic_util.OFReader: |
| 5495 | reader = buf |
| 5496 | else: |
| 5497 | reader = loxi.generic_util.OFReader(buf) |
| 5498 | _version = reader.read("!B")[0] |
| 5499 | assert(_version == 4) |
| 5500 | _type = reader.read("!B")[0] |
| 5501 | assert(_type == 1) |
| 5502 | _length = reader.read("!H")[0] |
| 5503 | obj.xid = reader.read("!L")[0] |
| 5504 | _err_type = reader.read("!H")[0] |
| 5505 | assert(_err_type == 5) |
| 5506 | obj.code = reader.read("!H")[0] |
| 5507 | obj.data = str(reader.read_all()) |
| 5508 | return obj |
| 5509 | |
| 5510 | def __eq__(self, other): |
| 5511 | if type(self) != type(other): return False |
| 5512 | if self.version != other.version: return False |
| 5513 | if self.type != other.type: return False |
| 5514 | if self.xid != other.xid: return False |
| 5515 | if self.code != other.code: return False |
| 5516 | if self.data != other.data: return False |
| 5517 | return True |
| 5518 | |
| 5519 | def __ne__(self, other): |
| 5520 | return not self.__eq__(other) |
| 5521 | |
| 5522 | def __str__(self): |
| 5523 | return self.show() |
| 5524 | |
| 5525 | def show(self): |
| 5526 | import loxi.pp |
| 5527 | return loxi.pp.pp(self) |
| 5528 | |
| 5529 | def pretty_print(self, q): |
| 5530 | q.text("flow_mod_failed_error_msg {") |
| 5531 | with q.group(): |
| 5532 | with q.indent(2): |
| 5533 | q.breakable() |
| 5534 | q.text("xid = "); |
| 5535 | if self.xid != None: |
| 5536 | q.text("%#x" % self.xid) |
| 5537 | else: |
| 5538 | q.text('None') |
| 5539 | q.text(","); q.breakable() |
| 5540 | q.text("code = "); |
| 5541 | q.text("%#x" % self.code) |
| 5542 | q.text(","); q.breakable() |
| 5543 | q.text("data = "); |
| 5544 | q.pp(self.data) |
| 5545 | q.breakable() |
| 5546 | q.text('}') |
| 5547 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5548 | class flow_modify(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5549 | version = 4 |
| 5550 | type = 14 |
| 5551 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5552 | |
| 5553 | 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): |
| 5554 | self.xid = xid |
| 5555 | if cookie != None: |
| 5556 | self.cookie = cookie |
| 5557 | else: |
| 5558 | self.cookie = 0 |
| 5559 | if cookie_mask != None: |
| 5560 | self.cookie_mask = cookie_mask |
| 5561 | else: |
| 5562 | self.cookie_mask = 0 |
| 5563 | if table_id != None: |
| 5564 | self.table_id = table_id |
| 5565 | else: |
| 5566 | self.table_id = 0 |
| 5567 | if idle_timeout != None: |
| 5568 | self.idle_timeout = idle_timeout |
| 5569 | else: |
| 5570 | self.idle_timeout = 0 |
| 5571 | if hard_timeout != None: |
| 5572 | self.hard_timeout = hard_timeout |
| 5573 | else: |
| 5574 | self.hard_timeout = 0 |
| 5575 | if priority != None: |
| 5576 | self.priority = priority |
| 5577 | else: |
| 5578 | self.priority = 0 |
| 5579 | if buffer_id != None: |
| 5580 | self.buffer_id = buffer_id |
| 5581 | else: |
| 5582 | self.buffer_id = 0 |
| 5583 | if out_port != None: |
| 5584 | self.out_port = out_port |
| 5585 | else: |
| 5586 | self.out_port = 0 |
| 5587 | if out_group != None: |
| 5588 | self.out_group = out_group |
| 5589 | else: |
| 5590 | self.out_group = 0 |
| 5591 | if flags != None: |
| 5592 | self.flags = flags |
| 5593 | else: |
| 5594 | self.flags = 0 |
| 5595 | if match != None: |
| 5596 | self.match = match |
| 5597 | else: |
| 5598 | self.match = common.match() |
| 5599 | if instructions != None: |
| 5600 | self.instructions = instructions |
| 5601 | else: |
| 5602 | self.instructions = [] |
| 5603 | |
| 5604 | def pack(self): |
| 5605 | packed = [] |
| 5606 | packed.append(struct.pack("!B", self.version)) |
| 5607 | packed.append(struct.pack("!B", self.type)) |
| 5608 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5609 | packed.append(struct.pack("!L", self.xid)) |
| 5610 | packed.append(struct.pack("!Q", self.cookie)) |
| 5611 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5612 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5613 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5614 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5615 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5616 | packed.append(struct.pack("!H", self.priority)) |
| 5617 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5618 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5619 | packed.append(struct.pack("!L", self.out_group)) |
| 5620 | packed.append(struct.pack("!H", self.flags)) |
| 5621 | packed.append('\x00' * 2) |
| 5622 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5623 | packed.append(util.pack_list(self.instructions)) |
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 = flow_modify() |
| 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 == 4) |
| 5638 | _type = reader.read("!B")[0] |
| 5639 | assert(_type == 14) |
| 5640 | _length = reader.read("!H")[0] |
| 5641 | obj.xid = reader.read("!L")[0] |
| 5642 | obj.cookie = reader.read("!Q")[0] |
| 5643 | obj.cookie_mask = reader.read("!Q")[0] |
| 5644 | obj.table_id = reader.read("!B")[0] |
| 5645 | __command = util.unpack_fm_cmd(reader) |
| 5646 | assert(__command == 1) |
| 5647 | obj.idle_timeout = reader.read("!H")[0] |
| 5648 | obj.hard_timeout = reader.read("!H")[0] |
| 5649 | obj.priority = reader.read("!H")[0] |
| 5650 | obj.buffer_id = reader.read("!L")[0] |
| 5651 | obj.out_port = util.unpack_port_no(reader) |
| 5652 | obj.out_group = reader.read("!L")[0] |
| 5653 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5654 | reader.skip(2) |
| 5655 | obj.match = common.match.unpack(reader) |
| 5656 | obj.instructions = instruction.unpack_list(reader) |
| 5657 | return obj |
| 5658 | |
| 5659 | def __eq__(self, other): |
| 5660 | if type(self) != type(other): return False |
| 5661 | if self.version != other.version: return False |
| 5662 | if self.type != other.type: return False |
| 5663 | if self.xid != other.xid: return False |
| 5664 | if self.cookie != other.cookie: return False |
| 5665 | if self.cookie_mask != other.cookie_mask: return False |
| 5666 | if self.table_id != other.table_id: return False |
| 5667 | if self.idle_timeout != other.idle_timeout: return False |
| 5668 | if self.hard_timeout != other.hard_timeout: return False |
| 5669 | if self.priority != other.priority: return False |
| 5670 | if self.buffer_id != other.buffer_id: return False |
| 5671 | if self.out_port != other.out_port: return False |
| 5672 | if self.out_group != other.out_group: return False |
| 5673 | if self.flags != other.flags: return False |
| 5674 | if self.match != other.match: return False |
| 5675 | if self.instructions != other.instructions: return False |
| 5676 | return True |
| 5677 | |
| 5678 | def __ne__(self, other): |
| 5679 | return not self.__eq__(other) |
| 5680 | |
| 5681 | def __str__(self): |
| 5682 | return self.show() |
| 5683 | |
| 5684 | def show(self): |
| 5685 | import loxi.pp |
| 5686 | return loxi.pp.pp(self) |
| 5687 | |
| 5688 | def pretty_print(self, q): |
| 5689 | q.text("flow_modify {") |
| 5690 | with q.group(): |
| 5691 | with q.indent(2): |
| 5692 | q.breakable() |
| 5693 | q.text("xid = "); |
| 5694 | if self.xid != None: |
| 5695 | q.text("%#x" % self.xid) |
| 5696 | else: |
| 5697 | q.text('None') |
| 5698 | q.text(","); q.breakable() |
| 5699 | q.text("cookie = "); |
| 5700 | q.text("%#x" % self.cookie) |
| 5701 | q.text(","); q.breakable() |
| 5702 | q.text("cookie_mask = "); |
| 5703 | q.text("%#x" % self.cookie_mask) |
| 5704 | q.text(","); q.breakable() |
| 5705 | q.text("table_id = "); |
| 5706 | q.text("%#x" % self.table_id) |
| 5707 | q.text(","); q.breakable() |
| 5708 | q.text("idle_timeout = "); |
| 5709 | q.text("%#x" % self.idle_timeout) |
| 5710 | q.text(","); q.breakable() |
| 5711 | q.text("hard_timeout = "); |
| 5712 | q.text("%#x" % self.hard_timeout) |
| 5713 | q.text(","); q.breakable() |
| 5714 | q.text("priority = "); |
| 5715 | q.text("%#x" % self.priority) |
| 5716 | q.text(","); q.breakable() |
| 5717 | q.text("buffer_id = "); |
| 5718 | q.text("%#x" % self.buffer_id) |
| 5719 | q.text(","); q.breakable() |
| 5720 | q.text("out_port = "); |
| 5721 | q.text(util.pretty_port(self.out_port)) |
| 5722 | q.text(","); q.breakable() |
| 5723 | q.text("out_group = "); |
| 5724 | q.text("%#x" % self.out_group) |
| 5725 | q.text(","); q.breakable() |
| 5726 | q.text("flags = "); |
| 5727 | q.text("%#x" % self.flags) |
| 5728 | q.text(","); q.breakable() |
| 5729 | q.text("match = "); |
| 5730 | q.pp(self.match) |
| 5731 | q.text(","); q.breakable() |
| 5732 | q.text("instructions = "); |
| 5733 | q.pp(self.instructions) |
| 5734 | q.breakable() |
| 5735 | q.text('}') |
| 5736 | |
| 5737 | class flow_modify_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5738 | version = 4 |
| 5739 | type = 14 |
| 5740 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5741 | |
| 5742 | 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): |
| 5743 | self.xid = xid |
| 5744 | if cookie != None: |
| 5745 | self.cookie = cookie |
| 5746 | else: |
| 5747 | self.cookie = 0 |
| 5748 | if cookie_mask != None: |
| 5749 | self.cookie_mask = cookie_mask |
| 5750 | else: |
| 5751 | self.cookie_mask = 0 |
| 5752 | if table_id != None: |
| 5753 | self.table_id = table_id |
| 5754 | else: |
| 5755 | self.table_id = 0 |
| 5756 | if idle_timeout != None: |
| 5757 | self.idle_timeout = idle_timeout |
| 5758 | else: |
| 5759 | self.idle_timeout = 0 |
| 5760 | if hard_timeout != None: |
| 5761 | self.hard_timeout = hard_timeout |
| 5762 | else: |
| 5763 | self.hard_timeout = 0 |
| 5764 | if priority != None: |
| 5765 | self.priority = priority |
| 5766 | else: |
| 5767 | self.priority = 0 |
| 5768 | if buffer_id != None: |
| 5769 | self.buffer_id = buffer_id |
| 5770 | else: |
| 5771 | self.buffer_id = 0 |
| 5772 | if out_port != None: |
| 5773 | self.out_port = out_port |
| 5774 | else: |
| 5775 | self.out_port = 0 |
| 5776 | if out_group != None: |
| 5777 | self.out_group = out_group |
| 5778 | else: |
| 5779 | self.out_group = 0 |
| 5780 | if flags != None: |
| 5781 | self.flags = flags |
| 5782 | else: |
| 5783 | self.flags = 0 |
| 5784 | if match != None: |
| 5785 | self.match = match |
| 5786 | else: |
| 5787 | self.match = common.match() |
| 5788 | if instructions != None: |
| 5789 | self.instructions = instructions |
| 5790 | else: |
| 5791 | self.instructions = [] |
| 5792 | |
| 5793 | def pack(self): |
| 5794 | packed = [] |
| 5795 | packed.append(struct.pack("!B", self.version)) |
| 5796 | packed.append(struct.pack("!B", self.type)) |
| 5797 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5798 | packed.append(struct.pack("!L", self.xid)) |
| 5799 | packed.append(struct.pack("!Q", self.cookie)) |
| 5800 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5801 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5802 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5803 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5804 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5805 | packed.append(struct.pack("!H", self.priority)) |
| 5806 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5807 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5808 | packed.append(struct.pack("!L", self.out_group)) |
| 5809 | packed.append(struct.pack("!H", self.flags)) |
| 5810 | packed.append('\x00' * 2) |
| 5811 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5812 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5813 | length = sum([len(x) for x in packed]) |
| 5814 | packed[2] = struct.pack("!H", length) |
| 5815 | return ''.join(packed) |
| 5816 | |
| 5817 | @staticmethod |
| 5818 | def unpack(buf): |
| 5819 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5820 | obj = flow_modify_strict() |
| 5821 | if type(buf) == loxi.generic_util.OFReader: |
| 5822 | reader = buf |
| 5823 | else: |
| 5824 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5825 | _version = reader.read("!B")[0] |
| 5826 | assert(_version == 4) |
| 5827 | _type = reader.read("!B")[0] |
| 5828 | assert(_type == 14) |
| 5829 | _length = reader.read("!H")[0] |
| 5830 | obj.xid = reader.read("!L")[0] |
| 5831 | obj.cookie = reader.read("!Q")[0] |
| 5832 | obj.cookie_mask = reader.read("!Q")[0] |
| 5833 | obj.table_id = reader.read("!B")[0] |
| 5834 | __command = util.unpack_fm_cmd(reader) |
| 5835 | assert(__command == 2) |
| 5836 | obj.idle_timeout = reader.read("!H")[0] |
| 5837 | obj.hard_timeout = reader.read("!H")[0] |
| 5838 | obj.priority = reader.read("!H")[0] |
| 5839 | obj.buffer_id = reader.read("!L")[0] |
| 5840 | obj.out_port = util.unpack_port_no(reader) |
| 5841 | obj.out_group = reader.read("!L")[0] |
| 5842 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5843 | reader.skip(2) |
| 5844 | obj.match = common.match.unpack(reader) |
| 5845 | obj.instructions = instruction.unpack_list(reader) |
| 5846 | return obj |
| 5847 | |
| 5848 | def __eq__(self, other): |
| 5849 | if type(self) != type(other): return False |
| 5850 | if self.version != other.version: return False |
| 5851 | if self.type != other.type: return False |
| 5852 | if self.xid != other.xid: return False |
| 5853 | if self.cookie != other.cookie: return False |
| 5854 | if self.cookie_mask != other.cookie_mask: return False |
| 5855 | if self.table_id != other.table_id: return False |
| 5856 | if self.idle_timeout != other.idle_timeout: return False |
| 5857 | if self.hard_timeout != other.hard_timeout: return False |
| 5858 | if self.priority != other.priority: return False |
| 5859 | if self.buffer_id != other.buffer_id: return False |
| 5860 | if self.out_port != other.out_port: return False |
| 5861 | if self.out_group != other.out_group: return False |
| 5862 | if self.flags != other.flags: return False |
| 5863 | if self.match != other.match: return False |
| 5864 | if self.instructions != other.instructions: return False |
| 5865 | return True |
| 5866 | |
| 5867 | def __ne__(self, other): |
| 5868 | return not self.__eq__(other) |
| 5869 | |
| 5870 | def __str__(self): |
| 5871 | return self.show() |
| 5872 | |
| 5873 | def show(self): |
| 5874 | import loxi.pp |
| 5875 | return loxi.pp.pp(self) |
| 5876 | |
| 5877 | def pretty_print(self, q): |
| 5878 | q.text("flow_modify_strict {") |
| 5879 | with q.group(): |
| 5880 | with q.indent(2): |
| 5881 | q.breakable() |
| 5882 | q.text("xid = "); |
| 5883 | if self.xid != None: |
| 5884 | q.text("%#x" % self.xid) |
| 5885 | else: |
| 5886 | q.text('None') |
| 5887 | q.text(","); q.breakable() |
| 5888 | q.text("cookie = "); |
| 5889 | q.text("%#x" % self.cookie) |
| 5890 | q.text(","); q.breakable() |
| 5891 | q.text("cookie_mask = "); |
| 5892 | q.text("%#x" % self.cookie_mask) |
| 5893 | q.text(","); q.breakable() |
| 5894 | q.text("table_id = "); |
| 5895 | q.text("%#x" % self.table_id) |
| 5896 | q.text(","); q.breakable() |
| 5897 | q.text("idle_timeout = "); |
| 5898 | q.text("%#x" % self.idle_timeout) |
| 5899 | q.text(","); q.breakable() |
| 5900 | q.text("hard_timeout = "); |
| 5901 | q.text("%#x" % self.hard_timeout) |
| 5902 | q.text(","); q.breakable() |
| 5903 | q.text("priority = "); |
| 5904 | q.text("%#x" % self.priority) |
| 5905 | q.text(","); q.breakable() |
| 5906 | q.text("buffer_id = "); |
| 5907 | q.text("%#x" % self.buffer_id) |
| 5908 | q.text(","); q.breakable() |
| 5909 | q.text("out_port = "); |
| 5910 | q.text(util.pretty_port(self.out_port)) |
| 5911 | q.text(","); q.breakable() |
| 5912 | q.text("out_group = "); |
| 5913 | q.text("%#x" % self.out_group) |
| 5914 | q.text(","); q.breakable() |
| 5915 | q.text("flags = "); |
| 5916 | q.text("%#x" % self.flags) |
| 5917 | q.text(","); q.breakable() |
| 5918 | q.text("match = "); |
| 5919 | q.pp(self.match) |
| 5920 | q.text(","); q.breakable() |
| 5921 | q.text("instructions = "); |
| 5922 | q.pp(self.instructions) |
| 5923 | q.breakable() |
| 5924 | q.text('}') |
| 5925 | |
| 5926 | class flow_removed(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5927 | version = 4 |
| 5928 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5929 | |
| 5930 | def __init__(self, xid=None, cookie=None, priority=None, reason=None, table_id=None, duration_sec=None, duration_nsec=None, idle_timeout=None, hard_timeout=None, packet_count=None, byte_count=None, match=None): |
| 5931 | self.xid = xid |
| 5932 | if cookie != None: |
| 5933 | self.cookie = cookie |
| 5934 | else: |
| 5935 | self.cookie = 0 |
| 5936 | if priority != None: |
| 5937 | self.priority = priority |
| 5938 | else: |
| 5939 | self.priority = 0 |
| 5940 | if reason != None: |
| 5941 | self.reason = reason |
| 5942 | else: |
| 5943 | self.reason = 0 |
| 5944 | if table_id != None: |
| 5945 | self.table_id = table_id |
| 5946 | else: |
| 5947 | self.table_id = 0 |
| 5948 | if duration_sec != None: |
| 5949 | self.duration_sec = duration_sec |
| 5950 | else: |
| 5951 | self.duration_sec = 0 |
| 5952 | if duration_nsec != None: |
| 5953 | self.duration_nsec = duration_nsec |
| 5954 | else: |
| 5955 | self.duration_nsec = 0 |
| 5956 | if idle_timeout != None: |
| 5957 | self.idle_timeout = idle_timeout |
| 5958 | else: |
| 5959 | self.idle_timeout = 0 |
| 5960 | if hard_timeout != None: |
| 5961 | self.hard_timeout = hard_timeout |
| 5962 | else: |
| 5963 | self.hard_timeout = 0 |
| 5964 | if packet_count != None: |
| 5965 | self.packet_count = packet_count |
| 5966 | else: |
| 5967 | self.packet_count = 0 |
| 5968 | if byte_count != None: |
| 5969 | self.byte_count = byte_count |
| 5970 | else: |
| 5971 | self.byte_count = 0 |
| 5972 | if match != None: |
| 5973 | self.match = match |
| 5974 | else: |
| 5975 | self.match = common.match() |
| 5976 | |
| 5977 | def pack(self): |
| 5978 | packed = [] |
| 5979 | packed.append(struct.pack("!B", self.version)) |
| 5980 | packed.append(struct.pack("!B", self.type)) |
| 5981 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5982 | packed.append(struct.pack("!L", self.xid)) |
| 5983 | packed.append(struct.pack("!Q", self.cookie)) |
| 5984 | packed.append(struct.pack("!H", self.priority)) |
| 5985 | packed.append(struct.pack("!B", self.reason)) |
| 5986 | packed.append(struct.pack("!B", self.table_id)) |
| 5987 | packed.append(struct.pack("!L", self.duration_sec)) |
| 5988 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 5989 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5990 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5991 | packed.append(struct.pack("!Q", self.packet_count)) |
| 5992 | packed.append(struct.pack("!Q", self.byte_count)) |
| 5993 | packed.append(self.match.pack()) |
| 5994 | length = sum([len(x) for x in packed]) |
| 5995 | packed[2] = struct.pack("!H", length) |
| 5996 | return ''.join(packed) |
| 5997 | |
| 5998 | @staticmethod |
| 5999 | def unpack(buf): |
| 6000 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6001 | obj = flow_removed() |
| 6002 | if type(buf) == loxi.generic_util.OFReader: |
| 6003 | reader = buf |
| 6004 | else: |
| 6005 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6006 | _version = reader.read("!B")[0] |
| 6007 | assert(_version == 4) |
| 6008 | _type = reader.read("!B")[0] |
| 6009 | assert(_type == 11) |
| 6010 | _length = reader.read("!H")[0] |
| 6011 | obj.xid = reader.read("!L")[0] |
| 6012 | obj.cookie = reader.read("!Q")[0] |
| 6013 | obj.priority = reader.read("!H")[0] |
| 6014 | obj.reason = reader.read("!B")[0] |
| 6015 | obj.table_id = reader.read("!B")[0] |
| 6016 | obj.duration_sec = reader.read("!L")[0] |
| 6017 | obj.duration_nsec = reader.read("!L")[0] |
| 6018 | obj.idle_timeout = reader.read("!H")[0] |
| 6019 | obj.hard_timeout = reader.read("!H")[0] |
| 6020 | obj.packet_count = reader.read("!Q")[0] |
| 6021 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6022 | obj.match = common.match.unpack(reader) |
| 6023 | return obj |
| 6024 | |
| 6025 | def __eq__(self, other): |
| 6026 | if type(self) != type(other): return False |
| 6027 | if self.version != other.version: return False |
| 6028 | if self.type != other.type: return False |
| 6029 | if self.xid != other.xid: return False |
| 6030 | if self.cookie != other.cookie: return False |
| 6031 | if self.priority != other.priority: return False |
| 6032 | if self.reason != other.reason: return False |
| 6033 | if self.table_id != other.table_id: return False |
| 6034 | if self.duration_sec != other.duration_sec: return False |
| 6035 | if self.duration_nsec != other.duration_nsec: return False |
| 6036 | if self.idle_timeout != other.idle_timeout: return False |
| 6037 | if self.hard_timeout != other.hard_timeout: return False |
| 6038 | if self.packet_count != other.packet_count: return False |
| 6039 | if self.byte_count != other.byte_count: return False |
| 6040 | if self.match != other.match: return False |
| 6041 | return True |
| 6042 | |
| 6043 | def __ne__(self, other): |
| 6044 | return not self.__eq__(other) |
| 6045 | |
| 6046 | def __str__(self): |
| 6047 | return self.show() |
| 6048 | |
| 6049 | def show(self): |
| 6050 | import loxi.pp |
| 6051 | return loxi.pp.pp(self) |
| 6052 | |
| 6053 | def pretty_print(self, q): |
| 6054 | q.text("flow_removed {") |
| 6055 | with q.group(): |
| 6056 | with q.indent(2): |
| 6057 | q.breakable() |
| 6058 | q.text("xid = "); |
| 6059 | if self.xid != None: |
| 6060 | q.text("%#x" % self.xid) |
| 6061 | else: |
| 6062 | q.text('None') |
| 6063 | q.text(","); q.breakable() |
| 6064 | q.text("cookie = "); |
| 6065 | q.text("%#x" % self.cookie) |
| 6066 | q.text(","); q.breakable() |
| 6067 | q.text("priority = "); |
| 6068 | q.text("%#x" % self.priority) |
| 6069 | q.text(","); q.breakable() |
| 6070 | q.text("reason = "); |
| 6071 | q.text("%#x" % self.reason) |
| 6072 | q.text(","); q.breakable() |
| 6073 | q.text("table_id = "); |
| 6074 | q.text("%#x" % self.table_id) |
| 6075 | q.text(","); q.breakable() |
| 6076 | q.text("duration_sec = "); |
| 6077 | q.text("%#x" % self.duration_sec) |
| 6078 | q.text(","); q.breakable() |
| 6079 | q.text("duration_nsec = "); |
| 6080 | q.text("%#x" % self.duration_nsec) |
| 6081 | q.text(","); q.breakable() |
| 6082 | q.text("idle_timeout = "); |
| 6083 | q.text("%#x" % self.idle_timeout) |
| 6084 | q.text(","); q.breakable() |
| 6085 | q.text("hard_timeout = "); |
| 6086 | q.text("%#x" % self.hard_timeout) |
| 6087 | q.text(","); q.breakable() |
| 6088 | q.text("packet_count = "); |
| 6089 | q.text("%#x" % self.packet_count) |
| 6090 | q.text(","); q.breakable() |
| 6091 | q.text("byte_count = "); |
| 6092 | q.text("%#x" % self.byte_count) |
| 6093 | q.text(","); q.breakable() |
| 6094 | q.text("match = "); |
| 6095 | q.pp(self.match) |
| 6096 | q.breakable() |
| 6097 | q.text('}') |
| 6098 | |
| 6099 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6100 | version = 4 |
| 6101 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6102 | stats_type = 1 |
| 6103 | |
| 6104 | def __init__(self, xid=None, flags=None, entries=None): |
| 6105 | self.xid = xid |
| 6106 | if flags != None: |
| 6107 | self.flags = flags |
| 6108 | else: |
| 6109 | self.flags = 0 |
| 6110 | if entries != None: |
| 6111 | self.entries = entries |
| 6112 | else: |
| 6113 | self.entries = [] |
| 6114 | |
| 6115 | def pack(self): |
| 6116 | packed = [] |
| 6117 | packed.append(struct.pack("!B", self.version)) |
| 6118 | packed.append(struct.pack("!B", self.type)) |
| 6119 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6120 | packed.append(struct.pack("!L", self.xid)) |
| 6121 | packed.append(struct.pack("!H", self.stats_type)) |
| 6122 | packed.append(struct.pack("!H", self.flags)) |
| 6123 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6124 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6125 | length = sum([len(x) for x in packed]) |
| 6126 | packed[2] = struct.pack("!H", length) |
| 6127 | return ''.join(packed) |
| 6128 | |
| 6129 | @staticmethod |
| 6130 | def unpack(buf): |
| 6131 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6132 | obj = flow_stats_reply() |
| 6133 | if type(buf) == loxi.generic_util.OFReader: |
| 6134 | reader = buf |
| 6135 | else: |
| 6136 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6137 | _version = reader.read("!B")[0] |
| 6138 | assert(_version == 4) |
| 6139 | _type = reader.read("!B")[0] |
| 6140 | assert(_type == 19) |
| 6141 | _length = reader.read("!H")[0] |
| 6142 | obj.xid = reader.read("!L")[0] |
| 6143 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6144 | assert(_stats_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6145 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6146 | reader.skip(4) |
| 6147 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
| 6148 | return obj |
| 6149 | |
| 6150 | def __eq__(self, other): |
| 6151 | if type(self) != type(other): return False |
| 6152 | if self.version != other.version: return False |
| 6153 | if self.type != other.type: return False |
| 6154 | if self.xid != other.xid: return False |
| 6155 | if self.flags != other.flags: return False |
| 6156 | if self.entries != other.entries: return False |
| 6157 | return True |
| 6158 | |
| 6159 | def __ne__(self, other): |
| 6160 | return not self.__eq__(other) |
| 6161 | |
| 6162 | def __str__(self): |
| 6163 | return self.show() |
| 6164 | |
| 6165 | def show(self): |
| 6166 | import loxi.pp |
| 6167 | return loxi.pp.pp(self) |
| 6168 | |
| 6169 | def pretty_print(self, q): |
| 6170 | q.text("flow_stats_reply {") |
| 6171 | with q.group(): |
| 6172 | with q.indent(2): |
| 6173 | q.breakable() |
| 6174 | q.text("xid = "); |
| 6175 | if self.xid != None: |
| 6176 | q.text("%#x" % self.xid) |
| 6177 | else: |
| 6178 | q.text('None') |
| 6179 | q.text(","); q.breakable() |
| 6180 | q.text("flags = "); |
| 6181 | q.text("%#x" % self.flags) |
| 6182 | q.text(","); q.breakable() |
| 6183 | q.text("entries = "); |
| 6184 | q.pp(self.entries) |
| 6185 | q.breakable() |
| 6186 | q.text('}') |
| 6187 | |
| 6188 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6189 | version = 4 |
| 6190 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6191 | stats_type = 1 |
| 6192 | |
| 6193 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 6194 | self.xid = xid |
| 6195 | if flags != None: |
| 6196 | self.flags = flags |
| 6197 | else: |
| 6198 | self.flags = 0 |
| 6199 | if table_id != None: |
| 6200 | self.table_id = table_id |
| 6201 | else: |
| 6202 | self.table_id = 0 |
| 6203 | if out_port != None: |
| 6204 | self.out_port = out_port |
| 6205 | else: |
| 6206 | self.out_port = 0 |
| 6207 | if out_group != None: |
| 6208 | self.out_group = out_group |
| 6209 | else: |
| 6210 | self.out_group = 0 |
| 6211 | if cookie != None: |
| 6212 | self.cookie = cookie |
| 6213 | else: |
| 6214 | self.cookie = 0 |
| 6215 | if cookie_mask != None: |
| 6216 | self.cookie_mask = cookie_mask |
| 6217 | else: |
| 6218 | self.cookie_mask = 0 |
| 6219 | if match != None: |
| 6220 | self.match = match |
| 6221 | else: |
| 6222 | self.match = common.match() |
| 6223 | |
| 6224 | def pack(self): |
| 6225 | packed = [] |
| 6226 | packed.append(struct.pack("!B", self.version)) |
| 6227 | packed.append(struct.pack("!B", self.type)) |
| 6228 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6229 | packed.append(struct.pack("!L", self.xid)) |
| 6230 | packed.append(struct.pack("!H", self.stats_type)) |
| 6231 | packed.append(struct.pack("!H", self.flags)) |
| 6232 | packed.append('\x00' * 4) |
| 6233 | packed.append(struct.pack("!B", self.table_id)) |
| 6234 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6235 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6236 | packed.append(struct.pack("!L", self.out_group)) |
| 6237 | packed.append('\x00' * 4) |
| 6238 | packed.append(struct.pack("!Q", self.cookie)) |
| 6239 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 6240 | packed.append(self.match.pack()) |
| 6241 | length = sum([len(x) for x in packed]) |
| 6242 | packed[2] = struct.pack("!H", length) |
| 6243 | return ''.join(packed) |
| 6244 | |
| 6245 | @staticmethod |
| 6246 | def unpack(buf): |
| 6247 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6248 | obj = flow_stats_request() |
| 6249 | if type(buf) == loxi.generic_util.OFReader: |
| 6250 | reader = buf |
| 6251 | else: |
| 6252 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6253 | _version = reader.read("!B")[0] |
| 6254 | assert(_version == 4) |
| 6255 | _type = reader.read("!B")[0] |
| 6256 | assert(_type == 18) |
| 6257 | _length = reader.read("!H")[0] |
| 6258 | obj.xid = reader.read("!L")[0] |
| 6259 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6260 | assert(_stats_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6261 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6262 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6263 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6264 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6265 | obj.out_port = util.unpack_port_no(reader) |
| 6266 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6267 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6268 | obj.cookie = reader.read("!Q")[0] |
| 6269 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6270 | obj.match = common.match.unpack(reader) |
| 6271 | return obj |
| 6272 | |
| 6273 | def __eq__(self, other): |
| 6274 | if type(self) != type(other): return False |
| 6275 | if self.version != other.version: return False |
| 6276 | if self.type != other.type: return False |
| 6277 | if self.xid != other.xid: return False |
| 6278 | if self.flags != other.flags: return False |
| 6279 | if self.table_id != other.table_id: return False |
| 6280 | if self.out_port != other.out_port: return False |
| 6281 | if self.out_group != other.out_group: return False |
| 6282 | if self.cookie != other.cookie: return False |
| 6283 | if self.cookie_mask != other.cookie_mask: return False |
| 6284 | if self.match != other.match: return False |
| 6285 | return True |
| 6286 | |
| 6287 | def __ne__(self, other): |
| 6288 | return not self.__eq__(other) |
| 6289 | |
| 6290 | def __str__(self): |
| 6291 | return self.show() |
| 6292 | |
| 6293 | def show(self): |
| 6294 | import loxi.pp |
| 6295 | return loxi.pp.pp(self) |
| 6296 | |
| 6297 | def pretty_print(self, q): |
| 6298 | q.text("flow_stats_request {") |
| 6299 | with q.group(): |
| 6300 | with q.indent(2): |
| 6301 | q.breakable() |
| 6302 | q.text("xid = "); |
| 6303 | if self.xid != None: |
| 6304 | q.text("%#x" % self.xid) |
| 6305 | else: |
| 6306 | q.text('None') |
| 6307 | q.text(","); q.breakable() |
| 6308 | q.text("flags = "); |
| 6309 | q.text("%#x" % self.flags) |
| 6310 | q.text(","); q.breakable() |
| 6311 | q.text("table_id = "); |
| 6312 | q.text("%#x" % self.table_id) |
| 6313 | q.text(","); q.breakable() |
| 6314 | q.text("out_port = "); |
| 6315 | q.text(util.pretty_port(self.out_port)) |
| 6316 | q.text(","); q.breakable() |
| 6317 | q.text("out_group = "); |
| 6318 | q.text("%#x" % self.out_group) |
| 6319 | q.text(","); q.breakable() |
| 6320 | q.text("cookie = "); |
| 6321 | q.text("%#x" % self.cookie) |
| 6322 | q.text(","); q.breakable() |
| 6323 | q.text("cookie_mask = "); |
| 6324 | q.text("%#x" % self.cookie_mask) |
| 6325 | q.text(","); q.breakable() |
| 6326 | q.text("match = "); |
| 6327 | q.pp(self.match) |
| 6328 | q.breakable() |
| 6329 | q.text('}') |
| 6330 | |
| 6331 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6332 | version = 4 |
| 6333 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6334 | |
| 6335 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 6336 | self.xid = xid |
| 6337 | if flags != None: |
| 6338 | self.flags = flags |
| 6339 | else: |
| 6340 | self.flags = 0 |
| 6341 | if miss_send_len != None: |
| 6342 | self.miss_send_len = miss_send_len |
| 6343 | else: |
| 6344 | self.miss_send_len = 0 |
| 6345 | |
| 6346 | def pack(self): |
| 6347 | packed = [] |
| 6348 | packed.append(struct.pack("!B", self.version)) |
| 6349 | packed.append(struct.pack("!B", self.type)) |
| 6350 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6351 | packed.append(struct.pack("!L", self.xid)) |
| 6352 | packed.append(struct.pack("!H", self.flags)) |
| 6353 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 6354 | length = sum([len(x) for x in packed]) |
| 6355 | packed[2] = struct.pack("!H", length) |
| 6356 | return ''.join(packed) |
| 6357 | |
| 6358 | @staticmethod |
| 6359 | def unpack(buf): |
| 6360 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6361 | obj = get_config_reply() |
| 6362 | if type(buf) == loxi.generic_util.OFReader: |
| 6363 | reader = buf |
| 6364 | else: |
| 6365 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6366 | _version = reader.read("!B")[0] |
| 6367 | assert(_version == 4) |
| 6368 | _type = reader.read("!B")[0] |
| 6369 | assert(_type == 8) |
| 6370 | _length = reader.read("!H")[0] |
| 6371 | obj.xid = reader.read("!L")[0] |
| 6372 | obj.flags = reader.read("!H")[0] |
| 6373 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6374 | return obj |
| 6375 | |
| 6376 | def __eq__(self, other): |
| 6377 | if type(self) != type(other): return False |
| 6378 | if self.version != other.version: return False |
| 6379 | if self.type != other.type: return False |
| 6380 | if self.xid != other.xid: return False |
| 6381 | if self.flags != other.flags: return False |
| 6382 | if self.miss_send_len != other.miss_send_len: return False |
| 6383 | return True |
| 6384 | |
| 6385 | def __ne__(self, other): |
| 6386 | return not self.__eq__(other) |
| 6387 | |
| 6388 | def __str__(self): |
| 6389 | return self.show() |
| 6390 | |
| 6391 | def show(self): |
| 6392 | import loxi.pp |
| 6393 | return loxi.pp.pp(self) |
| 6394 | |
| 6395 | def pretty_print(self, q): |
| 6396 | q.text("get_config_reply {") |
| 6397 | with q.group(): |
| 6398 | with q.indent(2): |
| 6399 | q.breakable() |
| 6400 | q.text("xid = "); |
| 6401 | if self.xid != None: |
| 6402 | q.text("%#x" % self.xid) |
| 6403 | else: |
| 6404 | q.text('None') |
| 6405 | q.text(","); q.breakable() |
| 6406 | q.text("flags = "); |
| 6407 | q.text("%#x" % self.flags) |
| 6408 | q.text(","); q.breakable() |
| 6409 | q.text("miss_send_len = "); |
| 6410 | q.text("%#x" % self.miss_send_len) |
| 6411 | q.breakable() |
| 6412 | q.text('}') |
| 6413 | |
| 6414 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6415 | version = 4 |
| 6416 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6417 | |
| 6418 | def __init__(self, xid=None): |
| 6419 | self.xid = xid |
| 6420 | |
| 6421 | def pack(self): |
| 6422 | packed = [] |
| 6423 | packed.append(struct.pack("!B", self.version)) |
| 6424 | packed.append(struct.pack("!B", self.type)) |
| 6425 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6426 | packed.append(struct.pack("!L", self.xid)) |
| 6427 | length = sum([len(x) for x in packed]) |
| 6428 | packed[2] = struct.pack("!H", length) |
| 6429 | return ''.join(packed) |
| 6430 | |
| 6431 | @staticmethod |
| 6432 | def unpack(buf): |
| 6433 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6434 | obj = get_config_request() |
| 6435 | if type(buf) == loxi.generic_util.OFReader: |
| 6436 | reader = buf |
| 6437 | else: |
| 6438 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6439 | _version = reader.read("!B")[0] |
| 6440 | assert(_version == 4) |
| 6441 | _type = reader.read("!B")[0] |
| 6442 | assert(_type == 7) |
| 6443 | _length = reader.read("!H")[0] |
| 6444 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6445 | return obj |
| 6446 | |
| 6447 | def __eq__(self, other): |
| 6448 | if type(self) != type(other): return False |
| 6449 | if self.version != other.version: return False |
| 6450 | if self.type != other.type: return False |
| 6451 | if self.xid != other.xid: return False |
| 6452 | return True |
| 6453 | |
| 6454 | def __ne__(self, other): |
| 6455 | return not self.__eq__(other) |
| 6456 | |
| 6457 | def __str__(self): |
| 6458 | return self.show() |
| 6459 | |
| 6460 | def show(self): |
| 6461 | import loxi.pp |
| 6462 | return loxi.pp.pp(self) |
| 6463 | |
| 6464 | def pretty_print(self, q): |
| 6465 | q.text("get_config_request {") |
| 6466 | with q.group(): |
| 6467 | with q.indent(2): |
| 6468 | q.breakable() |
| 6469 | q.text("xid = "); |
| 6470 | if self.xid != None: |
| 6471 | q.text("%#x" % self.xid) |
| 6472 | else: |
| 6473 | q.text('None') |
| 6474 | q.breakable() |
| 6475 | q.text('}') |
| 6476 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 6477 | class group_add(Message): |
| 6478 | version = 4 |
| 6479 | type = 15 |
| 6480 | command = 0 |
| 6481 | |
| 6482 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
| 6483 | self.xid = xid |
| 6484 | if group_type != None: |
| 6485 | self.group_type = group_type |
| 6486 | else: |
| 6487 | self.group_type = 0 |
| 6488 | if group_id != None: |
| 6489 | self.group_id = group_id |
| 6490 | else: |
| 6491 | self.group_id = 0 |
| 6492 | if buckets != None: |
| 6493 | self.buckets = buckets |
| 6494 | else: |
| 6495 | self.buckets = [] |
| 6496 | |
| 6497 | def pack(self): |
| 6498 | packed = [] |
| 6499 | packed.append(struct.pack("!B", self.version)) |
| 6500 | packed.append(struct.pack("!B", self.type)) |
| 6501 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6502 | packed.append(struct.pack("!L", self.xid)) |
| 6503 | packed.append(struct.pack("!H", self.command)) |
| 6504 | packed.append(struct.pack("!B", self.group_type)) |
| 6505 | packed.append('\x00' * 1) |
| 6506 | packed.append(struct.pack("!L", self.group_id)) |
| 6507 | packed.append(util.pack_list(self.buckets)) |
| 6508 | length = sum([len(x) for x in packed]) |
| 6509 | packed[2] = struct.pack("!H", length) |
| 6510 | return ''.join(packed) |
| 6511 | |
| 6512 | @staticmethod |
| 6513 | def unpack(buf): |
| 6514 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6515 | obj = group_add() |
| 6516 | if type(buf) == loxi.generic_util.OFReader: |
| 6517 | reader = buf |
| 6518 | else: |
| 6519 | reader = loxi.generic_util.OFReader(buf) |
| 6520 | _version = reader.read("!B")[0] |
| 6521 | assert(_version == 4) |
| 6522 | _type = reader.read("!B")[0] |
| 6523 | assert(_type == 15) |
| 6524 | _length = reader.read("!H")[0] |
| 6525 | obj.xid = reader.read("!L")[0] |
| 6526 | _command = reader.read("!H")[0] |
| 6527 | assert(_command == 0) |
| 6528 | obj.group_type = reader.read("!B")[0] |
| 6529 | reader.skip(1) |
| 6530 | obj.group_id = reader.read("!L")[0] |
| 6531 | obj.buckets = common.unpack_list_bucket(reader) |
| 6532 | return obj |
| 6533 | |
| 6534 | def __eq__(self, other): |
| 6535 | if type(self) != type(other): return False |
| 6536 | if self.version != other.version: return False |
| 6537 | if self.type != other.type: return False |
| 6538 | if self.xid != other.xid: return False |
| 6539 | if self.group_type != other.group_type: return False |
| 6540 | if self.group_id != other.group_id: return False |
| 6541 | if self.buckets != other.buckets: return False |
| 6542 | return True |
| 6543 | |
| 6544 | def __ne__(self, other): |
| 6545 | return not self.__eq__(other) |
| 6546 | |
| 6547 | def __str__(self): |
| 6548 | return self.show() |
| 6549 | |
| 6550 | def show(self): |
| 6551 | import loxi.pp |
| 6552 | return loxi.pp.pp(self) |
| 6553 | |
| 6554 | def pretty_print(self, q): |
| 6555 | q.text("group_add {") |
| 6556 | with q.group(): |
| 6557 | with q.indent(2): |
| 6558 | q.breakable() |
| 6559 | q.text("xid = "); |
| 6560 | if self.xid != None: |
| 6561 | q.text("%#x" % self.xid) |
| 6562 | else: |
| 6563 | q.text('None') |
| 6564 | q.text(","); q.breakable() |
| 6565 | q.text("group_type = "); |
| 6566 | q.text("%#x" % self.group_type) |
| 6567 | q.text(","); q.breakable() |
| 6568 | q.text("group_id = "); |
| 6569 | q.text("%#x" % self.group_id) |
| 6570 | q.text(","); q.breakable() |
| 6571 | q.text("buckets = "); |
| 6572 | q.pp(self.buckets) |
| 6573 | q.breakable() |
| 6574 | q.text('}') |
| 6575 | |
| 6576 | class group_delete(Message): |
| 6577 | version = 4 |
| 6578 | type = 15 |
| 6579 | command = 2 |
| 6580 | |
| 6581 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
| 6582 | self.xid = xid |
| 6583 | if group_type != None: |
| 6584 | self.group_type = group_type |
| 6585 | else: |
| 6586 | self.group_type = 0 |
| 6587 | if group_id != None: |
| 6588 | self.group_id = group_id |
| 6589 | else: |
| 6590 | self.group_id = 0 |
| 6591 | if buckets != None: |
| 6592 | self.buckets = buckets |
| 6593 | else: |
| 6594 | self.buckets = [] |
| 6595 | |
| 6596 | def pack(self): |
| 6597 | packed = [] |
| 6598 | packed.append(struct.pack("!B", self.version)) |
| 6599 | packed.append(struct.pack("!B", self.type)) |
| 6600 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6601 | packed.append(struct.pack("!L", self.xid)) |
| 6602 | packed.append(struct.pack("!H", self.command)) |
| 6603 | packed.append(struct.pack("!B", self.group_type)) |
| 6604 | packed.append('\x00' * 1) |
| 6605 | packed.append(struct.pack("!L", self.group_id)) |
| 6606 | packed.append(util.pack_list(self.buckets)) |
| 6607 | length = sum([len(x) for x in packed]) |
| 6608 | packed[2] = struct.pack("!H", length) |
| 6609 | return ''.join(packed) |
| 6610 | |
| 6611 | @staticmethod |
| 6612 | def unpack(buf): |
| 6613 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6614 | obj = group_delete() |
| 6615 | if type(buf) == loxi.generic_util.OFReader: |
| 6616 | reader = buf |
| 6617 | else: |
| 6618 | reader = loxi.generic_util.OFReader(buf) |
| 6619 | _version = reader.read("!B")[0] |
| 6620 | assert(_version == 4) |
| 6621 | _type = reader.read("!B")[0] |
| 6622 | assert(_type == 15) |
| 6623 | _length = reader.read("!H")[0] |
| 6624 | obj.xid = reader.read("!L")[0] |
| 6625 | _command = reader.read("!H")[0] |
| 6626 | assert(_command == 2) |
| 6627 | obj.group_type = reader.read("!B")[0] |
| 6628 | reader.skip(1) |
| 6629 | obj.group_id = reader.read("!L")[0] |
| 6630 | obj.buckets = common.unpack_list_bucket(reader) |
| 6631 | return obj |
| 6632 | |
| 6633 | def __eq__(self, other): |
| 6634 | if type(self) != type(other): return False |
| 6635 | if self.version != other.version: return False |
| 6636 | if self.type != other.type: return False |
| 6637 | if self.xid != other.xid: return False |
| 6638 | if self.group_type != other.group_type: return False |
| 6639 | if self.group_id != other.group_id: return False |
| 6640 | if self.buckets != other.buckets: return False |
| 6641 | return True |
| 6642 | |
| 6643 | def __ne__(self, other): |
| 6644 | return not self.__eq__(other) |
| 6645 | |
| 6646 | def __str__(self): |
| 6647 | return self.show() |
| 6648 | |
| 6649 | def show(self): |
| 6650 | import loxi.pp |
| 6651 | return loxi.pp.pp(self) |
| 6652 | |
| 6653 | def pretty_print(self, q): |
| 6654 | q.text("group_delete {") |
| 6655 | with q.group(): |
| 6656 | with q.indent(2): |
| 6657 | q.breakable() |
| 6658 | q.text("xid = "); |
| 6659 | if self.xid != None: |
| 6660 | q.text("%#x" % self.xid) |
| 6661 | else: |
| 6662 | q.text('None') |
| 6663 | q.text(","); q.breakable() |
| 6664 | q.text("group_type = "); |
| 6665 | q.text("%#x" % self.group_type) |
| 6666 | q.text(","); q.breakable() |
| 6667 | q.text("group_id = "); |
| 6668 | q.text("%#x" % self.group_id) |
| 6669 | q.text(","); q.breakable() |
| 6670 | q.text("buckets = "); |
| 6671 | q.pp(self.buckets) |
| 6672 | q.breakable() |
| 6673 | q.text('}') |
| 6674 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6675 | class group_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6676 | version = 4 |
| 6677 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6678 | stats_type = 7 |
| 6679 | |
| 6680 | def __init__(self, xid=None, flags=None, entries=None): |
| 6681 | self.xid = xid |
| 6682 | if flags != None: |
| 6683 | self.flags = flags |
| 6684 | else: |
| 6685 | self.flags = 0 |
| 6686 | if entries != None: |
| 6687 | self.entries = entries |
| 6688 | else: |
| 6689 | self.entries = [] |
| 6690 | |
| 6691 | def pack(self): |
| 6692 | packed = [] |
| 6693 | packed.append(struct.pack("!B", self.version)) |
| 6694 | packed.append(struct.pack("!B", self.type)) |
| 6695 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6696 | packed.append(struct.pack("!L", self.xid)) |
| 6697 | packed.append(struct.pack("!H", self.stats_type)) |
| 6698 | packed.append(struct.pack("!H", self.flags)) |
| 6699 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6700 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6701 | length = sum([len(x) for x in packed]) |
| 6702 | packed[2] = struct.pack("!H", length) |
| 6703 | return ''.join(packed) |
| 6704 | |
| 6705 | @staticmethod |
| 6706 | def unpack(buf): |
| 6707 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6708 | obj = group_desc_stats_reply() |
| 6709 | if type(buf) == loxi.generic_util.OFReader: |
| 6710 | reader = buf |
| 6711 | else: |
| 6712 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6713 | _version = reader.read("!B")[0] |
| 6714 | assert(_version == 4) |
| 6715 | _type = reader.read("!B")[0] |
| 6716 | assert(_type == 19) |
| 6717 | _length = reader.read("!H")[0] |
| 6718 | obj.xid = reader.read("!L")[0] |
| 6719 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6720 | assert(_stats_type == 7) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6721 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6722 | reader.skip(4) |
| 6723 | obj.entries = common.unpack_list_group_desc_stats_entry(reader) |
| 6724 | return obj |
| 6725 | |
| 6726 | def __eq__(self, other): |
| 6727 | if type(self) != type(other): return False |
| 6728 | if self.version != other.version: return False |
| 6729 | if self.type != other.type: return False |
| 6730 | if self.xid != other.xid: return False |
| 6731 | if self.flags != other.flags: return False |
| 6732 | if self.entries != other.entries: return False |
| 6733 | return True |
| 6734 | |
| 6735 | def __ne__(self, other): |
| 6736 | return not self.__eq__(other) |
| 6737 | |
| 6738 | def __str__(self): |
| 6739 | return self.show() |
| 6740 | |
| 6741 | def show(self): |
| 6742 | import loxi.pp |
| 6743 | return loxi.pp.pp(self) |
| 6744 | |
| 6745 | def pretty_print(self, q): |
| 6746 | q.text("group_desc_stats_reply {") |
| 6747 | with q.group(): |
| 6748 | with q.indent(2): |
| 6749 | q.breakable() |
| 6750 | q.text("xid = "); |
| 6751 | if self.xid != None: |
| 6752 | q.text("%#x" % self.xid) |
| 6753 | else: |
| 6754 | q.text('None') |
| 6755 | q.text(","); q.breakable() |
| 6756 | q.text("flags = "); |
| 6757 | q.text("%#x" % self.flags) |
| 6758 | q.text(","); q.breakable() |
| 6759 | q.text("entries = "); |
| 6760 | q.pp(self.entries) |
| 6761 | q.breakable() |
| 6762 | q.text('}') |
| 6763 | |
| 6764 | class group_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6765 | version = 4 |
| 6766 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6767 | stats_type = 7 |
| 6768 | |
| 6769 | def __init__(self, xid=None, flags=None): |
| 6770 | self.xid = xid |
| 6771 | if flags != None: |
| 6772 | self.flags = flags |
| 6773 | else: |
| 6774 | self.flags = 0 |
| 6775 | |
| 6776 | def pack(self): |
| 6777 | packed = [] |
| 6778 | packed.append(struct.pack("!B", self.version)) |
| 6779 | packed.append(struct.pack("!B", self.type)) |
| 6780 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6781 | packed.append(struct.pack("!L", self.xid)) |
| 6782 | packed.append(struct.pack("!H", self.stats_type)) |
| 6783 | packed.append(struct.pack("!H", self.flags)) |
| 6784 | packed.append('\x00' * 4) |
| 6785 | length = sum([len(x) for x in packed]) |
| 6786 | packed[2] = struct.pack("!H", length) |
| 6787 | return ''.join(packed) |
| 6788 | |
| 6789 | @staticmethod |
| 6790 | def unpack(buf): |
| 6791 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6792 | obj = group_desc_stats_request() |
| 6793 | if type(buf) == loxi.generic_util.OFReader: |
| 6794 | reader = buf |
| 6795 | else: |
| 6796 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6797 | _version = reader.read("!B")[0] |
| 6798 | assert(_version == 4) |
| 6799 | _type = reader.read("!B")[0] |
| 6800 | assert(_type == 18) |
| 6801 | _length = reader.read("!H")[0] |
| 6802 | obj.xid = reader.read("!L")[0] |
| 6803 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6804 | assert(_stats_type == 7) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6805 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6806 | reader.skip(4) |
| 6807 | return obj |
| 6808 | |
| 6809 | def __eq__(self, other): |
| 6810 | if type(self) != type(other): return False |
| 6811 | if self.version != other.version: return False |
| 6812 | if self.type != other.type: return False |
| 6813 | if self.xid != other.xid: return False |
| 6814 | if self.flags != other.flags: return False |
| 6815 | return True |
| 6816 | |
| 6817 | def __ne__(self, other): |
| 6818 | return not self.__eq__(other) |
| 6819 | |
| 6820 | def __str__(self): |
| 6821 | return self.show() |
| 6822 | |
| 6823 | def show(self): |
| 6824 | import loxi.pp |
| 6825 | return loxi.pp.pp(self) |
| 6826 | |
| 6827 | def pretty_print(self, q): |
| 6828 | q.text("group_desc_stats_request {") |
| 6829 | with q.group(): |
| 6830 | with q.indent(2): |
| 6831 | q.breakable() |
| 6832 | q.text("xid = "); |
| 6833 | if self.xid != None: |
| 6834 | q.text("%#x" % self.xid) |
| 6835 | else: |
| 6836 | q.text('None') |
| 6837 | q.text(","); q.breakable() |
| 6838 | q.text("flags = "); |
| 6839 | q.text("%#x" % self.flags) |
| 6840 | q.breakable() |
| 6841 | q.text('}') |
| 6842 | |
| 6843 | class group_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6844 | version = 4 |
| 6845 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6846 | stats_type = 8 |
| 6847 | |
| 6848 | def __init__(self, xid=None, flags=None, types=None, capabilities=None, max_groups_all=None, max_groups_select=None, max_groups_indirect=None, max_groups_ff=None, actions_all=None, actions_select=None, actions_indirect=None, actions_ff=None): |
| 6849 | self.xid = xid |
| 6850 | if flags != None: |
| 6851 | self.flags = flags |
| 6852 | else: |
| 6853 | self.flags = 0 |
| 6854 | if types != None: |
| 6855 | self.types = types |
| 6856 | else: |
| 6857 | self.types = 0 |
| 6858 | if capabilities != None: |
| 6859 | self.capabilities = capabilities |
| 6860 | else: |
| 6861 | self.capabilities = 0 |
| 6862 | if max_groups_all != None: |
| 6863 | self.max_groups_all = max_groups_all |
| 6864 | else: |
| 6865 | self.max_groups_all = 0 |
| 6866 | if max_groups_select != None: |
| 6867 | self.max_groups_select = max_groups_select |
| 6868 | else: |
| 6869 | self.max_groups_select = 0 |
| 6870 | if max_groups_indirect != None: |
| 6871 | self.max_groups_indirect = max_groups_indirect |
| 6872 | else: |
| 6873 | self.max_groups_indirect = 0 |
| 6874 | if max_groups_ff != None: |
| 6875 | self.max_groups_ff = max_groups_ff |
| 6876 | else: |
| 6877 | self.max_groups_ff = 0 |
| 6878 | if actions_all != None: |
| 6879 | self.actions_all = actions_all |
| 6880 | else: |
| 6881 | self.actions_all = 0 |
| 6882 | if actions_select != None: |
| 6883 | self.actions_select = actions_select |
| 6884 | else: |
| 6885 | self.actions_select = 0 |
| 6886 | if actions_indirect != None: |
| 6887 | self.actions_indirect = actions_indirect |
| 6888 | else: |
| 6889 | self.actions_indirect = 0 |
| 6890 | if actions_ff != None: |
| 6891 | self.actions_ff = actions_ff |
| 6892 | else: |
| 6893 | self.actions_ff = 0 |
| 6894 | |
| 6895 | def pack(self): |
| 6896 | packed = [] |
| 6897 | packed.append(struct.pack("!B", self.version)) |
| 6898 | packed.append(struct.pack("!B", self.type)) |
| 6899 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6900 | packed.append(struct.pack("!L", self.xid)) |
| 6901 | packed.append(struct.pack("!H", self.stats_type)) |
| 6902 | packed.append(struct.pack("!H", self.flags)) |
| 6903 | packed.append('\x00' * 4) |
| 6904 | packed.append(struct.pack("!L", self.types)) |
| 6905 | packed.append(struct.pack("!L", self.capabilities)) |
| 6906 | packed.append(struct.pack("!L", self.max_groups_all)) |
| 6907 | packed.append(struct.pack("!L", self.max_groups_select)) |
| 6908 | packed.append(struct.pack("!L", self.max_groups_indirect)) |
| 6909 | packed.append(struct.pack("!L", self.max_groups_ff)) |
| 6910 | packed.append(struct.pack("!L", self.actions_all)) |
| 6911 | packed.append(struct.pack("!L", self.actions_select)) |
| 6912 | packed.append(struct.pack("!L", self.actions_indirect)) |
| 6913 | packed.append(struct.pack("!L", self.actions_ff)) |
| 6914 | length = sum([len(x) for x in packed]) |
| 6915 | packed[2] = struct.pack("!H", length) |
| 6916 | return ''.join(packed) |
| 6917 | |
| 6918 | @staticmethod |
| 6919 | def unpack(buf): |
| 6920 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6921 | obj = group_features_stats_reply() |
| 6922 | if type(buf) == loxi.generic_util.OFReader: |
| 6923 | reader = buf |
| 6924 | else: |
| 6925 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6926 | _version = reader.read("!B")[0] |
| 6927 | assert(_version == 4) |
| 6928 | _type = reader.read("!B")[0] |
| 6929 | assert(_type == 19) |
| 6930 | _length = reader.read("!H")[0] |
| 6931 | obj.xid = reader.read("!L")[0] |
| 6932 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6933 | assert(_stats_type == 8) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6934 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6935 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6936 | obj.types = reader.read("!L")[0] |
| 6937 | obj.capabilities = reader.read("!L")[0] |
| 6938 | obj.max_groups_all = reader.read("!L")[0] |
| 6939 | obj.max_groups_select = reader.read("!L")[0] |
| 6940 | obj.max_groups_indirect = reader.read("!L")[0] |
| 6941 | obj.max_groups_ff = reader.read("!L")[0] |
| 6942 | obj.actions_all = reader.read("!L")[0] |
| 6943 | obj.actions_select = reader.read("!L")[0] |
| 6944 | obj.actions_indirect = reader.read("!L")[0] |
| 6945 | obj.actions_ff = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6946 | return obj |
| 6947 | |
| 6948 | def __eq__(self, other): |
| 6949 | if type(self) != type(other): return False |
| 6950 | if self.version != other.version: return False |
| 6951 | if self.type != other.type: return False |
| 6952 | if self.xid != other.xid: return False |
| 6953 | if self.flags != other.flags: return False |
| 6954 | if self.types != other.types: return False |
| 6955 | if self.capabilities != other.capabilities: return False |
| 6956 | if self.max_groups_all != other.max_groups_all: return False |
| 6957 | if self.max_groups_select != other.max_groups_select: return False |
| 6958 | if self.max_groups_indirect != other.max_groups_indirect: return False |
| 6959 | if self.max_groups_ff != other.max_groups_ff: return False |
| 6960 | if self.actions_all != other.actions_all: return False |
| 6961 | if self.actions_select != other.actions_select: return False |
| 6962 | if self.actions_indirect != other.actions_indirect: return False |
| 6963 | if self.actions_ff != other.actions_ff: return False |
| 6964 | return True |
| 6965 | |
| 6966 | def __ne__(self, other): |
| 6967 | return not self.__eq__(other) |
| 6968 | |
| 6969 | def __str__(self): |
| 6970 | return self.show() |
| 6971 | |
| 6972 | def show(self): |
| 6973 | import loxi.pp |
| 6974 | return loxi.pp.pp(self) |
| 6975 | |
| 6976 | def pretty_print(self, q): |
| 6977 | q.text("group_features_stats_reply {") |
| 6978 | with q.group(): |
| 6979 | with q.indent(2): |
| 6980 | q.breakable() |
| 6981 | q.text("xid = "); |
| 6982 | if self.xid != None: |
| 6983 | q.text("%#x" % self.xid) |
| 6984 | else: |
| 6985 | q.text('None') |
| 6986 | q.text(","); q.breakable() |
| 6987 | q.text("flags = "); |
| 6988 | q.text("%#x" % self.flags) |
| 6989 | q.text(","); q.breakable() |
| 6990 | q.text("types = "); |
| 6991 | q.text("%#x" % self.types) |
| 6992 | q.text(","); q.breakable() |
| 6993 | q.text("capabilities = "); |
| 6994 | q.text("%#x" % self.capabilities) |
| 6995 | q.text(","); q.breakable() |
| 6996 | q.text("max_groups_all = "); |
| 6997 | q.text("%#x" % self.max_groups_all) |
| 6998 | q.text(","); q.breakable() |
| 6999 | q.text("max_groups_select = "); |
| 7000 | q.text("%#x" % self.max_groups_select) |
| 7001 | q.text(","); q.breakable() |
| 7002 | q.text("max_groups_indirect = "); |
| 7003 | q.text("%#x" % self.max_groups_indirect) |
| 7004 | q.text(","); q.breakable() |
| 7005 | q.text("max_groups_ff = "); |
| 7006 | q.text("%#x" % self.max_groups_ff) |
| 7007 | q.text(","); q.breakable() |
| 7008 | q.text("actions_all = "); |
| 7009 | q.text("%#x" % self.actions_all) |
| 7010 | q.text(","); q.breakable() |
| 7011 | q.text("actions_select = "); |
| 7012 | q.text("%#x" % self.actions_select) |
| 7013 | q.text(","); q.breakable() |
| 7014 | q.text("actions_indirect = "); |
| 7015 | q.text("%#x" % self.actions_indirect) |
| 7016 | q.text(","); q.breakable() |
| 7017 | q.text("actions_ff = "); |
| 7018 | q.text("%#x" % self.actions_ff) |
| 7019 | q.breakable() |
| 7020 | q.text('}') |
| 7021 | |
| 7022 | class group_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7023 | version = 4 |
| 7024 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7025 | stats_type = 8 |
| 7026 | |
| 7027 | def __init__(self, xid=None, flags=None): |
| 7028 | self.xid = xid |
| 7029 | if flags != None: |
| 7030 | self.flags = flags |
| 7031 | else: |
| 7032 | self.flags = 0 |
| 7033 | |
| 7034 | def pack(self): |
| 7035 | packed = [] |
| 7036 | packed.append(struct.pack("!B", self.version)) |
| 7037 | packed.append(struct.pack("!B", self.type)) |
| 7038 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7039 | packed.append(struct.pack("!L", self.xid)) |
| 7040 | packed.append(struct.pack("!H", self.stats_type)) |
| 7041 | packed.append(struct.pack("!H", self.flags)) |
| 7042 | packed.append('\x00' * 4) |
| 7043 | length = sum([len(x) for x in packed]) |
| 7044 | packed[2] = struct.pack("!H", length) |
| 7045 | return ''.join(packed) |
| 7046 | |
| 7047 | @staticmethod |
| 7048 | def unpack(buf): |
| 7049 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7050 | obj = group_features_stats_request() |
| 7051 | if type(buf) == loxi.generic_util.OFReader: |
| 7052 | reader = buf |
| 7053 | else: |
| 7054 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7055 | _version = reader.read("!B")[0] |
| 7056 | assert(_version == 4) |
| 7057 | _type = reader.read("!B")[0] |
| 7058 | assert(_type == 18) |
| 7059 | _length = reader.read("!H")[0] |
| 7060 | obj.xid = reader.read("!L")[0] |
| 7061 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7062 | assert(_stats_type == 8) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7063 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7064 | reader.skip(4) |
| 7065 | return obj |
| 7066 | |
| 7067 | def __eq__(self, other): |
| 7068 | if type(self) != type(other): return False |
| 7069 | if self.version != other.version: return False |
| 7070 | if self.type != other.type: return False |
| 7071 | if self.xid != other.xid: return False |
| 7072 | if self.flags != other.flags: return False |
| 7073 | return True |
| 7074 | |
| 7075 | def __ne__(self, other): |
| 7076 | return not self.__eq__(other) |
| 7077 | |
| 7078 | def __str__(self): |
| 7079 | return self.show() |
| 7080 | |
| 7081 | def show(self): |
| 7082 | import loxi.pp |
| 7083 | return loxi.pp.pp(self) |
| 7084 | |
| 7085 | def pretty_print(self, q): |
| 7086 | q.text("group_features_stats_request {") |
| 7087 | with q.group(): |
| 7088 | with q.indent(2): |
| 7089 | q.breakable() |
| 7090 | q.text("xid = "); |
| 7091 | if self.xid != None: |
| 7092 | q.text("%#x" % self.xid) |
| 7093 | else: |
| 7094 | q.text('None') |
| 7095 | q.text(","); q.breakable() |
| 7096 | q.text("flags = "); |
| 7097 | q.text("%#x" % self.flags) |
| 7098 | q.breakable() |
| 7099 | q.text('}') |
| 7100 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7101 | class group_mod_failed_error_msg(Message): |
| 7102 | version = 4 |
| 7103 | type = 1 |
| 7104 | err_type = 6 |
| 7105 | |
| 7106 | def __init__(self, xid=None, code=None, data=None): |
| 7107 | self.xid = xid |
| 7108 | if code != None: |
| 7109 | self.code = code |
| 7110 | else: |
| 7111 | self.code = 0 |
| 7112 | if data != None: |
| 7113 | self.data = data |
| 7114 | else: |
| 7115 | self.data = '' |
| 7116 | |
| 7117 | def pack(self): |
| 7118 | packed = [] |
| 7119 | packed.append(struct.pack("!B", self.version)) |
| 7120 | packed.append(struct.pack("!B", self.type)) |
| 7121 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7122 | packed.append(struct.pack("!L", self.xid)) |
| 7123 | packed.append(struct.pack("!H", self.err_type)) |
| 7124 | packed.append(struct.pack("!H", self.code)) |
| 7125 | packed.append(self.data) |
| 7126 | length = sum([len(x) for x in packed]) |
| 7127 | packed[2] = struct.pack("!H", length) |
| 7128 | return ''.join(packed) |
| 7129 | |
| 7130 | @staticmethod |
| 7131 | def unpack(buf): |
| 7132 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7133 | obj = group_mod_failed_error_msg() |
| 7134 | if type(buf) == loxi.generic_util.OFReader: |
| 7135 | reader = buf |
| 7136 | else: |
| 7137 | reader = loxi.generic_util.OFReader(buf) |
| 7138 | _version = reader.read("!B")[0] |
| 7139 | assert(_version == 4) |
| 7140 | _type = reader.read("!B")[0] |
| 7141 | assert(_type == 1) |
| 7142 | _length = reader.read("!H")[0] |
| 7143 | obj.xid = reader.read("!L")[0] |
| 7144 | _err_type = reader.read("!H")[0] |
| 7145 | assert(_err_type == 6) |
| 7146 | obj.code = reader.read("!H")[0] |
| 7147 | obj.data = str(reader.read_all()) |
| 7148 | return obj |
| 7149 | |
| 7150 | def __eq__(self, other): |
| 7151 | if type(self) != type(other): return False |
| 7152 | if self.version != other.version: return False |
| 7153 | if self.type != other.type: return False |
| 7154 | if self.xid != other.xid: return False |
| 7155 | if self.code != other.code: return False |
| 7156 | if self.data != other.data: return False |
| 7157 | return True |
| 7158 | |
| 7159 | def __ne__(self, other): |
| 7160 | return not self.__eq__(other) |
| 7161 | |
| 7162 | def __str__(self): |
| 7163 | return self.show() |
| 7164 | |
| 7165 | def show(self): |
| 7166 | import loxi.pp |
| 7167 | return loxi.pp.pp(self) |
| 7168 | |
| 7169 | def pretty_print(self, q): |
| 7170 | q.text("group_mod_failed_error_msg {") |
| 7171 | with q.group(): |
| 7172 | with q.indent(2): |
| 7173 | q.breakable() |
| 7174 | q.text("xid = "); |
| 7175 | if self.xid != None: |
| 7176 | q.text("%#x" % self.xid) |
| 7177 | else: |
| 7178 | q.text('None') |
| 7179 | q.text(","); q.breakable() |
| 7180 | q.text("code = "); |
| 7181 | q.text("%#x" % self.code) |
| 7182 | q.text(","); q.breakable() |
| 7183 | q.text("data = "); |
| 7184 | q.pp(self.data) |
| 7185 | q.breakable() |
| 7186 | q.text('}') |
| 7187 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 7188 | class group_modify(Message): |
| 7189 | version = 4 |
| 7190 | type = 15 |
| 7191 | command = 1 |
| 7192 | |
| 7193 | def __init__(self, xid=None, group_type=None, group_id=None, buckets=None): |
| 7194 | self.xid = xid |
| 7195 | if group_type != None: |
| 7196 | self.group_type = group_type |
| 7197 | else: |
| 7198 | self.group_type = 0 |
| 7199 | if group_id != None: |
| 7200 | self.group_id = group_id |
| 7201 | else: |
| 7202 | self.group_id = 0 |
| 7203 | if buckets != None: |
| 7204 | self.buckets = buckets |
| 7205 | else: |
| 7206 | self.buckets = [] |
| 7207 | |
| 7208 | def pack(self): |
| 7209 | packed = [] |
| 7210 | packed.append(struct.pack("!B", self.version)) |
| 7211 | packed.append(struct.pack("!B", self.type)) |
| 7212 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7213 | packed.append(struct.pack("!L", self.xid)) |
| 7214 | packed.append(struct.pack("!H", self.command)) |
| 7215 | packed.append(struct.pack("!B", self.group_type)) |
| 7216 | packed.append('\x00' * 1) |
| 7217 | packed.append(struct.pack("!L", self.group_id)) |
| 7218 | packed.append(util.pack_list(self.buckets)) |
| 7219 | length = sum([len(x) for x in packed]) |
| 7220 | packed[2] = struct.pack("!H", length) |
| 7221 | return ''.join(packed) |
| 7222 | |
| 7223 | @staticmethod |
| 7224 | def unpack(buf): |
| 7225 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7226 | obj = group_modify() |
| 7227 | if type(buf) == loxi.generic_util.OFReader: |
| 7228 | reader = buf |
| 7229 | else: |
| 7230 | reader = loxi.generic_util.OFReader(buf) |
| 7231 | _version = reader.read("!B")[0] |
| 7232 | assert(_version == 4) |
| 7233 | _type = reader.read("!B")[0] |
| 7234 | assert(_type == 15) |
| 7235 | _length = reader.read("!H")[0] |
| 7236 | obj.xid = reader.read("!L")[0] |
| 7237 | _command = reader.read("!H")[0] |
| 7238 | assert(_command == 1) |
| 7239 | obj.group_type = reader.read("!B")[0] |
| 7240 | reader.skip(1) |
| 7241 | obj.group_id = reader.read("!L")[0] |
| 7242 | obj.buckets = common.unpack_list_bucket(reader) |
| 7243 | return obj |
| 7244 | |
| 7245 | def __eq__(self, other): |
| 7246 | if type(self) != type(other): return False |
| 7247 | if self.version != other.version: return False |
| 7248 | if self.type != other.type: return False |
| 7249 | if self.xid != other.xid: return False |
| 7250 | if self.group_type != other.group_type: return False |
| 7251 | if self.group_id != other.group_id: return False |
| 7252 | if self.buckets != other.buckets: return False |
| 7253 | return True |
| 7254 | |
| 7255 | def __ne__(self, other): |
| 7256 | return not self.__eq__(other) |
| 7257 | |
| 7258 | def __str__(self): |
| 7259 | return self.show() |
| 7260 | |
| 7261 | def show(self): |
| 7262 | import loxi.pp |
| 7263 | return loxi.pp.pp(self) |
| 7264 | |
| 7265 | def pretty_print(self, q): |
| 7266 | q.text("group_modify {") |
| 7267 | with q.group(): |
| 7268 | with q.indent(2): |
| 7269 | q.breakable() |
| 7270 | q.text("xid = "); |
| 7271 | if self.xid != None: |
| 7272 | q.text("%#x" % self.xid) |
| 7273 | else: |
| 7274 | q.text('None') |
| 7275 | q.text(","); q.breakable() |
| 7276 | q.text("group_type = "); |
| 7277 | q.text("%#x" % self.group_type) |
| 7278 | q.text(","); q.breakable() |
| 7279 | q.text("group_id = "); |
| 7280 | q.text("%#x" % self.group_id) |
| 7281 | q.text(","); q.breakable() |
| 7282 | q.text("buckets = "); |
| 7283 | q.pp(self.buckets) |
| 7284 | q.breakable() |
| 7285 | q.text('}') |
| 7286 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7287 | class group_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7288 | version = 4 |
| 7289 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7290 | stats_type = 6 |
| 7291 | |
| 7292 | def __init__(self, xid=None, flags=None, entries=None): |
| 7293 | self.xid = xid |
| 7294 | if flags != None: |
| 7295 | self.flags = flags |
| 7296 | else: |
| 7297 | self.flags = 0 |
| 7298 | if entries != None: |
| 7299 | self.entries = entries |
| 7300 | else: |
| 7301 | self.entries = [] |
| 7302 | |
| 7303 | def pack(self): |
| 7304 | packed = [] |
| 7305 | packed.append(struct.pack("!B", self.version)) |
| 7306 | packed.append(struct.pack("!B", self.type)) |
| 7307 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7308 | packed.append(struct.pack("!L", self.xid)) |
| 7309 | packed.append(struct.pack("!H", self.stats_type)) |
| 7310 | packed.append(struct.pack("!H", self.flags)) |
| 7311 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7312 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7313 | length = sum([len(x) for x in packed]) |
| 7314 | packed[2] = struct.pack("!H", length) |
| 7315 | return ''.join(packed) |
| 7316 | |
| 7317 | @staticmethod |
| 7318 | def unpack(buf): |
| 7319 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7320 | obj = group_stats_reply() |
| 7321 | if type(buf) == loxi.generic_util.OFReader: |
| 7322 | reader = buf |
| 7323 | else: |
| 7324 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7325 | _version = reader.read("!B")[0] |
| 7326 | assert(_version == 4) |
| 7327 | _type = reader.read("!B")[0] |
| 7328 | assert(_type == 19) |
| 7329 | _length = reader.read("!H")[0] |
| 7330 | obj.xid = reader.read("!L")[0] |
| 7331 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7332 | assert(_stats_type == 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7333 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7334 | reader.skip(4) |
| 7335 | obj.entries = common.unpack_list_group_stats_entry(reader) |
| 7336 | return obj |
| 7337 | |
| 7338 | def __eq__(self, other): |
| 7339 | if type(self) != type(other): return False |
| 7340 | if self.version != other.version: return False |
| 7341 | if self.type != other.type: return False |
| 7342 | if self.xid != other.xid: return False |
| 7343 | if self.flags != other.flags: return False |
| 7344 | if self.entries != other.entries: return False |
| 7345 | return True |
| 7346 | |
| 7347 | def __ne__(self, other): |
| 7348 | return not self.__eq__(other) |
| 7349 | |
| 7350 | def __str__(self): |
| 7351 | return self.show() |
| 7352 | |
| 7353 | def show(self): |
| 7354 | import loxi.pp |
| 7355 | return loxi.pp.pp(self) |
| 7356 | |
| 7357 | def pretty_print(self, q): |
| 7358 | q.text("group_stats_reply {") |
| 7359 | with q.group(): |
| 7360 | with q.indent(2): |
| 7361 | q.breakable() |
| 7362 | q.text("xid = "); |
| 7363 | if self.xid != None: |
| 7364 | q.text("%#x" % self.xid) |
| 7365 | else: |
| 7366 | q.text('None') |
| 7367 | q.text(","); q.breakable() |
| 7368 | q.text("flags = "); |
| 7369 | q.text("%#x" % self.flags) |
| 7370 | q.text(","); q.breakable() |
| 7371 | q.text("entries = "); |
| 7372 | q.pp(self.entries) |
| 7373 | q.breakable() |
| 7374 | q.text('}') |
| 7375 | |
| 7376 | class group_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7377 | version = 4 |
| 7378 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7379 | stats_type = 6 |
| 7380 | |
| 7381 | def __init__(self, xid=None, flags=None, group_id=None): |
| 7382 | self.xid = xid |
| 7383 | if flags != None: |
| 7384 | self.flags = flags |
| 7385 | else: |
| 7386 | self.flags = 0 |
| 7387 | if group_id != None: |
| 7388 | self.group_id = group_id |
| 7389 | else: |
| 7390 | self.group_id = 0 |
| 7391 | |
| 7392 | def pack(self): |
| 7393 | packed = [] |
| 7394 | packed.append(struct.pack("!B", self.version)) |
| 7395 | packed.append(struct.pack("!B", self.type)) |
| 7396 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7397 | packed.append(struct.pack("!L", self.xid)) |
| 7398 | packed.append(struct.pack("!H", self.stats_type)) |
| 7399 | packed.append(struct.pack("!H", self.flags)) |
| 7400 | packed.append('\x00' * 4) |
| 7401 | packed.append(struct.pack("!L", self.group_id)) |
| 7402 | packed.append('\x00' * 4) |
| 7403 | length = sum([len(x) for x in packed]) |
| 7404 | packed[2] = struct.pack("!H", length) |
| 7405 | return ''.join(packed) |
| 7406 | |
| 7407 | @staticmethod |
| 7408 | def unpack(buf): |
| 7409 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7410 | obj = group_stats_request() |
| 7411 | if type(buf) == loxi.generic_util.OFReader: |
| 7412 | reader = buf |
| 7413 | else: |
| 7414 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7415 | _version = reader.read("!B")[0] |
| 7416 | assert(_version == 4) |
| 7417 | _type = reader.read("!B")[0] |
| 7418 | assert(_type == 18) |
| 7419 | _length = reader.read("!H")[0] |
| 7420 | obj.xid = reader.read("!L")[0] |
| 7421 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7422 | assert(_stats_type == 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7423 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7424 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7425 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7426 | reader.skip(4) |
| 7427 | return obj |
| 7428 | |
| 7429 | def __eq__(self, other): |
| 7430 | if type(self) != type(other): return False |
| 7431 | if self.version != other.version: return False |
| 7432 | if self.type != other.type: return False |
| 7433 | if self.xid != other.xid: return False |
| 7434 | if self.flags != other.flags: return False |
| 7435 | if self.group_id != other.group_id: return False |
| 7436 | return True |
| 7437 | |
| 7438 | def __ne__(self, other): |
| 7439 | return not self.__eq__(other) |
| 7440 | |
| 7441 | def __str__(self): |
| 7442 | return self.show() |
| 7443 | |
| 7444 | def show(self): |
| 7445 | import loxi.pp |
| 7446 | return loxi.pp.pp(self) |
| 7447 | |
| 7448 | def pretty_print(self, q): |
| 7449 | q.text("group_stats_request {") |
| 7450 | with q.group(): |
| 7451 | with q.indent(2): |
| 7452 | q.breakable() |
| 7453 | q.text("xid = "); |
| 7454 | if self.xid != None: |
| 7455 | q.text("%#x" % self.xid) |
| 7456 | else: |
| 7457 | q.text('None') |
| 7458 | q.text(","); q.breakable() |
| 7459 | q.text("flags = "); |
| 7460 | q.text("%#x" % self.flags) |
| 7461 | q.text(","); q.breakable() |
| 7462 | q.text("group_id = "); |
| 7463 | q.text("%#x" % self.group_id) |
| 7464 | q.breakable() |
| 7465 | q.text('}') |
| 7466 | |
| 7467 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7468 | version = 4 |
| 7469 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7470 | |
| 7471 | def __init__(self, xid=None, elements=None): |
| 7472 | self.xid = xid |
| 7473 | if elements != None: |
| 7474 | self.elements = elements |
| 7475 | else: |
| 7476 | self.elements = [] |
| 7477 | |
| 7478 | def pack(self): |
| 7479 | packed = [] |
| 7480 | packed.append(struct.pack("!B", self.version)) |
| 7481 | packed.append(struct.pack("!B", self.type)) |
| 7482 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7483 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7484 | packed.append(util.pack_list(self.elements)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7485 | length = sum([len(x) for x in packed]) |
| 7486 | packed[2] = struct.pack("!H", length) |
| 7487 | return ''.join(packed) |
| 7488 | |
| 7489 | @staticmethod |
| 7490 | def unpack(buf): |
| 7491 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7492 | obj = hello() |
| 7493 | if type(buf) == loxi.generic_util.OFReader: |
| 7494 | reader = buf |
| 7495 | else: |
| 7496 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7497 | _version = reader.read("!B")[0] |
| 7498 | assert(_version == 4) |
| 7499 | _type = reader.read("!B")[0] |
| 7500 | assert(_type == 0) |
| 7501 | _length = reader.read("!H")[0] |
| 7502 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7503 | obj.elements = common.unpack_list_hello_elem(reader) |
| 7504 | return obj |
| 7505 | |
| 7506 | def __eq__(self, other): |
| 7507 | if type(self) != type(other): return False |
| 7508 | if self.version != other.version: return False |
| 7509 | if self.type != other.type: return False |
| 7510 | if self.xid != other.xid: return False |
| 7511 | if self.elements != other.elements: return False |
| 7512 | return True |
| 7513 | |
| 7514 | def __ne__(self, other): |
| 7515 | return not self.__eq__(other) |
| 7516 | |
| 7517 | def __str__(self): |
| 7518 | return self.show() |
| 7519 | |
| 7520 | def show(self): |
| 7521 | import loxi.pp |
| 7522 | return loxi.pp.pp(self) |
| 7523 | |
| 7524 | def pretty_print(self, q): |
| 7525 | q.text("hello {") |
| 7526 | with q.group(): |
| 7527 | with q.indent(2): |
| 7528 | q.breakable() |
| 7529 | q.text("xid = "); |
| 7530 | if self.xid != None: |
| 7531 | q.text("%#x" % self.xid) |
| 7532 | else: |
| 7533 | q.text('None') |
| 7534 | q.text(","); q.breakable() |
| 7535 | q.text("elements = "); |
| 7536 | q.pp(self.elements) |
| 7537 | q.breakable() |
| 7538 | q.text('}') |
| 7539 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7540 | class hello_failed_error_msg(Message): |
| 7541 | version = 4 |
| 7542 | type = 1 |
| 7543 | err_type = 0 |
| 7544 | |
| 7545 | def __init__(self, xid=None, code=None, data=None): |
| 7546 | self.xid = xid |
| 7547 | if code != None: |
| 7548 | self.code = code |
| 7549 | else: |
| 7550 | self.code = 0 |
| 7551 | if data != None: |
| 7552 | self.data = data |
| 7553 | else: |
| 7554 | self.data = '' |
| 7555 | |
| 7556 | def pack(self): |
| 7557 | packed = [] |
| 7558 | packed.append(struct.pack("!B", self.version)) |
| 7559 | packed.append(struct.pack("!B", self.type)) |
| 7560 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7561 | packed.append(struct.pack("!L", self.xid)) |
| 7562 | packed.append(struct.pack("!H", self.err_type)) |
| 7563 | packed.append(struct.pack("!H", self.code)) |
| 7564 | packed.append(self.data) |
| 7565 | length = sum([len(x) for x in packed]) |
| 7566 | packed[2] = struct.pack("!H", length) |
| 7567 | return ''.join(packed) |
| 7568 | |
| 7569 | @staticmethod |
| 7570 | def unpack(buf): |
| 7571 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7572 | obj = hello_failed_error_msg() |
| 7573 | if type(buf) == loxi.generic_util.OFReader: |
| 7574 | reader = buf |
| 7575 | else: |
| 7576 | reader = loxi.generic_util.OFReader(buf) |
| 7577 | _version = reader.read("!B")[0] |
| 7578 | assert(_version == 4) |
| 7579 | _type = reader.read("!B")[0] |
| 7580 | assert(_type == 1) |
| 7581 | _length = reader.read("!H")[0] |
| 7582 | obj.xid = reader.read("!L")[0] |
| 7583 | _err_type = reader.read("!H")[0] |
| 7584 | assert(_err_type == 0) |
| 7585 | obj.code = reader.read("!H")[0] |
| 7586 | obj.data = str(reader.read_all()) |
| 7587 | return obj |
| 7588 | |
| 7589 | def __eq__(self, other): |
| 7590 | if type(self) != type(other): return False |
| 7591 | if self.version != other.version: return False |
| 7592 | if self.type != other.type: return False |
| 7593 | if self.xid != other.xid: return False |
| 7594 | if self.code != other.code: return False |
| 7595 | if self.data != other.data: return False |
| 7596 | return True |
| 7597 | |
| 7598 | def __ne__(self, other): |
| 7599 | return not self.__eq__(other) |
| 7600 | |
| 7601 | def __str__(self): |
| 7602 | return self.show() |
| 7603 | |
| 7604 | def show(self): |
| 7605 | import loxi.pp |
| 7606 | return loxi.pp.pp(self) |
| 7607 | |
| 7608 | def pretty_print(self, q): |
| 7609 | q.text("hello_failed_error_msg {") |
| 7610 | with q.group(): |
| 7611 | with q.indent(2): |
| 7612 | q.breakable() |
| 7613 | q.text("xid = "); |
| 7614 | if self.xid != None: |
| 7615 | q.text("%#x" % self.xid) |
| 7616 | else: |
| 7617 | q.text('None') |
| 7618 | q.text(","); q.breakable() |
| 7619 | q.text("code = "); |
| 7620 | q.text("%#x" % self.code) |
| 7621 | q.text(","); q.breakable() |
| 7622 | q.text("data = "); |
| 7623 | q.pp(self.data) |
| 7624 | q.breakable() |
| 7625 | q.text('}') |
| 7626 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7627 | class meter_config_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7628 | version = 4 |
| 7629 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7630 | stats_type = 10 |
| 7631 | |
| 7632 | def __init__(self, xid=None, flags=None, entries=None): |
| 7633 | self.xid = xid |
| 7634 | if flags != None: |
| 7635 | self.flags = flags |
| 7636 | else: |
| 7637 | self.flags = 0 |
| 7638 | if entries != None: |
| 7639 | self.entries = entries |
| 7640 | else: |
| 7641 | self.entries = [] |
| 7642 | |
| 7643 | def pack(self): |
| 7644 | packed = [] |
| 7645 | packed.append(struct.pack("!B", self.version)) |
| 7646 | packed.append(struct.pack("!B", self.type)) |
| 7647 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7648 | packed.append(struct.pack("!L", self.xid)) |
| 7649 | packed.append(struct.pack("!H", self.stats_type)) |
| 7650 | packed.append(struct.pack("!H", self.flags)) |
| 7651 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7652 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7653 | length = sum([len(x) for x in packed]) |
| 7654 | packed[2] = struct.pack("!H", length) |
| 7655 | return ''.join(packed) |
| 7656 | |
| 7657 | @staticmethod |
| 7658 | def unpack(buf): |
| 7659 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7660 | obj = meter_config_stats_reply() |
| 7661 | if type(buf) == loxi.generic_util.OFReader: |
| 7662 | reader = buf |
| 7663 | else: |
| 7664 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7665 | _version = reader.read("!B")[0] |
| 7666 | assert(_version == 4) |
| 7667 | _type = reader.read("!B")[0] |
| 7668 | assert(_type == 19) |
| 7669 | _length = reader.read("!H")[0] |
| 7670 | obj.xid = reader.read("!L")[0] |
| 7671 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7672 | assert(_stats_type == 10) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7673 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7674 | reader.skip(4) |
| 7675 | obj.entries = meter_band.unpack_list(reader) |
| 7676 | return obj |
| 7677 | |
| 7678 | def __eq__(self, other): |
| 7679 | if type(self) != type(other): return False |
| 7680 | if self.version != other.version: return False |
| 7681 | if self.type != other.type: return False |
| 7682 | if self.xid != other.xid: return False |
| 7683 | if self.flags != other.flags: return False |
| 7684 | if self.entries != other.entries: return False |
| 7685 | return True |
| 7686 | |
| 7687 | def __ne__(self, other): |
| 7688 | return not self.__eq__(other) |
| 7689 | |
| 7690 | def __str__(self): |
| 7691 | return self.show() |
| 7692 | |
| 7693 | def show(self): |
| 7694 | import loxi.pp |
| 7695 | return loxi.pp.pp(self) |
| 7696 | |
| 7697 | def pretty_print(self, q): |
| 7698 | q.text("meter_config_stats_reply {") |
| 7699 | with q.group(): |
| 7700 | with q.indent(2): |
| 7701 | q.breakable() |
| 7702 | q.text("xid = "); |
| 7703 | if self.xid != None: |
| 7704 | q.text("%#x" % self.xid) |
| 7705 | else: |
| 7706 | q.text('None') |
| 7707 | q.text(","); q.breakable() |
| 7708 | q.text("flags = "); |
| 7709 | q.text("%#x" % self.flags) |
| 7710 | q.text(","); q.breakable() |
| 7711 | q.text("entries = "); |
| 7712 | q.pp(self.entries) |
| 7713 | q.breakable() |
| 7714 | q.text('}') |
| 7715 | |
| 7716 | class meter_config_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7717 | version = 4 |
| 7718 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7719 | stats_type = 10 |
| 7720 | |
| 7721 | def __init__(self, xid=None, flags=None, meter_id=None): |
| 7722 | self.xid = xid |
| 7723 | if flags != None: |
| 7724 | self.flags = flags |
| 7725 | else: |
| 7726 | self.flags = 0 |
| 7727 | if meter_id != None: |
| 7728 | self.meter_id = meter_id |
| 7729 | else: |
| 7730 | self.meter_id = 0 |
| 7731 | |
| 7732 | def pack(self): |
| 7733 | packed = [] |
| 7734 | packed.append(struct.pack("!B", self.version)) |
| 7735 | packed.append(struct.pack("!B", self.type)) |
| 7736 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7737 | packed.append(struct.pack("!L", self.xid)) |
| 7738 | packed.append(struct.pack("!H", self.stats_type)) |
| 7739 | packed.append(struct.pack("!H", self.flags)) |
| 7740 | packed.append('\x00' * 4) |
| 7741 | packed.append(struct.pack("!L", self.meter_id)) |
| 7742 | packed.append('\x00' * 4) |
| 7743 | length = sum([len(x) for x in packed]) |
| 7744 | packed[2] = struct.pack("!H", length) |
| 7745 | return ''.join(packed) |
| 7746 | |
| 7747 | @staticmethod |
| 7748 | def unpack(buf): |
| 7749 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7750 | obj = meter_config_stats_request() |
| 7751 | if type(buf) == loxi.generic_util.OFReader: |
| 7752 | reader = buf |
| 7753 | else: |
| 7754 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7755 | _version = reader.read("!B")[0] |
| 7756 | assert(_version == 4) |
| 7757 | _type = reader.read("!B")[0] |
| 7758 | assert(_type == 18) |
| 7759 | _length = reader.read("!H")[0] |
| 7760 | obj.xid = reader.read("!L")[0] |
| 7761 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7762 | assert(_stats_type == 10) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7763 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7764 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7765 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7766 | reader.skip(4) |
| 7767 | return obj |
| 7768 | |
| 7769 | def __eq__(self, other): |
| 7770 | if type(self) != type(other): return False |
| 7771 | if self.version != other.version: return False |
| 7772 | if self.type != other.type: return False |
| 7773 | if self.xid != other.xid: return False |
| 7774 | if self.flags != other.flags: return False |
| 7775 | if self.meter_id != other.meter_id: return False |
| 7776 | return True |
| 7777 | |
| 7778 | def __ne__(self, other): |
| 7779 | return not self.__eq__(other) |
| 7780 | |
| 7781 | def __str__(self): |
| 7782 | return self.show() |
| 7783 | |
| 7784 | def show(self): |
| 7785 | import loxi.pp |
| 7786 | return loxi.pp.pp(self) |
| 7787 | |
| 7788 | def pretty_print(self, q): |
| 7789 | q.text("meter_config_stats_request {") |
| 7790 | with q.group(): |
| 7791 | with q.indent(2): |
| 7792 | q.breakable() |
| 7793 | q.text("xid = "); |
| 7794 | if self.xid != None: |
| 7795 | q.text("%#x" % self.xid) |
| 7796 | else: |
| 7797 | q.text('None') |
| 7798 | q.text(","); q.breakable() |
| 7799 | q.text("flags = "); |
| 7800 | q.text("%#x" % self.flags) |
| 7801 | q.text(","); q.breakable() |
| 7802 | q.text("meter_id = "); |
| 7803 | q.text("%#x" % self.meter_id) |
| 7804 | q.breakable() |
| 7805 | q.text('}') |
| 7806 | |
| 7807 | class meter_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7808 | version = 4 |
| 7809 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7810 | stats_type = 11 |
| 7811 | |
| 7812 | def __init__(self, xid=None, flags=None, features=None): |
| 7813 | self.xid = xid |
| 7814 | if flags != None: |
| 7815 | self.flags = flags |
| 7816 | else: |
| 7817 | self.flags = 0 |
| 7818 | if features != None: |
| 7819 | self.features = features |
| 7820 | else: |
| 7821 | self.features = common.meter_features() |
| 7822 | |
| 7823 | def pack(self): |
| 7824 | packed = [] |
| 7825 | packed.append(struct.pack("!B", self.version)) |
| 7826 | packed.append(struct.pack("!B", self.type)) |
| 7827 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7828 | packed.append(struct.pack("!L", self.xid)) |
| 7829 | packed.append(struct.pack("!H", self.stats_type)) |
| 7830 | packed.append(struct.pack("!H", self.flags)) |
| 7831 | packed.append('\x00' * 4) |
| 7832 | packed.append(self.features.pack()) |
| 7833 | length = sum([len(x) for x in packed]) |
| 7834 | packed[2] = struct.pack("!H", length) |
| 7835 | return ''.join(packed) |
| 7836 | |
| 7837 | @staticmethod |
| 7838 | def unpack(buf): |
| 7839 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7840 | obj = meter_features_stats_reply() |
| 7841 | if type(buf) == loxi.generic_util.OFReader: |
| 7842 | reader = buf |
| 7843 | else: |
| 7844 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7845 | _version = reader.read("!B")[0] |
| 7846 | assert(_version == 4) |
| 7847 | _type = reader.read("!B")[0] |
| 7848 | assert(_type == 19) |
| 7849 | _length = reader.read("!H")[0] |
| 7850 | obj.xid = reader.read("!L")[0] |
| 7851 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7852 | assert(_stats_type == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7853 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7854 | reader.skip(4) |
| 7855 | obj.features = common.meter_features.unpack(reader) |
| 7856 | return obj |
| 7857 | |
| 7858 | def __eq__(self, other): |
| 7859 | if type(self) != type(other): return False |
| 7860 | if self.version != other.version: return False |
| 7861 | if self.type != other.type: return False |
| 7862 | if self.xid != other.xid: return False |
| 7863 | if self.flags != other.flags: return False |
| 7864 | if self.features != other.features: return False |
| 7865 | return True |
| 7866 | |
| 7867 | def __ne__(self, other): |
| 7868 | return not self.__eq__(other) |
| 7869 | |
| 7870 | def __str__(self): |
| 7871 | return self.show() |
| 7872 | |
| 7873 | def show(self): |
| 7874 | import loxi.pp |
| 7875 | return loxi.pp.pp(self) |
| 7876 | |
| 7877 | def pretty_print(self, q): |
| 7878 | q.text("meter_features_stats_reply {") |
| 7879 | with q.group(): |
| 7880 | with q.indent(2): |
| 7881 | q.breakable() |
| 7882 | q.text("xid = "); |
| 7883 | if self.xid != None: |
| 7884 | q.text("%#x" % self.xid) |
| 7885 | else: |
| 7886 | q.text('None') |
| 7887 | q.text(","); q.breakable() |
| 7888 | q.text("flags = "); |
| 7889 | q.text("%#x" % self.flags) |
| 7890 | q.text(","); q.breakable() |
| 7891 | q.text("features = "); |
| 7892 | q.pp(self.features) |
| 7893 | q.breakable() |
| 7894 | q.text('}') |
| 7895 | |
| 7896 | class meter_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7897 | version = 4 |
| 7898 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7899 | stats_type = 11 |
| 7900 | |
| 7901 | def __init__(self, xid=None, flags=None): |
| 7902 | self.xid = xid |
| 7903 | if flags != None: |
| 7904 | self.flags = flags |
| 7905 | else: |
| 7906 | self.flags = 0 |
| 7907 | |
| 7908 | def pack(self): |
| 7909 | packed = [] |
| 7910 | packed.append(struct.pack("!B", self.version)) |
| 7911 | packed.append(struct.pack("!B", self.type)) |
| 7912 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7913 | packed.append(struct.pack("!L", self.xid)) |
| 7914 | packed.append(struct.pack("!H", self.stats_type)) |
| 7915 | packed.append(struct.pack("!H", self.flags)) |
| 7916 | packed.append('\x00' * 4) |
| 7917 | length = sum([len(x) for x in packed]) |
| 7918 | packed[2] = struct.pack("!H", length) |
| 7919 | return ''.join(packed) |
| 7920 | |
| 7921 | @staticmethod |
| 7922 | def unpack(buf): |
| 7923 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7924 | obj = meter_features_stats_request() |
| 7925 | if type(buf) == loxi.generic_util.OFReader: |
| 7926 | reader = buf |
| 7927 | else: |
| 7928 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7929 | _version = reader.read("!B")[0] |
| 7930 | assert(_version == 4) |
| 7931 | _type = reader.read("!B")[0] |
| 7932 | assert(_type == 18) |
| 7933 | _length = reader.read("!H")[0] |
| 7934 | obj.xid = reader.read("!L")[0] |
| 7935 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7936 | assert(_stats_type == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7937 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7938 | reader.skip(4) |
| 7939 | return obj |
| 7940 | |
| 7941 | def __eq__(self, other): |
| 7942 | if type(self) != type(other): return False |
| 7943 | if self.version != other.version: return False |
| 7944 | if self.type != other.type: return False |
| 7945 | if self.xid != other.xid: return False |
| 7946 | if self.flags != other.flags: return False |
| 7947 | return True |
| 7948 | |
| 7949 | def __ne__(self, other): |
| 7950 | return not self.__eq__(other) |
| 7951 | |
| 7952 | def __str__(self): |
| 7953 | return self.show() |
| 7954 | |
| 7955 | def show(self): |
| 7956 | import loxi.pp |
| 7957 | return loxi.pp.pp(self) |
| 7958 | |
| 7959 | def pretty_print(self, q): |
| 7960 | q.text("meter_features_stats_request {") |
| 7961 | with q.group(): |
| 7962 | with q.indent(2): |
| 7963 | q.breakable() |
| 7964 | q.text("xid = "); |
| 7965 | if self.xid != None: |
| 7966 | q.text("%#x" % self.xid) |
| 7967 | else: |
| 7968 | q.text('None') |
| 7969 | q.text(","); q.breakable() |
| 7970 | q.text("flags = "); |
| 7971 | q.text("%#x" % self.flags) |
| 7972 | q.breakable() |
| 7973 | q.text('}') |
| 7974 | |
| 7975 | class meter_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7976 | version = 4 |
| 7977 | type = 29 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7978 | |
| 7979 | def __init__(self, xid=None, command=None, flags=None, meter_id=None, meters=None): |
| 7980 | self.xid = xid |
| 7981 | if command != None: |
| 7982 | self.command = command |
| 7983 | else: |
| 7984 | self.command = 0 |
| 7985 | if flags != None: |
| 7986 | self.flags = flags |
| 7987 | else: |
| 7988 | self.flags = 0 |
| 7989 | if meter_id != None: |
| 7990 | self.meter_id = meter_id |
| 7991 | else: |
| 7992 | self.meter_id = 0 |
| 7993 | if meters != None: |
| 7994 | self.meters = meters |
| 7995 | else: |
| 7996 | self.meters = [] |
| 7997 | |
| 7998 | def pack(self): |
| 7999 | packed = [] |
| 8000 | packed.append(struct.pack("!B", self.version)) |
| 8001 | packed.append(struct.pack("!B", self.type)) |
| 8002 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8003 | packed.append(struct.pack("!L", self.xid)) |
| 8004 | packed.append(struct.pack("!H", self.command)) |
| 8005 | packed.append(struct.pack("!H", self.flags)) |
| 8006 | packed.append(struct.pack("!L", self.meter_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8007 | packed.append(util.pack_list(self.meters)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8008 | length = sum([len(x) for x in packed]) |
| 8009 | packed[2] = struct.pack("!H", length) |
| 8010 | return ''.join(packed) |
| 8011 | |
| 8012 | @staticmethod |
| 8013 | def unpack(buf): |
| 8014 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8015 | obj = meter_mod() |
| 8016 | if type(buf) == loxi.generic_util.OFReader: |
| 8017 | reader = buf |
| 8018 | else: |
| 8019 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8020 | _version = reader.read("!B")[0] |
| 8021 | assert(_version == 4) |
| 8022 | _type = reader.read("!B")[0] |
| 8023 | assert(_type == 29) |
| 8024 | _length = reader.read("!H")[0] |
| 8025 | obj.xid = reader.read("!L")[0] |
| 8026 | obj.command = reader.read("!H")[0] |
| 8027 | obj.flags = reader.read("!H")[0] |
| 8028 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8029 | obj.meters = meter_band.unpack_list(reader) |
| 8030 | return obj |
| 8031 | |
| 8032 | def __eq__(self, other): |
| 8033 | if type(self) != type(other): return False |
| 8034 | if self.version != other.version: return False |
| 8035 | if self.type != other.type: return False |
| 8036 | if self.xid != other.xid: return False |
| 8037 | if self.command != other.command: return False |
| 8038 | if self.flags != other.flags: return False |
| 8039 | if self.meter_id != other.meter_id: return False |
| 8040 | if self.meters != other.meters: return False |
| 8041 | return True |
| 8042 | |
| 8043 | def __ne__(self, other): |
| 8044 | return not self.__eq__(other) |
| 8045 | |
| 8046 | def __str__(self): |
| 8047 | return self.show() |
| 8048 | |
| 8049 | def show(self): |
| 8050 | import loxi.pp |
| 8051 | return loxi.pp.pp(self) |
| 8052 | |
| 8053 | def pretty_print(self, q): |
| 8054 | q.text("meter_mod {") |
| 8055 | with q.group(): |
| 8056 | with q.indent(2): |
| 8057 | q.breakable() |
| 8058 | q.text("xid = "); |
| 8059 | if self.xid != None: |
| 8060 | q.text("%#x" % self.xid) |
| 8061 | else: |
| 8062 | q.text('None') |
| 8063 | q.text(","); q.breakable() |
| 8064 | q.text("command = "); |
| 8065 | q.text("%#x" % self.command) |
| 8066 | q.text(","); q.breakable() |
| 8067 | q.text("flags = "); |
| 8068 | q.text("%#x" % self.flags) |
| 8069 | q.text(","); q.breakable() |
| 8070 | q.text("meter_id = "); |
| 8071 | q.text("%#x" % self.meter_id) |
| 8072 | q.text(","); q.breakable() |
| 8073 | q.text("meters = "); |
| 8074 | q.pp(self.meters) |
| 8075 | q.breakable() |
| 8076 | q.text('}') |
| 8077 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8078 | class meter_mod_failed_error_msg(Message): |
| 8079 | version = 4 |
| 8080 | type = 1 |
| 8081 | err_type = 12 |
| 8082 | |
| 8083 | def __init__(self, xid=None, code=None, data=None): |
| 8084 | self.xid = xid |
| 8085 | if code != None: |
| 8086 | self.code = code |
| 8087 | else: |
| 8088 | self.code = 0 |
| 8089 | if data != None: |
| 8090 | self.data = data |
| 8091 | else: |
| 8092 | self.data = '' |
| 8093 | |
| 8094 | def pack(self): |
| 8095 | packed = [] |
| 8096 | packed.append(struct.pack("!B", self.version)) |
| 8097 | packed.append(struct.pack("!B", self.type)) |
| 8098 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8099 | packed.append(struct.pack("!L", self.xid)) |
| 8100 | packed.append(struct.pack("!H", self.err_type)) |
| 8101 | packed.append(struct.pack("!H", self.code)) |
| 8102 | packed.append(self.data) |
| 8103 | length = sum([len(x) for x in packed]) |
| 8104 | packed[2] = struct.pack("!H", length) |
| 8105 | return ''.join(packed) |
| 8106 | |
| 8107 | @staticmethod |
| 8108 | def unpack(buf): |
| 8109 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8110 | obj = meter_mod_failed_error_msg() |
| 8111 | if type(buf) == loxi.generic_util.OFReader: |
| 8112 | reader = buf |
| 8113 | else: |
| 8114 | reader = loxi.generic_util.OFReader(buf) |
| 8115 | _version = reader.read("!B")[0] |
| 8116 | assert(_version == 4) |
| 8117 | _type = reader.read("!B")[0] |
| 8118 | assert(_type == 1) |
| 8119 | _length = reader.read("!H")[0] |
| 8120 | obj.xid = reader.read("!L")[0] |
| 8121 | _err_type = reader.read("!H")[0] |
| 8122 | assert(_err_type == 12) |
| 8123 | obj.code = reader.read("!H")[0] |
| 8124 | obj.data = str(reader.read_all()) |
| 8125 | return obj |
| 8126 | |
| 8127 | def __eq__(self, other): |
| 8128 | if type(self) != type(other): return False |
| 8129 | if self.version != other.version: return False |
| 8130 | if self.type != other.type: return False |
| 8131 | if self.xid != other.xid: return False |
| 8132 | if self.code != other.code: return False |
| 8133 | if self.data != other.data: return False |
| 8134 | return True |
| 8135 | |
| 8136 | def __ne__(self, other): |
| 8137 | return not self.__eq__(other) |
| 8138 | |
| 8139 | def __str__(self): |
| 8140 | return self.show() |
| 8141 | |
| 8142 | def show(self): |
| 8143 | import loxi.pp |
| 8144 | return loxi.pp.pp(self) |
| 8145 | |
| 8146 | def pretty_print(self, q): |
| 8147 | q.text("meter_mod_failed_error_msg {") |
| 8148 | with q.group(): |
| 8149 | with q.indent(2): |
| 8150 | q.breakable() |
| 8151 | q.text("xid = "); |
| 8152 | if self.xid != None: |
| 8153 | q.text("%#x" % self.xid) |
| 8154 | else: |
| 8155 | q.text('None') |
| 8156 | q.text(","); q.breakable() |
| 8157 | q.text("code = "); |
| 8158 | q.text("%#x" % self.code) |
| 8159 | q.text(","); q.breakable() |
| 8160 | q.text("data = "); |
| 8161 | q.pp(self.data) |
| 8162 | q.breakable() |
| 8163 | q.text('}') |
| 8164 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8165 | class meter_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8166 | version = 4 |
| 8167 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8168 | stats_type = 9 |
| 8169 | |
| 8170 | def __init__(self, xid=None, flags=None, entries=None): |
| 8171 | self.xid = xid |
| 8172 | if flags != None: |
| 8173 | self.flags = flags |
| 8174 | else: |
| 8175 | self.flags = 0 |
| 8176 | if entries != None: |
| 8177 | self.entries = entries |
| 8178 | else: |
| 8179 | self.entries = [] |
| 8180 | |
| 8181 | def pack(self): |
| 8182 | packed = [] |
| 8183 | packed.append(struct.pack("!B", self.version)) |
| 8184 | packed.append(struct.pack("!B", self.type)) |
| 8185 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8186 | packed.append(struct.pack("!L", self.xid)) |
| 8187 | packed.append(struct.pack("!H", self.stats_type)) |
| 8188 | packed.append(struct.pack("!H", self.flags)) |
| 8189 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8190 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8191 | length = sum([len(x) for x in packed]) |
| 8192 | packed[2] = struct.pack("!H", length) |
| 8193 | return ''.join(packed) |
| 8194 | |
| 8195 | @staticmethod |
| 8196 | def unpack(buf): |
| 8197 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8198 | obj = meter_stats_reply() |
| 8199 | if type(buf) == loxi.generic_util.OFReader: |
| 8200 | reader = buf |
| 8201 | else: |
| 8202 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8203 | _version = reader.read("!B")[0] |
| 8204 | assert(_version == 4) |
| 8205 | _type = reader.read("!B")[0] |
| 8206 | assert(_type == 19) |
| 8207 | _length = reader.read("!H")[0] |
| 8208 | obj.xid = reader.read("!L")[0] |
| 8209 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8210 | assert(_stats_type == 9) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8211 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8212 | reader.skip(4) |
| 8213 | obj.entries = common.unpack_list_meter_stats(reader) |
| 8214 | return obj |
| 8215 | |
| 8216 | def __eq__(self, other): |
| 8217 | if type(self) != type(other): return False |
| 8218 | if self.version != other.version: return False |
| 8219 | if self.type != other.type: return False |
| 8220 | if self.xid != other.xid: return False |
| 8221 | if self.flags != other.flags: return False |
| 8222 | if self.entries != other.entries: return False |
| 8223 | return True |
| 8224 | |
| 8225 | def __ne__(self, other): |
| 8226 | return not self.__eq__(other) |
| 8227 | |
| 8228 | def __str__(self): |
| 8229 | return self.show() |
| 8230 | |
| 8231 | def show(self): |
| 8232 | import loxi.pp |
| 8233 | return loxi.pp.pp(self) |
| 8234 | |
| 8235 | def pretty_print(self, q): |
| 8236 | q.text("meter_stats_reply {") |
| 8237 | with q.group(): |
| 8238 | with q.indent(2): |
| 8239 | q.breakable() |
| 8240 | q.text("xid = "); |
| 8241 | if self.xid != None: |
| 8242 | q.text("%#x" % self.xid) |
| 8243 | else: |
| 8244 | q.text('None') |
| 8245 | q.text(","); q.breakable() |
| 8246 | q.text("flags = "); |
| 8247 | q.text("%#x" % self.flags) |
| 8248 | q.text(","); q.breakable() |
| 8249 | q.text("entries = "); |
| 8250 | q.pp(self.entries) |
| 8251 | q.breakable() |
| 8252 | q.text('}') |
| 8253 | |
| 8254 | class meter_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8255 | version = 4 |
| 8256 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8257 | stats_type = 9 |
| 8258 | |
| 8259 | def __init__(self, xid=None, flags=None, meter_id=None): |
| 8260 | self.xid = xid |
| 8261 | if flags != None: |
| 8262 | self.flags = flags |
| 8263 | else: |
| 8264 | self.flags = 0 |
| 8265 | if meter_id != None: |
| 8266 | self.meter_id = meter_id |
| 8267 | else: |
| 8268 | self.meter_id = 0 |
| 8269 | |
| 8270 | def pack(self): |
| 8271 | packed = [] |
| 8272 | packed.append(struct.pack("!B", self.version)) |
| 8273 | packed.append(struct.pack("!B", self.type)) |
| 8274 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8275 | packed.append(struct.pack("!L", self.xid)) |
| 8276 | packed.append(struct.pack("!H", self.stats_type)) |
| 8277 | packed.append(struct.pack("!H", self.flags)) |
| 8278 | packed.append('\x00' * 4) |
| 8279 | packed.append(struct.pack("!L", self.meter_id)) |
| 8280 | packed.append('\x00' * 4) |
| 8281 | length = sum([len(x) for x in packed]) |
| 8282 | packed[2] = struct.pack("!H", length) |
| 8283 | return ''.join(packed) |
| 8284 | |
| 8285 | @staticmethod |
| 8286 | def unpack(buf): |
| 8287 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8288 | obj = meter_stats_request() |
| 8289 | if type(buf) == loxi.generic_util.OFReader: |
| 8290 | reader = buf |
| 8291 | else: |
| 8292 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8293 | _version = reader.read("!B")[0] |
| 8294 | assert(_version == 4) |
| 8295 | _type = reader.read("!B")[0] |
| 8296 | assert(_type == 18) |
| 8297 | _length = reader.read("!H")[0] |
| 8298 | obj.xid = reader.read("!L")[0] |
| 8299 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8300 | assert(_stats_type == 9) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8301 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8302 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8303 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8304 | reader.skip(4) |
| 8305 | return obj |
| 8306 | |
| 8307 | def __eq__(self, other): |
| 8308 | if type(self) != type(other): return False |
| 8309 | if self.version != other.version: return False |
| 8310 | if self.type != other.type: return False |
| 8311 | if self.xid != other.xid: return False |
| 8312 | if self.flags != other.flags: return False |
| 8313 | if self.meter_id != other.meter_id: return False |
| 8314 | return True |
| 8315 | |
| 8316 | def __ne__(self, other): |
| 8317 | return not self.__eq__(other) |
| 8318 | |
| 8319 | def __str__(self): |
| 8320 | return self.show() |
| 8321 | |
| 8322 | def show(self): |
| 8323 | import loxi.pp |
| 8324 | return loxi.pp.pp(self) |
| 8325 | |
| 8326 | def pretty_print(self, q): |
| 8327 | q.text("meter_stats_request {") |
| 8328 | with q.group(): |
| 8329 | with q.indent(2): |
| 8330 | q.breakable() |
| 8331 | q.text("xid = "); |
| 8332 | if self.xid != None: |
| 8333 | q.text("%#x" % self.xid) |
| 8334 | else: |
| 8335 | q.text('None') |
| 8336 | q.text(","); q.breakable() |
| 8337 | q.text("flags = "); |
| 8338 | q.text("%#x" % self.flags) |
| 8339 | q.text(","); q.breakable() |
| 8340 | q.text("meter_id = "); |
| 8341 | q.text("%#x" % self.meter_id) |
| 8342 | q.breakable() |
| 8343 | q.text('}') |
| 8344 | |
| 8345 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8346 | version = 4 |
| 8347 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8348 | |
| 8349 | def __init__(self, xid=None, buffer_id=None, total_len=None, reason=None, table_id=None, cookie=None, match=None, data=None): |
| 8350 | self.xid = xid |
| 8351 | if buffer_id != None: |
| 8352 | self.buffer_id = buffer_id |
| 8353 | else: |
| 8354 | self.buffer_id = 0 |
| 8355 | if total_len != None: |
| 8356 | self.total_len = total_len |
| 8357 | else: |
| 8358 | self.total_len = 0 |
| 8359 | if reason != None: |
| 8360 | self.reason = reason |
| 8361 | else: |
| 8362 | self.reason = 0 |
| 8363 | if table_id != None: |
| 8364 | self.table_id = table_id |
| 8365 | else: |
| 8366 | self.table_id = 0 |
| 8367 | if cookie != None: |
| 8368 | self.cookie = cookie |
| 8369 | else: |
| 8370 | self.cookie = 0 |
| 8371 | if match != None: |
| 8372 | self.match = match |
| 8373 | else: |
| 8374 | self.match = common.match() |
| 8375 | if data != None: |
| 8376 | self.data = data |
| 8377 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8378 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8379 | |
| 8380 | def pack(self): |
| 8381 | packed = [] |
| 8382 | packed.append(struct.pack("!B", self.version)) |
| 8383 | packed.append(struct.pack("!B", self.type)) |
| 8384 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8385 | packed.append(struct.pack("!L", self.xid)) |
| 8386 | packed.append(struct.pack("!L", self.buffer_id)) |
| 8387 | packed.append(struct.pack("!H", self.total_len)) |
| 8388 | packed.append(struct.pack("!B", self.reason)) |
| 8389 | packed.append(struct.pack("!B", self.table_id)) |
| 8390 | packed.append(struct.pack("!Q", self.cookie)) |
| 8391 | packed.append(self.match.pack()) |
| 8392 | packed.append('\x00' * 2) |
| 8393 | packed.append(self.data) |
| 8394 | length = sum([len(x) for x in packed]) |
| 8395 | packed[2] = struct.pack("!H", length) |
| 8396 | return ''.join(packed) |
| 8397 | |
| 8398 | @staticmethod |
| 8399 | def unpack(buf): |
| 8400 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8401 | obj = packet_in() |
| 8402 | if type(buf) == loxi.generic_util.OFReader: |
| 8403 | reader = buf |
| 8404 | else: |
| 8405 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8406 | _version = reader.read("!B")[0] |
| 8407 | assert(_version == 4) |
| 8408 | _type = reader.read("!B")[0] |
| 8409 | assert(_type == 10) |
| 8410 | _length = reader.read("!H")[0] |
| 8411 | obj.xid = reader.read("!L")[0] |
| 8412 | obj.buffer_id = reader.read("!L")[0] |
| 8413 | obj.total_len = reader.read("!H")[0] |
| 8414 | obj.reason = reader.read("!B")[0] |
| 8415 | obj.table_id = reader.read("!B")[0] |
| 8416 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8417 | obj.match = common.match.unpack(reader) |
| 8418 | reader.skip(2) |
| 8419 | obj.data = str(reader.read_all()) |
| 8420 | return obj |
| 8421 | |
| 8422 | def __eq__(self, other): |
| 8423 | if type(self) != type(other): return False |
| 8424 | if self.version != other.version: return False |
| 8425 | if self.type != other.type: return False |
| 8426 | if self.xid != other.xid: return False |
| 8427 | if self.buffer_id != other.buffer_id: return False |
| 8428 | if self.total_len != other.total_len: return False |
| 8429 | if self.reason != other.reason: return False |
| 8430 | if self.table_id != other.table_id: return False |
| 8431 | if self.cookie != other.cookie: return False |
| 8432 | if self.match != other.match: return False |
| 8433 | if self.data != other.data: return False |
| 8434 | return True |
| 8435 | |
| 8436 | def __ne__(self, other): |
| 8437 | return not self.__eq__(other) |
| 8438 | |
| 8439 | def __str__(self): |
| 8440 | return self.show() |
| 8441 | |
| 8442 | def show(self): |
| 8443 | import loxi.pp |
| 8444 | return loxi.pp.pp(self) |
| 8445 | |
| 8446 | def pretty_print(self, q): |
| 8447 | q.text("packet_in {") |
| 8448 | with q.group(): |
| 8449 | with q.indent(2): |
| 8450 | q.breakable() |
| 8451 | q.text("xid = "); |
| 8452 | if self.xid != None: |
| 8453 | q.text("%#x" % self.xid) |
| 8454 | else: |
| 8455 | q.text('None') |
| 8456 | q.text(","); q.breakable() |
| 8457 | q.text("buffer_id = "); |
| 8458 | q.text("%#x" % self.buffer_id) |
| 8459 | q.text(","); q.breakable() |
| 8460 | q.text("total_len = "); |
| 8461 | q.text("%#x" % self.total_len) |
| 8462 | q.text(","); q.breakable() |
| 8463 | q.text("reason = "); |
| 8464 | q.text("%#x" % self.reason) |
| 8465 | q.text(","); q.breakable() |
| 8466 | q.text("table_id = "); |
| 8467 | q.text("%#x" % self.table_id) |
| 8468 | q.text(","); q.breakable() |
| 8469 | q.text("cookie = "); |
| 8470 | q.text("%#x" % self.cookie) |
| 8471 | q.text(","); q.breakable() |
| 8472 | q.text("match = "); |
| 8473 | q.pp(self.match) |
| 8474 | q.text(","); q.breakable() |
| 8475 | q.text("data = "); |
| 8476 | q.pp(self.data) |
| 8477 | q.breakable() |
| 8478 | q.text('}') |
| 8479 | |
| 8480 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8481 | version = 4 |
| 8482 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8483 | |
| 8484 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 8485 | self.xid = xid |
| 8486 | if buffer_id != None: |
| 8487 | self.buffer_id = buffer_id |
| 8488 | else: |
| 8489 | self.buffer_id = 0 |
| 8490 | if in_port != None: |
| 8491 | self.in_port = in_port |
| 8492 | else: |
| 8493 | self.in_port = 0 |
| 8494 | if actions != None: |
| 8495 | self.actions = actions |
| 8496 | else: |
| 8497 | self.actions = [] |
| 8498 | if data != None: |
| 8499 | self.data = data |
| 8500 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8501 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8502 | |
| 8503 | def pack(self): |
| 8504 | packed = [] |
| 8505 | packed.append(struct.pack("!B", self.version)) |
| 8506 | packed.append(struct.pack("!B", self.type)) |
| 8507 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8508 | packed.append(struct.pack("!L", self.xid)) |
| 8509 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8510 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8511 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 8512 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8513 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8514 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 8515 | packed.append(self.data) |
| 8516 | length = sum([len(x) for x in packed]) |
| 8517 | packed[2] = struct.pack("!H", length) |
| 8518 | return ''.join(packed) |
| 8519 | |
| 8520 | @staticmethod |
| 8521 | def unpack(buf): |
| 8522 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8523 | obj = packet_out() |
| 8524 | if type(buf) == loxi.generic_util.OFReader: |
| 8525 | reader = buf |
| 8526 | else: |
| 8527 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8528 | _version = reader.read("!B")[0] |
| 8529 | assert(_version == 4) |
| 8530 | _type = reader.read("!B")[0] |
| 8531 | assert(_type == 13) |
| 8532 | _length = reader.read("!H")[0] |
| 8533 | obj.xid = reader.read("!L")[0] |
| 8534 | obj.buffer_id = reader.read("!L")[0] |
| 8535 | obj.in_port = util.unpack_port_no(reader) |
| 8536 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8537 | reader.skip(6) |
| 8538 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 8539 | obj.data = str(reader.read_all()) |
| 8540 | return obj |
| 8541 | |
| 8542 | def __eq__(self, other): |
| 8543 | if type(self) != type(other): return False |
| 8544 | if self.version != other.version: return False |
| 8545 | if self.type != other.type: return False |
| 8546 | if self.xid != other.xid: return False |
| 8547 | if self.buffer_id != other.buffer_id: return False |
| 8548 | if self.in_port != other.in_port: return False |
| 8549 | if self.actions != other.actions: return False |
| 8550 | if self.data != other.data: return False |
| 8551 | return True |
| 8552 | |
| 8553 | def __ne__(self, other): |
| 8554 | return not self.__eq__(other) |
| 8555 | |
| 8556 | def __str__(self): |
| 8557 | return self.show() |
| 8558 | |
| 8559 | def show(self): |
| 8560 | import loxi.pp |
| 8561 | return loxi.pp.pp(self) |
| 8562 | |
| 8563 | def pretty_print(self, q): |
| 8564 | q.text("packet_out {") |
| 8565 | with q.group(): |
| 8566 | with q.indent(2): |
| 8567 | q.breakable() |
| 8568 | q.text("xid = "); |
| 8569 | if self.xid != None: |
| 8570 | q.text("%#x" % self.xid) |
| 8571 | else: |
| 8572 | q.text('None') |
| 8573 | q.text(","); q.breakable() |
| 8574 | q.text("buffer_id = "); |
| 8575 | q.text("%#x" % self.buffer_id) |
| 8576 | q.text(","); q.breakable() |
| 8577 | q.text("in_port = "); |
| 8578 | q.text(util.pretty_port(self.in_port)) |
| 8579 | q.text(","); q.breakable() |
| 8580 | q.text("actions = "); |
| 8581 | q.pp(self.actions) |
| 8582 | q.text(","); q.breakable() |
| 8583 | q.text("data = "); |
| 8584 | q.pp(self.data) |
| 8585 | q.breakable() |
| 8586 | q.text('}') |
| 8587 | |
| 8588 | class port_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8589 | version = 4 |
| 8590 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8591 | stats_type = 13 |
| 8592 | |
| 8593 | def __init__(self, xid=None, flags=None, entries=None): |
| 8594 | self.xid = xid |
| 8595 | if flags != None: |
| 8596 | self.flags = flags |
| 8597 | else: |
| 8598 | self.flags = 0 |
| 8599 | if entries != None: |
| 8600 | self.entries = entries |
| 8601 | else: |
| 8602 | self.entries = [] |
| 8603 | |
| 8604 | def pack(self): |
| 8605 | packed = [] |
| 8606 | packed.append(struct.pack("!B", self.version)) |
| 8607 | packed.append(struct.pack("!B", self.type)) |
| 8608 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8609 | packed.append(struct.pack("!L", self.xid)) |
| 8610 | packed.append(struct.pack("!H", self.stats_type)) |
| 8611 | packed.append(struct.pack("!H", self.flags)) |
| 8612 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8613 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8614 | length = sum([len(x) for x in packed]) |
| 8615 | packed[2] = struct.pack("!H", length) |
| 8616 | return ''.join(packed) |
| 8617 | |
| 8618 | @staticmethod |
| 8619 | def unpack(buf): |
| 8620 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8621 | obj = port_desc_stats_reply() |
| 8622 | if type(buf) == loxi.generic_util.OFReader: |
| 8623 | reader = buf |
| 8624 | else: |
| 8625 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8626 | _version = reader.read("!B")[0] |
| 8627 | assert(_version == 4) |
| 8628 | _type = reader.read("!B")[0] |
| 8629 | assert(_type == 19) |
| 8630 | _length = reader.read("!H")[0] |
| 8631 | obj.xid = reader.read("!L")[0] |
| 8632 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8633 | assert(_stats_type == 13) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8634 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8635 | reader.skip(4) |
| 8636 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 8637 | return obj |
| 8638 | |
| 8639 | def __eq__(self, other): |
| 8640 | if type(self) != type(other): return False |
| 8641 | if self.version != other.version: return False |
| 8642 | if self.type != other.type: return False |
| 8643 | if self.xid != other.xid: return False |
| 8644 | if self.flags != other.flags: return False |
| 8645 | if self.entries != other.entries: return False |
| 8646 | return True |
| 8647 | |
| 8648 | def __ne__(self, other): |
| 8649 | return not self.__eq__(other) |
| 8650 | |
| 8651 | def __str__(self): |
| 8652 | return self.show() |
| 8653 | |
| 8654 | def show(self): |
| 8655 | import loxi.pp |
| 8656 | return loxi.pp.pp(self) |
| 8657 | |
| 8658 | def pretty_print(self, q): |
| 8659 | q.text("port_desc_stats_reply {") |
| 8660 | with q.group(): |
| 8661 | with q.indent(2): |
| 8662 | q.breakable() |
| 8663 | q.text("xid = "); |
| 8664 | if self.xid != None: |
| 8665 | q.text("%#x" % self.xid) |
| 8666 | else: |
| 8667 | q.text('None') |
| 8668 | q.text(","); q.breakable() |
| 8669 | q.text("flags = "); |
| 8670 | q.text("%#x" % self.flags) |
| 8671 | q.text(","); q.breakable() |
| 8672 | q.text("entries = "); |
| 8673 | q.pp(self.entries) |
| 8674 | q.breakable() |
| 8675 | q.text('}') |
| 8676 | |
| 8677 | class port_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8678 | version = 4 |
| 8679 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8680 | stats_type = 13 |
| 8681 | |
| 8682 | def __init__(self, xid=None, flags=None): |
| 8683 | self.xid = xid |
| 8684 | if flags != None: |
| 8685 | self.flags = flags |
| 8686 | else: |
| 8687 | self.flags = 0 |
| 8688 | |
| 8689 | def pack(self): |
| 8690 | packed = [] |
| 8691 | packed.append(struct.pack("!B", self.version)) |
| 8692 | packed.append(struct.pack("!B", self.type)) |
| 8693 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8694 | packed.append(struct.pack("!L", self.xid)) |
| 8695 | packed.append(struct.pack("!H", self.stats_type)) |
| 8696 | packed.append(struct.pack("!H", self.flags)) |
| 8697 | packed.append('\x00' * 4) |
| 8698 | length = sum([len(x) for x in packed]) |
| 8699 | packed[2] = struct.pack("!H", length) |
| 8700 | return ''.join(packed) |
| 8701 | |
| 8702 | @staticmethod |
| 8703 | def unpack(buf): |
| 8704 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8705 | obj = port_desc_stats_request() |
| 8706 | if type(buf) == loxi.generic_util.OFReader: |
| 8707 | reader = buf |
| 8708 | else: |
| 8709 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8710 | _version = reader.read("!B")[0] |
| 8711 | assert(_version == 4) |
| 8712 | _type = reader.read("!B")[0] |
| 8713 | assert(_type == 18) |
| 8714 | _length = reader.read("!H")[0] |
| 8715 | obj.xid = reader.read("!L")[0] |
| 8716 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8717 | assert(_stats_type == 13) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8718 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8719 | reader.skip(4) |
| 8720 | return obj |
| 8721 | |
| 8722 | def __eq__(self, other): |
| 8723 | if type(self) != type(other): return False |
| 8724 | if self.version != other.version: return False |
| 8725 | if self.type != other.type: return False |
| 8726 | if self.xid != other.xid: return False |
| 8727 | if self.flags != other.flags: return False |
| 8728 | return True |
| 8729 | |
| 8730 | def __ne__(self, other): |
| 8731 | return not self.__eq__(other) |
| 8732 | |
| 8733 | def __str__(self): |
| 8734 | return self.show() |
| 8735 | |
| 8736 | def show(self): |
| 8737 | import loxi.pp |
| 8738 | return loxi.pp.pp(self) |
| 8739 | |
| 8740 | def pretty_print(self, q): |
| 8741 | q.text("port_desc_stats_request {") |
| 8742 | with q.group(): |
| 8743 | with q.indent(2): |
| 8744 | q.breakable() |
| 8745 | q.text("xid = "); |
| 8746 | if self.xid != None: |
| 8747 | q.text("%#x" % self.xid) |
| 8748 | else: |
| 8749 | q.text('None') |
| 8750 | q.text(","); q.breakable() |
| 8751 | q.text("flags = "); |
| 8752 | q.text("%#x" % self.flags) |
| 8753 | q.breakable() |
| 8754 | q.text('}') |
| 8755 | |
| 8756 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8757 | version = 4 |
| 8758 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8759 | |
| 8760 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
| 8761 | self.xid = xid |
| 8762 | if port_no != None: |
| 8763 | self.port_no = port_no |
| 8764 | else: |
| 8765 | self.port_no = 0 |
| 8766 | if hw_addr != None: |
| 8767 | self.hw_addr = hw_addr |
| 8768 | else: |
| 8769 | self.hw_addr = [0,0,0,0,0,0] |
| 8770 | if config != None: |
| 8771 | self.config = config |
| 8772 | else: |
| 8773 | self.config = 0 |
| 8774 | if mask != None: |
| 8775 | self.mask = mask |
| 8776 | else: |
| 8777 | self.mask = 0 |
| 8778 | if advertise != None: |
| 8779 | self.advertise = advertise |
| 8780 | else: |
| 8781 | self.advertise = 0 |
| 8782 | |
| 8783 | def pack(self): |
| 8784 | packed = [] |
| 8785 | packed.append(struct.pack("!B", self.version)) |
| 8786 | packed.append(struct.pack("!B", self.type)) |
| 8787 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8788 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8789 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8790 | packed.append('\x00' * 4) |
| 8791 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 8792 | packed.append('\x00' * 2) |
| 8793 | packed.append(struct.pack("!L", self.config)) |
| 8794 | packed.append(struct.pack("!L", self.mask)) |
| 8795 | packed.append(struct.pack("!L", self.advertise)) |
| 8796 | packed.append('\x00' * 4) |
| 8797 | length = sum([len(x) for x in packed]) |
| 8798 | packed[2] = struct.pack("!H", length) |
| 8799 | return ''.join(packed) |
| 8800 | |
| 8801 | @staticmethod |
| 8802 | def unpack(buf): |
| 8803 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8804 | obj = port_mod() |
| 8805 | if type(buf) == loxi.generic_util.OFReader: |
| 8806 | reader = buf |
| 8807 | else: |
| 8808 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8809 | _version = reader.read("!B")[0] |
| 8810 | assert(_version == 4) |
| 8811 | _type = reader.read("!B")[0] |
| 8812 | assert(_type == 16) |
| 8813 | _length = reader.read("!H")[0] |
| 8814 | obj.xid = reader.read("!L")[0] |
| 8815 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8816 | reader.skip(4) |
| 8817 | obj.hw_addr = list(reader.read('!6B')) |
| 8818 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8819 | obj.config = reader.read("!L")[0] |
| 8820 | obj.mask = reader.read("!L")[0] |
| 8821 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8822 | reader.skip(4) |
| 8823 | return obj |
| 8824 | |
| 8825 | def __eq__(self, other): |
| 8826 | if type(self) != type(other): return False |
| 8827 | if self.version != other.version: return False |
| 8828 | if self.type != other.type: return False |
| 8829 | if self.xid != other.xid: return False |
| 8830 | if self.port_no != other.port_no: return False |
| 8831 | if self.hw_addr != other.hw_addr: return False |
| 8832 | if self.config != other.config: return False |
| 8833 | if self.mask != other.mask: return False |
| 8834 | if self.advertise != other.advertise: return False |
| 8835 | return True |
| 8836 | |
| 8837 | def __ne__(self, other): |
| 8838 | return not self.__eq__(other) |
| 8839 | |
| 8840 | def __str__(self): |
| 8841 | return self.show() |
| 8842 | |
| 8843 | def show(self): |
| 8844 | import loxi.pp |
| 8845 | return loxi.pp.pp(self) |
| 8846 | |
| 8847 | def pretty_print(self, q): |
| 8848 | q.text("port_mod {") |
| 8849 | with q.group(): |
| 8850 | with q.indent(2): |
| 8851 | q.breakable() |
| 8852 | q.text("xid = "); |
| 8853 | if self.xid != None: |
| 8854 | q.text("%#x" % self.xid) |
| 8855 | else: |
| 8856 | q.text('None') |
| 8857 | q.text(","); q.breakable() |
| 8858 | q.text("port_no = "); |
| 8859 | q.text(util.pretty_port(self.port_no)) |
| 8860 | q.text(","); q.breakable() |
| 8861 | q.text("hw_addr = "); |
| 8862 | q.text(util.pretty_mac(self.hw_addr)) |
| 8863 | q.text(","); q.breakable() |
| 8864 | q.text("config = "); |
| 8865 | q.text("%#x" % self.config) |
| 8866 | q.text(","); q.breakable() |
| 8867 | q.text("mask = "); |
| 8868 | q.text("%#x" % self.mask) |
| 8869 | q.text(","); q.breakable() |
| 8870 | q.text("advertise = "); |
| 8871 | q.text("%#x" % self.advertise) |
| 8872 | q.breakable() |
| 8873 | q.text('}') |
| 8874 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8875 | class port_mod_failed_error_msg(Message): |
| 8876 | version = 4 |
| 8877 | type = 1 |
| 8878 | err_type = 7 |
| 8879 | |
| 8880 | def __init__(self, xid=None, code=None, data=None): |
| 8881 | self.xid = xid |
| 8882 | if code != None: |
| 8883 | self.code = code |
| 8884 | else: |
| 8885 | self.code = 0 |
| 8886 | if data != None: |
| 8887 | self.data = data |
| 8888 | else: |
| 8889 | self.data = '' |
| 8890 | |
| 8891 | def pack(self): |
| 8892 | packed = [] |
| 8893 | packed.append(struct.pack("!B", self.version)) |
| 8894 | packed.append(struct.pack("!B", self.type)) |
| 8895 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8896 | packed.append(struct.pack("!L", self.xid)) |
| 8897 | packed.append(struct.pack("!H", self.err_type)) |
| 8898 | packed.append(struct.pack("!H", self.code)) |
| 8899 | packed.append(self.data) |
| 8900 | length = sum([len(x) for x in packed]) |
| 8901 | packed[2] = struct.pack("!H", length) |
| 8902 | return ''.join(packed) |
| 8903 | |
| 8904 | @staticmethod |
| 8905 | def unpack(buf): |
| 8906 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8907 | obj = port_mod_failed_error_msg() |
| 8908 | if type(buf) == loxi.generic_util.OFReader: |
| 8909 | reader = buf |
| 8910 | else: |
| 8911 | reader = loxi.generic_util.OFReader(buf) |
| 8912 | _version = reader.read("!B")[0] |
| 8913 | assert(_version == 4) |
| 8914 | _type = reader.read("!B")[0] |
| 8915 | assert(_type == 1) |
| 8916 | _length = reader.read("!H")[0] |
| 8917 | obj.xid = reader.read("!L")[0] |
| 8918 | _err_type = reader.read("!H")[0] |
| 8919 | assert(_err_type == 7) |
| 8920 | obj.code = reader.read("!H")[0] |
| 8921 | obj.data = str(reader.read_all()) |
| 8922 | return obj |
| 8923 | |
| 8924 | def __eq__(self, other): |
| 8925 | if type(self) != type(other): return False |
| 8926 | if self.version != other.version: return False |
| 8927 | if self.type != other.type: return False |
| 8928 | if self.xid != other.xid: return False |
| 8929 | if self.code != other.code: return False |
| 8930 | if self.data != other.data: return False |
| 8931 | return True |
| 8932 | |
| 8933 | def __ne__(self, other): |
| 8934 | return not self.__eq__(other) |
| 8935 | |
| 8936 | def __str__(self): |
| 8937 | return self.show() |
| 8938 | |
| 8939 | def show(self): |
| 8940 | import loxi.pp |
| 8941 | return loxi.pp.pp(self) |
| 8942 | |
| 8943 | def pretty_print(self, q): |
| 8944 | q.text("port_mod_failed_error_msg {") |
| 8945 | with q.group(): |
| 8946 | with q.indent(2): |
| 8947 | q.breakable() |
| 8948 | q.text("xid = "); |
| 8949 | if self.xid != None: |
| 8950 | q.text("%#x" % self.xid) |
| 8951 | else: |
| 8952 | q.text('None') |
| 8953 | q.text(","); q.breakable() |
| 8954 | q.text("code = "); |
| 8955 | q.text("%#x" % self.code) |
| 8956 | q.text(","); q.breakable() |
| 8957 | q.text("data = "); |
| 8958 | q.pp(self.data) |
| 8959 | q.breakable() |
| 8960 | q.text('}') |
| 8961 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8962 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8963 | version = 4 |
| 8964 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8965 | stats_type = 4 |
| 8966 | |
| 8967 | def __init__(self, xid=None, flags=None, entries=None): |
| 8968 | self.xid = xid |
| 8969 | if flags != None: |
| 8970 | self.flags = flags |
| 8971 | else: |
| 8972 | self.flags = 0 |
| 8973 | if entries != None: |
| 8974 | self.entries = entries |
| 8975 | else: |
| 8976 | self.entries = [] |
| 8977 | |
| 8978 | def pack(self): |
| 8979 | packed = [] |
| 8980 | packed.append(struct.pack("!B", self.version)) |
| 8981 | packed.append(struct.pack("!B", self.type)) |
| 8982 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8983 | packed.append(struct.pack("!L", self.xid)) |
| 8984 | packed.append(struct.pack("!H", self.stats_type)) |
| 8985 | packed.append(struct.pack("!H", self.flags)) |
| 8986 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8987 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8988 | length = sum([len(x) for x in packed]) |
| 8989 | packed[2] = struct.pack("!H", length) |
| 8990 | return ''.join(packed) |
| 8991 | |
| 8992 | @staticmethod |
| 8993 | def unpack(buf): |
| 8994 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8995 | obj = port_stats_reply() |
| 8996 | if type(buf) == loxi.generic_util.OFReader: |
| 8997 | reader = buf |
| 8998 | else: |
| 8999 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9000 | _version = reader.read("!B")[0] |
| 9001 | assert(_version == 4) |
| 9002 | _type = reader.read("!B")[0] |
| 9003 | assert(_type == 19) |
| 9004 | _length = reader.read("!H")[0] |
| 9005 | obj.xid = reader.read("!L")[0] |
| 9006 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9007 | assert(_stats_type == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9008 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9009 | reader.skip(4) |
| 9010 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 9011 | return obj |
| 9012 | |
| 9013 | def __eq__(self, other): |
| 9014 | if type(self) != type(other): return False |
| 9015 | if self.version != other.version: return False |
| 9016 | if self.type != other.type: return False |
| 9017 | if self.xid != other.xid: return False |
| 9018 | if self.flags != other.flags: return False |
| 9019 | if self.entries != other.entries: return False |
| 9020 | return True |
| 9021 | |
| 9022 | def __ne__(self, other): |
| 9023 | return not self.__eq__(other) |
| 9024 | |
| 9025 | def __str__(self): |
| 9026 | return self.show() |
| 9027 | |
| 9028 | def show(self): |
| 9029 | import loxi.pp |
| 9030 | return loxi.pp.pp(self) |
| 9031 | |
| 9032 | def pretty_print(self, q): |
| 9033 | q.text("port_stats_reply {") |
| 9034 | with q.group(): |
| 9035 | with q.indent(2): |
| 9036 | q.breakable() |
| 9037 | q.text("xid = "); |
| 9038 | if self.xid != None: |
| 9039 | q.text("%#x" % self.xid) |
| 9040 | else: |
| 9041 | q.text('None') |
| 9042 | q.text(","); q.breakable() |
| 9043 | q.text("flags = "); |
| 9044 | q.text("%#x" % self.flags) |
| 9045 | q.text(","); q.breakable() |
| 9046 | q.text("entries = "); |
| 9047 | q.pp(self.entries) |
| 9048 | q.breakable() |
| 9049 | q.text('}') |
| 9050 | |
| 9051 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9052 | version = 4 |
| 9053 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9054 | stats_type = 4 |
| 9055 | |
| 9056 | def __init__(self, xid=None, flags=None, port_no=None): |
| 9057 | self.xid = xid |
| 9058 | if flags != None: |
| 9059 | self.flags = flags |
| 9060 | else: |
| 9061 | self.flags = 0 |
| 9062 | if port_no != None: |
| 9063 | self.port_no = port_no |
| 9064 | else: |
| 9065 | self.port_no = 0 |
| 9066 | |
| 9067 | def pack(self): |
| 9068 | packed = [] |
| 9069 | packed.append(struct.pack("!B", self.version)) |
| 9070 | packed.append(struct.pack("!B", self.type)) |
| 9071 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9072 | packed.append(struct.pack("!L", self.xid)) |
| 9073 | packed.append(struct.pack("!H", self.stats_type)) |
| 9074 | packed.append(struct.pack("!H", self.flags)) |
| 9075 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9076 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9077 | packed.append('\x00' * 4) |
| 9078 | length = sum([len(x) for x in packed]) |
| 9079 | packed[2] = struct.pack("!H", length) |
| 9080 | return ''.join(packed) |
| 9081 | |
| 9082 | @staticmethod |
| 9083 | def unpack(buf): |
| 9084 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9085 | obj = port_stats_request() |
| 9086 | if type(buf) == loxi.generic_util.OFReader: |
| 9087 | reader = buf |
| 9088 | else: |
| 9089 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9090 | _version = reader.read("!B")[0] |
| 9091 | assert(_version == 4) |
| 9092 | _type = reader.read("!B")[0] |
| 9093 | assert(_type == 18) |
| 9094 | _length = reader.read("!H")[0] |
| 9095 | obj.xid = reader.read("!L")[0] |
| 9096 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9097 | assert(_stats_type == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9098 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9099 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9100 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9101 | reader.skip(4) |
| 9102 | return obj |
| 9103 | |
| 9104 | def __eq__(self, other): |
| 9105 | if type(self) != type(other): return False |
| 9106 | if self.version != other.version: return False |
| 9107 | if self.type != other.type: return False |
| 9108 | if self.xid != other.xid: return False |
| 9109 | if self.flags != other.flags: return False |
| 9110 | if self.port_no != other.port_no: return False |
| 9111 | return True |
| 9112 | |
| 9113 | def __ne__(self, other): |
| 9114 | return not self.__eq__(other) |
| 9115 | |
| 9116 | def __str__(self): |
| 9117 | return self.show() |
| 9118 | |
| 9119 | def show(self): |
| 9120 | import loxi.pp |
| 9121 | return loxi.pp.pp(self) |
| 9122 | |
| 9123 | def pretty_print(self, q): |
| 9124 | q.text("port_stats_request {") |
| 9125 | with q.group(): |
| 9126 | with q.indent(2): |
| 9127 | q.breakable() |
| 9128 | q.text("xid = "); |
| 9129 | if self.xid != None: |
| 9130 | q.text("%#x" % self.xid) |
| 9131 | else: |
| 9132 | q.text('None') |
| 9133 | q.text(","); q.breakable() |
| 9134 | q.text("flags = "); |
| 9135 | q.text("%#x" % self.flags) |
| 9136 | q.text(","); q.breakable() |
| 9137 | q.text("port_no = "); |
| 9138 | q.text(util.pretty_port(self.port_no)) |
| 9139 | q.breakable() |
| 9140 | q.text('}') |
| 9141 | |
| 9142 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9143 | version = 4 |
| 9144 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9145 | |
| 9146 | def __init__(self, xid=None, reason=None, desc=None): |
| 9147 | self.xid = xid |
| 9148 | if reason != None: |
| 9149 | self.reason = reason |
| 9150 | else: |
| 9151 | self.reason = 0 |
| 9152 | if desc != None: |
| 9153 | self.desc = desc |
| 9154 | else: |
| 9155 | self.desc = common.port_desc() |
| 9156 | |
| 9157 | def pack(self): |
| 9158 | packed = [] |
| 9159 | packed.append(struct.pack("!B", self.version)) |
| 9160 | packed.append(struct.pack("!B", self.type)) |
| 9161 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9162 | packed.append(struct.pack("!L", self.xid)) |
| 9163 | packed.append(struct.pack("!B", self.reason)) |
| 9164 | packed.append('\x00' * 7) |
| 9165 | packed.append(self.desc.pack()) |
| 9166 | length = sum([len(x) for x in packed]) |
| 9167 | packed[2] = struct.pack("!H", length) |
| 9168 | return ''.join(packed) |
| 9169 | |
| 9170 | @staticmethod |
| 9171 | def unpack(buf): |
| 9172 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9173 | obj = port_status() |
| 9174 | if type(buf) == loxi.generic_util.OFReader: |
| 9175 | reader = buf |
| 9176 | else: |
| 9177 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9178 | _version = reader.read("!B")[0] |
| 9179 | assert(_version == 4) |
| 9180 | _type = reader.read("!B")[0] |
| 9181 | assert(_type == 12) |
| 9182 | _length = reader.read("!H")[0] |
| 9183 | obj.xid = reader.read("!L")[0] |
| 9184 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9185 | reader.skip(7) |
| 9186 | obj.desc = common.port_desc.unpack(reader) |
| 9187 | return obj |
| 9188 | |
| 9189 | def __eq__(self, other): |
| 9190 | if type(self) != type(other): return False |
| 9191 | if self.version != other.version: return False |
| 9192 | if self.type != other.type: return False |
| 9193 | if self.xid != other.xid: return False |
| 9194 | if self.reason != other.reason: return False |
| 9195 | if self.desc != other.desc: return False |
| 9196 | return True |
| 9197 | |
| 9198 | def __ne__(self, other): |
| 9199 | return not self.__eq__(other) |
| 9200 | |
| 9201 | def __str__(self): |
| 9202 | return self.show() |
| 9203 | |
| 9204 | def show(self): |
| 9205 | import loxi.pp |
| 9206 | return loxi.pp.pp(self) |
| 9207 | |
| 9208 | def pretty_print(self, q): |
| 9209 | q.text("port_status {") |
| 9210 | with q.group(): |
| 9211 | with q.indent(2): |
| 9212 | q.breakable() |
| 9213 | q.text("xid = "); |
| 9214 | if self.xid != None: |
| 9215 | q.text("%#x" % self.xid) |
| 9216 | else: |
| 9217 | q.text('None') |
| 9218 | q.text(","); q.breakable() |
| 9219 | q.text("reason = "); |
| 9220 | q.text("%#x" % self.reason) |
| 9221 | q.text(","); q.breakable() |
| 9222 | q.text("desc = "); |
| 9223 | q.pp(self.desc) |
| 9224 | q.breakable() |
| 9225 | q.text('}') |
| 9226 | |
| 9227 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9228 | version = 4 |
| 9229 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9230 | |
| 9231 | def __init__(self, xid=None, port=None, queues=None): |
| 9232 | self.xid = xid |
| 9233 | if port != None: |
| 9234 | self.port = port |
| 9235 | else: |
| 9236 | self.port = 0 |
| 9237 | if queues != None: |
| 9238 | self.queues = queues |
| 9239 | else: |
| 9240 | self.queues = [] |
| 9241 | |
| 9242 | def pack(self): |
| 9243 | packed = [] |
| 9244 | packed.append(struct.pack("!B", self.version)) |
| 9245 | packed.append(struct.pack("!B", self.type)) |
| 9246 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9247 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9248 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9249 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9250 | packed.append(util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9251 | length = sum([len(x) for x in packed]) |
| 9252 | packed[2] = struct.pack("!H", length) |
| 9253 | return ''.join(packed) |
| 9254 | |
| 9255 | @staticmethod |
| 9256 | def unpack(buf): |
| 9257 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9258 | obj = queue_get_config_reply() |
| 9259 | if type(buf) == loxi.generic_util.OFReader: |
| 9260 | reader = buf |
| 9261 | else: |
| 9262 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9263 | _version = reader.read("!B")[0] |
| 9264 | assert(_version == 4) |
| 9265 | _type = reader.read("!B")[0] |
| 9266 | assert(_type == 23) |
| 9267 | _length = reader.read("!H")[0] |
| 9268 | obj.xid = reader.read("!L")[0] |
| 9269 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9270 | reader.skip(4) |
| 9271 | obj.queues = common.unpack_list_packet_queue(reader) |
| 9272 | return obj |
| 9273 | |
| 9274 | def __eq__(self, other): |
| 9275 | if type(self) != type(other): return False |
| 9276 | if self.version != other.version: return False |
| 9277 | if self.type != other.type: return False |
| 9278 | if self.xid != other.xid: return False |
| 9279 | if self.port != other.port: return False |
| 9280 | if self.queues != other.queues: return False |
| 9281 | return True |
| 9282 | |
| 9283 | def __ne__(self, other): |
| 9284 | return not self.__eq__(other) |
| 9285 | |
| 9286 | def __str__(self): |
| 9287 | return self.show() |
| 9288 | |
| 9289 | def show(self): |
| 9290 | import loxi.pp |
| 9291 | return loxi.pp.pp(self) |
| 9292 | |
| 9293 | def pretty_print(self, q): |
| 9294 | q.text("queue_get_config_reply {") |
| 9295 | with q.group(): |
| 9296 | with q.indent(2): |
| 9297 | q.breakable() |
| 9298 | q.text("xid = "); |
| 9299 | if self.xid != None: |
| 9300 | q.text("%#x" % self.xid) |
| 9301 | else: |
| 9302 | q.text('None') |
| 9303 | q.text(","); q.breakable() |
| 9304 | q.text("port = "); |
| 9305 | q.text(util.pretty_port(self.port)) |
| 9306 | q.text(","); q.breakable() |
| 9307 | q.text("queues = "); |
| 9308 | q.pp(self.queues) |
| 9309 | q.breakable() |
| 9310 | q.text('}') |
| 9311 | |
| 9312 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9313 | version = 4 |
| 9314 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9315 | |
| 9316 | def __init__(self, xid=None, port=None): |
| 9317 | self.xid = xid |
| 9318 | if port != None: |
| 9319 | self.port = port |
| 9320 | else: |
| 9321 | self.port = 0 |
| 9322 | |
| 9323 | def pack(self): |
| 9324 | packed = [] |
| 9325 | packed.append(struct.pack("!B", self.version)) |
| 9326 | packed.append(struct.pack("!B", self.type)) |
| 9327 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9328 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9329 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9330 | packed.append('\x00' * 4) |
| 9331 | length = sum([len(x) for x in packed]) |
| 9332 | packed[2] = struct.pack("!H", length) |
| 9333 | return ''.join(packed) |
| 9334 | |
| 9335 | @staticmethod |
| 9336 | def unpack(buf): |
| 9337 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9338 | obj = queue_get_config_request() |
| 9339 | if type(buf) == loxi.generic_util.OFReader: |
| 9340 | reader = buf |
| 9341 | else: |
| 9342 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9343 | _version = reader.read("!B")[0] |
| 9344 | assert(_version == 4) |
| 9345 | _type = reader.read("!B")[0] |
| 9346 | assert(_type == 22) |
| 9347 | _length = reader.read("!H")[0] |
| 9348 | obj.xid = reader.read("!L")[0] |
| 9349 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9350 | reader.skip(4) |
| 9351 | return obj |
| 9352 | |
| 9353 | def __eq__(self, other): |
| 9354 | if type(self) != type(other): return False |
| 9355 | if self.version != other.version: return False |
| 9356 | if self.type != other.type: return False |
| 9357 | if self.xid != other.xid: return False |
| 9358 | if self.port != other.port: return False |
| 9359 | return True |
| 9360 | |
| 9361 | def __ne__(self, other): |
| 9362 | return not self.__eq__(other) |
| 9363 | |
| 9364 | def __str__(self): |
| 9365 | return self.show() |
| 9366 | |
| 9367 | def show(self): |
| 9368 | import loxi.pp |
| 9369 | return loxi.pp.pp(self) |
| 9370 | |
| 9371 | def pretty_print(self, q): |
| 9372 | q.text("queue_get_config_request {") |
| 9373 | with q.group(): |
| 9374 | with q.indent(2): |
| 9375 | q.breakable() |
| 9376 | q.text("xid = "); |
| 9377 | if self.xid != None: |
| 9378 | q.text("%#x" % self.xid) |
| 9379 | else: |
| 9380 | q.text('None') |
| 9381 | q.text(","); q.breakable() |
| 9382 | q.text("port = "); |
| 9383 | q.text(util.pretty_port(self.port)) |
| 9384 | q.breakable() |
| 9385 | q.text('}') |
| 9386 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9387 | class queue_op_failed_error_msg(Message): |
| 9388 | version = 4 |
| 9389 | type = 1 |
| 9390 | err_type = 9 |
| 9391 | |
| 9392 | def __init__(self, xid=None, code=None, data=None): |
| 9393 | self.xid = xid |
| 9394 | if code != None: |
| 9395 | self.code = code |
| 9396 | else: |
| 9397 | self.code = 0 |
| 9398 | if data != None: |
| 9399 | self.data = data |
| 9400 | else: |
| 9401 | self.data = '' |
| 9402 | |
| 9403 | def pack(self): |
| 9404 | packed = [] |
| 9405 | packed.append(struct.pack("!B", self.version)) |
| 9406 | packed.append(struct.pack("!B", self.type)) |
| 9407 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9408 | packed.append(struct.pack("!L", self.xid)) |
| 9409 | packed.append(struct.pack("!H", self.err_type)) |
| 9410 | packed.append(struct.pack("!H", self.code)) |
| 9411 | packed.append(self.data) |
| 9412 | length = sum([len(x) for x in packed]) |
| 9413 | packed[2] = struct.pack("!H", length) |
| 9414 | return ''.join(packed) |
| 9415 | |
| 9416 | @staticmethod |
| 9417 | def unpack(buf): |
| 9418 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9419 | obj = queue_op_failed_error_msg() |
| 9420 | if type(buf) == loxi.generic_util.OFReader: |
| 9421 | reader = buf |
| 9422 | else: |
| 9423 | reader = loxi.generic_util.OFReader(buf) |
| 9424 | _version = reader.read("!B")[0] |
| 9425 | assert(_version == 4) |
| 9426 | _type = reader.read("!B")[0] |
| 9427 | assert(_type == 1) |
| 9428 | _length = reader.read("!H")[0] |
| 9429 | obj.xid = reader.read("!L")[0] |
| 9430 | _err_type = reader.read("!H")[0] |
| 9431 | assert(_err_type == 9) |
| 9432 | obj.code = reader.read("!H")[0] |
| 9433 | obj.data = str(reader.read_all()) |
| 9434 | return obj |
| 9435 | |
| 9436 | def __eq__(self, other): |
| 9437 | if type(self) != type(other): return False |
| 9438 | if self.version != other.version: return False |
| 9439 | if self.type != other.type: return False |
| 9440 | if self.xid != other.xid: return False |
| 9441 | if self.code != other.code: return False |
| 9442 | if self.data != other.data: return False |
| 9443 | return True |
| 9444 | |
| 9445 | def __ne__(self, other): |
| 9446 | return not self.__eq__(other) |
| 9447 | |
| 9448 | def __str__(self): |
| 9449 | return self.show() |
| 9450 | |
| 9451 | def show(self): |
| 9452 | import loxi.pp |
| 9453 | return loxi.pp.pp(self) |
| 9454 | |
| 9455 | def pretty_print(self, q): |
| 9456 | q.text("queue_op_failed_error_msg {") |
| 9457 | with q.group(): |
| 9458 | with q.indent(2): |
| 9459 | q.breakable() |
| 9460 | q.text("xid = "); |
| 9461 | if self.xid != None: |
| 9462 | q.text("%#x" % self.xid) |
| 9463 | else: |
| 9464 | q.text('None') |
| 9465 | q.text(","); q.breakable() |
| 9466 | q.text("code = "); |
| 9467 | q.text("%#x" % self.code) |
| 9468 | q.text(","); q.breakable() |
| 9469 | q.text("data = "); |
| 9470 | q.pp(self.data) |
| 9471 | q.breakable() |
| 9472 | q.text('}') |
| 9473 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9474 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9475 | version = 4 |
| 9476 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9477 | stats_type = 5 |
| 9478 | |
| 9479 | def __init__(self, xid=None, flags=None, entries=None): |
| 9480 | self.xid = xid |
| 9481 | if flags != None: |
| 9482 | self.flags = flags |
| 9483 | else: |
| 9484 | self.flags = 0 |
| 9485 | if entries != None: |
| 9486 | self.entries = entries |
| 9487 | else: |
| 9488 | self.entries = [] |
| 9489 | |
| 9490 | def pack(self): |
| 9491 | packed = [] |
| 9492 | packed.append(struct.pack("!B", self.version)) |
| 9493 | packed.append(struct.pack("!B", self.type)) |
| 9494 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9495 | packed.append(struct.pack("!L", self.xid)) |
| 9496 | packed.append(struct.pack("!H", self.stats_type)) |
| 9497 | packed.append(struct.pack("!H", self.flags)) |
| 9498 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9499 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9500 | length = sum([len(x) for x in packed]) |
| 9501 | packed[2] = struct.pack("!H", length) |
| 9502 | return ''.join(packed) |
| 9503 | |
| 9504 | @staticmethod |
| 9505 | def unpack(buf): |
| 9506 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9507 | obj = queue_stats_reply() |
| 9508 | if type(buf) == loxi.generic_util.OFReader: |
| 9509 | reader = buf |
| 9510 | else: |
| 9511 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9512 | _version = reader.read("!B")[0] |
| 9513 | assert(_version == 4) |
| 9514 | _type = reader.read("!B")[0] |
| 9515 | assert(_type == 19) |
| 9516 | _length = reader.read("!H")[0] |
| 9517 | obj.xid = reader.read("!L")[0] |
| 9518 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9519 | assert(_stats_type == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9520 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9521 | reader.skip(4) |
| 9522 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 9523 | return obj |
| 9524 | |
| 9525 | def __eq__(self, other): |
| 9526 | if type(self) != type(other): return False |
| 9527 | if self.version != other.version: return False |
| 9528 | if self.type != other.type: return False |
| 9529 | if self.xid != other.xid: return False |
| 9530 | if self.flags != other.flags: return False |
| 9531 | if self.entries != other.entries: return False |
| 9532 | return True |
| 9533 | |
| 9534 | def __ne__(self, other): |
| 9535 | return not self.__eq__(other) |
| 9536 | |
| 9537 | def __str__(self): |
| 9538 | return self.show() |
| 9539 | |
| 9540 | def show(self): |
| 9541 | import loxi.pp |
| 9542 | return loxi.pp.pp(self) |
| 9543 | |
| 9544 | def pretty_print(self, q): |
| 9545 | q.text("queue_stats_reply {") |
| 9546 | with q.group(): |
| 9547 | with q.indent(2): |
| 9548 | q.breakable() |
| 9549 | q.text("xid = "); |
| 9550 | if self.xid != None: |
| 9551 | q.text("%#x" % self.xid) |
| 9552 | else: |
| 9553 | q.text('None') |
| 9554 | q.text(","); q.breakable() |
| 9555 | q.text("flags = "); |
| 9556 | q.text("%#x" % self.flags) |
| 9557 | q.text(","); q.breakable() |
| 9558 | q.text("entries = "); |
| 9559 | q.pp(self.entries) |
| 9560 | q.breakable() |
| 9561 | q.text('}') |
| 9562 | |
| 9563 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9564 | version = 4 |
| 9565 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9566 | stats_type = 5 |
| 9567 | |
| 9568 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
| 9569 | self.xid = xid |
| 9570 | if flags != None: |
| 9571 | self.flags = flags |
| 9572 | else: |
| 9573 | self.flags = 0 |
| 9574 | if port_no != None: |
| 9575 | self.port_no = port_no |
| 9576 | else: |
| 9577 | self.port_no = 0 |
| 9578 | if queue_id != None: |
| 9579 | self.queue_id = queue_id |
| 9580 | else: |
| 9581 | self.queue_id = 0 |
| 9582 | |
| 9583 | def pack(self): |
| 9584 | packed = [] |
| 9585 | packed.append(struct.pack("!B", self.version)) |
| 9586 | packed.append(struct.pack("!B", self.type)) |
| 9587 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9588 | packed.append(struct.pack("!L", self.xid)) |
| 9589 | packed.append(struct.pack("!H", self.stats_type)) |
| 9590 | packed.append(struct.pack("!H", self.flags)) |
| 9591 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9592 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9593 | packed.append(struct.pack("!L", self.queue_id)) |
| 9594 | length = sum([len(x) for x in packed]) |
| 9595 | packed[2] = struct.pack("!H", length) |
| 9596 | return ''.join(packed) |
| 9597 | |
| 9598 | @staticmethod |
| 9599 | def unpack(buf): |
| 9600 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9601 | obj = queue_stats_request() |
| 9602 | if type(buf) == loxi.generic_util.OFReader: |
| 9603 | reader = buf |
| 9604 | else: |
| 9605 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9606 | _version = reader.read("!B")[0] |
| 9607 | assert(_version == 4) |
| 9608 | _type = reader.read("!B")[0] |
| 9609 | assert(_type == 18) |
| 9610 | _length = reader.read("!H")[0] |
| 9611 | obj.xid = reader.read("!L")[0] |
| 9612 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9613 | assert(_stats_type == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9614 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9615 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9616 | obj.port_no = util.unpack_port_no(reader) |
| 9617 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9618 | return obj |
| 9619 | |
| 9620 | def __eq__(self, other): |
| 9621 | if type(self) != type(other): return False |
| 9622 | if self.version != other.version: return False |
| 9623 | if self.type != other.type: return False |
| 9624 | if self.xid != other.xid: return False |
| 9625 | if self.flags != other.flags: return False |
| 9626 | if self.port_no != other.port_no: return False |
| 9627 | if self.queue_id != other.queue_id: return False |
| 9628 | return True |
| 9629 | |
| 9630 | def __ne__(self, other): |
| 9631 | return not self.__eq__(other) |
| 9632 | |
| 9633 | def __str__(self): |
| 9634 | return self.show() |
| 9635 | |
| 9636 | def show(self): |
| 9637 | import loxi.pp |
| 9638 | return loxi.pp.pp(self) |
| 9639 | |
| 9640 | def pretty_print(self, q): |
| 9641 | q.text("queue_stats_request {") |
| 9642 | with q.group(): |
| 9643 | with q.indent(2): |
| 9644 | q.breakable() |
| 9645 | q.text("xid = "); |
| 9646 | if self.xid != None: |
| 9647 | q.text("%#x" % self.xid) |
| 9648 | else: |
| 9649 | q.text('None') |
| 9650 | q.text(","); q.breakable() |
| 9651 | q.text("flags = "); |
| 9652 | q.text("%#x" % self.flags) |
| 9653 | q.text(","); q.breakable() |
| 9654 | q.text("port_no = "); |
| 9655 | q.text(util.pretty_port(self.port_no)) |
| 9656 | q.text(","); q.breakable() |
| 9657 | q.text("queue_id = "); |
| 9658 | q.text("%#x" % self.queue_id) |
| 9659 | q.breakable() |
| 9660 | q.text('}') |
| 9661 | |
| 9662 | class role_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9663 | version = 4 |
| 9664 | type = 25 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9665 | |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9666 | def __init__(self, xid=None, role=None, generation_id=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9667 | self.xid = xid |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9668 | if role != None: |
| 9669 | self.role = role |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9670 | else: |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9671 | self.role = 0 |
| 9672 | if generation_id != None: |
| 9673 | self.generation_id = generation_id |
| 9674 | else: |
| 9675 | self.generation_id = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9676 | |
| 9677 | def pack(self): |
| 9678 | packed = [] |
| 9679 | packed.append(struct.pack("!B", self.version)) |
| 9680 | packed.append(struct.pack("!B", self.type)) |
| 9681 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9682 | packed.append(struct.pack("!L", self.xid)) |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9683 | packed.append(struct.pack("!L", self.role)) |
| 9684 | packed.append('\x00' * 4) |
| 9685 | packed.append(struct.pack("!Q", self.generation_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9686 | length = sum([len(x) for x in packed]) |
| 9687 | packed[2] = struct.pack("!H", length) |
| 9688 | return ''.join(packed) |
| 9689 | |
| 9690 | @staticmethod |
| 9691 | def unpack(buf): |
| 9692 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9693 | obj = role_reply() |
| 9694 | if type(buf) == loxi.generic_util.OFReader: |
| 9695 | reader = buf |
| 9696 | else: |
| 9697 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9698 | _version = reader.read("!B")[0] |
| 9699 | assert(_version == 4) |
| 9700 | _type = reader.read("!B")[0] |
| 9701 | assert(_type == 25) |
| 9702 | _length = reader.read("!H")[0] |
| 9703 | obj.xid = reader.read("!L")[0] |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9704 | obj.role = reader.read("!L")[0] |
| 9705 | reader.skip(4) |
| 9706 | obj.generation_id = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9707 | return obj |
| 9708 | |
| 9709 | def __eq__(self, other): |
| 9710 | if type(self) != type(other): return False |
| 9711 | if self.version != other.version: return False |
| 9712 | if self.type != other.type: return False |
| 9713 | if self.xid != other.xid: return False |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9714 | if self.role != other.role: return False |
| 9715 | if self.generation_id != other.generation_id: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9716 | return True |
| 9717 | |
| 9718 | def __ne__(self, other): |
| 9719 | return not self.__eq__(other) |
| 9720 | |
| 9721 | def __str__(self): |
| 9722 | return self.show() |
| 9723 | |
| 9724 | def show(self): |
| 9725 | import loxi.pp |
| 9726 | return loxi.pp.pp(self) |
| 9727 | |
| 9728 | def pretty_print(self, q): |
| 9729 | q.text("role_reply {") |
| 9730 | with q.group(): |
| 9731 | with q.indent(2): |
| 9732 | q.breakable() |
| 9733 | q.text("xid = "); |
| 9734 | if self.xid != None: |
| 9735 | q.text("%#x" % self.xid) |
| 9736 | else: |
| 9737 | q.text('None') |
| 9738 | q.text(","); q.breakable() |
Rich Lane | d9e3f7b | 2013-11-04 11:40:43 -0800 | [diff] [blame] | 9739 | q.text("role = "); |
| 9740 | q.text("%#x" % self.role) |
| 9741 | q.text(","); q.breakable() |
| 9742 | q.text("generation_id = "); |
| 9743 | q.text("%#x" % self.generation_id) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9744 | q.breakable() |
| 9745 | q.text('}') |
| 9746 | |
| 9747 | class role_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9748 | version = 4 |
| 9749 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9750 | |
| 9751 | def __init__(self, xid=None, role=None, generation_id=None): |
| 9752 | self.xid = xid |
| 9753 | if role != None: |
| 9754 | self.role = role |
| 9755 | else: |
| 9756 | self.role = 0 |
| 9757 | if generation_id != None: |
| 9758 | self.generation_id = generation_id |
| 9759 | else: |
| 9760 | self.generation_id = 0 |
| 9761 | |
| 9762 | def pack(self): |
| 9763 | packed = [] |
| 9764 | packed.append(struct.pack("!B", self.version)) |
| 9765 | packed.append(struct.pack("!B", self.type)) |
| 9766 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9767 | packed.append(struct.pack("!L", self.xid)) |
| 9768 | packed.append(struct.pack("!L", self.role)) |
| 9769 | packed.append('\x00' * 4) |
| 9770 | packed.append(struct.pack("!Q", self.generation_id)) |
| 9771 | length = sum([len(x) for x in packed]) |
| 9772 | packed[2] = struct.pack("!H", length) |
| 9773 | return ''.join(packed) |
| 9774 | |
| 9775 | @staticmethod |
| 9776 | def unpack(buf): |
| 9777 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9778 | obj = role_request() |
| 9779 | if type(buf) == loxi.generic_util.OFReader: |
| 9780 | reader = buf |
| 9781 | else: |
| 9782 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9783 | _version = reader.read("!B")[0] |
| 9784 | assert(_version == 4) |
| 9785 | _type = reader.read("!B")[0] |
| 9786 | assert(_type == 24) |
| 9787 | _length = reader.read("!H")[0] |
| 9788 | obj.xid = reader.read("!L")[0] |
| 9789 | obj.role = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9790 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9791 | obj.generation_id = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9792 | return obj |
| 9793 | |
| 9794 | def __eq__(self, other): |
| 9795 | if type(self) != type(other): return False |
| 9796 | if self.version != other.version: return False |
| 9797 | if self.type != other.type: return False |
| 9798 | if self.xid != other.xid: return False |
| 9799 | if self.role != other.role: return False |
| 9800 | if self.generation_id != other.generation_id: return False |
| 9801 | return True |
| 9802 | |
| 9803 | def __ne__(self, other): |
| 9804 | return not self.__eq__(other) |
| 9805 | |
| 9806 | def __str__(self): |
| 9807 | return self.show() |
| 9808 | |
| 9809 | def show(self): |
| 9810 | import loxi.pp |
| 9811 | return loxi.pp.pp(self) |
| 9812 | |
| 9813 | def pretty_print(self, q): |
| 9814 | q.text("role_request {") |
| 9815 | with q.group(): |
| 9816 | with q.indent(2): |
| 9817 | q.breakable() |
| 9818 | q.text("xid = "); |
| 9819 | if self.xid != None: |
| 9820 | q.text("%#x" % self.xid) |
| 9821 | else: |
| 9822 | q.text('None') |
| 9823 | q.text(","); q.breakable() |
| 9824 | q.text("role = "); |
| 9825 | q.text("%#x" % self.role) |
| 9826 | q.text(","); q.breakable() |
| 9827 | q.text("generation_id = "); |
| 9828 | q.text("%#x" % self.generation_id) |
| 9829 | q.breakable() |
| 9830 | q.text('}') |
| 9831 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9832 | class role_request_failed_error_msg(Message): |
| 9833 | version = 4 |
| 9834 | type = 1 |
| 9835 | err_type = 11 |
| 9836 | |
| 9837 | def __init__(self, xid=None, code=None, data=None): |
| 9838 | self.xid = xid |
| 9839 | if code != None: |
| 9840 | self.code = code |
| 9841 | else: |
| 9842 | self.code = 0 |
| 9843 | if data != None: |
| 9844 | self.data = data |
| 9845 | else: |
| 9846 | self.data = '' |
| 9847 | |
| 9848 | def pack(self): |
| 9849 | packed = [] |
| 9850 | packed.append(struct.pack("!B", self.version)) |
| 9851 | packed.append(struct.pack("!B", self.type)) |
| 9852 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9853 | packed.append(struct.pack("!L", self.xid)) |
| 9854 | packed.append(struct.pack("!H", self.err_type)) |
| 9855 | packed.append(struct.pack("!H", self.code)) |
| 9856 | packed.append(self.data) |
| 9857 | length = sum([len(x) for x in packed]) |
| 9858 | packed[2] = struct.pack("!H", length) |
| 9859 | return ''.join(packed) |
| 9860 | |
| 9861 | @staticmethod |
| 9862 | def unpack(buf): |
| 9863 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9864 | obj = role_request_failed_error_msg() |
| 9865 | if type(buf) == loxi.generic_util.OFReader: |
| 9866 | reader = buf |
| 9867 | else: |
| 9868 | reader = loxi.generic_util.OFReader(buf) |
| 9869 | _version = reader.read("!B")[0] |
| 9870 | assert(_version == 4) |
| 9871 | _type = reader.read("!B")[0] |
| 9872 | assert(_type == 1) |
| 9873 | _length = reader.read("!H")[0] |
| 9874 | obj.xid = reader.read("!L")[0] |
| 9875 | _err_type = reader.read("!H")[0] |
| 9876 | assert(_err_type == 11) |
| 9877 | obj.code = reader.read("!H")[0] |
| 9878 | obj.data = str(reader.read_all()) |
| 9879 | return obj |
| 9880 | |
| 9881 | def __eq__(self, other): |
| 9882 | if type(self) != type(other): return False |
| 9883 | if self.version != other.version: return False |
| 9884 | if self.type != other.type: return False |
| 9885 | if self.xid != other.xid: return False |
| 9886 | if self.code != other.code: return False |
| 9887 | if self.data != other.data: return False |
| 9888 | return True |
| 9889 | |
| 9890 | def __ne__(self, other): |
| 9891 | return not self.__eq__(other) |
| 9892 | |
| 9893 | def __str__(self): |
| 9894 | return self.show() |
| 9895 | |
| 9896 | def show(self): |
| 9897 | import loxi.pp |
| 9898 | return loxi.pp.pp(self) |
| 9899 | |
| 9900 | def pretty_print(self, q): |
| 9901 | q.text("role_request_failed_error_msg {") |
| 9902 | with q.group(): |
| 9903 | with q.indent(2): |
| 9904 | q.breakable() |
| 9905 | q.text("xid = "); |
| 9906 | if self.xid != None: |
| 9907 | q.text("%#x" % self.xid) |
| 9908 | else: |
| 9909 | q.text('None') |
| 9910 | q.text(","); q.breakable() |
| 9911 | q.text("code = "); |
| 9912 | q.text("%#x" % self.code) |
| 9913 | q.text(","); q.breakable() |
| 9914 | q.text("data = "); |
| 9915 | q.pp(self.data) |
| 9916 | q.breakable() |
| 9917 | q.text('}') |
| 9918 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9919 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9920 | version = 4 |
| 9921 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9922 | |
| 9923 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 9924 | self.xid = xid |
| 9925 | if flags != None: |
| 9926 | self.flags = flags |
| 9927 | else: |
| 9928 | self.flags = 0 |
| 9929 | if miss_send_len != None: |
| 9930 | self.miss_send_len = miss_send_len |
| 9931 | else: |
| 9932 | self.miss_send_len = 0 |
| 9933 | |
| 9934 | def pack(self): |
| 9935 | packed = [] |
| 9936 | packed.append(struct.pack("!B", self.version)) |
| 9937 | packed.append(struct.pack("!B", self.type)) |
| 9938 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9939 | packed.append(struct.pack("!L", self.xid)) |
| 9940 | packed.append(struct.pack("!H", self.flags)) |
| 9941 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 9942 | length = sum([len(x) for x in packed]) |
| 9943 | packed[2] = struct.pack("!H", length) |
| 9944 | return ''.join(packed) |
| 9945 | |
| 9946 | @staticmethod |
| 9947 | def unpack(buf): |
| 9948 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9949 | obj = set_config() |
| 9950 | if type(buf) == loxi.generic_util.OFReader: |
| 9951 | reader = buf |
| 9952 | else: |
| 9953 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9954 | _version = reader.read("!B")[0] |
| 9955 | assert(_version == 4) |
| 9956 | _type = reader.read("!B")[0] |
| 9957 | assert(_type == 9) |
| 9958 | _length = reader.read("!H")[0] |
| 9959 | obj.xid = reader.read("!L")[0] |
| 9960 | obj.flags = reader.read("!H")[0] |
| 9961 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9962 | return obj |
| 9963 | |
| 9964 | def __eq__(self, other): |
| 9965 | if type(self) != type(other): return False |
| 9966 | if self.version != other.version: return False |
| 9967 | if self.type != other.type: return False |
| 9968 | if self.xid != other.xid: return False |
| 9969 | if self.flags != other.flags: return False |
| 9970 | if self.miss_send_len != other.miss_send_len: return False |
| 9971 | return True |
| 9972 | |
| 9973 | def __ne__(self, other): |
| 9974 | return not self.__eq__(other) |
| 9975 | |
| 9976 | def __str__(self): |
| 9977 | return self.show() |
| 9978 | |
| 9979 | def show(self): |
| 9980 | import loxi.pp |
| 9981 | return loxi.pp.pp(self) |
| 9982 | |
| 9983 | def pretty_print(self, q): |
| 9984 | q.text("set_config {") |
| 9985 | with q.group(): |
| 9986 | with q.indent(2): |
| 9987 | q.breakable() |
| 9988 | q.text("xid = "); |
| 9989 | if self.xid != None: |
| 9990 | q.text("%#x" % self.xid) |
| 9991 | else: |
| 9992 | q.text('None') |
| 9993 | q.text(","); q.breakable() |
| 9994 | q.text("flags = "); |
| 9995 | q.text("%#x" % self.flags) |
| 9996 | q.text(","); q.breakable() |
| 9997 | q.text("miss_send_len = "); |
| 9998 | q.text("%#x" % self.miss_send_len) |
| 9999 | q.breakable() |
| 10000 | q.text('}') |
| 10001 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10002 | class switch_config_failed_error_msg(Message): |
| 10003 | version = 4 |
| 10004 | type = 1 |
| 10005 | err_type = 10 |
| 10006 | |
| 10007 | def __init__(self, xid=None, code=None, data=None): |
| 10008 | self.xid = xid |
| 10009 | if code != None: |
| 10010 | self.code = code |
| 10011 | else: |
| 10012 | self.code = 0 |
| 10013 | if data != None: |
| 10014 | self.data = data |
| 10015 | else: |
| 10016 | self.data = '' |
| 10017 | |
| 10018 | def pack(self): |
| 10019 | packed = [] |
| 10020 | packed.append(struct.pack("!B", self.version)) |
| 10021 | packed.append(struct.pack("!B", self.type)) |
| 10022 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10023 | packed.append(struct.pack("!L", self.xid)) |
| 10024 | packed.append(struct.pack("!H", self.err_type)) |
| 10025 | packed.append(struct.pack("!H", self.code)) |
| 10026 | packed.append(self.data) |
| 10027 | length = sum([len(x) for x in packed]) |
| 10028 | packed[2] = struct.pack("!H", length) |
| 10029 | return ''.join(packed) |
| 10030 | |
| 10031 | @staticmethod |
| 10032 | def unpack(buf): |
| 10033 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10034 | obj = switch_config_failed_error_msg() |
| 10035 | if type(buf) == loxi.generic_util.OFReader: |
| 10036 | reader = buf |
| 10037 | else: |
| 10038 | reader = loxi.generic_util.OFReader(buf) |
| 10039 | _version = reader.read("!B")[0] |
| 10040 | assert(_version == 4) |
| 10041 | _type = reader.read("!B")[0] |
| 10042 | assert(_type == 1) |
| 10043 | _length = reader.read("!H")[0] |
| 10044 | obj.xid = reader.read("!L")[0] |
| 10045 | _err_type = reader.read("!H")[0] |
| 10046 | assert(_err_type == 10) |
| 10047 | obj.code = reader.read("!H")[0] |
| 10048 | obj.data = str(reader.read_all()) |
| 10049 | return obj |
| 10050 | |
| 10051 | def __eq__(self, other): |
| 10052 | if type(self) != type(other): return False |
| 10053 | if self.version != other.version: return False |
| 10054 | if self.type != other.type: return False |
| 10055 | if self.xid != other.xid: return False |
| 10056 | if self.code != other.code: return False |
| 10057 | if self.data != other.data: return False |
| 10058 | return True |
| 10059 | |
| 10060 | def __ne__(self, other): |
| 10061 | return not self.__eq__(other) |
| 10062 | |
| 10063 | def __str__(self): |
| 10064 | return self.show() |
| 10065 | |
| 10066 | def show(self): |
| 10067 | import loxi.pp |
| 10068 | return loxi.pp.pp(self) |
| 10069 | |
| 10070 | def pretty_print(self, q): |
| 10071 | q.text("switch_config_failed_error_msg {") |
| 10072 | with q.group(): |
| 10073 | with q.indent(2): |
| 10074 | q.breakable() |
| 10075 | q.text("xid = "); |
| 10076 | if self.xid != None: |
| 10077 | q.text("%#x" % self.xid) |
| 10078 | else: |
| 10079 | q.text('None') |
| 10080 | q.text(","); q.breakable() |
| 10081 | q.text("code = "); |
| 10082 | q.text("%#x" % self.code) |
| 10083 | q.text(","); q.breakable() |
| 10084 | q.text("data = "); |
| 10085 | q.pp(self.data) |
| 10086 | q.breakable() |
| 10087 | q.text('}') |
| 10088 | |
| 10089 | class table_features_failed_error_msg(Message): |
| 10090 | version = 4 |
| 10091 | type = 1 |
| 10092 | err_type = 13 |
| 10093 | |
| 10094 | def __init__(self, xid=None, code=None, data=None): |
| 10095 | self.xid = xid |
| 10096 | if code != None: |
| 10097 | self.code = code |
| 10098 | else: |
| 10099 | self.code = 0 |
| 10100 | if data != None: |
| 10101 | self.data = data |
| 10102 | else: |
| 10103 | self.data = '' |
| 10104 | |
| 10105 | def pack(self): |
| 10106 | packed = [] |
| 10107 | packed.append(struct.pack("!B", self.version)) |
| 10108 | packed.append(struct.pack("!B", self.type)) |
| 10109 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10110 | packed.append(struct.pack("!L", self.xid)) |
| 10111 | packed.append(struct.pack("!H", self.err_type)) |
| 10112 | packed.append(struct.pack("!H", self.code)) |
| 10113 | packed.append(self.data) |
| 10114 | length = sum([len(x) for x in packed]) |
| 10115 | packed[2] = struct.pack("!H", length) |
| 10116 | return ''.join(packed) |
| 10117 | |
| 10118 | @staticmethod |
| 10119 | def unpack(buf): |
| 10120 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10121 | obj = table_features_failed_error_msg() |
| 10122 | if type(buf) == loxi.generic_util.OFReader: |
| 10123 | reader = buf |
| 10124 | else: |
| 10125 | reader = loxi.generic_util.OFReader(buf) |
| 10126 | _version = reader.read("!B")[0] |
| 10127 | assert(_version == 4) |
| 10128 | _type = reader.read("!B")[0] |
| 10129 | assert(_type == 1) |
| 10130 | _length = reader.read("!H")[0] |
| 10131 | obj.xid = reader.read("!L")[0] |
| 10132 | _err_type = reader.read("!H")[0] |
| 10133 | assert(_err_type == 13) |
| 10134 | obj.code = reader.read("!H")[0] |
| 10135 | obj.data = str(reader.read_all()) |
| 10136 | return obj |
| 10137 | |
| 10138 | def __eq__(self, other): |
| 10139 | if type(self) != type(other): return False |
| 10140 | if self.version != other.version: return False |
| 10141 | if self.type != other.type: return False |
| 10142 | if self.xid != other.xid: return False |
| 10143 | if self.code != other.code: return False |
| 10144 | if self.data != other.data: return False |
| 10145 | return True |
| 10146 | |
| 10147 | def __ne__(self, other): |
| 10148 | return not self.__eq__(other) |
| 10149 | |
| 10150 | def __str__(self): |
| 10151 | return self.show() |
| 10152 | |
| 10153 | def show(self): |
| 10154 | import loxi.pp |
| 10155 | return loxi.pp.pp(self) |
| 10156 | |
| 10157 | def pretty_print(self, q): |
| 10158 | q.text("table_features_failed_error_msg {") |
| 10159 | with q.group(): |
| 10160 | with q.indent(2): |
| 10161 | q.breakable() |
| 10162 | q.text("xid = "); |
| 10163 | if self.xid != None: |
| 10164 | q.text("%#x" % self.xid) |
| 10165 | else: |
| 10166 | q.text('None') |
| 10167 | q.text(","); q.breakable() |
| 10168 | q.text("code = "); |
| 10169 | q.text("%#x" % self.code) |
| 10170 | q.text(","); q.breakable() |
| 10171 | q.text("data = "); |
| 10172 | q.pp(self.data) |
| 10173 | q.breakable() |
| 10174 | q.text('}') |
| 10175 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10176 | class table_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10177 | version = 4 |
| 10178 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10179 | stats_type = 12 |
| 10180 | |
| 10181 | def __init__(self, xid=None, flags=None, entries=None): |
| 10182 | self.xid = xid |
| 10183 | if flags != None: |
| 10184 | self.flags = flags |
| 10185 | else: |
| 10186 | self.flags = 0 |
| 10187 | if entries != None: |
| 10188 | self.entries = entries |
| 10189 | else: |
| 10190 | self.entries = [] |
| 10191 | |
| 10192 | def pack(self): |
| 10193 | packed = [] |
| 10194 | packed.append(struct.pack("!B", self.version)) |
| 10195 | packed.append(struct.pack("!B", self.type)) |
| 10196 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10197 | packed.append(struct.pack("!L", self.xid)) |
| 10198 | packed.append(struct.pack("!H", self.stats_type)) |
| 10199 | packed.append(struct.pack("!H", self.flags)) |
| 10200 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10201 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10202 | length = sum([len(x) for x in packed]) |
| 10203 | packed[2] = struct.pack("!H", length) |
| 10204 | return ''.join(packed) |
| 10205 | |
| 10206 | @staticmethod |
| 10207 | def unpack(buf): |
| 10208 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10209 | obj = table_features_stats_reply() |
| 10210 | if type(buf) == loxi.generic_util.OFReader: |
| 10211 | reader = buf |
| 10212 | else: |
| 10213 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10214 | _version = reader.read("!B")[0] |
| 10215 | assert(_version == 4) |
| 10216 | _type = reader.read("!B")[0] |
| 10217 | assert(_type == 19) |
| 10218 | _length = reader.read("!H")[0] |
| 10219 | obj.xid = reader.read("!L")[0] |
| 10220 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10221 | assert(_stats_type == 12) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10222 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10223 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10224 | obj.entries = loxi.unimplemented('unpack list(of_table_features_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10225 | return obj |
| 10226 | |
| 10227 | def __eq__(self, other): |
| 10228 | if type(self) != type(other): return False |
| 10229 | if self.version != other.version: return False |
| 10230 | if self.type != other.type: return False |
| 10231 | if self.xid != other.xid: return False |
| 10232 | if self.flags != other.flags: return False |
| 10233 | if self.entries != other.entries: return False |
| 10234 | return True |
| 10235 | |
| 10236 | def __ne__(self, other): |
| 10237 | return not self.__eq__(other) |
| 10238 | |
| 10239 | def __str__(self): |
| 10240 | return self.show() |
| 10241 | |
| 10242 | def show(self): |
| 10243 | import loxi.pp |
| 10244 | return loxi.pp.pp(self) |
| 10245 | |
| 10246 | def pretty_print(self, q): |
| 10247 | q.text("table_features_stats_reply {") |
| 10248 | with q.group(): |
| 10249 | with q.indent(2): |
| 10250 | q.breakable() |
| 10251 | q.text("xid = "); |
| 10252 | if self.xid != None: |
| 10253 | q.text("%#x" % self.xid) |
| 10254 | else: |
| 10255 | q.text('None') |
| 10256 | q.text(","); q.breakable() |
| 10257 | q.text("flags = "); |
| 10258 | q.text("%#x" % self.flags) |
| 10259 | q.text(","); q.breakable() |
| 10260 | q.text("entries = "); |
| 10261 | q.pp(self.entries) |
| 10262 | q.breakable() |
| 10263 | q.text('}') |
| 10264 | |
| 10265 | class table_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10266 | version = 4 |
| 10267 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10268 | stats_type = 12 |
| 10269 | |
| 10270 | def __init__(self, xid=None, flags=None, entries=None): |
| 10271 | self.xid = xid |
| 10272 | if flags != None: |
| 10273 | self.flags = flags |
| 10274 | else: |
| 10275 | self.flags = 0 |
| 10276 | if entries != None: |
| 10277 | self.entries = entries |
| 10278 | else: |
| 10279 | self.entries = [] |
| 10280 | |
| 10281 | def pack(self): |
| 10282 | packed = [] |
| 10283 | packed.append(struct.pack("!B", self.version)) |
| 10284 | packed.append(struct.pack("!B", self.type)) |
| 10285 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10286 | packed.append(struct.pack("!L", self.xid)) |
| 10287 | packed.append(struct.pack("!H", self.stats_type)) |
| 10288 | packed.append(struct.pack("!H", self.flags)) |
| 10289 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10290 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10291 | length = sum([len(x) for x in packed]) |
| 10292 | packed[2] = struct.pack("!H", length) |
| 10293 | return ''.join(packed) |
| 10294 | |
| 10295 | @staticmethod |
| 10296 | def unpack(buf): |
| 10297 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10298 | obj = table_features_stats_request() |
| 10299 | if type(buf) == loxi.generic_util.OFReader: |
| 10300 | reader = buf |
| 10301 | else: |
| 10302 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10303 | _version = reader.read("!B")[0] |
| 10304 | assert(_version == 4) |
| 10305 | _type = reader.read("!B")[0] |
| 10306 | assert(_type == 18) |
| 10307 | _length = reader.read("!H")[0] |
| 10308 | obj.xid = reader.read("!L")[0] |
| 10309 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10310 | assert(_stats_type == 12) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10311 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10312 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10313 | obj.entries = loxi.unimplemented('unpack list(of_table_features_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10314 | return obj |
| 10315 | |
| 10316 | def __eq__(self, other): |
| 10317 | if type(self) != type(other): return False |
| 10318 | if self.version != other.version: return False |
| 10319 | if self.type != other.type: return False |
| 10320 | if self.xid != other.xid: return False |
| 10321 | if self.flags != other.flags: return False |
| 10322 | if self.entries != other.entries: return False |
| 10323 | return True |
| 10324 | |
| 10325 | def __ne__(self, other): |
| 10326 | return not self.__eq__(other) |
| 10327 | |
| 10328 | def __str__(self): |
| 10329 | return self.show() |
| 10330 | |
| 10331 | def show(self): |
| 10332 | import loxi.pp |
| 10333 | return loxi.pp.pp(self) |
| 10334 | |
| 10335 | def pretty_print(self, q): |
| 10336 | q.text("table_features_stats_request {") |
| 10337 | with q.group(): |
| 10338 | with q.indent(2): |
| 10339 | q.breakable() |
| 10340 | q.text("xid = "); |
| 10341 | if self.xid != None: |
| 10342 | q.text("%#x" % self.xid) |
| 10343 | else: |
| 10344 | q.text('None') |
| 10345 | q.text(","); q.breakable() |
| 10346 | q.text("flags = "); |
| 10347 | q.text("%#x" % self.flags) |
| 10348 | q.text(","); q.breakable() |
| 10349 | q.text("entries = "); |
| 10350 | q.pp(self.entries) |
| 10351 | q.breakable() |
| 10352 | q.text('}') |
| 10353 | |
| 10354 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10355 | version = 4 |
| 10356 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10357 | |
| 10358 | def __init__(self, xid=None, table_id=None, config=None): |
| 10359 | self.xid = xid |
| 10360 | if table_id != None: |
| 10361 | self.table_id = table_id |
| 10362 | else: |
| 10363 | self.table_id = 0 |
| 10364 | if config != None: |
| 10365 | self.config = config |
| 10366 | else: |
| 10367 | self.config = 0 |
| 10368 | |
| 10369 | def pack(self): |
| 10370 | packed = [] |
| 10371 | packed.append(struct.pack("!B", self.version)) |
| 10372 | packed.append(struct.pack("!B", self.type)) |
| 10373 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10374 | packed.append(struct.pack("!L", self.xid)) |
| 10375 | packed.append(struct.pack("!B", self.table_id)) |
| 10376 | packed.append('\x00' * 3) |
| 10377 | packed.append(struct.pack("!L", self.config)) |
| 10378 | length = sum([len(x) for x in packed]) |
| 10379 | packed[2] = struct.pack("!H", length) |
| 10380 | return ''.join(packed) |
| 10381 | |
| 10382 | @staticmethod |
| 10383 | def unpack(buf): |
| 10384 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10385 | obj = table_mod() |
| 10386 | if type(buf) == loxi.generic_util.OFReader: |
| 10387 | reader = buf |
| 10388 | else: |
| 10389 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10390 | _version = reader.read("!B")[0] |
| 10391 | assert(_version == 4) |
| 10392 | _type = reader.read("!B")[0] |
| 10393 | assert(_type == 17) |
| 10394 | _length = reader.read("!H")[0] |
| 10395 | obj.xid = reader.read("!L")[0] |
| 10396 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10397 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10398 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10399 | return obj |
| 10400 | |
| 10401 | def __eq__(self, other): |
| 10402 | if type(self) != type(other): return False |
| 10403 | if self.version != other.version: return False |
| 10404 | if self.type != other.type: return False |
| 10405 | if self.xid != other.xid: return False |
| 10406 | if self.table_id != other.table_id: return False |
| 10407 | if self.config != other.config: return False |
| 10408 | return True |
| 10409 | |
| 10410 | def __ne__(self, other): |
| 10411 | return not self.__eq__(other) |
| 10412 | |
| 10413 | def __str__(self): |
| 10414 | return self.show() |
| 10415 | |
| 10416 | def show(self): |
| 10417 | import loxi.pp |
| 10418 | return loxi.pp.pp(self) |
| 10419 | |
| 10420 | def pretty_print(self, q): |
| 10421 | q.text("table_mod {") |
| 10422 | with q.group(): |
| 10423 | with q.indent(2): |
| 10424 | q.breakable() |
| 10425 | q.text("xid = "); |
| 10426 | if self.xid != None: |
| 10427 | q.text("%#x" % self.xid) |
| 10428 | else: |
| 10429 | q.text('None') |
| 10430 | q.text(","); q.breakable() |
| 10431 | q.text("table_id = "); |
| 10432 | q.text("%#x" % self.table_id) |
| 10433 | q.text(","); q.breakable() |
| 10434 | q.text("config = "); |
| 10435 | q.text("%#x" % self.config) |
| 10436 | q.breakable() |
| 10437 | q.text('}') |
| 10438 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10439 | class table_mod_failed_error_msg(Message): |
| 10440 | version = 4 |
| 10441 | type = 1 |
| 10442 | err_type = 8 |
| 10443 | |
| 10444 | def __init__(self, xid=None, code=None, data=None): |
| 10445 | self.xid = xid |
| 10446 | if code != None: |
| 10447 | self.code = code |
| 10448 | else: |
| 10449 | self.code = 0 |
| 10450 | if data != None: |
| 10451 | self.data = data |
| 10452 | else: |
| 10453 | self.data = '' |
| 10454 | |
| 10455 | def pack(self): |
| 10456 | packed = [] |
| 10457 | packed.append(struct.pack("!B", self.version)) |
| 10458 | packed.append(struct.pack("!B", self.type)) |
| 10459 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10460 | packed.append(struct.pack("!L", self.xid)) |
| 10461 | packed.append(struct.pack("!H", self.err_type)) |
| 10462 | packed.append(struct.pack("!H", self.code)) |
| 10463 | packed.append(self.data) |
| 10464 | length = sum([len(x) for x in packed]) |
| 10465 | packed[2] = struct.pack("!H", length) |
| 10466 | return ''.join(packed) |
| 10467 | |
| 10468 | @staticmethod |
| 10469 | def unpack(buf): |
| 10470 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10471 | obj = table_mod_failed_error_msg() |
| 10472 | if type(buf) == loxi.generic_util.OFReader: |
| 10473 | reader = buf |
| 10474 | else: |
| 10475 | reader = loxi.generic_util.OFReader(buf) |
| 10476 | _version = reader.read("!B")[0] |
| 10477 | assert(_version == 4) |
| 10478 | _type = reader.read("!B")[0] |
| 10479 | assert(_type == 1) |
| 10480 | _length = reader.read("!H")[0] |
| 10481 | obj.xid = reader.read("!L")[0] |
| 10482 | _err_type = reader.read("!H")[0] |
| 10483 | assert(_err_type == 8) |
| 10484 | obj.code = reader.read("!H")[0] |
| 10485 | obj.data = str(reader.read_all()) |
| 10486 | return obj |
| 10487 | |
| 10488 | def __eq__(self, other): |
| 10489 | if type(self) != type(other): return False |
| 10490 | if self.version != other.version: return False |
| 10491 | if self.type != other.type: return False |
| 10492 | if self.xid != other.xid: return False |
| 10493 | if self.code != other.code: return False |
| 10494 | if self.data != other.data: return False |
| 10495 | return True |
| 10496 | |
| 10497 | def __ne__(self, other): |
| 10498 | return not self.__eq__(other) |
| 10499 | |
| 10500 | def __str__(self): |
| 10501 | return self.show() |
| 10502 | |
| 10503 | def show(self): |
| 10504 | import loxi.pp |
| 10505 | return loxi.pp.pp(self) |
| 10506 | |
| 10507 | def pretty_print(self, q): |
| 10508 | q.text("table_mod_failed_error_msg {") |
| 10509 | with q.group(): |
| 10510 | with q.indent(2): |
| 10511 | q.breakable() |
| 10512 | q.text("xid = "); |
| 10513 | if self.xid != None: |
| 10514 | q.text("%#x" % self.xid) |
| 10515 | else: |
| 10516 | q.text('None') |
| 10517 | q.text(","); q.breakable() |
| 10518 | q.text("code = "); |
| 10519 | q.text("%#x" % self.code) |
| 10520 | q.text(","); q.breakable() |
| 10521 | q.text("data = "); |
| 10522 | q.pp(self.data) |
| 10523 | q.breakable() |
| 10524 | q.text('}') |
| 10525 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10526 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10527 | version = 4 |
| 10528 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10529 | stats_type = 3 |
| 10530 | |
| 10531 | def __init__(self, xid=None, flags=None, entries=None): |
| 10532 | self.xid = xid |
| 10533 | if flags != None: |
| 10534 | self.flags = flags |
| 10535 | else: |
| 10536 | self.flags = 0 |
| 10537 | if entries != None: |
| 10538 | self.entries = entries |
| 10539 | else: |
| 10540 | self.entries = [] |
| 10541 | |
| 10542 | def pack(self): |
| 10543 | packed = [] |
| 10544 | packed.append(struct.pack("!B", self.version)) |
| 10545 | packed.append(struct.pack("!B", self.type)) |
| 10546 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10547 | packed.append(struct.pack("!L", self.xid)) |
| 10548 | packed.append(struct.pack("!H", self.stats_type)) |
| 10549 | packed.append(struct.pack("!H", self.flags)) |
| 10550 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10551 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10552 | length = sum([len(x) for x in packed]) |
| 10553 | packed[2] = struct.pack("!H", length) |
| 10554 | return ''.join(packed) |
| 10555 | |
| 10556 | @staticmethod |
| 10557 | def unpack(buf): |
| 10558 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10559 | obj = table_stats_reply() |
| 10560 | if type(buf) == loxi.generic_util.OFReader: |
| 10561 | reader = buf |
| 10562 | else: |
| 10563 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10564 | _version = reader.read("!B")[0] |
| 10565 | assert(_version == 4) |
| 10566 | _type = reader.read("!B")[0] |
| 10567 | assert(_type == 19) |
| 10568 | _length = reader.read("!H")[0] |
| 10569 | obj.xid = reader.read("!L")[0] |
| 10570 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10571 | assert(_stats_type == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10572 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10573 | reader.skip(4) |
| 10574 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 10575 | return obj |
| 10576 | |
| 10577 | def __eq__(self, other): |
| 10578 | if type(self) != type(other): return False |
| 10579 | if self.version != other.version: return False |
| 10580 | if self.type != other.type: return False |
| 10581 | if self.xid != other.xid: return False |
| 10582 | if self.flags != other.flags: return False |
| 10583 | if self.entries != other.entries: return False |
| 10584 | return True |
| 10585 | |
| 10586 | def __ne__(self, other): |
| 10587 | return not self.__eq__(other) |
| 10588 | |
| 10589 | def __str__(self): |
| 10590 | return self.show() |
| 10591 | |
| 10592 | def show(self): |
| 10593 | import loxi.pp |
| 10594 | return loxi.pp.pp(self) |
| 10595 | |
| 10596 | def pretty_print(self, q): |
| 10597 | q.text("table_stats_reply {") |
| 10598 | with q.group(): |
| 10599 | with q.indent(2): |
| 10600 | q.breakable() |
| 10601 | q.text("xid = "); |
| 10602 | if self.xid != None: |
| 10603 | q.text("%#x" % self.xid) |
| 10604 | else: |
| 10605 | q.text('None') |
| 10606 | q.text(","); q.breakable() |
| 10607 | q.text("flags = "); |
| 10608 | q.text("%#x" % self.flags) |
| 10609 | q.text(","); q.breakable() |
| 10610 | q.text("entries = "); |
| 10611 | q.pp(self.entries) |
| 10612 | q.breakable() |
| 10613 | q.text('}') |
| 10614 | |
| 10615 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10616 | version = 4 |
| 10617 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10618 | stats_type = 3 |
| 10619 | |
| 10620 | def __init__(self, xid=None, flags=None): |
| 10621 | self.xid = xid |
| 10622 | if flags != None: |
| 10623 | self.flags = flags |
| 10624 | else: |
| 10625 | self.flags = 0 |
| 10626 | |
| 10627 | def pack(self): |
| 10628 | packed = [] |
| 10629 | packed.append(struct.pack("!B", self.version)) |
| 10630 | packed.append(struct.pack("!B", self.type)) |
| 10631 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 10632 | packed.append(struct.pack("!L", self.xid)) |
| 10633 | packed.append(struct.pack("!H", self.stats_type)) |
| 10634 | packed.append(struct.pack("!H", self.flags)) |
| 10635 | packed.append('\x00' * 4) |
| 10636 | length = sum([len(x) for x in packed]) |
| 10637 | packed[2] = struct.pack("!H", length) |
| 10638 | return ''.join(packed) |
| 10639 | |
| 10640 | @staticmethod |
| 10641 | def unpack(buf): |
| 10642 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 10643 | obj = table_stats_request() |
| 10644 | if type(buf) == loxi.generic_util.OFReader: |
| 10645 | reader = buf |
| 10646 | else: |
| 10647 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10648 | _version = reader.read("!B")[0] |
| 10649 | assert(_version == 4) |
| 10650 | _type = reader.read("!B")[0] |
| 10651 | assert(_type == 18) |
| 10652 | _length = reader.read("!H")[0] |
| 10653 | obj.xid = reader.read("!L")[0] |
| 10654 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10655 | assert(_stats_type == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10656 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10657 | reader.skip(4) |
| 10658 | return obj |
| 10659 | |
| 10660 | def __eq__(self, other): |
| 10661 | if type(self) != type(other): return False |
| 10662 | if self.version != other.version: return False |
| 10663 | if self.type != other.type: return False |
| 10664 | if self.xid != other.xid: return False |
| 10665 | if self.flags != other.flags: return False |
| 10666 | return True |
| 10667 | |
| 10668 | def __ne__(self, other): |
| 10669 | return not self.__eq__(other) |
| 10670 | |
| 10671 | def __str__(self): |
| 10672 | return self.show() |
| 10673 | |
| 10674 | def show(self): |
| 10675 | import loxi.pp |
| 10676 | return loxi.pp.pp(self) |
| 10677 | |
| 10678 | def pretty_print(self, q): |
| 10679 | q.text("table_stats_request {") |
| 10680 | with q.group(): |
| 10681 | with q.indent(2): |
| 10682 | q.breakable() |
| 10683 | q.text("xid = "); |
| 10684 | if self.xid != None: |
| 10685 | q.text("%#x" % self.xid) |
| 10686 | else: |
| 10687 | q.text('None') |
| 10688 | q.text(","); q.breakable() |
| 10689 | q.text("flags = "); |
| 10690 | q.text("%#x" % self.flags) |
| 10691 | q.breakable() |
| 10692 | q.text('}') |
| 10693 | |
| 10694 | |
| 10695 | def parse_header(buf): |
| 10696 | if len(buf) < 8: |
| 10697 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 10698 | return struct.unpack_from("!BBHL", buf) |
| 10699 | |
| 10700 | def parse_message(buf): |
| 10701 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 10702 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 10703 | 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] | 10704 | if len(buf) != msg_len: |
| 10705 | raise loxi.ProtocolError("incorrect message size") |
| 10706 | if msg_type in parsers: |
| 10707 | return parsers[msg_type](buf) |
| 10708 | else: |
| 10709 | raise loxi.ProtocolError("unexpected message type") |
| 10710 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10711 | def parse_error(buf): |
| 10712 | if len(buf) < 8 + 2: |
| 10713 | raise loxi.ProtocolError("message too short") |
| 10714 | err_type, = struct.unpack_from("!H", buf, 8) |
| 10715 | if err_type in error_msg_parsers: |
| 10716 | return error_msg_parsers[err_type](buf) |
| 10717 | else: |
| 10718 | raise loxi.ProtocolError("unexpected error type %u" % err_type) |
| 10719 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10720 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 10721 | if len(buf) < 25 + 1: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10722 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 10723 | # Technically uint16_t for OF 1.0 |
| 10724 | cmd, = struct.unpack_from("!B", buf, 25) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10725 | if cmd in flow_mod_parsers: |
| 10726 | return flow_mod_parsers[cmd](buf) |
| 10727 | else: |
| 10728 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 10729 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10730 | def parse_group_mod(buf): |
| 10731 | if len(buf) < 8 + 2: |
| 10732 | raise loxi.ProtocolError("message too short") |
| 10733 | cmd, = struct.unpack_from("!H", buf, 8) |
| 10734 | if cmd in flow_mod_parsers: |
| 10735 | return group_mod_parsers[cmd](buf) |
| 10736 | else: |
| 10737 | raise loxi.ProtocolError("unexpected group mod cmd %u" % cmd) |
| 10738 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10739 | def parse_stats_reply(buf): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10740 | if len(buf) < 8 + 2: |
| 10741 | raise loxi.ProtocolError("message too short") |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10742 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 10743 | if stats_type in stats_reply_parsers: |
| 10744 | return stats_reply_parsers[stats_type](buf) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10745 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10746 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10747 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10748 | def parse_stats_request(buf): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10749 | if len(buf) < 8 + 2: |
| 10750 | raise loxi.ProtocolError("message too short") |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10751 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 10752 | if stats_type in stats_request_parsers: |
| 10753 | return stats_request_parsers[stats_type](buf) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10754 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10755 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10756 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10757 | def parse_experimenter_stats_request(buf): |
| 10758 | if len(buf) < 24: |
| 10759 | raise loxi.ProtocolError("experimenter stats request message too short") |
| 10760 | |
| 10761 | experimenter, exp_type = struct.unpack_from("!LL", buf, 16) |
| 10762 | |
| 10763 | if experimenter in experimenter_stats_request_parsers and \ |
| 10764 | exp_type in experimenter_stats_request_parsers[experimenter]: |
| 10765 | return experimenter_stats_request_parsers[experimenter][exp_type](buf) |
| 10766 | else: |
| 10767 | raise loxi.ProtocolError("unexpected stats request experimenter %#x exp_type %#x" % (experimenter, exp_type)) |
| 10768 | |
| 10769 | def parse_experimenter_stats_reply(buf): |
| 10770 | if len(buf) < 24: |
| 10771 | raise loxi.ProtocolError("experimenter stats reply message too short") |
| 10772 | |
| 10773 | experimenter, exp_type = struct.unpack_from("!LL", buf, 16) |
| 10774 | |
| 10775 | if experimenter in experimenter_stats_reply_parsers and \ |
| 10776 | exp_type in experimenter_stats_reply_parsers[experimenter]: |
| 10777 | return experimenter_stats_reply_parsers[experimenter][exp_type](buf) |
| 10778 | else: |
| 10779 | raise loxi.ProtocolError("unexpected stats reply experimenter %#x exp_type %#x" % (experimenter, exp_type)) |
| 10780 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10781 | def parse_experimenter(buf): |
| 10782 | if len(buf) < 16: |
| 10783 | raise loxi.ProtocolError("experimenter message too short") |
| 10784 | |
| 10785 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 10786 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 10787 | subtype, = struct.unpack_from("!L", buf, 12) |
| 10788 | elif experimenter == 0x00002320: # Nicira |
| 10789 | subtype, = struct.unpack_from("!L", buf, 12) |
| 10790 | else: |
| 10791 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 10792 | |
| 10793 | if subtype in experimenter_parsers[experimenter]: |
| 10794 | return experimenter_parsers[experimenter][subtype](buf) |
| 10795 | else: |
| 10796 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 10797 | |
| 10798 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10799 | const.OFPT_HELLO : hello.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10800 | const.OFPT_ERROR : parse_error, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10801 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 10802 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
| 10803 | const.OFPT_EXPERIMENTER : parse_experimenter, |
| 10804 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 10805 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 10806 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 10807 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10808 | const.OFPT_SET_CONFIG : set_config.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10809 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 10810 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 10811 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 10812 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 10813 | const.OFPT_FLOW_MOD : parse_flow_mod, |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10814 | const.OFPT_GROUP_MOD : parse_group_mod, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10815 | const.OFPT_PORT_MOD : port_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10816 | const.OFPT_TABLE_MOD : table_mod.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10817 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 10818 | const.OFPT_STATS_REPLY : parse_stats_reply, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10819 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 10820 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 10821 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 10822 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
| 10823 | const.OFPT_ROLE_REQUEST : role_request.unpack, |
| 10824 | const.OFPT_ROLE_REPLY : role_reply.unpack, |
| 10825 | const.OFPT_GET_ASYNC_REQUEST : async_get_request.unpack, |
| 10826 | const.OFPT_GET_ASYNC_REPLY : async_get_reply.unpack, |
| 10827 | const.OFPT_SET_ASYNC : async_set.unpack, |
| 10828 | const.OFPT_METER_MOD : meter_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10829 | } |
| 10830 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10831 | error_msg_parsers = { |
| 10832 | const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack, |
| 10833 | const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack, |
| 10834 | const.OFPET_BAD_ACTION : bad_action_error_msg.unpack, |
| 10835 | const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack, |
| 10836 | const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack, |
| 10837 | const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack, |
| 10838 | const.OFPET_BAD_INSTRUCTION : bad_instruction_error_msg.unpack, |
| 10839 | const.OFPET_BAD_MATCH : bad_match_error_msg.unpack, |
| 10840 | const.OFPET_GROUP_MOD_FAILED : group_mod_failed_error_msg.unpack, |
| 10841 | const.OFPET_TABLE_MOD_FAILED : table_mod_failed_error_msg.unpack, |
| 10842 | const.OFPET_SWITCH_CONFIG_FAILED : switch_config_failed_error_msg.unpack, |
| 10843 | const.OFPET_ROLE_REQUEST_FAILED : role_request_failed_error_msg.unpack, |
| 10844 | const.OFPET_EXPERIMENTER : experimenter_error_msg.unpack, |
| 10845 | const.OFPET_METER_MOD_FAILED : meter_mod_failed_error_msg.unpack, |
| 10846 | const.OFPET_TABLE_FEATURES_FAILED : table_features_failed_error_msg.unpack, |
| 10847 | } |
| 10848 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10849 | flow_mod_parsers = { |
| 10850 | const.OFPFC_ADD : flow_add.unpack, |
| 10851 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 10852 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 10853 | const.OFPFC_DELETE : flow_delete.unpack, |
| 10854 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 10855 | } |
| 10856 | |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10857 | group_mod_parsers = { |
| 10858 | const.OFPGC_ADD : group_add.unpack, |
| 10859 | const.OFPGC_MODIFY : group_modify.unpack, |
| 10860 | const.OFPGC_DELETE : group_delete.unpack, |
| 10861 | } |
| 10862 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10863 | stats_reply_parsers = { |
| 10864 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 10865 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 10866 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 10867 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 10868 | const.OFPST_PORT : port_stats_reply.unpack, |
| 10869 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10870 | const.OFPST_EXPERIMENTER : parse_experimenter_stats_reply, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10871 | const.OFPST_GROUP : group_stats_reply.unpack, |
| 10872 | const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack, |
| 10873 | const.OFPST_GROUP_FEATURES : group_features_stats_reply.unpack, |
| 10874 | const.OFPST_METER : meter_stats_reply.unpack, |
| 10875 | const.OFPST_METER_CONFIG : meter_config_stats_reply.unpack, |
| 10876 | const.OFPST_METER_FEATURES : meter_features_stats_reply.unpack, |
| 10877 | const.OFPST_TABLE_FEATURES : table_features_stats_reply.unpack, |
| 10878 | const.OFPST_PORT_DESC : port_desc_stats_reply.unpack, |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 10879 | } |
| 10880 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10881 | stats_request_parsers = { |
| 10882 | const.OFPST_DESC : desc_stats_request.unpack, |
| 10883 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 10884 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 10885 | const.OFPST_TABLE : table_stats_request.unpack, |
| 10886 | const.OFPST_PORT : port_stats_request.unpack, |
| 10887 | const.OFPST_QUEUE : queue_stats_request.unpack, |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10888 | const.OFPST_EXPERIMENTER : parse_experimenter_stats_request, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10889 | const.OFPST_GROUP : group_stats_request.unpack, |
| 10890 | const.OFPST_GROUP_DESC : group_desc_stats_request.unpack, |
| 10891 | const.OFPST_GROUP_FEATURES : group_features_stats_request.unpack, |
| 10892 | const.OFPST_METER : meter_stats_request.unpack, |
| 10893 | const.OFPST_METER_CONFIG : meter_config_stats_request.unpack, |
| 10894 | const.OFPST_METER_FEATURES : meter_features_stats_request.unpack, |
| 10895 | const.OFPST_TABLE_FEATURES : table_features_stats_request.unpack, |
| 10896 | const.OFPST_PORT_DESC : port_desc_stats_request.unpack, |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 10897 | } |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10898 | |
| 10899 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10900 | 6035143 : { |
| 10901 | 22: bsn_bw_clear_data_reply.unpack, |
| 10902 | 21: bsn_bw_clear_data_request.unpack, |
| 10903 | 20: bsn_bw_enable_get_reply.unpack, |
| 10904 | 19: bsn_bw_enable_get_request.unpack, |
| 10905 | 23: bsn_bw_enable_set_reply.unpack, |
| 10906 | 18: bsn_bw_enable_set_request.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10907 | 40: bsn_flow_idle.unpack, |
| 10908 | 39: bsn_flow_idle_enable_get_reply.unpack, |
| 10909 | 38: bsn_flow_idle_enable_get_request.unpack, |
| 10910 | 37: bsn_flow_idle_enable_set_reply.unpack, |
| 10911 | 36: bsn_flow_idle_enable_set_request.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10912 | 10: bsn_get_interfaces_reply.unpack, |
| 10913 | 9: bsn_get_interfaces_request.unpack, |
| 10914 | 5: bsn_get_mirroring_reply.unpack, |
| 10915 | 4: bsn_get_mirroring_request.unpack, |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10916 | 43: bsn_lacp_convergence_notif.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 10917 | 34: bsn_pdu_rx_reply.unpack, |
| 10918 | 33: bsn_pdu_rx_request.unpack, |
| 10919 | 35: bsn_pdu_rx_timeout.unpack, |
| 10920 | 32: bsn_pdu_tx_reply.unpack, |
| 10921 | 31: bsn_pdu_tx_request.unpack, |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10922 | 42: bsn_set_lacp_reply.unpack, |
| 10923 | 41: bsn_set_lacp_request.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10924 | 3: bsn_set_mirroring.unpack, |
| 10925 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 10926 | 11: bsn_set_pktin_suppression_request.unpack, |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10927 | 45: bsn_time_reply.unpack, |
| 10928 | 44: bsn_time_request.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 10929 | 16: bsn_virtual_port_create_reply.unpack, |
| 10930 | 15: bsn_virtual_port_create_request.unpack, |
| 10931 | 26: bsn_virtual_port_remove_reply.unpack, |
| 10932 | 17: bsn_virtual_port_remove_request.unpack, |
| 10933 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 10934 | } |
Rich Lane | 7b0f201 | 2013-11-22 14:15:26 -0800 | [diff] [blame] | 10935 | |
| 10936 | experimenter_stats_request_parsers = { |
| 10937 | 0x005c16c7: { |
| 10938 | 1: bsn_lacp_stats_request.unpack, |
| 10939 | }, |
| 10940 | } |
| 10941 | |
| 10942 | experimenter_stats_reply_parsers = { |
| 10943 | 0x005c16c7: { |
| 10944 | 1: bsn_lacp_stats_reply.unpack, |
| 10945 | }, |
| 10946 | } |