blob: 59ecfc01f752bb29db0d7a5be431ec26f992429a [file] [log] [blame]
Rich Lane2e079da2014-10-29 15:30:24 -07001# 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
9import struct
10import loxi
11import const
12import port_desc_prop
13import meter_band
14import table_mod_prop
15import instruction
16import queue_desc_prop
17import oxm
18import bundle_prop
19import common
20import instruction_id
21import action
22import role_prop
23import message
24import queue_stats_prop
25import port_stats_prop
26import port_mod_prop
27import async_config_prop
28import action_id
29import util
30import loxi.generic_util
31
32class bundle_prop(loxi.OFObject):
33 subtypes = {}
34
35
36 def __init__(self, type=None):
37 if type != None:
38 self.type = type
39 else:
40 self.type = 0
41 return
42
43 def pack(self):
44 packed = []
45 packed.append(struct.pack("!H", self.type))
46 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
47 length = sum([len(x) for x in packed])
48 packed[1] = struct.pack("!H", length)
49 return ''.join(packed)
50
51 @staticmethod
52 def unpack(reader):
53 subtype, = reader.peek('!H', 0)
54 subclass = bundle_prop.subtypes.get(subtype)
55 if subclass:
56 return subclass.unpack(reader)
57
58 obj = bundle_prop()
59 obj.type = reader.read("!H")[0]
60 _length = reader.read("!H")[0]
61 orig_reader = reader
62 reader = orig_reader.slice(_length - (2 + 2))
63 return obj
64
65 def __eq__(self, other):
66 if type(self) != type(other): return False
67 if self.type != other.type: return False
68 return True
69
70 def pretty_print(self, q):
71 q.text("bundle_prop {")
72 with q.group():
73 with q.indent(2):
74 q.breakable()
75 q.breakable()
76 q.text('}')
77
78
79class experimenter(bundle_prop):
80 subtypes = {}
81
82 type = 65535
83
84 def __init__(self, experimenter=None, exp_type=None):
85 if experimenter != None:
86 self.experimenter = experimenter
87 else:
88 self.experimenter = 0
89 if exp_type != None:
90 self.exp_type = exp_type
91 else:
92 self.exp_type = 0
93 return
94
95 def pack(self):
96 packed = []
97 packed.append(struct.pack("!H", self.type))
98 packed.append(struct.pack("!H", 0)) # placeholder for length at index 1
99 packed.append(struct.pack("!L", self.experimenter))
100 packed.append(struct.pack("!L", self.exp_type))
101 length = sum([len(x) for x in packed])
102 packed[1] = struct.pack("!H", length)
103 return ''.join(packed)
104
105 @staticmethod
106 def unpack(reader):
107 subtype, = reader.peek('!L', 4)
108 subclass = experimenter.subtypes.get(subtype)
109 if subclass:
110 return subclass.unpack(reader)
111
112 obj = experimenter()
113 _type = reader.read("!H")[0]
114 assert(_type == 65535)
115 _length = reader.read("!H")[0]
116 orig_reader = reader
117 reader = orig_reader.slice(_length - (2 + 2))
118 obj.experimenter = reader.read("!L")[0]
119 obj.exp_type = reader.read("!L")[0]
120 return obj
121
122 def __eq__(self, other):
123 if type(self) != type(other): return False
124 if self.experimenter != other.experimenter: return False
125 if self.exp_type != other.exp_type: return False
126 return True
127
128 def pretty_print(self, q):
129 q.text("experimenter {")
130 with q.group():
131 with q.indent(2):
132 q.breakable()
133 q.text("exp_type = ");
134 q.text("%#x" % self.exp_type)
135 q.breakable()
136 q.text('}')
137
138bundle_prop.subtypes[65535] = experimenter
139
140