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 | b658ddd | 2013-03-12 10:15:10 -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 util |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 15 | import loxi.generic_util |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 16 | |
| 17 | class Message(object): |
| 18 | version = const.OFP_VERSION |
| 19 | type = None # override in subclass |
| 20 | xid = None |
| 21 | |
| 22 | class aggregate_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 23 | version = 1 |
| 24 | type = 17 |
| 25 | stats_type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 26 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 27 | def __init__(self, xid=None, flags=None, packet_count=None, byte_count=None, flow_count=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 28 | self.xid = xid |
| 29 | if flags != None: |
| 30 | self.flags = flags |
| 31 | else: |
| 32 | self.flags = 0 |
| 33 | if packet_count != None: |
| 34 | self.packet_count = packet_count |
| 35 | else: |
| 36 | self.packet_count = 0 |
| 37 | if byte_count != None: |
| 38 | self.byte_count = byte_count |
| 39 | else: |
| 40 | self.byte_count = 0 |
| 41 | if flow_count != None: |
| 42 | self.flow_count = flow_count |
| 43 | else: |
| 44 | self.flow_count = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 45 | |
| 46 | def pack(self): |
| 47 | packed = [] |
| 48 | packed.append(struct.pack("!B", self.version)) |
| 49 | packed.append(struct.pack("!B", self.type)) |
| 50 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 51 | packed.append(struct.pack("!L", self.xid)) |
| 52 | packed.append(struct.pack("!H", self.stats_type)) |
| 53 | packed.append(struct.pack("!H", self.flags)) |
| 54 | packed.append(struct.pack("!Q", self.packet_count)) |
| 55 | packed.append(struct.pack("!Q", self.byte_count)) |
| 56 | packed.append(struct.pack("!L", self.flow_count)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 57 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 58 | length = sum([len(x) for x in packed]) |
| 59 | packed[2] = struct.pack("!H", length) |
| 60 | return ''.join(packed) |
| 61 | |
| 62 | @staticmethod |
| 63 | def unpack(buf): |
| 64 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 65 | obj = aggregate_stats_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 66 | if type(buf) == loxi.generic_util.OFReader: |
| 67 | reader = buf |
| 68 | else: |
| 69 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 70 | _version = reader.read("!B")[0] |
| 71 | assert(_version == 1) |
| 72 | _type = reader.read("!B")[0] |
| 73 | assert(_type == 17) |
| 74 | _length = reader.read("!H")[0] |
| 75 | obj.xid = reader.read("!L")[0] |
| 76 | _stats_type = reader.read("!H")[0] |
| 77 | assert(_stats_type == 2) |
| 78 | obj.flags = reader.read("!H")[0] |
| 79 | obj.packet_count = reader.read("!Q")[0] |
| 80 | obj.byte_count = reader.read("!Q")[0] |
| 81 | obj.flow_count = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 82 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 83 | return obj |
| 84 | |
| 85 | def __eq__(self, other): |
| 86 | if type(self) != type(other): return False |
| 87 | if self.version != other.version: return False |
| 88 | if self.type != other.type: return False |
| 89 | if self.xid != other.xid: return False |
| 90 | if self.flags != other.flags: return False |
| 91 | if self.packet_count != other.packet_count: return False |
| 92 | if self.byte_count != other.byte_count: return False |
| 93 | if self.flow_count != other.flow_count: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 94 | return True |
| 95 | |
| 96 | def __ne__(self, other): |
| 97 | return not self.__eq__(other) |
| 98 | |
| 99 | def __str__(self): |
| 100 | return self.show() |
| 101 | |
| 102 | def show(self): |
| 103 | import loxi.pp |
| 104 | return loxi.pp.pp(self) |
| 105 | |
| 106 | def pretty_print(self, q): |
| 107 | q.text("aggregate_stats_reply {") |
| 108 | with q.group(): |
| 109 | with q.indent(2): |
| 110 | q.breakable() |
| 111 | q.text("xid = "); |
| 112 | if self.xid != None: |
| 113 | q.text("%#x" % self.xid) |
| 114 | else: |
| 115 | q.text('None') |
| 116 | q.text(","); q.breakable() |
| 117 | q.text("flags = "); |
| 118 | q.text("%#x" % self.flags) |
| 119 | q.text(","); q.breakable() |
| 120 | q.text("packet_count = "); |
| 121 | q.text("%#x" % self.packet_count) |
| 122 | q.text(","); q.breakable() |
| 123 | q.text("byte_count = "); |
| 124 | q.text("%#x" % self.byte_count) |
| 125 | q.text(","); q.breakable() |
| 126 | q.text("flow_count = "); |
| 127 | q.text("%#x" % self.flow_count) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 128 | q.breakable() |
| 129 | q.text('}') |
| 130 | |
| 131 | class aggregate_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 132 | version = 1 |
| 133 | type = 16 |
| 134 | stats_type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 135 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 136 | def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 137 | self.xid = xid |
| 138 | if flags != None: |
| 139 | self.flags = flags |
| 140 | else: |
| 141 | self.flags = 0 |
| 142 | if match != None: |
| 143 | self.match = match |
| 144 | else: |
| 145 | self.match = common.match() |
| 146 | if table_id != None: |
| 147 | self.table_id = table_id |
| 148 | else: |
| 149 | self.table_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 150 | if out_port != None: |
| 151 | self.out_port = out_port |
| 152 | else: |
| 153 | self.out_port = 0 |
| 154 | |
| 155 | def pack(self): |
| 156 | packed = [] |
| 157 | packed.append(struct.pack("!B", self.version)) |
| 158 | packed.append(struct.pack("!B", self.type)) |
| 159 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 160 | packed.append(struct.pack("!L", self.xid)) |
| 161 | packed.append(struct.pack("!H", self.stats_type)) |
| 162 | packed.append(struct.pack("!H", self.flags)) |
| 163 | packed.append(self.match.pack()) |
| 164 | packed.append(struct.pack("!B", self.table_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 165 | packed.append('\x00' * 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 166 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 167 | length = sum([len(x) for x in packed]) |
| 168 | packed[2] = struct.pack("!H", length) |
| 169 | return ''.join(packed) |
| 170 | |
| 171 | @staticmethod |
| 172 | def unpack(buf): |
| 173 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 174 | obj = aggregate_stats_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 175 | if type(buf) == loxi.generic_util.OFReader: |
| 176 | reader = buf |
| 177 | else: |
| 178 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 179 | _version = reader.read("!B")[0] |
| 180 | assert(_version == 1) |
| 181 | _type = reader.read("!B")[0] |
| 182 | assert(_type == 16) |
| 183 | _length = reader.read("!H")[0] |
| 184 | obj.xid = reader.read("!L")[0] |
| 185 | _stats_type = reader.read("!H")[0] |
| 186 | assert(_stats_type == 2) |
| 187 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 188 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 189 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 190 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 191 | obj.out_port = util.unpack_port_no(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 192 | return obj |
| 193 | |
| 194 | def __eq__(self, other): |
| 195 | if type(self) != type(other): return False |
| 196 | if self.version != other.version: return False |
| 197 | if self.type != other.type: return False |
| 198 | if self.xid != other.xid: return False |
| 199 | if self.flags != other.flags: return False |
| 200 | if self.match != other.match: return False |
| 201 | if self.table_id != other.table_id: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 202 | if self.out_port != other.out_port: return False |
| 203 | return True |
| 204 | |
| 205 | def __ne__(self, other): |
| 206 | return not self.__eq__(other) |
| 207 | |
| 208 | def __str__(self): |
| 209 | return self.show() |
| 210 | |
| 211 | def show(self): |
| 212 | import loxi.pp |
| 213 | return loxi.pp.pp(self) |
| 214 | |
| 215 | def pretty_print(self, q): |
| 216 | q.text("aggregate_stats_request {") |
| 217 | with q.group(): |
| 218 | with q.indent(2): |
| 219 | q.breakable() |
| 220 | q.text("xid = "); |
| 221 | if self.xid != None: |
| 222 | q.text("%#x" % self.xid) |
| 223 | else: |
| 224 | q.text('None') |
| 225 | q.text(","); q.breakable() |
| 226 | q.text("flags = "); |
| 227 | q.text("%#x" % self.flags) |
| 228 | q.text(","); q.breakable() |
| 229 | q.text("match = "); |
| 230 | q.pp(self.match) |
| 231 | q.text(","); q.breakable() |
| 232 | q.text("table_id = "); |
| 233 | q.text("%#x" % self.table_id) |
| 234 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 235 | q.text("out_port = "); |
| 236 | q.text(util.pretty_port(self.out_port)) |
| 237 | q.breakable() |
| 238 | q.text('}') |
| 239 | |
| 240 | class barrier_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 241 | version = 1 |
| 242 | type = 19 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 243 | |
| 244 | def __init__(self, xid=None): |
| 245 | self.xid = xid |
| 246 | |
| 247 | def pack(self): |
| 248 | packed = [] |
| 249 | packed.append(struct.pack("!B", self.version)) |
| 250 | packed.append(struct.pack("!B", self.type)) |
| 251 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 252 | packed.append(struct.pack("!L", self.xid)) |
| 253 | length = sum([len(x) for x in packed]) |
| 254 | packed[2] = struct.pack("!H", length) |
| 255 | return ''.join(packed) |
| 256 | |
| 257 | @staticmethod |
| 258 | def unpack(buf): |
| 259 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 260 | obj = barrier_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 261 | if type(buf) == loxi.generic_util.OFReader: |
| 262 | reader = buf |
| 263 | else: |
| 264 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 265 | _version = reader.read("!B")[0] |
| 266 | assert(_version == 1) |
| 267 | _type = reader.read("!B")[0] |
| 268 | assert(_type == 19) |
| 269 | _length = reader.read("!H")[0] |
| 270 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 271 | return obj |
| 272 | |
| 273 | def __eq__(self, other): |
| 274 | if type(self) != type(other): return False |
| 275 | if self.version != other.version: return False |
| 276 | if self.type != other.type: return False |
| 277 | if self.xid != other.xid: return False |
| 278 | return True |
| 279 | |
| 280 | def __ne__(self, other): |
| 281 | return not self.__eq__(other) |
| 282 | |
| 283 | def __str__(self): |
| 284 | return self.show() |
| 285 | |
| 286 | def show(self): |
| 287 | import loxi.pp |
| 288 | return loxi.pp.pp(self) |
| 289 | |
| 290 | def pretty_print(self, q): |
| 291 | q.text("barrier_reply {") |
| 292 | with q.group(): |
| 293 | with q.indent(2): |
| 294 | q.breakable() |
| 295 | q.text("xid = "); |
| 296 | if self.xid != None: |
| 297 | q.text("%#x" % self.xid) |
| 298 | else: |
| 299 | q.text('None') |
| 300 | q.breakable() |
| 301 | q.text('}') |
| 302 | |
| 303 | class barrier_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 304 | version = 1 |
| 305 | type = 18 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 306 | |
| 307 | def __init__(self, xid=None): |
| 308 | self.xid = xid |
| 309 | |
| 310 | def pack(self): |
| 311 | packed = [] |
| 312 | packed.append(struct.pack("!B", self.version)) |
| 313 | packed.append(struct.pack("!B", self.type)) |
| 314 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 315 | packed.append(struct.pack("!L", self.xid)) |
| 316 | length = sum([len(x) for x in packed]) |
| 317 | packed[2] = struct.pack("!H", length) |
| 318 | return ''.join(packed) |
| 319 | |
| 320 | @staticmethod |
| 321 | def unpack(buf): |
| 322 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 323 | obj = barrier_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 324 | if type(buf) == loxi.generic_util.OFReader: |
| 325 | reader = buf |
| 326 | else: |
| 327 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 328 | _version = reader.read("!B")[0] |
| 329 | assert(_version == 1) |
| 330 | _type = reader.read("!B")[0] |
| 331 | assert(_type == 18) |
| 332 | _length = reader.read("!H")[0] |
| 333 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 334 | return obj |
| 335 | |
| 336 | def __eq__(self, other): |
| 337 | if type(self) != type(other): return False |
| 338 | if self.version != other.version: return False |
| 339 | if self.type != other.type: return False |
| 340 | if self.xid != other.xid: return False |
| 341 | return True |
| 342 | |
| 343 | def __ne__(self, other): |
| 344 | return not self.__eq__(other) |
| 345 | |
| 346 | def __str__(self): |
| 347 | return self.show() |
| 348 | |
| 349 | def show(self): |
| 350 | import loxi.pp |
| 351 | return loxi.pp.pp(self) |
| 352 | |
| 353 | def pretty_print(self, q): |
| 354 | q.text("barrier_request {") |
| 355 | with q.group(): |
| 356 | with q.indent(2): |
| 357 | q.breakable() |
| 358 | q.text("xid = "); |
| 359 | if self.xid != None: |
| 360 | q.text("%#x" % self.xid) |
| 361 | else: |
| 362 | q.text('None') |
| 363 | q.breakable() |
| 364 | q.text('}') |
| 365 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 366 | class bsn_bw_clear_data_reply(Message): |
| 367 | version = 1 |
| 368 | type = 4 |
| 369 | experimenter = 6035143 |
| 370 | subtype = 22 |
| 371 | |
| 372 | def __init__(self, xid=None, status=None): |
| 373 | self.xid = xid |
| 374 | if status != None: |
| 375 | self.status = status |
| 376 | else: |
| 377 | self.status = 0 |
| 378 | |
| 379 | def pack(self): |
| 380 | packed = [] |
| 381 | packed.append(struct.pack("!B", self.version)) |
| 382 | packed.append(struct.pack("!B", self.type)) |
| 383 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 384 | packed.append(struct.pack("!L", self.xid)) |
| 385 | packed.append(struct.pack("!L", self.experimenter)) |
| 386 | packed.append(struct.pack("!L", self.subtype)) |
| 387 | packed.append(struct.pack("!L", self.status)) |
| 388 | length = sum([len(x) for x in packed]) |
| 389 | packed[2] = struct.pack("!H", length) |
| 390 | return ''.join(packed) |
| 391 | |
| 392 | @staticmethod |
| 393 | def unpack(buf): |
| 394 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 395 | obj = bsn_bw_clear_data_reply() |
| 396 | if type(buf) == loxi.generic_util.OFReader: |
| 397 | reader = buf |
| 398 | else: |
| 399 | reader = loxi.generic_util.OFReader(buf) |
| 400 | _version = reader.read("!B")[0] |
| 401 | assert(_version == 1) |
| 402 | _type = reader.read("!B")[0] |
| 403 | assert(_type == 4) |
| 404 | _length = reader.read("!H")[0] |
| 405 | obj.xid = reader.read("!L")[0] |
| 406 | _experimenter = reader.read("!L")[0] |
| 407 | assert(_experimenter == 6035143) |
| 408 | _subtype = reader.read("!L")[0] |
| 409 | assert(_subtype == 22) |
| 410 | obj.status = reader.read("!L")[0] |
| 411 | return obj |
| 412 | |
| 413 | def __eq__(self, other): |
| 414 | if type(self) != type(other): return False |
| 415 | if self.version != other.version: return False |
| 416 | if self.type != other.type: return False |
| 417 | if self.xid != other.xid: return False |
| 418 | if self.status != other.status: return False |
| 419 | return True |
| 420 | |
| 421 | def __ne__(self, other): |
| 422 | return not self.__eq__(other) |
| 423 | |
| 424 | def __str__(self): |
| 425 | return self.show() |
| 426 | |
| 427 | def show(self): |
| 428 | import loxi.pp |
| 429 | return loxi.pp.pp(self) |
| 430 | |
| 431 | def pretty_print(self, q): |
| 432 | q.text("bsn_bw_clear_data_reply {") |
| 433 | with q.group(): |
| 434 | with q.indent(2): |
| 435 | q.breakable() |
| 436 | q.text("xid = "); |
| 437 | if self.xid != None: |
| 438 | q.text("%#x" % self.xid) |
| 439 | else: |
| 440 | q.text('None') |
| 441 | q.text(","); q.breakable() |
| 442 | q.text("status = "); |
| 443 | q.text("%#x" % self.status) |
| 444 | q.breakable() |
| 445 | q.text('}') |
| 446 | |
| 447 | class bsn_bw_clear_data_request(Message): |
| 448 | version = 1 |
| 449 | type = 4 |
| 450 | experimenter = 6035143 |
| 451 | subtype = 21 |
| 452 | |
| 453 | def __init__(self, xid=None): |
| 454 | self.xid = xid |
| 455 | |
| 456 | def pack(self): |
| 457 | packed = [] |
| 458 | packed.append(struct.pack("!B", self.version)) |
| 459 | packed.append(struct.pack("!B", self.type)) |
| 460 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 461 | packed.append(struct.pack("!L", self.xid)) |
| 462 | packed.append(struct.pack("!L", self.experimenter)) |
| 463 | packed.append(struct.pack("!L", self.subtype)) |
| 464 | length = sum([len(x) for x in packed]) |
| 465 | packed[2] = struct.pack("!H", length) |
| 466 | return ''.join(packed) |
| 467 | |
| 468 | @staticmethod |
| 469 | def unpack(buf): |
| 470 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 471 | obj = bsn_bw_clear_data_request() |
| 472 | if type(buf) == loxi.generic_util.OFReader: |
| 473 | reader = buf |
| 474 | else: |
| 475 | reader = loxi.generic_util.OFReader(buf) |
| 476 | _version = reader.read("!B")[0] |
| 477 | assert(_version == 1) |
| 478 | _type = reader.read("!B")[0] |
| 479 | assert(_type == 4) |
| 480 | _length = reader.read("!H")[0] |
| 481 | obj.xid = reader.read("!L")[0] |
| 482 | _experimenter = reader.read("!L")[0] |
| 483 | assert(_experimenter == 6035143) |
| 484 | _subtype = reader.read("!L")[0] |
| 485 | assert(_subtype == 21) |
| 486 | return obj |
| 487 | |
| 488 | def __eq__(self, other): |
| 489 | if type(self) != type(other): return False |
| 490 | if self.version != other.version: return False |
| 491 | if self.type != other.type: return False |
| 492 | if self.xid != other.xid: return False |
| 493 | return True |
| 494 | |
| 495 | def __ne__(self, other): |
| 496 | return not self.__eq__(other) |
| 497 | |
| 498 | def __str__(self): |
| 499 | return self.show() |
| 500 | |
| 501 | def show(self): |
| 502 | import loxi.pp |
| 503 | return loxi.pp.pp(self) |
| 504 | |
| 505 | def pretty_print(self, q): |
| 506 | q.text("bsn_bw_clear_data_request {") |
| 507 | with q.group(): |
| 508 | with q.indent(2): |
| 509 | q.breakable() |
| 510 | q.text("xid = "); |
| 511 | if self.xid != None: |
| 512 | q.text("%#x" % self.xid) |
| 513 | else: |
| 514 | q.text('None') |
| 515 | q.breakable() |
| 516 | q.text('}') |
| 517 | |
| 518 | class bsn_bw_enable_get_reply(Message): |
| 519 | version = 1 |
| 520 | type = 4 |
| 521 | experimenter = 6035143 |
| 522 | subtype = 20 |
| 523 | |
| 524 | def __init__(self, xid=None, enabled=None): |
| 525 | self.xid = xid |
| 526 | if enabled != None: |
| 527 | self.enabled = enabled |
| 528 | else: |
| 529 | self.enabled = 0 |
| 530 | |
| 531 | def pack(self): |
| 532 | packed = [] |
| 533 | packed.append(struct.pack("!B", self.version)) |
| 534 | packed.append(struct.pack("!B", self.type)) |
| 535 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 536 | packed.append(struct.pack("!L", self.xid)) |
| 537 | packed.append(struct.pack("!L", self.experimenter)) |
| 538 | packed.append(struct.pack("!L", self.subtype)) |
| 539 | packed.append(struct.pack("!L", self.enabled)) |
| 540 | length = sum([len(x) for x in packed]) |
| 541 | packed[2] = struct.pack("!H", length) |
| 542 | return ''.join(packed) |
| 543 | |
| 544 | @staticmethod |
| 545 | def unpack(buf): |
| 546 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 547 | obj = bsn_bw_enable_get_reply() |
| 548 | if type(buf) == loxi.generic_util.OFReader: |
| 549 | reader = buf |
| 550 | else: |
| 551 | reader = loxi.generic_util.OFReader(buf) |
| 552 | _version = reader.read("!B")[0] |
| 553 | assert(_version == 1) |
| 554 | _type = reader.read("!B")[0] |
| 555 | assert(_type == 4) |
| 556 | _length = reader.read("!H")[0] |
| 557 | obj.xid = reader.read("!L")[0] |
| 558 | _experimenter = reader.read("!L")[0] |
| 559 | assert(_experimenter == 6035143) |
| 560 | _subtype = reader.read("!L")[0] |
| 561 | assert(_subtype == 20) |
| 562 | obj.enabled = reader.read("!L")[0] |
| 563 | return obj |
| 564 | |
| 565 | def __eq__(self, other): |
| 566 | if type(self) != type(other): return False |
| 567 | if self.version != other.version: return False |
| 568 | if self.type != other.type: return False |
| 569 | if self.xid != other.xid: return False |
| 570 | if self.enabled != other.enabled: return False |
| 571 | return True |
| 572 | |
| 573 | def __ne__(self, other): |
| 574 | return not self.__eq__(other) |
| 575 | |
| 576 | def __str__(self): |
| 577 | return self.show() |
| 578 | |
| 579 | def show(self): |
| 580 | import loxi.pp |
| 581 | return loxi.pp.pp(self) |
| 582 | |
| 583 | def pretty_print(self, q): |
| 584 | q.text("bsn_bw_enable_get_reply {") |
| 585 | with q.group(): |
| 586 | with q.indent(2): |
| 587 | q.breakable() |
| 588 | q.text("xid = "); |
| 589 | if self.xid != None: |
| 590 | q.text("%#x" % self.xid) |
| 591 | else: |
| 592 | q.text('None') |
| 593 | q.text(","); q.breakable() |
| 594 | q.text("enabled = "); |
| 595 | q.text("%#x" % self.enabled) |
| 596 | q.breakable() |
| 597 | q.text('}') |
| 598 | |
| 599 | class bsn_bw_enable_get_request(Message): |
| 600 | version = 1 |
| 601 | type = 4 |
| 602 | experimenter = 6035143 |
| 603 | subtype = 19 |
| 604 | |
| 605 | def __init__(self, xid=None): |
| 606 | self.xid = xid |
| 607 | |
| 608 | def pack(self): |
| 609 | packed = [] |
| 610 | packed.append(struct.pack("!B", self.version)) |
| 611 | packed.append(struct.pack("!B", self.type)) |
| 612 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 613 | packed.append(struct.pack("!L", self.xid)) |
| 614 | packed.append(struct.pack("!L", self.experimenter)) |
| 615 | packed.append(struct.pack("!L", self.subtype)) |
| 616 | length = sum([len(x) for x in packed]) |
| 617 | packed[2] = struct.pack("!H", length) |
| 618 | return ''.join(packed) |
| 619 | |
| 620 | @staticmethod |
| 621 | def unpack(buf): |
| 622 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 623 | obj = bsn_bw_enable_get_request() |
| 624 | if type(buf) == loxi.generic_util.OFReader: |
| 625 | reader = buf |
| 626 | else: |
| 627 | reader = loxi.generic_util.OFReader(buf) |
| 628 | _version = reader.read("!B")[0] |
| 629 | assert(_version == 1) |
| 630 | _type = reader.read("!B")[0] |
| 631 | assert(_type == 4) |
| 632 | _length = reader.read("!H")[0] |
| 633 | obj.xid = reader.read("!L")[0] |
| 634 | _experimenter = reader.read("!L")[0] |
| 635 | assert(_experimenter == 6035143) |
| 636 | _subtype = reader.read("!L")[0] |
| 637 | assert(_subtype == 19) |
| 638 | return obj |
| 639 | |
| 640 | def __eq__(self, other): |
| 641 | if type(self) != type(other): return False |
| 642 | if self.version != other.version: return False |
| 643 | if self.type != other.type: return False |
| 644 | if self.xid != other.xid: return False |
| 645 | return True |
| 646 | |
| 647 | def __ne__(self, other): |
| 648 | return not self.__eq__(other) |
| 649 | |
| 650 | def __str__(self): |
| 651 | return self.show() |
| 652 | |
| 653 | def show(self): |
| 654 | import loxi.pp |
| 655 | return loxi.pp.pp(self) |
| 656 | |
| 657 | def pretty_print(self, q): |
| 658 | q.text("bsn_bw_enable_get_request {") |
| 659 | with q.group(): |
| 660 | with q.indent(2): |
| 661 | q.breakable() |
| 662 | q.text("xid = "); |
| 663 | if self.xid != None: |
| 664 | q.text("%#x" % self.xid) |
| 665 | else: |
| 666 | q.text('None') |
| 667 | q.breakable() |
| 668 | q.text('}') |
| 669 | |
| 670 | class bsn_bw_enable_set_reply(Message): |
| 671 | version = 1 |
| 672 | type = 4 |
| 673 | experimenter = 6035143 |
| 674 | subtype = 23 |
| 675 | |
| 676 | def __init__(self, xid=None, enable=None, status=None): |
| 677 | self.xid = xid |
| 678 | if enable != None: |
| 679 | self.enable = enable |
| 680 | else: |
| 681 | self.enable = 0 |
| 682 | if status != None: |
| 683 | self.status = status |
| 684 | else: |
| 685 | self.status = 0 |
| 686 | |
| 687 | def pack(self): |
| 688 | packed = [] |
| 689 | packed.append(struct.pack("!B", self.version)) |
| 690 | packed.append(struct.pack("!B", self.type)) |
| 691 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 692 | packed.append(struct.pack("!L", self.xid)) |
| 693 | packed.append(struct.pack("!L", self.experimenter)) |
| 694 | packed.append(struct.pack("!L", self.subtype)) |
| 695 | packed.append(struct.pack("!L", self.enable)) |
| 696 | packed.append(struct.pack("!L", self.status)) |
| 697 | length = sum([len(x) for x in packed]) |
| 698 | packed[2] = struct.pack("!H", length) |
| 699 | return ''.join(packed) |
| 700 | |
| 701 | @staticmethod |
| 702 | def unpack(buf): |
| 703 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 704 | obj = bsn_bw_enable_set_reply() |
| 705 | if type(buf) == loxi.generic_util.OFReader: |
| 706 | reader = buf |
| 707 | else: |
| 708 | reader = loxi.generic_util.OFReader(buf) |
| 709 | _version = reader.read("!B")[0] |
| 710 | assert(_version == 1) |
| 711 | _type = reader.read("!B")[0] |
| 712 | assert(_type == 4) |
| 713 | _length = reader.read("!H")[0] |
| 714 | obj.xid = reader.read("!L")[0] |
| 715 | _experimenter = reader.read("!L")[0] |
| 716 | assert(_experimenter == 6035143) |
| 717 | _subtype = reader.read("!L")[0] |
| 718 | assert(_subtype == 23) |
| 719 | obj.enable = reader.read("!L")[0] |
| 720 | obj.status = reader.read("!L")[0] |
| 721 | return obj |
| 722 | |
| 723 | def __eq__(self, other): |
| 724 | if type(self) != type(other): return False |
| 725 | if self.version != other.version: return False |
| 726 | if self.type != other.type: return False |
| 727 | if self.xid != other.xid: return False |
| 728 | if self.enable != other.enable: return False |
| 729 | if self.status != other.status: return False |
| 730 | return True |
| 731 | |
| 732 | def __ne__(self, other): |
| 733 | return not self.__eq__(other) |
| 734 | |
| 735 | def __str__(self): |
| 736 | return self.show() |
| 737 | |
| 738 | def show(self): |
| 739 | import loxi.pp |
| 740 | return loxi.pp.pp(self) |
| 741 | |
| 742 | def pretty_print(self, q): |
| 743 | q.text("bsn_bw_enable_set_reply {") |
| 744 | with q.group(): |
| 745 | with q.indent(2): |
| 746 | q.breakable() |
| 747 | q.text("xid = "); |
| 748 | if self.xid != None: |
| 749 | q.text("%#x" % self.xid) |
| 750 | else: |
| 751 | q.text('None') |
| 752 | q.text(","); q.breakable() |
| 753 | q.text("enable = "); |
| 754 | q.text("%#x" % self.enable) |
| 755 | q.text(","); q.breakable() |
| 756 | q.text("status = "); |
| 757 | q.text("%#x" % self.status) |
| 758 | q.breakable() |
| 759 | q.text('}') |
| 760 | |
| 761 | class bsn_bw_enable_set_request(Message): |
| 762 | version = 1 |
| 763 | type = 4 |
| 764 | experimenter = 6035143 |
| 765 | subtype = 18 |
| 766 | |
| 767 | def __init__(self, xid=None, enable=None): |
| 768 | self.xid = xid |
| 769 | if enable != None: |
| 770 | self.enable = enable |
| 771 | else: |
| 772 | self.enable = 0 |
| 773 | |
| 774 | def pack(self): |
| 775 | packed = [] |
| 776 | packed.append(struct.pack("!B", self.version)) |
| 777 | packed.append(struct.pack("!B", self.type)) |
| 778 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 779 | packed.append(struct.pack("!L", self.xid)) |
| 780 | packed.append(struct.pack("!L", self.experimenter)) |
| 781 | packed.append(struct.pack("!L", self.subtype)) |
| 782 | packed.append(struct.pack("!L", self.enable)) |
| 783 | length = sum([len(x) for x in packed]) |
| 784 | packed[2] = struct.pack("!H", length) |
| 785 | return ''.join(packed) |
| 786 | |
| 787 | @staticmethod |
| 788 | def unpack(buf): |
| 789 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 790 | obj = bsn_bw_enable_set_request() |
| 791 | if type(buf) == loxi.generic_util.OFReader: |
| 792 | reader = buf |
| 793 | else: |
| 794 | reader = loxi.generic_util.OFReader(buf) |
| 795 | _version = reader.read("!B")[0] |
| 796 | assert(_version == 1) |
| 797 | _type = reader.read("!B")[0] |
| 798 | assert(_type == 4) |
| 799 | _length = reader.read("!H")[0] |
| 800 | obj.xid = reader.read("!L")[0] |
| 801 | _experimenter = reader.read("!L")[0] |
| 802 | assert(_experimenter == 6035143) |
| 803 | _subtype = reader.read("!L")[0] |
| 804 | assert(_subtype == 18) |
| 805 | obj.enable = reader.read("!L")[0] |
| 806 | return obj |
| 807 | |
| 808 | def __eq__(self, other): |
| 809 | if type(self) != type(other): return False |
| 810 | if self.version != other.version: return False |
| 811 | if self.type != other.type: return False |
| 812 | if self.xid != other.xid: return False |
| 813 | if self.enable != other.enable: return False |
| 814 | return True |
| 815 | |
| 816 | def __ne__(self, other): |
| 817 | return not self.__eq__(other) |
| 818 | |
| 819 | def __str__(self): |
| 820 | return self.show() |
| 821 | |
| 822 | def show(self): |
| 823 | import loxi.pp |
| 824 | return loxi.pp.pp(self) |
| 825 | |
| 826 | def pretty_print(self, q): |
| 827 | q.text("bsn_bw_enable_set_request {") |
| 828 | with q.group(): |
| 829 | with q.indent(2): |
| 830 | q.breakable() |
| 831 | q.text("xid = "); |
| 832 | if self.xid != None: |
| 833 | q.text("%#x" % self.xid) |
| 834 | else: |
| 835 | q.text('None') |
| 836 | q.text(","); q.breakable() |
| 837 | q.text("enable = "); |
| 838 | q.text("%#x" % self.enable) |
| 839 | q.breakable() |
| 840 | q.text('}') |
| 841 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 842 | class bsn_get_interfaces_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 843 | version = 1 |
| 844 | type = 4 |
| 845 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 846 | subtype = 10 |
| 847 | |
| 848 | def __init__(self, xid=None, interfaces=None): |
| 849 | self.xid = xid |
| 850 | if interfaces != None: |
| 851 | self.interfaces = interfaces |
| 852 | else: |
| 853 | self.interfaces = [] |
| 854 | |
| 855 | def pack(self): |
| 856 | packed = [] |
| 857 | packed.append(struct.pack("!B", self.version)) |
| 858 | packed.append(struct.pack("!B", self.type)) |
| 859 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 860 | packed.append(struct.pack("!L", self.xid)) |
| 861 | packed.append(struct.pack("!L", self.experimenter)) |
| 862 | packed.append(struct.pack("!L", self.subtype)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 863 | packed.append(util.pack_list(self.interfaces)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 864 | length = sum([len(x) for x in packed]) |
| 865 | packed[2] = struct.pack("!H", length) |
| 866 | return ''.join(packed) |
| 867 | |
| 868 | @staticmethod |
| 869 | def unpack(buf): |
| 870 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 871 | obj = bsn_get_interfaces_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 872 | if type(buf) == loxi.generic_util.OFReader: |
| 873 | reader = buf |
| 874 | else: |
| 875 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 876 | _version = reader.read("!B")[0] |
| 877 | assert(_version == 1) |
| 878 | _type = reader.read("!B")[0] |
| 879 | assert(_type == 4) |
| 880 | _length = reader.read("!H")[0] |
| 881 | obj.xid = reader.read("!L")[0] |
| 882 | _experimenter = reader.read("!L")[0] |
| 883 | assert(_experimenter == 6035143) |
| 884 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 885 | assert(_subtype == 10) |
| 886 | obj.interfaces = loxi.generic_util.unpack_list(reader, common.bsn_interface.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 887 | return obj |
| 888 | |
| 889 | def __eq__(self, other): |
| 890 | if type(self) != type(other): return False |
| 891 | if self.version != other.version: return False |
| 892 | if self.type != other.type: return False |
| 893 | if self.xid != other.xid: return False |
| 894 | if self.interfaces != other.interfaces: return False |
| 895 | return True |
| 896 | |
| 897 | def __ne__(self, other): |
| 898 | return not self.__eq__(other) |
| 899 | |
| 900 | def __str__(self): |
| 901 | return self.show() |
| 902 | |
| 903 | def show(self): |
| 904 | import loxi.pp |
| 905 | return loxi.pp.pp(self) |
| 906 | |
| 907 | def pretty_print(self, q): |
| 908 | q.text("bsn_get_interfaces_reply {") |
| 909 | with q.group(): |
| 910 | with q.indent(2): |
| 911 | q.breakable() |
| 912 | q.text("xid = "); |
| 913 | if self.xid != None: |
| 914 | q.text("%#x" % self.xid) |
| 915 | else: |
| 916 | q.text('None') |
| 917 | q.text(","); q.breakable() |
| 918 | q.text("interfaces = "); |
| 919 | q.pp(self.interfaces) |
| 920 | q.breakable() |
| 921 | q.text('}') |
| 922 | |
| 923 | class bsn_get_interfaces_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 924 | version = 1 |
| 925 | type = 4 |
| 926 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 927 | subtype = 9 |
| 928 | |
| 929 | def __init__(self, xid=None): |
| 930 | self.xid = xid |
| 931 | |
| 932 | def pack(self): |
| 933 | packed = [] |
| 934 | packed.append(struct.pack("!B", self.version)) |
| 935 | packed.append(struct.pack("!B", self.type)) |
| 936 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 937 | packed.append(struct.pack("!L", self.xid)) |
| 938 | packed.append(struct.pack("!L", self.experimenter)) |
| 939 | packed.append(struct.pack("!L", self.subtype)) |
| 940 | length = sum([len(x) for x in packed]) |
| 941 | packed[2] = struct.pack("!H", length) |
| 942 | return ''.join(packed) |
| 943 | |
| 944 | @staticmethod |
| 945 | def unpack(buf): |
| 946 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 947 | obj = bsn_get_interfaces_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 948 | if type(buf) == loxi.generic_util.OFReader: |
| 949 | reader = buf |
| 950 | else: |
| 951 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 952 | _version = reader.read("!B")[0] |
| 953 | assert(_version == 1) |
| 954 | _type = reader.read("!B")[0] |
| 955 | assert(_type == 4) |
| 956 | _length = reader.read("!H")[0] |
| 957 | obj.xid = reader.read("!L")[0] |
| 958 | _experimenter = reader.read("!L")[0] |
| 959 | assert(_experimenter == 6035143) |
| 960 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 961 | assert(_subtype == 9) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 962 | return obj |
| 963 | |
| 964 | def __eq__(self, other): |
| 965 | if type(self) != type(other): return False |
| 966 | if self.version != other.version: return False |
| 967 | if self.type != other.type: return False |
| 968 | if self.xid != other.xid: return False |
| 969 | return True |
| 970 | |
| 971 | def __ne__(self, other): |
| 972 | return not self.__eq__(other) |
| 973 | |
| 974 | def __str__(self): |
| 975 | return self.show() |
| 976 | |
| 977 | def show(self): |
| 978 | import loxi.pp |
| 979 | return loxi.pp.pp(self) |
| 980 | |
| 981 | def pretty_print(self, q): |
| 982 | q.text("bsn_get_interfaces_request {") |
| 983 | with q.group(): |
| 984 | with q.indent(2): |
| 985 | q.breakable() |
| 986 | q.text("xid = "); |
| 987 | if self.xid != None: |
| 988 | q.text("%#x" % self.xid) |
| 989 | else: |
| 990 | q.text('None') |
| 991 | q.breakable() |
| 992 | q.text('}') |
| 993 | |
| 994 | class bsn_get_ip_mask_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 995 | version = 1 |
| 996 | type = 4 |
| 997 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 998 | subtype = 2 |
| 999 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1000 | def __init__(self, xid=None, index=None, mask=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1001 | self.xid = xid |
| 1002 | if index != None: |
| 1003 | self.index = index |
| 1004 | else: |
| 1005 | self.index = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1006 | if mask != None: |
| 1007 | self.mask = mask |
| 1008 | else: |
| 1009 | self.mask = 0 |
| 1010 | |
| 1011 | def pack(self): |
| 1012 | packed = [] |
| 1013 | packed.append(struct.pack("!B", self.version)) |
| 1014 | packed.append(struct.pack("!B", self.type)) |
| 1015 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1016 | packed.append(struct.pack("!L", self.xid)) |
| 1017 | packed.append(struct.pack("!L", self.experimenter)) |
| 1018 | packed.append(struct.pack("!L", self.subtype)) |
| 1019 | packed.append(struct.pack("!B", self.index)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1020 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1021 | packed.append(struct.pack("!L", self.mask)) |
| 1022 | length = sum([len(x) for x in packed]) |
| 1023 | packed[2] = struct.pack("!H", length) |
| 1024 | return ''.join(packed) |
| 1025 | |
| 1026 | @staticmethod |
| 1027 | def unpack(buf): |
| 1028 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1029 | obj = bsn_get_ip_mask_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1030 | if type(buf) == loxi.generic_util.OFReader: |
| 1031 | reader = buf |
| 1032 | else: |
| 1033 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1034 | _version = reader.read("!B")[0] |
| 1035 | assert(_version == 1) |
| 1036 | _type = reader.read("!B")[0] |
| 1037 | assert(_type == 4) |
| 1038 | _length = reader.read("!H")[0] |
| 1039 | obj.xid = reader.read("!L")[0] |
| 1040 | _experimenter = reader.read("!L")[0] |
| 1041 | assert(_experimenter == 6035143) |
| 1042 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1043 | assert(_subtype == 2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1044 | obj.index = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1045 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1046 | obj.mask = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1047 | return obj |
| 1048 | |
| 1049 | def __eq__(self, other): |
| 1050 | if type(self) != type(other): return False |
| 1051 | if self.version != other.version: return False |
| 1052 | if self.type != other.type: return False |
| 1053 | if self.xid != other.xid: return False |
| 1054 | if self.index != other.index: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1055 | if self.mask != other.mask: return False |
| 1056 | return True |
| 1057 | |
| 1058 | def __ne__(self, other): |
| 1059 | return not self.__eq__(other) |
| 1060 | |
| 1061 | def __str__(self): |
| 1062 | return self.show() |
| 1063 | |
| 1064 | def show(self): |
| 1065 | import loxi.pp |
| 1066 | return loxi.pp.pp(self) |
| 1067 | |
| 1068 | def pretty_print(self, q): |
| 1069 | q.text("bsn_get_ip_mask_reply {") |
| 1070 | with q.group(): |
| 1071 | with q.indent(2): |
| 1072 | q.breakable() |
| 1073 | q.text("xid = "); |
| 1074 | if self.xid != None: |
| 1075 | q.text("%#x" % self.xid) |
| 1076 | else: |
| 1077 | q.text('None') |
| 1078 | q.text(","); q.breakable() |
| 1079 | q.text("index = "); |
| 1080 | q.text("%#x" % self.index) |
| 1081 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1082 | q.text("mask = "); |
| 1083 | q.text("%#x" % self.mask) |
| 1084 | q.breakable() |
| 1085 | q.text('}') |
| 1086 | |
| 1087 | class bsn_get_ip_mask_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1088 | version = 1 |
| 1089 | type = 4 |
| 1090 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1091 | subtype = 1 |
| 1092 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1093 | def __init__(self, xid=None, index=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1094 | self.xid = xid |
| 1095 | if index != None: |
| 1096 | self.index = index |
| 1097 | else: |
| 1098 | self.index = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1099 | |
| 1100 | def pack(self): |
| 1101 | packed = [] |
| 1102 | packed.append(struct.pack("!B", self.version)) |
| 1103 | packed.append(struct.pack("!B", self.type)) |
| 1104 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1105 | packed.append(struct.pack("!L", self.xid)) |
| 1106 | packed.append(struct.pack("!L", self.experimenter)) |
| 1107 | packed.append(struct.pack("!L", self.subtype)) |
| 1108 | packed.append(struct.pack("!B", self.index)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1109 | packed.append('\x00' * 7) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1110 | length = sum([len(x) for x in packed]) |
| 1111 | packed[2] = struct.pack("!H", length) |
| 1112 | return ''.join(packed) |
| 1113 | |
| 1114 | @staticmethod |
| 1115 | def unpack(buf): |
| 1116 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1117 | obj = bsn_get_ip_mask_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1118 | if type(buf) == loxi.generic_util.OFReader: |
| 1119 | reader = buf |
| 1120 | else: |
| 1121 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1122 | _version = reader.read("!B")[0] |
| 1123 | assert(_version == 1) |
| 1124 | _type = reader.read("!B")[0] |
| 1125 | assert(_type == 4) |
| 1126 | _length = reader.read("!H")[0] |
| 1127 | obj.xid = reader.read("!L")[0] |
| 1128 | _experimenter = reader.read("!L")[0] |
| 1129 | assert(_experimenter == 6035143) |
| 1130 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1131 | assert(_subtype == 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1132 | obj.index = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1133 | reader.skip(7) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1134 | return obj |
| 1135 | |
| 1136 | def __eq__(self, other): |
| 1137 | if type(self) != type(other): return False |
| 1138 | if self.version != other.version: return False |
| 1139 | if self.type != other.type: return False |
| 1140 | if self.xid != other.xid: return False |
| 1141 | if self.index != other.index: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1142 | return True |
| 1143 | |
| 1144 | def __ne__(self, other): |
| 1145 | return not self.__eq__(other) |
| 1146 | |
| 1147 | def __str__(self): |
| 1148 | return self.show() |
| 1149 | |
| 1150 | def show(self): |
| 1151 | import loxi.pp |
| 1152 | return loxi.pp.pp(self) |
| 1153 | |
| 1154 | def pretty_print(self, q): |
| 1155 | q.text("bsn_get_ip_mask_request {") |
| 1156 | with q.group(): |
| 1157 | with q.indent(2): |
| 1158 | q.breakable() |
| 1159 | q.text("xid = "); |
| 1160 | if self.xid != None: |
| 1161 | q.text("%#x" % self.xid) |
| 1162 | else: |
| 1163 | q.text('None') |
| 1164 | q.text(","); q.breakable() |
| 1165 | q.text("index = "); |
| 1166 | q.text("%#x" % self.index) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1167 | q.breakable() |
| 1168 | q.text('}') |
| 1169 | |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1170 | class bsn_get_l2_table_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1171 | version = 1 |
| 1172 | type = 4 |
| 1173 | experimenter = 6035143 |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1174 | subtype = 14 |
| 1175 | |
| 1176 | def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None): |
| 1177 | self.xid = xid |
| 1178 | if l2_table_enable != None: |
| 1179 | self.l2_table_enable = l2_table_enable |
| 1180 | else: |
| 1181 | self.l2_table_enable = 0 |
| 1182 | if l2_table_priority != None: |
| 1183 | self.l2_table_priority = l2_table_priority |
| 1184 | else: |
| 1185 | self.l2_table_priority = 0 |
| 1186 | |
| 1187 | def pack(self): |
| 1188 | packed = [] |
| 1189 | packed.append(struct.pack("!B", self.version)) |
| 1190 | packed.append(struct.pack("!B", self.type)) |
| 1191 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1192 | packed.append(struct.pack("!L", self.xid)) |
| 1193 | packed.append(struct.pack("!L", self.experimenter)) |
| 1194 | packed.append(struct.pack("!L", self.subtype)) |
| 1195 | packed.append(struct.pack("!B", self.l2_table_enable)) |
| 1196 | packed.append('\x00' * 1) |
| 1197 | packed.append(struct.pack("!H", self.l2_table_priority)) |
| 1198 | packed.append('\x00' * 4) |
| 1199 | length = sum([len(x) for x in packed]) |
| 1200 | packed[2] = struct.pack("!H", length) |
| 1201 | return ''.join(packed) |
| 1202 | |
| 1203 | @staticmethod |
| 1204 | def unpack(buf): |
| 1205 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1206 | obj = bsn_get_l2_table_reply() |
| 1207 | if type(buf) == loxi.generic_util.OFReader: |
| 1208 | reader = buf |
| 1209 | else: |
| 1210 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1211 | _version = reader.read("!B")[0] |
| 1212 | assert(_version == 1) |
| 1213 | _type = reader.read("!B")[0] |
| 1214 | assert(_type == 4) |
| 1215 | _length = reader.read("!H")[0] |
| 1216 | obj.xid = reader.read("!L")[0] |
| 1217 | _experimenter = reader.read("!L")[0] |
| 1218 | assert(_experimenter == 6035143) |
| 1219 | _subtype = reader.read("!L")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1220 | assert(_subtype == 14) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1221 | obj.l2_table_enable = reader.read("!B")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1222 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1223 | obj.l2_table_priority = reader.read("!H")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1224 | reader.skip(4) |
| 1225 | return obj |
| 1226 | |
| 1227 | def __eq__(self, other): |
| 1228 | if type(self) != type(other): return False |
| 1229 | if self.version != other.version: return False |
| 1230 | if self.type != other.type: return False |
| 1231 | if self.xid != other.xid: return False |
| 1232 | if self.l2_table_enable != other.l2_table_enable: return False |
| 1233 | if self.l2_table_priority != other.l2_table_priority: return False |
| 1234 | return True |
| 1235 | |
| 1236 | def __ne__(self, other): |
| 1237 | return not self.__eq__(other) |
| 1238 | |
| 1239 | def __str__(self): |
| 1240 | return self.show() |
| 1241 | |
| 1242 | def show(self): |
| 1243 | import loxi.pp |
| 1244 | return loxi.pp.pp(self) |
| 1245 | |
| 1246 | def pretty_print(self, q): |
| 1247 | q.text("bsn_get_l2_table_reply {") |
| 1248 | with q.group(): |
| 1249 | with q.indent(2): |
| 1250 | q.breakable() |
| 1251 | q.text("xid = "); |
| 1252 | if self.xid != None: |
| 1253 | q.text("%#x" % self.xid) |
| 1254 | else: |
| 1255 | q.text('None') |
| 1256 | q.text(","); q.breakable() |
| 1257 | q.text("l2_table_enable = "); |
| 1258 | q.text("%#x" % self.l2_table_enable) |
| 1259 | q.text(","); q.breakable() |
| 1260 | q.text("l2_table_priority = "); |
| 1261 | q.text("%#x" % self.l2_table_priority) |
| 1262 | q.breakable() |
| 1263 | q.text('}') |
| 1264 | |
| 1265 | class bsn_get_l2_table_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1266 | version = 1 |
| 1267 | type = 4 |
| 1268 | experimenter = 6035143 |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1269 | subtype = 13 |
| 1270 | |
| 1271 | def __init__(self, xid=None): |
| 1272 | self.xid = xid |
| 1273 | |
| 1274 | def pack(self): |
| 1275 | packed = [] |
| 1276 | packed.append(struct.pack("!B", self.version)) |
| 1277 | packed.append(struct.pack("!B", self.type)) |
| 1278 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1279 | packed.append(struct.pack("!L", self.xid)) |
| 1280 | packed.append(struct.pack("!L", self.experimenter)) |
| 1281 | packed.append(struct.pack("!L", self.subtype)) |
| 1282 | length = sum([len(x) for x in packed]) |
| 1283 | packed[2] = struct.pack("!H", length) |
| 1284 | return ''.join(packed) |
| 1285 | |
| 1286 | @staticmethod |
| 1287 | def unpack(buf): |
| 1288 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1289 | obj = bsn_get_l2_table_request() |
| 1290 | if type(buf) == loxi.generic_util.OFReader: |
| 1291 | reader = buf |
| 1292 | else: |
| 1293 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1294 | _version = reader.read("!B")[0] |
| 1295 | assert(_version == 1) |
| 1296 | _type = reader.read("!B")[0] |
| 1297 | assert(_type == 4) |
| 1298 | _length = reader.read("!H")[0] |
| 1299 | obj.xid = reader.read("!L")[0] |
| 1300 | _experimenter = reader.read("!L")[0] |
| 1301 | assert(_experimenter == 6035143) |
| 1302 | _subtype = reader.read("!L")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1303 | assert(_subtype == 13) |
| 1304 | return obj |
| 1305 | |
| 1306 | def __eq__(self, other): |
| 1307 | if type(self) != type(other): return False |
| 1308 | if self.version != other.version: return False |
| 1309 | if self.type != other.type: return False |
| 1310 | if self.xid != other.xid: return False |
| 1311 | return True |
| 1312 | |
| 1313 | def __ne__(self, other): |
| 1314 | return not self.__eq__(other) |
| 1315 | |
| 1316 | def __str__(self): |
| 1317 | return self.show() |
| 1318 | |
| 1319 | def show(self): |
| 1320 | import loxi.pp |
| 1321 | return loxi.pp.pp(self) |
| 1322 | |
| 1323 | def pretty_print(self, q): |
| 1324 | q.text("bsn_get_l2_table_request {") |
| 1325 | with q.group(): |
| 1326 | with q.indent(2): |
| 1327 | q.breakable() |
| 1328 | q.text("xid = "); |
| 1329 | if self.xid != None: |
| 1330 | q.text("%#x" % self.xid) |
| 1331 | else: |
| 1332 | q.text('None') |
| 1333 | q.breakable() |
| 1334 | q.text('}') |
| 1335 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1336 | class bsn_get_mirroring_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1337 | version = 1 |
| 1338 | type = 4 |
| 1339 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1340 | subtype = 5 |
| 1341 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1342 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1343 | self.xid = xid |
| 1344 | if report_mirror_ports != None: |
| 1345 | self.report_mirror_ports = report_mirror_ports |
| 1346 | else: |
| 1347 | self.report_mirror_ports = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1348 | |
| 1349 | def pack(self): |
| 1350 | packed = [] |
| 1351 | packed.append(struct.pack("!B", self.version)) |
| 1352 | packed.append(struct.pack("!B", self.type)) |
| 1353 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1354 | packed.append(struct.pack("!L", self.xid)) |
| 1355 | packed.append(struct.pack("!L", self.experimenter)) |
| 1356 | packed.append(struct.pack("!L", self.subtype)) |
| 1357 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1358 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1359 | length = sum([len(x) for x in packed]) |
| 1360 | packed[2] = struct.pack("!H", length) |
| 1361 | return ''.join(packed) |
| 1362 | |
| 1363 | @staticmethod |
| 1364 | def unpack(buf): |
| 1365 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1366 | obj = bsn_get_mirroring_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1367 | if type(buf) == loxi.generic_util.OFReader: |
| 1368 | reader = buf |
| 1369 | else: |
| 1370 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1371 | _version = reader.read("!B")[0] |
| 1372 | assert(_version == 1) |
| 1373 | _type = reader.read("!B")[0] |
| 1374 | assert(_type == 4) |
| 1375 | _length = reader.read("!H")[0] |
| 1376 | obj.xid = reader.read("!L")[0] |
| 1377 | _experimenter = reader.read("!L")[0] |
| 1378 | assert(_experimenter == 6035143) |
| 1379 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1380 | assert(_subtype == 5) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1381 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1382 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1383 | return obj |
| 1384 | |
| 1385 | def __eq__(self, other): |
| 1386 | if type(self) != type(other): return False |
| 1387 | if self.version != other.version: return False |
| 1388 | if self.type != other.type: return False |
| 1389 | if self.xid != other.xid: return False |
| 1390 | if self.report_mirror_ports != other.report_mirror_ports: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1391 | return True |
| 1392 | |
| 1393 | def __ne__(self, other): |
| 1394 | return not self.__eq__(other) |
| 1395 | |
| 1396 | def __str__(self): |
| 1397 | return self.show() |
| 1398 | |
| 1399 | def show(self): |
| 1400 | import loxi.pp |
| 1401 | return loxi.pp.pp(self) |
| 1402 | |
| 1403 | def pretty_print(self, q): |
| 1404 | q.text("bsn_get_mirroring_reply {") |
| 1405 | with q.group(): |
| 1406 | with q.indent(2): |
| 1407 | q.breakable() |
| 1408 | q.text("xid = "); |
| 1409 | if self.xid != None: |
| 1410 | q.text("%#x" % self.xid) |
| 1411 | else: |
| 1412 | q.text('None') |
| 1413 | q.text(","); q.breakable() |
| 1414 | q.text("report_mirror_ports = "); |
| 1415 | q.text("%#x" % self.report_mirror_ports) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1416 | q.breakable() |
| 1417 | q.text('}') |
| 1418 | |
| 1419 | class bsn_get_mirroring_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1420 | version = 1 |
| 1421 | type = 4 |
| 1422 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1423 | subtype = 4 |
| 1424 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1425 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1426 | self.xid = xid |
| 1427 | if report_mirror_ports != None: |
| 1428 | self.report_mirror_ports = report_mirror_ports |
| 1429 | else: |
| 1430 | self.report_mirror_ports = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1431 | |
| 1432 | def pack(self): |
| 1433 | packed = [] |
| 1434 | packed.append(struct.pack("!B", self.version)) |
| 1435 | packed.append(struct.pack("!B", self.type)) |
| 1436 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1437 | packed.append(struct.pack("!L", self.xid)) |
| 1438 | packed.append(struct.pack("!L", self.experimenter)) |
| 1439 | packed.append(struct.pack("!L", self.subtype)) |
| 1440 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1441 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1442 | length = sum([len(x) for x in packed]) |
| 1443 | packed[2] = struct.pack("!H", length) |
| 1444 | return ''.join(packed) |
| 1445 | |
| 1446 | @staticmethod |
| 1447 | def unpack(buf): |
| 1448 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1449 | obj = bsn_get_mirroring_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1450 | if type(buf) == loxi.generic_util.OFReader: |
| 1451 | reader = buf |
| 1452 | else: |
| 1453 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1454 | _version = reader.read("!B")[0] |
| 1455 | assert(_version == 1) |
| 1456 | _type = reader.read("!B")[0] |
| 1457 | assert(_type == 4) |
| 1458 | _length = reader.read("!H")[0] |
| 1459 | obj.xid = reader.read("!L")[0] |
| 1460 | _experimenter = reader.read("!L")[0] |
| 1461 | assert(_experimenter == 6035143) |
| 1462 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1463 | assert(_subtype == 4) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1464 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1465 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1466 | return obj |
| 1467 | |
| 1468 | def __eq__(self, other): |
| 1469 | if type(self) != type(other): return False |
| 1470 | if self.version != other.version: return False |
| 1471 | if self.type != other.type: return False |
| 1472 | if self.xid != other.xid: return False |
| 1473 | if self.report_mirror_ports != other.report_mirror_ports: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1474 | return True |
| 1475 | |
| 1476 | def __ne__(self, other): |
| 1477 | return not self.__eq__(other) |
| 1478 | |
| 1479 | def __str__(self): |
| 1480 | return self.show() |
| 1481 | |
| 1482 | def show(self): |
| 1483 | import loxi.pp |
| 1484 | return loxi.pp.pp(self) |
| 1485 | |
| 1486 | def pretty_print(self, q): |
| 1487 | q.text("bsn_get_mirroring_request {") |
| 1488 | with q.group(): |
| 1489 | with q.indent(2): |
| 1490 | q.breakable() |
| 1491 | q.text("xid = "); |
| 1492 | if self.xid != None: |
| 1493 | q.text("%#x" % self.xid) |
| 1494 | else: |
| 1495 | q.text('None') |
| 1496 | q.text(","); q.breakable() |
| 1497 | q.text("report_mirror_ports = "); |
| 1498 | q.text("%#x" % self.report_mirror_ports) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1499 | q.breakable() |
| 1500 | q.text('}') |
| 1501 | |
| 1502 | class bsn_set_ip_mask(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1503 | version = 1 |
| 1504 | type = 4 |
| 1505 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1506 | subtype = 0 |
| 1507 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1508 | def __init__(self, xid=None, index=None, mask=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1509 | self.xid = xid |
| 1510 | if index != None: |
| 1511 | self.index = index |
| 1512 | else: |
| 1513 | self.index = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1514 | if mask != None: |
| 1515 | self.mask = mask |
| 1516 | else: |
| 1517 | self.mask = 0 |
| 1518 | |
| 1519 | def pack(self): |
| 1520 | packed = [] |
| 1521 | packed.append(struct.pack("!B", self.version)) |
| 1522 | packed.append(struct.pack("!B", self.type)) |
| 1523 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1524 | packed.append(struct.pack("!L", self.xid)) |
| 1525 | packed.append(struct.pack("!L", self.experimenter)) |
| 1526 | packed.append(struct.pack("!L", self.subtype)) |
| 1527 | packed.append(struct.pack("!B", self.index)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1528 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1529 | packed.append(struct.pack("!L", self.mask)) |
| 1530 | length = sum([len(x) for x in packed]) |
| 1531 | packed[2] = struct.pack("!H", length) |
| 1532 | return ''.join(packed) |
| 1533 | |
| 1534 | @staticmethod |
| 1535 | def unpack(buf): |
| 1536 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1537 | obj = bsn_set_ip_mask() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1538 | if type(buf) == loxi.generic_util.OFReader: |
| 1539 | reader = buf |
| 1540 | else: |
| 1541 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1542 | _version = reader.read("!B")[0] |
| 1543 | assert(_version == 1) |
| 1544 | _type = reader.read("!B")[0] |
| 1545 | assert(_type == 4) |
| 1546 | _length = reader.read("!H")[0] |
| 1547 | obj.xid = reader.read("!L")[0] |
| 1548 | _experimenter = reader.read("!L")[0] |
| 1549 | assert(_experimenter == 6035143) |
| 1550 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1551 | assert(_subtype == 0) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1552 | obj.index = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1553 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1554 | obj.mask = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1555 | return obj |
| 1556 | |
| 1557 | def __eq__(self, other): |
| 1558 | if type(self) != type(other): return False |
| 1559 | if self.version != other.version: return False |
| 1560 | if self.type != other.type: return False |
| 1561 | if self.xid != other.xid: return False |
| 1562 | if self.index != other.index: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1563 | if self.mask != other.mask: return False |
| 1564 | return True |
| 1565 | |
| 1566 | def __ne__(self, other): |
| 1567 | return not self.__eq__(other) |
| 1568 | |
| 1569 | def __str__(self): |
| 1570 | return self.show() |
| 1571 | |
| 1572 | def show(self): |
| 1573 | import loxi.pp |
| 1574 | return loxi.pp.pp(self) |
| 1575 | |
| 1576 | def pretty_print(self, q): |
| 1577 | q.text("bsn_set_ip_mask {") |
| 1578 | with q.group(): |
| 1579 | with q.indent(2): |
| 1580 | q.breakable() |
| 1581 | q.text("xid = "); |
| 1582 | if self.xid != None: |
| 1583 | q.text("%#x" % self.xid) |
| 1584 | else: |
| 1585 | q.text('None') |
| 1586 | q.text(","); q.breakable() |
| 1587 | q.text("index = "); |
| 1588 | q.text("%#x" % self.index) |
| 1589 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1590 | q.text("mask = "); |
| 1591 | q.text("%#x" % self.mask) |
| 1592 | q.breakable() |
| 1593 | q.text('}') |
| 1594 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1595 | class bsn_set_l2_table_reply(Message): |
| 1596 | version = 1 |
| 1597 | type = 4 |
| 1598 | experimenter = 6035143 |
| 1599 | subtype = 24 |
| 1600 | |
| 1601 | def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None, status=None): |
| 1602 | self.xid = xid |
| 1603 | if l2_table_enable != None: |
| 1604 | self.l2_table_enable = l2_table_enable |
| 1605 | else: |
| 1606 | self.l2_table_enable = 0 |
| 1607 | if l2_table_priority != None: |
| 1608 | self.l2_table_priority = l2_table_priority |
| 1609 | else: |
| 1610 | self.l2_table_priority = 0 |
| 1611 | if status != None: |
| 1612 | self.status = status |
| 1613 | else: |
| 1614 | self.status = 0 |
| 1615 | |
| 1616 | def pack(self): |
| 1617 | packed = [] |
| 1618 | packed.append(struct.pack("!B", self.version)) |
| 1619 | packed.append(struct.pack("!B", self.type)) |
| 1620 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1621 | packed.append(struct.pack("!L", self.xid)) |
| 1622 | packed.append(struct.pack("!L", self.experimenter)) |
| 1623 | packed.append(struct.pack("!L", self.subtype)) |
| 1624 | packed.append(struct.pack("!B", self.l2_table_enable)) |
| 1625 | packed.append('\x00' * 1) |
| 1626 | packed.append(struct.pack("!H", self.l2_table_priority)) |
| 1627 | packed.append(struct.pack("!L", self.status)) |
| 1628 | length = sum([len(x) for x in packed]) |
| 1629 | packed[2] = struct.pack("!H", length) |
| 1630 | return ''.join(packed) |
| 1631 | |
| 1632 | @staticmethod |
| 1633 | def unpack(buf): |
| 1634 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1635 | obj = bsn_set_l2_table_reply() |
| 1636 | if type(buf) == loxi.generic_util.OFReader: |
| 1637 | reader = buf |
| 1638 | else: |
| 1639 | reader = loxi.generic_util.OFReader(buf) |
| 1640 | _version = reader.read("!B")[0] |
| 1641 | assert(_version == 1) |
| 1642 | _type = reader.read("!B")[0] |
| 1643 | assert(_type == 4) |
| 1644 | _length = reader.read("!H")[0] |
| 1645 | obj.xid = reader.read("!L")[0] |
| 1646 | _experimenter = reader.read("!L")[0] |
| 1647 | assert(_experimenter == 6035143) |
| 1648 | _subtype = reader.read("!L")[0] |
| 1649 | assert(_subtype == 24) |
| 1650 | obj.l2_table_enable = reader.read("!B")[0] |
| 1651 | reader.skip(1) |
| 1652 | obj.l2_table_priority = reader.read("!H")[0] |
| 1653 | obj.status = reader.read("!L")[0] |
| 1654 | return obj |
| 1655 | |
| 1656 | def __eq__(self, other): |
| 1657 | if type(self) != type(other): return False |
| 1658 | if self.version != other.version: return False |
| 1659 | if self.type != other.type: return False |
| 1660 | if self.xid != other.xid: return False |
| 1661 | if self.l2_table_enable != other.l2_table_enable: return False |
| 1662 | if self.l2_table_priority != other.l2_table_priority: return False |
| 1663 | if self.status != other.status: return False |
| 1664 | return True |
| 1665 | |
| 1666 | def __ne__(self, other): |
| 1667 | return not self.__eq__(other) |
| 1668 | |
| 1669 | def __str__(self): |
| 1670 | return self.show() |
| 1671 | |
| 1672 | def show(self): |
| 1673 | import loxi.pp |
| 1674 | return loxi.pp.pp(self) |
| 1675 | |
| 1676 | def pretty_print(self, q): |
| 1677 | q.text("bsn_set_l2_table_reply {") |
| 1678 | with q.group(): |
| 1679 | with q.indent(2): |
| 1680 | q.breakable() |
| 1681 | q.text("xid = "); |
| 1682 | if self.xid != None: |
| 1683 | q.text("%#x" % self.xid) |
| 1684 | else: |
| 1685 | q.text('None') |
| 1686 | q.text(","); q.breakable() |
| 1687 | q.text("l2_table_enable = "); |
| 1688 | q.text("%#x" % self.l2_table_enable) |
| 1689 | q.text(","); q.breakable() |
| 1690 | q.text("l2_table_priority = "); |
| 1691 | q.text("%#x" % self.l2_table_priority) |
| 1692 | q.text(","); q.breakable() |
| 1693 | q.text("status = "); |
| 1694 | q.text("%#x" % self.status) |
| 1695 | q.breakable() |
| 1696 | q.text('}') |
| 1697 | |
| 1698 | class bsn_set_l2_table_request(Message): |
| 1699 | version = 1 |
| 1700 | type = 4 |
| 1701 | experimenter = 6035143 |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1702 | subtype = 12 |
| 1703 | |
| 1704 | def __init__(self, xid=None, l2_table_enable=None, l2_table_priority=None): |
| 1705 | self.xid = xid |
| 1706 | if l2_table_enable != None: |
| 1707 | self.l2_table_enable = l2_table_enable |
| 1708 | else: |
| 1709 | self.l2_table_enable = 0 |
| 1710 | if l2_table_priority != None: |
| 1711 | self.l2_table_priority = l2_table_priority |
| 1712 | else: |
| 1713 | self.l2_table_priority = 0 |
| 1714 | |
| 1715 | def pack(self): |
| 1716 | packed = [] |
| 1717 | packed.append(struct.pack("!B", self.version)) |
| 1718 | packed.append(struct.pack("!B", self.type)) |
| 1719 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1720 | packed.append(struct.pack("!L", self.xid)) |
| 1721 | packed.append(struct.pack("!L", self.experimenter)) |
| 1722 | packed.append(struct.pack("!L", self.subtype)) |
| 1723 | packed.append(struct.pack("!B", self.l2_table_enable)) |
| 1724 | packed.append('\x00' * 1) |
| 1725 | packed.append(struct.pack("!H", self.l2_table_priority)) |
| 1726 | packed.append('\x00' * 4) |
| 1727 | length = sum([len(x) for x in packed]) |
| 1728 | packed[2] = struct.pack("!H", length) |
| 1729 | return ''.join(packed) |
| 1730 | |
| 1731 | @staticmethod |
| 1732 | def unpack(buf): |
| 1733 | 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] | 1734 | obj = bsn_set_l2_table_request() |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1735 | if type(buf) == loxi.generic_util.OFReader: |
| 1736 | reader = buf |
| 1737 | else: |
| 1738 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1739 | _version = reader.read("!B")[0] |
| 1740 | assert(_version == 1) |
| 1741 | _type = reader.read("!B")[0] |
| 1742 | assert(_type == 4) |
| 1743 | _length = reader.read("!H")[0] |
| 1744 | obj.xid = reader.read("!L")[0] |
| 1745 | _experimenter = reader.read("!L")[0] |
| 1746 | assert(_experimenter == 6035143) |
| 1747 | _subtype = reader.read("!L")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1748 | assert(_subtype == 12) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1749 | obj.l2_table_enable = reader.read("!B")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1750 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1751 | obj.l2_table_priority = reader.read("!H")[0] |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1752 | reader.skip(4) |
| 1753 | return obj |
| 1754 | |
| 1755 | def __eq__(self, other): |
| 1756 | if type(self) != type(other): return False |
| 1757 | if self.version != other.version: return False |
| 1758 | if self.type != other.type: return False |
| 1759 | if self.xid != other.xid: return False |
| 1760 | if self.l2_table_enable != other.l2_table_enable: return False |
| 1761 | if self.l2_table_priority != other.l2_table_priority: return False |
| 1762 | return True |
| 1763 | |
| 1764 | def __ne__(self, other): |
| 1765 | return not self.__eq__(other) |
| 1766 | |
| 1767 | def __str__(self): |
| 1768 | return self.show() |
| 1769 | |
| 1770 | def show(self): |
| 1771 | import loxi.pp |
| 1772 | return loxi.pp.pp(self) |
| 1773 | |
| 1774 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1775 | q.text("bsn_set_l2_table_request {") |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 1776 | with q.group(): |
| 1777 | with q.indent(2): |
| 1778 | q.breakable() |
| 1779 | q.text("xid = "); |
| 1780 | if self.xid != None: |
| 1781 | q.text("%#x" % self.xid) |
| 1782 | else: |
| 1783 | q.text('None') |
| 1784 | q.text(","); q.breakable() |
| 1785 | q.text("l2_table_enable = "); |
| 1786 | q.text("%#x" % self.l2_table_enable) |
| 1787 | q.text(","); q.breakable() |
| 1788 | q.text("l2_table_priority = "); |
| 1789 | q.text("%#x" % self.l2_table_priority) |
| 1790 | q.breakable() |
| 1791 | q.text('}') |
| 1792 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1793 | class bsn_set_mirroring(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1794 | version = 1 |
| 1795 | type = 4 |
| 1796 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1797 | subtype = 3 |
| 1798 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1799 | def __init__(self, xid=None, report_mirror_ports=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1800 | self.xid = xid |
| 1801 | if report_mirror_ports != None: |
| 1802 | self.report_mirror_ports = report_mirror_ports |
| 1803 | else: |
| 1804 | self.report_mirror_ports = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1805 | |
| 1806 | def pack(self): |
| 1807 | packed = [] |
| 1808 | packed.append(struct.pack("!B", self.version)) |
| 1809 | packed.append(struct.pack("!B", self.type)) |
| 1810 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1811 | packed.append(struct.pack("!L", self.xid)) |
| 1812 | packed.append(struct.pack("!L", self.experimenter)) |
| 1813 | packed.append(struct.pack("!L", self.subtype)) |
| 1814 | packed.append(struct.pack("!B", self.report_mirror_ports)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1815 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1816 | length = sum([len(x) for x in packed]) |
| 1817 | packed[2] = struct.pack("!H", length) |
| 1818 | return ''.join(packed) |
| 1819 | |
| 1820 | @staticmethod |
| 1821 | def unpack(buf): |
| 1822 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1823 | obj = bsn_set_mirroring() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1824 | if type(buf) == loxi.generic_util.OFReader: |
| 1825 | reader = buf |
| 1826 | else: |
| 1827 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1828 | _version = reader.read("!B")[0] |
| 1829 | assert(_version == 1) |
| 1830 | _type = reader.read("!B")[0] |
| 1831 | assert(_type == 4) |
| 1832 | _length = reader.read("!H")[0] |
| 1833 | obj.xid = reader.read("!L")[0] |
| 1834 | _experimenter = reader.read("!L")[0] |
| 1835 | assert(_experimenter == 6035143) |
| 1836 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1837 | assert(_subtype == 3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1838 | obj.report_mirror_ports = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1839 | reader.skip(3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1840 | return obj |
| 1841 | |
| 1842 | def __eq__(self, other): |
| 1843 | if type(self) != type(other): return False |
| 1844 | if self.version != other.version: return False |
| 1845 | if self.type != other.type: return False |
| 1846 | if self.xid != other.xid: return False |
| 1847 | if self.report_mirror_ports != other.report_mirror_ports: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 1848 | return True |
| 1849 | |
| 1850 | def __ne__(self, other): |
| 1851 | return not self.__eq__(other) |
| 1852 | |
| 1853 | def __str__(self): |
| 1854 | return self.show() |
| 1855 | |
| 1856 | def show(self): |
| 1857 | import loxi.pp |
| 1858 | return loxi.pp.pp(self) |
| 1859 | |
| 1860 | def pretty_print(self, q): |
| 1861 | q.text("bsn_set_mirroring {") |
| 1862 | with q.group(): |
| 1863 | with q.indent(2): |
| 1864 | q.breakable() |
| 1865 | q.text("xid = "); |
| 1866 | if self.xid != None: |
| 1867 | q.text("%#x" % self.xid) |
| 1868 | else: |
| 1869 | q.text('None') |
| 1870 | q.text(","); q.breakable() |
| 1871 | q.text("report_mirror_ports = "); |
| 1872 | q.text("%#x" % self.report_mirror_ports) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1873 | q.breakable() |
| 1874 | q.text('}') |
| 1875 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 1876 | class bsn_set_pktin_suppression_reply(Message): |
| 1877 | version = 1 |
| 1878 | type = 4 |
| 1879 | experimenter = 6035143 |
| 1880 | subtype = 25 |
| 1881 | |
| 1882 | def __init__(self, xid=None, status=None): |
| 1883 | self.xid = xid |
| 1884 | if status != None: |
| 1885 | self.status = status |
| 1886 | else: |
| 1887 | self.status = 0 |
| 1888 | |
| 1889 | def pack(self): |
| 1890 | packed = [] |
| 1891 | packed.append(struct.pack("!B", self.version)) |
| 1892 | packed.append(struct.pack("!B", self.type)) |
| 1893 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1894 | packed.append(struct.pack("!L", self.xid)) |
| 1895 | packed.append(struct.pack("!L", self.experimenter)) |
| 1896 | packed.append(struct.pack("!L", self.subtype)) |
| 1897 | packed.append(struct.pack("!L", self.status)) |
| 1898 | length = sum([len(x) for x in packed]) |
| 1899 | packed[2] = struct.pack("!H", length) |
| 1900 | return ''.join(packed) |
| 1901 | |
| 1902 | @staticmethod |
| 1903 | def unpack(buf): |
| 1904 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 1905 | obj = bsn_set_pktin_suppression_reply() |
| 1906 | if type(buf) == loxi.generic_util.OFReader: |
| 1907 | reader = buf |
| 1908 | else: |
| 1909 | reader = loxi.generic_util.OFReader(buf) |
| 1910 | _version = reader.read("!B")[0] |
| 1911 | assert(_version == 1) |
| 1912 | _type = reader.read("!B")[0] |
| 1913 | assert(_type == 4) |
| 1914 | _length = reader.read("!H")[0] |
| 1915 | obj.xid = reader.read("!L")[0] |
| 1916 | _experimenter = reader.read("!L")[0] |
| 1917 | assert(_experimenter == 6035143) |
| 1918 | _subtype = reader.read("!L")[0] |
| 1919 | assert(_subtype == 25) |
| 1920 | obj.status = reader.read("!L")[0] |
| 1921 | return obj |
| 1922 | |
| 1923 | def __eq__(self, other): |
| 1924 | if type(self) != type(other): return False |
| 1925 | if self.version != other.version: return False |
| 1926 | if self.type != other.type: return False |
| 1927 | if self.xid != other.xid: return False |
| 1928 | if self.status != other.status: return False |
| 1929 | return True |
| 1930 | |
| 1931 | def __ne__(self, other): |
| 1932 | return not self.__eq__(other) |
| 1933 | |
| 1934 | def __str__(self): |
| 1935 | return self.show() |
| 1936 | |
| 1937 | def show(self): |
| 1938 | import loxi.pp |
| 1939 | return loxi.pp.pp(self) |
| 1940 | |
| 1941 | def pretty_print(self, q): |
| 1942 | q.text("bsn_set_pktin_suppression_reply {") |
| 1943 | with q.group(): |
| 1944 | with q.indent(2): |
| 1945 | q.breakable() |
| 1946 | q.text("xid = "); |
| 1947 | if self.xid != None: |
| 1948 | q.text("%#x" % self.xid) |
| 1949 | else: |
| 1950 | q.text('None') |
| 1951 | q.text(","); q.breakable() |
| 1952 | q.text("status = "); |
| 1953 | q.text("%#x" % self.status) |
| 1954 | q.breakable() |
| 1955 | q.text('}') |
| 1956 | |
| 1957 | class bsn_set_pktin_suppression_request(Message): |
| 1958 | version = 1 |
| 1959 | type = 4 |
| 1960 | experimenter = 6035143 |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 1961 | subtype = 11 |
| 1962 | |
| 1963 | def __init__(self, xid=None, enabled=None, idle_timeout=None, hard_timeout=None, priority=None, cookie=None): |
| 1964 | self.xid = xid |
| 1965 | if enabled != None: |
| 1966 | self.enabled = enabled |
| 1967 | else: |
| 1968 | self.enabled = 0 |
| 1969 | if idle_timeout != None: |
| 1970 | self.idle_timeout = idle_timeout |
| 1971 | else: |
| 1972 | self.idle_timeout = 0 |
| 1973 | if hard_timeout != None: |
| 1974 | self.hard_timeout = hard_timeout |
| 1975 | else: |
| 1976 | self.hard_timeout = 0 |
| 1977 | if priority != None: |
| 1978 | self.priority = priority |
| 1979 | else: |
| 1980 | self.priority = 0 |
| 1981 | if cookie != None: |
| 1982 | self.cookie = cookie |
| 1983 | else: |
| 1984 | self.cookie = 0 |
| 1985 | |
| 1986 | def pack(self): |
| 1987 | packed = [] |
| 1988 | packed.append(struct.pack("!B", self.version)) |
| 1989 | packed.append(struct.pack("!B", self.type)) |
| 1990 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 1991 | packed.append(struct.pack("!L", self.xid)) |
| 1992 | packed.append(struct.pack("!L", self.experimenter)) |
| 1993 | packed.append(struct.pack("!L", self.subtype)) |
| 1994 | packed.append(struct.pack("!B", self.enabled)) |
| 1995 | packed.append('\x00' * 1) |
| 1996 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 1997 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 1998 | packed.append(struct.pack("!H", self.priority)) |
| 1999 | packed.append(struct.pack("!Q", self.cookie)) |
| 2000 | length = sum([len(x) for x in packed]) |
| 2001 | packed[2] = struct.pack("!H", length) |
| 2002 | return ''.join(packed) |
| 2003 | |
| 2004 | @staticmethod |
| 2005 | def unpack(buf): |
| 2006 | 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] | 2007 | obj = bsn_set_pktin_suppression_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2008 | if type(buf) == loxi.generic_util.OFReader: |
| 2009 | reader = buf |
| 2010 | else: |
| 2011 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2012 | _version = reader.read("!B")[0] |
| 2013 | assert(_version == 1) |
| 2014 | _type = reader.read("!B")[0] |
| 2015 | assert(_type == 4) |
| 2016 | _length = reader.read("!H")[0] |
| 2017 | obj.xid = reader.read("!L")[0] |
| 2018 | _experimenter = reader.read("!L")[0] |
| 2019 | assert(_experimenter == 6035143) |
| 2020 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2021 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2022 | obj.enabled = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2023 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2024 | obj.idle_timeout = reader.read("!H")[0] |
| 2025 | obj.hard_timeout = reader.read("!H")[0] |
| 2026 | obj.priority = reader.read("!H")[0] |
| 2027 | obj.cookie = reader.read("!Q")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2028 | return obj |
| 2029 | |
| 2030 | def __eq__(self, other): |
| 2031 | if type(self) != type(other): return False |
| 2032 | if self.version != other.version: return False |
| 2033 | if self.type != other.type: return False |
| 2034 | if self.xid != other.xid: return False |
| 2035 | if self.enabled != other.enabled: return False |
| 2036 | if self.idle_timeout != other.idle_timeout: return False |
| 2037 | if self.hard_timeout != other.hard_timeout: return False |
| 2038 | if self.priority != other.priority: return False |
| 2039 | if self.cookie != other.cookie: return False |
| 2040 | return True |
| 2041 | |
| 2042 | def __ne__(self, other): |
| 2043 | return not self.__eq__(other) |
| 2044 | |
| 2045 | def __str__(self): |
| 2046 | return self.show() |
| 2047 | |
| 2048 | def show(self): |
| 2049 | import loxi.pp |
| 2050 | return loxi.pp.pp(self) |
| 2051 | |
| 2052 | def pretty_print(self, q): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2053 | q.text("bsn_set_pktin_suppression_request {") |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2054 | with q.group(): |
| 2055 | with q.indent(2): |
| 2056 | q.breakable() |
| 2057 | q.text("xid = "); |
| 2058 | if self.xid != None: |
| 2059 | q.text("%#x" % self.xid) |
| 2060 | else: |
| 2061 | q.text('None') |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2062 | q.text(","); q.breakable() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2063 | q.text("enabled = "); |
| 2064 | q.text("%#x" % self.enabled) |
| 2065 | q.text(","); q.breakable() |
| 2066 | q.text("idle_timeout = "); |
| 2067 | q.text("%#x" % self.idle_timeout) |
| 2068 | q.text(","); q.breakable() |
| 2069 | q.text("hard_timeout = "); |
| 2070 | q.text("%#x" % self.hard_timeout) |
| 2071 | q.text(","); q.breakable() |
| 2072 | q.text("priority = "); |
| 2073 | q.text("%#x" % self.priority) |
| 2074 | q.text(","); q.breakable() |
| 2075 | q.text("cookie = "); |
| 2076 | q.text("%#x" % self.cookie) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2077 | q.breakable() |
| 2078 | q.text('}') |
| 2079 | |
| 2080 | class bsn_shell_command(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2081 | version = 1 |
| 2082 | type = 4 |
| 2083 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2084 | subtype = 6 |
| 2085 | |
| 2086 | def __init__(self, xid=None, service=None, data=None): |
| 2087 | self.xid = xid |
| 2088 | if service != None: |
| 2089 | self.service = service |
| 2090 | else: |
| 2091 | self.service = 0 |
| 2092 | if data != None: |
| 2093 | self.data = data |
| 2094 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2095 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2096 | |
| 2097 | def pack(self): |
| 2098 | packed = [] |
| 2099 | packed.append(struct.pack("!B", self.version)) |
| 2100 | packed.append(struct.pack("!B", self.type)) |
| 2101 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2102 | packed.append(struct.pack("!L", self.xid)) |
| 2103 | packed.append(struct.pack("!L", self.experimenter)) |
| 2104 | packed.append(struct.pack("!L", self.subtype)) |
| 2105 | packed.append(struct.pack("!L", self.service)) |
| 2106 | packed.append(self.data) |
| 2107 | length = sum([len(x) for x in packed]) |
| 2108 | packed[2] = struct.pack("!H", length) |
| 2109 | return ''.join(packed) |
| 2110 | |
| 2111 | @staticmethod |
| 2112 | def unpack(buf): |
| 2113 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2114 | obj = bsn_shell_command() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2115 | if type(buf) == loxi.generic_util.OFReader: |
| 2116 | reader = buf |
| 2117 | else: |
| 2118 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2119 | _version = reader.read("!B")[0] |
| 2120 | assert(_version == 1) |
| 2121 | _type = reader.read("!B")[0] |
| 2122 | assert(_type == 4) |
| 2123 | _length = reader.read("!H")[0] |
| 2124 | obj.xid = reader.read("!L")[0] |
| 2125 | _experimenter = reader.read("!L")[0] |
| 2126 | assert(_experimenter == 6035143) |
| 2127 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2128 | assert(_subtype == 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2129 | obj.service = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2130 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2131 | return obj |
| 2132 | |
| 2133 | def __eq__(self, other): |
| 2134 | if type(self) != type(other): return False |
| 2135 | if self.version != other.version: return False |
| 2136 | if self.type != other.type: return False |
| 2137 | if self.xid != other.xid: return False |
| 2138 | if self.service != other.service: return False |
| 2139 | if self.data != other.data: return False |
| 2140 | return True |
| 2141 | |
| 2142 | def __ne__(self, other): |
| 2143 | return not self.__eq__(other) |
| 2144 | |
| 2145 | def __str__(self): |
| 2146 | return self.show() |
| 2147 | |
| 2148 | def show(self): |
| 2149 | import loxi.pp |
| 2150 | return loxi.pp.pp(self) |
| 2151 | |
| 2152 | def pretty_print(self, q): |
| 2153 | q.text("bsn_shell_command {") |
| 2154 | with q.group(): |
| 2155 | with q.indent(2): |
| 2156 | q.breakable() |
| 2157 | q.text("xid = "); |
| 2158 | if self.xid != None: |
| 2159 | q.text("%#x" % self.xid) |
| 2160 | else: |
| 2161 | q.text('None') |
| 2162 | q.text(","); q.breakable() |
| 2163 | q.text("service = "); |
| 2164 | q.text("%#x" % self.service) |
| 2165 | q.text(","); q.breakable() |
| 2166 | q.text("data = "); |
| 2167 | q.pp(self.data) |
| 2168 | q.breakable() |
| 2169 | q.text('}') |
| 2170 | |
| 2171 | class bsn_shell_output(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2172 | version = 1 |
| 2173 | type = 4 |
| 2174 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2175 | subtype = 7 |
| 2176 | |
| 2177 | def __init__(self, xid=None, data=None): |
| 2178 | self.xid = xid |
| 2179 | if data != None: |
| 2180 | self.data = data |
| 2181 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2182 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2183 | |
| 2184 | def pack(self): |
| 2185 | packed = [] |
| 2186 | packed.append(struct.pack("!B", self.version)) |
| 2187 | packed.append(struct.pack("!B", self.type)) |
| 2188 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2189 | packed.append(struct.pack("!L", self.xid)) |
| 2190 | packed.append(struct.pack("!L", self.experimenter)) |
| 2191 | packed.append(struct.pack("!L", self.subtype)) |
| 2192 | packed.append(self.data) |
| 2193 | length = sum([len(x) for x in packed]) |
| 2194 | packed[2] = struct.pack("!H", length) |
| 2195 | return ''.join(packed) |
| 2196 | |
| 2197 | @staticmethod |
| 2198 | def unpack(buf): |
| 2199 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2200 | obj = bsn_shell_output() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2201 | if type(buf) == loxi.generic_util.OFReader: |
| 2202 | reader = buf |
| 2203 | else: |
| 2204 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2205 | _version = reader.read("!B")[0] |
| 2206 | assert(_version == 1) |
| 2207 | _type = reader.read("!B")[0] |
| 2208 | assert(_type == 4) |
| 2209 | _length = reader.read("!H")[0] |
| 2210 | obj.xid = reader.read("!L")[0] |
| 2211 | _experimenter = reader.read("!L")[0] |
| 2212 | assert(_experimenter == 6035143) |
| 2213 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2214 | assert(_subtype == 7) |
| 2215 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2216 | return obj |
| 2217 | |
| 2218 | def __eq__(self, other): |
| 2219 | if type(self) != type(other): return False |
| 2220 | if self.version != other.version: return False |
| 2221 | if self.type != other.type: return False |
| 2222 | if self.xid != other.xid: return False |
| 2223 | if self.data != other.data: return False |
| 2224 | return True |
| 2225 | |
| 2226 | def __ne__(self, other): |
| 2227 | return not self.__eq__(other) |
| 2228 | |
| 2229 | def __str__(self): |
| 2230 | return self.show() |
| 2231 | |
| 2232 | def show(self): |
| 2233 | import loxi.pp |
| 2234 | return loxi.pp.pp(self) |
| 2235 | |
| 2236 | def pretty_print(self, q): |
| 2237 | q.text("bsn_shell_output {") |
| 2238 | with q.group(): |
| 2239 | with q.indent(2): |
| 2240 | q.breakable() |
| 2241 | q.text("xid = "); |
| 2242 | if self.xid != None: |
| 2243 | q.text("%#x" % self.xid) |
| 2244 | else: |
| 2245 | q.text('None') |
| 2246 | q.text(","); q.breakable() |
| 2247 | q.text("data = "); |
| 2248 | q.pp(self.data) |
| 2249 | q.breakable() |
| 2250 | q.text('}') |
| 2251 | |
| 2252 | class bsn_shell_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2253 | version = 1 |
| 2254 | type = 4 |
| 2255 | experimenter = 6035143 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2256 | subtype = 8 |
| 2257 | |
| 2258 | def __init__(self, xid=None, status=None): |
| 2259 | self.xid = xid |
| 2260 | if status != None: |
| 2261 | self.status = status |
| 2262 | else: |
| 2263 | self.status = 0 |
| 2264 | |
| 2265 | def pack(self): |
| 2266 | packed = [] |
| 2267 | packed.append(struct.pack("!B", self.version)) |
| 2268 | packed.append(struct.pack("!B", self.type)) |
| 2269 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2270 | packed.append(struct.pack("!L", self.xid)) |
| 2271 | packed.append(struct.pack("!L", self.experimenter)) |
| 2272 | packed.append(struct.pack("!L", self.subtype)) |
| 2273 | packed.append(struct.pack("!L", self.status)) |
| 2274 | length = sum([len(x) for x in packed]) |
| 2275 | packed[2] = struct.pack("!H", length) |
| 2276 | return ''.join(packed) |
| 2277 | |
| 2278 | @staticmethod |
| 2279 | def unpack(buf): |
| 2280 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2281 | obj = bsn_shell_status() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2282 | if type(buf) == loxi.generic_util.OFReader: |
| 2283 | reader = buf |
| 2284 | else: |
| 2285 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2286 | _version = reader.read("!B")[0] |
| 2287 | assert(_version == 1) |
| 2288 | _type = reader.read("!B")[0] |
| 2289 | assert(_type == 4) |
| 2290 | _length = reader.read("!H")[0] |
| 2291 | obj.xid = reader.read("!L")[0] |
| 2292 | _experimenter = reader.read("!L")[0] |
| 2293 | assert(_experimenter == 6035143) |
| 2294 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2295 | assert(_subtype == 8) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2296 | obj.status = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2297 | return obj |
| 2298 | |
| 2299 | def __eq__(self, other): |
| 2300 | if type(self) != type(other): return False |
| 2301 | if self.version != other.version: return False |
| 2302 | if self.type != other.type: return False |
| 2303 | if self.xid != other.xid: return False |
| 2304 | if self.status != other.status: return False |
| 2305 | return True |
| 2306 | |
| 2307 | def __ne__(self, other): |
| 2308 | return not self.__eq__(other) |
| 2309 | |
| 2310 | def __str__(self): |
| 2311 | return self.show() |
| 2312 | |
| 2313 | def show(self): |
| 2314 | import loxi.pp |
| 2315 | return loxi.pp.pp(self) |
| 2316 | |
| 2317 | def pretty_print(self, q): |
| 2318 | q.text("bsn_shell_status {") |
| 2319 | with q.group(): |
| 2320 | with q.indent(2): |
| 2321 | q.breakable() |
| 2322 | q.text("xid = "); |
| 2323 | if self.xid != None: |
| 2324 | q.text("%#x" % self.xid) |
| 2325 | else: |
| 2326 | q.text('None') |
| 2327 | q.text(","); q.breakable() |
| 2328 | q.text("status = "); |
| 2329 | q.text("%#x" % self.status) |
| 2330 | q.breakable() |
| 2331 | q.text('}') |
| 2332 | |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2333 | class bsn_virtual_port_create_reply(Message): |
| 2334 | version = 1 |
| 2335 | type = 4 |
| 2336 | experimenter = 6035143 |
| 2337 | subtype = 16 |
| 2338 | |
| 2339 | def __init__(self, xid=None, status=None, vport_no=None): |
| 2340 | self.xid = xid |
| 2341 | if status != None: |
| 2342 | self.status = status |
| 2343 | else: |
| 2344 | self.status = 0 |
| 2345 | if vport_no != None: |
| 2346 | self.vport_no = vport_no |
| 2347 | else: |
| 2348 | self.vport_no = 0 |
| 2349 | |
| 2350 | def pack(self): |
| 2351 | packed = [] |
| 2352 | packed.append(struct.pack("!B", self.version)) |
| 2353 | packed.append(struct.pack("!B", self.type)) |
| 2354 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2355 | packed.append(struct.pack("!L", self.xid)) |
| 2356 | packed.append(struct.pack("!L", self.experimenter)) |
| 2357 | packed.append(struct.pack("!L", self.subtype)) |
| 2358 | packed.append(struct.pack("!L", self.status)) |
| 2359 | packed.append(struct.pack("!L", self.vport_no)) |
| 2360 | length = sum([len(x) for x in packed]) |
| 2361 | packed[2] = struct.pack("!H", length) |
| 2362 | return ''.join(packed) |
| 2363 | |
| 2364 | @staticmethod |
| 2365 | def unpack(buf): |
| 2366 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2367 | obj = bsn_virtual_port_create_reply() |
| 2368 | if type(buf) == loxi.generic_util.OFReader: |
| 2369 | reader = buf |
| 2370 | else: |
| 2371 | reader = loxi.generic_util.OFReader(buf) |
| 2372 | _version = reader.read("!B")[0] |
| 2373 | assert(_version == 1) |
| 2374 | _type = reader.read("!B")[0] |
| 2375 | assert(_type == 4) |
| 2376 | _length = reader.read("!H")[0] |
| 2377 | obj.xid = reader.read("!L")[0] |
| 2378 | _experimenter = reader.read("!L")[0] |
| 2379 | assert(_experimenter == 6035143) |
| 2380 | _subtype = reader.read("!L")[0] |
| 2381 | assert(_subtype == 16) |
| 2382 | obj.status = reader.read("!L")[0] |
| 2383 | obj.vport_no = reader.read("!L")[0] |
| 2384 | return obj |
| 2385 | |
| 2386 | def __eq__(self, other): |
| 2387 | if type(self) != type(other): return False |
| 2388 | if self.version != other.version: return False |
| 2389 | if self.type != other.type: return False |
| 2390 | if self.xid != other.xid: return False |
| 2391 | if self.status != other.status: return False |
| 2392 | if self.vport_no != other.vport_no: return False |
| 2393 | return True |
| 2394 | |
| 2395 | def __ne__(self, other): |
| 2396 | return not self.__eq__(other) |
| 2397 | |
| 2398 | def __str__(self): |
| 2399 | return self.show() |
| 2400 | |
| 2401 | def show(self): |
| 2402 | import loxi.pp |
| 2403 | return loxi.pp.pp(self) |
| 2404 | |
| 2405 | def pretty_print(self, q): |
| 2406 | q.text("bsn_virtual_port_create_reply {") |
| 2407 | with q.group(): |
| 2408 | with q.indent(2): |
| 2409 | q.breakable() |
| 2410 | q.text("xid = "); |
| 2411 | if self.xid != None: |
| 2412 | q.text("%#x" % self.xid) |
| 2413 | else: |
| 2414 | q.text('None') |
| 2415 | q.text(","); q.breakable() |
| 2416 | q.text("status = "); |
| 2417 | q.text("%#x" % self.status) |
| 2418 | q.text(","); q.breakable() |
| 2419 | q.text("vport_no = "); |
| 2420 | q.text("%#x" % self.vport_no) |
| 2421 | q.breakable() |
| 2422 | q.text('}') |
| 2423 | |
| 2424 | class bsn_virtual_port_create_request(Message): |
| 2425 | version = 1 |
| 2426 | type = 4 |
| 2427 | experimenter = 6035143 |
| 2428 | subtype = 15 |
| 2429 | |
| 2430 | def __init__(self, xid=None, vport=None): |
| 2431 | self.xid = xid |
| 2432 | if vport != None: |
| 2433 | self.vport = vport |
| 2434 | else: |
| 2435 | self.vport = common.bsn_vport_q_in_q() |
| 2436 | |
| 2437 | def pack(self): |
| 2438 | packed = [] |
| 2439 | packed.append(struct.pack("!B", self.version)) |
| 2440 | packed.append(struct.pack("!B", self.type)) |
| 2441 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2442 | packed.append(struct.pack("!L", self.xid)) |
| 2443 | packed.append(struct.pack("!L", self.experimenter)) |
| 2444 | packed.append(struct.pack("!L", self.subtype)) |
| 2445 | packed.append(self.vport.pack()) |
| 2446 | length = sum([len(x) for x in packed]) |
| 2447 | packed[2] = struct.pack("!H", length) |
| 2448 | return ''.join(packed) |
| 2449 | |
| 2450 | @staticmethod |
| 2451 | def unpack(buf): |
| 2452 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2453 | obj = bsn_virtual_port_create_request() |
| 2454 | if type(buf) == loxi.generic_util.OFReader: |
| 2455 | reader = buf |
| 2456 | else: |
| 2457 | reader = loxi.generic_util.OFReader(buf) |
| 2458 | _version = reader.read("!B")[0] |
| 2459 | assert(_version == 1) |
| 2460 | _type = reader.read("!B")[0] |
| 2461 | assert(_type == 4) |
| 2462 | _length = reader.read("!H")[0] |
| 2463 | obj.xid = reader.read("!L")[0] |
| 2464 | _experimenter = reader.read("!L")[0] |
| 2465 | assert(_experimenter == 6035143) |
| 2466 | _subtype = reader.read("!L")[0] |
| 2467 | assert(_subtype == 15) |
| 2468 | obj.vport = common.bsn_vport_q_in_q.unpack(reader) |
| 2469 | return obj |
| 2470 | |
| 2471 | def __eq__(self, other): |
| 2472 | if type(self) != type(other): return False |
| 2473 | if self.version != other.version: return False |
| 2474 | if self.type != other.type: return False |
| 2475 | if self.xid != other.xid: return False |
| 2476 | if self.vport != other.vport: return False |
| 2477 | return True |
| 2478 | |
| 2479 | def __ne__(self, other): |
| 2480 | return not self.__eq__(other) |
| 2481 | |
| 2482 | def __str__(self): |
| 2483 | return self.show() |
| 2484 | |
| 2485 | def show(self): |
| 2486 | import loxi.pp |
| 2487 | return loxi.pp.pp(self) |
| 2488 | |
| 2489 | def pretty_print(self, q): |
| 2490 | q.text("bsn_virtual_port_create_request {") |
| 2491 | with q.group(): |
| 2492 | with q.indent(2): |
| 2493 | q.breakable() |
| 2494 | q.text("xid = "); |
| 2495 | if self.xid != None: |
| 2496 | q.text("%#x" % self.xid) |
| 2497 | else: |
| 2498 | q.text('None') |
| 2499 | q.text(","); q.breakable() |
| 2500 | q.text("vport = "); |
| 2501 | q.pp(self.vport) |
| 2502 | q.breakable() |
| 2503 | q.text('}') |
| 2504 | |
| 2505 | class bsn_virtual_port_remove_reply(Message): |
| 2506 | version = 1 |
| 2507 | type = 4 |
| 2508 | experimenter = 6035143 |
| 2509 | subtype = 26 |
| 2510 | |
| 2511 | def __init__(self, xid=None, status=None): |
| 2512 | self.xid = xid |
| 2513 | if status != None: |
| 2514 | self.status = status |
| 2515 | else: |
| 2516 | self.status = 0 |
| 2517 | |
| 2518 | def pack(self): |
| 2519 | packed = [] |
| 2520 | packed.append(struct.pack("!B", self.version)) |
| 2521 | packed.append(struct.pack("!B", self.type)) |
| 2522 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2523 | packed.append(struct.pack("!L", self.xid)) |
| 2524 | packed.append(struct.pack("!L", self.experimenter)) |
| 2525 | packed.append(struct.pack("!L", self.subtype)) |
| 2526 | packed.append(struct.pack("!L", self.status)) |
| 2527 | length = sum([len(x) for x in packed]) |
| 2528 | packed[2] = struct.pack("!H", length) |
| 2529 | return ''.join(packed) |
| 2530 | |
| 2531 | @staticmethod |
| 2532 | def unpack(buf): |
| 2533 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2534 | obj = bsn_virtual_port_remove_reply() |
| 2535 | if type(buf) == loxi.generic_util.OFReader: |
| 2536 | reader = buf |
| 2537 | else: |
| 2538 | reader = loxi.generic_util.OFReader(buf) |
| 2539 | _version = reader.read("!B")[0] |
| 2540 | assert(_version == 1) |
| 2541 | _type = reader.read("!B")[0] |
| 2542 | assert(_type == 4) |
| 2543 | _length = reader.read("!H")[0] |
| 2544 | obj.xid = reader.read("!L")[0] |
| 2545 | _experimenter = reader.read("!L")[0] |
| 2546 | assert(_experimenter == 6035143) |
| 2547 | _subtype = reader.read("!L")[0] |
| 2548 | assert(_subtype == 26) |
| 2549 | obj.status = reader.read("!L")[0] |
| 2550 | return obj |
| 2551 | |
| 2552 | def __eq__(self, other): |
| 2553 | if type(self) != type(other): return False |
| 2554 | if self.version != other.version: return False |
| 2555 | if self.type != other.type: return False |
| 2556 | if self.xid != other.xid: return False |
| 2557 | if self.status != other.status: return False |
| 2558 | return True |
| 2559 | |
| 2560 | def __ne__(self, other): |
| 2561 | return not self.__eq__(other) |
| 2562 | |
| 2563 | def __str__(self): |
| 2564 | return self.show() |
| 2565 | |
| 2566 | def show(self): |
| 2567 | import loxi.pp |
| 2568 | return loxi.pp.pp(self) |
| 2569 | |
| 2570 | def pretty_print(self, q): |
| 2571 | q.text("bsn_virtual_port_remove_reply {") |
| 2572 | with q.group(): |
| 2573 | with q.indent(2): |
| 2574 | q.breakable() |
| 2575 | q.text("xid = "); |
| 2576 | if self.xid != None: |
| 2577 | q.text("%#x" % self.xid) |
| 2578 | else: |
| 2579 | q.text('None') |
| 2580 | q.text(","); q.breakable() |
| 2581 | q.text("status = "); |
| 2582 | q.text("%#x" % self.status) |
| 2583 | q.breakable() |
| 2584 | q.text('}') |
| 2585 | |
| 2586 | class bsn_virtual_port_remove_request(Message): |
| 2587 | version = 1 |
| 2588 | type = 4 |
| 2589 | experimenter = 6035143 |
| 2590 | subtype = 17 |
| 2591 | |
| 2592 | def __init__(self, xid=None, vport_no=None): |
| 2593 | self.xid = xid |
| 2594 | if vport_no != None: |
| 2595 | self.vport_no = vport_no |
| 2596 | else: |
| 2597 | self.vport_no = 0 |
| 2598 | |
| 2599 | def pack(self): |
| 2600 | packed = [] |
| 2601 | packed.append(struct.pack("!B", self.version)) |
| 2602 | packed.append(struct.pack("!B", self.type)) |
| 2603 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2604 | packed.append(struct.pack("!L", self.xid)) |
| 2605 | packed.append(struct.pack("!L", self.experimenter)) |
| 2606 | packed.append(struct.pack("!L", self.subtype)) |
| 2607 | packed.append(struct.pack("!L", self.vport_no)) |
| 2608 | length = sum([len(x) for x in packed]) |
| 2609 | packed[2] = struct.pack("!H", length) |
| 2610 | return ''.join(packed) |
| 2611 | |
| 2612 | @staticmethod |
| 2613 | def unpack(buf): |
| 2614 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2615 | obj = bsn_virtual_port_remove_request() |
| 2616 | if type(buf) == loxi.generic_util.OFReader: |
| 2617 | reader = buf |
| 2618 | else: |
| 2619 | reader = loxi.generic_util.OFReader(buf) |
| 2620 | _version = reader.read("!B")[0] |
| 2621 | assert(_version == 1) |
| 2622 | _type = reader.read("!B")[0] |
| 2623 | assert(_type == 4) |
| 2624 | _length = reader.read("!H")[0] |
| 2625 | obj.xid = reader.read("!L")[0] |
| 2626 | _experimenter = reader.read("!L")[0] |
| 2627 | assert(_experimenter == 6035143) |
| 2628 | _subtype = reader.read("!L")[0] |
| 2629 | assert(_subtype == 17) |
| 2630 | obj.vport_no = reader.read("!L")[0] |
| 2631 | return obj |
| 2632 | |
| 2633 | def __eq__(self, other): |
| 2634 | if type(self) != type(other): return False |
| 2635 | if self.version != other.version: return False |
| 2636 | if self.type != other.type: return False |
| 2637 | if self.xid != other.xid: return False |
| 2638 | if self.vport_no != other.vport_no: return False |
| 2639 | return True |
| 2640 | |
| 2641 | def __ne__(self, other): |
| 2642 | return not self.__eq__(other) |
| 2643 | |
| 2644 | def __str__(self): |
| 2645 | return self.show() |
| 2646 | |
| 2647 | def show(self): |
| 2648 | import loxi.pp |
| 2649 | return loxi.pp.pp(self) |
| 2650 | |
| 2651 | def pretty_print(self, q): |
| 2652 | q.text("bsn_virtual_port_remove_request {") |
| 2653 | with q.group(): |
| 2654 | with q.indent(2): |
| 2655 | q.breakable() |
| 2656 | q.text("xid = "); |
| 2657 | if self.xid != None: |
| 2658 | q.text("%#x" % self.xid) |
| 2659 | else: |
| 2660 | q.text('None') |
| 2661 | q.text(","); q.breakable() |
| 2662 | q.text("vport_no = "); |
| 2663 | q.text("%#x" % self.vport_no) |
| 2664 | q.breakable() |
| 2665 | q.text('}') |
| 2666 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2667 | class desc_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2668 | version = 1 |
| 2669 | type = 17 |
| 2670 | stats_type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2671 | |
| 2672 | def __init__(self, xid=None, flags=None, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): |
| 2673 | self.xid = xid |
| 2674 | if flags != None: |
| 2675 | self.flags = flags |
| 2676 | else: |
| 2677 | self.flags = 0 |
| 2678 | if mfr_desc != None: |
| 2679 | self.mfr_desc = mfr_desc |
| 2680 | else: |
| 2681 | self.mfr_desc = "" |
| 2682 | if hw_desc != None: |
| 2683 | self.hw_desc = hw_desc |
| 2684 | else: |
| 2685 | self.hw_desc = "" |
| 2686 | if sw_desc != None: |
| 2687 | self.sw_desc = sw_desc |
| 2688 | else: |
| 2689 | self.sw_desc = "" |
| 2690 | if serial_num != None: |
| 2691 | self.serial_num = serial_num |
| 2692 | else: |
| 2693 | self.serial_num = "" |
| 2694 | if dp_desc != None: |
| 2695 | self.dp_desc = dp_desc |
| 2696 | else: |
| 2697 | self.dp_desc = "" |
| 2698 | |
| 2699 | def pack(self): |
| 2700 | packed = [] |
| 2701 | packed.append(struct.pack("!B", self.version)) |
| 2702 | packed.append(struct.pack("!B", self.type)) |
| 2703 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2704 | packed.append(struct.pack("!L", self.xid)) |
| 2705 | packed.append(struct.pack("!H", self.stats_type)) |
| 2706 | packed.append(struct.pack("!H", self.flags)) |
| 2707 | packed.append(struct.pack("!256s", self.mfr_desc)) |
| 2708 | packed.append(struct.pack("!256s", self.hw_desc)) |
| 2709 | packed.append(struct.pack("!256s", self.sw_desc)) |
| 2710 | packed.append(struct.pack("!32s", self.serial_num)) |
| 2711 | packed.append(struct.pack("!256s", self.dp_desc)) |
| 2712 | length = sum([len(x) for x in packed]) |
| 2713 | packed[2] = struct.pack("!H", length) |
| 2714 | return ''.join(packed) |
| 2715 | |
| 2716 | @staticmethod |
| 2717 | def unpack(buf): |
| 2718 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2719 | obj = desc_stats_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2720 | if type(buf) == loxi.generic_util.OFReader: |
| 2721 | reader = buf |
| 2722 | else: |
| 2723 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2724 | _version = reader.read("!B")[0] |
| 2725 | assert(_version == 1) |
| 2726 | _type = reader.read("!B")[0] |
| 2727 | assert(_type == 17) |
| 2728 | _length = reader.read("!H")[0] |
| 2729 | obj.xid = reader.read("!L")[0] |
| 2730 | _stats_type = reader.read("!H")[0] |
| 2731 | assert(_stats_type == 0) |
| 2732 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2733 | obj.mfr_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2734 | obj.hw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2735 | obj.sw_desc = reader.read("!256s")[0].rstrip("\x00") |
| 2736 | obj.serial_num = reader.read("!32s")[0].rstrip("\x00") |
| 2737 | obj.dp_desc = reader.read("!256s")[0].rstrip("\x00") |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2738 | return obj |
| 2739 | |
| 2740 | def __eq__(self, other): |
| 2741 | if type(self) != type(other): return False |
| 2742 | if self.version != other.version: return False |
| 2743 | if self.type != other.type: return False |
| 2744 | if self.xid != other.xid: return False |
| 2745 | if self.flags != other.flags: return False |
| 2746 | if self.mfr_desc != other.mfr_desc: return False |
| 2747 | if self.hw_desc != other.hw_desc: return False |
| 2748 | if self.sw_desc != other.sw_desc: return False |
| 2749 | if self.serial_num != other.serial_num: return False |
| 2750 | if self.dp_desc != other.dp_desc: return False |
| 2751 | return True |
| 2752 | |
| 2753 | def __ne__(self, other): |
| 2754 | return not self.__eq__(other) |
| 2755 | |
| 2756 | def __str__(self): |
| 2757 | return self.show() |
| 2758 | |
| 2759 | def show(self): |
| 2760 | import loxi.pp |
| 2761 | return loxi.pp.pp(self) |
| 2762 | |
| 2763 | def pretty_print(self, q): |
| 2764 | q.text("desc_stats_reply {") |
| 2765 | with q.group(): |
| 2766 | with q.indent(2): |
| 2767 | q.breakable() |
| 2768 | q.text("xid = "); |
| 2769 | if self.xid != None: |
| 2770 | q.text("%#x" % self.xid) |
| 2771 | else: |
| 2772 | q.text('None') |
| 2773 | q.text(","); q.breakable() |
| 2774 | q.text("flags = "); |
| 2775 | q.text("%#x" % self.flags) |
| 2776 | q.text(","); q.breakable() |
| 2777 | q.text("mfr_desc = "); |
| 2778 | q.pp(self.mfr_desc) |
| 2779 | q.text(","); q.breakable() |
| 2780 | q.text("hw_desc = "); |
| 2781 | q.pp(self.hw_desc) |
| 2782 | q.text(","); q.breakable() |
| 2783 | q.text("sw_desc = "); |
| 2784 | q.pp(self.sw_desc) |
| 2785 | q.text(","); q.breakable() |
| 2786 | q.text("serial_num = "); |
| 2787 | q.pp(self.serial_num) |
| 2788 | q.text(","); q.breakable() |
| 2789 | q.text("dp_desc = "); |
| 2790 | q.pp(self.dp_desc) |
| 2791 | q.breakable() |
| 2792 | q.text('}') |
| 2793 | |
| 2794 | class desc_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2795 | version = 1 |
| 2796 | type = 16 |
| 2797 | stats_type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2798 | |
| 2799 | def __init__(self, xid=None, flags=None): |
| 2800 | self.xid = xid |
| 2801 | if flags != None: |
| 2802 | self.flags = flags |
| 2803 | else: |
| 2804 | self.flags = 0 |
| 2805 | |
| 2806 | def pack(self): |
| 2807 | packed = [] |
| 2808 | packed.append(struct.pack("!B", self.version)) |
| 2809 | packed.append(struct.pack("!B", self.type)) |
| 2810 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2811 | packed.append(struct.pack("!L", self.xid)) |
| 2812 | packed.append(struct.pack("!H", self.stats_type)) |
| 2813 | packed.append(struct.pack("!H", self.flags)) |
| 2814 | length = sum([len(x) for x in packed]) |
| 2815 | packed[2] = struct.pack("!H", length) |
| 2816 | return ''.join(packed) |
| 2817 | |
| 2818 | @staticmethod |
| 2819 | def unpack(buf): |
| 2820 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2821 | obj = desc_stats_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2822 | if type(buf) == loxi.generic_util.OFReader: |
| 2823 | reader = buf |
| 2824 | else: |
| 2825 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2826 | _version = reader.read("!B")[0] |
| 2827 | assert(_version == 1) |
| 2828 | _type = reader.read("!B")[0] |
| 2829 | assert(_type == 16) |
| 2830 | _length = reader.read("!H")[0] |
| 2831 | obj.xid = reader.read("!L")[0] |
| 2832 | _stats_type = reader.read("!H")[0] |
| 2833 | assert(_stats_type == 0) |
| 2834 | obj.flags = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2835 | return obj |
| 2836 | |
| 2837 | def __eq__(self, other): |
| 2838 | if type(self) != type(other): return False |
| 2839 | if self.version != other.version: return False |
| 2840 | if self.type != other.type: return False |
| 2841 | if self.xid != other.xid: return False |
| 2842 | if self.flags != other.flags: return False |
| 2843 | return True |
| 2844 | |
| 2845 | def __ne__(self, other): |
| 2846 | return not self.__eq__(other) |
| 2847 | |
| 2848 | def __str__(self): |
| 2849 | return self.show() |
| 2850 | |
| 2851 | def show(self): |
| 2852 | import loxi.pp |
| 2853 | return loxi.pp.pp(self) |
| 2854 | |
| 2855 | def pretty_print(self, q): |
| 2856 | q.text("desc_stats_request {") |
| 2857 | with q.group(): |
| 2858 | with q.indent(2): |
| 2859 | q.breakable() |
| 2860 | q.text("xid = "); |
| 2861 | if self.xid != None: |
| 2862 | q.text("%#x" % self.xid) |
| 2863 | else: |
| 2864 | q.text('None') |
| 2865 | q.text(","); q.breakable() |
| 2866 | q.text("flags = "); |
| 2867 | q.text("%#x" % self.flags) |
| 2868 | q.breakable() |
| 2869 | q.text('}') |
| 2870 | |
| 2871 | class echo_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2872 | version = 1 |
| 2873 | type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2874 | |
| 2875 | def __init__(self, xid=None, data=None): |
| 2876 | self.xid = xid |
| 2877 | if data != None: |
| 2878 | self.data = data |
| 2879 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2880 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2881 | |
| 2882 | def pack(self): |
| 2883 | packed = [] |
| 2884 | packed.append(struct.pack("!B", self.version)) |
| 2885 | packed.append(struct.pack("!B", self.type)) |
| 2886 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2887 | packed.append(struct.pack("!L", self.xid)) |
| 2888 | packed.append(self.data) |
| 2889 | length = sum([len(x) for x in packed]) |
| 2890 | packed[2] = struct.pack("!H", length) |
| 2891 | return ''.join(packed) |
| 2892 | |
| 2893 | @staticmethod |
| 2894 | def unpack(buf): |
| 2895 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2896 | obj = echo_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2897 | if type(buf) == loxi.generic_util.OFReader: |
| 2898 | reader = buf |
| 2899 | else: |
| 2900 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2901 | _version = reader.read("!B")[0] |
| 2902 | assert(_version == 1) |
| 2903 | _type = reader.read("!B")[0] |
| 2904 | assert(_type == 3) |
| 2905 | _length = reader.read("!H")[0] |
| 2906 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2907 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2908 | return obj |
| 2909 | |
| 2910 | def __eq__(self, other): |
| 2911 | if type(self) != type(other): return False |
| 2912 | if self.version != other.version: return False |
| 2913 | if self.type != other.type: return False |
| 2914 | if self.xid != other.xid: return False |
| 2915 | if self.data != other.data: return False |
| 2916 | return True |
| 2917 | |
| 2918 | def __ne__(self, other): |
| 2919 | return not self.__eq__(other) |
| 2920 | |
| 2921 | def __str__(self): |
| 2922 | return self.show() |
| 2923 | |
| 2924 | def show(self): |
| 2925 | import loxi.pp |
| 2926 | return loxi.pp.pp(self) |
| 2927 | |
| 2928 | def pretty_print(self, q): |
| 2929 | q.text("echo_reply {") |
| 2930 | with q.group(): |
| 2931 | with q.indent(2): |
| 2932 | q.breakable() |
| 2933 | q.text("xid = "); |
| 2934 | if self.xid != None: |
| 2935 | q.text("%#x" % self.xid) |
| 2936 | else: |
| 2937 | q.text('None') |
| 2938 | q.text(","); q.breakable() |
| 2939 | q.text("data = "); |
| 2940 | q.pp(self.data) |
| 2941 | q.breakable() |
| 2942 | q.text('}') |
| 2943 | |
| 2944 | class echo_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2945 | version = 1 |
| 2946 | type = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2947 | |
| 2948 | def __init__(self, xid=None, data=None): |
| 2949 | self.xid = xid |
| 2950 | if data != None: |
| 2951 | self.data = data |
| 2952 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2953 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2954 | |
| 2955 | def pack(self): |
| 2956 | packed = [] |
| 2957 | packed.append(struct.pack("!B", self.version)) |
| 2958 | packed.append(struct.pack("!B", self.type)) |
| 2959 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 2960 | packed.append(struct.pack("!L", self.xid)) |
| 2961 | packed.append(self.data) |
| 2962 | length = sum([len(x) for x in packed]) |
| 2963 | packed[2] = struct.pack("!H", length) |
| 2964 | return ''.join(packed) |
| 2965 | |
| 2966 | @staticmethod |
| 2967 | def unpack(buf): |
| 2968 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 2969 | obj = echo_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2970 | if type(buf) == loxi.generic_util.OFReader: |
| 2971 | reader = buf |
| 2972 | else: |
| 2973 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 2974 | _version = reader.read("!B")[0] |
| 2975 | assert(_version == 1) |
| 2976 | _type = reader.read("!B")[0] |
| 2977 | assert(_type == 2) |
| 2978 | _length = reader.read("!H")[0] |
| 2979 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 2980 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 2981 | return obj |
| 2982 | |
| 2983 | def __eq__(self, other): |
| 2984 | if type(self) != type(other): return False |
| 2985 | if self.version != other.version: return False |
| 2986 | if self.type != other.type: return False |
| 2987 | if self.xid != other.xid: return False |
| 2988 | if self.data != other.data: return False |
| 2989 | return True |
| 2990 | |
| 2991 | def __ne__(self, other): |
| 2992 | return not self.__eq__(other) |
| 2993 | |
| 2994 | def __str__(self): |
| 2995 | return self.show() |
| 2996 | |
| 2997 | def show(self): |
| 2998 | import loxi.pp |
| 2999 | return loxi.pp.pp(self) |
| 3000 | |
| 3001 | def pretty_print(self, q): |
| 3002 | q.text("echo_request {") |
| 3003 | with q.group(): |
| 3004 | with q.indent(2): |
| 3005 | q.breakable() |
| 3006 | q.text("xid = "); |
| 3007 | if self.xid != None: |
| 3008 | q.text("%#x" % self.xid) |
| 3009 | else: |
| 3010 | q.text('None') |
| 3011 | q.text(","); q.breakable() |
| 3012 | q.text("data = "); |
| 3013 | q.pp(self.data) |
| 3014 | q.breakable() |
| 3015 | q.text('}') |
| 3016 | |
| 3017 | class error_msg(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3018 | version = 1 |
| 3019 | type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3020 | |
| 3021 | def __init__(self, xid=None, err_type=None, code=None, data=None): |
| 3022 | self.xid = xid |
| 3023 | if err_type != None: |
| 3024 | self.err_type = err_type |
| 3025 | else: |
| 3026 | self.err_type = 0 |
| 3027 | if code != None: |
| 3028 | self.code = code |
| 3029 | else: |
| 3030 | self.code = 0 |
| 3031 | if data != None: |
| 3032 | self.data = data |
| 3033 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3034 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3035 | |
| 3036 | def pack(self): |
| 3037 | packed = [] |
| 3038 | packed.append(struct.pack("!B", self.version)) |
| 3039 | packed.append(struct.pack("!B", self.type)) |
| 3040 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3041 | packed.append(struct.pack("!L", self.xid)) |
| 3042 | packed.append(struct.pack("!H", self.err_type)) |
| 3043 | packed.append(struct.pack("!H", self.code)) |
| 3044 | packed.append(self.data) |
| 3045 | length = sum([len(x) for x in packed]) |
| 3046 | packed[2] = struct.pack("!H", length) |
| 3047 | return ''.join(packed) |
| 3048 | |
| 3049 | @staticmethod |
| 3050 | def unpack(buf): |
| 3051 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3052 | obj = error_msg() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3053 | if type(buf) == loxi.generic_util.OFReader: |
| 3054 | reader = buf |
| 3055 | else: |
| 3056 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3057 | _version = reader.read("!B")[0] |
| 3058 | assert(_version == 1) |
| 3059 | _type = reader.read("!B")[0] |
| 3060 | assert(_type == 1) |
| 3061 | _length = reader.read("!H")[0] |
| 3062 | obj.xid = reader.read("!L")[0] |
| 3063 | obj.err_type = reader.read("!H")[0] |
| 3064 | obj.code = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3065 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -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.err_type != other.err_type: return False |
| 3074 | if self.code != other.code: return False |
| 3075 | if self.data != other.data: return False |
| 3076 | return True |
| 3077 | |
| 3078 | def __ne__(self, other): |
| 3079 | return not self.__eq__(other) |
| 3080 | |
| 3081 | def __str__(self): |
| 3082 | return self.show() |
| 3083 | |
| 3084 | def show(self): |
| 3085 | import loxi.pp |
| 3086 | return loxi.pp.pp(self) |
| 3087 | |
| 3088 | def pretty_print(self, q): |
| 3089 | q.text("error_msg {") |
| 3090 | with q.group(): |
| 3091 | with q.indent(2): |
| 3092 | q.breakable() |
| 3093 | q.text("xid = "); |
| 3094 | if self.xid != None: |
| 3095 | q.text("%#x" % self.xid) |
| 3096 | else: |
| 3097 | q.text('None') |
| 3098 | q.text(","); q.breakable() |
| 3099 | q.text("err_type = "); |
| 3100 | q.text("%#x" % self.err_type) |
| 3101 | q.text(","); q.breakable() |
| 3102 | q.text("code = "); |
| 3103 | q.text("%#x" % self.code) |
| 3104 | q.text(","); q.breakable() |
| 3105 | q.text("data = "); |
| 3106 | q.pp(self.data) |
| 3107 | q.breakable() |
| 3108 | q.text('}') |
| 3109 | |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3110 | class features_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3111 | version = 1 |
| 3112 | type = 6 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3113 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3114 | def __init__(self, xid=None, datapath_id=None, n_buffers=None, n_tables=None, capabilities=None, actions=None, ports=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3115 | self.xid = xid |
| 3116 | if datapath_id != None: |
| 3117 | self.datapath_id = datapath_id |
| 3118 | else: |
| 3119 | self.datapath_id = 0 |
| 3120 | if n_buffers != None: |
| 3121 | self.n_buffers = n_buffers |
| 3122 | else: |
| 3123 | self.n_buffers = 0 |
| 3124 | if n_tables != None: |
| 3125 | self.n_tables = n_tables |
| 3126 | else: |
| 3127 | self.n_tables = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3128 | if capabilities != None: |
| 3129 | self.capabilities = capabilities |
| 3130 | else: |
| 3131 | self.capabilities = 0 |
| 3132 | if actions != None: |
| 3133 | self.actions = actions |
| 3134 | else: |
| 3135 | self.actions = 0 |
| 3136 | if ports != None: |
| 3137 | self.ports = ports |
| 3138 | else: |
| 3139 | self.ports = [] |
| 3140 | |
| 3141 | def pack(self): |
| 3142 | packed = [] |
| 3143 | packed.append(struct.pack("!B", self.version)) |
| 3144 | packed.append(struct.pack("!B", self.type)) |
| 3145 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3146 | packed.append(struct.pack("!L", self.xid)) |
| 3147 | packed.append(struct.pack("!Q", self.datapath_id)) |
| 3148 | packed.append(struct.pack("!L", self.n_buffers)) |
| 3149 | packed.append(struct.pack("!B", self.n_tables)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3150 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3151 | packed.append(struct.pack("!L", self.capabilities)) |
| 3152 | packed.append(struct.pack("!L", self.actions)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3153 | packed.append(util.pack_list(self.ports)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3154 | length = sum([len(x) for x in packed]) |
| 3155 | packed[2] = struct.pack("!H", length) |
| 3156 | return ''.join(packed) |
| 3157 | |
| 3158 | @staticmethod |
| 3159 | def unpack(buf): |
| 3160 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3161 | obj = features_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3162 | if type(buf) == loxi.generic_util.OFReader: |
| 3163 | reader = buf |
| 3164 | else: |
| 3165 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3166 | _version = reader.read("!B")[0] |
| 3167 | assert(_version == 1) |
| 3168 | _type = reader.read("!B")[0] |
| 3169 | assert(_type == 6) |
| 3170 | _length = reader.read("!H")[0] |
| 3171 | obj.xid = reader.read("!L")[0] |
| 3172 | obj.datapath_id = reader.read("!Q")[0] |
| 3173 | obj.n_buffers = reader.read("!L")[0] |
| 3174 | obj.n_tables = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3175 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3176 | obj.capabilities = reader.read("!L")[0] |
| 3177 | obj.actions = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3178 | obj.ports = loxi.generic_util.unpack_list(reader, common.port_desc.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3179 | return obj |
| 3180 | |
| 3181 | def __eq__(self, other): |
| 3182 | if type(self) != type(other): return False |
| 3183 | if self.version != other.version: return False |
| 3184 | if self.type != other.type: return False |
| 3185 | if self.xid != other.xid: return False |
| 3186 | if self.datapath_id != other.datapath_id: return False |
| 3187 | if self.n_buffers != other.n_buffers: return False |
| 3188 | if self.n_tables != other.n_tables: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3189 | if self.capabilities != other.capabilities: return False |
| 3190 | if self.actions != other.actions: return False |
| 3191 | if self.ports != other.ports: return False |
| 3192 | return True |
| 3193 | |
| 3194 | def __ne__(self, other): |
| 3195 | return not self.__eq__(other) |
| 3196 | |
| 3197 | def __str__(self): |
| 3198 | return self.show() |
| 3199 | |
| 3200 | def show(self): |
| 3201 | import loxi.pp |
| 3202 | return loxi.pp.pp(self) |
| 3203 | |
| 3204 | def pretty_print(self, q): |
| 3205 | q.text("features_reply {") |
| 3206 | with q.group(): |
| 3207 | with q.indent(2): |
| 3208 | q.breakable() |
| 3209 | q.text("xid = "); |
| 3210 | if self.xid != None: |
| 3211 | q.text("%#x" % self.xid) |
| 3212 | else: |
| 3213 | q.text('None') |
| 3214 | q.text(","); q.breakable() |
| 3215 | q.text("datapath_id = "); |
| 3216 | q.text("%#x" % self.datapath_id) |
| 3217 | q.text(","); q.breakable() |
| 3218 | q.text("n_buffers = "); |
| 3219 | q.text("%#x" % self.n_buffers) |
| 3220 | q.text(","); q.breakable() |
| 3221 | q.text("n_tables = "); |
| 3222 | q.text("%#x" % self.n_tables) |
| 3223 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3224 | q.text("capabilities = "); |
| 3225 | q.text("%#x" % self.capabilities) |
| 3226 | q.text(","); q.breakable() |
| 3227 | q.text("actions = "); |
| 3228 | q.text("%#x" % self.actions) |
| 3229 | q.text(","); q.breakable() |
| 3230 | q.text("ports = "); |
| 3231 | q.pp(self.ports) |
| 3232 | q.breakable() |
| 3233 | q.text('}') |
| 3234 | |
| 3235 | class features_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3236 | version = 1 |
| 3237 | type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3238 | |
| 3239 | def __init__(self, xid=None): |
| 3240 | self.xid = xid |
| 3241 | |
| 3242 | def pack(self): |
| 3243 | packed = [] |
| 3244 | packed.append(struct.pack("!B", self.version)) |
| 3245 | packed.append(struct.pack("!B", self.type)) |
| 3246 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3247 | packed.append(struct.pack("!L", self.xid)) |
| 3248 | length = sum([len(x) for x in packed]) |
| 3249 | packed[2] = struct.pack("!H", length) |
| 3250 | return ''.join(packed) |
| 3251 | |
| 3252 | @staticmethod |
| 3253 | def unpack(buf): |
| 3254 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3255 | obj = features_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3256 | if type(buf) == loxi.generic_util.OFReader: |
| 3257 | reader = buf |
| 3258 | else: |
| 3259 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3260 | _version = reader.read("!B")[0] |
| 3261 | assert(_version == 1) |
| 3262 | _type = reader.read("!B")[0] |
| 3263 | assert(_type == 5) |
| 3264 | _length = reader.read("!H")[0] |
| 3265 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3266 | return obj |
| 3267 | |
| 3268 | def __eq__(self, other): |
| 3269 | if type(self) != type(other): return False |
| 3270 | if self.version != other.version: return False |
| 3271 | if self.type != other.type: return False |
| 3272 | if self.xid != other.xid: return False |
| 3273 | return True |
| 3274 | |
| 3275 | def __ne__(self, other): |
| 3276 | return not self.__eq__(other) |
| 3277 | |
| 3278 | def __str__(self): |
| 3279 | return self.show() |
| 3280 | |
| 3281 | def show(self): |
| 3282 | import loxi.pp |
| 3283 | return loxi.pp.pp(self) |
| 3284 | |
| 3285 | def pretty_print(self, q): |
| 3286 | q.text("features_request {") |
| 3287 | with q.group(): |
| 3288 | with q.indent(2): |
| 3289 | q.breakable() |
| 3290 | q.text("xid = "); |
| 3291 | if self.xid != None: |
| 3292 | q.text("%#x" % self.xid) |
| 3293 | else: |
| 3294 | q.text('None') |
| 3295 | q.breakable() |
| 3296 | q.text('}') |
| 3297 | |
| 3298 | class flow_add(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3299 | version = 1 |
| 3300 | type = 14 |
| 3301 | _command = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3302 | |
| 3303 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
| 3304 | self.xid = xid |
| 3305 | if match != None: |
| 3306 | self.match = match |
| 3307 | else: |
| 3308 | self.match = common.match() |
| 3309 | if cookie != None: |
| 3310 | self.cookie = cookie |
| 3311 | else: |
| 3312 | self.cookie = 0 |
| 3313 | if idle_timeout != None: |
| 3314 | self.idle_timeout = idle_timeout |
| 3315 | else: |
| 3316 | self.idle_timeout = 0 |
| 3317 | if hard_timeout != None: |
| 3318 | self.hard_timeout = hard_timeout |
| 3319 | else: |
| 3320 | self.hard_timeout = 0 |
| 3321 | if priority != None: |
| 3322 | self.priority = priority |
| 3323 | else: |
| 3324 | self.priority = 0 |
| 3325 | if buffer_id != None: |
| 3326 | self.buffer_id = buffer_id |
| 3327 | else: |
| 3328 | self.buffer_id = 0 |
| 3329 | if out_port != None: |
| 3330 | self.out_port = out_port |
| 3331 | else: |
| 3332 | self.out_port = 0 |
| 3333 | if flags != None: |
| 3334 | self.flags = flags |
| 3335 | else: |
| 3336 | self.flags = 0 |
| 3337 | if actions != None: |
| 3338 | self.actions = actions |
| 3339 | else: |
| 3340 | self.actions = [] |
| 3341 | |
| 3342 | def pack(self): |
| 3343 | packed = [] |
| 3344 | packed.append(struct.pack("!B", self.version)) |
| 3345 | packed.append(struct.pack("!B", self.type)) |
| 3346 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3347 | packed.append(struct.pack("!L", self.xid)) |
| 3348 | packed.append(self.match.pack()) |
| 3349 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3350 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3351 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3352 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3353 | packed.append(struct.pack("!H", self.priority)) |
| 3354 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3355 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3356 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3357 | packed.append(util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3358 | length = sum([len(x) for x in packed]) |
| 3359 | packed[2] = struct.pack("!H", length) |
| 3360 | return ''.join(packed) |
| 3361 | |
| 3362 | @staticmethod |
| 3363 | def unpack(buf): |
| 3364 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3365 | obj = flow_add() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3366 | if type(buf) == loxi.generic_util.OFReader: |
| 3367 | reader = buf |
| 3368 | else: |
| 3369 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3370 | _version = reader.read("!B")[0] |
| 3371 | assert(_version == 1) |
| 3372 | _type = reader.read("!B")[0] |
| 3373 | assert(_type == 14) |
| 3374 | _length = reader.read("!H")[0] |
| 3375 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3376 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3377 | obj.cookie = reader.read("!Q")[0] |
| 3378 | __command = util.unpack_fm_cmd(reader) |
| 3379 | assert(__command == 0) |
| 3380 | obj.idle_timeout = reader.read("!H")[0] |
| 3381 | obj.hard_timeout = reader.read("!H")[0] |
| 3382 | obj.priority = reader.read("!H")[0] |
| 3383 | obj.buffer_id = reader.read("!L")[0] |
| 3384 | obj.out_port = util.unpack_port_no(reader) |
| 3385 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3386 | obj.actions = action.unpack_list(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3387 | return obj |
| 3388 | |
| 3389 | def __eq__(self, other): |
| 3390 | if type(self) != type(other): return False |
| 3391 | if self.version != other.version: return False |
| 3392 | if self.type != other.type: return False |
| 3393 | if self.xid != other.xid: return False |
| 3394 | if self.match != other.match: return False |
| 3395 | if self.cookie != other.cookie: return False |
| 3396 | if self.idle_timeout != other.idle_timeout: return False |
| 3397 | if self.hard_timeout != other.hard_timeout: return False |
| 3398 | if self.priority != other.priority: return False |
| 3399 | if self.buffer_id != other.buffer_id: return False |
| 3400 | if self.out_port != other.out_port: return False |
| 3401 | if self.flags != other.flags: return False |
| 3402 | if self.actions != other.actions: return False |
| 3403 | return True |
| 3404 | |
| 3405 | def __ne__(self, other): |
| 3406 | return not self.__eq__(other) |
| 3407 | |
| 3408 | def __str__(self): |
| 3409 | return self.show() |
| 3410 | |
| 3411 | def show(self): |
| 3412 | import loxi.pp |
| 3413 | return loxi.pp.pp(self) |
| 3414 | |
| 3415 | def pretty_print(self, q): |
| 3416 | q.text("flow_add {") |
| 3417 | with q.group(): |
| 3418 | with q.indent(2): |
| 3419 | q.breakable() |
| 3420 | q.text("xid = "); |
| 3421 | if self.xid != None: |
| 3422 | q.text("%#x" % self.xid) |
| 3423 | else: |
| 3424 | q.text('None') |
| 3425 | q.text(","); q.breakable() |
| 3426 | q.text("match = "); |
| 3427 | q.pp(self.match) |
| 3428 | q.text(","); q.breakable() |
| 3429 | q.text("cookie = "); |
| 3430 | q.text("%#x" % self.cookie) |
| 3431 | q.text(","); q.breakable() |
| 3432 | q.text("idle_timeout = "); |
| 3433 | q.text("%#x" % self.idle_timeout) |
| 3434 | q.text(","); q.breakable() |
| 3435 | q.text("hard_timeout = "); |
| 3436 | q.text("%#x" % self.hard_timeout) |
| 3437 | q.text(","); q.breakable() |
| 3438 | q.text("priority = "); |
| 3439 | q.text("%#x" % self.priority) |
| 3440 | q.text(","); q.breakable() |
| 3441 | q.text("buffer_id = "); |
| 3442 | q.text("%#x" % self.buffer_id) |
| 3443 | q.text(","); q.breakable() |
| 3444 | q.text("out_port = "); |
| 3445 | q.text(util.pretty_port(self.out_port)) |
| 3446 | q.text(","); q.breakable() |
| 3447 | q.text("flags = "); |
| 3448 | q.text("%#x" % self.flags) |
| 3449 | q.text(","); q.breakable() |
| 3450 | q.text("actions = "); |
| 3451 | q.pp(self.actions) |
| 3452 | q.breakable() |
| 3453 | q.text('}') |
| 3454 | |
| 3455 | class flow_delete(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3456 | version = 1 |
| 3457 | type = 14 |
| 3458 | _command = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3459 | |
| 3460 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
| 3461 | self.xid = xid |
| 3462 | if match != None: |
| 3463 | self.match = match |
| 3464 | else: |
| 3465 | self.match = common.match() |
| 3466 | if cookie != None: |
| 3467 | self.cookie = cookie |
| 3468 | else: |
| 3469 | self.cookie = 0 |
| 3470 | if idle_timeout != None: |
| 3471 | self.idle_timeout = idle_timeout |
| 3472 | else: |
| 3473 | self.idle_timeout = 0 |
| 3474 | if hard_timeout != None: |
| 3475 | self.hard_timeout = hard_timeout |
| 3476 | else: |
| 3477 | self.hard_timeout = 0 |
| 3478 | if priority != None: |
| 3479 | self.priority = priority |
| 3480 | else: |
| 3481 | self.priority = 0 |
| 3482 | if buffer_id != None: |
| 3483 | self.buffer_id = buffer_id |
| 3484 | else: |
| 3485 | self.buffer_id = 0 |
| 3486 | if out_port != None: |
| 3487 | self.out_port = out_port |
| 3488 | else: |
| 3489 | self.out_port = 0 |
| 3490 | if flags != None: |
| 3491 | self.flags = flags |
| 3492 | else: |
| 3493 | self.flags = 0 |
| 3494 | if actions != None: |
| 3495 | self.actions = actions |
| 3496 | else: |
| 3497 | self.actions = [] |
| 3498 | |
| 3499 | def pack(self): |
| 3500 | packed = [] |
| 3501 | packed.append(struct.pack("!B", self.version)) |
| 3502 | packed.append(struct.pack("!B", self.type)) |
| 3503 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3504 | packed.append(struct.pack("!L", self.xid)) |
| 3505 | packed.append(self.match.pack()) |
| 3506 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3507 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3508 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3509 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3510 | packed.append(struct.pack("!H", self.priority)) |
| 3511 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3512 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3513 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3514 | packed.append(util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3515 | length = sum([len(x) for x in packed]) |
| 3516 | packed[2] = struct.pack("!H", length) |
| 3517 | return ''.join(packed) |
| 3518 | |
| 3519 | @staticmethod |
| 3520 | def unpack(buf): |
| 3521 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3522 | obj = flow_delete() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3523 | if type(buf) == loxi.generic_util.OFReader: |
| 3524 | reader = buf |
| 3525 | else: |
| 3526 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3527 | _version = reader.read("!B")[0] |
| 3528 | assert(_version == 1) |
| 3529 | _type = reader.read("!B")[0] |
| 3530 | assert(_type == 14) |
| 3531 | _length = reader.read("!H")[0] |
| 3532 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3533 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3534 | obj.cookie = reader.read("!Q")[0] |
| 3535 | __command = util.unpack_fm_cmd(reader) |
| 3536 | assert(__command == 3) |
| 3537 | obj.idle_timeout = reader.read("!H")[0] |
| 3538 | obj.hard_timeout = reader.read("!H")[0] |
| 3539 | obj.priority = reader.read("!H")[0] |
| 3540 | obj.buffer_id = reader.read("!L")[0] |
| 3541 | obj.out_port = util.unpack_port_no(reader) |
| 3542 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3543 | obj.actions = action.unpack_list(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3544 | return obj |
| 3545 | |
| 3546 | def __eq__(self, other): |
| 3547 | if type(self) != type(other): return False |
| 3548 | if self.version != other.version: return False |
| 3549 | if self.type != other.type: return False |
| 3550 | if self.xid != other.xid: return False |
| 3551 | if self.match != other.match: return False |
| 3552 | if self.cookie != other.cookie: return False |
| 3553 | if self.idle_timeout != other.idle_timeout: return False |
| 3554 | if self.hard_timeout != other.hard_timeout: return False |
| 3555 | if self.priority != other.priority: return False |
| 3556 | if self.buffer_id != other.buffer_id: return False |
| 3557 | if self.out_port != other.out_port: return False |
| 3558 | if self.flags != other.flags: return False |
| 3559 | if self.actions != other.actions: return False |
| 3560 | return True |
| 3561 | |
| 3562 | def __ne__(self, other): |
| 3563 | return not self.__eq__(other) |
| 3564 | |
| 3565 | def __str__(self): |
| 3566 | return self.show() |
| 3567 | |
| 3568 | def show(self): |
| 3569 | import loxi.pp |
| 3570 | return loxi.pp.pp(self) |
| 3571 | |
| 3572 | def pretty_print(self, q): |
| 3573 | q.text("flow_delete {") |
| 3574 | with q.group(): |
| 3575 | with q.indent(2): |
| 3576 | q.breakable() |
| 3577 | q.text("xid = "); |
| 3578 | if self.xid != None: |
| 3579 | q.text("%#x" % self.xid) |
| 3580 | else: |
| 3581 | q.text('None') |
| 3582 | q.text(","); q.breakable() |
| 3583 | q.text("match = "); |
| 3584 | q.pp(self.match) |
| 3585 | q.text(","); q.breakable() |
| 3586 | q.text("cookie = "); |
| 3587 | q.text("%#x" % self.cookie) |
| 3588 | q.text(","); q.breakable() |
| 3589 | q.text("idle_timeout = "); |
| 3590 | q.text("%#x" % self.idle_timeout) |
| 3591 | q.text(","); q.breakable() |
| 3592 | q.text("hard_timeout = "); |
| 3593 | q.text("%#x" % self.hard_timeout) |
| 3594 | q.text(","); q.breakable() |
| 3595 | q.text("priority = "); |
| 3596 | q.text("%#x" % self.priority) |
| 3597 | q.text(","); q.breakable() |
| 3598 | q.text("buffer_id = "); |
| 3599 | q.text("%#x" % self.buffer_id) |
| 3600 | q.text(","); q.breakable() |
| 3601 | q.text("out_port = "); |
| 3602 | q.text(util.pretty_port(self.out_port)) |
| 3603 | q.text(","); q.breakable() |
| 3604 | q.text("flags = "); |
| 3605 | q.text("%#x" % self.flags) |
| 3606 | q.text(","); q.breakable() |
| 3607 | q.text("actions = "); |
| 3608 | q.pp(self.actions) |
| 3609 | q.breakable() |
| 3610 | q.text('}') |
| 3611 | |
| 3612 | class flow_delete_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3613 | version = 1 |
| 3614 | type = 14 |
| 3615 | _command = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3616 | |
| 3617 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
| 3618 | self.xid = xid |
| 3619 | if match != None: |
| 3620 | self.match = match |
| 3621 | else: |
| 3622 | self.match = common.match() |
| 3623 | if cookie != None: |
| 3624 | self.cookie = cookie |
| 3625 | else: |
| 3626 | self.cookie = 0 |
| 3627 | if idle_timeout != None: |
| 3628 | self.idle_timeout = idle_timeout |
| 3629 | else: |
| 3630 | self.idle_timeout = 0 |
| 3631 | if hard_timeout != None: |
| 3632 | self.hard_timeout = hard_timeout |
| 3633 | else: |
| 3634 | self.hard_timeout = 0 |
| 3635 | if priority != None: |
| 3636 | self.priority = priority |
| 3637 | else: |
| 3638 | self.priority = 0 |
| 3639 | if buffer_id != None: |
| 3640 | self.buffer_id = buffer_id |
| 3641 | else: |
| 3642 | self.buffer_id = 0 |
| 3643 | if out_port != None: |
| 3644 | self.out_port = out_port |
| 3645 | else: |
| 3646 | self.out_port = 0 |
| 3647 | if flags != None: |
| 3648 | self.flags = flags |
| 3649 | else: |
| 3650 | self.flags = 0 |
| 3651 | if actions != None: |
| 3652 | self.actions = actions |
| 3653 | else: |
| 3654 | self.actions = [] |
| 3655 | |
| 3656 | def pack(self): |
| 3657 | packed = [] |
| 3658 | packed.append(struct.pack("!B", self.version)) |
| 3659 | packed.append(struct.pack("!B", self.type)) |
| 3660 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3661 | packed.append(struct.pack("!L", self.xid)) |
| 3662 | packed.append(self.match.pack()) |
| 3663 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3664 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3665 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3666 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3667 | packed.append(struct.pack("!H", self.priority)) |
| 3668 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3669 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3670 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3671 | packed.append(util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3672 | length = sum([len(x) for x in packed]) |
| 3673 | packed[2] = struct.pack("!H", length) |
| 3674 | return ''.join(packed) |
| 3675 | |
| 3676 | @staticmethod |
| 3677 | def unpack(buf): |
| 3678 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3679 | obj = flow_delete_strict() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3680 | if type(buf) == loxi.generic_util.OFReader: |
| 3681 | reader = buf |
| 3682 | else: |
| 3683 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3684 | _version = reader.read("!B")[0] |
| 3685 | assert(_version == 1) |
| 3686 | _type = reader.read("!B")[0] |
| 3687 | assert(_type == 14) |
| 3688 | _length = reader.read("!H")[0] |
| 3689 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3690 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3691 | obj.cookie = reader.read("!Q")[0] |
| 3692 | __command = util.unpack_fm_cmd(reader) |
| 3693 | assert(__command == 4) |
| 3694 | obj.idle_timeout = reader.read("!H")[0] |
| 3695 | obj.hard_timeout = reader.read("!H")[0] |
| 3696 | obj.priority = reader.read("!H")[0] |
| 3697 | obj.buffer_id = reader.read("!L")[0] |
| 3698 | obj.out_port = util.unpack_port_no(reader) |
| 3699 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3700 | obj.actions = action.unpack_list(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3701 | return obj |
| 3702 | |
| 3703 | def __eq__(self, other): |
| 3704 | if type(self) != type(other): return False |
| 3705 | if self.version != other.version: return False |
| 3706 | if self.type != other.type: return False |
| 3707 | if self.xid != other.xid: return False |
| 3708 | if self.match != other.match: return False |
| 3709 | if self.cookie != other.cookie: return False |
| 3710 | if self.idle_timeout != other.idle_timeout: return False |
| 3711 | if self.hard_timeout != other.hard_timeout: return False |
| 3712 | if self.priority != other.priority: return False |
| 3713 | if self.buffer_id != other.buffer_id: return False |
| 3714 | if self.out_port != other.out_port: return False |
| 3715 | if self.flags != other.flags: return False |
| 3716 | if self.actions != other.actions: return False |
| 3717 | return True |
| 3718 | |
| 3719 | def __ne__(self, other): |
| 3720 | return not self.__eq__(other) |
| 3721 | |
| 3722 | def __str__(self): |
| 3723 | return self.show() |
| 3724 | |
| 3725 | def show(self): |
| 3726 | import loxi.pp |
| 3727 | return loxi.pp.pp(self) |
| 3728 | |
| 3729 | def pretty_print(self, q): |
| 3730 | q.text("flow_delete_strict {") |
| 3731 | with q.group(): |
| 3732 | with q.indent(2): |
| 3733 | q.breakable() |
| 3734 | q.text("xid = "); |
| 3735 | if self.xid != None: |
| 3736 | q.text("%#x" % self.xid) |
| 3737 | else: |
| 3738 | q.text('None') |
| 3739 | q.text(","); q.breakable() |
| 3740 | q.text("match = "); |
| 3741 | q.pp(self.match) |
| 3742 | q.text(","); q.breakable() |
| 3743 | q.text("cookie = "); |
| 3744 | q.text("%#x" % self.cookie) |
| 3745 | q.text(","); q.breakable() |
| 3746 | q.text("idle_timeout = "); |
| 3747 | q.text("%#x" % self.idle_timeout) |
| 3748 | q.text(","); q.breakable() |
| 3749 | q.text("hard_timeout = "); |
| 3750 | q.text("%#x" % self.hard_timeout) |
| 3751 | q.text(","); q.breakable() |
| 3752 | q.text("priority = "); |
| 3753 | q.text("%#x" % self.priority) |
| 3754 | q.text(","); q.breakable() |
| 3755 | q.text("buffer_id = "); |
| 3756 | q.text("%#x" % self.buffer_id) |
| 3757 | q.text(","); q.breakable() |
| 3758 | q.text("out_port = "); |
| 3759 | q.text(util.pretty_port(self.out_port)) |
| 3760 | q.text(","); q.breakable() |
| 3761 | q.text("flags = "); |
| 3762 | q.text("%#x" % self.flags) |
| 3763 | q.text(","); q.breakable() |
| 3764 | q.text("actions = "); |
| 3765 | q.pp(self.actions) |
| 3766 | q.breakable() |
| 3767 | q.text('}') |
| 3768 | |
| 3769 | class flow_modify(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3770 | version = 1 |
| 3771 | type = 14 |
| 3772 | _command = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3773 | |
| 3774 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
| 3775 | self.xid = xid |
| 3776 | if match != None: |
| 3777 | self.match = match |
| 3778 | else: |
| 3779 | self.match = common.match() |
| 3780 | if cookie != None: |
| 3781 | self.cookie = cookie |
| 3782 | else: |
| 3783 | self.cookie = 0 |
| 3784 | if idle_timeout != None: |
| 3785 | self.idle_timeout = idle_timeout |
| 3786 | else: |
| 3787 | self.idle_timeout = 0 |
| 3788 | if hard_timeout != None: |
| 3789 | self.hard_timeout = hard_timeout |
| 3790 | else: |
| 3791 | self.hard_timeout = 0 |
| 3792 | if priority != None: |
| 3793 | self.priority = priority |
| 3794 | else: |
| 3795 | self.priority = 0 |
| 3796 | if buffer_id != None: |
| 3797 | self.buffer_id = buffer_id |
| 3798 | else: |
| 3799 | self.buffer_id = 0 |
| 3800 | if out_port != None: |
| 3801 | self.out_port = out_port |
| 3802 | else: |
| 3803 | self.out_port = 0 |
| 3804 | if flags != None: |
| 3805 | self.flags = flags |
| 3806 | else: |
| 3807 | self.flags = 0 |
| 3808 | if actions != None: |
| 3809 | self.actions = actions |
| 3810 | else: |
| 3811 | self.actions = [] |
| 3812 | |
| 3813 | def pack(self): |
| 3814 | packed = [] |
| 3815 | packed.append(struct.pack("!B", self.version)) |
| 3816 | packed.append(struct.pack("!B", self.type)) |
| 3817 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3818 | packed.append(struct.pack("!L", self.xid)) |
| 3819 | packed.append(self.match.pack()) |
| 3820 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3821 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3822 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3823 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3824 | packed.append(struct.pack("!H", self.priority)) |
| 3825 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3826 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3827 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3828 | packed.append(util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3829 | length = sum([len(x) for x in packed]) |
| 3830 | packed[2] = struct.pack("!H", length) |
| 3831 | return ''.join(packed) |
| 3832 | |
| 3833 | @staticmethod |
| 3834 | def unpack(buf): |
| 3835 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3836 | obj = flow_modify() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3837 | if type(buf) == loxi.generic_util.OFReader: |
| 3838 | reader = buf |
| 3839 | else: |
| 3840 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3841 | _version = reader.read("!B")[0] |
| 3842 | assert(_version == 1) |
| 3843 | _type = reader.read("!B")[0] |
| 3844 | assert(_type == 14) |
| 3845 | _length = reader.read("!H")[0] |
| 3846 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3847 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3848 | obj.cookie = reader.read("!Q")[0] |
| 3849 | __command = util.unpack_fm_cmd(reader) |
| 3850 | assert(__command == 1) |
| 3851 | obj.idle_timeout = reader.read("!H")[0] |
| 3852 | obj.hard_timeout = reader.read("!H")[0] |
| 3853 | obj.priority = reader.read("!H")[0] |
| 3854 | obj.buffer_id = reader.read("!L")[0] |
| 3855 | obj.out_port = util.unpack_port_no(reader) |
| 3856 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3857 | obj.actions = action.unpack_list(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3858 | return obj |
| 3859 | |
| 3860 | def __eq__(self, other): |
| 3861 | if type(self) != type(other): return False |
| 3862 | if self.version != other.version: return False |
| 3863 | if self.type != other.type: return False |
| 3864 | if self.xid != other.xid: return False |
| 3865 | if self.match != other.match: return False |
| 3866 | if self.cookie != other.cookie: return False |
| 3867 | if self.idle_timeout != other.idle_timeout: return False |
| 3868 | if self.hard_timeout != other.hard_timeout: return False |
| 3869 | if self.priority != other.priority: return False |
| 3870 | if self.buffer_id != other.buffer_id: return False |
| 3871 | if self.out_port != other.out_port: return False |
| 3872 | if self.flags != other.flags: return False |
| 3873 | if self.actions != other.actions: return False |
| 3874 | return True |
| 3875 | |
| 3876 | def __ne__(self, other): |
| 3877 | return not self.__eq__(other) |
| 3878 | |
| 3879 | def __str__(self): |
| 3880 | return self.show() |
| 3881 | |
| 3882 | def show(self): |
| 3883 | import loxi.pp |
| 3884 | return loxi.pp.pp(self) |
| 3885 | |
| 3886 | def pretty_print(self, q): |
| 3887 | q.text("flow_modify {") |
| 3888 | with q.group(): |
| 3889 | with q.indent(2): |
| 3890 | q.breakable() |
| 3891 | q.text("xid = "); |
| 3892 | if self.xid != None: |
| 3893 | q.text("%#x" % self.xid) |
| 3894 | else: |
| 3895 | q.text('None') |
| 3896 | q.text(","); q.breakable() |
| 3897 | q.text("match = "); |
| 3898 | q.pp(self.match) |
| 3899 | q.text(","); q.breakable() |
| 3900 | q.text("cookie = "); |
| 3901 | q.text("%#x" % self.cookie) |
| 3902 | q.text(","); q.breakable() |
| 3903 | q.text("idle_timeout = "); |
| 3904 | q.text("%#x" % self.idle_timeout) |
| 3905 | q.text(","); q.breakable() |
| 3906 | q.text("hard_timeout = "); |
| 3907 | q.text("%#x" % self.hard_timeout) |
| 3908 | q.text(","); q.breakable() |
| 3909 | q.text("priority = "); |
| 3910 | q.text("%#x" % self.priority) |
| 3911 | q.text(","); q.breakable() |
| 3912 | q.text("buffer_id = "); |
| 3913 | q.text("%#x" % self.buffer_id) |
| 3914 | q.text(","); q.breakable() |
| 3915 | q.text("out_port = "); |
| 3916 | q.text(util.pretty_port(self.out_port)) |
| 3917 | q.text(","); q.breakable() |
| 3918 | q.text("flags = "); |
| 3919 | q.text("%#x" % self.flags) |
| 3920 | q.text(","); q.breakable() |
| 3921 | q.text("actions = "); |
| 3922 | q.pp(self.actions) |
| 3923 | q.breakable() |
| 3924 | q.text('}') |
| 3925 | |
| 3926 | class flow_modify_strict(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3927 | version = 1 |
| 3928 | type = 14 |
| 3929 | _command = 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3930 | |
| 3931 | def __init__(self, xid=None, match=None, cookie=None, idle_timeout=None, hard_timeout=None, priority=None, buffer_id=None, out_port=None, flags=None, actions=None): |
| 3932 | self.xid = xid |
| 3933 | if match != None: |
| 3934 | self.match = match |
| 3935 | else: |
| 3936 | self.match = common.match() |
| 3937 | if cookie != None: |
| 3938 | self.cookie = cookie |
| 3939 | else: |
| 3940 | self.cookie = 0 |
| 3941 | if idle_timeout != None: |
| 3942 | self.idle_timeout = idle_timeout |
| 3943 | else: |
| 3944 | self.idle_timeout = 0 |
| 3945 | if hard_timeout != None: |
| 3946 | self.hard_timeout = hard_timeout |
| 3947 | else: |
| 3948 | self.hard_timeout = 0 |
| 3949 | if priority != None: |
| 3950 | self.priority = priority |
| 3951 | else: |
| 3952 | self.priority = 0 |
| 3953 | if buffer_id != None: |
| 3954 | self.buffer_id = buffer_id |
| 3955 | else: |
| 3956 | self.buffer_id = 0 |
| 3957 | if out_port != None: |
| 3958 | self.out_port = out_port |
| 3959 | else: |
| 3960 | self.out_port = 0 |
| 3961 | if flags != None: |
| 3962 | self.flags = flags |
| 3963 | else: |
| 3964 | self.flags = 0 |
| 3965 | if actions != None: |
| 3966 | self.actions = actions |
| 3967 | else: |
| 3968 | self.actions = [] |
| 3969 | |
| 3970 | def pack(self): |
| 3971 | packed = [] |
| 3972 | packed.append(struct.pack("!B", self.version)) |
| 3973 | packed.append(struct.pack("!B", self.type)) |
| 3974 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 3975 | packed.append(struct.pack("!L", self.xid)) |
| 3976 | packed.append(self.match.pack()) |
| 3977 | packed.append(struct.pack("!Q", self.cookie)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3978 | packed.append(util.pack_fm_cmd(self._command)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3979 | packed.append(struct.pack("!H", self.idle_timeout)) |
| 3980 | packed.append(struct.pack("!H", self.hard_timeout)) |
| 3981 | packed.append(struct.pack("!H", self.priority)) |
| 3982 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3983 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3984 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3985 | packed.append(util.pack_list(self.actions)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 3986 | length = sum([len(x) for x in packed]) |
| 3987 | packed[2] = struct.pack("!H", length) |
| 3988 | return ''.join(packed) |
| 3989 | |
| 3990 | @staticmethod |
| 3991 | def unpack(buf): |
| 3992 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 3993 | obj = flow_modify_strict() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 3994 | if type(buf) == loxi.generic_util.OFReader: |
| 3995 | reader = buf |
| 3996 | else: |
| 3997 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 3998 | _version = reader.read("!B")[0] |
| 3999 | assert(_version == 1) |
| 4000 | _type = reader.read("!B")[0] |
| 4001 | assert(_type == 14) |
| 4002 | _length = reader.read("!H")[0] |
| 4003 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4004 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4005 | obj.cookie = reader.read("!Q")[0] |
| 4006 | __command = util.unpack_fm_cmd(reader) |
| 4007 | assert(__command == 2) |
| 4008 | obj.idle_timeout = reader.read("!H")[0] |
| 4009 | obj.hard_timeout = reader.read("!H")[0] |
| 4010 | obj.priority = reader.read("!H")[0] |
| 4011 | obj.buffer_id = reader.read("!L")[0] |
| 4012 | obj.out_port = util.unpack_port_no(reader) |
| 4013 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4014 | obj.actions = action.unpack_list(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4015 | return obj |
| 4016 | |
| 4017 | def __eq__(self, other): |
| 4018 | if type(self) != type(other): return False |
| 4019 | if self.version != other.version: return False |
| 4020 | if self.type != other.type: return False |
| 4021 | if self.xid != other.xid: return False |
| 4022 | if self.match != other.match: return False |
| 4023 | if self.cookie != other.cookie: return False |
| 4024 | if self.idle_timeout != other.idle_timeout: return False |
| 4025 | if self.hard_timeout != other.hard_timeout: return False |
| 4026 | if self.priority != other.priority: return False |
| 4027 | if self.buffer_id != other.buffer_id: return False |
| 4028 | if self.out_port != other.out_port: return False |
| 4029 | if self.flags != other.flags: return False |
| 4030 | if self.actions != other.actions: return False |
| 4031 | return True |
| 4032 | |
| 4033 | def __ne__(self, other): |
| 4034 | return not self.__eq__(other) |
| 4035 | |
| 4036 | def __str__(self): |
| 4037 | return self.show() |
| 4038 | |
| 4039 | def show(self): |
| 4040 | import loxi.pp |
| 4041 | return loxi.pp.pp(self) |
| 4042 | |
| 4043 | def pretty_print(self, q): |
| 4044 | q.text("flow_modify_strict {") |
| 4045 | with q.group(): |
| 4046 | with q.indent(2): |
| 4047 | q.breakable() |
| 4048 | q.text("xid = "); |
| 4049 | if self.xid != None: |
| 4050 | q.text("%#x" % self.xid) |
| 4051 | else: |
| 4052 | q.text('None') |
| 4053 | q.text(","); q.breakable() |
| 4054 | q.text("match = "); |
| 4055 | q.pp(self.match) |
| 4056 | q.text(","); q.breakable() |
| 4057 | q.text("cookie = "); |
| 4058 | q.text("%#x" % self.cookie) |
| 4059 | q.text(","); q.breakable() |
| 4060 | q.text("idle_timeout = "); |
| 4061 | q.text("%#x" % self.idle_timeout) |
| 4062 | q.text(","); q.breakable() |
| 4063 | q.text("hard_timeout = "); |
| 4064 | q.text("%#x" % self.hard_timeout) |
| 4065 | q.text(","); q.breakable() |
| 4066 | q.text("priority = "); |
| 4067 | q.text("%#x" % self.priority) |
| 4068 | q.text(","); q.breakable() |
| 4069 | q.text("buffer_id = "); |
| 4070 | q.text("%#x" % self.buffer_id) |
| 4071 | q.text(","); q.breakable() |
| 4072 | q.text("out_port = "); |
| 4073 | q.text(util.pretty_port(self.out_port)) |
| 4074 | q.text(","); q.breakable() |
| 4075 | q.text("flags = "); |
| 4076 | q.text("%#x" % self.flags) |
| 4077 | q.text(","); q.breakable() |
| 4078 | q.text("actions = "); |
| 4079 | q.pp(self.actions) |
| 4080 | q.breakable() |
| 4081 | q.text('}') |
| 4082 | |
| 4083 | class flow_removed(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4084 | version = 1 |
| 4085 | type = 11 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4086 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4087 | def __init__(self, xid=None, match=None, cookie=None, priority=None, reason=None, duration_sec=None, duration_nsec=None, idle_timeout=None, packet_count=None, byte_count=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4088 | self.xid = xid |
| 4089 | if match != None: |
| 4090 | self.match = match |
| 4091 | else: |
| 4092 | self.match = common.match() |
| 4093 | if cookie != None: |
| 4094 | self.cookie = cookie |
| 4095 | else: |
| 4096 | self.cookie = 0 |
| 4097 | if priority != None: |
| 4098 | self.priority = priority |
| 4099 | else: |
| 4100 | self.priority = 0 |
| 4101 | if reason != None: |
| 4102 | self.reason = reason |
| 4103 | else: |
| 4104 | self.reason = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4105 | if duration_sec != None: |
| 4106 | self.duration_sec = duration_sec |
| 4107 | else: |
| 4108 | self.duration_sec = 0 |
| 4109 | if duration_nsec != None: |
| 4110 | self.duration_nsec = duration_nsec |
| 4111 | else: |
| 4112 | self.duration_nsec = 0 |
| 4113 | if idle_timeout != None: |
| 4114 | self.idle_timeout = idle_timeout |
| 4115 | else: |
| 4116 | self.idle_timeout = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4117 | if packet_count != None: |
| 4118 | self.packet_count = packet_count |
| 4119 | else: |
| 4120 | self.packet_count = 0 |
| 4121 | if byte_count != None: |
| 4122 | self.byte_count = byte_count |
| 4123 | else: |
| 4124 | self.byte_count = 0 |
| 4125 | |
| 4126 | def pack(self): |
| 4127 | packed = [] |
| 4128 | packed.append(struct.pack("!B", self.version)) |
| 4129 | packed.append(struct.pack("!B", self.type)) |
| 4130 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4131 | packed.append(struct.pack("!L", self.xid)) |
| 4132 | packed.append(self.match.pack()) |
| 4133 | packed.append(struct.pack("!Q", self.cookie)) |
| 4134 | packed.append(struct.pack("!H", self.priority)) |
| 4135 | packed.append(struct.pack("!B", self.reason)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4136 | packed.append('\x00' * 1) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4137 | packed.append(struct.pack("!L", self.duration_sec)) |
| 4138 | packed.append(struct.pack("!L", self.duration_nsec)) |
| 4139 | packed.append(struct.pack("!H", self.idle_timeout)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4140 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4141 | packed.append(struct.pack("!Q", self.packet_count)) |
| 4142 | packed.append(struct.pack("!Q", self.byte_count)) |
| 4143 | length = sum([len(x) for x in packed]) |
| 4144 | packed[2] = struct.pack("!H", length) |
| 4145 | return ''.join(packed) |
| 4146 | |
| 4147 | @staticmethod |
| 4148 | def unpack(buf): |
| 4149 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4150 | obj = flow_removed() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4151 | if type(buf) == loxi.generic_util.OFReader: |
| 4152 | reader = buf |
| 4153 | else: |
| 4154 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4155 | _version = reader.read("!B")[0] |
| 4156 | assert(_version == 1) |
| 4157 | _type = reader.read("!B")[0] |
| 4158 | assert(_type == 11) |
| 4159 | _length = reader.read("!H")[0] |
| 4160 | obj.xid = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4161 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4162 | obj.cookie = reader.read("!Q")[0] |
| 4163 | obj.priority = reader.read("!H")[0] |
| 4164 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4165 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4166 | obj.duration_sec = reader.read("!L")[0] |
| 4167 | obj.duration_nsec = reader.read("!L")[0] |
| 4168 | obj.idle_timeout = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4169 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4170 | obj.packet_count = reader.read("!Q")[0] |
| 4171 | obj.byte_count = reader.read("!Q")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4172 | return obj |
| 4173 | |
| 4174 | def __eq__(self, other): |
| 4175 | if type(self) != type(other): return False |
| 4176 | if self.version != other.version: return False |
| 4177 | if self.type != other.type: return False |
| 4178 | if self.xid != other.xid: return False |
| 4179 | if self.match != other.match: return False |
| 4180 | if self.cookie != other.cookie: return False |
| 4181 | if self.priority != other.priority: return False |
| 4182 | if self.reason != other.reason: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4183 | if self.duration_sec != other.duration_sec: return False |
| 4184 | if self.duration_nsec != other.duration_nsec: return False |
| 4185 | if self.idle_timeout != other.idle_timeout: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4186 | if self.packet_count != other.packet_count: return False |
| 4187 | if self.byte_count != other.byte_count: return False |
| 4188 | return True |
| 4189 | |
| 4190 | def __ne__(self, other): |
| 4191 | return not self.__eq__(other) |
| 4192 | |
| 4193 | def __str__(self): |
| 4194 | return self.show() |
| 4195 | |
| 4196 | def show(self): |
| 4197 | import loxi.pp |
| 4198 | return loxi.pp.pp(self) |
| 4199 | |
| 4200 | def pretty_print(self, q): |
| 4201 | q.text("flow_removed {") |
| 4202 | with q.group(): |
| 4203 | with q.indent(2): |
| 4204 | q.breakable() |
| 4205 | q.text("xid = "); |
| 4206 | if self.xid != None: |
| 4207 | q.text("%#x" % self.xid) |
| 4208 | else: |
| 4209 | q.text('None') |
| 4210 | q.text(","); q.breakable() |
| 4211 | q.text("match = "); |
| 4212 | q.pp(self.match) |
| 4213 | q.text(","); q.breakable() |
| 4214 | q.text("cookie = "); |
| 4215 | q.text("%#x" % self.cookie) |
| 4216 | q.text(","); q.breakable() |
| 4217 | q.text("priority = "); |
| 4218 | q.text("%#x" % self.priority) |
| 4219 | q.text(","); q.breakable() |
| 4220 | q.text("reason = "); |
| 4221 | q.text("%#x" % self.reason) |
| 4222 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4223 | q.text("duration_sec = "); |
| 4224 | q.text("%#x" % self.duration_sec) |
| 4225 | q.text(","); q.breakable() |
| 4226 | q.text("duration_nsec = "); |
| 4227 | q.text("%#x" % self.duration_nsec) |
| 4228 | q.text(","); q.breakable() |
| 4229 | q.text("idle_timeout = "); |
| 4230 | q.text("%#x" % self.idle_timeout) |
| 4231 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4232 | q.text("packet_count = "); |
| 4233 | q.text("%#x" % self.packet_count) |
| 4234 | q.text(","); q.breakable() |
| 4235 | q.text("byte_count = "); |
| 4236 | q.text("%#x" % self.byte_count) |
| 4237 | q.breakable() |
| 4238 | q.text('}') |
| 4239 | |
| 4240 | class flow_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4241 | version = 1 |
| 4242 | type = 17 |
| 4243 | stats_type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4244 | |
| 4245 | def __init__(self, xid=None, flags=None, entries=None): |
| 4246 | self.xid = xid |
| 4247 | if flags != None: |
| 4248 | self.flags = flags |
| 4249 | else: |
| 4250 | self.flags = 0 |
| 4251 | if entries != None: |
| 4252 | self.entries = entries |
| 4253 | else: |
| 4254 | self.entries = [] |
| 4255 | |
| 4256 | def pack(self): |
| 4257 | packed = [] |
| 4258 | packed.append(struct.pack("!B", self.version)) |
| 4259 | packed.append(struct.pack("!B", self.type)) |
| 4260 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4261 | packed.append(struct.pack("!L", self.xid)) |
| 4262 | packed.append(struct.pack("!H", self.stats_type)) |
| 4263 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4264 | packed.append(util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4265 | length = sum([len(x) for x in packed]) |
| 4266 | packed[2] = struct.pack("!H", length) |
| 4267 | return ''.join(packed) |
| 4268 | |
| 4269 | @staticmethod |
| 4270 | def unpack(buf): |
| 4271 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4272 | obj = flow_stats_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4273 | if type(buf) == loxi.generic_util.OFReader: |
| 4274 | reader = buf |
| 4275 | else: |
| 4276 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4277 | _version = reader.read("!B")[0] |
| 4278 | assert(_version == 1) |
| 4279 | _type = reader.read("!B")[0] |
| 4280 | assert(_type == 17) |
| 4281 | _length = reader.read("!H")[0] |
| 4282 | obj.xid = reader.read("!L")[0] |
| 4283 | _stats_type = reader.read("!H")[0] |
| 4284 | assert(_stats_type == 1) |
| 4285 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4286 | obj.entries = common.unpack_list_flow_stats_entry(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4287 | return obj |
| 4288 | |
| 4289 | def __eq__(self, other): |
| 4290 | if type(self) != type(other): return False |
| 4291 | if self.version != other.version: return False |
| 4292 | if self.type != other.type: return False |
| 4293 | if self.xid != other.xid: return False |
| 4294 | if self.flags != other.flags: return False |
| 4295 | if self.entries != other.entries: return False |
| 4296 | return True |
| 4297 | |
| 4298 | def __ne__(self, other): |
| 4299 | return not self.__eq__(other) |
| 4300 | |
| 4301 | def __str__(self): |
| 4302 | return self.show() |
| 4303 | |
| 4304 | def show(self): |
| 4305 | import loxi.pp |
| 4306 | return loxi.pp.pp(self) |
| 4307 | |
| 4308 | def pretty_print(self, q): |
| 4309 | q.text("flow_stats_reply {") |
| 4310 | with q.group(): |
| 4311 | with q.indent(2): |
| 4312 | q.breakable() |
| 4313 | q.text("xid = "); |
| 4314 | if self.xid != None: |
| 4315 | q.text("%#x" % self.xid) |
| 4316 | else: |
| 4317 | q.text('None') |
| 4318 | q.text(","); q.breakable() |
| 4319 | q.text("flags = "); |
| 4320 | q.text("%#x" % self.flags) |
| 4321 | q.text(","); q.breakable() |
| 4322 | q.text("entries = "); |
| 4323 | q.pp(self.entries) |
| 4324 | q.breakable() |
| 4325 | q.text('}') |
| 4326 | |
| 4327 | class flow_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4328 | version = 1 |
| 4329 | type = 16 |
| 4330 | stats_type = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4331 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4332 | def __init__(self, xid=None, flags=None, match=None, table_id=None, out_port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4333 | self.xid = xid |
| 4334 | if flags != None: |
| 4335 | self.flags = flags |
| 4336 | else: |
| 4337 | self.flags = 0 |
| 4338 | if match != None: |
| 4339 | self.match = match |
| 4340 | else: |
| 4341 | self.match = common.match() |
| 4342 | if table_id != None: |
| 4343 | self.table_id = table_id |
| 4344 | else: |
| 4345 | self.table_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4346 | if out_port != None: |
| 4347 | self.out_port = out_port |
| 4348 | else: |
| 4349 | self.out_port = 0 |
| 4350 | |
| 4351 | def pack(self): |
| 4352 | packed = [] |
| 4353 | packed.append(struct.pack("!B", self.version)) |
| 4354 | packed.append(struct.pack("!B", self.type)) |
| 4355 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4356 | packed.append(struct.pack("!L", self.xid)) |
| 4357 | packed.append(struct.pack("!H", self.stats_type)) |
| 4358 | packed.append(struct.pack("!H", self.flags)) |
| 4359 | packed.append(self.match.pack()) |
| 4360 | packed.append(struct.pack("!B", self.table_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4361 | packed.append('\x00' * 1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4362 | packed.append(util.pack_port_no(self.out_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4363 | length = sum([len(x) for x in packed]) |
| 4364 | packed[2] = struct.pack("!H", length) |
| 4365 | return ''.join(packed) |
| 4366 | |
| 4367 | @staticmethod |
| 4368 | def unpack(buf): |
| 4369 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4370 | obj = flow_stats_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4371 | if type(buf) == loxi.generic_util.OFReader: |
| 4372 | reader = buf |
| 4373 | else: |
| 4374 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4375 | _version = reader.read("!B")[0] |
| 4376 | assert(_version == 1) |
| 4377 | _type = reader.read("!B")[0] |
| 4378 | assert(_type == 16) |
| 4379 | _length = reader.read("!H")[0] |
| 4380 | obj.xid = reader.read("!L")[0] |
| 4381 | _stats_type = reader.read("!H")[0] |
| 4382 | assert(_stats_type == 1) |
| 4383 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4384 | obj.match = common.match.unpack(reader) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4385 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4386 | reader.skip(1) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4387 | obj.out_port = util.unpack_port_no(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4388 | return obj |
| 4389 | |
| 4390 | def __eq__(self, other): |
| 4391 | if type(self) != type(other): return False |
| 4392 | if self.version != other.version: return False |
| 4393 | if self.type != other.type: return False |
| 4394 | if self.xid != other.xid: return False |
| 4395 | if self.flags != other.flags: return False |
| 4396 | if self.match != other.match: return False |
| 4397 | if self.table_id != other.table_id: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4398 | if self.out_port != other.out_port: return False |
| 4399 | return True |
| 4400 | |
| 4401 | def __ne__(self, other): |
| 4402 | return not self.__eq__(other) |
| 4403 | |
| 4404 | def __str__(self): |
| 4405 | return self.show() |
| 4406 | |
| 4407 | def show(self): |
| 4408 | import loxi.pp |
| 4409 | return loxi.pp.pp(self) |
| 4410 | |
| 4411 | def pretty_print(self, q): |
| 4412 | q.text("flow_stats_request {") |
| 4413 | with q.group(): |
| 4414 | with q.indent(2): |
| 4415 | q.breakable() |
| 4416 | q.text("xid = "); |
| 4417 | if self.xid != None: |
| 4418 | q.text("%#x" % self.xid) |
| 4419 | else: |
| 4420 | q.text('None') |
| 4421 | q.text(","); q.breakable() |
| 4422 | q.text("flags = "); |
| 4423 | q.text("%#x" % self.flags) |
| 4424 | q.text(","); q.breakable() |
| 4425 | q.text("match = "); |
| 4426 | q.pp(self.match) |
| 4427 | q.text(","); q.breakable() |
| 4428 | q.text("table_id = "); |
| 4429 | q.text("%#x" % self.table_id) |
| 4430 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4431 | q.text("out_port = "); |
| 4432 | q.text(util.pretty_port(self.out_port)) |
| 4433 | q.breakable() |
| 4434 | q.text('}') |
| 4435 | |
| 4436 | class get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4437 | version = 1 |
| 4438 | type = 8 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4439 | |
| 4440 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 4441 | self.xid = xid |
| 4442 | if flags != None: |
| 4443 | self.flags = flags |
| 4444 | else: |
| 4445 | self.flags = 0 |
| 4446 | if miss_send_len != None: |
| 4447 | self.miss_send_len = miss_send_len |
| 4448 | else: |
| 4449 | self.miss_send_len = 0 |
| 4450 | |
| 4451 | def pack(self): |
| 4452 | packed = [] |
| 4453 | packed.append(struct.pack("!B", self.version)) |
| 4454 | packed.append(struct.pack("!B", self.type)) |
| 4455 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4456 | packed.append(struct.pack("!L", self.xid)) |
| 4457 | packed.append(struct.pack("!H", self.flags)) |
| 4458 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 4459 | length = sum([len(x) for x in packed]) |
| 4460 | packed[2] = struct.pack("!H", length) |
| 4461 | return ''.join(packed) |
| 4462 | |
| 4463 | @staticmethod |
| 4464 | def unpack(buf): |
| 4465 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4466 | obj = get_config_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4467 | if type(buf) == loxi.generic_util.OFReader: |
| 4468 | reader = buf |
| 4469 | else: |
| 4470 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4471 | _version = reader.read("!B")[0] |
| 4472 | assert(_version == 1) |
| 4473 | _type = reader.read("!B")[0] |
| 4474 | assert(_type == 8) |
| 4475 | _length = reader.read("!H")[0] |
| 4476 | obj.xid = reader.read("!L")[0] |
| 4477 | obj.flags = reader.read("!H")[0] |
| 4478 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4479 | return obj |
| 4480 | |
| 4481 | def __eq__(self, other): |
| 4482 | if type(self) != type(other): return False |
| 4483 | if self.version != other.version: return False |
| 4484 | if self.type != other.type: return False |
| 4485 | if self.xid != other.xid: return False |
| 4486 | if self.flags != other.flags: return False |
| 4487 | if self.miss_send_len != other.miss_send_len: return False |
| 4488 | return True |
| 4489 | |
| 4490 | def __ne__(self, other): |
| 4491 | return not self.__eq__(other) |
| 4492 | |
| 4493 | def __str__(self): |
| 4494 | return self.show() |
| 4495 | |
| 4496 | def show(self): |
| 4497 | import loxi.pp |
| 4498 | return loxi.pp.pp(self) |
| 4499 | |
| 4500 | def pretty_print(self, q): |
| 4501 | q.text("get_config_reply {") |
| 4502 | with q.group(): |
| 4503 | with q.indent(2): |
| 4504 | q.breakable() |
| 4505 | q.text("xid = "); |
| 4506 | if self.xid != None: |
| 4507 | q.text("%#x" % self.xid) |
| 4508 | else: |
| 4509 | q.text('None') |
| 4510 | q.text(","); q.breakable() |
| 4511 | q.text("flags = "); |
| 4512 | q.text("%#x" % self.flags) |
| 4513 | q.text(","); q.breakable() |
| 4514 | q.text("miss_send_len = "); |
| 4515 | q.text("%#x" % self.miss_send_len) |
| 4516 | q.breakable() |
| 4517 | q.text('}') |
| 4518 | |
| 4519 | class get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4520 | version = 1 |
| 4521 | type = 7 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4522 | |
| 4523 | def __init__(self, xid=None): |
| 4524 | self.xid = xid |
| 4525 | |
| 4526 | def pack(self): |
| 4527 | packed = [] |
| 4528 | packed.append(struct.pack("!B", self.version)) |
| 4529 | packed.append(struct.pack("!B", self.type)) |
| 4530 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4531 | packed.append(struct.pack("!L", self.xid)) |
| 4532 | length = sum([len(x) for x in packed]) |
| 4533 | packed[2] = struct.pack("!H", length) |
| 4534 | return ''.join(packed) |
| 4535 | |
| 4536 | @staticmethod |
| 4537 | def unpack(buf): |
| 4538 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4539 | obj = get_config_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4540 | if type(buf) == loxi.generic_util.OFReader: |
| 4541 | reader = buf |
| 4542 | else: |
| 4543 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4544 | _version = reader.read("!B")[0] |
| 4545 | assert(_version == 1) |
| 4546 | _type = reader.read("!B")[0] |
| 4547 | assert(_type == 7) |
| 4548 | _length = reader.read("!H")[0] |
| 4549 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4550 | return obj |
| 4551 | |
| 4552 | def __eq__(self, other): |
| 4553 | if type(self) != type(other): return False |
| 4554 | if self.version != other.version: return False |
| 4555 | if self.type != other.type: return False |
| 4556 | if self.xid != other.xid: return False |
| 4557 | return True |
| 4558 | |
| 4559 | def __ne__(self, other): |
| 4560 | return not self.__eq__(other) |
| 4561 | |
| 4562 | def __str__(self): |
| 4563 | return self.show() |
| 4564 | |
| 4565 | def show(self): |
| 4566 | import loxi.pp |
| 4567 | return loxi.pp.pp(self) |
| 4568 | |
| 4569 | def pretty_print(self, q): |
| 4570 | q.text("get_config_request {") |
| 4571 | with q.group(): |
| 4572 | with q.indent(2): |
| 4573 | q.breakable() |
| 4574 | q.text("xid = "); |
| 4575 | if self.xid != None: |
| 4576 | q.text("%#x" % self.xid) |
| 4577 | else: |
| 4578 | q.text('None') |
| 4579 | q.breakable() |
| 4580 | q.text('}') |
| 4581 | |
| 4582 | class hello(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4583 | version = 1 |
| 4584 | type = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4585 | |
| 4586 | def __init__(self, xid=None): |
| 4587 | self.xid = xid |
| 4588 | |
| 4589 | def pack(self): |
| 4590 | packed = [] |
| 4591 | packed.append(struct.pack("!B", self.version)) |
| 4592 | packed.append(struct.pack("!B", self.type)) |
| 4593 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4594 | packed.append(struct.pack("!L", self.xid)) |
| 4595 | length = sum([len(x) for x in packed]) |
| 4596 | packed[2] = struct.pack("!H", length) |
| 4597 | return ''.join(packed) |
| 4598 | |
| 4599 | @staticmethod |
| 4600 | def unpack(buf): |
| 4601 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4602 | obj = hello() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4603 | if type(buf) == loxi.generic_util.OFReader: |
| 4604 | reader = buf |
| 4605 | else: |
| 4606 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4607 | _version = reader.read("!B")[0] |
| 4608 | assert(_version == 1) |
| 4609 | _type = reader.read("!B")[0] |
| 4610 | assert(_type == 0) |
| 4611 | _length = reader.read("!H")[0] |
| 4612 | obj.xid = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4613 | return obj |
| 4614 | |
| 4615 | def __eq__(self, other): |
| 4616 | if type(self) != type(other): return False |
| 4617 | if self.version != other.version: return False |
| 4618 | if self.type != other.type: return False |
| 4619 | if self.xid != other.xid: return False |
| 4620 | return True |
| 4621 | |
| 4622 | def __ne__(self, other): |
| 4623 | return not self.__eq__(other) |
| 4624 | |
| 4625 | def __str__(self): |
| 4626 | return self.show() |
| 4627 | |
| 4628 | def show(self): |
| 4629 | import loxi.pp |
| 4630 | return loxi.pp.pp(self) |
| 4631 | |
| 4632 | def pretty_print(self, q): |
| 4633 | q.text("hello {") |
| 4634 | with q.group(): |
| 4635 | with q.indent(2): |
| 4636 | q.breakable() |
| 4637 | q.text("xid = "); |
| 4638 | if self.xid != None: |
| 4639 | q.text("%#x" % self.xid) |
| 4640 | else: |
| 4641 | q.text('None') |
| 4642 | q.breakable() |
| 4643 | q.text('}') |
| 4644 | |
| 4645 | class nicira_controller_role_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4646 | version = 1 |
| 4647 | type = 4 |
| 4648 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4649 | subtype = 11 |
| 4650 | |
| 4651 | def __init__(self, xid=None, role=None): |
| 4652 | self.xid = xid |
| 4653 | if role != None: |
| 4654 | self.role = role |
| 4655 | else: |
| 4656 | self.role = 0 |
| 4657 | |
| 4658 | def pack(self): |
| 4659 | packed = [] |
| 4660 | packed.append(struct.pack("!B", self.version)) |
| 4661 | packed.append(struct.pack("!B", self.type)) |
| 4662 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4663 | packed.append(struct.pack("!L", self.xid)) |
| 4664 | packed.append(struct.pack("!L", self.experimenter)) |
| 4665 | packed.append(struct.pack("!L", self.subtype)) |
| 4666 | packed.append(struct.pack("!L", self.role)) |
| 4667 | length = sum([len(x) for x in packed]) |
| 4668 | packed[2] = struct.pack("!H", length) |
| 4669 | return ''.join(packed) |
| 4670 | |
| 4671 | @staticmethod |
| 4672 | def unpack(buf): |
| 4673 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4674 | obj = nicira_controller_role_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4675 | if type(buf) == loxi.generic_util.OFReader: |
| 4676 | reader = buf |
| 4677 | else: |
| 4678 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4679 | _version = reader.read("!B")[0] |
| 4680 | assert(_version == 1) |
| 4681 | _type = reader.read("!B")[0] |
| 4682 | assert(_type == 4) |
| 4683 | _length = reader.read("!H")[0] |
| 4684 | obj.xid = reader.read("!L")[0] |
| 4685 | _experimenter = reader.read("!L")[0] |
| 4686 | assert(_experimenter == 8992) |
| 4687 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4688 | assert(_subtype == 11) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4689 | obj.role = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4690 | return obj |
| 4691 | |
| 4692 | def __eq__(self, other): |
| 4693 | if type(self) != type(other): return False |
| 4694 | if self.version != other.version: return False |
| 4695 | if self.type != other.type: return False |
| 4696 | if self.xid != other.xid: return False |
| 4697 | if self.role != other.role: return False |
| 4698 | return True |
| 4699 | |
| 4700 | def __ne__(self, other): |
| 4701 | return not self.__eq__(other) |
| 4702 | |
| 4703 | def __str__(self): |
| 4704 | return self.show() |
| 4705 | |
| 4706 | def show(self): |
| 4707 | import loxi.pp |
| 4708 | return loxi.pp.pp(self) |
| 4709 | |
| 4710 | def pretty_print(self, q): |
| 4711 | q.text("nicira_controller_role_reply {") |
| 4712 | with q.group(): |
| 4713 | with q.indent(2): |
| 4714 | q.breakable() |
| 4715 | q.text("xid = "); |
| 4716 | if self.xid != None: |
| 4717 | q.text("%#x" % self.xid) |
| 4718 | else: |
| 4719 | q.text('None') |
| 4720 | q.text(","); q.breakable() |
| 4721 | q.text("role = "); |
| 4722 | q.text("%#x" % self.role) |
| 4723 | q.breakable() |
| 4724 | q.text('}') |
| 4725 | |
| 4726 | class nicira_controller_role_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4727 | version = 1 |
| 4728 | type = 4 |
| 4729 | experimenter = 8992 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4730 | subtype = 10 |
| 4731 | |
| 4732 | def __init__(self, xid=None, role=None): |
| 4733 | self.xid = xid |
| 4734 | if role != None: |
| 4735 | self.role = role |
| 4736 | else: |
| 4737 | self.role = 0 |
| 4738 | |
| 4739 | def pack(self): |
| 4740 | packed = [] |
| 4741 | packed.append(struct.pack("!B", self.version)) |
| 4742 | packed.append(struct.pack("!B", self.type)) |
| 4743 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4744 | packed.append(struct.pack("!L", self.xid)) |
| 4745 | packed.append(struct.pack("!L", self.experimenter)) |
| 4746 | packed.append(struct.pack("!L", self.subtype)) |
| 4747 | packed.append(struct.pack("!L", self.role)) |
| 4748 | length = sum([len(x) for x in packed]) |
| 4749 | packed[2] = struct.pack("!H", length) |
| 4750 | return ''.join(packed) |
| 4751 | |
| 4752 | @staticmethod |
| 4753 | def unpack(buf): |
| 4754 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4755 | obj = nicira_controller_role_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4756 | if type(buf) == loxi.generic_util.OFReader: |
| 4757 | reader = buf |
| 4758 | else: |
| 4759 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4760 | _version = reader.read("!B")[0] |
| 4761 | assert(_version == 1) |
| 4762 | _type = reader.read("!B")[0] |
| 4763 | assert(_type == 4) |
| 4764 | _length = reader.read("!H")[0] |
| 4765 | obj.xid = reader.read("!L")[0] |
| 4766 | _experimenter = reader.read("!L")[0] |
| 4767 | assert(_experimenter == 8992) |
| 4768 | _subtype = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4769 | assert(_subtype == 10) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4770 | obj.role = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4771 | return obj |
| 4772 | |
| 4773 | def __eq__(self, other): |
| 4774 | if type(self) != type(other): return False |
| 4775 | if self.version != other.version: return False |
| 4776 | if self.type != other.type: return False |
| 4777 | if self.xid != other.xid: return False |
| 4778 | if self.role != other.role: return False |
| 4779 | return True |
| 4780 | |
| 4781 | def __ne__(self, other): |
| 4782 | return not self.__eq__(other) |
| 4783 | |
| 4784 | def __str__(self): |
| 4785 | return self.show() |
| 4786 | |
| 4787 | def show(self): |
| 4788 | import loxi.pp |
| 4789 | return loxi.pp.pp(self) |
| 4790 | |
| 4791 | def pretty_print(self, q): |
| 4792 | q.text("nicira_controller_role_request {") |
| 4793 | with q.group(): |
| 4794 | with q.indent(2): |
| 4795 | q.breakable() |
| 4796 | q.text("xid = "); |
| 4797 | if self.xid != None: |
| 4798 | q.text("%#x" % self.xid) |
| 4799 | else: |
| 4800 | q.text('None') |
| 4801 | q.text(","); q.breakable() |
| 4802 | q.text("role = "); |
| 4803 | q.text("%#x" % self.role) |
| 4804 | q.breakable() |
| 4805 | q.text('}') |
| 4806 | |
| 4807 | class packet_in(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4808 | version = 1 |
| 4809 | type = 10 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4810 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4811 | def __init__(self, xid=None, buffer_id=None, total_len=None, in_port=None, reason=None, data=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4812 | self.xid = xid |
| 4813 | if buffer_id != None: |
| 4814 | self.buffer_id = buffer_id |
| 4815 | else: |
| 4816 | self.buffer_id = 0 |
| 4817 | if total_len != None: |
| 4818 | self.total_len = total_len |
| 4819 | else: |
| 4820 | self.total_len = 0 |
| 4821 | if in_port != None: |
| 4822 | self.in_port = in_port |
| 4823 | else: |
| 4824 | self.in_port = 0 |
| 4825 | if reason != None: |
| 4826 | self.reason = reason |
| 4827 | else: |
| 4828 | self.reason = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4829 | if data != None: |
| 4830 | self.data = data |
| 4831 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4832 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4833 | |
| 4834 | def pack(self): |
| 4835 | packed = [] |
| 4836 | packed.append(struct.pack("!B", self.version)) |
| 4837 | packed.append(struct.pack("!B", self.type)) |
| 4838 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 4839 | packed.append(struct.pack("!L", self.xid)) |
| 4840 | packed.append(struct.pack("!L", self.buffer_id)) |
| 4841 | packed.append(struct.pack("!H", self.total_len)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4842 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4843 | packed.append(struct.pack("!B", self.reason)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4844 | packed.append('\x00' * 1) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4845 | packed.append(self.data) |
| 4846 | length = sum([len(x) for x in packed]) |
| 4847 | packed[2] = struct.pack("!H", length) |
| 4848 | return ''.join(packed) |
| 4849 | |
| 4850 | @staticmethod |
| 4851 | def unpack(buf): |
| 4852 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4853 | obj = packet_in() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4854 | if type(buf) == loxi.generic_util.OFReader: |
| 4855 | reader = buf |
| 4856 | else: |
| 4857 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4858 | _version = reader.read("!B")[0] |
| 4859 | assert(_version == 1) |
| 4860 | _type = reader.read("!B")[0] |
| 4861 | assert(_type == 10) |
| 4862 | _length = reader.read("!H")[0] |
| 4863 | obj.xid = reader.read("!L")[0] |
| 4864 | obj.buffer_id = reader.read("!L")[0] |
| 4865 | obj.total_len = reader.read("!H")[0] |
| 4866 | obj.in_port = util.unpack_port_no(reader) |
| 4867 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4868 | reader.skip(1) |
| 4869 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4870 | return obj |
| 4871 | |
| 4872 | def __eq__(self, other): |
| 4873 | if type(self) != type(other): return False |
| 4874 | if self.version != other.version: return False |
| 4875 | if self.type != other.type: return False |
| 4876 | if self.xid != other.xid: return False |
| 4877 | if self.buffer_id != other.buffer_id: return False |
| 4878 | if self.total_len != other.total_len: return False |
| 4879 | if self.in_port != other.in_port: return False |
| 4880 | if self.reason != other.reason: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4881 | if self.data != other.data: return False |
| 4882 | return True |
| 4883 | |
| 4884 | def __ne__(self, other): |
| 4885 | return not self.__eq__(other) |
| 4886 | |
| 4887 | def __str__(self): |
| 4888 | return self.show() |
| 4889 | |
| 4890 | def show(self): |
| 4891 | import loxi.pp |
| 4892 | return loxi.pp.pp(self) |
| 4893 | |
| 4894 | def pretty_print(self, q): |
| 4895 | q.text("packet_in {") |
| 4896 | with q.group(): |
| 4897 | with q.indent(2): |
| 4898 | q.breakable() |
| 4899 | q.text("xid = "); |
| 4900 | if self.xid != None: |
| 4901 | q.text("%#x" % self.xid) |
| 4902 | else: |
| 4903 | q.text('None') |
| 4904 | q.text(","); q.breakable() |
| 4905 | q.text("buffer_id = "); |
| 4906 | q.text("%#x" % self.buffer_id) |
| 4907 | q.text(","); q.breakable() |
| 4908 | q.text("total_len = "); |
| 4909 | q.text("%#x" % self.total_len) |
| 4910 | q.text(","); q.breakable() |
| 4911 | q.text("in_port = "); |
| 4912 | q.text(util.pretty_port(self.in_port)) |
| 4913 | q.text(","); q.breakable() |
| 4914 | q.text("reason = "); |
| 4915 | q.text("%#x" % self.reason) |
| 4916 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4917 | q.text("data = "); |
| 4918 | q.pp(self.data) |
| 4919 | q.breakable() |
| 4920 | q.text('}') |
| 4921 | |
| 4922 | class packet_out(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4923 | version = 1 |
| 4924 | type = 13 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4925 | |
| 4926 | def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None, data=None): |
| 4927 | self.xid = xid |
| 4928 | if buffer_id != None: |
| 4929 | self.buffer_id = buffer_id |
| 4930 | else: |
Rich Lane | ff637c9 | 2013-04-04 13:57:09 -0700 | [diff] [blame] | 4931 | self.buffer_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4932 | if in_port != None: |
| 4933 | self.in_port = in_port |
| 4934 | else: |
| 4935 | self.in_port = 0 |
| 4936 | if actions != None: |
| 4937 | self.actions = actions |
| 4938 | else: |
| 4939 | self.actions = [] |
| 4940 | if data != None: |
| 4941 | self.data = data |
| 4942 | else: |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4943 | self.data = '' |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4944 | |
| 4945 | def pack(self): |
| 4946 | packed = [] |
| 4947 | packed.append(struct.pack("!B", self.version)) |
| 4948 | packed.append(struct.pack("!B", self.type)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4949 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4950 | packed.append(struct.pack("!L", self.xid)) |
| 4951 | packed.append(struct.pack("!L", self.buffer_id)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4952 | packed.append(util.pack_port_no(self.in_port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4953 | packed.append(struct.pack("!H", 0)) # placeholder for actions_len at index 6 |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4954 | packed.append(util.pack_list(self.actions)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4955 | packed[6] = struct.pack("!H", len(packed[-1])) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4956 | packed.append(self.data) |
| 4957 | length = sum([len(x) for x in packed]) |
| 4958 | packed[2] = struct.pack("!H", length) |
| 4959 | return ''.join(packed) |
| 4960 | |
| 4961 | @staticmethod |
| 4962 | def unpack(buf): |
| 4963 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 4964 | obj = packet_out() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4965 | if type(buf) == loxi.generic_util.OFReader: |
| 4966 | reader = buf |
| 4967 | else: |
| 4968 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 4969 | _version = reader.read("!B")[0] |
| 4970 | assert(_version == 1) |
| 4971 | _type = reader.read("!B")[0] |
| 4972 | assert(_type == 13) |
| 4973 | _length = reader.read("!H")[0] |
| 4974 | obj.xid = reader.read("!L")[0] |
| 4975 | obj.buffer_id = reader.read("!L")[0] |
| 4976 | obj.in_port = util.unpack_port_no(reader) |
| 4977 | _actions_len = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 4978 | obj.actions = action.unpack_list(reader.slice(_actions_len)) |
| 4979 | obj.data = str(reader.read_all()) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 4980 | return obj |
| 4981 | |
| 4982 | def __eq__(self, other): |
| 4983 | if type(self) != type(other): return False |
| 4984 | if self.version != other.version: return False |
| 4985 | if self.type != other.type: return False |
| 4986 | if self.xid != other.xid: return False |
| 4987 | if self.buffer_id != other.buffer_id: return False |
| 4988 | if self.in_port != other.in_port: return False |
| 4989 | if self.actions != other.actions: return False |
| 4990 | if self.data != other.data: return False |
| 4991 | return True |
| 4992 | |
| 4993 | def __ne__(self, other): |
| 4994 | return not self.__eq__(other) |
| 4995 | |
| 4996 | def __str__(self): |
| 4997 | return self.show() |
| 4998 | |
| 4999 | def show(self): |
| 5000 | import loxi.pp |
| 5001 | return loxi.pp.pp(self) |
| 5002 | |
| 5003 | def pretty_print(self, q): |
| 5004 | q.text("packet_out {") |
| 5005 | with q.group(): |
| 5006 | with q.indent(2): |
| 5007 | q.breakable() |
| 5008 | q.text("xid = "); |
| 5009 | if self.xid != None: |
| 5010 | q.text("%#x" % self.xid) |
| 5011 | else: |
| 5012 | q.text('None') |
| 5013 | q.text(","); q.breakable() |
| 5014 | q.text("buffer_id = "); |
| 5015 | q.text("%#x" % self.buffer_id) |
| 5016 | q.text(","); q.breakable() |
| 5017 | q.text("in_port = "); |
| 5018 | q.text(util.pretty_port(self.in_port)) |
| 5019 | q.text(","); q.breakable() |
| 5020 | q.text("actions = "); |
| 5021 | q.pp(self.actions) |
| 5022 | q.text(","); q.breakable() |
| 5023 | q.text("data = "); |
| 5024 | q.pp(self.data) |
| 5025 | q.breakable() |
| 5026 | q.text('}') |
| 5027 | |
| 5028 | class port_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5029 | version = 1 |
| 5030 | type = 15 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5031 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5032 | def __init__(self, xid=None, port_no=None, hw_addr=None, config=None, mask=None, advertise=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5033 | self.xid = xid |
| 5034 | if port_no != None: |
| 5035 | self.port_no = port_no |
| 5036 | else: |
| 5037 | self.port_no = 0 |
| 5038 | if hw_addr != None: |
| 5039 | self.hw_addr = hw_addr |
| 5040 | else: |
| 5041 | self.hw_addr = [0,0,0,0,0,0] |
| 5042 | if config != None: |
| 5043 | self.config = config |
| 5044 | else: |
| 5045 | self.config = 0 |
| 5046 | if mask != None: |
| 5047 | self.mask = mask |
| 5048 | else: |
| 5049 | self.mask = 0 |
| 5050 | if advertise != None: |
| 5051 | self.advertise = advertise |
| 5052 | else: |
| 5053 | self.advertise = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5054 | |
| 5055 | def pack(self): |
| 5056 | packed = [] |
| 5057 | packed.append(struct.pack("!B", self.version)) |
| 5058 | packed.append(struct.pack("!B", self.type)) |
| 5059 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5060 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5061 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5062 | packed.append(struct.pack("!6B", *self.hw_addr)) |
| 5063 | packed.append(struct.pack("!L", self.config)) |
| 5064 | packed.append(struct.pack("!L", self.mask)) |
| 5065 | packed.append(struct.pack("!L", self.advertise)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5066 | packed.append('\x00' * 4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5067 | length = sum([len(x) for x in packed]) |
| 5068 | packed[2] = struct.pack("!H", length) |
| 5069 | return ''.join(packed) |
| 5070 | |
| 5071 | @staticmethod |
| 5072 | def unpack(buf): |
| 5073 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5074 | obj = port_mod() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5075 | if type(buf) == loxi.generic_util.OFReader: |
| 5076 | reader = buf |
| 5077 | else: |
| 5078 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5079 | _version = reader.read("!B")[0] |
| 5080 | assert(_version == 1) |
| 5081 | _type = reader.read("!B")[0] |
| 5082 | assert(_type == 15) |
| 5083 | _length = reader.read("!H")[0] |
| 5084 | obj.xid = reader.read("!L")[0] |
| 5085 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5086 | obj.hw_addr = list(reader.read('!6B')) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5087 | obj.config = reader.read("!L")[0] |
| 5088 | obj.mask = reader.read("!L")[0] |
| 5089 | obj.advertise = reader.read("!L")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5090 | reader.skip(4) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5091 | return obj |
| 5092 | |
| 5093 | def __eq__(self, other): |
| 5094 | if type(self) != type(other): return False |
| 5095 | if self.version != other.version: return False |
| 5096 | if self.type != other.type: return False |
| 5097 | if self.xid != other.xid: return False |
| 5098 | if self.port_no != other.port_no: return False |
| 5099 | if self.hw_addr != other.hw_addr: return False |
| 5100 | if self.config != other.config: return False |
| 5101 | if self.mask != other.mask: return False |
| 5102 | if self.advertise != other.advertise: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5103 | return True |
| 5104 | |
| 5105 | def __ne__(self, other): |
| 5106 | return not self.__eq__(other) |
| 5107 | |
| 5108 | def __str__(self): |
| 5109 | return self.show() |
| 5110 | |
| 5111 | def show(self): |
| 5112 | import loxi.pp |
| 5113 | return loxi.pp.pp(self) |
| 5114 | |
| 5115 | def pretty_print(self, q): |
| 5116 | q.text("port_mod {") |
| 5117 | with q.group(): |
| 5118 | with q.indent(2): |
| 5119 | q.breakable() |
| 5120 | q.text("xid = "); |
| 5121 | if self.xid != None: |
| 5122 | q.text("%#x" % self.xid) |
| 5123 | else: |
| 5124 | q.text('None') |
| 5125 | q.text(","); q.breakable() |
| 5126 | q.text("port_no = "); |
| 5127 | q.text(util.pretty_port(self.port_no)) |
| 5128 | q.text(","); q.breakable() |
| 5129 | q.text("hw_addr = "); |
| 5130 | q.text(util.pretty_mac(self.hw_addr)) |
| 5131 | q.text(","); q.breakable() |
| 5132 | q.text("config = "); |
| 5133 | q.text("%#x" % self.config) |
| 5134 | q.text(","); q.breakable() |
| 5135 | q.text("mask = "); |
| 5136 | q.text("%#x" % self.mask) |
| 5137 | q.text(","); q.breakable() |
| 5138 | q.text("advertise = "); |
| 5139 | q.text("%#x" % self.advertise) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5140 | q.breakable() |
| 5141 | q.text('}') |
| 5142 | |
| 5143 | class port_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5144 | version = 1 |
| 5145 | type = 17 |
| 5146 | stats_type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5147 | |
| 5148 | def __init__(self, xid=None, flags=None, entries=None): |
| 5149 | self.xid = xid |
| 5150 | if flags != None: |
| 5151 | self.flags = flags |
| 5152 | else: |
| 5153 | self.flags = 0 |
| 5154 | if entries != None: |
| 5155 | self.entries = entries |
| 5156 | else: |
| 5157 | self.entries = [] |
| 5158 | |
| 5159 | def pack(self): |
| 5160 | packed = [] |
| 5161 | packed.append(struct.pack("!B", self.version)) |
| 5162 | packed.append(struct.pack("!B", self.type)) |
| 5163 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5164 | packed.append(struct.pack("!L", self.xid)) |
| 5165 | packed.append(struct.pack("!H", self.stats_type)) |
| 5166 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5167 | packed.append(util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5168 | length = sum([len(x) for x in packed]) |
| 5169 | packed[2] = struct.pack("!H", length) |
| 5170 | return ''.join(packed) |
| 5171 | |
| 5172 | @staticmethod |
| 5173 | def unpack(buf): |
| 5174 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5175 | obj = port_stats_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5176 | if type(buf) == loxi.generic_util.OFReader: |
| 5177 | reader = buf |
| 5178 | else: |
| 5179 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5180 | _version = reader.read("!B")[0] |
| 5181 | assert(_version == 1) |
| 5182 | _type = reader.read("!B")[0] |
| 5183 | assert(_type == 17) |
| 5184 | _length = reader.read("!H")[0] |
| 5185 | obj.xid = reader.read("!L")[0] |
| 5186 | _stats_type = reader.read("!H")[0] |
| 5187 | assert(_stats_type == 4) |
| 5188 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5189 | obj.entries = loxi.generic_util.unpack_list(reader, common.port_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5190 | return obj |
| 5191 | |
| 5192 | def __eq__(self, other): |
| 5193 | if type(self) != type(other): return False |
| 5194 | if self.version != other.version: return False |
| 5195 | if self.type != other.type: return False |
| 5196 | if self.xid != other.xid: return False |
| 5197 | if self.flags != other.flags: return False |
| 5198 | if self.entries != other.entries: return False |
| 5199 | return True |
| 5200 | |
| 5201 | def __ne__(self, other): |
| 5202 | return not self.__eq__(other) |
| 5203 | |
| 5204 | def __str__(self): |
| 5205 | return self.show() |
| 5206 | |
| 5207 | def show(self): |
| 5208 | import loxi.pp |
| 5209 | return loxi.pp.pp(self) |
| 5210 | |
| 5211 | def pretty_print(self, q): |
| 5212 | q.text("port_stats_reply {") |
| 5213 | with q.group(): |
| 5214 | with q.indent(2): |
| 5215 | q.breakable() |
| 5216 | q.text("xid = "); |
| 5217 | if self.xid != None: |
| 5218 | q.text("%#x" % self.xid) |
| 5219 | else: |
| 5220 | q.text('None') |
| 5221 | q.text(","); q.breakable() |
| 5222 | q.text("flags = "); |
| 5223 | q.text("%#x" % self.flags) |
| 5224 | q.text(","); q.breakable() |
| 5225 | q.text("entries = "); |
| 5226 | q.pp(self.entries) |
| 5227 | q.breakable() |
| 5228 | q.text('}') |
| 5229 | |
| 5230 | class port_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5231 | version = 1 |
| 5232 | type = 16 |
| 5233 | stats_type = 4 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5234 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5235 | def __init__(self, xid=None, flags=None, port_no=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5236 | self.xid = xid |
| 5237 | if flags != None: |
| 5238 | self.flags = flags |
| 5239 | else: |
| 5240 | self.flags = 0 |
| 5241 | if port_no != None: |
| 5242 | self.port_no = port_no |
| 5243 | else: |
| 5244 | self.port_no = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5245 | |
| 5246 | def pack(self): |
| 5247 | packed = [] |
| 5248 | packed.append(struct.pack("!B", self.version)) |
| 5249 | packed.append(struct.pack("!B", self.type)) |
| 5250 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5251 | packed.append(struct.pack("!L", self.xid)) |
| 5252 | packed.append(struct.pack("!H", self.stats_type)) |
| 5253 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5254 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5255 | packed.append('\x00' * 6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5256 | length = sum([len(x) for x in packed]) |
| 5257 | packed[2] = struct.pack("!H", length) |
| 5258 | return ''.join(packed) |
| 5259 | |
| 5260 | @staticmethod |
| 5261 | def unpack(buf): |
| 5262 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5263 | obj = port_stats_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5264 | if type(buf) == loxi.generic_util.OFReader: |
| 5265 | reader = buf |
| 5266 | else: |
| 5267 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5268 | _version = reader.read("!B")[0] |
| 5269 | assert(_version == 1) |
| 5270 | _type = reader.read("!B")[0] |
| 5271 | assert(_type == 16) |
| 5272 | _length = reader.read("!H")[0] |
| 5273 | obj.xid = reader.read("!L")[0] |
| 5274 | _stats_type = reader.read("!H")[0] |
| 5275 | assert(_stats_type == 4) |
| 5276 | obj.flags = reader.read("!H")[0] |
| 5277 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5278 | reader.skip(6) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5279 | return obj |
| 5280 | |
| 5281 | def __eq__(self, other): |
| 5282 | if type(self) != type(other): return False |
| 5283 | if self.version != other.version: return False |
| 5284 | if self.type != other.type: return False |
| 5285 | if self.xid != other.xid: return False |
| 5286 | if self.flags != other.flags: return False |
| 5287 | if self.port_no != other.port_no: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5288 | return True |
| 5289 | |
| 5290 | def __ne__(self, other): |
| 5291 | return not self.__eq__(other) |
| 5292 | |
| 5293 | def __str__(self): |
| 5294 | return self.show() |
| 5295 | |
| 5296 | def show(self): |
| 5297 | import loxi.pp |
| 5298 | return loxi.pp.pp(self) |
| 5299 | |
| 5300 | def pretty_print(self, q): |
| 5301 | q.text("port_stats_request {") |
| 5302 | with q.group(): |
| 5303 | with q.indent(2): |
| 5304 | q.breakable() |
| 5305 | q.text("xid = "); |
| 5306 | if self.xid != None: |
| 5307 | q.text("%#x" % self.xid) |
| 5308 | else: |
| 5309 | q.text('None') |
| 5310 | q.text(","); q.breakable() |
| 5311 | q.text("flags = "); |
| 5312 | q.text("%#x" % self.flags) |
| 5313 | q.text(","); q.breakable() |
| 5314 | q.text("port_no = "); |
| 5315 | q.text(util.pretty_port(self.port_no)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5316 | q.breakable() |
| 5317 | q.text('}') |
| 5318 | |
| 5319 | class port_status(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5320 | version = 1 |
| 5321 | type = 12 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5322 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5323 | def __init__(self, xid=None, reason=None, desc=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5324 | self.xid = xid |
| 5325 | if reason != None: |
| 5326 | self.reason = reason |
| 5327 | else: |
| 5328 | self.reason = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5329 | if desc != None: |
| 5330 | self.desc = desc |
| 5331 | else: |
| 5332 | self.desc = common.port_desc() |
| 5333 | |
| 5334 | def pack(self): |
| 5335 | packed = [] |
| 5336 | packed.append(struct.pack("!B", self.version)) |
| 5337 | packed.append(struct.pack("!B", self.type)) |
| 5338 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5339 | packed.append(struct.pack("!L", self.xid)) |
| 5340 | packed.append(struct.pack("!B", self.reason)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5341 | packed.append('\x00' * 7) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5342 | packed.append(self.desc.pack()) |
| 5343 | length = sum([len(x) for x in packed]) |
| 5344 | packed[2] = struct.pack("!H", length) |
| 5345 | return ''.join(packed) |
| 5346 | |
| 5347 | @staticmethod |
| 5348 | def unpack(buf): |
| 5349 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5350 | obj = port_status() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5351 | if type(buf) == loxi.generic_util.OFReader: |
| 5352 | reader = buf |
| 5353 | else: |
| 5354 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5355 | _version = reader.read("!B")[0] |
| 5356 | assert(_version == 1) |
| 5357 | _type = reader.read("!B")[0] |
| 5358 | assert(_type == 12) |
| 5359 | _length = reader.read("!H")[0] |
| 5360 | obj.xid = reader.read("!L")[0] |
| 5361 | obj.reason = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5362 | reader.skip(7) |
| 5363 | obj.desc = common.port_desc.unpack(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5364 | return obj |
| 5365 | |
| 5366 | def __eq__(self, other): |
| 5367 | if type(self) != type(other): return False |
| 5368 | if self.version != other.version: return False |
| 5369 | if self.type != other.type: return False |
| 5370 | if self.xid != other.xid: return False |
| 5371 | if self.reason != other.reason: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5372 | if self.desc != other.desc: return False |
| 5373 | return True |
| 5374 | |
| 5375 | def __ne__(self, other): |
| 5376 | return not self.__eq__(other) |
| 5377 | |
| 5378 | def __str__(self): |
| 5379 | return self.show() |
| 5380 | |
| 5381 | def show(self): |
| 5382 | import loxi.pp |
| 5383 | return loxi.pp.pp(self) |
| 5384 | |
| 5385 | def pretty_print(self, q): |
| 5386 | q.text("port_status {") |
| 5387 | with q.group(): |
| 5388 | with q.indent(2): |
| 5389 | q.breakable() |
| 5390 | q.text("xid = "); |
| 5391 | if self.xid != None: |
| 5392 | q.text("%#x" % self.xid) |
| 5393 | else: |
| 5394 | q.text('None') |
| 5395 | q.text(","); q.breakable() |
| 5396 | q.text("reason = "); |
| 5397 | q.text("%#x" % self.reason) |
| 5398 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5399 | q.text("desc = "); |
| 5400 | q.pp(self.desc) |
| 5401 | q.breakable() |
| 5402 | q.text('}') |
| 5403 | |
| 5404 | class queue_get_config_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5405 | version = 1 |
| 5406 | type = 21 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5407 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5408 | def __init__(self, xid=None, port=None, queues=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5409 | self.xid = xid |
| 5410 | if port != None: |
| 5411 | self.port = port |
| 5412 | else: |
| 5413 | self.port = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5414 | if queues != None: |
| 5415 | self.queues = queues |
| 5416 | else: |
| 5417 | self.queues = [] |
| 5418 | |
| 5419 | def pack(self): |
| 5420 | packed = [] |
| 5421 | packed.append(struct.pack("!B", self.version)) |
| 5422 | packed.append(struct.pack("!B", self.type)) |
| 5423 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5424 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5425 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5426 | packed.append('\x00' * 6) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5427 | packed.append(util.pack_list(self.queues)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5428 | length = sum([len(x) for x in packed]) |
| 5429 | packed[2] = struct.pack("!H", length) |
| 5430 | return ''.join(packed) |
| 5431 | |
| 5432 | @staticmethod |
| 5433 | def unpack(buf): |
| 5434 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5435 | obj = queue_get_config_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5436 | if type(buf) == loxi.generic_util.OFReader: |
| 5437 | reader = buf |
| 5438 | else: |
| 5439 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5440 | _version = reader.read("!B")[0] |
| 5441 | assert(_version == 1) |
| 5442 | _type = reader.read("!B")[0] |
| 5443 | assert(_type == 21) |
| 5444 | _length = reader.read("!H")[0] |
| 5445 | obj.xid = reader.read("!L")[0] |
| 5446 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5447 | reader.skip(6) |
| 5448 | obj.queues = common.unpack_list_packet_queue(reader) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5449 | return obj |
| 5450 | |
| 5451 | def __eq__(self, other): |
| 5452 | if type(self) != type(other): return False |
| 5453 | if self.version != other.version: return False |
| 5454 | if self.type != other.type: return False |
| 5455 | if self.xid != other.xid: return False |
| 5456 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5457 | if self.queues != other.queues: return False |
| 5458 | return True |
| 5459 | |
| 5460 | def __ne__(self, other): |
| 5461 | return not self.__eq__(other) |
| 5462 | |
| 5463 | def __str__(self): |
| 5464 | return self.show() |
| 5465 | |
| 5466 | def show(self): |
| 5467 | import loxi.pp |
| 5468 | return loxi.pp.pp(self) |
| 5469 | |
| 5470 | def pretty_print(self, q): |
| 5471 | q.text("queue_get_config_reply {") |
| 5472 | with q.group(): |
| 5473 | with q.indent(2): |
| 5474 | q.breakable() |
| 5475 | q.text("xid = "); |
| 5476 | if self.xid != None: |
| 5477 | q.text("%#x" % self.xid) |
| 5478 | else: |
| 5479 | q.text('None') |
| 5480 | q.text(","); q.breakable() |
| 5481 | q.text("port = "); |
| 5482 | q.text(util.pretty_port(self.port)) |
| 5483 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5484 | q.text("queues = "); |
| 5485 | q.pp(self.queues) |
| 5486 | q.breakable() |
| 5487 | q.text('}') |
| 5488 | |
| 5489 | class queue_get_config_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5490 | version = 1 |
| 5491 | type = 20 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5492 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5493 | def __init__(self, xid=None, port=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5494 | self.xid = xid |
| 5495 | if port != None: |
| 5496 | self.port = port |
| 5497 | else: |
| 5498 | self.port = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5499 | |
| 5500 | def pack(self): |
| 5501 | packed = [] |
| 5502 | packed.append(struct.pack("!B", self.version)) |
| 5503 | packed.append(struct.pack("!B", self.type)) |
| 5504 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5505 | packed.append(struct.pack("!L", self.xid)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5506 | packed.append(util.pack_port_no(self.port)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5507 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5508 | length = sum([len(x) for x in packed]) |
| 5509 | packed[2] = struct.pack("!H", length) |
| 5510 | return ''.join(packed) |
| 5511 | |
| 5512 | @staticmethod |
| 5513 | def unpack(buf): |
| 5514 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5515 | obj = queue_get_config_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5516 | if type(buf) == loxi.generic_util.OFReader: |
| 5517 | reader = buf |
| 5518 | else: |
| 5519 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5520 | _version = reader.read("!B")[0] |
| 5521 | assert(_version == 1) |
| 5522 | _type = reader.read("!B")[0] |
| 5523 | assert(_type == 20) |
| 5524 | _length = reader.read("!H")[0] |
| 5525 | obj.xid = reader.read("!L")[0] |
| 5526 | obj.port = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5527 | reader.skip(2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5528 | return obj |
| 5529 | |
| 5530 | def __eq__(self, other): |
| 5531 | if type(self) != type(other): return False |
| 5532 | if self.version != other.version: return False |
| 5533 | if self.type != other.type: return False |
| 5534 | if self.xid != other.xid: return False |
| 5535 | if self.port != other.port: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5536 | return True |
| 5537 | |
| 5538 | def __ne__(self, other): |
| 5539 | return not self.__eq__(other) |
| 5540 | |
| 5541 | def __str__(self): |
| 5542 | return self.show() |
| 5543 | |
| 5544 | def show(self): |
| 5545 | import loxi.pp |
| 5546 | return loxi.pp.pp(self) |
| 5547 | |
| 5548 | def pretty_print(self, q): |
| 5549 | q.text("queue_get_config_request {") |
| 5550 | with q.group(): |
| 5551 | with q.indent(2): |
| 5552 | q.breakable() |
| 5553 | q.text("xid = "); |
| 5554 | if self.xid != None: |
| 5555 | q.text("%#x" % self.xid) |
| 5556 | else: |
| 5557 | q.text('None') |
| 5558 | q.text(","); q.breakable() |
| 5559 | q.text("port = "); |
| 5560 | q.text(util.pretty_port(self.port)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5561 | q.breakable() |
| 5562 | q.text('}') |
| 5563 | |
| 5564 | class queue_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5565 | version = 1 |
| 5566 | type = 17 |
| 5567 | stats_type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5568 | |
| 5569 | def __init__(self, xid=None, flags=None, entries=None): |
| 5570 | self.xid = xid |
| 5571 | if flags != None: |
| 5572 | self.flags = flags |
| 5573 | else: |
| 5574 | self.flags = 0 |
| 5575 | if entries != None: |
| 5576 | self.entries = entries |
| 5577 | else: |
| 5578 | self.entries = [] |
| 5579 | |
| 5580 | def pack(self): |
| 5581 | packed = [] |
| 5582 | packed.append(struct.pack("!B", self.version)) |
| 5583 | packed.append(struct.pack("!B", self.type)) |
| 5584 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5585 | packed.append(struct.pack("!L", self.xid)) |
| 5586 | packed.append(struct.pack("!H", self.stats_type)) |
| 5587 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5588 | packed.append(util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5589 | length = sum([len(x) for x in packed]) |
| 5590 | packed[2] = struct.pack("!H", length) |
| 5591 | return ''.join(packed) |
| 5592 | |
| 5593 | @staticmethod |
| 5594 | def unpack(buf): |
| 5595 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5596 | obj = queue_stats_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5597 | if type(buf) == loxi.generic_util.OFReader: |
| 5598 | reader = buf |
| 5599 | else: |
| 5600 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5601 | _version = reader.read("!B")[0] |
| 5602 | assert(_version == 1) |
| 5603 | _type = reader.read("!B")[0] |
| 5604 | assert(_type == 17) |
| 5605 | _length = reader.read("!H")[0] |
| 5606 | obj.xid = reader.read("!L")[0] |
| 5607 | _stats_type = reader.read("!H")[0] |
| 5608 | assert(_stats_type == 5) |
| 5609 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5610 | obj.entries = loxi.generic_util.unpack_list(reader, common.queue_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5611 | return obj |
| 5612 | |
| 5613 | def __eq__(self, other): |
| 5614 | if type(self) != type(other): return False |
| 5615 | if self.version != other.version: return False |
| 5616 | if self.type != other.type: return False |
| 5617 | if self.xid != other.xid: return False |
| 5618 | if self.flags != other.flags: return False |
| 5619 | if self.entries != other.entries: return False |
| 5620 | return True |
| 5621 | |
| 5622 | def __ne__(self, other): |
| 5623 | return not self.__eq__(other) |
| 5624 | |
| 5625 | def __str__(self): |
| 5626 | return self.show() |
| 5627 | |
| 5628 | def show(self): |
| 5629 | import loxi.pp |
| 5630 | return loxi.pp.pp(self) |
| 5631 | |
| 5632 | def pretty_print(self, q): |
| 5633 | q.text("queue_stats_reply {") |
| 5634 | with q.group(): |
| 5635 | with q.indent(2): |
| 5636 | q.breakable() |
| 5637 | q.text("xid = "); |
| 5638 | if self.xid != None: |
| 5639 | q.text("%#x" % self.xid) |
| 5640 | else: |
| 5641 | q.text('None') |
| 5642 | q.text(","); q.breakable() |
| 5643 | q.text("flags = "); |
| 5644 | q.text("%#x" % self.flags) |
| 5645 | q.text(","); q.breakable() |
| 5646 | q.text("entries = "); |
| 5647 | q.pp(self.entries) |
| 5648 | q.breakable() |
| 5649 | q.text('}') |
| 5650 | |
| 5651 | class queue_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5652 | version = 1 |
| 5653 | type = 16 |
| 5654 | stats_type = 5 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5655 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5656 | def __init__(self, xid=None, flags=None, port_no=None, queue_id=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5657 | self.xid = xid |
| 5658 | if flags != None: |
| 5659 | self.flags = flags |
| 5660 | else: |
| 5661 | self.flags = 0 |
| 5662 | if port_no != None: |
| 5663 | self.port_no = port_no |
| 5664 | else: |
| 5665 | self.port_no = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5666 | if queue_id != None: |
| 5667 | self.queue_id = queue_id |
| 5668 | else: |
| 5669 | self.queue_id = 0 |
| 5670 | |
| 5671 | def pack(self): |
| 5672 | packed = [] |
| 5673 | packed.append(struct.pack("!B", self.version)) |
| 5674 | packed.append(struct.pack("!B", self.type)) |
| 5675 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5676 | packed.append(struct.pack("!L", self.xid)) |
| 5677 | packed.append(struct.pack("!H", self.stats_type)) |
| 5678 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5679 | packed.append(util.pack_port_no(self.port_no)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5680 | packed.append('\x00' * 2) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5681 | packed.append(struct.pack("!L", self.queue_id)) |
| 5682 | length = sum([len(x) for x in packed]) |
| 5683 | packed[2] = struct.pack("!H", length) |
| 5684 | return ''.join(packed) |
| 5685 | |
| 5686 | @staticmethod |
| 5687 | def unpack(buf): |
| 5688 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5689 | obj = queue_stats_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5690 | if type(buf) == loxi.generic_util.OFReader: |
| 5691 | reader = buf |
| 5692 | else: |
| 5693 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5694 | _version = reader.read("!B")[0] |
| 5695 | assert(_version == 1) |
| 5696 | _type = reader.read("!B")[0] |
| 5697 | assert(_type == 16) |
| 5698 | _length = reader.read("!H")[0] |
| 5699 | obj.xid = reader.read("!L")[0] |
| 5700 | _stats_type = reader.read("!H")[0] |
| 5701 | assert(_stats_type == 5) |
| 5702 | obj.flags = reader.read("!H")[0] |
| 5703 | obj.port_no = util.unpack_port_no(reader) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5704 | reader.skip(2) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5705 | obj.queue_id = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5706 | return obj |
| 5707 | |
| 5708 | def __eq__(self, other): |
| 5709 | if type(self) != type(other): return False |
| 5710 | if self.version != other.version: return False |
| 5711 | if self.type != other.type: return False |
| 5712 | if self.xid != other.xid: return False |
| 5713 | if self.flags != other.flags: return False |
| 5714 | if self.port_no != other.port_no: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5715 | if self.queue_id != other.queue_id: return False |
| 5716 | return True |
| 5717 | |
| 5718 | def __ne__(self, other): |
| 5719 | return not self.__eq__(other) |
| 5720 | |
| 5721 | def __str__(self): |
| 5722 | return self.show() |
| 5723 | |
| 5724 | def show(self): |
| 5725 | import loxi.pp |
| 5726 | return loxi.pp.pp(self) |
| 5727 | |
| 5728 | def pretty_print(self, q): |
| 5729 | q.text("queue_stats_request {") |
| 5730 | with q.group(): |
| 5731 | with q.indent(2): |
| 5732 | q.breakable() |
| 5733 | q.text("xid = "); |
| 5734 | if self.xid != None: |
| 5735 | q.text("%#x" % self.xid) |
| 5736 | else: |
| 5737 | q.text('None') |
| 5738 | q.text(","); q.breakable() |
| 5739 | q.text("flags = "); |
| 5740 | q.text("%#x" % self.flags) |
| 5741 | q.text(","); q.breakable() |
| 5742 | q.text("port_no = "); |
| 5743 | q.text(util.pretty_port(self.port_no)) |
| 5744 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5745 | q.text("queue_id = "); |
| 5746 | q.text("%#x" % self.queue_id) |
| 5747 | q.breakable() |
| 5748 | q.text('}') |
| 5749 | |
| 5750 | class set_config(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5751 | version = 1 |
| 5752 | type = 9 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5753 | |
| 5754 | def __init__(self, xid=None, flags=None, miss_send_len=None): |
| 5755 | self.xid = xid |
| 5756 | if flags != None: |
| 5757 | self.flags = flags |
| 5758 | else: |
| 5759 | self.flags = 0 |
| 5760 | if miss_send_len != None: |
| 5761 | self.miss_send_len = miss_send_len |
| 5762 | else: |
| 5763 | self.miss_send_len = 0 |
| 5764 | |
| 5765 | def pack(self): |
| 5766 | packed = [] |
| 5767 | packed.append(struct.pack("!B", self.version)) |
| 5768 | packed.append(struct.pack("!B", self.type)) |
| 5769 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5770 | packed.append(struct.pack("!L", self.xid)) |
| 5771 | packed.append(struct.pack("!H", self.flags)) |
| 5772 | packed.append(struct.pack("!H", self.miss_send_len)) |
| 5773 | length = sum([len(x) for x in packed]) |
| 5774 | packed[2] = struct.pack("!H", length) |
| 5775 | return ''.join(packed) |
| 5776 | |
| 5777 | @staticmethod |
| 5778 | def unpack(buf): |
| 5779 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5780 | obj = set_config() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5781 | if type(buf) == loxi.generic_util.OFReader: |
| 5782 | reader = buf |
| 5783 | else: |
| 5784 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5785 | _version = reader.read("!B")[0] |
| 5786 | assert(_version == 1) |
| 5787 | _type = reader.read("!B")[0] |
| 5788 | assert(_type == 9) |
| 5789 | _length = reader.read("!H")[0] |
| 5790 | obj.xid = reader.read("!L")[0] |
| 5791 | obj.flags = reader.read("!H")[0] |
| 5792 | obj.miss_send_len = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5793 | return obj |
| 5794 | |
| 5795 | def __eq__(self, other): |
| 5796 | if type(self) != type(other): return False |
| 5797 | if self.version != other.version: return False |
| 5798 | if self.type != other.type: return False |
| 5799 | if self.xid != other.xid: return False |
| 5800 | if self.flags != other.flags: return False |
| 5801 | if self.miss_send_len != other.miss_send_len: return False |
| 5802 | return True |
| 5803 | |
| 5804 | def __ne__(self, other): |
| 5805 | return not self.__eq__(other) |
| 5806 | |
| 5807 | def __str__(self): |
| 5808 | return self.show() |
| 5809 | |
| 5810 | def show(self): |
| 5811 | import loxi.pp |
| 5812 | return loxi.pp.pp(self) |
| 5813 | |
| 5814 | def pretty_print(self, q): |
| 5815 | q.text("set_config {") |
| 5816 | with q.group(): |
| 5817 | with q.indent(2): |
| 5818 | q.breakable() |
| 5819 | q.text("xid = "); |
| 5820 | if self.xid != None: |
| 5821 | q.text("%#x" % self.xid) |
| 5822 | else: |
| 5823 | q.text('None') |
| 5824 | q.text(","); q.breakable() |
| 5825 | q.text("flags = "); |
| 5826 | q.text("%#x" % self.flags) |
| 5827 | q.text(","); q.breakable() |
| 5828 | q.text("miss_send_len = "); |
| 5829 | q.text("%#x" % self.miss_send_len) |
| 5830 | q.breakable() |
| 5831 | q.text('}') |
| 5832 | |
| 5833 | class table_mod(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5834 | version = 1 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5835 | type = 22 |
| 5836 | |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5837 | def __init__(self, xid=None, table_id=None, config=None): |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5838 | self.xid = xid |
| 5839 | if table_id != None: |
| 5840 | self.table_id = table_id |
| 5841 | else: |
| 5842 | self.table_id = 0 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5843 | if config != None: |
| 5844 | self.config = config |
| 5845 | else: |
| 5846 | self.config = 0 |
| 5847 | |
| 5848 | def pack(self): |
| 5849 | packed = [] |
| 5850 | packed.append(struct.pack("!B", self.version)) |
| 5851 | packed.append(struct.pack("!B", self.type)) |
| 5852 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5853 | packed.append(struct.pack("!L", self.xid)) |
| 5854 | packed.append(struct.pack("!B", self.table_id)) |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5855 | packed.append('\x00' * 3) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5856 | packed.append(struct.pack("!L", self.config)) |
| 5857 | length = sum([len(x) for x in packed]) |
| 5858 | packed[2] = struct.pack("!H", length) |
| 5859 | return ''.join(packed) |
| 5860 | |
| 5861 | @staticmethod |
| 5862 | def unpack(buf): |
| 5863 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5864 | obj = table_mod() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5865 | if type(buf) == loxi.generic_util.OFReader: |
| 5866 | reader = buf |
| 5867 | else: |
| 5868 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5869 | _version = reader.read("!B")[0] |
| 5870 | assert(_version == 1) |
| 5871 | _type = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5872 | assert(_type == 22) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5873 | _length = reader.read("!H")[0] |
| 5874 | obj.xid = reader.read("!L")[0] |
| 5875 | obj.table_id = reader.read("!B")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5876 | reader.skip(3) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5877 | obj.config = reader.read("!L")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5878 | return obj |
| 5879 | |
| 5880 | def __eq__(self, other): |
| 5881 | if type(self) != type(other): return False |
| 5882 | if self.version != other.version: return False |
| 5883 | if self.type != other.type: return False |
| 5884 | if self.xid != other.xid: return False |
| 5885 | if self.table_id != other.table_id: return False |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5886 | if self.config != other.config: return False |
| 5887 | return True |
| 5888 | |
| 5889 | def __ne__(self, other): |
| 5890 | return not self.__eq__(other) |
| 5891 | |
| 5892 | def __str__(self): |
| 5893 | return self.show() |
| 5894 | |
| 5895 | def show(self): |
| 5896 | import loxi.pp |
| 5897 | return loxi.pp.pp(self) |
| 5898 | |
| 5899 | def pretty_print(self, q): |
| 5900 | q.text("table_mod {") |
| 5901 | with q.group(): |
| 5902 | with q.indent(2): |
| 5903 | q.breakable() |
| 5904 | q.text("xid = "); |
| 5905 | if self.xid != None: |
| 5906 | q.text("%#x" % self.xid) |
| 5907 | else: |
| 5908 | q.text('None') |
| 5909 | q.text(","); q.breakable() |
| 5910 | q.text("table_id = "); |
| 5911 | q.text("%#x" % self.table_id) |
| 5912 | q.text(","); q.breakable() |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5913 | q.text("config = "); |
| 5914 | q.text("%#x" % self.config) |
| 5915 | q.breakable() |
| 5916 | q.text('}') |
| 5917 | |
| 5918 | class table_stats_reply(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5919 | version = 1 |
| 5920 | type = 17 |
| 5921 | stats_type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5922 | |
| 5923 | def __init__(self, xid=None, flags=None, entries=None): |
| 5924 | self.xid = xid |
| 5925 | if flags != None: |
| 5926 | self.flags = flags |
| 5927 | else: |
| 5928 | self.flags = 0 |
| 5929 | if entries != None: |
| 5930 | self.entries = entries |
| 5931 | else: |
| 5932 | self.entries = [] |
| 5933 | |
| 5934 | def pack(self): |
| 5935 | packed = [] |
| 5936 | packed.append(struct.pack("!B", self.version)) |
| 5937 | packed.append(struct.pack("!B", self.type)) |
| 5938 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 5939 | packed.append(struct.pack("!L", self.xid)) |
| 5940 | packed.append(struct.pack("!H", self.stats_type)) |
| 5941 | packed.append(struct.pack("!H", self.flags)) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5942 | packed.append(util.pack_list(self.entries)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5943 | length = sum([len(x) for x in packed]) |
| 5944 | packed[2] = struct.pack("!H", length) |
| 5945 | return ''.join(packed) |
| 5946 | |
| 5947 | @staticmethod |
| 5948 | def unpack(buf): |
| 5949 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 5950 | obj = table_stats_reply() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5951 | if type(buf) == loxi.generic_util.OFReader: |
| 5952 | reader = buf |
| 5953 | else: |
| 5954 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 5955 | _version = reader.read("!B")[0] |
| 5956 | assert(_version == 1) |
| 5957 | _type = reader.read("!B")[0] |
| 5958 | assert(_type == 17) |
| 5959 | _length = reader.read("!H")[0] |
| 5960 | obj.xid = reader.read("!L")[0] |
| 5961 | _stats_type = reader.read("!H")[0] |
| 5962 | assert(_stats_type == 3) |
| 5963 | obj.flags = reader.read("!H")[0] |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 5964 | obj.entries = loxi.generic_util.unpack_list(reader, common.table_stats_entry.unpack) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 5965 | return obj |
| 5966 | |
| 5967 | def __eq__(self, other): |
| 5968 | if type(self) != type(other): return False |
| 5969 | if self.version != other.version: return False |
| 5970 | if self.type != other.type: return False |
| 5971 | if self.xid != other.xid: return False |
| 5972 | if self.flags != other.flags: return False |
| 5973 | if self.entries != other.entries: return False |
| 5974 | return True |
| 5975 | |
| 5976 | def __ne__(self, other): |
| 5977 | return not self.__eq__(other) |
| 5978 | |
| 5979 | def __str__(self): |
| 5980 | return self.show() |
| 5981 | |
| 5982 | def show(self): |
| 5983 | import loxi.pp |
| 5984 | return loxi.pp.pp(self) |
| 5985 | |
| 5986 | def pretty_print(self, q): |
| 5987 | q.text("table_stats_reply {") |
| 5988 | with q.group(): |
| 5989 | with q.indent(2): |
| 5990 | q.breakable() |
| 5991 | q.text("xid = "); |
| 5992 | if self.xid != None: |
| 5993 | q.text("%#x" % self.xid) |
| 5994 | else: |
| 5995 | q.text('None') |
| 5996 | q.text(","); q.breakable() |
| 5997 | q.text("flags = "); |
| 5998 | q.text("%#x" % self.flags) |
| 5999 | q.text(","); q.breakable() |
| 6000 | q.text("entries = "); |
| 6001 | q.pp(self.entries) |
| 6002 | q.breakable() |
| 6003 | q.text('}') |
| 6004 | |
| 6005 | class table_stats_request(Message): |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6006 | version = 1 |
| 6007 | type = 16 |
| 6008 | stats_type = 3 |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6009 | |
| 6010 | def __init__(self, xid=None, flags=None): |
| 6011 | self.xid = xid |
| 6012 | if flags != None: |
| 6013 | self.flags = flags |
| 6014 | else: |
| 6015 | self.flags = 0 |
| 6016 | |
| 6017 | def pack(self): |
| 6018 | packed = [] |
| 6019 | packed.append(struct.pack("!B", self.version)) |
| 6020 | packed.append(struct.pack("!B", self.type)) |
| 6021 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 2 |
| 6022 | packed.append(struct.pack("!L", self.xid)) |
| 6023 | packed.append(struct.pack("!H", self.stats_type)) |
| 6024 | packed.append(struct.pack("!H", self.flags)) |
| 6025 | length = sum([len(x) for x in packed]) |
| 6026 | packed[2] = struct.pack("!H", length) |
| 6027 | return ''.join(packed) |
| 6028 | |
| 6029 | @staticmethod |
| 6030 | def unpack(buf): |
| 6031 | if len(buf) < 8: raise loxi.ProtocolError("buffer too short to contain an OpenFlow message") |
| 6032 | obj = table_stats_request() |
Rich Lane | c2ee4b8 | 2013-04-24 17:12:38 -0700 | [diff] [blame] | 6033 | if type(buf) == loxi.generic_util.OFReader: |
| 6034 | reader = buf |
| 6035 | else: |
| 6036 | reader = loxi.generic_util.OFReader(buf) |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6037 | _version = reader.read("!B")[0] |
| 6038 | assert(_version == 1) |
| 6039 | _type = reader.read("!B")[0] |
| 6040 | assert(_type == 16) |
| 6041 | _length = reader.read("!H")[0] |
| 6042 | obj.xid = reader.read("!L")[0] |
| 6043 | _stats_type = reader.read("!H")[0] |
| 6044 | assert(_stats_type == 3) |
| 6045 | obj.flags = reader.read("!H")[0] |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6046 | return obj |
| 6047 | |
| 6048 | def __eq__(self, other): |
| 6049 | if type(self) != type(other): return False |
| 6050 | if self.version != other.version: return False |
| 6051 | if self.type != other.type: return False |
| 6052 | if self.xid != other.xid: return False |
| 6053 | if self.flags != other.flags: return False |
| 6054 | return True |
| 6055 | |
| 6056 | def __ne__(self, other): |
| 6057 | return not self.__eq__(other) |
| 6058 | |
| 6059 | def __str__(self): |
| 6060 | return self.show() |
| 6061 | |
| 6062 | def show(self): |
| 6063 | import loxi.pp |
| 6064 | return loxi.pp.pp(self) |
| 6065 | |
| 6066 | def pretty_print(self, q): |
| 6067 | q.text("table_stats_request {") |
| 6068 | with q.group(): |
| 6069 | with q.indent(2): |
| 6070 | q.breakable() |
| 6071 | q.text("xid = "); |
| 6072 | if self.xid != None: |
| 6073 | q.text("%#x" % self.xid) |
| 6074 | else: |
| 6075 | q.text('None') |
| 6076 | q.text(","); q.breakable() |
| 6077 | q.text("flags = "); |
| 6078 | q.text("%#x" % self.flags) |
| 6079 | q.breakable() |
| 6080 | q.text('}') |
| 6081 | |
| 6082 | |
| 6083 | def parse_header(buf): |
| 6084 | if len(buf) < 8: |
| 6085 | raise loxi.ProtocolError("too short to be an OpenFlow message") |
| 6086 | return struct.unpack_from("!BBHL", buf) |
| 6087 | |
| 6088 | def parse_message(buf): |
| 6089 | msg_ver, msg_type, msg_len, msg_xid = parse_header(buf) |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 6090 | if msg_ver != const.OFP_VERSION and msg_type != const.OFPT_HELLO: |
| 6091 | raise loxi.ProtocolError("wrong OpenFlow version (expected %d, got %d)" % (const.OFP_VERSION, msg_ver)) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6092 | if len(buf) != msg_len: |
| 6093 | raise loxi.ProtocolError("incorrect message size") |
| 6094 | if msg_type in parsers: |
| 6095 | return parsers[msg_type](buf) |
| 6096 | else: |
| 6097 | raise loxi.ProtocolError("unexpected message type") |
| 6098 | |
| 6099 | def parse_flow_mod(buf): |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 6100 | if len(buf) < 57 + 1: |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6101 | raise loxi.ProtocolError("message too short") |
Rich Lane | fe600f5 | 2013-07-09 13:22:32 -0700 | [diff] [blame] | 6102 | # Technically uint16_t for OF 1.0 |
| 6103 | cmd, = struct.unpack_from("!B", buf, 57) |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6104 | if cmd in flow_mod_parsers: |
| 6105 | return flow_mod_parsers[cmd](buf) |
| 6106 | else: |
| 6107 | raise loxi.ProtocolError("unexpected flow mod cmd %u" % cmd) |
| 6108 | |
| 6109 | def parse_stats_reply(buf): |
| 6110 | if len(buf) < 8 + 2: |
| 6111 | raise loxi.ProtocolError("message too short") |
| 6112 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 6113 | if stats_type in stats_reply_parsers: |
| 6114 | return stats_reply_parsers[stats_type](buf) |
| 6115 | else: |
| 6116 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 6117 | |
| 6118 | def parse_stats_request(buf): |
| 6119 | if len(buf) < 8 + 2: |
| 6120 | raise loxi.ProtocolError("message too short") |
| 6121 | stats_type, = struct.unpack_from("!H", buf, 8) |
| 6122 | if stats_type in stats_request_parsers: |
| 6123 | return stats_request_parsers[stats_type](buf) |
| 6124 | else: |
| 6125 | raise loxi.ProtocolError("unexpected stats type %u" % stats_type) |
| 6126 | |
| 6127 | def parse_vendor(buf): |
| 6128 | if len(buf) < 16: |
| 6129 | raise loxi.ProtocolError("experimenter message too short") |
| 6130 | |
| 6131 | experimenter, = struct.unpack_from("!L", buf, 8) |
| 6132 | if experimenter == 0x005c16c7: # Big Switch Networks |
| 6133 | subtype, = struct.unpack_from("!L", buf, 12) |
| 6134 | elif experimenter == 0x00002320: # Nicira |
| 6135 | subtype, = struct.unpack_from("!L", buf, 12) |
| 6136 | else: |
| 6137 | raise loxi.ProtocolError("unexpected experimenter id %#x" % experimenter) |
| 6138 | |
| 6139 | if subtype in experimenter_parsers[experimenter]: |
| 6140 | return experimenter_parsers[experimenter][subtype](buf) |
| 6141 | else: |
| 6142 | raise loxi.ProtocolError("unexpected experimenter %#x subtype %#x" % (experimenter, subtype)) |
| 6143 | |
| 6144 | parsers = { |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6145 | const.OFPT_HELLO : hello.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6146 | const.OFPT_ERROR : error_msg.unpack, |
| 6147 | const.OFPT_ECHO_REQUEST : echo_request.unpack, |
| 6148 | const.OFPT_ECHO_REPLY : echo_reply.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6149 | const.OFPT_VENDOR : parse_vendor, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6150 | const.OFPT_FEATURES_REQUEST : features_request.unpack, |
| 6151 | const.OFPT_FEATURES_REPLY : features_reply.unpack, |
| 6152 | const.OFPT_GET_CONFIG_REQUEST : get_config_request.unpack, |
| 6153 | const.OFPT_GET_CONFIG_REPLY : get_config_reply.unpack, |
| 6154 | const.OFPT_SET_CONFIG : set_config.unpack, |
| 6155 | const.OFPT_PACKET_IN : packet_in.unpack, |
| 6156 | const.OFPT_FLOW_REMOVED : flow_removed.unpack, |
| 6157 | const.OFPT_PORT_STATUS : port_status.unpack, |
| 6158 | const.OFPT_PACKET_OUT : packet_out.unpack, |
| 6159 | const.OFPT_FLOW_MOD : parse_flow_mod, |
| 6160 | const.OFPT_PORT_MOD : port_mod.unpack, |
| 6161 | const.OFPT_STATS_REQUEST : parse_stats_request, |
| 6162 | const.OFPT_STATS_REPLY : parse_stats_reply, |
| 6163 | const.OFPT_BARRIER_REQUEST : barrier_request.unpack, |
| 6164 | const.OFPT_BARRIER_REPLY : barrier_reply.unpack, |
| 6165 | const.OFPT_QUEUE_GET_CONFIG_REQUEST : queue_get_config_request.unpack, |
| 6166 | const.OFPT_QUEUE_GET_CONFIG_REPLY : queue_get_config_reply.unpack, |
| 6167 | 22 : table_mod.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6168 | } |
| 6169 | |
| 6170 | flow_mod_parsers = { |
| 6171 | const.OFPFC_ADD : flow_add.unpack, |
| 6172 | const.OFPFC_MODIFY : flow_modify.unpack, |
| 6173 | const.OFPFC_MODIFY_STRICT : flow_modify_strict.unpack, |
| 6174 | const.OFPFC_DELETE : flow_delete.unpack, |
| 6175 | const.OFPFC_DELETE_STRICT : flow_delete_strict.unpack, |
| 6176 | } |
| 6177 | |
| 6178 | stats_reply_parsers = { |
| 6179 | const.OFPST_DESC : desc_stats_reply.unpack, |
| 6180 | const.OFPST_FLOW : flow_stats_reply.unpack, |
| 6181 | const.OFPST_AGGREGATE : aggregate_stats_reply.unpack, |
| 6182 | const.OFPST_TABLE : table_stats_reply.unpack, |
| 6183 | const.OFPST_PORT : port_stats_reply.unpack, |
| 6184 | const.OFPST_QUEUE : queue_stats_reply.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6185 | } |
| 6186 | |
| 6187 | stats_request_parsers = { |
| 6188 | const.OFPST_DESC : desc_stats_request.unpack, |
| 6189 | const.OFPST_FLOW : flow_stats_request.unpack, |
| 6190 | const.OFPST_AGGREGATE : aggregate_stats_request.unpack, |
| 6191 | const.OFPST_TABLE : table_stats_request.unpack, |
| 6192 | const.OFPST_PORT : port_stats_request.unpack, |
| 6193 | const.OFPST_QUEUE : queue_stats_request.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6194 | } |
| 6195 | |
| 6196 | experimenter_parsers = { |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6197 | 8992 : { |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6198 | 11: nicira_controller_role_reply.unpack, |
| 6199 | 10: nicira_controller_role_request.unpack, |
| 6200 | }, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6201 | 6035143 : { |
| 6202 | 22: bsn_bw_clear_data_reply.unpack, |
| 6203 | 21: bsn_bw_clear_data_request.unpack, |
| 6204 | 20: bsn_bw_enable_get_reply.unpack, |
| 6205 | 19: bsn_bw_enable_get_request.unpack, |
| 6206 | 23: bsn_bw_enable_set_reply.unpack, |
| 6207 | 18: bsn_bw_enable_set_request.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6208 | 10: bsn_get_interfaces_reply.unpack, |
| 6209 | 9: bsn_get_interfaces_request.unpack, |
| 6210 | 2: bsn_get_ip_mask_reply.unpack, |
| 6211 | 1: bsn_get_ip_mask_request.unpack, |
Rich Lane | 90c961c | 2013-05-14 09:26:50 -0700 | [diff] [blame] | 6212 | 14: bsn_get_l2_table_reply.unpack, |
| 6213 | 13: bsn_get_l2_table_request.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6214 | 5: bsn_get_mirroring_reply.unpack, |
| 6215 | 4: bsn_get_mirroring_request.unpack, |
| 6216 | 0: bsn_set_ip_mask.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6217 | 24: bsn_set_l2_table_reply.unpack, |
| 6218 | 12: bsn_set_l2_table_request.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6219 | 3: bsn_set_mirroring.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6220 | 25: bsn_set_pktin_suppression_reply.unpack, |
| 6221 | 11: bsn_set_pktin_suppression_request.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6222 | 6: bsn_shell_command.unpack, |
| 6223 | 7: bsn_shell_output.unpack, |
| 6224 | 8: bsn_shell_status.unpack, |
Dan Talayco | f620225 | 2013-07-02 01:00:29 -0700 | [diff] [blame] | 6225 | 16: bsn_virtual_port_create_reply.unpack, |
| 6226 | 15: bsn_virtual_port_create_request.unpack, |
| 6227 | 26: bsn_virtual_port_remove_reply.unpack, |
| 6228 | 17: bsn_virtual_port_remove_request.unpack, |
Rich Lane | b658ddd | 2013-03-12 10:15:10 -0700 | [diff] [blame] | 6229 | }, |
| 6230 | } |