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 | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 2352 | class bsn_pdu_rx_reply(Message): |
| 2353 | version = 4 |
| 2354 | type = 4 |
| 2355 | experimenter = 6035143 |
| 2356 | subtype = 34 |
| 2357 | |
| 2358 | def __init__(self, xid=None, status=None): |
| 2359 | self.xid = xid |
| 2360 | if status != None: |
| 2361 | self.status = status |
| 2362 | else: |
| 2363 | self.status = 0 |
| 2364 | |
| 2365 | def pack(self): |
| 2366 | packed = [] |
| 2367 | packed.append(struct.pack("!B", self.version)) |
| 2368 | packed.append(struct.pack("!B", self.type)) |
| 2369 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2370 | packed.append(struct.pack("!L", self.xid)) |
| 2371 | packed.append(struct.pack("!L", self.experimenter)) |
| 2372 | packed.append(struct.pack("!L", self.subtype)) |
| 2373 | packed.append(struct.pack("!L", self.status)) |
| 2374 | length = sum([len(x) for x in packed]) |
| 2375 | packed[2] = struct.pack("!H", length) |
| 2376 | return ''.join(packed) |
| 2377 | |
| 2378 | @staticmethod |
| 2379 | def unpack(buf): |
| 2380 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2381 | obj = bsn_pdu_rx_reply() |
| 2382 | if type(buf) == loxi.generic_util.OFReader: |
| 2383 | reader = buf |
| 2384 | else: |
| 2385 | reader = loxi.generic_util.OFReader(buf) |
| 2386 | _version = reader.read("!B")[0] |
| 2387 | assert(_version == 4) |
| 2388 | _type = reader.read("!B")[0] |
| 2389 | assert(_type == 4) |
| 2390 | _length = reader.read("!H")[0] |
| 2391 | obj.xid = reader.read("!L")[0] |
| 2392 | _experimenter = reader.read("!L")[0] |
| 2393 | assert(_experimenter == 6035143) |
| 2394 | _subtype = reader.read("!L")[0] |
| 2395 | assert(_subtype == 34) |
| 2396 | obj.status = reader.read("!L")[0] |
| 2397 | return obj |
| 2398 | |
| 2399 | def __eq__(self, other): |
| 2400 | if type(self) != type(other): return False |
| 2401 | if self.version != other.version: return False |
| 2402 | if self.type != other.type: return False |
| 2403 | if self.xid != other.xid: return False |
| 2404 | if self.status != other.status: return False |
| 2405 | return True |
| 2406 | |
| 2407 | def __ne__(self, other): |
| 2408 | return not self.__eq__(other) |
| 2409 | |
| 2410 | def __str__(self): |
| 2411 | return self.show() |
| 2412 | |
| 2413 | def show(self): |
| 2414 | import loxi.pp |
| 2415 | return loxi.pp.pp(self) |
| 2416 | |
| 2417 | def pretty_print(self, q): |
| 2418 | q.text("bsn_pdu_rx_reply {") |
| 2419 | with q.group(): |
| 2420 | with q.indent(2): |
| 2421 | q.breakable() |
| 2422 | q.text("xid = "); |
| 2423 | if self.xid != None: |
| 2424 | q.text("%#x" % self.xid) |
| 2425 | else: |
| 2426 | q.text('None') |
| 2427 | q.text(","); q.breakable() |
| 2428 | q.text("status = "); |
| 2429 | q.text("%#x" % self.status) |
| 2430 | q.breakable() |
| 2431 | q.text('}') |
| 2432 | |
| 2433 | class bsn_pdu_rx_request(Message): |
| 2434 | version = 4 |
| 2435 | type = 4 |
| 2436 | experimenter = 6035143 |
| 2437 | subtype = 33 |
| 2438 | |
| 2439 | def __init__(self, xid=None, timeout_ms=None, port_no=None, slot_num=None, data=None): |
| 2440 | self.xid = xid |
| 2441 | if timeout_ms != None: |
| 2442 | self.timeout_ms = timeout_ms |
| 2443 | else: |
| 2444 | self.timeout_ms = 0 |
| 2445 | if port_no != None: |
| 2446 | self.port_no = port_no |
| 2447 | else: |
| 2448 | self.port_no = 0 |
| 2449 | if slot_num != None: |
| 2450 | self.slot_num = slot_num |
| 2451 | else: |
| 2452 | self.slot_num = 0 |
| 2453 | if data != None: |
| 2454 | self.data = data |
| 2455 | else: |
| 2456 | self.data = '' |
| 2457 | |
| 2458 | def pack(self): |
| 2459 | packed = [] |
| 2460 | packed.append(struct.pack("!B", self.version)) |
| 2461 | packed.append(struct.pack("!B", self.type)) |
| 2462 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2463 | packed.append(struct.pack("!L", self.xid)) |
| 2464 | packed.append(struct.pack("!L", self.experimenter)) |
| 2465 | packed.append(struct.pack("!L", self.subtype)) |
| 2466 | packed.append(struct.pack("!L", self.timeout_ms)) |
| 2467 | packed.append(util.pack_port_no(self.port_no)) |
| 2468 | packed.append(struct.pack("!B", self.slot_num)) |
| 2469 | packed.append('\x00' * 3) |
| 2470 | packed.append(self.data) |
| 2471 | length = sum([len(x) for x in packed]) |
| 2472 | packed[2] = struct.pack("!H", length) |
| 2473 | return ''.join(packed) |
| 2474 | |
| 2475 | @staticmethod |
| 2476 | def unpack(buf): |
| 2477 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2478 | obj = bsn_pdu_rx_request() |
| 2479 | if type(buf) == loxi.generic_util.OFReader: |
| 2480 | reader = buf |
| 2481 | else: |
| 2482 | reader = loxi.generic_util.OFReader(buf) |
| 2483 | _version = reader.read("!B")[0] |
| 2484 | assert(_version == 4) |
| 2485 | _type = reader.read("!B")[0] |
| 2486 | assert(_type == 4) |
| 2487 | _length = reader.read("!H")[0] |
| 2488 | obj.xid = reader.read("!L")[0] |
| 2489 | _experimenter = reader.read("!L")[0] |
| 2490 | assert(_experimenter == 6035143) |
| 2491 | _subtype = reader.read("!L")[0] |
| 2492 | assert(_subtype == 33) |
| 2493 | obj.timeout_ms = reader.read("!L")[0] |
| 2494 | obj.port_no = util.unpack_port_no(reader) |
| 2495 | obj.slot_num = reader.read("!B")[0] |
| 2496 | reader.skip(3) |
| 2497 | obj.data = str(reader.read_all()) |
| 2498 | return obj |
| 2499 | |
| 2500 | def __eq__(self, other): |
| 2501 | if type(self) != type(other): return False |
| 2502 | if self.version != other.version: return False |
| 2503 | if self.type != other.type: return False |
| 2504 | if self.xid != other.xid: return False |
| 2505 | if self.timeout_ms != other.timeout_ms: return False |
| 2506 | if self.port_no != other.port_no: return False |
| 2507 | if self.slot_num != other.slot_num: return False |
| 2508 | if self.data != other.data: return False |
| 2509 | return True |
| 2510 | |
| 2511 | def __ne__(self, other): |
| 2512 | return not self.__eq__(other) |
| 2513 | |
| 2514 | def __str__(self): |
| 2515 | return self.show() |
| 2516 | |
| 2517 | def show(self): |
| 2518 | import loxi.pp |
| 2519 | return loxi.pp.pp(self) |
| 2520 | |
| 2521 | def pretty_print(self, q): |
| 2522 | q.text("bsn_pdu_rx_request {") |
| 2523 | with q.group(): |
| 2524 | with q.indent(2): |
| 2525 | q.breakable() |
| 2526 | q.text("xid = "); |
| 2527 | if self.xid != None: |
| 2528 | q.text("%#x" % self.xid) |
| 2529 | else: |
| 2530 | q.text('None') |
| 2531 | q.text(","); q.breakable() |
| 2532 | q.text("timeout_ms = "); |
| 2533 | q.text("%#x" % self.timeout_ms) |
| 2534 | q.text(","); q.breakable() |
| 2535 | q.text("port_no = "); |
| 2536 | q.text(util.pretty_port(self.port_no)) |
| 2537 | q.text(","); q.breakable() |
| 2538 | q.text("slot_num = "); |
| 2539 | q.text("%#x" % self.slot_num) |
| 2540 | q.text(","); q.breakable() |
| 2541 | q.text("data = "); |
| 2542 | q.pp(self.data) |
| 2543 | q.breakable() |
| 2544 | q.text('}') |
| 2545 | |
| 2546 | class bsn_pdu_rx_timeout(Message): |
| 2547 | version = 4 |
| 2548 | type = 4 |
| 2549 | experimenter = 6035143 |
| 2550 | subtype = 35 |
| 2551 | |
| 2552 | def __init__(self, xid=None, port_no=None, slot_num=None): |
| 2553 | self.xid = xid |
| 2554 | if port_no != None: |
| 2555 | self.port_no = port_no |
| 2556 | else: |
| 2557 | self.port_no = 0 |
| 2558 | if slot_num != None: |
| 2559 | self.slot_num = slot_num |
| 2560 | else: |
| 2561 | self.slot_num = 0 |
| 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("!L", self.experimenter)) |
| 2570 | packed.append(struct.pack("!L", self.subtype)) |
| 2571 | packed.append(util.pack_port_no(self.port_no)) |
| 2572 | packed.append(struct.pack("!B", self.slot_num)) |
| 2573 | length = sum([len(x) for x in packed]) |
| 2574 | packed[2] = struct.pack("!H", length) |
| 2575 | return ''.join(packed) |
| 2576 | |
| 2577 | @staticmethod |
| 2578 | def unpack(buf): |
| 2579 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2580 | obj = bsn_pdu_rx_timeout() |
| 2581 | if type(buf) == loxi.generic_util.OFReader: |
| 2582 | reader = buf |
| 2583 | else: |
| 2584 | reader = loxi.generic_util.OFReader(buf) |
| 2585 | _version = reader.read("!B")[0] |
| 2586 | assert(_version == 4) |
| 2587 | _type = reader.read("!B")[0] |
| 2588 | assert(_type == 4) |
| 2589 | _length = reader.read("!H")[0] |
| 2590 | obj.xid = reader.read("!L")[0] |
| 2591 | _experimenter = reader.read("!L")[0] |
| 2592 | assert(_experimenter == 6035143) |
| 2593 | _subtype = reader.read("!L")[0] |
| 2594 | assert(_subtype == 35) |
| 2595 | obj.port_no = util.unpack_port_no(reader) |
| 2596 | obj.slot_num = reader.read("!B")[0] |
| 2597 | return obj |
| 2598 | |
| 2599 | def __eq__(self, other): |
| 2600 | if type(self) != type(other): return False |
| 2601 | if self.version != other.version: return False |
| 2602 | if self.type != other.type: return False |
| 2603 | if self.xid != other.xid: return False |
| 2604 | if self.port_no != other.port_no: return False |
| 2605 | if self.slot_num != other.slot_num: return False |
| 2606 | return True |
| 2607 | |
| 2608 | def __ne__(self, other): |
| 2609 | return not self.__eq__(other) |
| 2610 | |
| 2611 | def __str__(self): |
| 2612 | return self.show() |
| 2613 | |
| 2614 | def show(self): |
| 2615 | import loxi.pp |
| 2616 | return loxi.pp.pp(self) |
| 2617 | |
| 2618 | def pretty_print(self, q): |
| 2619 | q.text("bsn_pdu_rx_timeout {") |
| 2620 | with q.group(): |
| 2621 | with q.indent(2): |
| 2622 | q.breakable() |
| 2623 | q.text("xid = "); |
| 2624 | if self.xid != None: |
| 2625 | q.text("%#x" % self.xid) |
| 2626 | else: |
| 2627 | q.text('None') |
| 2628 | q.text(","); q.breakable() |
| 2629 | q.text("port_no = "); |
| 2630 | q.text(util.pretty_port(self.port_no)) |
| 2631 | q.text(","); q.breakable() |
| 2632 | q.text("slot_num = "); |
| 2633 | q.text("%#x" % self.slot_num) |
| 2634 | q.breakable() |
| 2635 | q.text('}') |
| 2636 | |
| 2637 | class bsn_pdu_tx_reply(Message): |
| 2638 | version = 4 |
| 2639 | type = 4 |
| 2640 | experimenter = 6035143 |
| 2641 | subtype = 32 |
| 2642 | |
| 2643 | def __init__(self, xid=None, status=None): |
| 2644 | self.xid = xid |
| 2645 | if status != None: |
| 2646 | self.status = status |
| 2647 | else: |
| 2648 | self.status = 0 |
| 2649 | |
| 2650 | def pack(self): |
| 2651 | packed = [] |
| 2652 | packed.append(struct.pack("!B", self.version)) |
| 2653 | packed.append(struct.pack("!B", self.type)) |
| 2654 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2655 | packed.append(struct.pack("!L", self.xid)) |
| 2656 | packed.append(struct.pack("!L", self.experimenter)) |
| 2657 | packed.append(struct.pack("!L", self.subtype)) |
| 2658 | packed.append(struct.pack("!L", self.status)) |
| 2659 | length = sum([len(x) for x in packed]) |
| 2660 | packed[2] = struct.pack("!H", length) |
| 2661 | return ''.join(packed) |
| 2662 | |
| 2663 | @staticmethod |
| 2664 | def unpack(buf): |
| 2665 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2666 | obj = bsn_pdu_tx_reply() |
| 2667 | if type(buf) == loxi.generic_util.OFReader: |
| 2668 | reader = buf |
| 2669 | else: |
| 2670 | reader = loxi.generic_util.OFReader(buf) |
| 2671 | _version = reader.read("!B")[0] |
| 2672 | assert(_version == 4) |
| 2673 | _type = reader.read("!B")[0] |
| 2674 | assert(_type == 4) |
| 2675 | _length = reader.read("!H")[0] |
| 2676 | obj.xid = reader.read("!L")[0] |
| 2677 | _experimenter = reader.read("!L")[0] |
| 2678 | assert(_experimenter == 6035143) |
| 2679 | _subtype = reader.read("!L")[0] |
| 2680 | assert(_subtype == 32) |
| 2681 | obj.status = reader.read("!L")[0] |
| 2682 | return obj |
| 2683 | |
| 2684 | def __eq__(self, other): |
| 2685 | if type(self) != type(other): return False |
| 2686 | if self.version != other.version: return False |
| 2687 | if self.type != other.type: return False |
| 2688 | if self.xid != other.xid: return False |
| 2689 | if self.status != other.status: return False |
| 2690 | return True |
| 2691 | |
| 2692 | def __ne__(self, other): |
| 2693 | return not self.__eq__(other) |
| 2694 | |
| 2695 | def __str__(self): |
| 2696 | return self.show() |
| 2697 | |
| 2698 | def show(self): |
| 2699 | import loxi.pp |
| 2700 | return loxi.pp.pp(self) |
| 2701 | |
| 2702 | def pretty_print(self, q): |
| 2703 | q.text("bsn_pdu_tx_reply {") |
| 2704 | with q.group(): |
| 2705 | with q.indent(2): |
| 2706 | q.breakable() |
| 2707 | q.text("xid = "); |
| 2708 | if self.xid != None: |
| 2709 | q.text("%#x" % self.xid) |
| 2710 | else: |
| 2711 | q.text('None') |
| 2712 | q.text(","); q.breakable() |
| 2713 | q.text("status = "); |
| 2714 | q.text("%#x" % self.status) |
| 2715 | q.breakable() |
| 2716 | q.text('}') |
| 2717 | |
| 2718 | class bsn_pdu_tx_request(Message): |
| 2719 | version = 4 |
| 2720 | type = 4 |
| 2721 | experimenter = 6035143 |
| 2722 | subtype = 31 |
| 2723 | |
| 2724 | def __init__(self, xid=None, tx_interval_ms=None, port_no=None, slot_num=None, data=None): |
| 2725 | self.xid = xid |
| 2726 | if tx_interval_ms != None: |
| 2727 | self.tx_interval_ms = tx_interval_ms |
| 2728 | else: |
| 2729 | self.tx_interval_ms = 0 |
| 2730 | if port_no != None: |
| 2731 | self.port_no = port_no |
| 2732 | else: |
| 2733 | self.port_no = 0 |
| 2734 | if slot_num != None: |
| 2735 | self.slot_num = slot_num |
| 2736 | else: |
| 2737 | self.slot_num = 0 |
| 2738 | if data != None: |
| 2739 | self.data = data |
| 2740 | else: |
| 2741 | self.data = '' |
| 2742 | |
| 2743 | def pack(self): |
| 2744 | packed = [] |
| 2745 | packed.append(struct.pack("!B", self.version)) |
| 2746 | packed.append(struct.pack("!B", self.type)) |
| 2747 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2748 | packed.append(struct.pack("!L", self.xid)) |
| 2749 | packed.append(struct.pack("!L", self.experimenter)) |
| 2750 | packed.append(struct.pack("!L", self.subtype)) |
| 2751 | packed.append(struct.pack("!L", self.tx_interval_ms)) |
| 2752 | packed.append(util.pack_port_no(self.port_no)) |
| 2753 | packed.append(struct.pack("!B", self.slot_num)) |
| 2754 | packed.append('\x00' * 3) |
| 2755 | packed.append(self.data) |
| 2756 | length = sum([len(x) for x in packed]) |
| 2757 | packed[2] = struct.pack("!H", length) |
| 2758 | return ''.join(packed) |
| 2759 | |
| 2760 | @staticmethod |
| 2761 | def unpack(buf): |
| 2762 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2763 | obj = bsn_pdu_tx_request() |
| 2764 | if type(buf) == loxi.generic_util.OFReader: |
| 2765 | reader = buf |
| 2766 | else: |
| 2767 | reader = loxi.generic_util.OFReader(buf) |
| 2768 | _version = reader.read("!B")[0] |
| 2769 | assert(_version == 4) |
| 2770 | _type = reader.read("!B")[0] |
| 2771 | assert(_type == 4) |
| 2772 | _length = reader.read("!H")[0] |
| 2773 | obj.xid = reader.read("!L")[0] |
| 2774 | _experimenter = reader.read("!L")[0] |
| 2775 | assert(_experimenter == 6035143) |
| 2776 | _subtype = reader.read("!L")[0] |
| 2777 | assert(_subtype == 31) |
| 2778 | obj.tx_interval_ms = reader.read("!L")[0] |
| 2779 | obj.port_no = util.unpack_port_no(reader) |
| 2780 | obj.slot_num = reader.read("!B")[0] |
| 2781 | reader.skip(3) |
| 2782 | obj.data = str(reader.read_all()) |
| 2783 | return obj |
| 2784 | |
| 2785 | def __eq__(self, other): |
| 2786 | if type(self) != type(other): return False |
| 2787 | if self.version != other.version: return False |
| 2788 | if self.type != other.type: return False |
| 2789 | if self.xid != other.xid: return False |
| 2790 | if self.tx_interval_ms != other.tx_interval_ms: return False |
| 2791 | if self.port_no != other.port_no: return False |
| 2792 | if self.slot_num != other.slot_num: return False |
| 2793 | if self.data != other.data: return False |
| 2794 | return True |
| 2795 | |
| 2796 | def __ne__(self, other): |
| 2797 | return not self.__eq__(other) |
| 2798 | |
| 2799 | def __str__(self): |
| 2800 | return self.show() |
| 2801 | |
| 2802 | def show(self): |
| 2803 | import loxi.pp |
| 2804 | return loxi.pp.pp(self) |
| 2805 | |
| 2806 | def pretty_print(self, q): |
| 2807 | q.text("bsn_pdu_tx_request {") |
| 2808 | with q.group(): |
| 2809 | with q.indent(2): |
| 2810 | q.breakable() |
| 2811 | q.text("xid = "); |
| 2812 | if self.xid != None: |
| 2813 | q.text("%#x" % self.xid) |
| 2814 | else: |
| 2815 | q.text('None') |
| 2816 | q.text(","); q.breakable() |
| 2817 | q.text("tx_interval_ms = "); |
| 2818 | q.text("%#x" % self.tx_interval_ms) |
| 2819 | q.text(","); q.breakable() |
| 2820 | q.text("port_no = "); |
| 2821 | q.text(util.pretty_port(self.port_no)) |
| 2822 | q.text(","); q.breakable() |
| 2823 | q.text("slot_num = "); |
| 2824 | q.text("%#x" % self.slot_num) |
| 2825 | q.text(","); q.breakable() |
| 2826 | q.text("data = "); |
| 2827 | q.pp(self.data) |
| 2828 | q.breakable() |
| 2829 | q.text('}') |
| 2830 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2831 | class bsn_set_mirroring(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2832 | version = 4 |
| 2833 | type = 4 |
| 2834 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2835 | subtype = 3 |
| 2836 | |
| 2837 | def __init__(self, xid=None, report_mirror_ports=None): |
| 2838 | self.xid = xid |
| 2839 | if report_mirror_ports != None: |
| 2840 | self.report_mirror_ports = report_mirror_ports |
| 2841 | else: |
| 2842 | self.report_mirror_ports = 0 |
| 2843 | |
| 2844 | def pack(self): |
| 2845 | packed = [] |
| 2846 | packed.append(struct.pack("!B", self.version)) |
| 2847 | packed.append(struct.pack("!B", self.type)) |
| 2848 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2849 | packed.append(struct.pack("!L", self.xid)) |
| 2850 | packed.append(struct.pack("!L", self.experimenter)) |
| 2851 | packed.append(struct.pack("!L", self.subtype)) |
| 2852 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
| 2853 | packed.append('\x00' * 3) |
| 2854 | length = sum([len(x) for x in packed]) |
| 2855 | packed[2] = struct.pack("!H", length) |
| 2856 | return ''.join(packed) |
| 2857 | |
| 2858 | @staticmethod |
| 2859 | def unpack(buf): |
| 2860 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2861 | obj = bsn_set_mirroring() |
| 2862 | if type(buf) == loxi.generic_util.OFReader: |
| 2863 | reader = buf |
| 2864 | else: |
| 2865 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2866 | _version = reader.read("!B")[0] |
| 2867 | assert(_version == 4) |
| 2868 | _type = reader.read("!B")[0] |
| 2869 | assert(_type == 4) |
| 2870 | _length = reader.read("!H")[0] |
| 2871 | obj.xid = reader.read("!L")[0] |
| 2872 | _experimenter = reader.read("!L")[0] |
| 2873 | assert(_experimenter == 6035143) |
| 2874 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2875 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2876 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2877 | reader.skip(3) |
| 2878 | return obj |
| 2879 | |
| 2880 | def __eq__(self, other): |
| 2881 | if type(self) != type(other): return False |
| 2882 | if self.version != other.version: return False |
| 2883 | if self.type != other.type: return False |
| 2884 | if self.xid != other.xid: return False |
| 2885 | if self.report_mirror_ports != other.report_mirror_ports: return False |
| 2886 | return True |
| 2887 | |
| 2888 | def __ne__(self, other): |
| 2889 | return not self.__eq__(other) |
| 2890 | |
| 2891 | def __str__(self): |
| 2892 | return self.show() |
| 2893 | |
| 2894 | def show(self): |
| 2895 | import loxi.pp |
| 2896 | return loxi.pp.pp(self) |
| 2897 | |
| 2898 | def pretty_print(self, q): |
| 2899 | q.text("bsn_set_mirroring {") |
| 2900 | with q.group(): |
| 2901 | with q.indent(2): |
| 2902 | q.breakable() |
| 2903 | q.text("xid = "); |
| 2904 | if self.xid != None: |
| 2905 | q.text("%#x" % self.xid) |
| 2906 | else: |
| 2907 | q.text('None') |
| 2908 | q.text(","); q.breakable() |
| 2909 | q.text("report_mirror_ports = "); |
| 2910 | q.text("%#x" % self.report_mirror_ports) |
| 2911 | q.breakable() |
| 2912 | q.text('}') |
| 2913 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2914 | class bsn_set_pktin_suppression_reply(Message): |
| 2915 | version = 4 |
| 2916 | type = 4 |
| 2917 | experimenter = 6035143 |
| 2918 | subtype = 25 |
| 2919 | |
| 2920 | def __init__(self, xid=None, status=None): |
| 2921 | self.xid = xid |
| 2922 | if status != None: |
| 2923 | self.status = status |
| 2924 | else: |
| 2925 | self.status = 0 |
| 2926 | |
| 2927 | def pack(self): |
| 2928 | packed = [] |
| 2929 | packed.append(struct.pack("!B", self.version)) |
| 2930 | packed.append(struct.pack("!B", self.type)) |
| 2931 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2932 | packed.append(struct.pack("!L", self.xid)) |
| 2933 | packed.append(struct.pack("!L", self.experimenter)) |
| 2934 | packed.append(struct.pack("!L", self.subtype)) |
| 2935 | packed.append(struct.pack("!L", self.status)) |
| 2936 | length = sum([len(x) for x in packed]) |
| 2937 | packed[2] = struct.pack("!H", length) |
| 2938 | return ''.join(packed) |
| 2939 | |
| 2940 | @staticmethod |
| 2941 | def unpack(buf): |
| 2942 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2943 | obj = bsn_set_pktin_suppression_reply() |
| 2944 | if type(buf) == loxi.generic_util.OFReader: |
| 2945 | reader = buf |
| 2946 | else: |
| 2947 | reader = loxi.generic_util.OFReader(buf) |
| 2948 | _version = reader.read("!B")[0] |
| 2949 | assert(_version == 4) |
| 2950 | _type = reader.read("!B")[0] |
| 2951 | assert(_type == 4) |
| 2952 | _length = reader.read("!H")[0] |
| 2953 | obj.xid = reader.read("!L")[0] |
| 2954 | _experimenter = reader.read("!L")[0] |
| 2955 | assert(_experimenter == 6035143) |
| 2956 | _subtype = reader.read("!L")[0] |
| 2957 | assert(_subtype == 25) |
| 2958 | obj.status = reader.read("!L")[0] |
| 2959 | return obj |
| 2960 | |
| 2961 | def __eq__(self, other): |
| 2962 | if type(self) != type(other): return False |
| 2963 | if self.version != other.version: return False |
| 2964 | if self.type != other.type: return False |
| 2965 | if self.xid != other.xid: return False |
| 2966 | if self.status != other.status: return False |
| 2967 | return True |
| 2968 | |
| 2969 | def __ne__(self, other): |
| 2970 | return not self.__eq__(other) |
| 2971 | |
| 2972 | def __str__(self): |
| 2973 | return self.show() |
| 2974 | |
| 2975 | def show(self): |
| 2976 | import loxi.pp |
| 2977 | return loxi.pp.pp(self) |
| 2978 | |
| 2979 | def pretty_print(self, q): |
| 2980 | q.text("bsn_set_pktin_suppression_reply {") |
| 2981 | with q.group(): |
| 2982 | with q.indent(2): |
| 2983 | q.breakable() |
| 2984 | q.text("xid = "); |
| 2985 | if self.xid != None: |
| 2986 | q.text("%#x" % self.xid) |
| 2987 | else: |
| 2988 | q.text('None') |
| 2989 | q.text(","); q.breakable() |
| 2990 | q.text("status = "); |
| 2991 | q.text("%#x" % self.status) |
| 2992 | q.breakable() |
| 2993 | q.text('}') |
| 2994 | |
| 2995 | class bsn_set_pktin_suppression_request(Message): |
| 2996 | version = 4 |
| 2997 | type = 4 |
| 2998 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2999 | subtype = 11 |
| 3000 | |
| 3001 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
| 3002 | self.xid = xid |
| 3003 | if enabled != None: |
| 3004 | self.enabled = enabled |
| 3005 | else: |
| 3006 | self.enabled = 0 |
| 3007 | if idle_timeout != None: |
| 3008 | self.idle_timeout = idle_timeout |
| 3009 | else: |
| 3010 | self.idle_timeout = 0 |
| 3011 | if hard_timeout != None: |
| 3012 | self.hard_timeout = hard_timeout |
| 3013 | else: |
| 3014 | self.hard_timeout = 0 |
| 3015 | if priority != None: |
| 3016 | self.priority = priority |
| 3017 | else: |
| 3018 | self.priority = 0 |
| 3019 | if cookie != None: |
| 3020 | self.cookie = cookie |
| 3021 | else: |
| 3022 | self.cookie = 0 |
| 3023 | |
| 3024 | def pack(self): |
| 3025 | packed = [] |
| 3026 | packed.append(struct.pack("!B", self.version)) |
| 3027 | packed.append(struct.pack("!B", self.type)) |
| 3028 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3029 | packed.append(struct.pack("!L", self.xid)) |
| 3030 | packed.append(struct.pack("!L", self.experimenter)) |
| 3031 | packed.append(struct.pack("!L", self.subtype)) |
| 3032 | packed.append(struct.pack("!B", self.enabled)) |
| 3033 | packed.append('\x00' * 1) |
| 3034 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3035 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3036 | packed.append(struct.pack("!H", self.priority)) |
| 3037 | packed.append(struct.pack("!Q", self.cookie)) |
| 3038 | length = sum([len(x) for x in packed]) |
| 3039 | packed[2] = struct.pack("!H", length) |
| 3040 | return ''.join(packed) |
| 3041 | |
| 3042 | @staticmethod |
| 3043 | def unpack(buf): |
| 3044 | 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] | 3045 | obj = bsn_set_pktin_suppression_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3046 | if type(buf) == loxi.generic_util.OFReader: |
| 3047 | reader = buf |
| 3048 | else: |
| 3049 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3050 | _version = reader.read("!B")[0] |
| 3051 | assert(_version == 4) |
| 3052 | _type = reader.read("!B")[0] |
| 3053 | assert(_type == 4) |
| 3054 | _length = reader.read("!H")[0] |
| 3055 | obj.xid = reader.read("!L")[0] |
| 3056 | _experimenter = reader.read("!L")[0] |
| 3057 | assert(_experimenter == 6035143) |
| 3058 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3059 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3060 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3061 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3062 | obj.idle_timeout = reader.read("!H")[0] |
| 3063 | obj.hard_timeout = reader.read("!H")[0] |
| 3064 | obj.priority = reader.read("!H")[0] |
| 3065 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3066 | return obj |
| 3067 | |
| 3068 | def __eq__(self, other): |
| 3069 | if type(self) != type(other): return False |
| 3070 | if self.version != other.version: return False |
| 3071 | if self.type != other.type: return False |
| 3072 | if self.xid != other.xid: return False |
| 3073 | if self.enabled != other.enabled: return False |
| 3074 | if self.idle_timeout != other.idle_timeout: return False |
| 3075 | if self.hard_timeout != other.hard_timeout: return False |
| 3076 | if self.priority != other.priority: return False |
| 3077 | if self.cookie != other.cookie: return False |
| 3078 | return True |
| 3079 | |
| 3080 | def __ne__(self, other): |
| 3081 | return not self.__eq__(other) |
| 3082 | |
| 3083 | def __str__(self): |
| 3084 | return self.show() |
| 3085 | |
| 3086 | def show(self): |
| 3087 | import loxi.pp |
| 3088 | return loxi.pp.pp(self) |
| 3089 | |
| 3090 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3091 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3092 | with q.group(): |
| 3093 | with q.indent(2): |
| 3094 | q.breakable() |
| 3095 | q.text("xid = "); |
| 3096 | if self.xid != None: |
| 3097 | q.text("%#x" % self.xid) |
| 3098 | else: |
| 3099 | q.text('None') |
| 3100 | q.text(","); q.breakable() |
| 3101 | q.text("enabled = "); |
| 3102 | q.text("%#x" % self.enabled) |
| 3103 | q.text(","); q.breakable() |
| 3104 | q.text("idle_timeout = "); |
| 3105 | q.text("%#x" % self.idle_timeout) |
| 3106 | q.text(","); q.breakable() |
| 3107 | q.text("hard_timeout = "); |
| 3108 | q.text("%#x" % self.hard_timeout) |
| 3109 | q.text(","); q.breakable() |
| 3110 | q.text("priority = "); |
| 3111 | q.text("%#x" % self.priority) |
| 3112 | q.text(","); q.breakable() |
| 3113 | q.text("cookie = "); |
| 3114 | q.text("%#x" % self.cookie) |
| 3115 | q.breakable() |
| 3116 | q.text('}') |
| 3117 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3118 | class bsn_virtual_port_create_reply(Message): |
| 3119 | version = 4 |
| 3120 | type = 4 |
| 3121 | experimenter = 6035143 |
| 3122 | subtype = 16 |
| 3123 | |
| 3124 | def __init__(self, xid=None, status=None, vport_no=None): |
| 3125 | self.xid = xid |
| 3126 | if status != None: |
| 3127 | self.status = status |
| 3128 | else: |
| 3129 | self.status = 0 |
| 3130 | if vport_no != None: |
| 3131 | self.vport_no = vport_no |
| 3132 | else: |
| 3133 | self.vport_no = 0 |
| 3134 | |
| 3135 | def pack(self): |
| 3136 | packed = [] |
| 3137 | packed.append(struct.pack("!B", self.version)) |
| 3138 | packed.append(struct.pack("!B", self.type)) |
| 3139 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3140 | packed.append(struct.pack("!L", self.xid)) |
| 3141 | packed.append(struct.pack("!L", self.experimenter)) |
| 3142 | packed.append(struct.pack("!L", self.subtype)) |
| 3143 | packed.append(struct.pack("!L", self.status)) |
| 3144 | packed.append(struct.pack("!L", self.vport_no)) |
| 3145 | length = sum([len(x) for x in packed]) |
| 3146 | packed[2] = struct.pack("!H", length) |
| 3147 | return ''.join(packed) |
| 3148 | |
| 3149 | @staticmethod |
| 3150 | def unpack(buf): |
| 3151 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3152 | obj = bsn_virtual_port_create_reply() |
| 3153 | if type(buf) == loxi.generic_util.OFReader: |
| 3154 | reader = buf |
| 3155 | else: |
| 3156 | reader = loxi.generic_util.OFReader(buf) |
| 3157 | _version = reader.read("!B")[0] |
| 3158 | assert(_version == 4) |
| 3159 | _type = reader.read("!B")[0] |
| 3160 | assert(_type == 4) |
| 3161 | _length = reader.read("!H")[0] |
| 3162 | obj.xid = reader.read("!L")[0] |
| 3163 | _experimenter = reader.read("!L")[0] |
| 3164 | assert(_experimenter == 6035143) |
| 3165 | _subtype = reader.read("!L")[0] |
| 3166 | assert(_subtype == 16) |
| 3167 | obj.status = reader.read("!L")[0] |
| 3168 | obj.vport_no = reader.read("!L")[0] |
| 3169 | return obj |
| 3170 | |
| 3171 | def __eq__(self, other): |
| 3172 | if type(self) != type(other): return False |
| 3173 | if self.version != other.version: return False |
| 3174 | if self.type != other.type: return False |
| 3175 | if self.xid != other.xid: return False |
| 3176 | if self.status != other.status: return False |
| 3177 | if self.vport_no != other.vport_no: return False |
| 3178 | return True |
| 3179 | |
| 3180 | def __ne__(self, other): |
| 3181 | return not self.__eq__(other) |
| 3182 | |
| 3183 | def __str__(self): |
| 3184 | return self.show() |
| 3185 | |
| 3186 | def show(self): |
| 3187 | import loxi.pp |
| 3188 | return loxi.pp.pp(self) |
| 3189 | |
| 3190 | def pretty_print(self, q): |
| 3191 | q.text("bsn_virtual_port_create_reply {") |
| 3192 | with q.group(): |
| 3193 | with q.indent(2): |
| 3194 | q.breakable() |
| 3195 | q.text("xid = "); |
| 3196 | if self.xid != None: |
| 3197 | q.text("%#x" % self.xid) |
| 3198 | else: |
| 3199 | q.text('None') |
| 3200 | q.text(","); q.breakable() |
| 3201 | q.text("status = "); |
| 3202 | q.text("%#x" % self.status) |
| 3203 | q.text(","); q.breakable() |
| 3204 | q.text("vport_no = "); |
| 3205 | q.text("%#x" % self.vport_no) |
| 3206 | q.breakable() |
| 3207 | q.text('}') |
| 3208 | |
| 3209 | class bsn_virtual_port_create_request(Message): |
| 3210 | version = 4 |
| 3211 | type = 4 |
| 3212 | experimenter = 6035143 |
| 3213 | subtype = 15 |
| 3214 | |
| 3215 | def __init__(self, xid=None, vport=None): |
| 3216 | self.xid = xid |
| 3217 | if vport != None: |
| 3218 | self.vport = vport |
| 3219 | else: |
| 3220 | self.vport = common.bsn_vport_q_in_q() |
| 3221 | |
| 3222 | def pack(self): |
| 3223 | packed = [] |
| 3224 | packed.append(struct.pack("!B", self.version)) |
| 3225 | packed.append(struct.pack("!B", self.type)) |
| 3226 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3227 | packed.append(struct.pack("!L", self.xid)) |
| 3228 | packed.append(struct.pack("!L", self.experimenter)) |
| 3229 | packed.append(struct.pack("!L", self.subtype)) |
| 3230 | packed.append(self.vport.pack()) |
| 3231 | length = sum([len(x) for x in packed]) |
| 3232 | packed[2] = struct.pack("!H", length) |
| 3233 | return ''.join(packed) |
| 3234 | |
| 3235 | @staticmethod |
| 3236 | def unpack(buf): |
| 3237 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3238 | obj = bsn_virtual_port_create_request() |
| 3239 | if type(buf) == loxi.generic_util.OFReader: |
| 3240 | reader = buf |
| 3241 | else: |
| 3242 | reader = loxi.generic_util.OFReader(buf) |
| 3243 | _version = reader.read("!B")[0] |
| 3244 | assert(_version == 4) |
| 3245 | _type = reader.read("!B")[0] |
| 3246 | assert(_type == 4) |
| 3247 | _length = reader.read("!H")[0] |
| 3248 | obj.xid = reader.read("!L")[0] |
| 3249 | _experimenter = reader.read("!L")[0] |
| 3250 | assert(_experimenter == 6035143) |
| 3251 | _subtype = reader.read("!L")[0] |
| 3252 | assert(_subtype == 15) |
| 3253 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 3254 | return obj |
| 3255 | |
| 3256 | def __eq__(self, other): |
| 3257 | if type(self) != type(other): return False |
| 3258 | if self.version != other.version: return False |
| 3259 | if self.type != other.type: return False |
| 3260 | if self.xid != other.xid: return False |
| 3261 | if self.vport != other.vport: return False |
| 3262 | return True |
| 3263 | |
| 3264 | def __ne__(self, other): |
| 3265 | return not self.__eq__(other) |
| 3266 | |
| 3267 | def __str__(self): |
| 3268 | return self.show() |
| 3269 | |
| 3270 | def show(self): |
| 3271 | import loxi.pp |
| 3272 | return loxi.pp.pp(self) |
| 3273 | |
| 3274 | def pretty_print(self, q): |
| 3275 | q.text("bsn_virtual_port_create_request {") |
| 3276 | with q.group(): |
| 3277 | with q.indent(2): |
| 3278 | q.breakable() |
| 3279 | q.text("xid = "); |
| 3280 | if self.xid != None: |
| 3281 | q.text("%#x" % self.xid) |
| 3282 | else: |
| 3283 | q.text('None') |
| 3284 | q.text(","); q.breakable() |
| 3285 | q.text("vport = "); |
| 3286 | q.pp(self.vport) |
| 3287 | q.breakable() |
| 3288 | q.text('}') |
| 3289 | |
| 3290 | class bsn_virtual_port_remove_reply(Message): |
| 3291 | version = 4 |
| 3292 | type = 4 |
| 3293 | experimenter = 6035143 |
| 3294 | subtype = 26 |
| 3295 | |
| 3296 | def __init__(self, xid=None, status=None): |
| 3297 | self.xid = xid |
| 3298 | if status != None: |
| 3299 | self.status = status |
| 3300 | else: |
| 3301 | self.status = 0 |
| 3302 | |
| 3303 | def pack(self): |
| 3304 | packed = [] |
| 3305 | packed.append(struct.pack("!B", self.version)) |
| 3306 | packed.append(struct.pack("!B", self.type)) |
| 3307 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3308 | packed.append(struct.pack("!L", self.xid)) |
| 3309 | packed.append(struct.pack("!L", self.experimenter)) |
| 3310 | packed.append(struct.pack("!L", self.subtype)) |
| 3311 | packed.append(struct.pack("!L", self.status)) |
| 3312 | length = sum([len(x) for x in packed]) |
| 3313 | packed[2] = struct.pack("!H", length) |
| 3314 | return ''.join(packed) |
| 3315 | |
| 3316 | @staticmethod |
| 3317 | def unpack(buf): |
| 3318 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3319 | obj = bsn_virtual_port_remove_reply() |
| 3320 | if type(buf) == loxi.generic_util.OFReader: |
| 3321 | reader = buf |
| 3322 | else: |
| 3323 | reader = loxi.generic_util.OFReader(buf) |
| 3324 | _version = reader.read("!B")[0] |
| 3325 | assert(_version == 4) |
| 3326 | _type = reader.read("!B")[0] |
| 3327 | assert(_type == 4) |
| 3328 | _length = reader.read("!H")[0] |
| 3329 | obj.xid = reader.read("!L")[0] |
| 3330 | _experimenter = reader.read("!L")[0] |
| 3331 | assert(_experimenter == 6035143) |
| 3332 | _subtype = reader.read("!L")[0] |
| 3333 | assert(_subtype == 26) |
| 3334 | obj.status = reader.read("!L")[0] |
| 3335 | return obj |
| 3336 | |
| 3337 | def __eq__(self, other): |
| 3338 | if type(self) != type(other): return False |
| 3339 | if self.version != other.version: return False |
| 3340 | if self.type != other.type: return False |
| 3341 | if self.xid != other.xid: return False |
| 3342 | if self.status != other.status: return False |
| 3343 | return True |
| 3344 | |
| 3345 | def __ne__(self, other): |
| 3346 | return not self.__eq__(other) |
| 3347 | |
| 3348 | def __str__(self): |
| 3349 | return self.show() |
| 3350 | |
| 3351 | def show(self): |
| 3352 | import loxi.pp |
| 3353 | return loxi.pp.pp(self) |
| 3354 | |
| 3355 | def pretty_print(self, q): |
| 3356 | q.text("bsn_virtual_port_remove_reply {") |
| 3357 | with q.group(): |
| 3358 | with q.indent(2): |
| 3359 | q.breakable() |
| 3360 | q.text("xid = "); |
| 3361 | if self.xid != None: |
| 3362 | q.text("%#x" % self.xid) |
| 3363 | else: |
| 3364 | q.text('None') |
| 3365 | q.text(","); q.breakable() |
| 3366 | q.text("status = "); |
| 3367 | q.text("%#x" % self.status) |
| 3368 | q.breakable() |
| 3369 | q.text('}') |
| 3370 | |
| 3371 | class bsn_virtual_port_remove_request(Message): |
| 3372 | version = 4 |
| 3373 | type = 4 |
| 3374 | experimenter = 6035143 |
| 3375 | subtype = 17 |
| 3376 | |
| 3377 | def __init__(self, xid=None, vport_no=None): |
| 3378 | self.xid = xid |
| 3379 | if vport_no != None: |
| 3380 | self.vport_no = vport_no |
| 3381 | else: |
| 3382 | self.vport_no = 0 |
| 3383 | |
| 3384 | def pack(self): |
| 3385 | packed = [] |
| 3386 | packed.append(struct.pack("!B", self.version)) |
| 3387 | packed.append(struct.pack("!B", self.type)) |
| 3388 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3389 | packed.append(struct.pack("!L", self.xid)) |
| 3390 | packed.append(struct.pack("!L", self.experimenter)) |
| 3391 | packed.append(struct.pack("!L", self.subtype)) |
| 3392 | packed.append(struct.pack("!L", self.vport_no)) |
| 3393 | length = sum([len(x) for x in packed]) |
| 3394 | packed[2] = struct.pack("!H", length) |
| 3395 | return ''.join(packed) |
| 3396 | |
| 3397 | @staticmethod |
| 3398 | def unpack(buf): |
| 3399 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3400 | obj = bsn_virtual_port_remove_request() |
| 3401 | if type(buf) == loxi.generic_util.OFReader: |
| 3402 | reader = buf |
| 3403 | else: |
| 3404 | reader = loxi.generic_util.OFReader(buf) |
| 3405 | _version = reader.read("!B")[0] |
| 3406 | assert(_version == 4) |
| 3407 | _type = reader.read("!B")[0] |
| 3408 | assert(_type == 4) |
| 3409 | _length = reader.read("!H")[0] |
| 3410 | obj.xid = reader.read("!L")[0] |
| 3411 | _experimenter = reader.read("!L")[0] |
| 3412 | assert(_experimenter == 6035143) |
| 3413 | _subtype = reader.read("!L")[0] |
| 3414 | assert(_subtype == 17) |
| 3415 | obj.vport_no = reader.read("!L")[0] |
| 3416 | return obj |
| 3417 | |
| 3418 | def __eq__(self, other): |
| 3419 | if type(self) != type(other): return False |
| 3420 | if self.version != other.version: return False |
| 3421 | if self.type != other.type: return False |
| 3422 | if self.xid != other.xid: return False |
| 3423 | if self.vport_no != other.vport_no: return False |
| 3424 | return True |
| 3425 | |
| 3426 | def __ne__(self, other): |
| 3427 | return not self.__eq__(other) |
| 3428 | |
| 3429 | def __str__(self): |
| 3430 | return self.show() |
| 3431 | |
| 3432 | def show(self): |
| 3433 | import loxi.pp |
| 3434 | return loxi.pp.pp(self) |
| 3435 | |
| 3436 | def pretty_print(self, q): |
| 3437 | q.text("bsn_virtual_port_remove_request {") |
| 3438 | with q.group(): |
| 3439 | with q.indent(2): |
| 3440 | q.breakable() |
| 3441 | q.text("xid = "); |
| 3442 | if self.xid != None: |
| 3443 | q.text("%#x" % self.xid) |
| 3444 | else: |
| 3445 | q.text('None') |
| 3446 | q.text(","); q.breakable() |
| 3447 | q.text("vport_no = "); |
| 3448 | q.text("%#x" % self.vport_no) |
| 3449 | q.breakable() |
| 3450 | q.text('}') |
| 3451 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3452 | class desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3453 | version = 4 |
| 3454 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3455 | stats_type = 0 |
| 3456 | |
| 3457 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
| 3458 | self.xid = xid |
| 3459 | if flags != None: |
| 3460 | self.flags = flags |
| 3461 | else: |
| 3462 | self.flags = 0 |
| 3463 | if mfr_desc != None: |
| 3464 | self.mfr_desc = mfr_desc |
| 3465 | else: |
| 3466 | self.mfr_desc = "" |
| 3467 | if hw_desc != None: |
| 3468 | self.hw_desc = hw_desc |
| 3469 | else: |
| 3470 | self.hw_desc = "" |
| 3471 | if sw_desc != None: |
| 3472 | self.sw_desc = sw_desc |
| 3473 | else: |
| 3474 | self.sw_desc = "" |
| 3475 | if serial_num != None: |
| 3476 | self.serial_num = serial_num |
| 3477 | else: |
| 3478 | self.serial_num = "" |
| 3479 | if dp_desc != None: |
| 3480 | self.dp_desc = dp_desc |
| 3481 | else: |
| 3482 | self.dp_desc = "" |
| 3483 | |
| 3484 | def pack(self): |
| 3485 | packed = [] |
| 3486 | packed.append(struct.pack("!B", self.version)) |
| 3487 | packed.append(struct.pack("!B", self.type)) |
| 3488 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3489 | packed.append(struct.pack("!L", self.xid)) |
| 3490 | packed.append(struct.pack("!H", self.stats_type)) |
| 3491 | packed.append(struct.pack("!H", self.flags)) |
| 3492 | packed.append('\x00' * 4) |
| 3493 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 3494 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 3495 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 3496 | packed.append(struct.pack("!32s", self.serial_num)) |
| 3497 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 3498 | length = sum([len(x) for x in packed]) |
| 3499 | packed[2] = struct.pack("!H", length) |
| 3500 | return ''.join(packed) |
| 3501 | |
| 3502 | @staticmethod |
| 3503 | def unpack(buf): |
| 3504 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3505 | obj = desc_stats_reply() |
| 3506 | if type(buf) == loxi.generic_util.OFReader: |
| 3507 | reader = buf |
| 3508 | else: |
| 3509 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3510 | _version = reader.read("!B")[0] |
| 3511 | assert(_version == 4) |
| 3512 | _type = reader.read("!B")[0] |
| 3513 | assert(_type == 19) |
| 3514 | _length = reader.read("!H")[0] |
| 3515 | obj.xid = reader.read("!L")[0] |
| 3516 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3517 | assert(_stats_type == 0) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3518 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3519 | reader.skip(4) |
| 3520 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3521 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3522 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3523 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 3524 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
| 3525 | return obj |
| 3526 | |
| 3527 | def __eq__(self, other): |
| 3528 | if type(self) != type(other): return False |
| 3529 | if self.version != other.version: return False |
| 3530 | if self.type != other.type: return False |
| 3531 | if self.xid != other.xid: return False |
| 3532 | if self.flags != other.flags: return False |
| 3533 | if self.mfr_desc != other.mfr_desc: return False |
| 3534 | if self.hw_desc != other.hw_desc: return False |
| 3535 | if self.sw_desc != other.sw_desc: return False |
| 3536 | if self.serial_num != other.serial_num: return False |
| 3537 | if self.dp_desc != other.dp_desc: return False |
| 3538 | return True |
| 3539 | |
| 3540 | def __ne__(self, other): |
| 3541 | return not self.__eq__(other) |
| 3542 | |
| 3543 | def __str__(self): |
| 3544 | return self.show() |
| 3545 | |
| 3546 | def show(self): |
| 3547 | import loxi.pp |
| 3548 | return loxi.pp.pp(self) |
| 3549 | |
| 3550 | def pretty_print(self, q): |
| 3551 | q.text("desc_stats_reply {") |
| 3552 | with q.group(): |
| 3553 | with q.indent(2): |
| 3554 | q.breakable() |
| 3555 | q.text("xid = "); |
| 3556 | if self.xid != None: |
| 3557 | q.text("%#x" % self.xid) |
| 3558 | else: |
| 3559 | q.text('None') |
| 3560 | q.text(","); q.breakable() |
| 3561 | q.text("flags = "); |
| 3562 | q.text("%#x" % self.flags) |
| 3563 | q.text(","); q.breakable() |
| 3564 | q.text("mfr_desc = "); |
| 3565 | q.pp(self.mfr_desc) |
| 3566 | q.text(","); q.breakable() |
| 3567 | q.text("hw_desc = "); |
| 3568 | q.pp(self.hw_desc) |
| 3569 | q.text(","); q.breakable() |
| 3570 | q.text("sw_desc = "); |
| 3571 | q.pp(self.sw_desc) |
| 3572 | q.text(","); q.breakable() |
| 3573 | q.text("serial_num = "); |
| 3574 | q.pp(self.serial_num) |
| 3575 | q.text(","); q.breakable() |
| 3576 | q.text("dp_desc = "); |
| 3577 | q.pp(self.dp_desc) |
| 3578 | q.breakable() |
| 3579 | q.text('}') |
| 3580 | |
| 3581 | class desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3582 | version = 4 |
| 3583 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3584 | stats_type = 0 |
| 3585 | |
| 3586 | def __init__(self, xid=None, flags=None): |
| 3587 | self.xid = xid |
| 3588 | if flags != None: |
| 3589 | self.flags = flags |
| 3590 | else: |
| 3591 | self.flags = 0 |
| 3592 | |
| 3593 | def pack(self): |
| 3594 | packed = [] |
| 3595 | packed.append(struct.pack("!B", self.version)) |
| 3596 | packed.append(struct.pack("!B", self.type)) |
| 3597 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3598 | packed.append(struct.pack("!L", self.xid)) |
| 3599 | packed.append(struct.pack("!H", self.stats_type)) |
| 3600 | packed.append(struct.pack("!H", self.flags)) |
| 3601 | packed.append('\x00' * 4) |
| 3602 | length = sum([len(x) for x in packed]) |
| 3603 | packed[2] = struct.pack("!H", length) |
| 3604 | return ''.join(packed) |
| 3605 | |
| 3606 | @staticmethod |
| 3607 | def unpack(buf): |
| 3608 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3609 | obj = desc_stats_request() |
| 3610 | if type(buf) == loxi.generic_util.OFReader: |
| 3611 | reader = buf |
| 3612 | else: |
| 3613 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3614 | _version = reader.read("!B")[0] |
| 3615 | assert(_version == 4) |
| 3616 | _type = reader.read("!B")[0] |
| 3617 | assert(_type == 18) |
| 3618 | _length = reader.read("!H")[0] |
| 3619 | obj.xid = reader.read("!L")[0] |
| 3620 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3621 | assert(_stats_type == 0) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3622 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3623 | reader.skip(4) |
| 3624 | return obj |
| 3625 | |
| 3626 | def __eq__(self, other): |
| 3627 | if type(self) != type(other): return False |
| 3628 | if self.version != other.version: return False |
| 3629 | if self.type != other.type: return False |
| 3630 | if self.xid != other.xid: return False |
| 3631 | if self.flags != other.flags: return False |
| 3632 | return True |
| 3633 | |
| 3634 | def __ne__(self, other): |
| 3635 | return not self.__eq__(other) |
| 3636 | |
| 3637 | def __str__(self): |
| 3638 | return self.show() |
| 3639 | |
| 3640 | def show(self): |
| 3641 | import loxi.pp |
| 3642 | return loxi.pp.pp(self) |
| 3643 | |
| 3644 | def pretty_print(self, q): |
| 3645 | q.text("desc_stats_request {") |
| 3646 | with q.group(): |
| 3647 | with q.indent(2): |
| 3648 | q.breakable() |
| 3649 | q.text("xid = "); |
| 3650 | if self.xid != None: |
| 3651 | q.text("%#x" % self.xid) |
| 3652 | else: |
| 3653 | q.text('None') |
| 3654 | q.text(","); q.breakable() |
| 3655 | q.text("flags = "); |
| 3656 | q.text("%#x" % self.flags) |
| 3657 | q.breakable() |
| 3658 | q.text('}') |
| 3659 | |
| 3660 | class echo_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3661 | version = 4 |
| 3662 | type = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3663 | |
| 3664 | def __init__(self, xid=None, data=None): |
| 3665 | self.xid = xid |
| 3666 | if data != None: |
| 3667 | self.data = data |
| 3668 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3669 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3670 | |
| 3671 | def pack(self): |
| 3672 | packed = [] |
| 3673 | packed.append(struct.pack("!B", self.version)) |
| 3674 | packed.append(struct.pack("!B", self.type)) |
| 3675 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3676 | packed.append(struct.pack("!L", self.xid)) |
| 3677 | packed.append(self.data) |
| 3678 | length = sum([len(x) for x in packed]) |
| 3679 | packed[2] = struct.pack("!H", length) |
| 3680 | return ''.join(packed) |
| 3681 | |
| 3682 | @staticmethod |
| 3683 | def unpack(buf): |
| 3684 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3685 | obj = echo_reply() |
| 3686 | if type(buf) == loxi.generic_util.OFReader: |
| 3687 | reader = buf |
| 3688 | else: |
| 3689 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3690 | _version = reader.read("!B")[0] |
| 3691 | assert(_version == 4) |
| 3692 | _type = reader.read("!B")[0] |
| 3693 | assert(_type == 3) |
| 3694 | _length = reader.read("!H")[0] |
| 3695 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3696 | obj.data = str(reader.read_all()) |
| 3697 | return obj |
| 3698 | |
| 3699 | def __eq__(self, other): |
| 3700 | if type(self) != type(other): return False |
| 3701 | if self.version != other.version: return False |
| 3702 | if self.type != other.type: return False |
| 3703 | if self.xid != other.xid: return False |
| 3704 | if self.data != other.data: return False |
| 3705 | return True |
| 3706 | |
| 3707 | def __ne__(self, other): |
| 3708 | return not self.__eq__(other) |
| 3709 | |
| 3710 | def __str__(self): |
| 3711 | return self.show() |
| 3712 | |
| 3713 | def show(self): |
| 3714 | import loxi.pp |
| 3715 | return loxi.pp.pp(self) |
| 3716 | |
| 3717 | def pretty_print(self, q): |
| 3718 | q.text("echo_reply {") |
| 3719 | with q.group(): |
| 3720 | with q.indent(2): |
| 3721 | q.breakable() |
| 3722 | q.text("xid = "); |
| 3723 | if self.xid != None: |
| 3724 | q.text("%#x" % self.xid) |
| 3725 | else: |
| 3726 | q.text('None') |
| 3727 | q.text(","); q.breakable() |
| 3728 | q.text("data = "); |
| 3729 | q.pp(self.data) |
| 3730 | q.breakable() |
| 3731 | q.text('}') |
| 3732 | |
| 3733 | class echo_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3734 | version = 4 |
| 3735 | type = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3736 | |
| 3737 | def __init__(self, xid=None, data=None): |
| 3738 | self.xid = xid |
| 3739 | if data != None: |
| 3740 | self.data = data |
| 3741 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3742 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3743 | |
| 3744 | def pack(self): |
| 3745 | packed = [] |
| 3746 | packed.append(struct.pack("!B", self.version)) |
| 3747 | packed.append(struct.pack("!B", self.type)) |
| 3748 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3749 | packed.append(struct.pack("!L", self.xid)) |
| 3750 | packed.append(self.data) |
| 3751 | length = sum([len(x) for x in packed]) |
| 3752 | packed[2] = struct.pack("!H", length) |
| 3753 | return ''.join(packed) |
| 3754 | |
| 3755 | @staticmethod |
| 3756 | def unpack(buf): |
| 3757 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3758 | obj = echo_request() |
| 3759 | if type(buf) == loxi.generic_util.OFReader: |
| 3760 | reader = buf |
| 3761 | else: |
| 3762 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3763 | _version = reader.read("!B")[0] |
| 3764 | assert(_version == 4) |
| 3765 | _type = reader.read("!B")[0] |
| 3766 | assert(_type == 2) |
| 3767 | _length = reader.read("!H")[0] |
| 3768 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3769 | obj.data = str(reader.read_all()) |
| 3770 | return obj |
| 3771 | |
| 3772 | def __eq__(self, other): |
| 3773 | if type(self) != type(other): return False |
| 3774 | if self.version != other.version: return False |
| 3775 | if self.type != other.type: return False |
| 3776 | if self.xid != other.xid: return False |
| 3777 | if self.data != other.data: return False |
| 3778 | return True |
| 3779 | |
| 3780 | def __ne__(self, other): |
| 3781 | return not self.__eq__(other) |
| 3782 | |
| 3783 | def __str__(self): |
| 3784 | return self.show() |
| 3785 | |
| 3786 | def show(self): |
| 3787 | import loxi.pp |
| 3788 | return loxi.pp.pp(self) |
| 3789 | |
| 3790 | def pretty_print(self, q): |
| 3791 | q.text("echo_request {") |
| 3792 | with q.group(): |
| 3793 | with q.indent(2): |
| 3794 | q.breakable() |
| 3795 | q.text("xid = "); |
| 3796 | if self.xid != None: |
| 3797 | q.text("%#x" % self.xid) |
| 3798 | else: |
| 3799 | q.text('None') |
| 3800 | q.text(","); q.breakable() |
| 3801 | q.text("data = "); |
| 3802 | q.pp(self.data) |
| 3803 | q.breakable() |
| 3804 | q.text('}') |
| 3805 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3806 | class experimenter_error_msg(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3807 | version = 4 |
| 3808 | type = 1 |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3809 | err_type = 65535 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3810 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3811 | def __init__(self, xid=None, subtype=None, experimenter=None, data=None): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3812 | self.xid = xid |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3813 | if subtype != None: |
| 3814 | self.subtype = subtype |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3815 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3816 | self.subtype = 0 |
| 3817 | if experimenter != None: |
| 3818 | self.experimenter = experimenter |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3819 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3820 | self.experimenter = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3821 | if data != None: |
| 3822 | self.data = data |
| 3823 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3824 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3825 | |
| 3826 | def pack(self): |
| 3827 | packed = [] |
| 3828 | packed.append(struct.pack("!B", self.version)) |
| 3829 | packed.append(struct.pack("!B", self.type)) |
| 3830 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3831 | packed.append(struct.pack("!L", self.xid)) |
| 3832 | packed.append(struct.pack("!H", self.err_type)) |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3833 | packed.append(struct.pack("!H", self.subtype)) |
| 3834 | packed.append(struct.pack("!L", self.experimenter)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3835 | packed.append(self.data) |
| 3836 | length = sum([len(x) for x in packed]) |
| 3837 | packed[2] = struct.pack("!H", length) |
| 3838 | return ''.join(packed) |
| 3839 | |
| 3840 | @staticmethod |
| 3841 | def unpack(buf): |
| 3842 | 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] | 3843 | obj = experimenter_error_msg() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3844 | if type(buf) == loxi.generic_util.OFReader: |
| 3845 | reader = buf |
| 3846 | else: |
| 3847 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3848 | _version = reader.read("!B")[0] |
| 3849 | assert(_version == 4) |
| 3850 | _type = reader.read("!B")[0] |
| 3851 | assert(_type == 1) |
| 3852 | _length = reader.read("!H")[0] |
| 3853 | obj.xid = reader.read("!L")[0] |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3854 | _err_type = reader.read("!H")[0] |
| 3855 | assert(_err_type == 65535) |
| 3856 | obj.subtype = reader.read("!H")[0] |
| 3857 | obj.experimenter = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3858 | obj.data = str(reader.read_all()) |
| 3859 | return obj |
| 3860 | |
| 3861 | def __eq__(self, other): |
| 3862 | if type(self) != type(other): return False |
| 3863 | if self.version != other.version: return False |
| 3864 | if self.type != other.type: return False |
| 3865 | if self.xid != other.xid: return False |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3866 | if self.subtype != other.subtype: return False |
| 3867 | if self.experimenter != other.experimenter: return False |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3868 | if self.data != other.data: return False |
| 3869 | return True |
| 3870 | |
| 3871 | def __ne__(self, other): |
| 3872 | return not self.__eq__(other) |
| 3873 | |
| 3874 | def __str__(self): |
| 3875 | return self.show() |
| 3876 | |
| 3877 | def show(self): |
| 3878 | import loxi.pp |
| 3879 | return loxi.pp.pp(self) |
| 3880 | |
| 3881 | def pretty_print(self, q): |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3882 | q.text("experimenter_error_msg {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3883 | with q.group(): |
| 3884 | with q.indent(2): |
| 3885 | q.breakable() |
| 3886 | q.text("xid = "); |
| 3887 | if self.xid != None: |
| 3888 | q.text("%#x" % self.xid) |
| 3889 | else: |
| 3890 | q.text('None') |
| 3891 | q.text(","); q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3892 | q.text("subtype = "); |
| 3893 | q.text("%#x" % self.subtype) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3894 | q.text(","); q.breakable() |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 3895 | q.text("experimenter = "); |
| 3896 | q.text("%#x" % self.experimenter) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3897 | q.text(","); q.breakable() |
| 3898 | q.text("data = "); |
| 3899 | q.pp(self.data) |
| 3900 | q.breakable() |
| 3901 | q.text('}') |
| 3902 | |
| 3903 | class features_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3904 | version = 4 |
| 3905 | type = 6 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3906 | |
| 3907 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, auxiliary_id=None, capabilities=None, reserved=None): |
| 3908 | self.xid = xid |
| 3909 | if datapath_id != None: |
| 3910 | self.datapath_id = datapath_id |
| 3911 | else: |
| 3912 | self.datapath_id = 0 |
| 3913 | if n_buffers != None: |
| 3914 | self.n_buffers = n_buffers |
| 3915 | else: |
| 3916 | self.n_buffers = 0 |
| 3917 | if n_tables != None: |
| 3918 | self.n_tables = n_tables |
| 3919 | else: |
| 3920 | self.n_tables = 0 |
| 3921 | if auxiliary_id != None: |
| 3922 | self.auxiliary_id = auxiliary_id |
| 3923 | else: |
| 3924 | self.auxiliary_id = 0 |
| 3925 | if capabilities != None: |
| 3926 | self.capabilities = capabilities |
| 3927 | else: |
| 3928 | self.capabilities = 0 |
| 3929 | if reserved != None: |
| 3930 | self.reserved = reserved |
| 3931 | else: |
| 3932 | self.reserved = 0 |
| 3933 | |
| 3934 | def pack(self): |
| 3935 | packed = [] |
| 3936 | packed.append(struct.pack("!B", self.version)) |
| 3937 | packed.append(struct.pack("!B", self.type)) |
| 3938 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3939 | packed.append(struct.pack("!L", self.xid)) |
| 3940 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 3941 | packed.append(struct.pack("!L", self.n_buffers)) |
| 3942 | packed.append(struct.pack("!B", self.n_tables)) |
| 3943 | packed.append(struct.pack("!B", self.auxiliary_id)) |
| 3944 | packed.append('\x00' * 2) |
| 3945 | packed.append(struct.pack("!L", self.capabilities)) |
| 3946 | packed.append(struct.pack("!L", self.reserved)) |
| 3947 | length = sum([len(x) for x in packed]) |
| 3948 | packed[2] = struct.pack("!H", length) |
| 3949 | return ''.join(packed) |
| 3950 | |
| 3951 | @staticmethod |
| 3952 | def unpack(buf): |
| 3953 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3954 | obj = features_reply() |
| 3955 | if type(buf) == loxi.generic_util.OFReader: |
| 3956 | reader = buf |
| 3957 | else: |
| 3958 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3959 | _version = reader.read("!B")[0] |
| 3960 | assert(_version == 4) |
| 3961 | _type = reader.read("!B")[0] |
| 3962 | assert(_type == 6) |
| 3963 | _length = reader.read("!H")[0] |
| 3964 | obj.xid = reader.read("!L")[0] |
| 3965 | obj.datapath_id = reader.read("!Q")[0] |
| 3966 | obj.n_buffers = reader.read("!L")[0] |
| 3967 | obj.n_tables = reader.read("!B")[0] |
| 3968 | obj.auxiliary_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3969 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3970 | obj.capabilities = reader.read("!L")[0] |
| 3971 | obj.reserved = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 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.datapath_id != other.datapath_id: return False |
| 3980 | if self.n_buffers != other.n_buffers: return False |
| 3981 | if self.n_tables != other.n_tables: return False |
| 3982 | if self.auxiliary_id != other.auxiliary_id: return False |
| 3983 | if self.capabilities != other.capabilities: return False |
| 3984 | if self.reserved != other.reserved: return False |
| 3985 | return True |
| 3986 | |
| 3987 | def __ne__(self, other): |
| 3988 | return not self.__eq__(other) |
| 3989 | |
| 3990 | def __str__(self): |
| 3991 | return self.show() |
| 3992 | |
| 3993 | def show(self): |
| 3994 | import loxi.pp |
| 3995 | return loxi.pp.pp(self) |
| 3996 | |
| 3997 | def pretty_print(self, q): |
| 3998 | q.text("features_reply {") |
| 3999 | with q.group(): |
| 4000 | with q.indent(2): |
| 4001 | q.breakable() |
| 4002 | q.text("xid = "); |
| 4003 | if self.xid != None: |
| 4004 | q.text("%#x" % self.xid) |
| 4005 | else: |
| 4006 | q.text('None') |
| 4007 | q.text(","); q.breakable() |
| 4008 | q.text("datapath_id = "); |
| 4009 | q.text("%#x" % self.datapath_id) |
| 4010 | q.text(","); q.breakable() |
| 4011 | q.text("n_buffers = "); |
| 4012 | q.text("%#x" % self.n_buffers) |
| 4013 | q.text(","); q.breakable() |
| 4014 | q.text("n_tables = "); |
| 4015 | q.text("%#x" % self.n_tables) |
| 4016 | q.text(","); q.breakable() |
| 4017 | q.text("auxiliary_id = "); |
| 4018 | q.text("%#x" % self.auxiliary_id) |
| 4019 | q.text(","); q.breakable() |
| 4020 | q.text("capabilities = "); |
| 4021 | q.text("%#x" % self.capabilities) |
| 4022 | q.text(","); q.breakable() |
| 4023 | q.text("reserved = "); |
| 4024 | q.text("%#x" % self.reserved) |
| 4025 | q.breakable() |
| 4026 | q.text('}') |
| 4027 | |
| 4028 | class features_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4029 | version = 4 |
| 4030 | type = 5 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4031 | |
| 4032 | def __init__(self, xid=None): |
| 4033 | self.xid = xid |
| 4034 | |
| 4035 | def pack(self): |
| 4036 | packed = [] |
| 4037 | packed.append(struct.pack("!B", self.version)) |
| 4038 | packed.append(struct.pack("!B", self.type)) |
| 4039 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4040 | packed.append(struct.pack("!L", self.xid)) |
| 4041 | length = sum([len(x) for x in packed]) |
| 4042 | packed[2] = struct.pack("!H", length) |
| 4043 | return ''.join(packed) |
| 4044 | |
| 4045 | @staticmethod |
| 4046 | def unpack(buf): |
| 4047 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4048 | obj = features_request() |
| 4049 | if type(buf) == loxi.generic_util.OFReader: |
| 4050 | reader = buf |
| 4051 | else: |
| 4052 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4053 | _version = reader.read("!B")[0] |
| 4054 | assert(_version == 4) |
| 4055 | _type = reader.read("!B")[0] |
| 4056 | assert(_type == 5) |
| 4057 | _length = reader.read("!H")[0] |
| 4058 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4059 | return obj |
| 4060 | |
| 4061 | def __eq__(self, other): |
| 4062 | if type(self) != type(other): return False |
| 4063 | if self.version != other.version: return False |
| 4064 | if self.type != other.type: return False |
| 4065 | if self.xid != other.xid: return False |
| 4066 | return True |
| 4067 | |
| 4068 | def __ne__(self, other): |
| 4069 | return not self.__eq__(other) |
| 4070 | |
| 4071 | def __str__(self): |
| 4072 | return self.show() |
| 4073 | |
| 4074 | def show(self): |
| 4075 | import loxi.pp |
| 4076 | return loxi.pp.pp(self) |
| 4077 | |
| 4078 | def pretty_print(self, q): |
| 4079 | q.text("features_request {") |
| 4080 | with q.group(): |
| 4081 | with q.indent(2): |
| 4082 | q.breakable() |
| 4083 | q.text("xid = "); |
| 4084 | if self.xid != None: |
| 4085 | q.text("%#x" % self.xid) |
| 4086 | else: |
| 4087 | q.text('None') |
| 4088 | q.breakable() |
| 4089 | q.text('}') |
| 4090 | |
| 4091 | class flow_add(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4092 | version = 4 |
| 4093 | type = 14 |
| 4094 | _command = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4095 | |
| 4096 | 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): |
| 4097 | self.xid = xid |
| 4098 | if cookie != None: |
| 4099 | self.cookie = cookie |
| 4100 | else: |
| 4101 | self.cookie = 0 |
| 4102 | if cookie_mask != None: |
| 4103 | self.cookie_mask = cookie_mask |
| 4104 | else: |
| 4105 | self.cookie_mask = 0 |
| 4106 | if table_id != None: |
| 4107 | self.table_id = table_id |
| 4108 | else: |
| 4109 | self.table_id = 0 |
| 4110 | if idle_timeout != None: |
| 4111 | self.idle_timeout = idle_timeout |
| 4112 | else: |
| 4113 | self.idle_timeout = 0 |
| 4114 | if hard_timeout != None: |
| 4115 | self.hard_timeout = hard_timeout |
| 4116 | else: |
| 4117 | self.hard_timeout = 0 |
| 4118 | if priority != None: |
| 4119 | self.priority = priority |
| 4120 | else: |
| 4121 | self.priority = 0 |
| 4122 | if buffer_id != None: |
| 4123 | self.buffer_id = buffer_id |
| 4124 | else: |
| 4125 | self.buffer_id = 0 |
| 4126 | if out_port != None: |
| 4127 | self.out_port = out_port |
| 4128 | else: |
| 4129 | self.out_port = 0 |
| 4130 | if out_group != None: |
| 4131 | self.out_group = out_group |
| 4132 | else: |
| 4133 | self.out_group = 0 |
| 4134 | if flags != None: |
| 4135 | self.flags = flags |
| 4136 | else: |
| 4137 | self.flags = 0 |
| 4138 | if match != None: |
| 4139 | self.match = match |
| 4140 | else: |
| 4141 | self.match = common.match() |
| 4142 | if instructions != None: |
| 4143 | self.instructions = instructions |
| 4144 | else: |
| 4145 | self.instructions = [] |
| 4146 | |
| 4147 | def pack(self): |
| 4148 | packed = [] |
| 4149 | packed.append(struct.pack("!B", self.version)) |
| 4150 | packed.append(struct.pack("!B", self.type)) |
| 4151 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4152 | packed.append(struct.pack("!L", self.xid)) |
| 4153 | packed.append(struct.pack("!Q", self.cookie)) |
| 4154 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4155 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4156 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4157 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4158 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4159 | packed.append(struct.pack("!H", self.priority)) |
| 4160 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4161 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4162 | packed.append(struct.pack("!L", self.out_group)) |
| 4163 | packed.append(struct.pack("!H", self.flags)) |
| 4164 | packed.append('\x00' * 2) |
| 4165 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4166 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4167 | length = sum([len(x) for x in packed]) |
| 4168 | packed[2] = struct.pack("!H", length) |
| 4169 | return ''.join(packed) |
| 4170 | |
| 4171 | @staticmethod |
| 4172 | def unpack(buf): |
| 4173 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4174 | obj = flow_add() |
| 4175 | if type(buf) == loxi.generic_util.OFReader: |
| 4176 | reader = buf |
| 4177 | else: |
| 4178 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4179 | _version = reader.read("!B")[0] |
| 4180 | assert(_version == 4) |
| 4181 | _type = reader.read("!B")[0] |
| 4182 | assert(_type == 14) |
| 4183 | _length = reader.read("!H")[0] |
| 4184 | obj.xid = reader.read("!L")[0] |
| 4185 | obj.cookie = reader.read("!Q")[0] |
| 4186 | obj.cookie_mask = reader.read("!Q")[0] |
| 4187 | obj.table_id = reader.read("!B")[0] |
| 4188 | __command = util.unpack_fm_cmd(reader) |
| 4189 | assert(__command == 0) |
| 4190 | obj.idle_timeout = reader.read("!H")[0] |
| 4191 | obj.hard_timeout = reader.read("!H")[0] |
| 4192 | obj.priority = reader.read("!H")[0] |
| 4193 | obj.buffer_id = reader.read("!L")[0] |
| 4194 | obj.out_port = util.unpack_port_no(reader) |
| 4195 | obj.out_group = reader.read("!L")[0] |
| 4196 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4197 | reader.skip(2) |
| 4198 | obj.match = common.match.unpack(reader) |
| 4199 | obj.instructions = instruction.unpack_list(reader) |
| 4200 | return obj |
| 4201 | |
| 4202 | def __eq__(self, other): |
| 4203 | if type(self) != type(other): return False |
| 4204 | if self.version != other.version: return False |
| 4205 | if self.type != other.type: return False |
| 4206 | if self.xid != other.xid: return False |
| 4207 | if self.cookie != other.cookie: return False |
| 4208 | if self.cookie_mask != other.cookie_mask: return False |
| 4209 | if self.table_id != other.table_id: return False |
| 4210 | if self.idle_timeout != other.idle_timeout: return False |
| 4211 | if self.hard_timeout != other.hard_timeout: return False |
| 4212 | if self.priority != other.priority: return False |
| 4213 | if self.buffer_id != other.buffer_id: return False |
| 4214 | if self.out_port != other.out_port: return False |
| 4215 | if self.out_group != other.out_group: return False |
| 4216 | if self.flags != other.flags: return False |
| 4217 | if self.match != other.match: return False |
| 4218 | if self.instructions != other.instructions: return False |
| 4219 | return True |
| 4220 | |
| 4221 | def __ne__(self, other): |
| 4222 | return not self.__eq__(other) |
| 4223 | |
| 4224 | def __str__(self): |
| 4225 | return self.show() |
| 4226 | |
| 4227 | def show(self): |
| 4228 | import loxi.pp |
| 4229 | return loxi.pp.pp(self) |
| 4230 | |
| 4231 | def pretty_print(self, q): |
| 4232 | q.text("flow_add {") |
| 4233 | with q.group(): |
| 4234 | with q.indent(2): |
| 4235 | q.breakable() |
| 4236 | q.text("xid = "); |
| 4237 | if self.xid != None: |
| 4238 | q.text("%#x" % self.xid) |
| 4239 | else: |
| 4240 | q.text('None') |
| 4241 | q.text(","); q.breakable() |
| 4242 | q.text("cookie = "); |
| 4243 | q.text("%#x" % self.cookie) |
| 4244 | q.text(","); q.breakable() |
| 4245 | q.text("cookie_mask = "); |
| 4246 | q.text("%#x" % self.cookie_mask) |
| 4247 | q.text(","); q.breakable() |
| 4248 | q.text("table_id = "); |
| 4249 | q.text("%#x" % self.table_id) |
| 4250 | q.text(","); q.breakable() |
| 4251 | q.text("idle_timeout = "); |
| 4252 | q.text("%#x" % self.idle_timeout) |
| 4253 | q.text(","); q.breakable() |
| 4254 | q.text("hard_timeout = "); |
| 4255 | q.text("%#x" % self.hard_timeout) |
| 4256 | q.text(","); q.breakable() |
| 4257 | q.text("priority = "); |
| 4258 | q.text("%#x" % self.priority) |
| 4259 | q.text(","); q.breakable() |
| 4260 | q.text("buffer_id = "); |
| 4261 | q.text("%#x" % self.buffer_id) |
| 4262 | q.text(","); q.breakable() |
| 4263 | q.text("out_port = "); |
| 4264 | q.text(util.pretty_port(self.out_port)) |
| 4265 | q.text(","); q.breakable() |
| 4266 | q.text("out_group = "); |
| 4267 | q.text("%#x" % self.out_group) |
| 4268 | q.text(","); q.breakable() |
| 4269 | q.text("flags = "); |
| 4270 | q.text("%#x" % self.flags) |
| 4271 | q.text(","); q.breakable() |
| 4272 | q.text("match = "); |
| 4273 | q.pp(self.match) |
| 4274 | q.text(","); q.breakable() |
| 4275 | q.text("instructions = "); |
| 4276 | q.pp(self.instructions) |
| 4277 | q.breakable() |
| 4278 | q.text('}') |
| 4279 | |
| 4280 | class flow_delete(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4281 | version = 4 |
| 4282 | type = 14 |
| 4283 | _command = 3 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4284 | |
| 4285 | 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): |
| 4286 | self.xid = xid |
| 4287 | if cookie != None: |
| 4288 | self.cookie = cookie |
| 4289 | else: |
| 4290 | self.cookie = 0 |
| 4291 | if cookie_mask != None: |
| 4292 | self.cookie_mask = cookie_mask |
| 4293 | else: |
| 4294 | self.cookie_mask = 0 |
| 4295 | if table_id != None: |
| 4296 | self.table_id = table_id |
| 4297 | else: |
| 4298 | self.table_id = 0 |
| 4299 | if idle_timeout != None: |
| 4300 | self.idle_timeout = idle_timeout |
| 4301 | else: |
| 4302 | self.idle_timeout = 0 |
| 4303 | if hard_timeout != None: |
| 4304 | self.hard_timeout = hard_timeout |
| 4305 | else: |
| 4306 | self.hard_timeout = 0 |
| 4307 | if priority != None: |
| 4308 | self.priority = priority |
| 4309 | else: |
| 4310 | self.priority = 0 |
| 4311 | if buffer_id != None: |
| 4312 | self.buffer_id = buffer_id |
| 4313 | else: |
| 4314 | self.buffer_id = 0 |
| 4315 | if out_port != None: |
| 4316 | self.out_port = out_port |
| 4317 | else: |
| 4318 | self.out_port = 0 |
| 4319 | if out_group != None: |
| 4320 | self.out_group = out_group |
| 4321 | else: |
| 4322 | self.out_group = 0 |
| 4323 | if flags != None: |
| 4324 | self.flags = flags |
| 4325 | else: |
| 4326 | self.flags = 0 |
| 4327 | if match != None: |
| 4328 | self.match = match |
| 4329 | else: |
| 4330 | self.match = common.match() |
| 4331 | if instructions != None: |
| 4332 | self.instructions = instructions |
| 4333 | else: |
| 4334 | self.instructions = [] |
| 4335 | |
| 4336 | def pack(self): |
| 4337 | packed = [] |
| 4338 | packed.append(struct.pack("!B", self.version)) |
| 4339 | packed.append(struct.pack("!B", self.type)) |
| 4340 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4341 | packed.append(struct.pack("!L", self.xid)) |
| 4342 | packed.append(struct.pack("!Q", self.cookie)) |
| 4343 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4344 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4345 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4346 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4347 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4348 | packed.append(struct.pack("!H", self.priority)) |
| 4349 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4350 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4351 | packed.append(struct.pack("!L", self.out_group)) |
| 4352 | packed.append(struct.pack("!H", self.flags)) |
| 4353 | packed.append('\x00' * 2) |
| 4354 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4355 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4356 | length = sum([len(x) for x in packed]) |
| 4357 | packed[2] = struct.pack("!H", length) |
| 4358 | return ''.join(packed) |
| 4359 | |
| 4360 | @staticmethod |
| 4361 | def unpack(buf): |
| 4362 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4363 | obj = flow_delete() |
| 4364 | if type(buf) == loxi.generic_util.OFReader: |
| 4365 | reader = buf |
| 4366 | else: |
| 4367 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4368 | _version = reader.read("!B")[0] |
| 4369 | assert(_version == 4) |
| 4370 | _type = reader.read("!B")[0] |
| 4371 | assert(_type == 14) |
| 4372 | _length = reader.read("!H")[0] |
| 4373 | obj.xid = reader.read("!L")[0] |
| 4374 | obj.cookie = reader.read("!Q")[0] |
| 4375 | obj.cookie_mask = reader.read("!Q")[0] |
| 4376 | obj.table_id = reader.read("!B")[0] |
| 4377 | __command = util.unpack_fm_cmd(reader) |
| 4378 | assert(__command == 3) |
| 4379 | obj.idle_timeout = reader.read("!H")[0] |
| 4380 | obj.hard_timeout = reader.read("!H")[0] |
| 4381 | obj.priority = reader.read("!H")[0] |
| 4382 | obj.buffer_id = reader.read("!L")[0] |
| 4383 | obj.out_port = util.unpack_port_no(reader) |
| 4384 | obj.out_group = reader.read("!L")[0] |
| 4385 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4386 | reader.skip(2) |
| 4387 | obj.match = common.match.unpack(reader) |
| 4388 | obj.instructions = instruction.unpack_list(reader) |
| 4389 | return obj |
| 4390 | |
| 4391 | def __eq__(self, other): |
| 4392 | if type(self) != type(other): return False |
| 4393 | if self.version != other.version: return False |
| 4394 | if self.type != other.type: return False |
| 4395 | if self.xid != other.xid: return False |
| 4396 | if self.cookie != other.cookie: return False |
| 4397 | if self.cookie_mask != other.cookie_mask: return False |
| 4398 | if self.table_id != other.table_id: return False |
| 4399 | if self.idle_timeout != other.idle_timeout: return False |
| 4400 | if self.hard_timeout != other.hard_timeout: return False |
| 4401 | if self.priority != other.priority: return False |
| 4402 | if self.buffer_id != other.buffer_id: return False |
| 4403 | if self.out_port != other.out_port: return False |
| 4404 | if self.out_group != other.out_group: return False |
| 4405 | if self.flags != other.flags: return False |
| 4406 | if self.match != other.match: return False |
| 4407 | if self.instructions != other.instructions: return False |
| 4408 | return True |
| 4409 | |
| 4410 | def __ne__(self, other): |
| 4411 | return not self.__eq__(other) |
| 4412 | |
| 4413 | def __str__(self): |
| 4414 | return self.show() |
| 4415 | |
| 4416 | def show(self): |
| 4417 | import loxi.pp |
| 4418 | return loxi.pp.pp(self) |
| 4419 | |
| 4420 | def pretty_print(self, q): |
| 4421 | q.text("flow_delete {") |
| 4422 | with q.group(): |
| 4423 | with q.indent(2): |
| 4424 | q.breakable() |
| 4425 | q.text("xid = "); |
| 4426 | if self.xid != None: |
| 4427 | q.text("%#x" % self.xid) |
| 4428 | else: |
| 4429 | q.text('None') |
| 4430 | q.text(","); q.breakable() |
| 4431 | q.text("cookie = "); |
| 4432 | q.text("%#x" % self.cookie) |
| 4433 | q.text(","); q.breakable() |
| 4434 | q.text("cookie_mask = "); |
| 4435 | q.text("%#x" % self.cookie_mask) |
| 4436 | q.text(","); q.breakable() |
| 4437 | q.text("table_id = "); |
| 4438 | q.text("%#x" % self.table_id) |
| 4439 | q.text(","); q.breakable() |
| 4440 | q.text("idle_timeout = "); |
| 4441 | q.text("%#x" % self.idle_timeout) |
| 4442 | q.text(","); q.breakable() |
| 4443 | q.text("hard_timeout = "); |
| 4444 | q.text("%#x" % self.hard_timeout) |
| 4445 | q.text(","); q.breakable() |
| 4446 | q.text("priority = "); |
| 4447 | q.text("%#x" % self.priority) |
| 4448 | q.text(","); q.breakable() |
| 4449 | q.text("buffer_id = "); |
| 4450 | q.text("%#x" % self.buffer_id) |
| 4451 | q.text(","); q.breakable() |
| 4452 | q.text("out_port = "); |
| 4453 | q.text(util.pretty_port(self.out_port)) |
| 4454 | q.text(","); q.breakable() |
| 4455 | q.text("out_group = "); |
| 4456 | q.text("%#x" % self.out_group) |
| 4457 | q.text(","); q.breakable() |
| 4458 | q.text("flags = "); |
| 4459 | q.text("%#x" % self.flags) |
| 4460 | q.text(","); q.breakable() |
| 4461 | q.text("match = "); |
| 4462 | q.pp(self.match) |
| 4463 | q.text(","); q.breakable() |
| 4464 | q.text("instructions = "); |
| 4465 | q.pp(self.instructions) |
| 4466 | q.breakable() |
| 4467 | q.text('}') |
| 4468 | |
| 4469 | class flow_delete_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4470 | version = 4 |
| 4471 | type = 14 |
| 4472 | _command = 4 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4473 | |
| 4474 | 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): |
| 4475 | self.xid = xid |
| 4476 | if cookie != None: |
| 4477 | self.cookie = cookie |
| 4478 | else: |
| 4479 | self.cookie = 0 |
| 4480 | if cookie_mask != None: |
| 4481 | self.cookie_mask = cookie_mask |
| 4482 | else: |
| 4483 | self.cookie_mask = 0 |
| 4484 | if table_id != None: |
| 4485 | self.table_id = table_id |
| 4486 | else: |
| 4487 | self.table_id = 0 |
| 4488 | if idle_timeout != None: |
| 4489 | self.idle_timeout = idle_timeout |
| 4490 | else: |
| 4491 | self.idle_timeout = 0 |
| 4492 | if hard_timeout != None: |
| 4493 | self.hard_timeout = hard_timeout |
| 4494 | else: |
| 4495 | self.hard_timeout = 0 |
| 4496 | if priority != None: |
| 4497 | self.priority = priority |
| 4498 | else: |
| 4499 | self.priority = 0 |
| 4500 | if buffer_id != None: |
| 4501 | self.buffer_id = buffer_id |
| 4502 | else: |
| 4503 | self.buffer_id = 0 |
| 4504 | if out_port != None: |
| 4505 | self.out_port = out_port |
| 4506 | else: |
| 4507 | self.out_port = 0 |
| 4508 | if out_group != None: |
| 4509 | self.out_group = out_group |
| 4510 | else: |
| 4511 | self.out_group = 0 |
| 4512 | if flags != None: |
| 4513 | self.flags = flags |
| 4514 | else: |
| 4515 | self.flags = 0 |
| 4516 | if match != None: |
| 4517 | self.match = match |
| 4518 | else: |
| 4519 | self.match = common.match() |
| 4520 | if instructions != None: |
| 4521 | self.instructions = instructions |
| 4522 | else: |
| 4523 | self.instructions = [] |
| 4524 | |
| 4525 | def pack(self): |
| 4526 | packed = [] |
| 4527 | packed.append(struct.pack("!B", self.version)) |
| 4528 | packed.append(struct.pack("!B", self.type)) |
| 4529 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4530 | packed.append(struct.pack("!L", self.xid)) |
| 4531 | packed.append(struct.pack("!Q", self.cookie)) |
| 4532 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4533 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4534 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4535 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4536 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4537 | packed.append(struct.pack("!H", self.priority)) |
| 4538 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4539 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4540 | packed.append(struct.pack("!L", self.out_group)) |
| 4541 | packed.append(struct.pack("!H", self.flags)) |
| 4542 | packed.append('\x00' * 2) |
| 4543 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4544 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4545 | length = sum([len(x) for x in packed]) |
| 4546 | packed[2] = struct.pack("!H", length) |
| 4547 | return ''.join(packed) |
| 4548 | |
| 4549 | @staticmethod |
| 4550 | def unpack(buf): |
| 4551 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4552 | obj = flow_delete_strict() |
| 4553 | if type(buf) == loxi.generic_util.OFReader: |
| 4554 | reader = buf |
| 4555 | else: |
| 4556 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4557 | _version = reader.read("!B")[0] |
| 4558 | assert(_version == 4) |
| 4559 | _type = reader.read("!B")[0] |
| 4560 | assert(_type == 14) |
| 4561 | _length = reader.read("!H")[0] |
| 4562 | obj.xid = reader.read("!L")[0] |
| 4563 | obj.cookie = reader.read("!Q")[0] |
| 4564 | obj.cookie_mask = reader.read("!Q")[0] |
| 4565 | obj.table_id = reader.read("!B")[0] |
| 4566 | __command = util.unpack_fm_cmd(reader) |
| 4567 | assert(__command == 4) |
| 4568 | obj.idle_timeout = reader.read("!H")[0] |
| 4569 | obj.hard_timeout = reader.read("!H")[0] |
| 4570 | obj.priority = reader.read("!H")[0] |
| 4571 | obj.buffer_id = reader.read("!L")[0] |
| 4572 | obj.out_port = util.unpack_port_no(reader) |
| 4573 | obj.out_group = reader.read("!L")[0] |
| 4574 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4575 | reader.skip(2) |
| 4576 | obj.match = common.match.unpack(reader) |
| 4577 | obj.instructions = instruction.unpack_list(reader) |
| 4578 | return obj |
| 4579 | |
| 4580 | def __eq__(self, other): |
| 4581 | if type(self) != type(other): return False |
| 4582 | if self.version != other.version: return False |
| 4583 | if self.type != other.type: return False |
| 4584 | if self.xid != other.xid: return False |
| 4585 | if self.cookie != other.cookie: return False |
| 4586 | if self.cookie_mask != other.cookie_mask: return False |
| 4587 | if self.table_id != other.table_id: return False |
| 4588 | if self.idle_timeout != other.idle_timeout: return False |
| 4589 | if self.hard_timeout != other.hard_timeout: return False |
| 4590 | if self.priority != other.priority: return False |
| 4591 | if self.buffer_id != other.buffer_id: return False |
| 4592 | if self.out_port != other.out_port: return False |
| 4593 | if self.out_group != other.out_group: return False |
| 4594 | if self.flags != other.flags: return False |
| 4595 | if self.match != other.match: return False |
| 4596 | if self.instructions != other.instructions: return False |
| 4597 | return True |
| 4598 | |
| 4599 | def __ne__(self, other): |
| 4600 | return not self.__eq__(other) |
| 4601 | |
| 4602 | def __str__(self): |
| 4603 | return self.show() |
| 4604 | |
| 4605 | def show(self): |
| 4606 | import loxi.pp |
| 4607 | return loxi.pp.pp(self) |
| 4608 | |
| 4609 | def pretty_print(self, q): |
| 4610 | q.text("flow_delete_strict {") |
| 4611 | with q.group(): |
| 4612 | with q.indent(2): |
| 4613 | q.breakable() |
| 4614 | q.text("xid = "); |
| 4615 | if self.xid != None: |
| 4616 | q.text("%#x" % self.xid) |
| 4617 | else: |
| 4618 | q.text('None') |
| 4619 | q.text(","); q.breakable() |
| 4620 | q.text("cookie = "); |
| 4621 | q.text("%#x" % self.cookie) |
| 4622 | q.text(","); q.breakable() |
| 4623 | q.text("cookie_mask = "); |
| 4624 | q.text("%#x" % self.cookie_mask) |
| 4625 | q.text(","); q.breakable() |
| 4626 | q.text("table_id = "); |
| 4627 | q.text("%#x" % self.table_id) |
| 4628 | q.text(","); q.breakable() |
| 4629 | q.text("idle_timeout = "); |
| 4630 | q.text("%#x" % self.idle_timeout) |
| 4631 | q.text(","); q.breakable() |
| 4632 | q.text("hard_timeout = "); |
| 4633 | q.text("%#x" % self.hard_timeout) |
| 4634 | q.text(","); q.breakable() |
| 4635 | q.text("priority = "); |
| 4636 | q.text("%#x" % self.priority) |
| 4637 | q.text(","); q.breakable() |
| 4638 | q.text("buffer_id = "); |
| 4639 | q.text("%#x" % self.buffer_id) |
| 4640 | q.text(","); q.breakable() |
| 4641 | q.text("out_port = "); |
| 4642 | q.text(util.pretty_port(self.out_port)) |
| 4643 | q.text(","); q.breakable() |
| 4644 | q.text("out_group = "); |
| 4645 | q.text("%#x" % self.out_group) |
| 4646 | q.text(","); q.breakable() |
| 4647 | q.text("flags = "); |
| 4648 | q.text("%#x" % self.flags) |
| 4649 | q.text(","); q.breakable() |
| 4650 | q.text("match = "); |
| 4651 | q.pp(self.match) |
| 4652 | q.text(","); q.breakable() |
| 4653 | q.text("instructions = "); |
| 4654 | q.pp(self.instructions) |
| 4655 | q.breakable() |
| 4656 | q.text('}') |
| 4657 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 4658 | class flow_mod_failed_error_msg(Message): |
| 4659 | version = 4 |
| 4660 | type = 1 |
| 4661 | err_type = 5 |
| 4662 | |
| 4663 | def __init__(self, xid=None, code=None, data=None): |
| 4664 | self.xid = xid |
| 4665 | if code != None: |
| 4666 | self.code = code |
| 4667 | else: |
| 4668 | self.code = 0 |
| 4669 | if data != None: |
| 4670 | self.data = data |
| 4671 | else: |
| 4672 | self.data = '' |
| 4673 | |
| 4674 | def pack(self): |
| 4675 | packed = [] |
| 4676 | packed.append(struct.pack("!B", self.version)) |
| 4677 | packed.append(struct.pack("!B", self.type)) |
| 4678 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4679 | packed.append(struct.pack("!L", self.xid)) |
| 4680 | packed.append(struct.pack("!H", self.err_type)) |
| 4681 | packed.append(struct.pack("!H", self.code)) |
| 4682 | packed.append(self.data) |
| 4683 | length = sum([len(x) for x in packed]) |
| 4684 | packed[2] = struct.pack("!H", length) |
| 4685 | return ''.join(packed) |
| 4686 | |
| 4687 | @staticmethod |
| 4688 | def unpack(buf): |
| 4689 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4690 | obj = flow_mod_failed_error_msg() |
| 4691 | if type(buf) == loxi.generic_util.OFReader: |
| 4692 | reader = buf |
| 4693 | else: |
| 4694 | reader = loxi.generic_util.OFReader(buf) |
| 4695 | _version = reader.read("!B")[0] |
| 4696 | assert(_version == 4) |
| 4697 | _type = reader.read("!B")[0] |
| 4698 | assert(_type == 1) |
| 4699 | _length = reader.read("!H")[0] |
| 4700 | obj.xid = reader.read("!L")[0] |
| 4701 | _err_type = reader.read("!H")[0] |
| 4702 | assert(_err_type == 5) |
| 4703 | obj.code = reader.read("!H")[0] |
| 4704 | obj.data = str(reader.read_all()) |
| 4705 | return obj |
| 4706 | |
| 4707 | def __eq__(self, other): |
| 4708 | if type(self) != type(other): return False |
| 4709 | if self.version != other.version: return False |
| 4710 | if self.type != other.type: return False |
| 4711 | if self.xid != other.xid: return False |
| 4712 | if self.code != other.code: return False |
| 4713 | if self.data != other.data: return False |
| 4714 | return True |
| 4715 | |
| 4716 | def __ne__(self, other): |
| 4717 | return not self.__eq__(other) |
| 4718 | |
| 4719 | def __str__(self): |
| 4720 | return self.show() |
| 4721 | |
| 4722 | def show(self): |
| 4723 | import loxi.pp |
| 4724 | return loxi.pp.pp(self) |
| 4725 | |
| 4726 | def pretty_print(self, q): |
| 4727 | q.text("flow_mod_failed_error_msg {") |
| 4728 | with q.group(): |
| 4729 | with q.indent(2): |
| 4730 | q.breakable() |
| 4731 | q.text("xid = "); |
| 4732 | if self.xid != None: |
| 4733 | q.text("%#x" % self.xid) |
| 4734 | else: |
| 4735 | q.text('None') |
| 4736 | q.text(","); q.breakable() |
| 4737 | q.text("code = "); |
| 4738 | q.text("%#x" % self.code) |
| 4739 | q.text(","); q.breakable() |
| 4740 | q.text("data = "); |
| 4741 | q.pp(self.data) |
| 4742 | q.breakable() |
| 4743 | q.text('}') |
| 4744 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4745 | class flow_modify(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4746 | version = 4 |
| 4747 | type = 14 |
| 4748 | _command = 1 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4749 | |
| 4750 | 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): |
| 4751 | self.xid = xid |
| 4752 | if cookie != None: |
| 4753 | self.cookie = cookie |
| 4754 | else: |
| 4755 | self.cookie = 0 |
| 4756 | if cookie_mask != None: |
| 4757 | self.cookie_mask = cookie_mask |
| 4758 | else: |
| 4759 | self.cookie_mask = 0 |
| 4760 | if table_id != None: |
| 4761 | self.table_id = table_id |
| 4762 | else: |
| 4763 | self.table_id = 0 |
| 4764 | if idle_timeout != None: |
| 4765 | self.idle_timeout = idle_timeout |
| 4766 | else: |
| 4767 | self.idle_timeout = 0 |
| 4768 | if hard_timeout != None: |
| 4769 | self.hard_timeout = hard_timeout |
| 4770 | else: |
| 4771 | self.hard_timeout = 0 |
| 4772 | if priority != None: |
| 4773 | self.priority = priority |
| 4774 | else: |
| 4775 | self.priority = 0 |
| 4776 | if buffer_id != None: |
| 4777 | self.buffer_id = buffer_id |
| 4778 | else: |
| 4779 | self.buffer_id = 0 |
| 4780 | if out_port != None: |
| 4781 | self.out_port = out_port |
| 4782 | else: |
| 4783 | self.out_port = 0 |
| 4784 | if out_group != None: |
| 4785 | self.out_group = out_group |
| 4786 | else: |
| 4787 | self.out_group = 0 |
| 4788 | if flags != None: |
| 4789 | self.flags = flags |
| 4790 | else: |
| 4791 | self.flags = 0 |
| 4792 | if match != None: |
| 4793 | self.match = match |
| 4794 | else: |
| 4795 | self.match = common.match() |
| 4796 | if instructions != None: |
| 4797 | self.instructions = instructions |
| 4798 | else: |
| 4799 | self.instructions = [] |
| 4800 | |
| 4801 | def pack(self): |
| 4802 | packed = [] |
| 4803 | packed.append(struct.pack("!B", self.version)) |
| 4804 | packed.append(struct.pack("!B", self.type)) |
| 4805 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4806 | packed.append(struct.pack("!L", self.xid)) |
| 4807 | packed.append(struct.pack("!Q", self.cookie)) |
| 4808 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4809 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4810 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4811 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 4812 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 4813 | packed.append(struct.pack("!H", self.priority)) |
| 4814 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4815 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4816 | packed.append(struct.pack("!L", self.out_group)) |
| 4817 | packed.append(struct.pack("!H", self.flags)) |
| 4818 | packed.append('\x00' * 2) |
| 4819 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4820 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4821 | length = sum([len(x) for x in packed]) |
| 4822 | packed[2] = struct.pack("!H", length) |
| 4823 | return ''.join(packed) |
| 4824 | |
| 4825 | @staticmethod |
| 4826 | def unpack(buf): |
| 4827 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4828 | obj = flow_modify() |
| 4829 | if type(buf) == loxi.generic_util.OFReader: |
| 4830 | reader = buf |
| 4831 | else: |
| 4832 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4833 | _version = reader.read("!B")[0] |
| 4834 | assert(_version == 4) |
| 4835 | _type = reader.read("!B")[0] |
| 4836 | assert(_type == 14) |
| 4837 | _length = reader.read("!H")[0] |
| 4838 | obj.xid = reader.read("!L")[0] |
| 4839 | obj.cookie = reader.read("!Q")[0] |
| 4840 | obj.cookie_mask = reader.read("!Q")[0] |
| 4841 | obj.table_id = reader.read("!B")[0] |
| 4842 | __command = util.unpack_fm_cmd(reader) |
| 4843 | assert(__command == 1) |
| 4844 | obj.idle_timeout = reader.read("!H")[0] |
| 4845 | obj.hard_timeout = reader.read("!H")[0] |
| 4846 | obj.priority = reader.read("!H")[0] |
| 4847 | obj.buffer_id = reader.read("!L")[0] |
| 4848 | obj.out_port = util.unpack_port_no(reader) |
| 4849 | obj.out_group = reader.read("!L")[0] |
| 4850 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4851 | reader.skip(2) |
| 4852 | obj.match = common.match.unpack(reader) |
| 4853 | obj.instructions = instruction.unpack_list(reader) |
| 4854 | return obj |
| 4855 | |
| 4856 | def __eq__(self, other): |
| 4857 | if type(self) != type(other): return False |
| 4858 | if self.version != other.version: return False |
| 4859 | if self.type != other.type: return False |
| 4860 | if self.xid != other.xid: return False |
| 4861 | if self.cookie != other.cookie: return False |
| 4862 | if self.cookie_mask != other.cookie_mask: return False |
| 4863 | if self.table_id != other.table_id: return False |
| 4864 | if self.idle_timeout != other.idle_timeout: return False |
| 4865 | if self.hard_timeout != other.hard_timeout: return False |
| 4866 | if self.priority != other.priority: return False |
| 4867 | if self.buffer_id != other.buffer_id: return False |
| 4868 | if self.out_port != other.out_port: return False |
| 4869 | if self.out_group != other.out_group: return False |
| 4870 | if self.flags != other.flags: return False |
| 4871 | if self.match != other.match: return False |
| 4872 | if self.instructions != other.instructions: return False |
| 4873 | return True |
| 4874 | |
| 4875 | def __ne__(self, other): |
| 4876 | return not self.__eq__(other) |
| 4877 | |
| 4878 | def __str__(self): |
| 4879 | return self.show() |
| 4880 | |
| 4881 | def show(self): |
| 4882 | import loxi.pp |
| 4883 | return loxi.pp.pp(self) |
| 4884 | |
| 4885 | def pretty_print(self, q): |
| 4886 | q.text("flow_modify {") |
| 4887 | with q.group(): |
| 4888 | with q.indent(2): |
| 4889 | q.breakable() |
| 4890 | q.text("xid = "); |
| 4891 | if self.xid != None: |
| 4892 | q.text("%#x" % self.xid) |
| 4893 | else: |
| 4894 | q.text('None') |
| 4895 | q.text(","); q.breakable() |
| 4896 | q.text("cookie = "); |
| 4897 | q.text("%#x" % self.cookie) |
| 4898 | q.text(","); q.breakable() |
| 4899 | q.text("cookie_mask = "); |
| 4900 | q.text("%#x" % self.cookie_mask) |
| 4901 | q.text(","); q.breakable() |
| 4902 | q.text("table_id = "); |
| 4903 | q.text("%#x" % self.table_id) |
| 4904 | q.text(","); q.breakable() |
| 4905 | q.text("idle_timeout = "); |
| 4906 | q.text("%#x" % self.idle_timeout) |
| 4907 | q.text(","); q.breakable() |
| 4908 | q.text("hard_timeout = "); |
| 4909 | q.text("%#x" % self.hard_timeout) |
| 4910 | q.text(","); q.breakable() |
| 4911 | q.text("priority = "); |
| 4912 | q.text("%#x" % self.priority) |
| 4913 | q.text(","); q.breakable() |
| 4914 | q.text("buffer_id = "); |
| 4915 | q.text("%#x" % self.buffer_id) |
| 4916 | q.text(","); q.breakable() |
| 4917 | q.text("out_port = "); |
| 4918 | q.text(util.pretty_port(self.out_port)) |
| 4919 | q.text(","); q.breakable() |
| 4920 | q.text("out_group = "); |
| 4921 | q.text("%#x" % self.out_group) |
| 4922 | q.text(","); q.breakable() |
| 4923 | q.text("flags = "); |
| 4924 | q.text("%#x" % self.flags) |
| 4925 | q.text(","); q.breakable() |
| 4926 | q.text("match = "); |
| 4927 | q.pp(self.match) |
| 4928 | q.text(","); q.breakable() |
| 4929 | q.text("instructions = "); |
| 4930 | q.pp(self.instructions) |
| 4931 | q.breakable() |
| 4932 | q.text('}') |
| 4933 | |
| 4934 | class flow_modify_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4935 | version = 4 |
| 4936 | type = 14 |
| 4937 | _command = 2 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4938 | |
| 4939 | 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): |
| 4940 | self.xid = xid |
| 4941 | if cookie != None: |
| 4942 | self.cookie = cookie |
| 4943 | else: |
| 4944 | self.cookie = 0 |
| 4945 | if cookie_mask != None: |
| 4946 | self.cookie_mask = cookie_mask |
| 4947 | else: |
| 4948 | self.cookie_mask = 0 |
| 4949 | if table_id != None: |
| 4950 | self.table_id = table_id |
| 4951 | else: |
| 4952 | self.table_id = 0 |
| 4953 | if idle_timeout != None: |
| 4954 | self.idle_timeout = idle_timeout |
| 4955 | else: |
| 4956 | self.idle_timeout = 0 |
| 4957 | if hard_timeout != None: |
| 4958 | self.hard_timeout = hard_timeout |
| 4959 | else: |
| 4960 | self.hard_timeout = 0 |
| 4961 | if priority != None: |
| 4962 | self.priority = priority |
| 4963 | else: |
| 4964 | self.priority = 0 |
| 4965 | if buffer_id != None: |
| 4966 | self.buffer_id = buffer_id |
| 4967 | else: |
| 4968 | self.buffer_id = 0 |
| 4969 | if out_port != None: |
| 4970 | self.out_port = out_port |
| 4971 | else: |
| 4972 | self.out_port = 0 |
| 4973 | if out_group != None: |
| 4974 | self.out_group = out_group |
| 4975 | else: |
| 4976 | self.out_group = 0 |
| 4977 | if flags != None: |
| 4978 | self.flags = flags |
| 4979 | else: |
| 4980 | self.flags = 0 |
| 4981 | if match != None: |
| 4982 | self.match = match |
| 4983 | else: |
| 4984 | self.match = common.match() |
| 4985 | if instructions != None: |
| 4986 | self.instructions = instructions |
| 4987 | else: |
| 4988 | self.instructions = [] |
| 4989 | |
| 4990 | def pack(self): |
| 4991 | packed = [] |
| 4992 | packed.append(struct.pack("!B", self.version)) |
| 4993 | packed.append(struct.pack("!B", self.type)) |
| 4994 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4995 | packed.append(struct.pack("!L", self.xid)) |
| 4996 | packed.append(struct.pack("!Q", self.cookie)) |
| 4997 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 4998 | packed.append(struct.pack("!B", self.table_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4999 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5000 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5001 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5002 | packed.append(struct.pack("!H", self.priority)) |
| 5003 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5004 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5005 | packed.append(struct.pack("!L", self.out_group)) |
| 5006 | packed.append(struct.pack("!H", self.flags)) |
| 5007 | packed.append('\x00' * 2) |
| 5008 | packed.append(self.match.pack()) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5009 | packed.append(util.pack_list(self.instructions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5010 | length = sum([len(x) for x in packed]) |
| 5011 | packed[2] = struct.pack("!H", length) |
| 5012 | return ''.join(packed) |
| 5013 | |
| 5014 | @staticmethod |
| 5015 | def unpack(buf): |
| 5016 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5017 | obj = flow_modify_strict() |
| 5018 | if type(buf) == loxi.generic_util.OFReader: |
| 5019 | reader = buf |
| 5020 | else: |
| 5021 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5022 | _version = reader.read("!B")[0] |
| 5023 | assert(_version == 4) |
| 5024 | _type = reader.read("!B")[0] |
| 5025 | assert(_type == 14) |
| 5026 | _length = reader.read("!H")[0] |
| 5027 | obj.xid = reader.read("!L")[0] |
| 5028 | obj.cookie = reader.read("!Q")[0] |
| 5029 | obj.cookie_mask = reader.read("!Q")[0] |
| 5030 | obj.table_id = reader.read("!B")[0] |
| 5031 | __command = util.unpack_fm_cmd(reader) |
| 5032 | assert(__command == 2) |
| 5033 | obj.idle_timeout = reader.read("!H")[0] |
| 5034 | obj.hard_timeout = reader.read("!H")[0] |
| 5035 | obj.priority = reader.read("!H")[0] |
| 5036 | obj.buffer_id = reader.read("!L")[0] |
| 5037 | obj.out_port = util.unpack_port_no(reader) |
| 5038 | obj.out_group = reader.read("!L")[0] |
| 5039 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5040 | reader.skip(2) |
| 5041 | obj.match = common.match.unpack(reader) |
| 5042 | obj.instructions = instruction.unpack_list(reader) |
| 5043 | return obj |
| 5044 | |
| 5045 | def __eq__(self, other): |
| 5046 | if type(self) != type(other): return False |
| 5047 | if self.version != other.version: return False |
| 5048 | if self.type != other.type: return False |
| 5049 | if self.xid != other.xid: return False |
| 5050 | if self.cookie != other.cookie: return False |
| 5051 | if self.cookie_mask != other.cookie_mask: return False |
| 5052 | if self.table_id != other.table_id: return False |
| 5053 | if self.idle_timeout != other.idle_timeout: return False |
| 5054 | if self.hard_timeout != other.hard_timeout: return False |
| 5055 | if self.priority != other.priority: return False |
| 5056 | if self.buffer_id != other.buffer_id: return False |
| 5057 | if self.out_port != other.out_port: return False |
| 5058 | if self.out_group != other.out_group: return False |
| 5059 | if self.flags != other.flags: return False |
| 5060 | if self.match != other.match: return False |
| 5061 | if self.instructions != other.instructions: return False |
| 5062 | return True |
| 5063 | |
| 5064 | def __ne__(self, other): |
| 5065 | return not self.__eq__(other) |
| 5066 | |
| 5067 | def __str__(self): |
| 5068 | return self.show() |
| 5069 | |
| 5070 | def show(self): |
| 5071 | import loxi.pp |
| 5072 | return loxi.pp.pp(self) |
| 5073 | |
| 5074 | def pretty_print(self, q): |
| 5075 | q.text("flow_modify_strict {") |
| 5076 | with q.group(): |
| 5077 | with q.indent(2): |
| 5078 | q.breakable() |
| 5079 | q.text("xid = "); |
| 5080 | if self.xid != None: |
| 5081 | q.text("%#x" % self.xid) |
| 5082 | else: |
| 5083 | q.text('None') |
| 5084 | q.text(","); q.breakable() |
| 5085 | q.text("cookie = "); |
| 5086 | q.text("%#x" % self.cookie) |
| 5087 | q.text(","); q.breakable() |
| 5088 | q.text("cookie_mask = "); |
| 5089 | q.text("%#x" % self.cookie_mask) |
| 5090 | q.text(","); q.breakable() |
| 5091 | q.text("table_id = "); |
| 5092 | q.text("%#x" % self.table_id) |
| 5093 | q.text(","); q.breakable() |
| 5094 | q.text("idle_timeout = "); |
| 5095 | q.text("%#x" % self.idle_timeout) |
| 5096 | q.text(","); q.breakable() |
| 5097 | q.text("hard_timeout = "); |
| 5098 | q.text("%#x" % self.hard_timeout) |
| 5099 | q.text(","); q.breakable() |
| 5100 | q.text("priority = "); |
| 5101 | q.text("%#x" % self.priority) |
| 5102 | q.text(","); q.breakable() |
| 5103 | q.text("buffer_id = "); |
| 5104 | q.text("%#x" % self.buffer_id) |
| 5105 | q.text(","); q.breakable() |
| 5106 | q.text("out_port = "); |
| 5107 | q.text(util.pretty_port(self.out_port)) |
| 5108 | q.text(","); q.breakable() |
| 5109 | q.text("out_group = "); |
| 5110 | q.text("%#x" % self.out_group) |
| 5111 | q.text(","); q.breakable() |
| 5112 | q.text("flags = "); |
| 5113 | q.text("%#x" % self.flags) |
| 5114 | q.text(","); q.breakable() |
| 5115 | q.text("match = "); |
| 5116 | q.pp(self.match) |
| 5117 | q.text(","); q.breakable() |
| 5118 | q.text("instructions = "); |
| 5119 | q.pp(self.instructions) |
| 5120 | q.breakable() |
| 5121 | q.text('}') |
| 5122 | |
| 5123 | class flow_removed(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5124 | version = 4 |
| 5125 | type = 11 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5126 | |
| 5127 | 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): |
| 5128 | self.xid = xid |
| 5129 | if cookie != None: |
| 5130 | self.cookie = cookie |
| 5131 | else: |
| 5132 | self.cookie = 0 |
| 5133 | if priority != None: |
| 5134 | self.priority = priority |
| 5135 | else: |
| 5136 | self.priority = 0 |
| 5137 | if reason != None: |
| 5138 | self.reason = reason |
| 5139 | else: |
| 5140 | self.reason = 0 |
| 5141 | if table_id != None: |
| 5142 | self.table_id = table_id |
| 5143 | else: |
| 5144 | self.table_id = 0 |
| 5145 | if duration_sec != None: |
| 5146 | self.duration_sec = duration_sec |
| 5147 | else: |
| 5148 | self.duration_sec = 0 |
| 5149 | if duration_nsec != None: |
| 5150 | self.duration_nsec = duration_nsec |
| 5151 | else: |
| 5152 | self.duration_nsec = 0 |
| 5153 | if idle_timeout != None: |
| 5154 | self.idle_timeout = idle_timeout |
| 5155 | else: |
| 5156 | self.idle_timeout = 0 |
| 5157 | if hard_timeout != None: |
| 5158 | self.hard_timeout = hard_timeout |
| 5159 | else: |
| 5160 | self.hard_timeout = 0 |
| 5161 | if packet_count != None: |
| 5162 | self.packet_count = packet_count |
| 5163 | else: |
| 5164 | self.packet_count = 0 |
| 5165 | if byte_count != None: |
| 5166 | self.byte_count = byte_count |
| 5167 | else: |
| 5168 | self.byte_count = 0 |
| 5169 | if match != None: |
| 5170 | self.match = match |
| 5171 | else: |
| 5172 | self.match = common.match() |
| 5173 | |
| 5174 | def pack(self): |
| 5175 | packed = [] |
| 5176 | packed.append(struct.pack("!B", self.version)) |
| 5177 | packed.append(struct.pack("!B", self.type)) |
| 5178 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5179 | packed.append(struct.pack("!L", self.xid)) |
| 5180 | packed.append(struct.pack("!Q", self.cookie)) |
| 5181 | packed.append(struct.pack("!H", self.priority)) |
| 5182 | packed.append(struct.pack("!B", self.reason)) |
| 5183 | packed.append(struct.pack("!B", self.table_id)) |
| 5184 | packed.append(struct.pack("!L", self.duration_sec)) |
| 5185 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 5186 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 5187 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 5188 | packed.append(struct.pack("!Q", self.packet_count)) |
| 5189 | packed.append(struct.pack("!Q", self.byte_count)) |
| 5190 | packed.append(self.match.pack()) |
| 5191 | length = sum([len(x) for x in packed]) |
| 5192 | packed[2] = struct.pack("!H", length) |
| 5193 | return ''.join(packed) |
| 5194 | |
| 5195 | @staticmethod |
| 5196 | def unpack(buf): |
| 5197 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5198 | obj = flow_removed() |
| 5199 | if type(buf) == loxi.generic_util.OFReader: |
| 5200 | reader = buf |
| 5201 | else: |
| 5202 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5203 | _version = reader.read("!B")[0] |
| 5204 | assert(_version == 4) |
| 5205 | _type = reader.read("!B")[0] |
| 5206 | assert(_type == 11) |
| 5207 | _length = reader.read("!H")[0] |
| 5208 | obj.xid = reader.read("!L")[0] |
| 5209 | obj.cookie = reader.read("!Q")[0] |
| 5210 | obj.priority = reader.read("!H")[0] |
| 5211 | obj.reason = reader.read("!B")[0] |
| 5212 | obj.table_id = reader.read("!B")[0] |
| 5213 | obj.duration_sec = reader.read("!L")[0] |
| 5214 | obj.duration_nsec = reader.read("!L")[0] |
| 5215 | obj.idle_timeout = reader.read("!H")[0] |
| 5216 | obj.hard_timeout = reader.read("!H")[0] |
| 5217 | obj.packet_count = reader.read("!Q")[0] |
| 5218 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5219 | obj.match = common.match.unpack(reader) |
| 5220 | return obj |
| 5221 | |
| 5222 | def __eq__(self, other): |
| 5223 | if type(self) != type(other): return False |
| 5224 | if self.version != other.version: return False |
| 5225 | if self.type != other.type: return False |
| 5226 | if self.xid != other.xid: return False |
| 5227 | if self.cookie != other.cookie: return False |
| 5228 | if self.priority != other.priority: return False |
| 5229 | if self.reason != other.reason: return False |
| 5230 | if self.table_id != other.table_id: return False |
| 5231 | if self.duration_sec != other.duration_sec: return False |
| 5232 | if self.duration_nsec != other.duration_nsec: return False |
| 5233 | if self.idle_timeout != other.idle_timeout: return False |
| 5234 | if self.hard_timeout != other.hard_timeout: return False |
| 5235 | if self.packet_count != other.packet_count: return False |
| 5236 | if self.byte_count != other.byte_count: return False |
| 5237 | if self.match != other.match: return False |
| 5238 | return True |
| 5239 | |
| 5240 | def __ne__(self, other): |
| 5241 | return not self.__eq__(other) |
| 5242 | |
| 5243 | def __str__(self): |
| 5244 | return self.show() |
| 5245 | |
| 5246 | def show(self): |
| 5247 | import loxi.pp |
| 5248 | return loxi.pp.pp(self) |
| 5249 | |
| 5250 | def pretty_print(self, q): |
| 5251 | q.text("flow_removed {") |
| 5252 | with q.group(): |
| 5253 | with q.indent(2): |
| 5254 | q.breakable() |
| 5255 | q.text("xid = "); |
| 5256 | if self.xid != None: |
| 5257 | q.text("%#x" % self.xid) |
| 5258 | else: |
| 5259 | q.text('None') |
| 5260 | q.text(","); q.breakable() |
| 5261 | q.text("cookie = "); |
| 5262 | q.text("%#x" % self.cookie) |
| 5263 | q.text(","); q.breakable() |
| 5264 | q.text("priority = "); |
| 5265 | q.text("%#x" % self.priority) |
| 5266 | q.text(","); q.breakable() |
| 5267 | q.text("reason = "); |
| 5268 | q.text("%#x" % self.reason) |
| 5269 | q.text(","); q.breakable() |
| 5270 | q.text("table_id = "); |
| 5271 | q.text("%#x" % self.table_id) |
| 5272 | q.text(","); q.breakable() |
| 5273 | q.text("duration_sec = "); |
| 5274 | q.text("%#x" % self.duration_sec) |
| 5275 | q.text(","); q.breakable() |
| 5276 | q.text("duration_nsec = "); |
| 5277 | q.text("%#x" % self.duration_nsec) |
| 5278 | q.text(","); q.breakable() |
| 5279 | q.text("idle_timeout = "); |
| 5280 | q.text("%#x" % self.idle_timeout) |
| 5281 | q.text(","); q.breakable() |
| 5282 | q.text("hard_timeout = "); |
| 5283 | q.text("%#x" % self.hard_timeout) |
| 5284 | q.text(","); q.breakable() |
| 5285 | q.text("packet_count = "); |
| 5286 | q.text("%#x" % self.packet_count) |
| 5287 | q.text(","); q.breakable() |
| 5288 | q.text("byte_count = "); |
| 5289 | q.text("%#x" % self.byte_count) |
| 5290 | q.text(","); q.breakable() |
| 5291 | q.text("match = "); |
| 5292 | q.pp(self.match) |
| 5293 | q.breakable() |
| 5294 | q.text('}') |
| 5295 | |
| 5296 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5297 | version = 4 |
| 5298 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5299 | stats_type = 1 |
| 5300 | |
| 5301 | def __init__(self, xid=None, flags=None, entries=None): |
| 5302 | self.xid = xid |
| 5303 | if flags != None: |
| 5304 | self.flags = flags |
| 5305 | else: |
| 5306 | self.flags = 0 |
| 5307 | if entries != None: |
| 5308 | self.entries = entries |
| 5309 | else: |
| 5310 | self.entries = [] |
| 5311 | |
| 5312 | def pack(self): |
| 5313 | packed = [] |
| 5314 | packed.append(struct.pack("!B", self.version)) |
| 5315 | packed.append(struct.pack("!B", self.type)) |
| 5316 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5317 | packed.append(struct.pack("!L", self.xid)) |
| 5318 | packed.append(struct.pack("!H", self.stats_type)) |
| 5319 | packed.append(struct.pack("!H", self.flags)) |
| 5320 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5321 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5322 | length = sum([len(x) for x in packed]) |
| 5323 | packed[2] = struct.pack("!H", length) |
| 5324 | return ''.join(packed) |
| 5325 | |
| 5326 | @staticmethod |
| 5327 | def unpack(buf): |
| 5328 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5329 | obj = flow_stats_reply() |
| 5330 | if type(buf) == loxi.generic_util.OFReader: |
| 5331 | reader = buf |
| 5332 | else: |
| 5333 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5334 | _version = reader.read("!B")[0] |
| 5335 | assert(_version == 4) |
| 5336 | _type = reader.read("!B")[0] |
| 5337 | assert(_type == 19) |
| 5338 | _length = reader.read("!H")[0] |
| 5339 | obj.xid = reader.read("!L")[0] |
| 5340 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5341 | assert(_stats_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5342 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5343 | reader.skip(4) |
| 5344 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
| 5345 | return obj |
| 5346 | |
| 5347 | def __eq__(self, other): |
| 5348 | if type(self) != type(other): return False |
| 5349 | if self.version != other.version: return False |
| 5350 | if self.type != other.type: return False |
| 5351 | if self.xid != other.xid: return False |
| 5352 | if self.flags != other.flags: return False |
| 5353 | if self.entries != other.entries: return False |
| 5354 | return True |
| 5355 | |
| 5356 | def __ne__(self, other): |
| 5357 | return not self.__eq__(other) |
| 5358 | |
| 5359 | def __str__(self): |
| 5360 | return self.show() |
| 5361 | |
| 5362 | def show(self): |
| 5363 | import loxi.pp |
| 5364 | return loxi.pp.pp(self) |
| 5365 | |
| 5366 | def pretty_print(self, q): |
| 5367 | q.text("flow_stats_reply {") |
| 5368 | with q.group(): |
| 5369 | with q.indent(2): |
| 5370 | q.breakable() |
| 5371 | q.text("xid = "); |
| 5372 | if self.xid != None: |
| 5373 | q.text("%#x" % self.xid) |
| 5374 | else: |
| 5375 | q.text('None') |
| 5376 | q.text(","); q.breakable() |
| 5377 | q.text("flags = "); |
| 5378 | q.text("%#x" % self.flags) |
| 5379 | q.text(","); q.breakable() |
| 5380 | q.text("entries = "); |
| 5381 | q.pp(self.entries) |
| 5382 | q.breakable() |
| 5383 | q.text('}') |
| 5384 | |
| 5385 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5386 | version = 4 |
| 5387 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5388 | stats_type = 1 |
| 5389 | |
| 5390 | def __init__(self, xid=None, flags=None, table_id=None, out_port=None, out_group=None, cookie=None, cookie_mask=None, match=None): |
| 5391 | self.xid = xid |
| 5392 | if flags != None: |
| 5393 | self.flags = flags |
| 5394 | else: |
| 5395 | self.flags = 0 |
| 5396 | if table_id != None: |
| 5397 | self.table_id = table_id |
| 5398 | else: |
| 5399 | self.table_id = 0 |
| 5400 | if out_port != None: |
| 5401 | self.out_port = out_port |
| 5402 | else: |
| 5403 | self.out_port = 0 |
| 5404 | if out_group != None: |
| 5405 | self.out_group = out_group |
| 5406 | else: |
| 5407 | self.out_group = 0 |
| 5408 | if cookie != None: |
| 5409 | self.cookie = cookie |
| 5410 | else: |
| 5411 | self.cookie = 0 |
| 5412 | if cookie_mask != None: |
| 5413 | self.cookie_mask = cookie_mask |
| 5414 | else: |
| 5415 | self.cookie_mask = 0 |
| 5416 | if match != None: |
| 5417 | self.match = match |
| 5418 | else: |
| 5419 | self.match = common.match() |
| 5420 | |
| 5421 | def pack(self): |
| 5422 | packed = [] |
| 5423 | packed.append(struct.pack("!B", self.version)) |
| 5424 | packed.append(struct.pack("!B", self.type)) |
| 5425 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5426 | packed.append(struct.pack("!L", self.xid)) |
| 5427 | packed.append(struct.pack("!H", self.stats_type)) |
| 5428 | packed.append(struct.pack("!H", self.flags)) |
| 5429 | packed.append('\x00' * 4) |
| 5430 | packed.append(struct.pack("!B", self.table_id)) |
| 5431 | packed.append('\x00' * 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5432 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5433 | packed.append(struct.pack("!L", self.out_group)) |
| 5434 | packed.append('\x00' * 4) |
| 5435 | packed.append(struct.pack("!Q", self.cookie)) |
| 5436 | packed.append(struct.pack("!Q", self.cookie_mask)) |
| 5437 | packed.append(self.match.pack()) |
| 5438 | length = sum([len(x) for x in packed]) |
| 5439 | packed[2] = struct.pack("!H", length) |
| 5440 | return ''.join(packed) |
| 5441 | |
| 5442 | @staticmethod |
| 5443 | def unpack(buf): |
| 5444 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5445 | obj = flow_stats_request() |
| 5446 | if type(buf) == loxi.generic_util.OFReader: |
| 5447 | reader = buf |
| 5448 | else: |
| 5449 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5450 | _version = reader.read("!B")[0] |
| 5451 | assert(_version == 4) |
| 5452 | _type = reader.read("!B")[0] |
| 5453 | assert(_type == 18) |
| 5454 | _length = reader.read("!H")[0] |
| 5455 | obj.xid = reader.read("!L")[0] |
| 5456 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5457 | assert(_stats_type == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5458 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5459 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5460 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5461 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5462 | obj.out_port = util.unpack_port_no(reader) |
| 5463 | obj.out_group = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5464 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5465 | obj.cookie = reader.read("!Q")[0] |
| 5466 | obj.cookie_mask = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5467 | obj.match = common.match.unpack(reader) |
| 5468 | return obj |
| 5469 | |
| 5470 | def __eq__(self, other): |
| 5471 | if type(self) != type(other): return False |
| 5472 | if self.version != other.version: return False |
| 5473 | if self.type != other.type: return False |
| 5474 | if self.xid != other.xid: return False |
| 5475 | if self.flags != other.flags: return False |
| 5476 | if self.table_id != other.table_id: return False |
| 5477 | if self.out_port != other.out_port: return False |
| 5478 | if self.out_group != other.out_group: return False |
| 5479 | if self.cookie != other.cookie: return False |
| 5480 | if self.cookie_mask != other.cookie_mask: return False |
| 5481 | if self.match != other.match: return False |
| 5482 | return True |
| 5483 | |
| 5484 | def __ne__(self, other): |
| 5485 | return not self.__eq__(other) |
| 5486 | |
| 5487 | def __str__(self): |
| 5488 | return self.show() |
| 5489 | |
| 5490 | def show(self): |
| 5491 | import loxi.pp |
| 5492 | return loxi.pp.pp(self) |
| 5493 | |
| 5494 | def pretty_print(self, q): |
| 5495 | q.text("flow_stats_request {") |
| 5496 | with q.group(): |
| 5497 | with q.indent(2): |
| 5498 | q.breakable() |
| 5499 | q.text("xid = "); |
| 5500 | if self.xid != None: |
| 5501 | q.text("%#x" % self.xid) |
| 5502 | else: |
| 5503 | q.text('None') |
| 5504 | q.text(","); q.breakable() |
| 5505 | q.text("flags = "); |
| 5506 | q.text("%#x" % self.flags) |
| 5507 | q.text(","); q.breakable() |
| 5508 | q.text("table_id = "); |
| 5509 | q.text("%#x" % self.table_id) |
| 5510 | q.text(","); q.breakable() |
| 5511 | q.text("out_port = "); |
| 5512 | q.text(util.pretty_port(self.out_port)) |
| 5513 | q.text(","); q.breakable() |
| 5514 | q.text("out_group = "); |
| 5515 | q.text("%#x" % self.out_group) |
| 5516 | q.text(","); q.breakable() |
| 5517 | q.text("cookie = "); |
| 5518 | q.text("%#x" % self.cookie) |
| 5519 | q.text(","); q.breakable() |
| 5520 | q.text("cookie_mask = "); |
| 5521 | q.text("%#x" % self.cookie_mask) |
| 5522 | q.text(","); q.breakable() |
| 5523 | q.text("match = "); |
| 5524 | q.pp(self.match) |
| 5525 | q.breakable() |
| 5526 | q.text('}') |
| 5527 | |
| 5528 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5529 | version = 4 |
| 5530 | type = 8 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5531 | |
| 5532 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 5533 | self.xid = xid |
| 5534 | if flags != None: |
| 5535 | self.flags = flags |
| 5536 | else: |
| 5537 | self.flags = 0 |
| 5538 | if miss_send_len != None: |
| 5539 | self.miss_send_len = miss_send_len |
| 5540 | else: |
| 5541 | self.miss_send_len = 0 |
| 5542 | |
| 5543 | def pack(self): |
| 5544 | packed = [] |
| 5545 | packed.append(struct.pack("!B", self.version)) |
| 5546 | packed.append(struct.pack("!B", self.type)) |
| 5547 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5548 | packed.append(struct.pack("!L", self.xid)) |
| 5549 | packed.append(struct.pack("!H", self.flags)) |
| 5550 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5551 | length = sum([len(x) for x in packed]) |
| 5552 | packed[2] = struct.pack("!H", length) |
| 5553 | return ''.join(packed) |
| 5554 | |
| 5555 | @staticmethod |
| 5556 | def unpack(buf): |
| 5557 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5558 | obj = get_config_reply() |
| 5559 | if type(buf) == loxi.generic_util.OFReader: |
| 5560 | reader = buf |
| 5561 | else: |
| 5562 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5563 | _version = reader.read("!B")[0] |
| 5564 | assert(_version == 4) |
| 5565 | _type = reader.read("!B")[0] |
| 5566 | assert(_type == 8) |
| 5567 | _length = reader.read("!H")[0] |
| 5568 | obj.xid = reader.read("!L")[0] |
| 5569 | obj.flags = reader.read("!H")[0] |
| 5570 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5571 | return obj |
| 5572 | |
| 5573 | def __eq__(self, other): |
| 5574 | if type(self) != type(other): return False |
| 5575 | if self.version != other.version: return False |
| 5576 | if self.type != other.type: return False |
| 5577 | if self.xid != other.xid: return False |
| 5578 | if self.flags != other.flags: return False |
| 5579 | if self.miss_send_len != other.miss_send_len: return False |
| 5580 | return True |
| 5581 | |
| 5582 | def __ne__(self, other): |
| 5583 | return not self.__eq__(other) |
| 5584 | |
| 5585 | def __str__(self): |
| 5586 | return self.show() |
| 5587 | |
| 5588 | def show(self): |
| 5589 | import loxi.pp |
| 5590 | return loxi.pp.pp(self) |
| 5591 | |
| 5592 | def pretty_print(self, q): |
| 5593 | q.text("get_config_reply {") |
| 5594 | with q.group(): |
| 5595 | with q.indent(2): |
| 5596 | q.breakable() |
| 5597 | q.text("xid = "); |
| 5598 | if self.xid != None: |
| 5599 | q.text("%#x" % self.xid) |
| 5600 | else: |
| 5601 | q.text('None') |
| 5602 | q.text(","); q.breakable() |
| 5603 | q.text("flags = "); |
| 5604 | q.text("%#x" % self.flags) |
| 5605 | q.text(","); q.breakable() |
| 5606 | q.text("miss_send_len = "); |
| 5607 | q.text("%#x" % self.miss_send_len) |
| 5608 | q.breakable() |
| 5609 | q.text('}') |
| 5610 | |
| 5611 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5612 | version = 4 |
| 5613 | type = 7 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5614 | |
| 5615 | def __init__(self, xid=None): |
| 5616 | self.xid = xid |
| 5617 | |
| 5618 | def pack(self): |
| 5619 | packed = [] |
| 5620 | packed.append(struct.pack("!B", self.version)) |
| 5621 | packed.append(struct.pack("!B", self.type)) |
| 5622 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5623 | packed.append(struct.pack("!L", self.xid)) |
| 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 = get_config_request() |
| 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 == 7) |
| 5640 | _length = reader.read("!H")[0] |
| 5641 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5642 | return obj |
| 5643 | |
| 5644 | def __eq__(self, other): |
| 5645 | if type(self) != type(other): return False |
| 5646 | if self.version != other.version: return False |
| 5647 | if self.type != other.type: return False |
| 5648 | if self.xid != other.xid: return False |
| 5649 | return True |
| 5650 | |
| 5651 | def __ne__(self, other): |
| 5652 | return not self.__eq__(other) |
| 5653 | |
| 5654 | def __str__(self): |
| 5655 | return self.show() |
| 5656 | |
| 5657 | def show(self): |
| 5658 | import loxi.pp |
| 5659 | return loxi.pp.pp(self) |
| 5660 | |
| 5661 | def pretty_print(self, q): |
| 5662 | q.text("get_config_request {") |
| 5663 | with q.group(): |
| 5664 | with q.indent(2): |
| 5665 | q.breakable() |
| 5666 | q.text("xid = "); |
| 5667 | if self.xid != None: |
| 5668 | q.text("%#x" % self.xid) |
| 5669 | else: |
| 5670 | q.text('None') |
| 5671 | q.breakable() |
| 5672 | q.text('}') |
| 5673 | |
| 5674 | class group_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5675 | version = 4 |
| 5676 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5677 | stats_type = 7 |
| 5678 | |
| 5679 | def __init__(self, xid=None, flags=None, entries=None): |
| 5680 | self.xid = xid |
| 5681 | if flags != None: |
| 5682 | self.flags = flags |
| 5683 | else: |
| 5684 | self.flags = 0 |
| 5685 | if entries != None: |
| 5686 | self.entries = entries |
| 5687 | else: |
| 5688 | self.entries = [] |
| 5689 | |
| 5690 | def pack(self): |
| 5691 | packed = [] |
| 5692 | packed.append(struct.pack("!B", self.version)) |
| 5693 | packed.append(struct.pack("!B", self.type)) |
| 5694 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5695 | packed.append(struct.pack("!L", self.xid)) |
| 5696 | packed.append(struct.pack("!H", self.stats_type)) |
| 5697 | packed.append(struct.pack("!H", self.flags)) |
| 5698 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5699 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5700 | length = sum([len(x) for x in packed]) |
| 5701 | packed[2] = struct.pack("!H", length) |
| 5702 | return ''.join(packed) |
| 5703 | |
| 5704 | @staticmethod |
| 5705 | def unpack(buf): |
| 5706 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5707 | obj = group_desc_stats_reply() |
| 5708 | if type(buf) == loxi.generic_util.OFReader: |
| 5709 | reader = buf |
| 5710 | else: |
| 5711 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5712 | _version = reader.read("!B")[0] |
| 5713 | assert(_version == 4) |
| 5714 | _type = reader.read("!B")[0] |
| 5715 | assert(_type == 19) |
| 5716 | _length = reader.read("!H")[0] |
| 5717 | obj.xid = reader.read("!L")[0] |
| 5718 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5719 | assert(_stats_type == 7) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5720 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5721 | reader.skip(4) |
| 5722 | obj.entries = common.unpack_list_group_desc_stats_entry(reader) |
| 5723 | return obj |
| 5724 | |
| 5725 | def __eq__(self, other): |
| 5726 | if type(self) != type(other): return False |
| 5727 | if self.version != other.version: return False |
| 5728 | if self.type != other.type: return False |
| 5729 | if self.xid != other.xid: return False |
| 5730 | if self.flags != other.flags: return False |
| 5731 | if self.entries != other.entries: return False |
| 5732 | return True |
| 5733 | |
| 5734 | def __ne__(self, other): |
| 5735 | return not self.__eq__(other) |
| 5736 | |
| 5737 | def __str__(self): |
| 5738 | return self.show() |
| 5739 | |
| 5740 | def show(self): |
| 5741 | import loxi.pp |
| 5742 | return loxi.pp.pp(self) |
| 5743 | |
| 5744 | def pretty_print(self, q): |
| 5745 | q.text("group_desc_stats_reply {") |
| 5746 | with q.group(): |
| 5747 | with q.indent(2): |
| 5748 | q.breakable() |
| 5749 | q.text("xid = "); |
| 5750 | if self.xid != None: |
| 5751 | q.text("%#x" % self.xid) |
| 5752 | else: |
| 5753 | q.text('None') |
| 5754 | q.text(","); q.breakable() |
| 5755 | q.text("flags = "); |
| 5756 | q.text("%#x" % self.flags) |
| 5757 | q.text(","); q.breakable() |
| 5758 | q.text("entries = "); |
| 5759 | q.pp(self.entries) |
| 5760 | q.breakable() |
| 5761 | q.text('}') |
| 5762 | |
| 5763 | class group_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5764 | version = 4 |
| 5765 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5766 | stats_type = 7 |
| 5767 | |
| 5768 | def __init__(self, xid=None, flags=None): |
| 5769 | self.xid = xid |
| 5770 | if flags != None: |
| 5771 | self.flags = flags |
| 5772 | else: |
| 5773 | self.flags = 0 |
| 5774 | |
| 5775 | def pack(self): |
| 5776 | packed = [] |
| 5777 | packed.append(struct.pack("!B", self.version)) |
| 5778 | packed.append(struct.pack("!B", self.type)) |
| 5779 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5780 | packed.append(struct.pack("!L", self.xid)) |
| 5781 | packed.append(struct.pack("!H", self.stats_type)) |
| 5782 | packed.append(struct.pack("!H", self.flags)) |
| 5783 | packed.append('\x00' * 4) |
| 5784 | length = sum([len(x) for x in packed]) |
| 5785 | packed[2] = struct.pack("!H", length) |
| 5786 | return ''.join(packed) |
| 5787 | |
| 5788 | @staticmethod |
| 5789 | def unpack(buf): |
| 5790 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5791 | obj = group_desc_stats_request() |
| 5792 | if type(buf) == loxi.generic_util.OFReader: |
| 5793 | reader = buf |
| 5794 | else: |
| 5795 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5796 | _version = reader.read("!B")[0] |
| 5797 | assert(_version == 4) |
| 5798 | _type = reader.read("!B")[0] |
| 5799 | assert(_type == 18) |
| 5800 | _length = reader.read("!H")[0] |
| 5801 | obj.xid = reader.read("!L")[0] |
| 5802 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5803 | assert(_stats_type == 7) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5804 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5805 | reader.skip(4) |
| 5806 | return obj |
| 5807 | |
| 5808 | def __eq__(self, other): |
| 5809 | if type(self) != type(other): return False |
| 5810 | if self.version != other.version: return False |
| 5811 | if self.type != other.type: return False |
| 5812 | if self.xid != other.xid: return False |
| 5813 | if self.flags != other.flags: return False |
| 5814 | return True |
| 5815 | |
| 5816 | def __ne__(self, other): |
| 5817 | return not self.__eq__(other) |
| 5818 | |
| 5819 | def __str__(self): |
| 5820 | return self.show() |
| 5821 | |
| 5822 | def show(self): |
| 5823 | import loxi.pp |
| 5824 | return loxi.pp.pp(self) |
| 5825 | |
| 5826 | def pretty_print(self, q): |
| 5827 | q.text("group_desc_stats_request {") |
| 5828 | with q.group(): |
| 5829 | with q.indent(2): |
| 5830 | q.breakable() |
| 5831 | q.text("xid = "); |
| 5832 | if self.xid != None: |
| 5833 | q.text("%#x" % self.xid) |
| 5834 | else: |
| 5835 | q.text('None') |
| 5836 | q.text(","); q.breakable() |
| 5837 | q.text("flags = "); |
| 5838 | q.text("%#x" % self.flags) |
| 5839 | q.breakable() |
| 5840 | q.text('}') |
| 5841 | |
| 5842 | class group_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5843 | version = 4 |
| 5844 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5845 | stats_type = 8 |
| 5846 | |
| 5847 | 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): |
| 5848 | self.xid = xid |
| 5849 | if flags != None: |
| 5850 | self.flags = flags |
| 5851 | else: |
| 5852 | self.flags = 0 |
| 5853 | if types != None: |
| 5854 | self.types = types |
| 5855 | else: |
| 5856 | self.types = 0 |
| 5857 | if capabilities != None: |
| 5858 | self.capabilities = capabilities |
| 5859 | else: |
| 5860 | self.capabilities = 0 |
| 5861 | if max_groups_all != None: |
| 5862 | self.max_groups_all = max_groups_all |
| 5863 | else: |
| 5864 | self.max_groups_all = 0 |
| 5865 | if max_groups_select != None: |
| 5866 | self.max_groups_select = max_groups_select |
| 5867 | else: |
| 5868 | self.max_groups_select = 0 |
| 5869 | if max_groups_indirect != None: |
| 5870 | self.max_groups_indirect = max_groups_indirect |
| 5871 | else: |
| 5872 | self.max_groups_indirect = 0 |
| 5873 | if max_groups_ff != None: |
| 5874 | self.max_groups_ff = max_groups_ff |
| 5875 | else: |
| 5876 | self.max_groups_ff = 0 |
| 5877 | if actions_all != None: |
| 5878 | self.actions_all = actions_all |
| 5879 | else: |
| 5880 | self.actions_all = 0 |
| 5881 | if actions_select != None: |
| 5882 | self.actions_select = actions_select |
| 5883 | else: |
| 5884 | self.actions_select = 0 |
| 5885 | if actions_indirect != None: |
| 5886 | self.actions_indirect = actions_indirect |
| 5887 | else: |
| 5888 | self.actions_indirect = 0 |
| 5889 | if actions_ff != None: |
| 5890 | self.actions_ff = actions_ff |
| 5891 | else: |
| 5892 | self.actions_ff = 0 |
| 5893 | |
| 5894 | def pack(self): |
| 5895 | packed = [] |
| 5896 | packed.append(struct.pack("!B", self.version)) |
| 5897 | packed.append(struct.pack("!B", self.type)) |
| 5898 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5899 | packed.append(struct.pack("!L", self.xid)) |
| 5900 | packed.append(struct.pack("!H", self.stats_type)) |
| 5901 | packed.append(struct.pack("!H", self.flags)) |
| 5902 | packed.append('\x00' * 4) |
| 5903 | packed.append(struct.pack("!L", self.types)) |
| 5904 | packed.append(struct.pack("!L", self.capabilities)) |
| 5905 | packed.append(struct.pack("!L", self.max_groups_all)) |
| 5906 | packed.append(struct.pack("!L", self.max_groups_select)) |
| 5907 | packed.append(struct.pack("!L", self.max_groups_indirect)) |
| 5908 | packed.append(struct.pack("!L", self.max_groups_ff)) |
| 5909 | packed.append(struct.pack("!L", self.actions_all)) |
| 5910 | packed.append(struct.pack("!L", self.actions_select)) |
| 5911 | packed.append(struct.pack("!L", self.actions_indirect)) |
| 5912 | packed.append(struct.pack("!L", self.actions_ff)) |
| 5913 | length = sum([len(x) for x in packed]) |
| 5914 | packed[2] = struct.pack("!H", length) |
| 5915 | return ''.join(packed) |
| 5916 | |
| 5917 | @staticmethod |
| 5918 | def unpack(buf): |
| 5919 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5920 | obj = group_features_stats_reply() |
| 5921 | if type(buf) == loxi.generic_util.OFReader: |
| 5922 | reader = buf |
| 5923 | else: |
| 5924 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5925 | _version = reader.read("!B")[0] |
| 5926 | assert(_version == 4) |
| 5927 | _type = reader.read("!B")[0] |
| 5928 | assert(_type == 19) |
| 5929 | _length = reader.read("!H")[0] |
| 5930 | obj.xid = reader.read("!L")[0] |
| 5931 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5932 | assert(_stats_type == 8) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5933 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5934 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5935 | obj.types = reader.read("!L")[0] |
| 5936 | obj.capabilities = reader.read("!L")[0] |
| 5937 | obj.max_groups_all = reader.read("!L")[0] |
| 5938 | obj.max_groups_select = reader.read("!L")[0] |
| 5939 | obj.max_groups_indirect = reader.read("!L")[0] |
| 5940 | obj.max_groups_ff = reader.read("!L")[0] |
| 5941 | obj.actions_all = reader.read("!L")[0] |
| 5942 | obj.actions_select = reader.read("!L")[0] |
| 5943 | obj.actions_indirect = reader.read("!L")[0] |
| 5944 | obj.actions_ff = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5945 | return obj |
| 5946 | |
| 5947 | def __eq__(self, other): |
| 5948 | if type(self) != type(other): return False |
| 5949 | if self.version != other.version: return False |
| 5950 | if self.type != other.type: return False |
| 5951 | if self.xid != other.xid: return False |
| 5952 | if self.flags != other.flags: return False |
| 5953 | if self.types != other.types: return False |
| 5954 | if self.capabilities != other.capabilities: return False |
| 5955 | if self.max_groups_all != other.max_groups_all: return False |
| 5956 | if self.max_groups_select != other.max_groups_select: return False |
| 5957 | if self.max_groups_indirect != other.max_groups_indirect: return False |
| 5958 | if self.max_groups_ff != other.max_groups_ff: return False |
| 5959 | if self.actions_all != other.actions_all: return False |
| 5960 | if self.actions_select != other.actions_select: return False |
| 5961 | if self.actions_indirect != other.actions_indirect: return False |
| 5962 | if self.actions_ff != other.actions_ff: return False |
| 5963 | return True |
| 5964 | |
| 5965 | def __ne__(self, other): |
| 5966 | return not self.__eq__(other) |
| 5967 | |
| 5968 | def __str__(self): |
| 5969 | return self.show() |
| 5970 | |
| 5971 | def show(self): |
| 5972 | import loxi.pp |
| 5973 | return loxi.pp.pp(self) |
| 5974 | |
| 5975 | def pretty_print(self, q): |
| 5976 | q.text("group_features_stats_reply {") |
| 5977 | with q.group(): |
| 5978 | with q.indent(2): |
| 5979 | q.breakable() |
| 5980 | q.text("xid = "); |
| 5981 | if self.xid != None: |
| 5982 | q.text("%#x" % self.xid) |
| 5983 | else: |
| 5984 | q.text('None') |
| 5985 | q.text(","); q.breakable() |
| 5986 | q.text("flags = "); |
| 5987 | q.text("%#x" % self.flags) |
| 5988 | q.text(","); q.breakable() |
| 5989 | q.text("types = "); |
| 5990 | q.text("%#x" % self.types) |
| 5991 | q.text(","); q.breakable() |
| 5992 | q.text("capabilities = "); |
| 5993 | q.text("%#x" % self.capabilities) |
| 5994 | q.text(","); q.breakable() |
| 5995 | q.text("max_groups_all = "); |
| 5996 | q.text("%#x" % self.max_groups_all) |
| 5997 | q.text(","); q.breakable() |
| 5998 | q.text("max_groups_select = "); |
| 5999 | q.text("%#x" % self.max_groups_select) |
| 6000 | q.text(","); q.breakable() |
| 6001 | q.text("max_groups_indirect = "); |
| 6002 | q.text("%#x" % self.max_groups_indirect) |
| 6003 | q.text(","); q.breakable() |
| 6004 | q.text("max_groups_ff = "); |
| 6005 | q.text("%#x" % self.max_groups_ff) |
| 6006 | q.text(","); q.breakable() |
| 6007 | q.text("actions_all = "); |
| 6008 | q.text("%#x" % self.actions_all) |
| 6009 | q.text(","); q.breakable() |
| 6010 | q.text("actions_select = "); |
| 6011 | q.text("%#x" % self.actions_select) |
| 6012 | q.text(","); q.breakable() |
| 6013 | q.text("actions_indirect = "); |
| 6014 | q.text("%#x" % self.actions_indirect) |
| 6015 | q.text(","); q.breakable() |
| 6016 | q.text("actions_ff = "); |
| 6017 | q.text("%#x" % self.actions_ff) |
| 6018 | q.breakable() |
| 6019 | q.text('}') |
| 6020 | |
| 6021 | class group_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6022 | version = 4 |
| 6023 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6024 | stats_type = 8 |
| 6025 | |
| 6026 | def __init__(self, xid=None, flags=None): |
| 6027 | self.xid = xid |
| 6028 | if flags != None: |
| 6029 | self.flags = flags |
| 6030 | else: |
| 6031 | self.flags = 0 |
| 6032 | |
| 6033 | def pack(self): |
| 6034 | packed = [] |
| 6035 | packed.append(struct.pack("!B", self.version)) |
| 6036 | packed.append(struct.pack("!B", self.type)) |
| 6037 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6038 | packed.append(struct.pack("!L", self.xid)) |
| 6039 | packed.append(struct.pack("!H", self.stats_type)) |
| 6040 | packed.append(struct.pack("!H", self.flags)) |
| 6041 | packed.append('\x00' * 4) |
| 6042 | length = sum([len(x) for x in packed]) |
| 6043 | packed[2] = struct.pack("!H", length) |
| 6044 | return ''.join(packed) |
| 6045 | |
| 6046 | @staticmethod |
| 6047 | def unpack(buf): |
| 6048 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6049 | obj = group_features_stats_request() |
| 6050 | if type(buf) == loxi.generic_util.OFReader: |
| 6051 | reader = buf |
| 6052 | else: |
| 6053 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6054 | _version = reader.read("!B")[0] |
| 6055 | assert(_version == 4) |
| 6056 | _type = reader.read("!B")[0] |
| 6057 | assert(_type == 18) |
| 6058 | _length = reader.read("!H")[0] |
| 6059 | obj.xid = reader.read("!L")[0] |
| 6060 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6061 | assert(_stats_type == 8) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6062 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6063 | reader.skip(4) |
| 6064 | return obj |
| 6065 | |
| 6066 | def __eq__(self, other): |
| 6067 | if type(self) != type(other): return False |
| 6068 | if self.version != other.version: return False |
| 6069 | if self.type != other.type: return False |
| 6070 | if self.xid != other.xid: return False |
| 6071 | if self.flags != other.flags: return False |
| 6072 | return True |
| 6073 | |
| 6074 | def __ne__(self, other): |
| 6075 | return not self.__eq__(other) |
| 6076 | |
| 6077 | def __str__(self): |
| 6078 | return self.show() |
| 6079 | |
| 6080 | def show(self): |
| 6081 | import loxi.pp |
| 6082 | return loxi.pp.pp(self) |
| 6083 | |
| 6084 | def pretty_print(self, q): |
| 6085 | q.text("group_features_stats_request {") |
| 6086 | with q.group(): |
| 6087 | with q.indent(2): |
| 6088 | q.breakable() |
| 6089 | q.text("xid = "); |
| 6090 | if self.xid != None: |
| 6091 | q.text("%#x" % self.xid) |
| 6092 | else: |
| 6093 | q.text('None') |
| 6094 | q.text(","); q.breakable() |
| 6095 | q.text("flags = "); |
| 6096 | q.text("%#x" % self.flags) |
| 6097 | q.breakable() |
| 6098 | q.text('}') |
| 6099 | |
| 6100 | class group_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6101 | version = 4 |
| 6102 | type = 15 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6103 | |
| 6104 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, buckets=None): |
| 6105 | self.xid = xid |
| 6106 | if command != None: |
| 6107 | self.command = command |
| 6108 | else: |
| 6109 | self.command = 0 |
| 6110 | if group_type != None: |
| 6111 | self.group_type = group_type |
| 6112 | else: |
| 6113 | self.group_type = 0 |
| 6114 | if group_id != None: |
| 6115 | self.group_id = group_id |
| 6116 | else: |
| 6117 | self.group_id = 0 |
| 6118 | if buckets != None: |
| 6119 | self.buckets = buckets |
| 6120 | else: |
| 6121 | self.buckets = [] |
| 6122 | |
| 6123 | def pack(self): |
| 6124 | packed = [] |
| 6125 | packed.append(struct.pack("!B", self.version)) |
| 6126 | packed.append(struct.pack("!B", self.type)) |
| 6127 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6128 | packed.append(struct.pack("!L", self.xid)) |
| 6129 | packed.append(struct.pack("!H", self.command)) |
| 6130 | packed.append(struct.pack("!B", self.group_type)) |
| 6131 | packed.append('\x00' * 1) |
| 6132 | packed.append(struct.pack("!L", self.group_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6133 | packed.append(util.pack_list(self.buckets)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6134 | length = sum([len(x) for x in packed]) |
| 6135 | packed[2] = struct.pack("!H", length) |
| 6136 | return ''.join(packed) |
| 6137 | |
| 6138 | @staticmethod |
| 6139 | def unpack(buf): |
| 6140 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6141 | obj = group_mod() |
| 6142 | if type(buf) == loxi.generic_util.OFReader: |
| 6143 | reader = buf |
| 6144 | else: |
| 6145 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6146 | _version = reader.read("!B")[0] |
| 6147 | assert(_version == 4) |
| 6148 | _type = reader.read("!B")[0] |
| 6149 | assert(_type == 15) |
| 6150 | _length = reader.read("!H")[0] |
| 6151 | obj.xid = reader.read("!L")[0] |
| 6152 | obj.command = reader.read("!H")[0] |
| 6153 | obj.group_type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6154 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6155 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6156 | obj.buckets = common.unpack_list_bucket(reader) |
| 6157 | return obj |
| 6158 | |
| 6159 | def __eq__(self, other): |
| 6160 | if type(self) != type(other): return False |
| 6161 | if self.version != other.version: return False |
| 6162 | if self.type != other.type: return False |
| 6163 | if self.xid != other.xid: return False |
| 6164 | if self.command != other.command: return False |
| 6165 | if self.group_type != other.group_type: return False |
| 6166 | if self.group_id != other.group_id: return False |
| 6167 | if self.buckets != other.buckets: return False |
| 6168 | return True |
| 6169 | |
| 6170 | def __ne__(self, other): |
| 6171 | return not self.__eq__(other) |
| 6172 | |
| 6173 | def __str__(self): |
| 6174 | return self.show() |
| 6175 | |
| 6176 | def show(self): |
| 6177 | import loxi.pp |
| 6178 | return loxi.pp.pp(self) |
| 6179 | |
| 6180 | def pretty_print(self, q): |
| 6181 | q.text("group_mod {") |
| 6182 | with q.group(): |
| 6183 | with q.indent(2): |
| 6184 | q.breakable() |
| 6185 | q.text("xid = "); |
| 6186 | if self.xid != None: |
| 6187 | q.text("%#x" % self.xid) |
| 6188 | else: |
| 6189 | q.text('None') |
| 6190 | q.text(","); q.breakable() |
| 6191 | q.text("command = "); |
| 6192 | q.text("%#x" % self.command) |
| 6193 | q.text(","); q.breakable() |
| 6194 | q.text("group_type = "); |
| 6195 | q.text("%#x" % self.group_type) |
| 6196 | q.text(","); q.breakable() |
| 6197 | q.text("group_id = "); |
| 6198 | q.text("%#x" % self.group_id) |
| 6199 | q.text(","); q.breakable() |
| 6200 | q.text("buckets = "); |
| 6201 | q.pp(self.buckets) |
| 6202 | q.breakable() |
| 6203 | q.text('}') |
| 6204 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6205 | class group_mod_failed_error_msg(Message): |
| 6206 | version = 4 |
| 6207 | type = 1 |
| 6208 | err_type = 6 |
| 6209 | |
| 6210 | def __init__(self, xid=None, code=None, data=None): |
| 6211 | self.xid = xid |
| 6212 | if code != None: |
| 6213 | self.code = code |
| 6214 | else: |
| 6215 | self.code = 0 |
| 6216 | if data != None: |
| 6217 | self.data = data |
| 6218 | else: |
| 6219 | self.data = '' |
| 6220 | |
| 6221 | def pack(self): |
| 6222 | packed = [] |
| 6223 | packed.append(struct.pack("!B", self.version)) |
| 6224 | packed.append(struct.pack("!B", self.type)) |
| 6225 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6226 | packed.append(struct.pack("!L", self.xid)) |
| 6227 | packed.append(struct.pack("!H", self.err_type)) |
| 6228 | packed.append(struct.pack("!H", self.code)) |
| 6229 | packed.append(self.data) |
| 6230 | length = sum([len(x) for x in packed]) |
| 6231 | packed[2] = struct.pack("!H", length) |
| 6232 | return ''.join(packed) |
| 6233 | |
| 6234 | @staticmethod |
| 6235 | def unpack(buf): |
| 6236 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6237 | obj = group_mod_failed_error_msg() |
| 6238 | if type(buf) == loxi.generic_util.OFReader: |
| 6239 | reader = buf |
| 6240 | else: |
| 6241 | reader = loxi.generic_util.OFReader(buf) |
| 6242 | _version = reader.read("!B")[0] |
| 6243 | assert(_version == 4) |
| 6244 | _type = reader.read("!B")[0] |
| 6245 | assert(_type == 1) |
| 6246 | _length = reader.read("!H")[0] |
| 6247 | obj.xid = reader.read("!L")[0] |
| 6248 | _err_type = reader.read("!H")[0] |
| 6249 | assert(_err_type == 6) |
| 6250 | obj.code = reader.read("!H")[0] |
| 6251 | obj.data = str(reader.read_all()) |
| 6252 | return obj |
| 6253 | |
| 6254 | def __eq__(self, other): |
| 6255 | if type(self) != type(other): return False |
| 6256 | if self.version != other.version: return False |
| 6257 | if self.type != other.type: return False |
| 6258 | if self.xid != other.xid: return False |
| 6259 | if self.code != other.code: return False |
| 6260 | if self.data != other.data: return False |
| 6261 | return True |
| 6262 | |
| 6263 | def __ne__(self, other): |
| 6264 | return not self.__eq__(other) |
| 6265 | |
| 6266 | def __str__(self): |
| 6267 | return self.show() |
| 6268 | |
| 6269 | def show(self): |
| 6270 | import loxi.pp |
| 6271 | return loxi.pp.pp(self) |
| 6272 | |
| 6273 | def pretty_print(self, q): |
| 6274 | q.text("group_mod_failed_error_msg {") |
| 6275 | with q.group(): |
| 6276 | with q.indent(2): |
| 6277 | q.breakable() |
| 6278 | q.text("xid = "); |
| 6279 | if self.xid != None: |
| 6280 | q.text("%#x" % self.xid) |
| 6281 | else: |
| 6282 | q.text('None') |
| 6283 | q.text(","); q.breakable() |
| 6284 | q.text("code = "); |
| 6285 | q.text("%#x" % self.code) |
| 6286 | q.text(","); q.breakable() |
| 6287 | q.text("data = "); |
| 6288 | q.pp(self.data) |
| 6289 | q.breakable() |
| 6290 | q.text('}') |
| 6291 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6292 | class group_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6293 | version = 4 |
| 6294 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6295 | stats_type = 6 |
| 6296 | |
| 6297 | def __init__(self, xid=None, flags=None, entries=None): |
| 6298 | self.xid = xid |
| 6299 | if flags != None: |
| 6300 | self.flags = flags |
| 6301 | else: |
| 6302 | self.flags = 0 |
| 6303 | if entries != None: |
| 6304 | self.entries = entries |
| 6305 | else: |
| 6306 | self.entries = [] |
| 6307 | |
| 6308 | def pack(self): |
| 6309 | packed = [] |
| 6310 | packed.append(struct.pack("!B", self.version)) |
| 6311 | packed.append(struct.pack("!B", self.type)) |
| 6312 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6313 | packed.append(struct.pack("!L", self.xid)) |
| 6314 | packed.append(struct.pack("!H", self.stats_type)) |
| 6315 | packed.append(struct.pack("!H", self.flags)) |
| 6316 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6317 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6318 | length = sum([len(x) for x in packed]) |
| 6319 | packed[2] = struct.pack("!H", length) |
| 6320 | return ''.join(packed) |
| 6321 | |
| 6322 | @staticmethod |
| 6323 | def unpack(buf): |
| 6324 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6325 | obj = group_stats_reply() |
| 6326 | if type(buf) == loxi.generic_util.OFReader: |
| 6327 | reader = buf |
| 6328 | else: |
| 6329 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6330 | _version = reader.read("!B")[0] |
| 6331 | assert(_version == 4) |
| 6332 | _type = reader.read("!B")[0] |
| 6333 | assert(_type == 19) |
| 6334 | _length = reader.read("!H")[0] |
| 6335 | obj.xid = reader.read("!L")[0] |
| 6336 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6337 | assert(_stats_type == 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6338 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6339 | reader.skip(4) |
| 6340 | obj.entries = common.unpack_list_group_stats_entry(reader) |
| 6341 | return obj |
| 6342 | |
| 6343 | def __eq__(self, other): |
| 6344 | if type(self) != type(other): return False |
| 6345 | if self.version != other.version: return False |
| 6346 | if self.type != other.type: return False |
| 6347 | if self.xid != other.xid: return False |
| 6348 | if self.flags != other.flags: return False |
| 6349 | if self.entries != other.entries: return False |
| 6350 | return True |
| 6351 | |
| 6352 | def __ne__(self, other): |
| 6353 | return not self.__eq__(other) |
| 6354 | |
| 6355 | def __str__(self): |
| 6356 | return self.show() |
| 6357 | |
| 6358 | def show(self): |
| 6359 | import loxi.pp |
| 6360 | return loxi.pp.pp(self) |
| 6361 | |
| 6362 | def pretty_print(self, q): |
| 6363 | q.text("group_stats_reply {") |
| 6364 | with q.group(): |
| 6365 | with q.indent(2): |
| 6366 | q.breakable() |
| 6367 | q.text("xid = "); |
| 6368 | if self.xid != None: |
| 6369 | q.text("%#x" % self.xid) |
| 6370 | else: |
| 6371 | q.text('None') |
| 6372 | q.text(","); q.breakable() |
| 6373 | q.text("flags = "); |
| 6374 | q.text("%#x" % self.flags) |
| 6375 | q.text(","); q.breakable() |
| 6376 | q.text("entries = "); |
| 6377 | q.pp(self.entries) |
| 6378 | q.breakable() |
| 6379 | q.text('}') |
| 6380 | |
| 6381 | class group_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6382 | version = 4 |
| 6383 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6384 | stats_type = 6 |
| 6385 | |
| 6386 | def __init__(self, xid=None, flags=None, group_id=None): |
| 6387 | self.xid = xid |
| 6388 | if flags != None: |
| 6389 | self.flags = flags |
| 6390 | else: |
| 6391 | self.flags = 0 |
| 6392 | if group_id != None: |
| 6393 | self.group_id = group_id |
| 6394 | else: |
| 6395 | self.group_id = 0 |
| 6396 | |
| 6397 | def pack(self): |
| 6398 | packed = [] |
| 6399 | packed.append(struct.pack("!B", self.version)) |
| 6400 | packed.append(struct.pack("!B", self.type)) |
| 6401 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6402 | packed.append(struct.pack("!L", self.xid)) |
| 6403 | packed.append(struct.pack("!H", self.stats_type)) |
| 6404 | packed.append(struct.pack("!H", self.flags)) |
| 6405 | packed.append('\x00' * 4) |
| 6406 | packed.append(struct.pack("!L", self.group_id)) |
| 6407 | packed.append('\x00' * 4) |
| 6408 | length = sum([len(x) for x in packed]) |
| 6409 | packed[2] = struct.pack("!H", length) |
| 6410 | return ''.join(packed) |
| 6411 | |
| 6412 | @staticmethod |
| 6413 | def unpack(buf): |
| 6414 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6415 | obj = group_stats_request() |
| 6416 | if type(buf) == loxi.generic_util.OFReader: |
| 6417 | reader = buf |
| 6418 | else: |
| 6419 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6420 | _version = reader.read("!B")[0] |
| 6421 | assert(_version == 4) |
| 6422 | _type = reader.read("!B")[0] |
| 6423 | assert(_type == 18) |
| 6424 | _length = reader.read("!H")[0] |
| 6425 | obj.xid = reader.read("!L")[0] |
| 6426 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6427 | assert(_stats_type == 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6428 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6429 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6430 | obj.group_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6431 | reader.skip(4) |
| 6432 | return obj |
| 6433 | |
| 6434 | def __eq__(self, other): |
| 6435 | if type(self) != type(other): return False |
| 6436 | if self.version != other.version: return False |
| 6437 | if self.type != other.type: return False |
| 6438 | if self.xid != other.xid: return False |
| 6439 | if self.flags != other.flags: return False |
| 6440 | if self.group_id != other.group_id: return False |
| 6441 | return True |
| 6442 | |
| 6443 | def __ne__(self, other): |
| 6444 | return not self.__eq__(other) |
| 6445 | |
| 6446 | def __str__(self): |
| 6447 | return self.show() |
| 6448 | |
| 6449 | def show(self): |
| 6450 | import loxi.pp |
| 6451 | return loxi.pp.pp(self) |
| 6452 | |
| 6453 | def pretty_print(self, q): |
| 6454 | q.text("group_stats_request {") |
| 6455 | with q.group(): |
| 6456 | with q.indent(2): |
| 6457 | q.breakable() |
| 6458 | q.text("xid = "); |
| 6459 | if self.xid != None: |
| 6460 | q.text("%#x" % self.xid) |
| 6461 | else: |
| 6462 | q.text('None') |
| 6463 | q.text(","); q.breakable() |
| 6464 | q.text("flags = "); |
| 6465 | q.text("%#x" % self.flags) |
| 6466 | q.text(","); q.breakable() |
| 6467 | q.text("group_id = "); |
| 6468 | q.text("%#x" % self.group_id) |
| 6469 | q.breakable() |
| 6470 | q.text('}') |
| 6471 | |
| 6472 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6473 | version = 4 |
| 6474 | type = 0 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6475 | |
| 6476 | def __init__(self, xid=None, elements=None): |
| 6477 | self.xid = xid |
| 6478 | if elements != None: |
| 6479 | self.elements = elements |
| 6480 | else: |
| 6481 | self.elements = [] |
| 6482 | |
| 6483 | def pack(self): |
| 6484 | packed = [] |
| 6485 | packed.append(struct.pack("!B", self.version)) |
| 6486 | packed.append(struct.pack("!B", self.type)) |
| 6487 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6488 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6489 | packed.append(util.pack_list(self.elements)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6490 | length = sum([len(x) for x in packed]) |
| 6491 | packed[2] = struct.pack("!H", length) |
| 6492 | return ''.join(packed) |
| 6493 | |
| 6494 | @staticmethod |
| 6495 | def unpack(buf): |
| 6496 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6497 | obj = hello() |
| 6498 | if type(buf) == loxi.generic_util.OFReader: |
| 6499 | reader = buf |
| 6500 | else: |
| 6501 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6502 | _version = reader.read("!B")[0] |
| 6503 | assert(_version == 4) |
| 6504 | _type = reader.read("!B")[0] |
| 6505 | assert(_type == 0) |
| 6506 | _length = reader.read("!H")[0] |
| 6507 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6508 | obj.elements = common.unpack_list_hello_elem(reader) |
| 6509 | return obj |
| 6510 | |
| 6511 | def __eq__(self, other): |
| 6512 | if type(self) != type(other): return False |
| 6513 | if self.version != other.version: return False |
| 6514 | if self.type != other.type: return False |
| 6515 | if self.xid != other.xid: return False |
| 6516 | if self.elements != other.elements: return False |
| 6517 | return True |
| 6518 | |
| 6519 | def __ne__(self, other): |
| 6520 | return not self.__eq__(other) |
| 6521 | |
| 6522 | def __str__(self): |
| 6523 | return self.show() |
| 6524 | |
| 6525 | def show(self): |
| 6526 | import loxi.pp |
| 6527 | return loxi.pp.pp(self) |
| 6528 | |
| 6529 | def pretty_print(self, q): |
| 6530 | q.text("hello {") |
| 6531 | with q.group(): |
| 6532 | with q.indent(2): |
| 6533 | q.breakable() |
| 6534 | q.text("xid = "); |
| 6535 | if self.xid != None: |
| 6536 | q.text("%#x" % self.xid) |
| 6537 | else: |
| 6538 | q.text('None') |
| 6539 | q.text(","); q.breakable() |
| 6540 | q.text("elements = "); |
| 6541 | q.pp(self.elements) |
| 6542 | q.breakable() |
| 6543 | q.text('}') |
| 6544 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 6545 | class hello_failed_error_msg(Message): |
| 6546 | version = 4 |
| 6547 | type = 1 |
| 6548 | err_type = 0 |
| 6549 | |
| 6550 | def __init__(self, xid=None, code=None, data=None): |
| 6551 | self.xid = xid |
| 6552 | if code != None: |
| 6553 | self.code = code |
| 6554 | else: |
| 6555 | self.code = 0 |
| 6556 | if data != None: |
| 6557 | self.data = data |
| 6558 | else: |
| 6559 | self.data = '' |
| 6560 | |
| 6561 | def pack(self): |
| 6562 | packed = [] |
| 6563 | packed.append(struct.pack("!B", self.version)) |
| 6564 | packed.append(struct.pack("!B", self.type)) |
| 6565 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6566 | packed.append(struct.pack("!L", self.xid)) |
| 6567 | packed.append(struct.pack("!H", self.err_type)) |
| 6568 | packed.append(struct.pack("!H", self.code)) |
| 6569 | packed.append(self.data) |
| 6570 | length = sum([len(x) for x in packed]) |
| 6571 | packed[2] = struct.pack("!H", length) |
| 6572 | return ''.join(packed) |
| 6573 | |
| 6574 | @staticmethod |
| 6575 | def unpack(buf): |
| 6576 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6577 | obj = hello_failed_error_msg() |
| 6578 | if type(buf) == loxi.generic_util.OFReader: |
| 6579 | reader = buf |
| 6580 | else: |
| 6581 | reader = loxi.generic_util.OFReader(buf) |
| 6582 | _version = reader.read("!B")[0] |
| 6583 | assert(_version == 4) |
| 6584 | _type = reader.read("!B")[0] |
| 6585 | assert(_type == 1) |
| 6586 | _length = reader.read("!H")[0] |
| 6587 | obj.xid = reader.read("!L")[0] |
| 6588 | _err_type = reader.read("!H")[0] |
| 6589 | assert(_err_type == 0) |
| 6590 | obj.code = reader.read("!H")[0] |
| 6591 | obj.data = str(reader.read_all()) |
| 6592 | return obj |
| 6593 | |
| 6594 | def __eq__(self, other): |
| 6595 | if type(self) != type(other): return False |
| 6596 | if self.version != other.version: return False |
| 6597 | if self.type != other.type: return False |
| 6598 | if self.xid != other.xid: return False |
| 6599 | if self.code != other.code: return False |
| 6600 | if self.data != other.data: return False |
| 6601 | return True |
| 6602 | |
| 6603 | def __ne__(self, other): |
| 6604 | return not self.__eq__(other) |
| 6605 | |
| 6606 | def __str__(self): |
| 6607 | return self.show() |
| 6608 | |
| 6609 | def show(self): |
| 6610 | import loxi.pp |
| 6611 | return loxi.pp.pp(self) |
| 6612 | |
| 6613 | def pretty_print(self, q): |
| 6614 | q.text("hello_failed_error_msg {") |
| 6615 | with q.group(): |
| 6616 | with q.indent(2): |
| 6617 | q.breakable() |
| 6618 | q.text("xid = "); |
| 6619 | if self.xid != None: |
| 6620 | q.text("%#x" % self.xid) |
| 6621 | else: |
| 6622 | q.text('None') |
| 6623 | q.text(","); q.breakable() |
| 6624 | q.text("code = "); |
| 6625 | q.text("%#x" % self.code) |
| 6626 | q.text(","); q.breakable() |
| 6627 | q.text("data = "); |
| 6628 | q.pp(self.data) |
| 6629 | q.breakable() |
| 6630 | q.text('}') |
| 6631 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6632 | class meter_config_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6633 | version = 4 |
| 6634 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6635 | stats_type = 10 |
| 6636 | |
| 6637 | def __init__(self, xid=None, flags=None, entries=None): |
| 6638 | self.xid = xid |
| 6639 | if flags != None: |
| 6640 | self.flags = flags |
| 6641 | else: |
| 6642 | self.flags = 0 |
| 6643 | if entries != None: |
| 6644 | self.entries = entries |
| 6645 | else: |
| 6646 | self.entries = [] |
| 6647 | |
| 6648 | def pack(self): |
| 6649 | packed = [] |
| 6650 | packed.append(struct.pack("!B", self.version)) |
| 6651 | packed.append(struct.pack("!B", self.type)) |
| 6652 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6653 | packed.append(struct.pack("!L", self.xid)) |
| 6654 | packed.append(struct.pack("!H", self.stats_type)) |
| 6655 | packed.append(struct.pack("!H", self.flags)) |
| 6656 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6657 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6658 | length = sum([len(x) for x in packed]) |
| 6659 | packed[2] = struct.pack("!H", length) |
| 6660 | return ''.join(packed) |
| 6661 | |
| 6662 | @staticmethod |
| 6663 | def unpack(buf): |
| 6664 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6665 | obj = meter_config_stats_reply() |
| 6666 | if type(buf) == loxi.generic_util.OFReader: |
| 6667 | reader = buf |
| 6668 | else: |
| 6669 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6670 | _version = reader.read("!B")[0] |
| 6671 | assert(_version == 4) |
| 6672 | _type = reader.read("!B")[0] |
| 6673 | assert(_type == 19) |
| 6674 | _length = reader.read("!H")[0] |
| 6675 | obj.xid = reader.read("!L")[0] |
| 6676 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6677 | assert(_stats_type == 10) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6678 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6679 | reader.skip(4) |
| 6680 | obj.entries = meter_band.unpack_list(reader) |
| 6681 | return obj |
| 6682 | |
| 6683 | def __eq__(self, other): |
| 6684 | if type(self) != type(other): return False |
| 6685 | if self.version != other.version: return False |
| 6686 | if self.type != other.type: return False |
| 6687 | if self.xid != other.xid: return False |
| 6688 | if self.flags != other.flags: return False |
| 6689 | if self.entries != other.entries: return False |
| 6690 | return True |
| 6691 | |
| 6692 | def __ne__(self, other): |
| 6693 | return not self.__eq__(other) |
| 6694 | |
| 6695 | def __str__(self): |
| 6696 | return self.show() |
| 6697 | |
| 6698 | def show(self): |
| 6699 | import loxi.pp |
| 6700 | return loxi.pp.pp(self) |
| 6701 | |
| 6702 | def pretty_print(self, q): |
| 6703 | q.text("meter_config_stats_reply {") |
| 6704 | with q.group(): |
| 6705 | with q.indent(2): |
| 6706 | q.breakable() |
| 6707 | q.text("xid = "); |
| 6708 | if self.xid != None: |
| 6709 | q.text("%#x" % self.xid) |
| 6710 | else: |
| 6711 | q.text('None') |
| 6712 | q.text(","); q.breakable() |
| 6713 | q.text("flags = "); |
| 6714 | q.text("%#x" % self.flags) |
| 6715 | q.text(","); q.breakable() |
| 6716 | q.text("entries = "); |
| 6717 | q.pp(self.entries) |
| 6718 | q.breakable() |
| 6719 | q.text('}') |
| 6720 | |
| 6721 | class meter_config_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6722 | version = 4 |
| 6723 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6724 | stats_type = 10 |
| 6725 | |
| 6726 | def __init__(self, xid=None, flags=None, meter_id=None): |
| 6727 | self.xid = xid |
| 6728 | if flags != None: |
| 6729 | self.flags = flags |
| 6730 | else: |
| 6731 | self.flags = 0 |
| 6732 | if meter_id != None: |
| 6733 | self.meter_id = meter_id |
| 6734 | else: |
| 6735 | self.meter_id = 0 |
| 6736 | |
| 6737 | def pack(self): |
| 6738 | packed = [] |
| 6739 | packed.append(struct.pack("!B", self.version)) |
| 6740 | packed.append(struct.pack("!B", self.type)) |
| 6741 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6742 | packed.append(struct.pack("!L", self.xid)) |
| 6743 | packed.append(struct.pack("!H", self.stats_type)) |
| 6744 | packed.append(struct.pack("!H", self.flags)) |
| 6745 | packed.append('\x00' * 4) |
| 6746 | packed.append(struct.pack("!L", self.meter_id)) |
| 6747 | packed.append('\x00' * 4) |
| 6748 | length = sum([len(x) for x in packed]) |
| 6749 | packed[2] = struct.pack("!H", length) |
| 6750 | return ''.join(packed) |
| 6751 | |
| 6752 | @staticmethod |
| 6753 | def unpack(buf): |
| 6754 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6755 | obj = meter_config_stats_request() |
| 6756 | if type(buf) == loxi.generic_util.OFReader: |
| 6757 | reader = buf |
| 6758 | else: |
| 6759 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6760 | _version = reader.read("!B")[0] |
| 6761 | assert(_version == 4) |
| 6762 | _type = reader.read("!B")[0] |
| 6763 | assert(_type == 18) |
| 6764 | _length = reader.read("!H")[0] |
| 6765 | obj.xid = reader.read("!L")[0] |
| 6766 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6767 | assert(_stats_type == 10) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6768 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6769 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6770 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6771 | reader.skip(4) |
| 6772 | return obj |
| 6773 | |
| 6774 | def __eq__(self, other): |
| 6775 | if type(self) != type(other): return False |
| 6776 | if self.version != other.version: return False |
| 6777 | if self.type != other.type: return False |
| 6778 | if self.xid != other.xid: return False |
| 6779 | if self.flags != other.flags: return False |
| 6780 | if self.meter_id != other.meter_id: return False |
| 6781 | return True |
| 6782 | |
| 6783 | def __ne__(self, other): |
| 6784 | return not self.__eq__(other) |
| 6785 | |
| 6786 | def __str__(self): |
| 6787 | return self.show() |
| 6788 | |
| 6789 | def show(self): |
| 6790 | import loxi.pp |
| 6791 | return loxi.pp.pp(self) |
| 6792 | |
| 6793 | def pretty_print(self, q): |
| 6794 | q.text("meter_config_stats_request {") |
| 6795 | with q.group(): |
| 6796 | with q.indent(2): |
| 6797 | q.breakable() |
| 6798 | q.text("xid = "); |
| 6799 | if self.xid != None: |
| 6800 | q.text("%#x" % self.xid) |
| 6801 | else: |
| 6802 | q.text('None') |
| 6803 | q.text(","); q.breakable() |
| 6804 | q.text("flags = "); |
| 6805 | q.text("%#x" % self.flags) |
| 6806 | q.text(","); q.breakable() |
| 6807 | q.text("meter_id = "); |
| 6808 | q.text("%#x" % self.meter_id) |
| 6809 | q.breakable() |
| 6810 | q.text('}') |
| 6811 | |
| 6812 | class meter_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6813 | version = 4 |
| 6814 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6815 | stats_type = 11 |
| 6816 | |
| 6817 | def __init__(self, xid=None, flags=None, features=None): |
| 6818 | self.xid = xid |
| 6819 | if flags != None: |
| 6820 | self.flags = flags |
| 6821 | else: |
| 6822 | self.flags = 0 |
| 6823 | if features != None: |
| 6824 | self.features = features |
| 6825 | else: |
| 6826 | self.features = common.meter_features() |
| 6827 | |
| 6828 | def pack(self): |
| 6829 | packed = [] |
| 6830 | packed.append(struct.pack("!B", self.version)) |
| 6831 | packed.append(struct.pack("!B", self.type)) |
| 6832 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6833 | packed.append(struct.pack("!L", self.xid)) |
| 6834 | packed.append(struct.pack("!H", self.stats_type)) |
| 6835 | packed.append(struct.pack("!H", self.flags)) |
| 6836 | packed.append('\x00' * 4) |
| 6837 | packed.append(self.features.pack()) |
| 6838 | length = sum([len(x) for x in packed]) |
| 6839 | packed[2] = struct.pack("!H", length) |
| 6840 | return ''.join(packed) |
| 6841 | |
| 6842 | @staticmethod |
| 6843 | def unpack(buf): |
| 6844 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6845 | obj = meter_features_stats_reply() |
| 6846 | if type(buf) == loxi.generic_util.OFReader: |
| 6847 | reader = buf |
| 6848 | else: |
| 6849 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6850 | _version = reader.read("!B")[0] |
| 6851 | assert(_version == 4) |
| 6852 | _type = reader.read("!B")[0] |
| 6853 | assert(_type == 19) |
| 6854 | _length = reader.read("!H")[0] |
| 6855 | obj.xid = reader.read("!L")[0] |
| 6856 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6857 | assert(_stats_type == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6858 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6859 | reader.skip(4) |
| 6860 | obj.features = common.meter_features.unpack(reader) |
| 6861 | return obj |
| 6862 | |
| 6863 | def __eq__(self, other): |
| 6864 | if type(self) != type(other): return False |
| 6865 | if self.version != other.version: return False |
| 6866 | if self.type != other.type: return False |
| 6867 | if self.xid != other.xid: return False |
| 6868 | if self.flags != other.flags: return False |
| 6869 | if self.features != other.features: return False |
| 6870 | return True |
| 6871 | |
| 6872 | def __ne__(self, other): |
| 6873 | return not self.__eq__(other) |
| 6874 | |
| 6875 | def __str__(self): |
| 6876 | return self.show() |
| 6877 | |
| 6878 | def show(self): |
| 6879 | import loxi.pp |
| 6880 | return loxi.pp.pp(self) |
| 6881 | |
| 6882 | def pretty_print(self, q): |
| 6883 | q.text("meter_features_stats_reply {") |
| 6884 | with q.group(): |
| 6885 | with q.indent(2): |
| 6886 | q.breakable() |
| 6887 | q.text("xid = "); |
| 6888 | if self.xid != None: |
| 6889 | q.text("%#x" % self.xid) |
| 6890 | else: |
| 6891 | q.text('None') |
| 6892 | q.text(","); q.breakable() |
| 6893 | q.text("flags = "); |
| 6894 | q.text("%#x" % self.flags) |
| 6895 | q.text(","); q.breakable() |
| 6896 | q.text("features = "); |
| 6897 | q.pp(self.features) |
| 6898 | q.breakable() |
| 6899 | q.text('}') |
| 6900 | |
| 6901 | class meter_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6902 | version = 4 |
| 6903 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6904 | stats_type = 11 |
| 6905 | |
| 6906 | def __init__(self, xid=None, flags=None): |
| 6907 | self.xid = xid |
| 6908 | if flags != None: |
| 6909 | self.flags = flags |
| 6910 | else: |
| 6911 | self.flags = 0 |
| 6912 | |
| 6913 | def pack(self): |
| 6914 | packed = [] |
| 6915 | packed.append(struct.pack("!B", self.version)) |
| 6916 | packed.append(struct.pack("!B", self.type)) |
| 6917 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6918 | packed.append(struct.pack("!L", self.xid)) |
| 6919 | packed.append(struct.pack("!H", self.stats_type)) |
| 6920 | packed.append(struct.pack("!H", self.flags)) |
| 6921 | packed.append('\x00' * 4) |
| 6922 | length = sum([len(x) for x in packed]) |
| 6923 | packed[2] = struct.pack("!H", length) |
| 6924 | return ''.join(packed) |
| 6925 | |
| 6926 | @staticmethod |
| 6927 | def unpack(buf): |
| 6928 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6929 | obj = meter_features_stats_request() |
| 6930 | if type(buf) == loxi.generic_util.OFReader: |
| 6931 | reader = buf |
| 6932 | else: |
| 6933 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6934 | _version = reader.read("!B")[0] |
| 6935 | assert(_version == 4) |
| 6936 | _type = reader.read("!B")[0] |
| 6937 | assert(_type == 18) |
| 6938 | _length = reader.read("!H")[0] |
| 6939 | obj.xid = reader.read("!L")[0] |
| 6940 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6941 | assert(_stats_type == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6942 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6943 | reader.skip(4) |
| 6944 | return obj |
| 6945 | |
| 6946 | def __eq__(self, other): |
| 6947 | if type(self) != type(other): return False |
| 6948 | if self.version != other.version: return False |
| 6949 | if self.type != other.type: return False |
| 6950 | if self.xid != other.xid: return False |
| 6951 | if self.flags != other.flags: return False |
| 6952 | return True |
| 6953 | |
| 6954 | def __ne__(self, other): |
| 6955 | return not self.__eq__(other) |
| 6956 | |
| 6957 | def __str__(self): |
| 6958 | return self.show() |
| 6959 | |
| 6960 | def show(self): |
| 6961 | import loxi.pp |
| 6962 | return loxi.pp.pp(self) |
| 6963 | |
| 6964 | def pretty_print(self, q): |
| 6965 | q.text("meter_features_stats_request {") |
| 6966 | with q.group(): |
| 6967 | with q.indent(2): |
| 6968 | q.breakable() |
| 6969 | q.text("xid = "); |
| 6970 | if self.xid != None: |
| 6971 | q.text("%#x" % self.xid) |
| 6972 | else: |
| 6973 | q.text('None') |
| 6974 | q.text(","); q.breakable() |
| 6975 | q.text("flags = "); |
| 6976 | q.text("%#x" % self.flags) |
| 6977 | q.breakable() |
| 6978 | q.text('}') |
| 6979 | |
| 6980 | class meter_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6981 | version = 4 |
| 6982 | type = 29 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6983 | |
| 6984 | def __init__(self, xid=None, command=None, flags=None, meter_id=None, meters=None): |
| 6985 | self.xid = xid |
| 6986 | if command != None: |
| 6987 | self.command = command |
| 6988 | else: |
| 6989 | self.command = 0 |
| 6990 | if flags != None: |
| 6991 | self.flags = flags |
| 6992 | else: |
| 6993 | self.flags = 0 |
| 6994 | if meter_id != None: |
| 6995 | self.meter_id = meter_id |
| 6996 | else: |
| 6997 | self.meter_id = 0 |
| 6998 | if meters != None: |
| 6999 | self.meters = meters |
| 7000 | else: |
| 7001 | self.meters = [] |
| 7002 | |
| 7003 | def pack(self): |
| 7004 | packed = [] |
| 7005 | packed.append(struct.pack("!B", self.version)) |
| 7006 | packed.append(struct.pack("!B", self.type)) |
| 7007 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7008 | packed.append(struct.pack("!L", self.xid)) |
| 7009 | packed.append(struct.pack("!H", self.command)) |
| 7010 | packed.append(struct.pack("!H", self.flags)) |
| 7011 | packed.append(struct.pack("!L", self.meter_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7012 | packed.append(util.pack_list(self.meters)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7013 | length = sum([len(x) for x in packed]) |
| 7014 | packed[2] = struct.pack("!H", length) |
| 7015 | return ''.join(packed) |
| 7016 | |
| 7017 | @staticmethod |
| 7018 | def unpack(buf): |
| 7019 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7020 | obj = meter_mod() |
| 7021 | if type(buf) == loxi.generic_util.OFReader: |
| 7022 | reader = buf |
| 7023 | else: |
| 7024 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7025 | _version = reader.read("!B")[0] |
| 7026 | assert(_version == 4) |
| 7027 | _type = reader.read("!B")[0] |
| 7028 | assert(_type == 29) |
| 7029 | _length = reader.read("!H")[0] |
| 7030 | obj.xid = reader.read("!L")[0] |
| 7031 | obj.command = reader.read("!H")[0] |
| 7032 | obj.flags = reader.read("!H")[0] |
| 7033 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7034 | obj.meters = meter_band.unpack_list(reader) |
| 7035 | return obj |
| 7036 | |
| 7037 | def __eq__(self, other): |
| 7038 | if type(self) != type(other): return False |
| 7039 | if self.version != other.version: return False |
| 7040 | if self.type != other.type: return False |
| 7041 | if self.xid != other.xid: return False |
| 7042 | if self.command != other.command: return False |
| 7043 | if self.flags != other.flags: return False |
| 7044 | if self.meter_id != other.meter_id: return False |
| 7045 | if self.meters != other.meters: return False |
| 7046 | return True |
| 7047 | |
| 7048 | def __ne__(self, other): |
| 7049 | return not self.__eq__(other) |
| 7050 | |
| 7051 | def __str__(self): |
| 7052 | return self.show() |
| 7053 | |
| 7054 | def show(self): |
| 7055 | import loxi.pp |
| 7056 | return loxi.pp.pp(self) |
| 7057 | |
| 7058 | def pretty_print(self, q): |
| 7059 | q.text("meter_mod {") |
| 7060 | with q.group(): |
| 7061 | with q.indent(2): |
| 7062 | q.breakable() |
| 7063 | q.text("xid = "); |
| 7064 | if self.xid != None: |
| 7065 | q.text("%#x" % self.xid) |
| 7066 | else: |
| 7067 | q.text('None') |
| 7068 | q.text(","); q.breakable() |
| 7069 | q.text("command = "); |
| 7070 | q.text("%#x" % self.command) |
| 7071 | q.text(","); q.breakable() |
| 7072 | q.text("flags = "); |
| 7073 | q.text("%#x" % self.flags) |
| 7074 | q.text(","); q.breakable() |
| 7075 | q.text("meter_id = "); |
| 7076 | q.text("%#x" % self.meter_id) |
| 7077 | q.text(","); q.breakable() |
| 7078 | q.text("meters = "); |
| 7079 | q.pp(self.meters) |
| 7080 | q.breakable() |
| 7081 | q.text('}') |
| 7082 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7083 | class meter_mod_failed_error_msg(Message): |
| 7084 | version = 4 |
| 7085 | type = 1 |
| 7086 | err_type = 12 |
| 7087 | |
| 7088 | def __init__(self, xid=None, code=None, data=None): |
| 7089 | self.xid = xid |
| 7090 | if code != None: |
| 7091 | self.code = code |
| 7092 | else: |
| 7093 | self.code = 0 |
| 7094 | if data != None: |
| 7095 | self.data = data |
| 7096 | else: |
| 7097 | self.data = '' |
| 7098 | |
| 7099 | def pack(self): |
| 7100 | packed = [] |
| 7101 | packed.append(struct.pack("!B", self.version)) |
| 7102 | packed.append(struct.pack("!B", self.type)) |
| 7103 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7104 | packed.append(struct.pack("!L", self.xid)) |
| 7105 | packed.append(struct.pack("!H", self.err_type)) |
| 7106 | packed.append(struct.pack("!H", self.code)) |
| 7107 | packed.append(self.data) |
| 7108 | length = sum([len(x) for x in packed]) |
| 7109 | packed[2] = struct.pack("!H", length) |
| 7110 | return ''.join(packed) |
| 7111 | |
| 7112 | @staticmethod |
| 7113 | def unpack(buf): |
| 7114 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7115 | obj = meter_mod_failed_error_msg() |
| 7116 | if type(buf) == loxi.generic_util.OFReader: |
| 7117 | reader = buf |
| 7118 | else: |
| 7119 | reader = loxi.generic_util.OFReader(buf) |
| 7120 | _version = reader.read("!B")[0] |
| 7121 | assert(_version == 4) |
| 7122 | _type = reader.read("!B")[0] |
| 7123 | assert(_type == 1) |
| 7124 | _length = reader.read("!H")[0] |
| 7125 | obj.xid = reader.read("!L")[0] |
| 7126 | _err_type = reader.read("!H")[0] |
| 7127 | assert(_err_type == 12) |
| 7128 | obj.code = reader.read("!H")[0] |
| 7129 | obj.data = str(reader.read_all()) |
| 7130 | return obj |
| 7131 | |
| 7132 | def __eq__(self, other): |
| 7133 | if type(self) != type(other): return False |
| 7134 | if self.version != other.version: return False |
| 7135 | if self.type != other.type: return False |
| 7136 | if self.xid != other.xid: return False |
| 7137 | if self.code != other.code: return False |
| 7138 | if self.data != other.data: return False |
| 7139 | return True |
| 7140 | |
| 7141 | def __ne__(self, other): |
| 7142 | return not self.__eq__(other) |
| 7143 | |
| 7144 | def __str__(self): |
| 7145 | return self.show() |
| 7146 | |
| 7147 | def show(self): |
| 7148 | import loxi.pp |
| 7149 | return loxi.pp.pp(self) |
| 7150 | |
| 7151 | def pretty_print(self, q): |
| 7152 | q.text("meter_mod_failed_error_msg {") |
| 7153 | with q.group(): |
| 7154 | with q.indent(2): |
| 7155 | q.breakable() |
| 7156 | q.text("xid = "); |
| 7157 | if self.xid != None: |
| 7158 | q.text("%#x" % self.xid) |
| 7159 | else: |
| 7160 | q.text('None') |
| 7161 | q.text(","); q.breakable() |
| 7162 | q.text("code = "); |
| 7163 | q.text("%#x" % self.code) |
| 7164 | q.text(","); q.breakable() |
| 7165 | q.text("data = "); |
| 7166 | q.pp(self.data) |
| 7167 | q.breakable() |
| 7168 | q.text('}') |
| 7169 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7170 | class meter_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7171 | version = 4 |
| 7172 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7173 | stats_type = 9 |
| 7174 | |
| 7175 | def __init__(self, xid=None, flags=None, entries=None): |
| 7176 | self.xid = xid |
| 7177 | if flags != None: |
| 7178 | self.flags = flags |
| 7179 | else: |
| 7180 | self.flags = 0 |
| 7181 | if entries != None: |
| 7182 | self.entries = entries |
| 7183 | else: |
| 7184 | self.entries = [] |
| 7185 | |
| 7186 | def pack(self): |
| 7187 | packed = [] |
| 7188 | packed.append(struct.pack("!B", self.version)) |
| 7189 | packed.append(struct.pack("!B", self.type)) |
| 7190 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7191 | packed.append(struct.pack("!L", self.xid)) |
| 7192 | packed.append(struct.pack("!H", self.stats_type)) |
| 7193 | packed.append(struct.pack("!H", self.flags)) |
| 7194 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7195 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7196 | length = sum([len(x) for x in packed]) |
| 7197 | packed[2] = struct.pack("!H", length) |
| 7198 | return ''.join(packed) |
| 7199 | |
| 7200 | @staticmethod |
| 7201 | def unpack(buf): |
| 7202 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7203 | obj = meter_stats_reply() |
| 7204 | if type(buf) == loxi.generic_util.OFReader: |
| 7205 | reader = buf |
| 7206 | else: |
| 7207 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7208 | _version = reader.read("!B")[0] |
| 7209 | assert(_version == 4) |
| 7210 | _type = reader.read("!B")[0] |
| 7211 | assert(_type == 19) |
| 7212 | _length = reader.read("!H")[0] |
| 7213 | obj.xid = reader.read("!L")[0] |
| 7214 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7215 | assert(_stats_type == 9) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7216 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7217 | reader.skip(4) |
| 7218 | obj.entries = common.unpack_list_meter_stats(reader) |
| 7219 | return obj |
| 7220 | |
| 7221 | def __eq__(self, other): |
| 7222 | if type(self) != type(other): return False |
| 7223 | if self.version != other.version: return False |
| 7224 | if self.type != other.type: return False |
| 7225 | if self.xid != other.xid: return False |
| 7226 | if self.flags != other.flags: return False |
| 7227 | if self.entries != other.entries: return False |
| 7228 | return True |
| 7229 | |
| 7230 | def __ne__(self, other): |
| 7231 | return not self.__eq__(other) |
| 7232 | |
| 7233 | def __str__(self): |
| 7234 | return self.show() |
| 7235 | |
| 7236 | def show(self): |
| 7237 | import loxi.pp |
| 7238 | return loxi.pp.pp(self) |
| 7239 | |
| 7240 | def pretty_print(self, q): |
| 7241 | q.text("meter_stats_reply {") |
| 7242 | with q.group(): |
| 7243 | with q.indent(2): |
| 7244 | q.breakable() |
| 7245 | q.text("xid = "); |
| 7246 | if self.xid != None: |
| 7247 | q.text("%#x" % self.xid) |
| 7248 | else: |
| 7249 | q.text('None') |
| 7250 | q.text(","); q.breakable() |
| 7251 | q.text("flags = "); |
| 7252 | q.text("%#x" % self.flags) |
| 7253 | q.text(","); q.breakable() |
| 7254 | q.text("entries = "); |
| 7255 | q.pp(self.entries) |
| 7256 | q.breakable() |
| 7257 | q.text('}') |
| 7258 | |
| 7259 | class meter_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7260 | version = 4 |
| 7261 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7262 | stats_type = 9 |
| 7263 | |
| 7264 | def __init__(self, xid=None, flags=None, meter_id=None): |
| 7265 | self.xid = xid |
| 7266 | if flags != None: |
| 7267 | self.flags = flags |
| 7268 | else: |
| 7269 | self.flags = 0 |
| 7270 | if meter_id != None: |
| 7271 | self.meter_id = meter_id |
| 7272 | else: |
| 7273 | self.meter_id = 0 |
| 7274 | |
| 7275 | def pack(self): |
| 7276 | packed = [] |
| 7277 | packed.append(struct.pack("!B", self.version)) |
| 7278 | packed.append(struct.pack("!B", self.type)) |
| 7279 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7280 | packed.append(struct.pack("!L", self.xid)) |
| 7281 | packed.append(struct.pack("!H", self.stats_type)) |
| 7282 | packed.append(struct.pack("!H", self.flags)) |
| 7283 | packed.append('\x00' * 4) |
| 7284 | packed.append(struct.pack("!L", self.meter_id)) |
| 7285 | packed.append('\x00' * 4) |
| 7286 | length = sum([len(x) for x in packed]) |
| 7287 | packed[2] = struct.pack("!H", length) |
| 7288 | return ''.join(packed) |
| 7289 | |
| 7290 | @staticmethod |
| 7291 | def unpack(buf): |
| 7292 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7293 | obj = meter_stats_request() |
| 7294 | if type(buf) == loxi.generic_util.OFReader: |
| 7295 | reader = buf |
| 7296 | else: |
| 7297 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7298 | _version = reader.read("!B")[0] |
| 7299 | assert(_version == 4) |
| 7300 | _type = reader.read("!B")[0] |
| 7301 | assert(_type == 18) |
| 7302 | _length = reader.read("!H")[0] |
| 7303 | obj.xid = reader.read("!L")[0] |
| 7304 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7305 | assert(_stats_type == 9) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7306 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7307 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7308 | obj.meter_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7309 | reader.skip(4) |
| 7310 | return obj |
| 7311 | |
| 7312 | def __eq__(self, other): |
| 7313 | if type(self) != type(other): return False |
| 7314 | if self.version != other.version: return False |
| 7315 | if self.type != other.type: return False |
| 7316 | if self.xid != other.xid: return False |
| 7317 | if self.flags != other.flags: return False |
| 7318 | if self.meter_id != other.meter_id: return False |
| 7319 | return True |
| 7320 | |
| 7321 | def __ne__(self, other): |
| 7322 | return not self.__eq__(other) |
| 7323 | |
| 7324 | def __str__(self): |
| 7325 | return self.show() |
| 7326 | |
| 7327 | def show(self): |
| 7328 | import loxi.pp |
| 7329 | return loxi.pp.pp(self) |
| 7330 | |
| 7331 | def pretty_print(self, q): |
| 7332 | q.text("meter_stats_request {") |
| 7333 | with q.group(): |
| 7334 | with q.indent(2): |
| 7335 | q.breakable() |
| 7336 | q.text("xid = "); |
| 7337 | if self.xid != None: |
| 7338 | q.text("%#x" % self.xid) |
| 7339 | else: |
| 7340 | q.text('None') |
| 7341 | q.text(","); q.breakable() |
| 7342 | q.text("flags = "); |
| 7343 | q.text("%#x" % self.flags) |
| 7344 | q.text(","); q.breakable() |
| 7345 | q.text("meter_id = "); |
| 7346 | q.text("%#x" % self.meter_id) |
| 7347 | q.breakable() |
| 7348 | q.text('}') |
| 7349 | |
| 7350 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7351 | version = 4 |
| 7352 | type = 10 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7353 | |
| 7354 | def __init__(self, xid=None, buffer_id=None, total_len=None, reason=None, table_id=None, cookie=None, match=None, data=None): |
| 7355 | self.xid = xid |
| 7356 | if buffer_id != None: |
| 7357 | self.buffer_id = buffer_id |
| 7358 | else: |
| 7359 | self.buffer_id = 0 |
| 7360 | if total_len != None: |
| 7361 | self.total_len = total_len |
| 7362 | else: |
| 7363 | self.total_len = 0 |
| 7364 | if reason != None: |
| 7365 | self.reason = reason |
| 7366 | else: |
| 7367 | self.reason = 0 |
| 7368 | if table_id != None: |
| 7369 | self.table_id = table_id |
| 7370 | else: |
| 7371 | self.table_id = 0 |
| 7372 | if cookie != None: |
| 7373 | self.cookie = cookie |
| 7374 | else: |
| 7375 | self.cookie = 0 |
| 7376 | if match != None: |
| 7377 | self.match = match |
| 7378 | else: |
| 7379 | self.match = common.match() |
| 7380 | if data != None: |
| 7381 | self.data = data |
| 7382 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7383 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7384 | |
| 7385 | def pack(self): |
| 7386 | packed = [] |
| 7387 | packed.append(struct.pack("!B", self.version)) |
| 7388 | packed.append(struct.pack("!B", self.type)) |
| 7389 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7390 | packed.append(struct.pack("!L", self.xid)) |
| 7391 | packed.append(struct.pack("!L", self.buffer_id)) |
| 7392 | packed.append(struct.pack("!H", self.total_len)) |
| 7393 | packed.append(struct.pack("!B", self.reason)) |
| 7394 | packed.append(struct.pack("!B", self.table_id)) |
| 7395 | packed.append(struct.pack("!Q", self.cookie)) |
| 7396 | packed.append(self.match.pack()) |
| 7397 | packed.append('\x00' * 2) |
| 7398 | packed.append(self.data) |
| 7399 | length = sum([len(x) for x in packed]) |
| 7400 | packed[2] = struct.pack("!H", length) |
| 7401 | return ''.join(packed) |
| 7402 | |
| 7403 | @staticmethod |
| 7404 | def unpack(buf): |
| 7405 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7406 | obj = packet_in() |
| 7407 | if type(buf) == loxi.generic_util.OFReader: |
| 7408 | reader = buf |
| 7409 | else: |
| 7410 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7411 | _version = reader.read("!B")[0] |
| 7412 | assert(_version == 4) |
| 7413 | _type = reader.read("!B")[0] |
| 7414 | assert(_type == 10) |
| 7415 | _length = reader.read("!H")[0] |
| 7416 | obj.xid = reader.read("!L")[0] |
| 7417 | obj.buffer_id = reader.read("!L")[0] |
| 7418 | obj.total_len = reader.read("!H")[0] |
| 7419 | obj.reason = reader.read("!B")[0] |
| 7420 | obj.table_id = reader.read("!B")[0] |
| 7421 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7422 | obj.match = common.match.unpack(reader) |
| 7423 | reader.skip(2) |
| 7424 | obj.data = str(reader.read_all()) |
| 7425 | return obj |
| 7426 | |
| 7427 | def __eq__(self, other): |
| 7428 | if type(self) != type(other): return False |
| 7429 | if self.version != other.version: return False |
| 7430 | if self.type != other.type: return False |
| 7431 | if self.xid != other.xid: return False |
| 7432 | if self.buffer_id != other.buffer_id: return False |
| 7433 | if self.total_len != other.total_len: return False |
| 7434 | if self.reason != other.reason: return False |
| 7435 | if self.table_id != other.table_id: return False |
| 7436 | if self.cookie != other.cookie: return False |
| 7437 | if self.match != other.match: return False |
| 7438 | if self.data != other.data: return False |
| 7439 | return True |
| 7440 | |
| 7441 | def __ne__(self, other): |
| 7442 | return not self.__eq__(other) |
| 7443 | |
| 7444 | def __str__(self): |
| 7445 | return self.show() |
| 7446 | |
| 7447 | def show(self): |
| 7448 | import loxi.pp |
| 7449 | return loxi.pp.pp(self) |
| 7450 | |
| 7451 | def pretty_print(self, q): |
| 7452 | q.text("packet_in {") |
| 7453 | with q.group(): |
| 7454 | with q.indent(2): |
| 7455 | q.breakable() |
| 7456 | q.text("xid = "); |
| 7457 | if self.xid != None: |
| 7458 | q.text("%#x" % self.xid) |
| 7459 | else: |
| 7460 | q.text('None') |
| 7461 | q.text(","); q.breakable() |
| 7462 | q.text("buffer_id = "); |
| 7463 | q.text("%#x" % self.buffer_id) |
| 7464 | q.text(","); q.breakable() |
| 7465 | q.text("total_len = "); |
| 7466 | q.text("%#x" % self.total_len) |
| 7467 | q.text(","); q.breakable() |
| 7468 | q.text("reason = "); |
| 7469 | q.text("%#x" % self.reason) |
| 7470 | q.text(","); q.breakable() |
| 7471 | q.text("table_id = "); |
| 7472 | q.text("%#x" % self.table_id) |
| 7473 | q.text(","); q.breakable() |
| 7474 | q.text("cookie = "); |
| 7475 | q.text("%#x" % self.cookie) |
| 7476 | q.text(","); q.breakable() |
| 7477 | q.text("match = "); |
| 7478 | q.pp(self.match) |
| 7479 | q.text(","); q.breakable() |
| 7480 | q.text("data = "); |
| 7481 | q.pp(self.data) |
| 7482 | q.breakable() |
| 7483 | q.text('}') |
| 7484 | |
| 7485 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7486 | version = 4 |
| 7487 | type = 13 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7488 | |
| 7489 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 7490 | self.xid = xid |
| 7491 | if buffer_id != None: |
| 7492 | self.buffer_id = buffer_id |
| 7493 | else: |
| 7494 | self.buffer_id = 0 |
| 7495 | if in_port != None: |
| 7496 | self.in_port = in_port |
| 7497 | else: |
| 7498 | self.in_port = 0 |
| 7499 | if actions != None: |
| 7500 | self.actions = actions |
| 7501 | else: |
| 7502 | self.actions = [] |
| 7503 | if data != None: |
| 7504 | self.data = data |
| 7505 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7506 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7507 | |
| 7508 | def pack(self): |
| 7509 | packed = [] |
| 7510 | packed.append(struct.pack("!B", self.version)) |
| 7511 | packed.append(struct.pack("!B", self.type)) |
| 7512 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7513 | packed.append(struct.pack("!L", self.xid)) |
| 7514 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7515 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7516 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
| 7517 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7518 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7519 | packed[6] = struct.pack("!H", len(packed[-1])) |
| 7520 | packed.append(self.data) |
| 7521 | length = sum([len(x) for x in packed]) |
| 7522 | packed[2] = struct.pack("!H", length) |
| 7523 | return ''.join(packed) |
| 7524 | |
| 7525 | @staticmethod |
| 7526 | def unpack(buf): |
| 7527 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7528 | obj = packet_out() |
| 7529 | if type(buf) == loxi.generic_util.OFReader: |
| 7530 | reader = buf |
| 7531 | else: |
| 7532 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7533 | _version = reader.read("!B")[0] |
| 7534 | assert(_version == 4) |
| 7535 | _type = reader.read("!B")[0] |
| 7536 | assert(_type == 13) |
| 7537 | _length = reader.read("!H")[0] |
| 7538 | obj.xid = reader.read("!L")[0] |
| 7539 | obj.buffer_id = reader.read("!L")[0] |
| 7540 | obj.in_port = util.unpack_port_no(reader) |
| 7541 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7542 | reader.skip(6) |
| 7543 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 7544 | obj.data = str(reader.read_all()) |
| 7545 | return obj |
| 7546 | |
| 7547 | def __eq__(self, other): |
| 7548 | if type(self) != type(other): return False |
| 7549 | if self.version != other.version: return False |
| 7550 | if self.type != other.type: return False |
| 7551 | if self.xid != other.xid: return False |
| 7552 | if self.buffer_id != other.buffer_id: return False |
| 7553 | if self.in_port != other.in_port: return False |
| 7554 | if self.actions != other.actions: return False |
| 7555 | if self.data != other.data: return False |
| 7556 | return True |
| 7557 | |
| 7558 | def __ne__(self, other): |
| 7559 | return not self.__eq__(other) |
| 7560 | |
| 7561 | def __str__(self): |
| 7562 | return self.show() |
| 7563 | |
| 7564 | def show(self): |
| 7565 | import loxi.pp |
| 7566 | return loxi.pp.pp(self) |
| 7567 | |
| 7568 | def pretty_print(self, q): |
| 7569 | q.text("packet_out {") |
| 7570 | with q.group(): |
| 7571 | with q.indent(2): |
| 7572 | q.breakable() |
| 7573 | q.text("xid = "); |
| 7574 | if self.xid != None: |
| 7575 | q.text("%#x" % self.xid) |
| 7576 | else: |
| 7577 | q.text('None') |
| 7578 | q.text(","); q.breakable() |
| 7579 | q.text("buffer_id = "); |
| 7580 | q.text("%#x" % self.buffer_id) |
| 7581 | q.text(","); q.breakable() |
| 7582 | q.text("in_port = "); |
| 7583 | q.text(util.pretty_port(self.in_port)) |
| 7584 | q.text(","); q.breakable() |
| 7585 | q.text("actions = "); |
| 7586 | q.pp(self.actions) |
| 7587 | q.text(","); q.breakable() |
| 7588 | q.text("data = "); |
| 7589 | q.pp(self.data) |
| 7590 | q.breakable() |
| 7591 | q.text('}') |
| 7592 | |
| 7593 | class port_desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7594 | version = 4 |
| 7595 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7596 | stats_type = 13 |
| 7597 | |
| 7598 | def __init__(self, xid=None, flags=None, entries=None): |
| 7599 | self.xid = xid |
| 7600 | if flags != None: |
| 7601 | self.flags = flags |
| 7602 | else: |
| 7603 | self.flags = 0 |
| 7604 | if entries != None: |
| 7605 | self.entries = entries |
| 7606 | else: |
| 7607 | self.entries = [] |
| 7608 | |
| 7609 | def pack(self): |
| 7610 | packed = [] |
| 7611 | packed.append(struct.pack("!B", self.version)) |
| 7612 | packed.append(struct.pack("!B", self.type)) |
| 7613 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7614 | packed.append(struct.pack("!L", self.xid)) |
| 7615 | packed.append(struct.pack("!H", self.stats_type)) |
| 7616 | packed.append(struct.pack("!H", self.flags)) |
| 7617 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7618 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7619 | length = sum([len(x) for x in packed]) |
| 7620 | packed[2] = struct.pack("!H", length) |
| 7621 | return ''.join(packed) |
| 7622 | |
| 7623 | @staticmethod |
| 7624 | def unpack(buf): |
| 7625 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7626 | obj = port_desc_stats_reply() |
| 7627 | if type(buf) == loxi.generic_util.OFReader: |
| 7628 | reader = buf |
| 7629 | else: |
| 7630 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7631 | _version = reader.read("!B")[0] |
| 7632 | assert(_version == 4) |
| 7633 | _type = reader.read("!B")[0] |
| 7634 | assert(_type == 19) |
| 7635 | _length = reader.read("!H")[0] |
| 7636 | obj.xid = reader.read("!L")[0] |
| 7637 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7638 | assert(_stats_type == 13) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7639 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7640 | reader.skip(4) |
| 7641 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
| 7642 | return obj |
| 7643 | |
| 7644 | def __eq__(self, other): |
| 7645 | if type(self) != type(other): return False |
| 7646 | if self.version != other.version: return False |
| 7647 | if self.type != other.type: return False |
| 7648 | if self.xid != other.xid: return False |
| 7649 | if self.flags != other.flags: return False |
| 7650 | if self.entries != other.entries: return False |
| 7651 | return True |
| 7652 | |
| 7653 | def __ne__(self, other): |
| 7654 | return not self.__eq__(other) |
| 7655 | |
| 7656 | def __str__(self): |
| 7657 | return self.show() |
| 7658 | |
| 7659 | def show(self): |
| 7660 | import loxi.pp |
| 7661 | return loxi.pp.pp(self) |
| 7662 | |
| 7663 | def pretty_print(self, q): |
| 7664 | q.text("port_desc_stats_reply {") |
| 7665 | with q.group(): |
| 7666 | with q.indent(2): |
| 7667 | q.breakable() |
| 7668 | q.text("xid = "); |
| 7669 | if self.xid != None: |
| 7670 | q.text("%#x" % self.xid) |
| 7671 | else: |
| 7672 | q.text('None') |
| 7673 | q.text(","); q.breakable() |
| 7674 | q.text("flags = "); |
| 7675 | q.text("%#x" % self.flags) |
| 7676 | q.text(","); q.breakable() |
| 7677 | q.text("entries = "); |
| 7678 | q.pp(self.entries) |
| 7679 | q.breakable() |
| 7680 | q.text('}') |
| 7681 | |
| 7682 | class port_desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7683 | version = 4 |
| 7684 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7685 | stats_type = 13 |
| 7686 | |
| 7687 | def __init__(self, xid=None, flags=None): |
| 7688 | self.xid = xid |
| 7689 | if flags != None: |
| 7690 | self.flags = flags |
| 7691 | else: |
| 7692 | self.flags = 0 |
| 7693 | |
| 7694 | def pack(self): |
| 7695 | packed = [] |
| 7696 | packed.append(struct.pack("!B", self.version)) |
| 7697 | packed.append(struct.pack("!B", self.type)) |
| 7698 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7699 | packed.append(struct.pack("!L", self.xid)) |
| 7700 | packed.append(struct.pack("!H", self.stats_type)) |
| 7701 | packed.append(struct.pack("!H", self.flags)) |
| 7702 | packed.append('\x00' * 4) |
| 7703 | length = sum([len(x) for x in packed]) |
| 7704 | packed[2] = struct.pack("!H", length) |
| 7705 | return ''.join(packed) |
| 7706 | |
| 7707 | @staticmethod |
| 7708 | def unpack(buf): |
| 7709 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7710 | obj = port_desc_stats_request() |
| 7711 | if type(buf) == loxi.generic_util.OFReader: |
| 7712 | reader = buf |
| 7713 | else: |
| 7714 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7715 | _version = reader.read("!B")[0] |
| 7716 | assert(_version == 4) |
| 7717 | _type = reader.read("!B")[0] |
| 7718 | assert(_type == 18) |
| 7719 | _length = reader.read("!H")[0] |
| 7720 | obj.xid = reader.read("!L")[0] |
| 7721 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7722 | assert(_stats_type == 13) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7723 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7724 | reader.skip(4) |
| 7725 | return obj |
| 7726 | |
| 7727 | def __eq__(self, other): |
| 7728 | if type(self) != type(other): return False |
| 7729 | if self.version != other.version: return False |
| 7730 | if self.type != other.type: return False |
| 7731 | if self.xid != other.xid: return False |
| 7732 | if self.flags != other.flags: return False |
| 7733 | return True |
| 7734 | |
| 7735 | def __ne__(self, other): |
| 7736 | return not self.__eq__(other) |
| 7737 | |
| 7738 | def __str__(self): |
| 7739 | return self.show() |
| 7740 | |
| 7741 | def show(self): |
| 7742 | import loxi.pp |
| 7743 | return loxi.pp.pp(self) |
| 7744 | |
| 7745 | def pretty_print(self, q): |
| 7746 | q.text("port_desc_stats_request {") |
| 7747 | with q.group(): |
| 7748 | with q.indent(2): |
| 7749 | q.breakable() |
| 7750 | q.text("xid = "); |
| 7751 | if self.xid != None: |
| 7752 | q.text("%#x" % self.xid) |
| 7753 | else: |
| 7754 | q.text('None') |
| 7755 | q.text(","); q.breakable() |
| 7756 | q.text("flags = "); |
| 7757 | q.text("%#x" % self.flags) |
| 7758 | q.breakable() |
| 7759 | q.text('}') |
| 7760 | |
| 7761 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7762 | version = 4 |
| 7763 | type = 16 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7764 | |
| 7765 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
| 7766 | self.xid = xid |
| 7767 | if port_no != None: |
| 7768 | self.port_no = port_no |
| 7769 | else: |
| 7770 | self.port_no = 0 |
| 7771 | if hw_addr != None: |
| 7772 | self.hw_addr = hw_addr |
| 7773 | else: |
| 7774 | self.hw_addr = [0,0,0,0,0,0] |
| 7775 | if config != None: |
| 7776 | self.config = config |
| 7777 | else: |
| 7778 | self.config = 0 |
| 7779 | if mask != None: |
| 7780 | self.mask = mask |
| 7781 | else: |
| 7782 | self.mask = 0 |
| 7783 | if advertise != None: |
| 7784 | self.advertise = advertise |
| 7785 | else: |
| 7786 | self.advertise = 0 |
| 7787 | |
| 7788 | def pack(self): |
| 7789 | packed = [] |
| 7790 | packed.append(struct.pack("!B", self.version)) |
| 7791 | packed.append(struct.pack("!B", self.type)) |
| 7792 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7793 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7794 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7795 | packed.append('\x00' * 4) |
| 7796 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 7797 | packed.append('\x00' * 2) |
| 7798 | packed.append(struct.pack("!L", self.config)) |
| 7799 | packed.append(struct.pack("!L", self.mask)) |
| 7800 | packed.append(struct.pack("!L", self.advertise)) |
| 7801 | packed.append('\x00' * 4) |
| 7802 | length = sum([len(x) for x in packed]) |
| 7803 | packed[2] = struct.pack("!H", length) |
| 7804 | return ''.join(packed) |
| 7805 | |
| 7806 | @staticmethod |
| 7807 | def unpack(buf): |
| 7808 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7809 | obj = port_mod() |
| 7810 | if type(buf) == loxi.generic_util.OFReader: |
| 7811 | reader = buf |
| 7812 | else: |
| 7813 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7814 | _version = reader.read("!B")[0] |
| 7815 | assert(_version == 4) |
| 7816 | _type = reader.read("!B")[0] |
| 7817 | assert(_type == 16) |
| 7818 | _length = reader.read("!H")[0] |
| 7819 | obj.xid = reader.read("!L")[0] |
| 7820 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7821 | reader.skip(4) |
| 7822 | obj.hw_addr = list(reader.read('!6B')) |
| 7823 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7824 | obj.config = reader.read("!L")[0] |
| 7825 | obj.mask = reader.read("!L")[0] |
| 7826 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7827 | reader.skip(4) |
| 7828 | return obj |
| 7829 | |
| 7830 | def __eq__(self, other): |
| 7831 | if type(self) != type(other): return False |
| 7832 | if self.version != other.version: return False |
| 7833 | if self.type != other.type: return False |
| 7834 | if self.xid != other.xid: return False |
| 7835 | if self.port_no != other.port_no: return False |
| 7836 | if self.hw_addr != other.hw_addr: return False |
| 7837 | if self.config != other.config: return False |
| 7838 | if self.mask != other.mask: return False |
| 7839 | if self.advertise != other.advertise: return False |
| 7840 | return True |
| 7841 | |
| 7842 | def __ne__(self, other): |
| 7843 | return not self.__eq__(other) |
| 7844 | |
| 7845 | def __str__(self): |
| 7846 | return self.show() |
| 7847 | |
| 7848 | def show(self): |
| 7849 | import loxi.pp |
| 7850 | return loxi.pp.pp(self) |
| 7851 | |
| 7852 | def pretty_print(self, q): |
| 7853 | q.text("port_mod {") |
| 7854 | with q.group(): |
| 7855 | with q.indent(2): |
| 7856 | q.breakable() |
| 7857 | q.text("xid = "); |
| 7858 | if self.xid != None: |
| 7859 | q.text("%#x" % self.xid) |
| 7860 | else: |
| 7861 | q.text('None') |
| 7862 | q.text(","); q.breakable() |
| 7863 | q.text("port_no = "); |
| 7864 | q.text(util.pretty_port(self.port_no)) |
| 7865 | q.text(","); q.breakable() |
| 7866 | q.text("hw_addr = "); |
| 7867 | q.text(util.pretty_mac(self.hw_addr)) |
| 7868 | q.text(","); q.breakable() |
| 7869 | q.text("config = "); |
| 7870 | q.text("%#x" % self.config) |
| 7871 | q.text(","); q.breakable() |
| 7872 | q.text("mask = "); |
| 7873 | q.text("%#x" % self.mask) |
| 7874 | q.text(","); q.breakable() |
| 7875 | q.text("advertise = "); |
| 7876 | q.text("%#x" % self.advertise) |
| 7877 | q.breakable() |
| 7878 | q.text('}') |
| 7879 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 7880 | class port_mod_failed_error_msg(Message): |
| 7881 | version = 4 |
| 7882 | type = 1 |
| 7883 | err_type = 7 |
| 7884 | |
| 7885 | def __init__(self, xid=None, code=None, data=None): |
| 7886 | self.xid = xid |
| 7887 | if code != None: |
| 7888 | self.code = code |
| 7889 | else: |
| 7890 | self.code = 0 |
| 7891 | if data != None: |
| 7892 | self.data = data |
| 7893 | else: |
| 7894 | self.data = '' |
| 7895 | |
| 7896 | def pack(self): |
| 7897 | packed = [] |
| 7898 | packed.append(struct.pack("!B", self.version)) |
| 7899 | packed.append(struct.pack("!B", self.type)) |
| 7900 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7901 | packed.append(struct.pack("!L", self.xid)) |
| 7902 | packed.append(struct.pack("!H", self.err_type)) |
| 7903 | packed.append(struct.pack("!H", self.code)) |
| 7904 | packed.append(self.data) |
| 7905 | length = sum([len(x) for x in packed]) |
| 7906 | packed[2] = struct.pack("!H", length) |
| 7907 | return ''.join(packed) |
| 7908 | |
| 7909 | @staticmethod |
| 7910 | def unpack(buf): |
| 7911 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 7912 | obj = port_mod_failed_error_msg() |
| 7913 | if type(buf) == loxi.generic_util.OFReader: |
| 7914 | reader = buf |
| 7915 | else: |
| 7916 | reader = loxi.generic_util.OFReader(buf) |
| 7917 | _version = reader.read("!B")[0] |
| 7918 | assert(_version == 4) |
| 7919 | _type = reader.read("!B")[0] |
| 7920 | assert(_type == 1) |
| 7921 | _length = reader.read("!H")[0] |
| 7922 | obj.xid = reader.read("!L")[0] |
| 7923 | _err_type = reader.read("!H")[0] |
| 7924 | assert(_err_type == 7) |
| 7925 | obj.code = reader.read("!H")[0] |
| 7926 | obj.data = str(reader.read_all()) |
| 7927 | return obj |
| 7928 | |
| 7929 | def __eq__(self, other): |
| 7930 | if type(self) != type(other): return False |
| 7931 | if self.version != other.version: return False |
| 7932 | if self.type != other.type: return False |
| 7933 | if self.xid != other.xid: return False |
| 7934 | if self.code != other.code: return False |
| 7935 | if self.data != other.data: return False |
| 7936 | return True |
| 7937 | |
| 7938 | def __ne__(self, other): |
| 7939 | return not self.__eq__(other) |
| 7940 | |
| 7941 | def __str__(self): |
| 7942 | return self.show() |
| 7943 | |
| 7944 | def show(self): |
| 7945 | import loxi.pp |
| 7946 | return loxi.pp.pp(self) |
| 7947 | |
| 7948 | def pretty_print(self, q): |
| 7949 | q.text("port_mod_failed_error_msg {") |
| 7950 | with q.group(): |
| 7951 | with q.indent(2): |
| 7952 | q.breakable() |
| 7953 | q.text("xid = "); |
| 7954 | if self.xid != None: |
| 7955 | q.text("%#x" % self.xid) |
| 7956 | else: |
| 7957 | q.text('None') |
| 7958 | q.text(","); q.breakable() |
| 7959 | q.text("code = "); |
| 7960 | q.text("%#x" % self.code) |
| 7961 | q.text(","); q.breakable() |
| 7962 | q.text("data = "); |
| 7963 | q.pp(self.data) |
| 7964 | q.breakable() |
| 7965 | q.text('}') |
| 7966 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7967 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7968 | version = 4 |
| 7969 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7970 | stats_type = 4 |
| 7971 | |
| 7972 | def __init__(self, xid=None, flags=None, entries=None): |
| 7973 | self.xid = xid |
| 7974 | if flags != None: |
| 7975 | self.flags = flags |
| 7976 | else: |
| 7977 | self.flags = 0 |
| 7978 | if entries != None: |
| 7979 | self.entries = entries |
| 7980 | else: |
| 7981 | self.entries = [] |
| 7982 | |
| 7983 | def pack(self): |
| 7984 | packed = [] |
| 7985 | packed.append(struct.pack("!B", self.version)) |
| 7986 | packed.append(struct.pack("!B", self.type)) |
| 7987 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 7988 | packed.append(struct.pack("!L", self.xid)) |
| 7989 | packed.append(struct.pack("!H", self.stats_type)) |
| 7990 | packed.append(struct.pack("!H", self.flags)) |
| 7991 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 7992 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 7993 | length = sum([len(x) for x in packed]) |
| 7994 | packed[2] = struct.pack("!H", length) |
| 7995 | return ''.join(packed) |
| 7996 | |
| 7997 | @staticmethod |
| 7998 | def unpack(buf): |
| 7999 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8000 | obj = port_stats_reply() |
| 8001 | if type(buf) == loxi.generic_util.OFReader: |
| 8002 | reader = buf |
| 8003 | else: |
| 8004 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8005 | _version = reader.read("!B")[0] |
| 8006 | assert(_version == 4) |
| 8007 | _type = reader.read("!B")[0] |
| 8008 | assert(_type == 19) |
| 8009 | _length = reader.read("!H")[0] |
| 8010 | obj.xid = reader.read("!L")[0] |
| 8011 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8012 | assert(_stats_type == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8013 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8014 | reader.skip(4) |
| 8015 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
| 8016 | return obj |
| 8017 | |
| 8018 | def __eq__(self, other): |
| 8019 | if type(self) != type(other): return False |
| 8020 | if self.version != other.version: return False |
| 8021 | if self.type != other.type: return False |
| 8022 | if self.xid != other.xid: return False |
| 8023 | if self.flags != other.flags: return False |
| 8024 | if self.entries != other.entries: return False |
| 8025 | return True |
| 8026 | |
| 8027 | def __ne__(self, other): |
| 8028 | return not self.__eq__(other) |
| 8029 | |
| 8030 | def __str__(self): |
| 8031 | return self.show() |
| 8032 | |
| 8033 | def show(self): |
| 8034 | import loxi.pp |
| 8035 | return loxi.pp.pp(self) |
| 8036 | |
| 8037 | def pretty_print(self, q): |
| 8038 | q.text("port_stats_reply {") |
| 8039 | with q.group(): |
| 8040 | with q.indent(2): |
| 8041 | q.breakable() |
| 8042 | q.text("xid = "); |
| 8043 | if self.xid != None: |
| 8044 | q.text("%#x" % self.xid) |
| 8045 | else: |
| 8046 | q.text('None') |
| 8047 | q.text(","); q.breakable() |
| 8048 | q.text("flags = "); |
| 8049 | q.text("%#x" % self.flags) |
| 8050 | q.text(","); q.breakable() |
| 8051 | q.text("entries = "); |
| 8052 | q.pp(self.entries) |
| 8053 | q.breakable() |
| 8054 | q.text('}') |
| 8055 | |
| 8056 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8057 | version = 4 |
| 8058 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8059 | stats_type = 4 |
| 8060 | |
| 8061 | def __init__(self, xid=None, flags=None, port_no=None): |
| 8062 | self.xid = xid |
| 8063 | if flags != None: |
| 8064 | self.flags = flags |
| 8065 | else: |
| 8066 | self.flags = 0 |
| 8067 | if port_no != None: |
| 8068 | self.port_no = port_no |
| 8069 | else: |
| 8070 | self.port_no = 0 |
| 8071 | |
| 8072 | def pack(self): |
| 8073 | packed = [] |
| 8074 | packed.append(struct.pack("!B", self.version)) |
| 8075 | packed.append(struct.pack("!B", self.type)) |
| 8076 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8077 | packed.append(struct.pack("!L", self.xid)) |
| 8078 | packed.append(struct.pack("!H", self.stats_type)) |
| 8079 | packed.append(struct.pack("!H", self.flags)) |
| 8080 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8081 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8082 | packed.append('\x00' * 4) |
| 8083 | length = sum([len(x) for x in packed]) |
| 8084 | packed[2] = struct.pack("!H", length) |
| 8085 | return ''.join(packed) |
| 8086 | |
| 8087 | @staticmethod |
| 8088 | def unpack(buf): |
| 8089 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8090 | obj = port_stats_request() |
| 8091 | if type(buf) == loxi.generic_util.OFReader: |
| 8092 | reader = buf |
| 8093 | else: |
| 8094 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8095 | _version = reader.read("!B")[0] |
| 8096 | assert(_version == 4) |
| 8097 | _type = reader.read("!B")[0] |
| 8098 | assert(_type == 18) |
| 8099 | _length = reader.read("!H")[0] |
| 8100 | obj.xid = reader.read("!L")[0] |
| 8101 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8102 | assert(_stats_type == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8103 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8104 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8105 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8106 | reader.skip(4) |
| 8107 | return obj |
| 8108 | |
| 8109 | def __eq__(self, other): |
| 8110 | if type(self) != type(other): return False |
| 8111 | if self.version != other.version: return False |
| 8112 | if self.type != other.type: return False |
| 8113 | if self.xid != other.xid: return False |
| 8114 | if self.flags != other.flags: return False |
| 8115 | if self.port_no != other.port_no: return False |
| 8116 | return True |
| 8117 | |
| 8118 | def __ne__(self, other): |
| 8119 | return not self.__eq__(other) |
| 8120 | |
| 8121 | def __str__(self): |
| 8122 | return self.show() |
| 8123 | |
| 8124 | def show(self): |
| 8125 | import loxi.pp |
| 8126 | return loxi.pp.pp(self) |
| 8127 | |
| 8128 | def pretty_print(self, q): |
| 8129 | q.text("port_stats_request {") |
| 8130 | with q.group(): |
| 8131 | with q.indent(2): |
| 8132 | q.breakable() |
| 8133 | q.text("xid = "); |
| 8134 | if self.xid != None: |
| 8135 | q.text("%#x" % self.xid) |
| 8136 | else: |
| 8137 | q.text('None') |
| 8138 | q.text(","); q.breakable() |
| 8139 | q.text("flags = "); |
| 8140 | q.text("%#x" % self.flags) |
| 8141 | q.text(","); q.breakable() |
| 8142 | q.text("port_no = "); |
| 8143 | q.text(util.pretty_port(self.port_no)) |
| 8144 | q.breakable() |
| 8145 | q.text('}') |
| 8146 | |
| 8147 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8148 | version = 4 |
| 8149 | type = 12 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8150 | |
| 8151 | def __init__(self, xid=None, reason=None, desc=None): |
| 8152 | self.xid = xid |
| 8153 | if reason != None: |
| 8154 | self.reason = reason |
| 8155 | else: |
| 8156 | self.reason = 0 |
| 8157 | if desc != None: |
| 8158 | self.desc = desc |
| 8159 | else: |
| 8160 | self.desc = common.port_desc() |
| 8161 | |
| 8162 | def pack(self): |
| 8163 | packed = [] |
| 8164 | packed.append(struct.pack("!B", self.version)) |
| 8165 | packed.append(struct.pack("!B", self.type)) |
| 8166 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8167 | packed.append(struct.pack("!L", self.xid)) |
| 8168 | packed.append(struct.pack("!B", self.reason)) |
| 8169 | packed.append('\x00' * 7) |
| 8170 | packed.append(self.desc.pack()) |
| 8171 | length = sum([len(x) for x in packed]) |
| 8172 | packed[2] = struct.pack("!H", length) |
| 8173 | return ''.join(packed) |
| 8174 | |
| 8175 | @staticmethod |
| 8176 | def unpack(buf): |
| 8177 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8178 | obj = port_status() |
| 8179 | if type(buf) == loxi.generic_util.OFReader: |
| 8180 | reader = buf |
| 8181 | else: |
| 8182 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8183 | _version = reader.read("!B")[0] |
| 8184 | assert(_version == 4) |
| 8185 | _type = reader.read("!B")[0] |
| 8186 | assert(_type == 12) |
| 8187 | _length = reader.read("!H")[0] |
| 8188 | obj.xid = reader.read("!L")[0] |
| 8189 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8190 | reader.skip(7) |
| 8191 | obj.desc = common.port_desc.unpack(reader) |
| 8192 | return obj |
| 8193 | |
| 8194 | def __eq__(self, other): |
| 8195 | if type(self) != type(other): return False |
| 8196 | if self.version != other.version: return False |
| 8197 | if self.type != other.type: return False |
| 8198 | if self.xid != other.xid: return False |
| 8199 | if self.reason != other.reason: return False |
| 8200 | if self.desc != other.desc: return False |
| 8201 | return True |
| 8202 | |
| 8203 | def __ne__(self, other): |
| 8204 | return not self.__eq__(other) |
| 8205 | |
| 8206 | def __str__(self): |
| 8207 | return self.show() |
| 8208 | |
| 8209 | def show(self): |
| 8210 | import loxi.pp |
| 8211 | return loxi.pp.pp(self) |
| 8212 | |
| 8213 | def pretty_print(self, q): |
| 8214 | q.text("port_status {") |
| 8215 | with q.group(): |
| 8216 | with q.indent(2): |
| 8217 | q.breakable() |
| 8218 | q.text("xid = "); |
| 8219 | if self.xid != None: |
| 8220 | q.text("%#x" % self.xid) |
| 8221 | else: |
| 8222 | q.text('None') |
| 8223 | q.text(","); q.breakable() |
| 8224 | q.text("reason = "); |
| 8225 | q.text("%#x" % self.reason) |
| 8226 | q.text(","); q.breakable() |
| 8227 | q.text("desc = "); |
| 8228 | q.pp(self.desc) |
| 8229 | q.breakable() |
| 8230 | q.text('}') |
| 8231 | |
| 8232 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8233 | version = 4 |
| 8234 | type = 23 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8235 | |
| 8236 | def __init__(self, xid=None, port=None, queues=None): |
| 8237 | self.xid = xid |
| 8238 | if port != None: |
| 8239 | self.port = port |
| 8240 | else: |
| 8241 | self.port = 0 |
| 8242 | if queues != None: |
| 8243 | self.queues = queues |
| 8244 | else: |
| 8245 | self.queues = [] |
| 8246 | |
| 8247 | def pack(self): |
| 8248 | packed = [] |
| 8249 | packed.append(struct.pack("!B", self.version)) |
| 8250 | packed.append(struct.pack("!B", self.type)) |
| 8251 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8252 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8253 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8254 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8255 | packed.append(util.pack_list(self.queues)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8256 | length = sum([len(x) for x in packed]) |
| 8257 | packed[2] = struct.pack("!H", length) |
| 8258 | return ''.join(packed) |
| 8259 | |
| 8260 | @staticmethod |
| 8261 | def unpack(buf): |
| 8262 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8263 | obj = queue_get_config_reply() |
| 8264 | if type(buf) == loxi.generic_util.OFReader: |
| 8265 | reader = buf |
| 8266 | else: |
| 8267 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8268 | _version = reader.read("!B")[0] |
| 8269 | assert(_version == 4) |
| 8270 | _type = reader.read("!B")[0] |
| 8271 | assert(_type == 23) |
| 8272 | _length = reader.read("!H")[0] |
| 8273 | obj.xid = reader.read("!L")[0] |
| 8274 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8275 | reader.skip(4) |
| 8276 | obj.queues = common.unpack_list_packet_queue(reader) |
| 8277 | return obj |
| 8278 | |
| 8279 | def __eq__(self, other): |
| 8280 | if type(self) != type(other): return False |
| 8281 | if self.version != other.version: return False |
| 8282 | if self.type != other.type: return False |
| 8283 | if self.xid != other.xid: return False |
| 8284 | if self.port != other.port: return False |
| 8285 | if self.queues != other.queues: return False |
| 8286 | return True |
| 8287 | |
| 8288 | def __ne__(self, other): |
| 8289 | return not self.__eq__(other) |
| 8290 | |
| 8291 | def __str__(self): |
| 8292 | return self.show() |
| 8293 | |
| 8294 | def show(self): |
| 8295 | import loxi.pp |
| 8296 | return loxi.pp.pp(self) |
| 8297 | |
| 8298 | def pretty_print(self, q): |
| 8299 | q.text("queue_get_config_reply {") |
| 8300 | with q.group(): |
| 8301 | with q.indent(2): |
| 8302 | q.breakable() |
| 8303 | q.text("xid = "); |
| 8304 | if self.xid != None: |
| 8305 | q.text("%#x" % self.xid) |
| 8306 | else: |
| 8307 | q.text('None') |
| 8308 | q.text(","); q.breakable() |
| 8309 | q.text("port = "); |
| 8310 | q.text(util.pretty_port(self.port)) |
| 8311 | q.text(","); q.breakable() |
| 8312 | q.text("queues = "); |
| 8313 | q.pp(self.queues) |
| 8314 | q.breakable() |
| 8315 | q.text('}') |
| 8316 | |
| 8317 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8318 | version = 4 |
| 8319 | type = 22 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8320 | |
| 8321 | def __init__(self, xid=None, port=None): |
| 8322 | self.xid = xid |
| 8323 | if port != None: |
| 8324 | self.port = port |
| 8325 | else: |
| 8326 | self.port = 0 |
| 8327 | |
| 8328 | def pack(self): |
| 8329 | packed = [] |
| 8330 | packed.append(struct.pack("!B", self.version)) |
| 8331 | packed.append(struct.pack("!B", self.type)) |
| 8332 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8333 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8334 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8335 | packed.append('\x00' * 4) |
| 8336 | length = sum([len(x) for x in packed]) |
| 8337 | packed[2] = struct.pack("!H", length) |
| 8338 | return ''.join(packed) |
| 8339 | |
| 8340 | @staticmethod |
| 8341 | def unpack(buf): |
| 8342 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8343 | obj = queue_get_config_request() |
| 8344 | if type(buf) == loxi.generic_util.OFReader: |
| 8345 | reader = buf |
| 8346 | else: |
| 8347 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8348 | _version = reader.read("!B")[0] |
| 8349 | assert(_version == 4) |
| 8350 | _type = reader.read("!B")[0] |
| 8351 | assert(_type == 22) |
| 8352 | _length = reader.read("!H")[0] |
| 8353 | obj.xid = reader.read("!L")[0] |
| 8354 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8355 | reader.skip(4) |
| 8356 | return obj |
| 8357 | |
| 8358 | def __eq__(self, other): |
| 8359 | if type(self) != type(other): return False |
| 8360 | if self.version != other.version: return False |
| 8361 | if self.type != other.type: return False |
| 8362 | if self.xid != other.xid: return False |
| 8363 | if self.port != other.port: return False |
| 8364 | return True |
| 8365 | |
| 8366 | def __ne__(self, other): |
| 8367 | return not self.__eq__(other) |
| 8368 | |
| 8369 | def __str__(self): |
| 8370 | return self.show() |
| 8371 | |
| 8372 | def show(self): |
| 8373 | import loxi.pp |
| 8374 | return loxi.pp.pp(self) |
| 8375 | |
| 8376 | def pretty_print(self, q): |
| 8377 | q.text("queue_get_config_request {") |
| 8378 | with q.group(): |
| 8379 | with q.indent(2): |
| 8380 | q.breakable() |
| 8381 | q.text("xid = "); |
| 8382 | if self.xid != None: |
| 8383 | q.text("%#x" % self.xid) |
| 8384 | else: |
| 8385 | q.text('None') |
| 8386 | q.text(","); q.breakable() |
| 8387 | q.text("port = "); |
| 8388 | q.text(util.pretty_port(self.port)) |
| 8389 | q.breakable() |
| 8390 | q.text('}') |
| 8391 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8392 | class queue_op_failed_error_msg(Message): |
| 8393 | version = 4 |
| 8394 | type = 1 |
| 8395 | err_type = 9 |
| 8396 | |
| 8397 | def __init__(self, xid=None, code=None, data=None): |
| 8398 | self.xid = xid |
| 8399 | if code != None: |
| 8400 | self.code = code |
| 8401 | else: |
| 8402 | self.code = 0 |
| 8403 | if data != None: |
| 8404 | self.data = data |
| 8405 | else: |
| 8406 | self.data = '' |
| 8407 | |
| 8408 | def pack(self): |
| 8409 | packed = [] |
| 8410 | packed.append(struct.pack("!B", self.version)) |
| 8411 | packed.append(struct.pack("!B", self.type)) |
| 8412 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8413 | packed.append(struct.pack("!L", self.xid)) |
| 8414 | packed.append(struct.pack("!H", self.err_type)) |
| 8415 | packed.append(struct.pack("!H", self.code)) |
| 8416 | packed.append(self.data) |
| 8417 | length = sum([len(x) for x in packed]) |
| 8418 | packed[2] = struct.pack("!H", length) |
| 8419 | return ''.join(packed) |
| 8420 | |
| 8421 | @staticmethod |
| 8422 | def unpack(buf): |
| 8423 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8424 | obj = queue_op_failed_error_msg() |
| 8425 | if type(buf) == loxi.generic_util.OFReader: |
| 8426 | reader = buf |
| 8427 | else: |
| 8428 | reader = loxi.generic_util.OFReader(buf) |
| 8429 | _version = reader.read("!B")[0] |
| 8430 | assert(_version == 4) |
| 8431 | _type = reader.read("!B")[0] |
| 8432 | assert(_type == 1) |
| 8433 | _length = reader.read("!H")[0] |
| 8434 | obj.xid = reader.read("!L")[0] |
| 8435 | _err_type = reader.read("!H")[0] |
| 8436 | assert(_err_type == 9) |
| 8437 | obj.code = reader.read("!H")[0] |
| 8438 | obj.data = str(reader.read_all()) |
| 8439 | return obj |
| 8440 | |
| 8441 | def __eq__(self, other): |
| 8442 | if type(self) != type(other): return False |
| 8443 | if self.version != other.version: return False |
| 8444 | if self.type != other.type: return False |
| 8445 | if self.xid != other.xid: return False |
| 8446 | if self.code != other.code: return False |
| 8447 | if self.data != other.data: return False |
| 8448 | return True |
| 8449 | |
| 8450 | def __ne__(self, other): |
| 8451 | return not self.__eq__(other) |
| 8452 | |
| 8453 | def __str__(self): |
| 8454 | return self.show() |
| 8455 | |
| 8456 | def show(self): |
| 8457 | import loxi.pp |
| 8458 | return loxi.pp.pp(self) |
| 8459 | |
| 8460 | def pretty_print(self, q): |
| 8461 | q.text("queue_op_failed_error_msg {") |
| 8462 | with q.group(): |
| 8463 | with q.indent(2): |
| 8464 | q.breakable() |
| 8465 | q.text("xid = "); |
| 8466 | if self.xid != None: |
| 8467 | q.text("%#x" % self.xid) |
| 8468 | else: |
| 8469 | q.text('None') |
| 8470 | q.text(","); q.breakable() |
| 8471 | q.text("code = "); |
| 8472 | q.text("%#x" % self.code) |
| 8473 | q.text(","); q.breakable() |
| 8474 | q.text("data = "); |
| 8475 | q.pp(self.data) |
| 8476 | q.breakable() |
| 8477 | q.text('}') |
| 8478 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8479 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8480 | version = 4 |
| 8481 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8482 | stats_type = 5 |
| 8483 | |
| 8484 | def __init__(self, xid=None, flags=None, entries=None): |
| 8485 | self.xid = xid |
| 8486 | if flags != None: |
| 8487 | self.flags = flags |
| 8488 | else: |
| 8489 | self.flags = 0 |
| 8490 | if entries != None: |
| 8491 | self.entries = entries |
| 8492 | else: |
| 8493 | self.entries = [] |
| 8494 | |
| 8495 | def pack(self): |
| 8496 | packed = [] |
| 8497 | packed.append(struct.pack("!B", self.version)) |
| 8498 | packed.append(struct.pack("!B", self.type)) |
| 8499 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8500 | packed.append(struct.pack("!L", self.xid)) |
| 8501 | packed.append(struct.pack("!H", self.stats_type)) |
| 8502 | packed.append(struct.pack("!H", self.flags)) |
| 8503 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8504 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8505 | length = sum([len(x) for x in packed]) |
| 8506 | packed[2] = struct.pack("!H", length) |
| 8507 | return ''.join(packed) |
| 8508 | |
| 8509 | @staticmethod |
| 8510 | def unpack(buf): |
| 8511 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8512 | obj = queue_stats_reply() |
| 8513 | if type(buf) == loxi.generic_util.OFReader: |
| 8514 | reader = buf |
| 8515 | else: |
| 8516 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8517 | _version = reader.read("!B")[0] |
| 8518 | assert(_version == 4) |
| 8519 | _type = reader.read("!B")[0] |
| 8520 | assert(_type == 19) |
| 8521 | _length = reader.read("!H")[0] |
| 8522 | obj.xid = reader.read("!L")[0] |
| 8523 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8524 | assert(_stats_type == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8525 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8526 | reader.skip(4) |
| 8527 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
| 8528 | return obj |
| 8529 | |
| 8530 | def __eq__(self, other): |
| 8531 | if type(self) != type(other): return False |
| 8532 | if self.version != other.version: return False |
| 8533 | if self.type != other.type: return False |
| 8534 | if self.xid != other.xid: return False |
| 8535 | if self.flags != other.flags: return False |
| 8536 | if self.entries != other.entries: return False |
| 8537 | return True |
| 8538 | |
| 8539 | def __ne__(self, other): |
| 8540 | return not self.__eq__(other) |
| 8541 | |
| 8542 | def __str__(self): |
| 8543 | return self.show() |
| 8544 | |
| 8545 | def show(self): |
| 8546 | import loxi.pp |
| 8547 | return loxi.pp.pp(self) |
| 8548 | |
| 8549 | def pretty_print(self, q): |
| 8550 | q.text("queue_stats_reply {") |
| 8551 | with q.group(): |
| 8552 | with q.indent(2): |
| 8553 | q.breakable() |
| 8554 | q.text("xid = "); |
| 8555 | if self.xid != None: |
| 8556 | q.text("%#x" % self.xid) |
| 8557 | else: |
| 8558 | q.text('None') |
| 8559 | q.text(","); q.breakable() |
| 8560 | q.text("flags = "); |
| 8561 | q.text("%#x" % self.flags) |
| 8562 | q.text(","); q.breakable() |
| 8563 | q.text("entries = "); |
| 8564 | q.pp(self.entries) |
| 8565 | q.breakable() |
| 8566 | q.text('}') |
| 8567 | |
| 8568 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8569 | version = 4 |
| 8570 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8571 | stats_type = 5 |
| 8572 | |
| 8573 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
| 8574 | self.xid = xid |
| 8575 | if flags != None: |
| 8576 | self.flags = flags |
| 8577 | else: |
| 8578 | self.flags = 0 |
| 8579 | if port_no != None: |
| 8580 | self.port_no = port_no |
| 8581 | else: |
| 8582 | self.port_no = 0 |
| 8583 | if queue_id != None: |
| 8584 | self.queue_id = queue_id |
| 8585 | else: |
| 8586 | self.queue_id = 0 |
| 8587 | |
| 8588 | def pack(self): |
| 8589 | packed = [] |
| 8590 | packed.append(struct.pack("!B", self.version)) |
| 8591 | packed.append(struct.pack("!B", self.type)) |
| 8592 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8593 | packed.append(struct.pack("!L", self.xid)) |
| 8594 | packed.append(struct.pack("!H", self.stats_type)) |
| 8595 | packed.append(struct.pack("!H", self.flags)) |
| 8596 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8597 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8598 | packed.append(struct.pack("!L", self.queue_id)) |
| 8599 | length = sum([len(x) for x in packed]) |
| 8600 | packed[2] = struct.pack("!H", length) |
| 8601 | return ''.join(packed) |
| 8602 | |
| 8603 | @staticmethod |
| 8604 | def unpack(buf): |
| 8605 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8606 | obj = queue_stats_request() |
| 8607 | if type(buf) == loxi.generic_util.OFReader: |
| 8608 | reader = buf |
| 8609 | else: |
| 8610 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8611 | _version = reader.read("!B")[0] |
| 8612 | assert(_version == 4) |
| 8613 | _type = reader.read("!B")[0] |
| 8614 | assert(_type == 18) |
| 8615 | _length = reader.read("!H")[0] |
| 8616 | obj.xid = reader.read("!L")[0] |
| 8617 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8618 | assert(_stats_type == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8619 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8620 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8621 | obj.port_no = util.unpack_port_no(reader) |
| 8622 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8623 | return obj |
| 8624 | |
| 8625 | def __eq__(self, other): |
| 8626 | if type(self) != type(other): return False |
| 8627 | if self.version != other.version: return False |
| 8628 | if self.type != other.type: return False |
| 8629 | if self.xid != other.xid: return False |
| 8630 | if self.flags != other.flags: return False |
| 8631 | if self.port_no != other.port_no: return False |
| 8632 | if self.queue_id != other.queue_id: return False |
| 8633 | return True |
| 8634 | |
| 8635 | def __ne__(self, other): |
| 8636 | return not self.__eq__(other) |
| 8637 | |
| 8638 | def __str__(self): |
| 8639 | return self.show() |
| 8640 | |
| 8641 | def show(self): |
| 8642 | import loxi.pp |
| 8643 | return loxi.pp.pp(self) |
| 8644 | |
| 8645 | def pretty_print(self, q): |
| 8646 | q.text("queue_stats_request {") |
| 8647 | with q.group(): |
| 8648 | with q.indent(2): |
| 8649 | q.breakable() |
| 8650 | q.text("xid = "); |
| 8651 | if self.xid != None: |
| 8652 | q.text("%#x" % self.xid) |
| 8653 | else: |
| 8654 | q.text('None') |
| 8655 | q.text(","); q.breakable() |
| 8656 | q.text("flags = "); |
| 8657 | q.text("%#x" % self.flags) |
| 8658 | q.text(","); q.breakable() |
| 8659 | q.text("port_no = "); |
| 8660 | q.text(util.pretty_port(self.port_no)) |
| 8661 | q.text(","); q.breakable() |
| 8662 | q.text("queue_id = "); |
| 8663 | q.text("%#x" % self.queue_id) |
| 8664 | q.breakable() |
| 8665 | q.text('}') |
| 8666 | |
| 8667 | class role_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8668 | version = 4 |
| 8669 | type = 25 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8670 | |
| 8671 | def __init__(self, xid=None, data=None): |
| 8672 | self.xid = xid |
| 8673 | if data != None: |
| 8674 | self.data = data |
| 8675 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8676 | self.data = '' |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8677 | |
| 8678 | def pack(self): |
| 8679 | packed = [] |
| 8680 | packed.append(struct.pack("!B", self.version)) |
| 8681 | packed.append(struct.pack("!B", self.type)) |
| 8682 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8683 | packed.append(struct.pack("!L", self.xid)) |
| 8684 | packed.append(self.data) |
| 8685 | length = sum([len(x) for x in packed]) |
| 8686 | packed[2] = struct.pack("!H", length) |
| 8687 | return ''.join(packed) |
| 8688 | |
| 8689 | @staticmethod |
| 8690 | def unpack(buf): |
| 8691 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8692 | obj = role_reply() |
| 8693 | if type(buf) == loxi.generic_util.OFReader: |
| 8694 | reader = buf |
| 8695 | else: |
| 8696 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8697 | _version = reader.read("!B")[0] |
| 8698 | assert(_version == 4) |
| 8699 | _type = reader.read("!B")[0] |
| 8700 | assert(_type == 25) |
| 8701 | _length = reader.read("!H")[0] |
| 8702 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8703 | obj.data = str(reader.read_all()) |
| 8704 | return obj |
| 8705 | |
| 8706 | def __eq__(self, other): |
| 8707 | if type(self) != type(other): return False |
| 8708 | if self.version != other.version: return False |
| 8709 | if self.type != other.type: return False |
| 8710 | if self.xid != other.xid: return False |
| 8711 | if self.data != other.data: return False |
| 8712 | return True |
| 8713 | |
| 8714 | def __ne__(self, other): |
| 8715 | return not self.__eq__(other) |
| 8716 | |
| 8717 | def __str__(self): |
| 8718 | return self.show() |
| 8719 | |
| 8720 | def show(self): |
| 8721 | import loxi.pp |
| 8722 | return loxi.pp.pp(self) |
| 8723 | |
| 8724 | def pretty_print(self, q): |
| 8725 | q.text("role_reply {") |
| 8726 | with q.group(): |
| 8727 | with q.indent(2): |
| 8728 | q.breakable() |
| 8729 | q.text("xid = "); |
| 8730 | if self.xid != None: |
| 8731 | q.text("%#x" % self.xid) |
| 8732 | else: |
| 8733 | q.text('None') |
| 8734 | q.text(","); q.breakable() |
| 8735 | q.text("data = "); |
| 8736 | q.pp(self.data) |
| 8737 | q.breakable() |
| 8738 | q.text('}') |
| 8739 | |
| 8740 | class role_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8741 | version = 4 |
| 8742 | type = 24 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8743 | |
| 8744 | def __init__(self, xid=None, role=None, generation_id=None): |
| 8745 | self.xid = xid |
| 8746 | if role != None: |
| 8747 | self.role = role |
| 8748 | else: |
| 8749 | self.role = 0 |
| 8750 | if generation_id != None: |
| 8751 | self.generation_id = generation_id |
| 8752 | else: |
| 8753 | self.generation_id = 0 |
| 8754 | |
| 8755 | def pack(self): |
| 8756 | packed = [] |
| 8757 | packed.append(struct.pack("!B", self.version)) |
| 8758 | packed.append(struct.pack("!B", self.type)) |
| 8759 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8760 | packed.append(struct.pack("!L", self.xid)) |
| 8761 | packed.append(struct.pack("!L", self.role)) |
| 8762 | packed.append('\x00' * 4) |
| 8763 | packed.append(struct.pack("!Q", self.generation_id)) |
| 8764 | length = sum([len(x) for x in packed]) |
| 8765 | packed[2] = struct.pack("!H", length) |
| 8766 | return ''.join(packed) |
| 8767 | |
| 8768 | @staticmethod |
| 8769 | def unpack(buf): |
| 8770 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8771 | obj = role_request() |
| 8772 | if type(buf) == loxi.generic_util.OFReader: |
| 8773 | reader = buf |
| 8774 | else: |
| 8775 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8776 | _version = reader.read("!B")[0] |
| 8777 | assert(_version == 4) |
| 8778 | _type = reader.read("!B")[0] |
| 8779 | assert(_type == 24) |
| 8780 | _length = reader.read("!H")[0] |
| 8781 | obj.xid = reader.read("!L")[0] |
| 8782 | obj.role = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8783 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8784 | obj.generation_id = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8785 | return obj |
| 8786 | |
| 8787 | def __eq__(self, other): |
| 8788 | if type(self) != type(other): return False |
| 8789 | if self.version != other.version: return False |
| 8790 | if self.type != other.type: return False |
| 8791 | if self.xid != other.xid: return False |
| 8792 | if self.role != other.role: return False |
| 8793 | if self.generation_id != other.generation_id: return False |
| 8794 | return True |
| 8795 | |
| 8796 | def __ne__(self, other): |
| 8797 | return not self.__eq__(other) |
| 8798 | |
| 8799 | def __str__(self): |
| 8800 | return self.show() |
| 8801 | |
| 8802 | def show(self): |
| 8803 | import loxi.pp |
| 8804 | return loxi.pp.pp(self) |
| 8805 | |
| 8806 | def pretty_print(self, q): |
| 8807 | q.text("role_request {") |
| 8808 | with q.group(): |
| 8809 | with q.indent(2): |
| 8810 | q.breakable() |
| 8811 | q.text("xid = "); |
| 8812 | if self.xid != None: |
| 8813 | q.text("%#x" % self.xid) |
| 8814 | else: |
| 8815 | q.text('None') |
| 8816 | q.text(","); q.breakable() |
| 8817 | q.text("role = "); |
| 8818 | q.text("%#x" % self.role) |
| 8819 | q.text(","); q.breakable() |
| 8820 | q.text("generation_id = "); |
| 8821 | q.text("%#x" % self.generation_id) |
| 8822 | q.breakable() |
| 8823 | q.text('}') |
| 8824 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8825 | class role_request_failed_error_msg(Message): |
| 8826 | version = 4 |
| 8827 | type = 1 |
| 8828 | err_type = 11 |
| 8829 | |
| 8830 | def __init__(self, xid=None, code=None, data=None): |
| 8831 | self.xid = xid |
| 8832 | if code != None: |
| 8833 | self.code = code |
| 8834 | else: |
| 8835 | self.code = 0 |
| 8836 | if data != None: |
| 8837 | self.data = data |
| 8838 | else: |
| 8839 | self.data = '' |
| 8840 | |
| 8841 | def pack(self): |
| 8842 | packed = [] |
| 8843 | packed.append(struct.pack("!B", self.version)) |
| 8844 | packed.append(struct.pack("!B", self.type)) |
| 8845 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8846 | packed.append(struct.pack("!L", self.xid)) |
| 8847 | packed.append(struct.pack("!H", self.err_type)) |
| 8848 | packed.append(struct.pack("!H", self.code)) |
| 8849 | packed.append(self.data) |
| 8850 | length = sum([len(x) for x in packed]) |
| 8851 | packed[2] = struct.pack("!H", length) |
| 8852 | return ''.join(packed) |
| 8853 | |
| 8854 | @staticmethod |
| 8855 | def unpack(buf): |
| 8856 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8857 | obj = role_request_failed_error_msg() |
| 8858 | if type(buf) == loxi.generic_util.OFReader: |
| 8859 | reader = buf |
| 8860 | else: |
| 8861 | reader = loxi.generic_util.OFReader(buf) |
| 8862 | _version = reader.read("!B")[0] |
| 8863 | assert(_version == 4) |
| 8864 | _type = reader.read("!B")[0] |
| 8865 | assert(_type == 1) |
| 8866 | _length = reader.read("!H")[0] |
| 8867 | obj.xid = reader.read("!L")[0] |
| 8868 | _err_type = reader.read("!H")[0] |
| 8869 | assert(_err_type == 11) |
| 8870 | obj.code = reader.read("!H")[0] |
| 8871 | obj.data = str(reader.read_all()) |
| 8872 | return obj |
| 8873 | |
| 8874 | def __eq__(self, other): |
| 8875 | if type(self) != type(other): return False |
| 8876 | if self.version != other.version: return False |
| 8877 | if self.type != other.type: return False |
| 8878 | if self.xid != other.xid: return False |
| 8879 | if self.code != other.code: return False |
| 8880 | if self.data != other.data: return False |
| 8881 | return True |
| 8882 | |
| 8883 | def __ne__(self, other): |
| 8884 | return not self.__eq__(other) |
| 8885 | |
| 8886 | def __str__(self): |
| 8887 | return self.show() |
| 8888 | |
| 8889 | def show(self): |
| 8890 | import loxi.pp |
| 8891 | return loxi.pp.pp(self) |
| 8892 | |
| 8893 | def pretty_print(self, q): |
| 8894 | q.text("role_request_failed_error_msg {") |
| 8895 | with q.group(): |
| 8896 | with q.indent(2): |
| 8897 | q.breakable() |
| 8898 | q.text("xid = "); |
| 8899 | if self.xid != None: |
| 8900 | q.text("%#x" % self.xid) |
| 8901 | else: |
| 8902 | q.text('None') |
| 8903 | q.text(","); q.breakable() |
| 8904 | q.text("code = "); |
| 8905 | q.text("%#x" % self.code) |
| 8906 | q.text(","); q.breakable() |
| 8907 | q.text("data = "); |
| 8908 | q.pp(self.data) |
| 8909 | q.breakable() |
| 8910 | q.text('}') |
| 8911 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8912 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8913 | version = 4 |
| 8914 | type = 9 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8915 | |
| 8916 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 8917 | self.xid = xid |
| 8918 | if flags != None: |
| 8919 | self.flags = flags |
| 8920 | else: |
| 8921 | self.flags = 0 |
| 8922 | if miss_send_len != None: |
| 8923 | self.miss_send_len = miss_send_len |
| 8924 | else: |
| 8925 | self.miss_send_len = 0 |
| 8926 | |
| 8927 | def pack(self): |
| 8928 | packed = [] |
| 8929 | packed.append(struct.pack("!B", self.version)) |
| 8930 | packed.append(struct.pack("!B", self.type)) |
| 8931 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 8932 | packed.append(struct.pack("!L", self.xid)) |
| 8933 | packed.append(struct.pack("!H", self.flags)) |
| 8934 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 8935 | length = sum([len(x) for x in packed]) |
| 8936 | packed[2] = struct.pack("!H", length) |
| 8937 | return ''.join(packed) |
| 8938 | |
| 8939 | @staticmethod |
| 8940 | def unpack(buf): |
| 8941 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 8942 | obj = set_config() |
| 8943 | if type(buf) == loxi.generic_util.OFReader: |
| 8944 | reader = buf |
| 8945 | else: |
| 8946 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 8947 | _version = reader.read("!B")[0] |
| 8948 | assert(_version == 4) |
| 8949 | _type = reader.read("!B")[0] |
| 8950 | assert(_type == 9) |
| 8951 | _length = reader.read("!H")[0] |
| 8952 | obj.xid = reader.read("!L")[0] |
| 8953 | obj.flags = reader.read("!H")[0] |
| 8954 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 8955 | return obj |
| 8956 | |
| 8957 | def __eq__(self, other): |
| 8958 | if type(self) != type(other): return False |
| 8959 | if self.version != other.version: return False |
| 8960 | if self.type != other.type: return False |
| 8961 | if self.xid != other.xid: return False |
| 8962 | if self.flags != other.flags: return False |
| 8963 | if self.miss_send_len != other.miss_send_len: return False |
| 8964 | return True |
| 8965 | |
| 8966 | def __ne__(self, other): |
| 8967 | return not self.__eq__(other) |
| 8968 | |
| 8969 | def __str__(self): |
| 8970 | return self.show() |
| 8971 | |
| 8972 | def show(self): |
| 8973 | import loxi.pp |
| 8974 | return loxi.pp.pp(self) |
| 8975 | |
| 8976 | def pretty_print(self, q): |
| 8977 | q.text("set_config {") |
| 8978 | with q.group(): |
| 8979 | with q.indent(2): |
| 8980 | q.breakable() |
| 8981 | q.text("xid = "); |
| 8982 | if self.xid != None: |
| 8983 | q.text("%#x" % self.xid) |
| 8984 | else: |
| 8985 | q.text('None') |
| 8986 | q.text(","); q.breakable() |
| 8987 | q.text("flags = "); |
| 8988 | q.text("%#x" % self.flags) |
| 8989 | q.text(","); q.breakable() |
| 8990 | q.text("miss_send_len = "); |
| 8991 | q.text("%#x" % self.miss_send_len) |
| 8992 | q.breakable() |
| 8993 | q.text('}') |
| 8994 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 8995 | class switch_config_failed_error_msg(Message): |
| 8996 | version = 4 |
| 8997 | type = 1 |
| 8998 | err_type = 10 |
| 8999 | |
| 9000 | def __init__(self, xid=None, code=None, data=None): |
| 9001 | self.xid = xid |
| 9002 | if code != None: |
| 9003 | self.code = code |
| 9004 | else: |
| 9005 | self.code = 0 |
| 9006 | if data != None: |
| 9007 | self.data = data |
| 9008 | else: |
| 9009 | self.data = '' |
| 9010 | |
| 9011 | def pack(self): |
| 9012 | packed = [] |
| 9013 | packed.append(struct.pack("!B", self.version)) |
| 9014 | packed.append(struct.pack("!B", self.type)) |
| 9015 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9016 | packed.append(struct.pack("!L", self.xid)) |
| 9017 | packed.append(struct.pack("!H", self.err_type)) |
| 9018 | packed.append(struct.pack("!H", self.code)) |
| 9019 | packed.append(self.data) |
| 9020 | length = sum([len(x) for x in packed]) |
| 9021 | packed[2] = struct.pack("!H", length) |
| 9022 | return ''.join(packed) |
| 9023 | |
| 9024 | @staticmethod |
| 9025 | def unpack(buf): |
| 9026 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9027 | obj = switch_config_failed_error_msg() |
| 9028 | if type(buf) == loxi.generic_util.OFReader: |
| 9029 | reader = buf |
| 9030 | else: |
| 9031 | reader = loxi.generic_util.OFReader(buf) |
| 9032 | _version = reader.read("!B")[0] |
| 9033 | assert(_version == 4) |
| 9034 | _type = reader.read("!B")[0] |
| 9035 | assert(_type == 1) |
| 9036 | _length = reader.read("!H")[0] |
| 9037 | obj.xid = reader.read("!L")[0] |
| 9038 | _err_type = reader.read("!H")[0] |
| 9039 | assert(_err_type == 10) |
| 9040 | obj.code = reader.read("!H")[0] |
| 9041 | obj.data = str(reader.read_all()) |
| 9042 | return obj |
| 9043 | |
| 9044 | def __eq__(self, other): |
| 9045 | if type(self) != type(other): return False |
| 9046 | if self.version != other.version: return False |
| 9047 | if self.type != other.type: return False |
| 9048 | if self.xid != other.xid: return False |
| 9049 | if self.code != other.code: return False |
| 9050 | if self.data != other.data: return False |
| 9051 | return True |
| 9052 | |
| 9053 | def __ne__(self, other): |
| 9054 | return not self.__eq__(other) |
| 9055 | |
| 9056 | def __str__(self): |
| 9057 | return self.show() |
| 9058 | |
| 9059 | def show(self): |
| 9060 | import loxi.pp |
| 9061 | return loxi.pp.pp(self) |
| 9062 | |
| 9063 | def pretty_print(self, q): |
| 9064 | q.text("switch_config_failed_error_msg {") |
| 9065 | with q.group(): |
| 9066 | with q.indent(2): |
| 9067 | q.breakable() |
| 9068 | q.text("xid = "); |
| 9069 | if self.xid != None: |
| 9070 | q.text("%#x" % self.xid) |
| 9071 | else: |
| 9072 | q.text('None') |
| 9073 | q.text(","); q.breakable() |
| 9074 | q.text("code = "); |
| 9075 | q.text("%#x" % self.code) |
| 9076 | q.text(","); q.breakable() |
| 9077 | q.text("data = "); |
| 9078 | q.pp(self.data) |
| 9079 | q.breakable() |
| 9080 | q.text('}') |
| 9081 | |
| 9082 | class table_features_failed_error_msg(Message): |
| 9083 | version = 4 |
| 9084 | type = 1 |
| 9085 | err_type = 13 |
| 9086 | |
| 9087 | def __init__(self, xid=None, code=None, data=None): |
| 9088 | self.xid = xid |
| 9089 | if code != None: |
| 9090 | self.code = code |
| 9091 | else: |
| 9092 | self.code = 0 |
| 9093 | if data != None: |
| 9094 | self.data = data |
| 9095 | else: |
| 9096 | self.data = '' |
| 9097 | |
| 9098 | def pack(self): |
| 9099 | packed = [] |
| 9100 | packed.append(struct.pack("!B", self.version)) |
| 9101 | packed.append(struct.pack("!B", self.type)) |
| 9102 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9103 | packed.append(struct.pack("!L", self.xid)) |
| 9104 | packed.append(struct.pack("!H", self.err_type)) |
| 9105 | packed.append(struct.pack("!H", self.code)) |
| 9106 | packed.append(self.data) |
| 9107 | length = sum([len(x) for x in packed]) |
| 9108 | packed[2] = struct.pack("!H", length) |
| 9109 | return ''.join(packed) |
| 9110 | |
| 9111 | @staticmethod |
| 9112 | def unpack(buf): |
| 9113 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9114 | obj = table_features_failed_error_msg() |
| 9115 | if type(buf) == loxi.generic_util.OFReader: |
| 9116 | reader = buf |
| 9117 | else: |
| 9118 | reader = loxi.generic_util.OFReader(buf) |
| 9119 | _version = reader.read("!B")[0] |
| 9120 | assert(_version == 4) |
| 9121 | _type = reader.read("!B")[0] |
| 9122 | assert(_type == 1) |
| 9123 | _length = reader.read("!H")[0] |
| 9124 | obj.xid = reader.read("!L")[0] |
| 9125 | _err_type = reader.read("!H")[0] |
| 9126 | assert(_err_type == 13) |
| 9127 | obj.code = reader.read("!H")[0] |
| 9128 | obj.data = str(reader.read_all()) |
| 9129 | return obj |
| 9130 | |
| 9131 | def __eq__(self, other): |
| 9132 | if type(self) != type(other): return False |
| 9133 | if self.version != other.version: return False |
| 9134 | if self.type != other.type: return False |
| 9135 | if self.xid != other.xid: return False |
| 9136 | if self.code != other.code: return False |
| 9137 | if self.data != other.data: return False |
| 9138 | return True |
| 9139 | |
| 9140 | def __ne__(self, other): |
| 9141 | return not self.__eq__(other) |
| 9142 | |
| 9143 | def __str__(self): |
| 9144 | return self.show() |
| 9145 | |
| 9146 | def show(self): |
| 9147 | import loxi.pp |
| 9148 | return loxi.pp.pp(self) |
| 9149 | |
| 9150 | def pretty_print(self, q): |
| 9151 | q.text("table_features_failed_error_msg {") |
| 9152 | with q.group(): |
| 9153 | with q.indent(2): |
| 9154 | q.breakable() |
| 9155 | q.text("xid = "); |
| 9156 | if self.xid != None: |
| 9157 | q.text("%#x" % self.xid) |
| 9158 | else: |
| 9159 | q.text('None') |
| 9160 | q.text(","); q.breakable() |
| 9161 | q.text("code = "); |
| 9162 | q.text("%#x" % self.code) |
| 9163 | q.text(","); q.breakable() |
| 9164 | q.text("data = "); |
| 9165 | q.pp(self.data) |
| 9166 | q.breakable() |
| 9167 | q.text('}') |
| 9168 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9169 | class table_features_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9170 | version = 4 |
| 9171 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9172 | stats_type = 12 |
| 9173 | |
| 9174 | def __init__(self, xid=None, flags=None, entries=None): |
| 9175 | self.xid = xid |
| 9176 | if flags != None: |
| 9177 | self.flags = flags |
| 9178 | else: |
| 9179 | self.flags = 0 |
| 9180 | if entries != None: |
| 9181 | self.entries = entries |
| 9182 | else: |
| 9183 | self.entries = [] |
| 9184 | |
| 9185 | def pack(self): |
| 9186 | packed = [] |
| 9187 | packed.append(struct.pack("!B", self.version)) |
| 9188 | packed.append(struct.pack("!B", self.type)) |
| 9189 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9190 | packed.append(struct.pack("!L", self.xid)) |
| 9191 | packed.append(struct.pack("!H", self.stats_type)) |
| 9192 | packed.append(struct.pack("!H", self.flags)) |
| 9193 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9194 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9195 | length = sum([len(x) for x in packed]) |
| 9196 | packed[2] = struct.pack("!H", length) |
| 9197 | return ''.join(packed) |
| 9198 | |
| 9199 | @staticmethod |
| 9200 | def unpack(buf): |
| 9201 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9202 | obj = table_features_stats_reply() |
| 9203 | if type(buf) == loxi.generic_util.OFReader: |
| 9204 | reader = buf |
| 9205 | else: |
| 9206 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9207 | _version = reader.read("!B")[0] |
| 9208 | assert(_version == 4) |
| 9209 | _type = reader.read("!B")[0] |
| 9210 | assert(_type == 19) |
| 9211 | _length = reader.read("!H")[0] |
| 9212 | obj.xid = reader.read("!L")[0] |
| 9213 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9214 | assert(_stats_type == 12) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9215 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9216 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9217 | obj.entries = loxi.unimplemented('unpack list(of_table_features_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9218 | return obj |
| 9219 | |
| 9220 | def __eq__(self, other): |
| 9221 | if type(self) != type(other): return False |
| 9222 | if self.version != other.version: return False |
| 9223 | if self.type != other.type: return False |
| 9224 | if self.xid != other.xid: return False |
| 9225 | if self.flags != other.flags: return False |
| 9226 | if self.entries != other.entries: return False |
| 9227 | return True |
| 9228 | |
| 9229 | def __ne__(self, other): |
| 9230 | return not self.__eq__(other) |
| 9231 | |
| 9232 | def __str__(self): |
| 9233 | return self.show() |
| 9234 | |
| 9235 | def show(self): |
| 9236 | import loxi.pp |
| 9237 | return loxi.pp.pp(self) |
| 9238 | |
| 9239 | def pretty_print(self, q): |
| 9240 | q.text("table_features_stats_reply {") |
| 9241 | with q.group(): |
| 9242 | with q.indent(2): |
| 9243 | q.breakable() |
| 9244 | q.text("xid = "); |
| 9245 | if self.xid != None: |
| 9246 | q.text("%#x" % self.xid) |
| 9247 | else: |
| 9248 | q.text('None') |
| 9249 | q.text(","); q.breakable() |
| 9250 | q.text("flags = "); |
| 9251 | q.text("%#x" % self.flags) |
| 9252 | q.text(","); q.breakable() |
| 9253 | q.text("entries = "); |
| 9254 | q.pp(self.entries) |
| 9255 | q.breakable() |
| 9256 | q.text('}') |
| 9257 | |
| 9258 | class table_features_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9259 | version = 4 |
| 9260 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9261 | stats_type = 12 |
| 9262 | |
| 9263 | def __init__(self, xid=None, flags=None, entries=None): |
| 9264 | self.xid = xid |
| 9265 | if flags != None: |
| 9266 | self.flags = flags |
| 9267 | else: |
| 9268 | self.flags = 0 |
| 9269 | if entries != None: |
| 9270 | self.entries = entries |
| 9271 | else: |
| 9272 | self.entries = [] |
| 9273 | |
| 9274 | def pack(self): |
| 9275 | packed = [] |
| 9276 | packed.append(struct.pack("!B", self.version)) |
| 9277 | packed.append(struct.pack("!B", self.type)) |
| 9278 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9279 | packed.append(struct.pack("!L", self.xid)) |
| 9280 | packed.append(struct.pack("!H", self.stats_type)) |
| 9281 | packed.append(struct.pack("!H", self.flags)) |
| 9282 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9283 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9284 | length = sum([len(x) for x in packed]) |
| 9285 | packed[2] = struct.pack("!H", length) |
| 9286 | return ''.join(packed) |
| 9287 | |
| 9288 | @staticmethod |
| 9289 | def unpack(buf): |
| 9290 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9291 | obj = table_features_stats_request() |
| 9292 | if type(buf) == loxi.generic_util.OFReader: |
| 9293 | reader = buf |
| 9294 | else: |
| 9295 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9296 | _version = reader.read("!B")[0] |
| 9297 | assert(_version == 4) |
| 9298 | _type = reader.read("!B")[0] |
| 9299 | assert(_type == 18) |
| 9300 | _length = reader.read("!H")[0] |
| 9301 | obj.xid = reader.read("!L")[0] |
| 9302 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9303 | assert(_stats_type == 12) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9304 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9305 | reader.skip(4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9306 | obj.entries = loxi.unimplemented('unpack list(of_table_features_t)') |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9307 | return obj |
| 9308 | |
| 9309 | def __eq__(self, other): |
| 9310 | if type(self) != type(other): return False |
| 9311 | if self.version != other.version: return False |
| 9312 | if self.type != other.type: return False |
| 9313 | if self.xid != other.xid: return False |
| 9314 | if self.flags != other.flags: return False |
| 9315 | if self.entries != other.entries: return False |
| 9316 | return True |
| 9317 | |
| 9318 | def __ne__(self, other): |
| 9319 | return not self.__eq__(other) |
| 9320 | |
| 9321 | def __str__(self): |
| 9322 | return self.show() |
| 9323 | |
| 9324 | def show(self): |
| 9325 | import loxi.pp |
| 9326 | return loxi.pp.pp(self) |
| 9327 | |
| 9328 | def pretty_print(self, q): |
| 9329 | q.text("table_features_stats_request {") |
| 9330 | with q.group(): |
| 9331 | with q.indent(2): |
| 9332 | q.breakable() |
| 9333 | q.text("xid = "); |
| 9334 | if self.xid != None: |
| 9335 | q.text("%#x" % self.xid) |
| 9336 | else: |
| 9337 | q.text('None') |
| 9338 | q.text(","); q.breakable() |
| 9339 | q.text("flags = "); |
| 9340 | q.text("%#x" % self.flags) |
| 9341 | q.text(","); q.breakable() |
| 9342 | q.text("entries = "); |
| 9343 | q.pp(self.entries) |
| 9344 | q.breakable() |
| 9345 | q.text('}') |
| 9346 | |
| 9347 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9348 | version = 4 |
| 9349 | type = 17 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9350 | |
| 9351 | def __init__(self, xid=None, table_id=None, config=None): |
| 9352 | self.xid = xid |
| 9353 | if table_id != None: |
| 9354 | self.table_id = table_id |
| 9355 | else: |
| 9356 | self.table_id = 0 |
| 9357 | if config != None: |
| 9358 | self.config = config |
| 9359 | else: |
| 9360 | self.config = 0 |
| 9361 | |
| 9362 | def pack(self): |
| 9363 | packed = [] |
| 9364 | packed.append(struct.pack("!B", self.version)) |
| 9365 | packed.append(struct.pack("!B", self.type)) |
| 9366 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9367 | packed.append(struct.pack("!L", self.xid)) |
| 9368 | packed.append(struct.pack("!B", self.table_id)) |
| 9369 | packed.append('\x00' * 3) |
| 9370 | packed.append(struct.pack("!L", self.config)) |
| 9371 | length = sum([len(x) for x in packed]) |
| 9372 | packed[2] = struct.pack("!H", length) |
| 9373 | return ''.join(packed) |
| 9374 | |
| 9375 | @staticmethod |
| 9376 | def unpack(buf): |
| 9377 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9378 | obj = table_mod() |
| 9379 | if type(buf) == loxi.generic_util.OFReader: |
| 9380 | reader = buf |
| 9381 | else: |
| 9382 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9383 | _version = reader.read("!B")[0] |
| 9384 | assert(_version == 4) |
| 9385 | _type = reader.read("!B")[0] |
| 9386 | assert(_type == 17) |
| 9387 | _length = reader.read("!H")[0] |
| 9388 | obj.xid = reader.read("!L")[0] |
| 9389 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9390 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9391 | obj.config = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9392 | return obj |
| 9393 | |
| 9394 | def __eq__(self, other): |
| 9395 | if type(self) != type(other): return False |
| 9396 | if self.version != other.version: return False |
| 9397 | if self.type != other.type: return False |
| 9398 | if self.xid != other.xid: return False |
| 9399 | if self.table_id != other.table_id: return False |
| 9400 | if self.config != other.config: return False |
| 9401 | return True |
| 9402 | |
| 9403 | def __ne__(self, other): |
| 9404 | return not self.__eq__(other) |
| 9405 | |
| 9406 | def __str__(self): |
| 9407 | return self.show() |
| 9408 | |
| 9409 | def show(self): |
| 9410 | import loxi.pp |
| 9411 | return loxi.pp.pp(self) |
| 9412 | |
| 9413 | def pretty_print(self, q): |
| 9414 | q.text("table_mod {") |
| 9415 | with q.group(): |
| 9416 | with q.indent(2): |
| 9417 | q.breakable() |
| 9418 | q.text("xid = "); |
| 9419 | if self.xid != None: |
| 9420 | q.text("%#x" % self.xid) |
| 9421 | else: |
| 9422 | q.text('None') |
| 9423 | q.text(","); q.breakable() |
| 9424 | q.text("table_id = "); |
| 9425 | q.text("%#x" % self.table_id) |
| 9426 | q.text(","); q.breakable() |
| 9427 | q.text("config = "); |
| 9428 | q.text("%#x" % self.config) |
| 9429 | q.breakable() |
| 9430 | q.text('}') |
| 9431 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9432 | class table_mod_failed_error_msg(Message): |
| 9433 | version = 4 |
| 9434 | type = 1 |
| 9435 | err_type = 8 |
| 9436 | |
| 9437 | def __init__(self, xid=None, code=None, data=None): |
| 9438 | self.xid = xid |
| 9439 | if code != None: |
| 9440 | self.code = code |
| 9441 | else: |
| 9442 | self.code = 0 |
| 9443 | if data != None: |
| 9444 | self.data = data |
| 9445 | else: |
| 9446 | self.data = '' |
| 9447 | |
| 9448 | def pack(self): |
| 9449 | packed = [] |
| 9450 | packed.append(struct.pack("!B", self.version)) |
| 9451 | packed.append(struct.pack("!B", self.type)) |
| 9452 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9453 | packed.append(struct.pack("!L", self.xid)) |
| 9454 | packed.append(struct.pack("!H", self.err_type)) |
| 9455 | packed.append(struct.pack("!H", self.code)) |
| 9456 | packed.append(self.data) |
| 9457 | length = sum([len(x) for x in packed]) |
| 9458 | packed[2] = struct.pack("!H", length) |
| 9459 | return ''.join(packed) |
| 9460 | |
| 9461 | @staticmethod |
| 9462 | def unpack(buf): |
| 9463 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9464 | obj = table_mod_failed_error_msg() |
| 9465 | if type(buf) == loxi.generic_util.OFReader: |
| 9466 | reader = buf |
| 9467 | else: |
| 9468 | reader = loxi.generic_util.OFReader(buf) |
| 9469 | _version = reader.read("!B")[0] |
| 9470 | assert(_version == 4) |
| 9471 | _type = reader.read("!B")[0] |
| 9472 | assert(_type == 1) |
| 9473 | _length = reader.read("!H")[0] |
| 9474 | obj.xid = reader.read("!L")[0] |
| 9475 | _err_type = reader.read("!H")[0] |
| 9476 | assert(_err_type == 8) |
| 9477 | obj.code = reader.read("!H")[0] |
| 9478 | obj.data = str(reader.read_all()) |
| 9479 | return obj |
| 9480 | |
| 9481 | def __eq__(self, other): |
| 9482 | if type(self) != type(other): return False |
| 9483 | if self.version != other.version: return False |
| 9484 | if self.type != other.type: return False |
| 9485 | if self.xid != other.xid: return False |
| 9486 | if self.code != other.code: return False |
| 9487 | if self.data != other.data: return False |
| 9488 | return True |
| 9489 | |
| 9490 | def __ne__(self, other): |
| 9491 | return not self.__eq__(other) |
| 9492 | |
| 9493 | def __str__(self): |
| 9494 | return self.show() |
| 9495 | |
| 9496 | def show(self): |
| 9497 | import loxi.pp |
| 9498 | return loxi.pp.pp(self) |
| 9499 | |
| 9500 | def pretty_print(self, q): |
| 9501 | q.text("table_mod_failed_error_msg {") |
| 9502 | with q.group(): |
| 9503 | with q.indent(2): |
| 9504 | q.breakable() |
| 9505 | q.text("xid = "); |
| 9506 | if self.xid != None: |
| 9507 | q.text("%#x" % self.xid) |
| 9508 | else: |
| 9509 | q.text('None') |
| 9510 | q.text(","); q.breakable() |
| 9511 | q.text("code = "); |
| 9512 | q.text("%#x" % self.code) |
| 9513 | q.text(","); q.breakable() |
| 9514 | q.text("data = "); |
| 9515 | q.pp(self.data) |
| 9516 | q.breakable() |
| 9517 | q.text('}') |
| 9518 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9519 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9520 | version = 4 |
| 9521 | type = 19 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9522 | stats_type = 3 |
| 9523 | |
| 9524 | def __init__(self, xid=None, flags=None, entries=None): |
| 9525 | self.xid = xid |
| 9526 | if flags != None: |
| 9527 | self.flags = flags |
| 9528 | else: |
| 9529 | self.flags = 0 |
| 9530 | if entries != None: |
| 9531 | self.entries = entries |
| 9532 | else: |
| 9533 | self.entries = [] |
| 9534 | |
| 9535 | def pack(self): |
| 9536 | packed = [] |
| 9537 | packed.append(struct.pack("!B", self.version)) |
| 9538 | packed.append(struct.pack("!B", self.type)) |
| 9539 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9540 | packed.append(struct.pack("!L", self.xid)) |
| 9541 | packed.append(struct.pack("!H", self.stats_type)) |
| 9542 | packed.append(struct.pack("!H", self.flags)) |
| 9543 | packed.append('\x00' * 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9544 | packed.append(util.pack_list(self.entries)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9545 | length = sum([len(x) for x in packed]) |
| 9546 | packed[2] = struct.pack("!H", length) |
| 9547 | return ''.join(packed) |
| 9548 | |
| 9549 | @staticmethod |
| 9550 | def unpack(buf): |
| 9551 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9552 | obj = table_stats_reply() |
| 9553 | if type(buf) == loxi.generic_util.OFReader: |
| 9554 | reader = buf |
| 9555 | else: |
| 9556 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9557 | _version = reader.read("!B")[0] |
| 9558 | assert(_version == 4) |
| 9559 | _type = reader.read("!B")[0] |
| 9560 | assert(_type == 19) |
| 9561 | _length = reader.read("!H")[0] |
| 9562 | obj.xid = reader.read("!L")[0] |
| 9563 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9564 | assert(_stats_type == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9565 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9566 | reader.skip(4) |
| 9567 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
| 9568 | return obj |
| 9569 | |
| 9570 | def __eq__(self, other): |
| 9571 | if type(self) != type(other): return False |
| 9572 | if self.version != other.version: return False |
| 9573 | if self.type != other.type: return False |
| 9574 | if self.xid != other.xid: return False |
| 9575 | if self.flags != other.flags: return False |
| 9576 | if self.entries != other.entries: return False |
| 9577 | return True |
| 9578 | |
| 9579 | def __ne__(self, other): |
| 9580 | return not self.__eq__(other) |
| 9581 | |
| 9582 | def __str__(self): |
| 9583 | return self.show() |
| 9584 | |
| 9585 | def show(self): |
| 9586 | import loxi.pp |
| 9587 | return loxi.pp.pp(self) |
| 9588 | |
| 9589 | def pretty_print(self, q): |
| 9590 | q.text("table_stats_reply {") |
| 9591 | with q.group(): |
| 9592 | with q.indent(2): |
| 9593 | q.breakable() |
| 9594 | q.text("xid = "); |
| 9595 | if self.xid != None: |
| 9596 | q.text("%#x" % self.xid) |
| 9597 | else: |
| 9598 | q.text('None') |
| 9599 | q.text(","); q.breakable() |
| 9600 | q.text("flags = "); |
| 9601 | q.text("%#x" % self.flags) |
| 9602 | q.text(","); q.breakable() |
| 9603 | q.text("entries = "); |
| 9604 | q.pp(self.entries) |
| 9605 | q.breakable() |
| 9606 | q.text('}') |
| 9607 | |
| 9608 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9609 | version = 4 |
| 9610 | type = 18 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9611 | stats_type = 3 |
| 9612 | |
| 9613 | def __init__(self, xid=None, flags=None): |
| 9614 | self.xid = xid |
| 9615 | if flags != None: |
| 9616 | self.flags = flags |
| 9617 | else: |
| 9618 | self.flags = 0 |
| 9619 | |
| 9620 | def pack(self): |
| 9621 | packed = [] |
| 9622 | packed.append(struct.pack("!B", self.version)) |
| 9623 | packed.append(struct.pack("!B", self.type)) |
| 9624 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 9625 | packed.append(struct.pack("!L", self.xid)) |
| 9626 | packed.append(struct.pack("!H", self.stats_type)) |
| 9627 | packed.append(struct.pack("!H", self.flags)) |
| 9628 | packed.append('\x00' * 4) |
| 9629 | length = sum([len(x) for x in packed]) |
| 9630 | packed[2] = struct.pack("!H", length) |
| 9631 | return ''.join(packed) |
| 9632 | |
| 9633 | @staticmethod |
| 9634 | def unpack(buf): |
| 9635 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 9636 | obj = table_stats_request() |
| 9637 | if type(buf) == loxi.generic_util.OFReader: |
| 9638 | reader = buf |
| 9639 | else: |
| 9640 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9641 | _version = reader.read("!B")[0] |
| 9642 | assert(_version == 4) |
| 9643 | _type = reader.read("!B")[0] |
| 9644 | assert(_type == 18) |
| 9645 | _length = reader.read("!H")[0] |
| 9646 | obj.xid = reader.read("!L")[0] |
| 9647 | _stats_type = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9648 | assert(_stats_type == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9649 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9650 | reader.skip(4) |
| 9651 | return obj |
| 9652 | |
| 9653 | def __eq__(self, other): |
| 9654 | if type(self) != type(other): return False |
| 9655 | if self.version != other.version: return False |
| 9656 | if self.type != other.type: return False |
| 9657 | if self.xid != other.xid: return False |
| 9658 | if self.flags != other.flags: return False |
| 9659 | return True |
| 9660 | |
| 9661 | def __ne__(self, other): |
| 9662 | return not self.__eq__(other) |
| 9663 | |
| 9664 | def __str__(self): |
| 9665 | return self.show() |
| 9666 | |
| 9667 | def show(self): |
| 9668 | import loxi.pp |
| 9669 | return loxi.pp.pp(self) |
| 9670 | |
| 9671 | def pretty_print(self, q): |
| 9672 | q.text("table_stats_request {") |
| 9673 | with q.group(): |
| 9674 | with q.indent(2): |
| 9675 | q.breakable() |
| 9676 | q.text("xid = "); |
| 9677 | if self.xid != None: |
| 9678 | q.text("%#x" % self.xid) |
| 9679 | else: |
| 9680 | q.text('None') |
| 9681 | q.text(","); q.breakable() |
| 9682 | q.text("flags = "); |
| 9683 | q.text("%#x" % self.flags) |
| 9684 | q.breakable() |
| 9685 | q.text('}') |
| 9686 | |
| 9687 | |
| 9688 | def parse_header(buf): |
| 9689 | if len(buf) < 8: |
| 9690 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 9691 | return struct.unpack_from("!BBHL", buf) |
| 9692 | |
| 9693 | def parse_message(buf): |
| 9694 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 9695 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 9696 | 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] | 9697 | if len(buf) != msg_len: |
| 9698 | raise loxi.ProtocolError("incorrect message size") |
| 9699 | if msg_type in parsers: |
| 9700 | return parsers[msg_type](buf) |
| 9701 | else: |
| 9702 | raise loxi.ProtocolError("unexpected message type") |
| 9703 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9704 | def parse_error(buf): |
| 9705 | if len(buf) < 8 + 2: |
| 9706 | raise loxi.ProtocolError("message too short") |
| 9707 | err_type, = struct.unpack_from("!H", buf, 8) |
| 9708 | if err_type in error_msg_parsers: |
| 9709 | return error_msg_parsers[err_type](buf) |
| 9710 | else: |
| 9711 | raise loxi.ProtocolError("unexpected error type %u" % err_type) |
| 9712 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9713 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 9714 | if len(buf) < 25 + 1: |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9715 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 9716 | # Technically uint16_t for OF 1.0 |
| 9717 | cmd, = struct.unpack_from("!B", buf, 25) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9718 | if cmd in flow_mod_parsers: |
| 9719 | return flow_mod_parsers[cmd](buf) |
| 9720 | else: |
| 9721 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 9722 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9723 | def parse_stats_reply(buf): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9724 | if len(buf) < 8 + 2: |
| 9725 | raise loxi.ProtocolError("message too short") |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9726 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 9727 | if stats_type in stats_reply_parsers: |
| 9728 | return stats_reply_parsers[stats_type](buf) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9729 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9730 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9731 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9732 | def parse_stats_request(buf): |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9733 | if len(buf) < 8 + 2: |
| 9734 | raise loxi.ProtocolError("message too short") |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9735 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 9736 | if stats_type in stats_request_parsers: |
| 9737 | return stats_request_parsers[stats_type](buf) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9738 | else: |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9739 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9740 | |
| 9741 | def parse_experimenter(buf): |
| 9742 | if len(buf) < 16: |
| 9743 | raise loxi.ProtocolError("experimenter message too short") |
| 9744 | |
| 9745 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 9746 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 9747 | subtype, = struct.unpack_from("!L", buf, 12) |
| 9748 | elif experimenter == 0x00002320: # Nicira |
| 9749 | subtype, = struct.unpack_from("!L", buf, 12) |
| 9750 | else: |
| 9751 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 9752 | |
| 9753 | if subtype in experimenter_parsers[experimenter]: |
| 9754 | return experimenter_parsers[experimenter][subtype](buf) |
| 9755 | else: |
| 9756 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 9757 | |
| 9758 | parsers = { |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9759 | const.OFPT_HELLO : hello.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9760 | const.OFPT_ERROR : parse_error, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9761 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 9762 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
| 9763 | const.OFPT_EXPERIMENTER : parse_experimenter, |
| 9764 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 9765 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 9766 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 9767 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9768 | const.OFPT_SET_CONFIG : set_config.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9769 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 9770 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 9771 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 9772 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 9773 | const.OFPT_FLOW_MOD : parse_flow_mod, |
| 9774 | const.OFPT_GROUP_MOD : group_mod.unpack, |
| 9775 | const.OFPT_PORT_MOD : port_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9776 | const.OFPT_TABLE_MOD : table_mod.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9777 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 9778 | const.OFPT_STATS_REPLY : parse_stats_reply, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9779 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 9780 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 9781 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 9782 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
| 9783 | const.OFPT_ROLE_REQUEST : role_request.unpack, |
| 9784 | const.OFPT_ROLE_REPLY : role_reply.unpack, |
| 9785 | const.OFPT_GET_ASYNC_REQUEST : async_get_request.unpack, |
| 9786 | const.OFPT_GET_ASYNC_REPLY : async_get_reply.unpack, |
| 9787 | const.OFPT_SET_ASYNC : async_set.unpack, |
| 9788 | const.OFPT_METER_MOD : meter_mod.unpack, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9789 | } |
| 9790 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9791 | error_msg_parsers = { |
| 9792 | const.OFPET_HELLO_FAILED : hello_failed_error_msg.unpack, |
| 9793 | const.OFPET_BAD_REQUEST : bad_request_error_msg.unpack, |
| 9794 | const.OFPET_BAD_ACTION : bad_action_error_msg.unpack, |
| 9795 | const.OFPET_FLOW_MOD_FAILED : flow_mod_failed_error_msg.unpack, |
| 9796 | const.OFPET_PORT_MOD_FAILED : port_mod_failed_error_msg.unpack, |
| 9797 | const.OFPET_QUEUE_OP_FAILED : queue_op_failed_error_msg.unpack, |
| 9798 | const.OFPET_BAD_INSTRUCTION : bad_instruction_error_msg.unpack, |
| 9799 | const.OFPET_BAD_MATCH : bad_match_error_msg.unpack, |
| 9800 | const.OFPET_GROUP_MOD_FAILED : group_mod_failed_error_msg.unpack, |
| 9801 | const.OFPET_TABLE_MOD_FAILED : table_mod_failed_error_msg.unpack, |
| 9802 | const.OFPET_SWITCH_CONFIG_FAILED : switch_config_failed_error_msg.unpack, |
| 9803 | const.OFPET_ROLE_REQUEST_FAILED : role_request_failed_error_msg.unpack, |
| 9804 | const.OFPET_EXPERIMENTER : experimenter_error_msg.unpack, |
| 9805 | const.OFPET_METER_MOD_FAILED : meter_mod_failed_error_msg.unpack, |
| 9806 | const.OFPET_TABLE_FEATURES_FAILED : table_features_failed_error_msg.unpack, |
| 9807 | } |
| 9808 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9809 | flow_mod_parsers = { |
| 9810 | const.OFPFC_ADD : flow_add.unpack, |
| 9811 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 9812 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 9813 | const.OFPFC_DELETE : flow_delete.unpack, |
| 9814 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 9815 | } |
| 9816 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9817 | stats_reply_parsers = { |
| 9818 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 9819 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 9820 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 9821 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 9822 | const.OFPST_PORT : port_stats_reply.unpack, |
| 9823 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
| 9824 | const.OFPST_GROUP : group_stats_reply.unpack, |
| 9825 | const.OFPST_GROUP_DESC : group_desc_stats_reply.unpack, |
| 9826 | const.OFPST_GROUP_FEATURES : group_features_stats_reply.unpack, |
| 9827 | const.OFPST_METER : meter_stats_reply.unpack, |
| 9828 | const.OFPST_METER_CONFIG : meter_config_stats_reply.unpack, |
| 9829 | const.OFPST_METER_FEATURES : meter_features_stats_reply.unpack, |
| 9830 | const.OFPST_TABLE_FEATURES : table_features_stats_reply.unpack, |
| 9831 | const.OFPST_PORT_DESC : port_desc_stats_reply.unpack, |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 9832 | } |
| 9833 | |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9834 | stats_request_parsers = { |
| 9835 | const.OFPST_DESC : desc_stats_request.unpack, |
| 9836 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 9837 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 9838 | const.OFPST_TABLE : table_stats_request.unpack, |
| 9839 | const.OFPST_PORT : port_stats_request.unpack, |
| 9840 | const.OFPST_QUEUE : queue_stats_request.unpack, |
| 9841 | const.OFPST_GROUP : group_stats_request.unpack, |
| 9842 | const.OFPST_GROUP_DESC : group_desc_stats_request.unpack, |
| 9843 | const.OFPST_GROUP_FEATURES : group_features_stats_request.unpack, |
| 9844 | const.OFPST_METER : meter_stats_request.unpack, |
| 9845 | const.OFPST_METER_CONFIG : meter_config_stats_request.unpack, |
| 9846 | const.OFPST_METER_FEATURES : meter_features_stats_request.unpack, |
| 9847 | const.OFPST_TABLE_FEATURES : table_features_stats_request.unpack, |
| 9848 | const.OFPST_PORT_DESC : port_desc_stats_request.unpack, |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 9849 | } |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9850 | |
| 9851 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9852 | 6035143 : { |
| 9853 | 22: bsn_bw_clear_data_reply.unpack, |
| 9854 | 21: bsn_bw_clear_data_request.unpack, |
| 9855 | 20: bsn_bw_enable_get_reply.unpack, |
| 9856 | 19: bsn_bw_enable_get_request.unpack, |
| 9857 | 23: bsn_bw_enable_set_reply.unpack, |
| 9858 | 18: bsn_bw_enable_set_request.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9859 | 40: bsn_flow_idle.unpack, |
| 9860 | 39: bsn_flow_idle_enable_get_reply.unpack, |
| 9861 | 38: bsn_flow_idle_enable_get_request.unpack, |
| 9862 | 37: bsn_flow_idle_enable_set_reply.unpack, |
| 9863 | 36: bsn_flow_idle_enable_set_request.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9864 | 10: bsn_get_interfaces_reply.unpack, |
| 9865 | 9: bsn_get_interfaces_request.unpack, |
| 9866 | 5: bsn_get_mirroring_reply.unpack, |
| 9867 | 4: bsn_get_mirroring_request.unpack, |
Rich Lane | 6f4978c | 2013-10-20 21:33:52 -0700 | [diff] [blame] | 9868 | 34: bsn_pdu_rx_reply.unpack, |
| 9869 | 33: bsn_pdu_rx_request.unpack, |
| 9870 | 35: bsn_pdu_rx_timeout.unpack, |
| 9871 | 32: bsn_pdu_tx_reply.unpack, |
| 9872 | 31: bsn_pdu_tx_request.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 9873 | 3: bsn_set_mirroring.unpack, |
| 9874 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 9875 | 11: bsn_set_pktin_suppression_request.unpack, |
| 9876 | 16: bsn_virtual_port_create_reply.unpack, |
| 9877 | 15: bsn_virtual_port_create_request.unpack, |
| 9878 | 26: bsn_virtual_port_remove_reply.unpack, |
| 9879 | 17: bsn_virtual_port_remove_request.unpack, |
| 9880 | }, |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 9881 | } |