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 port_mod_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 = port_mod_prop.subtypes.get(subtype) |
| 40 | if subclass: |
| 41 | return subclass.unpack(reader) |
| 42 | |
| 43 | obj = port_mod_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("port_mod_prop {") |
| 57 | with q.group(): |
| 58 | with q.indent(2): |
| 59 | q.breakable() |
| 60 | q.breakable() |
| 61 | q.text('}') |
| 62 | |
| 63 | |
| 64 | class ethernet(port_mod_prop): |
| 65 | type = 0 |
| 66 | |
| 67 | def __init__(self, advertise=None): |
| 68 | if advertise != None: |
| 69 | self.advertise = advertise |
| 70 | else: |
| 71 | self.advertise = 0 |
| 72 | return |
| 73 | |
| 74 | def pack(self): |
| 75 | packed = [] |
| 76 | packed.append(struct.pack("!H", self.type)) |
| 77 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 78 | packed.append(struct.pack("!L", self.advertise)) |
| 79 | length = sum([len(x) for x in packed]) |
| 80 | packed[1] = struct.pack("!H", length) |
| 81 | return ''.join(packed) |
| 82 | |
| 83 | @staticmethod |
| 84 | def unpack(reader): |
| 85 | obj = ethernet() |
| 86 | _type = reader.read("!H")[0] |
| 87 | assert(_type == 0) |
| 88 | _length = reader.read("!H")[0] |
| 89 | orig_reader = reader |
| 90 | reader = orig_reader.slice(_length, 4) |
| 91 | obj.advertise = reader.read("!L")[0] |
| 92 | return obj |
| 93 | |
| 94 | def __eq__(self, other): |
| 95 | if type(self) != type(other): return False |
| 96 | if self.advertise != other.advertise: return False |
| 97 | return True |
| 98 | |
| 99 | def pretty_print(self, q): |
| 100 | q.text("ethernet {") |
| 101 | with q.group(): |
| 102 | with q.indent(2): |
| 103 | q.breakable() |
| 104 | q.text("advertise = "); |
| 105 | q.text("%#x" % self.advertise) |
| 106 | q.breakable() |
| 107 | q.text('}') |
| 108 | |
| 109 | port_mod_prop.subtypes[0] = ethernet |
| 110 | |
| 111 | class experimenter(port_mod_prop): |
| 112 | subtypes = {} |
| 113 | |
| 114 | type = 65535 |
| 115 | |
| 116 | def __init__(self, experimenter=None, exp_type=None): |
| 117 | if experimenter != None: |
| 118 | self.experimenter = experimenter |
| 119 | else: |
| 120 | self.experimenter = 0 |
| 121 | if exp_type != None: |
| 122 | self.exp_type = exp_type |
| 123 | else: |
| 124 | self.exp_type = 0 |
| 125 | return |
| 126 | |
| 127 | def pack(self): |
| 128 | packed = [] |
| 129 | packed.append(struct.pack("!H", self.type)) |
| 130 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 131 | packed.append(struct.pack("!L", self.experimenter)) |
| 132 | packed.append(struct.pack("!L", self.exp_type)) |
| 133 | length = sum([len(x) for x in packed]) |
| 134 | packed[1] = struct.pack("!H", length) |
| 135 | return ''.join(packed) |
| 136 | |
| 137 | @staticmethod |
| 138 | def unpack(reader): |
| 139 | subtype, = reader.peek('!L', 4) |
| 140 | subclass = experimenter.subtypes.get(subtype) |
| 141 | if subclass: |
| 142 | return subclass.unpack(reader) |
| 143 | |
| 144 | obj = experimenter() |
| 145 | _type = reader.read("!H")[0] |
| 146 | assert(_type == 65535) |
| 147 | _length = reader.read("!H")[0] |
| 148 | orig_reader = reader |
| 149 | reader = orig_reader.slice(_length, 4) |
| 150 | obj.experimenter = reader.read("!L")[0] |
| 151 | obj.exp_type = reader.read("!L")[0] |
| 152 | return obj |
| 153 | |
| 154 | def __eq__(self, other): |
| 155 | if type(self) != type(other): return False |
| 156 | if self.experimenter != other.experimenter: return False |
| 157 | if self.exp_type != other.exp_type: return False |
| 158 | return True |
| 159 | |
| 160 | def pretty_print(self, q): |
| 161 | q.text("experimenter {") |
| 162 | with q.group(): |
| 163 | with q.indent(2): |
| 164 | q.breakable() |
| 165 | q.text("exp_type = "); |
| 166 | q.text("%#x" % self.exp_type) |
| 167 | q.breakable() |
| 168 | q.text('}') |
| 169 | |
| 170 | port_mod_prop.subtypes[65535] = experimenter |
| 171 | |
| 172 | class optical(port_mod_prop): |
| 173 | type = 1 |
| 174 | |
| 175 | def __init__(self, configure=None, freq_ldma=None, fl_offset=None, grid_span=None, tx_pwr=None): |
| 176 | if configure != None: |
| 177 | self.configure = configure |
| 178 | else: |
| 179 | self.configure = 0 |
| 180 | if freq_ldma != None: |
| 181 | self.freq_ldma = freq_ldma |
| 182 | else: |
| 183 | self.freq_ldma = 0 |
| 184 | if fl_offset != None: |
| 185 | self.fl_offset = fl_offset |
| 186 | else: |
| 187 | self.fl_offset = 0 |
| 188 | if grid_span != None: |
| 189 | self.grid_span = grid_span |
| 190 | else: |
| 191 | self.grid_span = 0 |
| 192 | if tx_pwr != None: |
| 193 | self.tx_pwr = tx_pwr |
| 194 | else: |
| 195 | self.tx_pwr = 0 |
| 196 | return |
| 197 | |
| 198 | def pack(self): |
| 199 | packed = [] |
| 200 | packed.append(struct.pack("!H", self.type)) |
| 201 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 202 | packed.append(struct.pack("!L", self.configure)) |
| 203 | packed.append(struct.pack("!L", self.freq_ldma)) |
| 204 | packed.append(struct.pack("!L", self.fl_offset)) |
| 205 | packed.append(struct.pack("!L", self.grid_span)) |
| 206 | packed.append(struct.pack("!L", self.tx_pwr)) |
| 207 | length = sum([len(x) for x in packed]) |
| 208 | packed[1] = struct.pack("!H", length) |
| 209 | return ''.join(packed) |
| 210 | |
| 211 | @staticmethod |
| 212 | def unpack(reader): |
| 213 | obj = optical() |
| 214 | _type = reader.read("!H")[0] |
| 215 | assert(_type == 1) |
| 216 | _length = reader.read("!H")[0] |
| 217 | orig_reader = reader |
| 218 | reader = orig_reader.slice(_length, 4) |
| 219 | obj.configure = reader.read("!L")[0] |
| 220 | obj.freq_ldma = reader.read("!L")[0] |
| 221 | obj.fl_offset = reader.read("!L")[0] |
| 222 | obj.grid_span = reader.read("!L")[0] |
| 223 | obj.tx_pwr = reader.read("!L")[0] |
| 224 | return obj |
| 225 | |
| 226 | def __eq__(self, other): |
| 227 | if type(self) != type(other): return False |
| 228 | if self.configure != other.configure: return False |
| 229 | if self.freq_ldma != other.freq_ldma: return False |
| 230 | if self.fl_offset != other.fl_offset: return False |
| 231 | if self.grid_span != other.grid_span: return False |
| 232 | if self.tx_pwr != other.tx_pwr: return False |
| 233 | return True |
| 234 | |
| 235 | def pretty_print(self, q): |
| 236 | q.text("optical {") |
| 237 | with q.group(): |
| 238 | with q.indent(2): |
| 239 | q.breakable() |
| 240 | q.text("configure = "); |
| 241 | q.text("%#x" % self.configure) |
| 242 | q.text(","); q.breakable() |
| 243 | q.text("freq_ldma = "); |
| 244 | q.text("%#x" % self.freq_ldma) |
| 245 | q.text(","); q.breakable() |
| 246 | q.text("fl_offset = "); |
| 247 | q.text("%#x" % self.fl_offset) |
| 248 | q.text(","); q.breakable() |
| 249 | q.text("grid_span = "); |
| 250 | q.text("%#x" % self.grid_span) |
| 251 | q.text(","); q.breakable() |
| 252 | q.text("tx_pwr = "); |
| 253 | q.text("%#x" % self.tx_pwr) |
| 254 | q.breakable() |
| 255 | q.text('}') |
| 256 | |
| 257 | port_mod_prop.subtypes[1] = optical |
| 258 | |
| 259 | |