blob: 3ea74f4c2657f559dd6e9fcd04c54ab6751be1e4 [file] [log] [blame]
Rich Lane5ec97b82013-01-06 18:04:25 -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)
20 self.header = ofp_header()
21 self.header.type = OFPT_ERROR
22 self.type = OFPET_HELLO_FAILED
23 self.data = ""
24
25 def pack(self, assertstruct=True):
26 self.header.length = self.__len__()
27 packed = self.header.pack()
28 packed += ofp_error_msg.pack(self)
29 packed += self.data
30 return packed
31
32 def unpack(self, binary_string):
33 binary_string = self.header.unpack(binary_string)
34 binary_string = ofp_error_msg.unpack(self, binary_string)
35 self.data = binary_string
36 return ""
37
38 def __len__(self):
39 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
40
41 def show(self, prefix=''):
42 outstr = prefix + "hello_failed_error_msg\m"
43 outstr += self.header.show(prefix + ' ')
44 outstr += ofp_error_msg.show(self, prefix + ' ')
45 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
46 ##@todo Consider trying to parse the string
47 return outstr
48
49 def __eq__(self, other):
50 if type(self) != type(other): return False
51 return (self.header == other.header and
52 ofp_error_msg.__eq__(self, other) and
53 self.data == other.data)
54
55 def __ne__(self, other): return not self.__eq__(other)
56
57
58class bad_request_error_msg(ofp_error_msg):
59 """
60 Wrapper class for bad_request error message class
61
62 Data members inherited from ofp_error_msg:
63 @arg type
64 @arg code
65 @arg data: Binary string following message members
66
67 """
68 def __init__(self):
69 ofp_error_msg.__init__(self)
70 self.header = ofp_header()
71 self.header.type = OFPT_ERROR
72 self.type = OFPET_BAD_REQUEST
73 self.data = ""
74
75 def pack(self, assertstruct=True):
76 self.header.length = self.__len__()
77 packed = self.header.pack()
78 packed += ofp_error_msg.pack(self)
79 packed += self.data
80 return packed
81
82 def unpack(self, binary_string):
83 binary_string = self.header.unpack(binary_string)
84 binary_string = ofp_error_msg.unpack(self, binary_string)
85 self.data = binary_string
86 return ""
87
88 def __len__(self):
89 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
90
91 def show(self, prefix=''):
92 outstr = prefix + "bad_request_error_msg\m"
93 outstr += self.header.show(prefix + ' ')
94 outstr += ofp_error_msg.show(self, prefix + ' ')
95 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
96 ##@todo Consider trying to parse the string
97 return outstr
98
99 def __eq__(self, other):
100 if type(self) != type(other): return False
101 return (self.header == other.header and
102 ofp_error_msg.__eq__(self, other) and
103 self.data == other.data)
104
105 def __ne__(self, other): return not self.__eq__(other)
106
107
108class bad_action_error_msg(ofp_error_msg):
109 """
110 Wrapper class for bad_action error message class
111
112 Data members inherited from ofp_error_msg:
113 @arg type
114 @arg code
115 @arg data: Binary string following message members
116
117 """
118 def __init__(self):
119 ofp_error_msg.__init__(self)
120 self.header = ofp_header()
121 self.header.type = OFPT_ERROR
122 self.type = OFPET_BAD_ACTION
123 self.data = ""
124
125 def pack(self, assertstruct=True):
126 self.header.length = self.__len__()
127 packed = self.header.pack()
128 packed += ofp_error_msg.pack(self)
129 packed += self.data
130 return packed
131
132 def unpack(self, binary_string):
133 binary_string = self.header.unpack(binary_string)
134 binary_string = ofp_error_msg.unpack(self, binary_string)
135 self.data = binary_string
136 return ""
137
138 def __len__(self):
139 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
140
141 def show(self, prefix=''):
142 outstr = prefix + "bad_action_error_msg\m"
143 outstr += self.header.show(prefix + ' ')
144 outstr += ofp_error_msg.show(self, prefix + ' ')
145 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
146 ##@todo Consider trying to parse the string
147 return outstr
148
149 def __eq__(self, other):
150 if type(self) != type(other): return False
151 return (self.header == other.header and
152 ofp_error_msg.__eq__(self, other) and
153 self.data == other.data)
154
155 def __ne__(self, other): return not self.__eq__(other)
156
157
158class flow_mod_failed_error_msg(ofp_error_msg):
159 """
160 Wrapper class for flow_mod_failed error message class
161
162 Data members inherited from ofp_error_msg:
163 @arg type
164 @arg code
165 @arg data: Binary string following message members
166
167 """
168 def __init__(self):
169 ofp_error_msg.__init__(self)
170 self.header = ofp_header()
171 self.header.type = OFPT_ERROR
172 self.type = OFPET_FLOW_MOD_FAILED
173 self.data = ""
174
175 def pack(self, assertstruct=True):
176 self.header.length = self.__len__()
177 packed = self.header.pack()
178 packed += ofp_error_msg.pack(self)
179 packed += self.data
180 return packed
181
182 def unpack(self, binary_string):
183 binary_string = self.header.unpack(binary_string)
184 binary_string = ofp_error_msg.unpack(self, binary_string)
185 self.data = binary_string
186 return ""
187
188 def __len__(self):
189 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
190
191 def show(self, prefix=''):
192 outstr = prefix + "flow_mod_failed_error_msg\m"
193 outstr += self.header.show(prefix + ' ')
194 outstr += ofp_error_msg.show(self, prefix + ' ')
195 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
196 ##@todo Consider trying to parse the string
197 return outstr
198
199 def __eq__(self, other):
200 if type(self) != type(other): return False
201 return (self.header == other.header and
202 ofp_error_msg.__eq__(self, other) and
203 self.data == other.data)
204
205 def __ne__(self, other): return not self.__eq__(other)
206
207
208class group_mod_failed_error_msg(ofp_error_msg):
209 """
210 Wrapper class for group_mod_failed error message class
211
212 Data members inherited from ofp_error_msg:
213 @arg type
214 @arg code
215 @arg data: Binary string following message members
216
217 """
218 def __init__(self):
219 ofp_error_msg.__init__(self)
220 self.header = ofp_header()
221 self.header.type = OFPT_ERROR
222 self.type = OFPET_GROUP_MOD_FAILED
223 self.data = ""
224
225 def pack(self, assertstruct=True):
226 self.header.length = self.__len__()
227 packed = self.header.pack()
228 packed += ofp_error_msg.pack(self)
229 packed += self.data
230 return packed
231
232 def unpack(self, binary_string):
233 binary_string = self.header.unpack(binary_string)
234 binary_string = ofp_error_msg.unpack(self, binary_string)
235 self.data = binary_string
236 return ""
237
238 def __len__(self):
239 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
240
241 def show(self, prefix=''):
242 outstr = prefix + "group_mod_failed_error_msg\m"
243 outstr += self.header.show(prefix + ' ')
244 outstr += ofp_error_msg.show(self, prefix + ' ')
245 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
246 ##@todo Consider trying to parse the string
247 return outstr
248
249 def __eq__(self, other):
250 if type(self) != type(other): return False
251 return (self.header == other.header and
252 ofp_error_msg.__eq__(self, other) and
253 self.data == other.data)
254
255 def __ne__(self, other): return not self.__eq__(other)
256
257
258class port_mod_failed_error_msg(ofp_error_msg):
259 """
260 Wrapper class for port_mod_failed error message class
261
262 Data members inherited from ofp_error_msg:
263 @arg type
264 @arg code
265 @arg data: Binary string following message members
266
267 """
268 def __init__(self):
269 ofp_error_msg.__init__(self)
270 self.header = ofp_header()
271 self.header.type = OFPT_ERROR
272 self.type = OFPET_PORT_MOD_FAILED
273 self.data = ""
274
275 def pack(self, assertstruct=True):
276 self.header.length = self.__len__()
277 packed = self.header.pack()
278 packed += ofp_error_msg.pack(self)
279 packed += self.data
280 return packed
281
282 def unpack(self, binary_string):
283 binary_string = self.header.unpack(binary_string)
284 binary_string = ofp_error_msg.unpack(self, binary_string)
285 self.data = binary_string
286 return ""
287
288 def __len__(self):
289 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
290
291 def show(self, prefix=''):
292 outstr = prefix + "port_mod_failed_error_msg\m"
293 outstr += self.header.show(prefix + ' ')
294 outstr += ofp_error_msg.show(self, prefix + ' ')
295 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
296 ##@todo Consider trying to parse the string
297 return outstr
298
299 def __eq__(self, other):
300 if type(self) != type(other): return False
301 return (self.header == other.header and
302 ofp_error_msg.__eq__(self, other) and
303 self.data == other.data)
304
305 def __ne__(self, other): return not self.__eq__(other)
306
307
308class table_mod_failed_error_msg(ofp_error_msg):
309 """
310 Wrapper class for table_mod_failed error message class
311
312 Data members inherited from ofp_error_msg:
313 @arg type
314 @arg code
315 @arg data: Binary string following message members
316
317 """
318 def __init__(self):
319 ofp_error_msg.__init__(self)
320 self.header = ofp_header()
321 self.header.type = OFPT_ERROR
322 self.type = OFPET_TABLE_MOD_FAILED
323 self.data = ""
324
325 def pack(self, assertstruct=True):
326 self.header.length = self.__len__()
327 packed = self.header.pack()
328 packed += ofp_error_msg.pack(self)
329 packed += self.data
330 return packed
331
332 def unpack(self, binary_string):
333 binary_string = self.header.unpack(binary_string)
334 binary_string = ofp_error_msg.unpack(self, binary_string)
335 self.data = binary_string
336 return ""
337
338 def __len__(self):
339 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
340
341 def show(self, prefix=''):
342 outstr = prefix + "table_mod_failed_error_msg\m"
343 outstr += self.header.show(prefix + ' ')
344 outstr += ofp_error_msg.show(self, prefix + ' ')
345 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
346 ##@todo Consider trying to parse the string
347 return outstr
348
349 def __eq__(self, other):
350 if type(self) != type(other): return False
351 return (self.header == other.header and
352 ofp_error_msg.__eq__(self, other) and
353 self.data == other.data)
354
355 def __ne__(self, other): return not self.__eq__(other)
356
357
358class queue_op_failed_error_msg(ofp_error_msg):
359 """
360 Wrapper class for queue_op_failed error message class
361
362 Data members inherited from ofp_error_msg:
363 @arg type
364 @arg code
365 @arg data: Binary string following message members
366
367 """
368 def __init__(self):
369 ofp_error_msg.__init__(self)
370 self.header = ofp_header()
371 self.header.type = OFPT_ERROR
372 self.type = OFPET_QUEUE_OP_FAILED
373 self.data = ""
374
375 def pack(self, assertstruct=True):
376 self.header.length = self.__len__()
377 packed = self.header.pack()
378 packed += ofp_error_msg.pack(self)
379 packed += self.data
380 return packed
381
382 def unpack(self, binary_string):
383 binary_string = self.header.unpack(binary_string)
384 binary_string = ofp_error_msg.unpack(self, binary_string)
385 self.data = binary_string
386 return ""
387
388 def __len__(self):
389 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
390
391 def show(self, prefix=''):
392 outstr = prefix + "queue_op_failed_error_msg\m"
393 outstr += self.header.show(prefix + ' ')
394 outstr += ofp_error_msg.show(self, prefix + ' ')
395 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
396 ##@todo Consider trying to parse the string
397 return outstr
398
399 def __eq__(self, other):
400 if type(self) != type(other): return False
401 return (self.header == other.header and
402 ofp_error_msg.__eq__(self, other) and
403 self.data == other.data)
404
405 def __ne__(self, other): return not self.__eq__(other)
406
407
408class switch_config_failed_error_msg(ofp_error_msg):
409 """
410 Wrapper class for switch_config_failed error message class
411
412 Data members inherited from ofp_error_msg:
413 @arg type
414 @arg code
415 @arg data: Binary string following message members
416
417 """
418 def __init__(self):
419 ofp_error_msg.__init__(self)
420 self.header = ofp_header()
421 self.header.type = OFPT_ERROR
422 self.type = OFPET_SWITCH_CONFIG_FAILED
423 self.data = ""
424
425 def pack(self, assertstruct=True):
426 self.header.length = self.__len__()
427 packed = self.header.pack()
428 packed += ofp_error_msg.pack(self)
429 packed += self.data
430 return packed
431
432 def unpack(self, binary_string):
433 binary_string = self.header.unpack(binary_string)
434 binary_string = ofp_error_msg.unpack(self, binary_string)
435 self.data = binary_string
436 return ""
437
438 def __len__(self):
439 return OFP_HEADER_BYTES + OFP_ERROR_MSG_BYTES + len(self.data)
440
441 def show(self, prefix=''):
442 outstr = prefix + "switch_config_failed_error_msg\m"
443 outstr += self.header.show(prefix + ' ')
444 outstr += ofp_error_msg.show(self, prefix + ' ')
445 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
446 ##@todo Consider trying to parse the string
447 return outstr
448
449 def __eq__(self, other):
450 if type(self) != type(other): return False
451 return (self.header == other.header and
452 ofp_error_msg.__eq__(self, other) and
453 self.data == other.data)
454
455 def __ne__(self, other): return not self.__eq__(other)
456