Nathan Knuth | 418fdc8 | 2016-09-16 22:51:15 -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. |
| 4 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 5 | |
| 6 | # Automatically generated by LOXI from template module.py |
| 7 | # Do not modify |
| 8 | |
| 9 | import struct |
| 10 | import loxi |
| 11 | import util |
| 12 | import loxi.generic_util |
| 13 | |
| 14 | import sys |
| 15 | ofp = sys.modules['loxi.of14'] |
| 16 | |
| 17 | class queue_desc_prop(loxi.OFObject): |
| 18 | subtypes = {} |
| 19 | |
| 20 | |
| 21 | def __init__(self, type=None): |
| 22 | if type != None: |
| 23 | self.type = type |
| 24 | else: |
| 25 | self.type = 0 |
| 26 | return |
| 27 | |
| 28 | def pack(self): |
| 29 | packed = [] |
| 30 | packed.append(struct.pack("!H", self.type)) |
| 31 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 32 | length = sum([len(x) for x in packed]) |
| 33 | packed[1] = struct.pack("!H", length) |
| 34 | return ''.join(packed) |
| 35 | |
| 36 | @staticmethod |
| 37 | def unpack(reader): |
| 38 | subtype, = reader.peek('!H', 0) |
| 39 | subclass = queue_desc_prop.subtypes.get(subtype) |
| 40 | if subclass: |
| 41 | return subclass.unpack(reader) |
| 42 | |
| 43 | obj = queue_desc_prop() |
| 44 | obj.type = reader.read("!H")[0] |
| 45 | _length = reader.read("!H")[0] |
| 46 | orig_reader = reader |
| 47 | reader = orig_reader.slice(_length, 4) |
| 48 | return obj |
| 49 | |
| 50 | def __eq__(self, other): |
| 51 | if type(self) != type(other): return False |
| 52 | if self.type != other.type: return False |
| 53 | return True |
| 54 | |
| 55 | def pretty_print(self, q): |
| 56 | q.text("queue_desc_prop {") |
| 57 | with q.group(): |
| 58 | with q.indent(2): |
| 59 | q.breakable() |
| 60 | q.breakable() |
| 61 | q.text('}') |
| 62 | |
| 63 | |
| 64 | class experimenter(queue_desc_prop): |
| 65 | subtypes = {} |
| 66 | |
| 67 | type = 65535 |
| 68 | |
| 69 | def __init__(self, experimenter=None, exp_type=None): |
| 70 | if experimenter != None: |
| 71 | self.experimenter = experimenter |
| 72 | else: |
| 73 | self.experimenter = 0 |
| 74 | if exp_type != None: |
| 75 | self.exp_type = exp_type |
| 76 | else: |
| 77 | self.exp_type = 0 |
| 78 | return |
| 79 | |
| 80 | def pack(self): |
| 81 | packed = [] |
| 82 | packed.append(struct.pack("!H", self.type)) |
| 83 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 84 | packed.append(struct.pack("!L", self.experimenter)) |
| 85 | packed.append(struct.pack("!L", self.exp_type)) |
| 86 | length = sum([len(x) for x in packed]) |
| 87 | packed[1] = struct.pack("!H", length) |
| 88 | return ''.join(packed) |
| 89 | |
| 90 | @staticmethod |
| 91 | def unpack(reader): |
| 92 | subtype, = reader.peek('!L', 4) |
| 93 | subclass = experimenter.subtypes.get(subtype) |
| 94 | if subclass: |
| 95 | return subclass.unpack(reader) |
| 96 | |
| 97 | obj = experimenter() |
| 98 | _type = reader.read("!H")[0] |
| 99 | assert(_type == 65535) |
| 100 | _length = reader.read("!H")[0] |
| 101 | orig_reader = reader |
| 102 | reader = orig_reader.slice(_length, 4) |
| 103 | obj.experimenter = reader.read("!L")[0] |
| 104 | obj.exp_type = reader.read("!L")[0] |
| 105 | return obj |
| 106 | |
| 107 | def __eq__(self, other): |
| 108 | if type(self) != type(other): return False |
| 109 | if self.experimenter != other.experimenter: return False |
| 110 | if self.exp_type != other.exp_type: return False |
| 111 | return True |
| 112 | |
| 113 | def pretty_print(self, q): |
| 114 | q.text("experimenter {") |
| 115 | with q.group(): |
| 116 | with q.indent(2): |
| 117 | q.breakable() |
| 118 | q.text("exp_type = "); |
| 119 | q.text("%#x" % self.exp_type) |
| 120 | q.breakable() |
| 121 | q.text('}') |
| 122 | |
| 123 | queue_desc_prop.subtypes[65535] = experimenter |
| 124 | |
| 125 | class max_rate(queue_desc_prop): |
| 126 | type = 2 |
| 127 | |
| 128 | def __init__(self, rate=None): |
| 129 | if rate != None: |
| 130 | self.rate = rate |
| 131 | else: |
| 132 | self.rate = 0 |
| 133 | return |
| 134 | |
| 135 | def pack(self): |
| 136 | packed = [] |
| 137 | packed.append(struct.pack("!H", self.type)) |
| 138 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 139 | packed.append(struct.pack("!H", self.rate)) |
| 140 | packed.append('\x00' * 2) |
| 141 | length = sum([len(x) for x in packed]) |
| 142 | packed[1] = struct.pack("!H", length) |
| 143 | return ''.join(packed) |
| 144 | |
| 145 | @staticmethod |
| 146 | def unpack(reader): |
| 147 | obj = max_rate() |
| 148 | _type = reader.read("!H")[0] |
| 149 | assert(_type == 2) |
| 150 | _length = reader.read("!H")[0] |
| 151 | orig_reader = reader |
| 152 | reader = orig_reader.slice(_length, 4) |
| 153 | obj.rate = reader.read("!H")[0] |
| 154 | reader.skip(2) |
| 155 | return obj |
| 156 | |
| 157 | def __eq__(self, other): |
| 158 | if type(self) != type(other): return False |
| 159 | if self.rate != other.rate: return False |
| 160 | return True |
| 161 | |
| 162 | def pretty_print(self, q): |
| 163 | q.text("max_rate {") |
| 164 | with q.group(): |
| 165 | with q.indent(2): |
| 166 | q.breakable() |
| 167 | q.text("rate = "); |
| 168 | q.text("%#x" % self.rate) |
| 169 | q.breakable() |
| 170 | q.text('}') |
| 171 | |
| 172 | queue_desc_prop.subtypes[2] = max_rate |
| 173 | |
| 174 | class min_rate(queue_desc_prop): |
| 175 | type = 1 |
| 176 | |
| 177 | def __init__(self, rate=None): |
| 178 | if rate != None: |
| 179 | self.rate = rate |
| 180 | else: |
| 181 | self.rate = 0 |
| 182 | return |
| 183 | |
| 184 | def pack(self): |
| 185 | packed = [] |
| 186 | packed.append(struct.pack("!H", self.type)) |
| 187 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 188 | packed.append(struct.pack("!H", self.rate)) |
| 189 | packed.append('\x00' * 2) |
| 190 | length = sum([len(x) for x in packed]) |
| 191 | packed[1] = struct.pack("!H", length) |
| 192 | return ''.join(packed) |
| 193 | |
| 194 | @staticmethod |
| 195 | def unpack(reader): |
| 196 | obj = min_rate() |
| 197 | _type = reader.read("!H")[0] |
| 198 | assert(_type == 1) |
| 199 | _length = reader.read("!H")[0] |
| 200 | orig_reader = reader |
| 201 | reader = orig_reader.slice(_length, 4) |
| 202 | obj.rate = reader.read("!H")[0] |
| 203 | reader.skip(2) |
| 204 | return obj |
| 205 | |
| 206 | def __eq__(self, other): |
| 207 | if type(self) != type(other): return False |
| 208 | if self.rate != other.rate: return False |
| 209 | return True |
| 210 | |
| 211 | def pretty_print(self, q): |
| 212 | q.text("min_rate {") |
| 213 | with q.group(): |
| 214 | with q.indent(2): |
| 215 | q.breakable() |
| 216 | q.text("rate = "); |
| 217 | q.text("%#x" % self.rate) |
| 218 | q.breakable() |
| 219 | q.text('}') |
| 220 | |
| 221 | queue_desc_prop.subtypes[1] = min_rate |
| 222 | |
| 223 | |