blob: f545bc5d1a2ffbe046d1e724e558e8c80fc1fa73 [file] [log] [blame]
Rich Lane6242d9f2013-01-06 17:35:39 -08001
2# Python OpenFlow error wrapper classes
3
4from cstruct import *
5
6
7
8class hello_failed_error_msg(ofp_error_msg):
9 """
10 Wrapper class for hello_failed error message class
11
12 Data members inherited from ofp_error_msg:
13 @arg type
14 @arg code
15 @arg data: Binary string following message members
16
17 """
18 def __init__(self):
19 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -070020 self.version = OFP_VERSION
21 self.type = OFPT_ERROR
Rich Lane8fbfd662013-03-11 15:30:44 -070022 self.xid = None
Rich Laneb73808c2013-03-11 15:22:23 -070023 self.err_type = OFPET_HELLO_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -080024 self.data = ""
25
26 def pack(self, assertstruct=True):
27 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -070028 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -080029 packed += ofp_error_msg.pack(self)
30 packed += self.data
31 return packed
32
33 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -080034 binary_string = ofp_error_msg.unpack(self, binary_string)
35 self.data = binary_string
36 return ""
37
38 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -070039 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -080040
41 def show(self, prefix=''):
42 outstr = prefix + "hello_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -080043 outstr += ofp_error_msg.show(self, prefix + ' ')
44 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
45 ##@todo Consider trying to parse the string
46 return outstr
47
48 def __eq__(self, other):
49 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -070050 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -080051 self.data == other.data)
52
53 def __ne__(self, other): return not self.__eq__(other)
54
55
56class bad_request_error_msg(ofp_error_msg):
57 """
58 Wrapper class for bad_request error message class
59
60 Data members inherited from ofp_error_msg:
61 @arg type
62 @arg code
63 @arg data: Binary string following message members
64
65 """
66 def __init__(self):
67 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -070068 self.version = OFP_VERSION
69 self.type = OFPT_ERROR
Rich Lane8fbfd662013-03-11 15:30:44 -070070 self.xid = None
Rich Laneb73808c2013-03-11 15:22:23 -070071 self.err_type = OFPET_BAD_REQUEST
Rich Lane6242d9f2013-01-06 17:35:39 -080072 self.data = ""
73
74 def pack(self, assertstruct=True):
75 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -070076 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -080077 packed += ofp_error_msg.pack(self)
78 packed += self.data
79 return packed
80
81 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -080082 binary_string = ofp_error_msg.unpack(self, binary_string)
83 self.data = binary_string
84 return ""
85
86 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -070087 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -080088
89 def show(self, prefix=''):
90 outstr = prefix + "bad_request_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -080091 outstr += ofp_error_msg.show(self, prefix + ' ')
92 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
93 ##@todo Consider trying to parse the string
94 return outstr
95
96 def __eq__(self, other):
97 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -070098 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -080099 self.data == other.data)
100
101 def __ne__(self, other): return not self.__eq__(other)
102
103
104class bad_action_error_msg(ofp_error_msg):
105 """
106 Wrapper class for bad_action error message class
107
108 Data members inherited from ofp_error_msg:
109 @arg type
110 @arg code
111 @arg data: Binary string following message members
112
113 """
114 def __init__(self):
115 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700116 self.version = OFP_VERSION
117 self.type = OFPT_ERROR
Rich Lane8fbfd662013-03-11 15:30:44 -0700118 self.xid = None
Rich Laneb73808c2013-03-11 15:22:23 -0700119 self.err_type = OFPET_BAD_ACTION
Rich Lane6242d9f2013-01-06 17:35:39 -0800120 self.data = ""
121
122 def pack(self, assertstruct=True):
123 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700124 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800125 packed += ofp_error_msg.pack(self)
126 packed += self.data
127 return packed
128
129 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800130 binary_string = ofp_error_msg.unpack(self, binary_string)
131 self.data = binary_string
132 return ""
133
134 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700135 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800136
137 def show(self, prefix=''):
138 outstr = prefix + "bad_action_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800139 outstr += ofp_error_msg.show(self, prefix + ' ')
140 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
141 ##@todo Consider trying to parse the string
142 return outstr
143
144 def __eq__(self, other):
145 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700146 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800147 self.data == other.data)
148
149 def __ne__(self, other): return not self.__eq__(other)
150
151
152class flow_mod_failed_error_msg(ofp_error_msg):
153 """
154 Wrapper class for flow_mod_failed error message class
155
156 Data members inherited from ofp_error_msg:
157 @arg type
158 @arg code
159 @arg data: Binary string following message members
160
161 """
162 def __init__(self):
163 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700164 self.version = OFP_VERSION
165 self.type = OFPT_ERROR
Rich Lane8fbfd662013-03-11 15:30:44 -0700166 self.xid = None
Rich Laneb73808c2013-03-11 15:22:23 -0700167 self.err_type = OFPET_FLOW_MOD_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -0800168 self.data = ""
169
170 def pack(self, assertstruct=True):
171 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700172 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800173 packed += ofp_error_msg.pack(self)
174 packed += self.data
175 return packed
176
177 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800178 binary_string = ofp_error_msg.unpack(self, binary_string)
179 self.data = binary_string
180 return ""
181
182 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700183 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800184
185 def show(self, prefix=''):
186 outstr = prefix + "flow_mod_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800187 outstr += ofp_error_msg.show(self, prefix + ' ')
188 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
189 ##@todo Consider trying to parse the string
190 return outstr
191
192 def __eq__(self, other):
193 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700194 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800195 self.data == other.data)
196
197 def __ne__(self, other): return not self.__eq__(other)
198
199
200class port_mod_failed_error_msg(ofp_error_msg):
201 """
202 Wrapper class for port_mod_failed error message class
203
204 Data members inherited from ofp_error_msg:
205 @arg type
206 @arg code
207 @arg data: Binary string following message members
208
209 """
210 def __init__(self):
211 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700212 self.version = OFP_VERSION
213 self.type = OFPT_ERROR
Rich Lane8fbfd662013-03-11 15:30:44 -0700214 self.xid = None
Rich Laneb73808c2013-03-11 15:22:23 -0700215 self.err_type = OFPET_PORT_MOD_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -0800216 self.data = ""
217
218 def pack(self, assertstruct=True):
219 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700220 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800221 packed += ofp_error_msg.pack(self)
222 packed += self.data
223 return packed
224
225 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800226 binary_string = ofp_error_msg.unpack(self, binary_string)
227 self.data = binary_string
228 return ""
229
230 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700231 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800232
233 def show(self, prefix=''):
234 outstr = prefix + "port_mod_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800235 outstr += ofp_error_msg.show(self, prefix + ' ')
236 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
237 ##@todo Consider trying to parse the string
238 return outstr
239
240 def __eq__(self, other):
241 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700242 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800243 self.data == other.data)
244
245 def __ne__(self, other): return not self.__eq__(other)
246
247
248class queue_op_failed_error_msg(ofp_error_msg):
249 """
250 Wrapper class for queue_op_failed error message class
251
252 Data members inherited from ofp_error_msg:
253 @arg type
254 @arg code
255 @arg data: Binary string following message members
256
257 """
258 def __init__(self):
259 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700260 self.version = OFP_VERSION
261 self.type = OFPT_ERROR
Rich Lane8fbfd662013-03-11 15:30:44 -0700262 self.xid = None
Rich Laneb73808c2013-03-11 15:22:23 -0700263 self.err_type = OFPET_QUEUE_OP_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -0800264 self.data = ""
265
266 def pack(self, assertstruct=True):
267 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700268 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800269 packed += ofp_error_msg.pack(self)
270 packed += self.data
271 return packed
272
273 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800274 binary_string = ofp_error_msg.unpack(self, binary_string)
275 self.data = binary_string
276 return ""
277
278 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700279 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800280
281 def show(self, prefix=''):
282 outstr = prefix + "queue_op_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800283 outstr += ofp_error_msg.show(self, prefix + ' ')
284 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
285 ##@todo Consider trying to parse the string
286 return outstr
287
288 def __eq__(self, other):
289 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700290 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800291 self.data == other.data)
292
293 def __ne__(self, other): return not self.__eq__(other)
294