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