Stephane Barbarie | 6e1bd50 | 2018-11-05 22:44:45 -0500 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 15 | # Copyright (c) 2011, 2012 Open Networking Foundation |
| 16 | # Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 17 | # See the file LICENSE.pyloxi which should have been included in the source distribution |
| 18 | |
| 19 | # Automatically generated by LOXI from template module.py |
| 20 | # Do not modify |
| 21 | |
| 22 | import struct |
| 23 | import loxi |
| 24 | import util |
| 25 | import loxi.generic_util |
| 26 | |
| 27 | import sys |
| 28 | ofp = sys.modules['loxi.of14'] |
| 29 | |
| 30 | class bundle_prop(loxi.OFObject): |
| 31 | subtypes = {} |
| 32 | |
| 33 | |
| 34 | def __init__(self, type=None): |
| 35 | if type != None: |
| 36 | self.type = type |
| 37 | else: |
| 38 | self.type = 0 |
| 39 | return |
| 40 | |
| 41 | def pack(self): |
| 42 | packed = [] |
| 43 | packed.append(struct.pack("!H", self.type)) |
| 44 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 45 | length = sum([len(x) for x in packed]) |
| 46 | packed[1] = struct.pack("!H", length) |
| 47 | return ''.join(packed) |
| 48 | |
| 49 | @staticmethod |
| 50 | def unpack(reader): |
| 51 | subtype, = reader.peek('!H', 0) |
| 52 | subclass = bundle_prop.subtypes.get(subtype) |
| 53 | if subclass: |
| 54 | return subclass.unpack(reader) |
| 55 | |
| 56 | obj = bundle_prop() |
| 57 | obj.type = reader.read("!H")[0] |
| 58 | _length = reader.read("!H")[0] |
| 59 | orig_reader = reader |
| 60 | reader = orig_reader.slice(_length, 4) |
| 61 | return obj |
| 62 | |
| 63 | def __eq__(self, other): |
| 64 | if type(self) != type(other): return False |
| 65 | if self.type != other.type: return False |
| 66 | return True |
| 67 | |
| 68 | def pretty_print(self, q): |
| 69 | q.text("bundle_prop {") |
| 70 | with q.group(): |
| 71 | with q.indent(2): |
| 72 | q.breakable() |
| 73 | q.breakable() |
| 74 | q.text('}') |
| 75 | |
| 76 | |
| 77 | class experimenter(bundle_prop): |
| 78 | subtypes = {} |
| 79 | |
| 80 | type = 65535 |
| 81 | |
| 82 | def __init__(self, experimenter=None, exp_type=None): |
| 83 | if experimenter != None: |
| 84 | self.experimenter = experimenter |
| 85 | else: |
| 86 | self.experimenter = 0 |
| 87 | if exp_type != None: |
| 88 | self.exp_type = exp_type |
| 89 | else: |
| 90 | self.exp_type = 0 |
| 91 | return |
| 92 | |
| 93 | def pack(self): |
| 94 | packed = [] |
| 95 | packed.append(struct.pack("!H", self.type)) |
| 96 | packed.append(struct.pack("!H", 0)) # placeholder for length at index 1 |
| 97 | packed.append(struct.pack("!L", self.experimenter)) |
| 98 | packed.append(struct.pack("!L", self.exp_type)) |
| 99 | length = sum([len(x) for x in packed]) |
| 100 | packed[1] = struct.pack("!H", length) |
| 101 | return ''.join(packed) |
| 102 | |
| 103 | @staticmethod |
| 104 | def unpack(reader): |
| 105 | subtype, = reader.peek('!L', 4) |
| 106 | subclass = experimenter.subtypes.get(subtype) |
| 107 | if subclass: |
| 108 | return subclass.unpack(reader) |
| 109 | |
| 110 | obj = experimenter() |
| 111 | _type = reader.read("!H")[0] |
| 112 | assert(_type == 65535) |
| 113 | _length = reader.read("!H")[0] |
| 114 | orig_reader = reader |
| 115 | reader = orig_reader.slice(_length, 4) |
| 116 | obj.experimenter = reader.read("!L")[0] |
| 117 | obj.exp_type = reader.read("!L")[0] |
| 118 | return obj |
| 119 | |
| 120 | def __eq__(self, other): |
| 121 | if type(self) != type(other): return False |
| 122 | if self.experimenter != other.experimenter: return False |
| 123 | if self.exp_type != other.exp_type: return False |
| 124 | return True |
| 125 | |
| 126 | def pretty_print(self, q): |
| 127 | q.text("experimenter {") |
| 128 | with q.group(): |
| 129 | with q.indent(2): |
| 130 | q.breakable() |
| 131 | q.text("exp_type = "); |
| 132 | q.text("%#x" % self.exp_type) |
| 133 | q.breakable() |
| 134 | q.text('}') |
| 135 | |
| 136 | bundle_prop.subtypes[65535] = experimenter |
| 137 | |
| 138 | |