blob: 700338bbda861ca09c7da67e461eaf127eb912e1 [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
22 self.err_type = OFPET_HELLO_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -080023 self.data = ""
24
25 def pack(self, assertstruct=True):
26 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -070027 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -080028 packed += ofp_error_msg.pack(self)
29 packed += self.data
30 return packed
31
32 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -080033 binary_string = ofp_error_msg.unpack(self, binary_string)
34 self.data = binary_string
35 return ""
36
37 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -070038 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -080039
40 def show(self, prefix=''):
41 outstr = prefix + "hello_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -080042 outstr += ofp_error_msg.show(self, prefix + ' ')
43 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
44 ##@todo Consider trying to parse the string
45 return outstr
46
47 def __eq__(self, other):
48 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -070049 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -080050 self.data == other.data)
51
52 def __ne__(self, other): return not self.__eq__(other)
53
54
55class bad_request_error_msg(ofp_error_msg):
56 """
57 Wrapper class for bad_request error message class
58
59 Data members inherited from ofp_error_msg:
60 @arg type
61 @arg code
62 @arg data: Binary string following message members
63
64 """
65 def __init__(self):
66 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -070067 self.version = OFP_VERSION
68 self.type = OFPT_ERROR
69 self.err_type = OFPET_BAD_REQUEST
Rich Lane6242d9f2013-01-06 17:35:39 -080070 self.data = ""
71
72 def pack(self, assertstruct=True):
73 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -070074 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -080075 packed += ofp_error_msg.pack(self)
76 packed += self.data
77 return packed
78
79 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -080080 binary_string = ofp_error_msg.unpack(self, binary_string)
81 self.data = binary_string
82 return ""
83
84 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -070085 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -080086
87 def show(self, prefix=''):
88 outstr = prefix + "bad_request_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -080089 outstr += ofp_error_msg.show(self, prefix + ' ')
90 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
91 ##@todo Consider trying to parse the string
92 return outstr
93
94 def __eq__(self, other):
95 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -070096 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -080097 self.data == other.data)
98
99 def __ne__(self, other): return not self.__eq__(other)
100
101
102class bad_action_error_msg(ofp_error_msg):
103 """
104 Wrapper class for bad_action error message class
105
106 Data members inherited from ofp_error_msg:
107 @arg type
108 @arg code
109 @arg data: Binary string following message members
110
111 """
112 def __init__(self):
113 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700114 self.version = OFP_VERSION
115 self.type = OFPT_ERROR
116 self.err_type = OFPET_BAD_ACTION
Rich Lane6242d9f2013-01-06 17:35:39 -0800117 self.data = ""
118
119 def pack(self, assertstruct=True):
120 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700121 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800122 packed += ofp_error_msg.pack(self)
123 packed += self.data
124 return packed
125
126 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800127 binary_string = ofp_error_msg.unpack(self, binary_string)
128 self.data = binary_string
129 return ""
130
131 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700132 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800133
134 def show(self, prefix=''):
135 outstr = prefix + "bad_action_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800136 outstr += ofp_error_msg.show(self, prefix + ' ')
137 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
138 ##@todo Consider trying to parse the string
139 return outstr
140
141 def __eq__(self, other):
142 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700143 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800144 self.data == other.data)
145
146 def __ne__(self, other): return not self.__eq__(other)
147
148
149class flow_mod_failed_error_msg(ofp_error_msg):
150 """
151 Wrapper class for flow_mod_failed error message class
152
153 Data members inherited from ofp_error_msg:
154 @arg type
155 @arg code
156 @arg data: Binary string following message members
157
158 """
159 def __init__(self):
160 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700161 self.version = OFP_VERSION
162 self.type = OFPT_ERROR
163 self.err_type = OFPET_FLOW_MOD_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -0800164 self.data = ""
165
166 def pack(self, assertstruct=True):
167 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700168 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800169 packed += ofp_error_msg.pack(self)
170 packed += self.data
171 return packed
172
173 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800174 binary_string = ofp_error_msg.unpack(self, binary_string)
175 self.data = binary_string
176 return ""
177
178 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700179 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800180
181 def show(self, prefix=''):
182 outstr = prefix + "flow_mod_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800183 outstr += ofp_error_msg.show(self, prefix + ' ')
184 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
185 ##@todo Consider trying to parse the string
186 return outstr
187
188 def __eq__(self, other):
189 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700190 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800191 self.data == other.data)
192
193 def __ne__(self, other): return not self.__eq__(other)
194
195
196class port_mod_failed_error_msg(ofp_error_msg):
197 """
198 Wrapper class for port_mod_failed error message class
199
200 Data members inherited from ofp_error_msg:
201 @arg type
202 @arg code
203 @arg data: Binary string following message members
204
205 """
206 def __init__(self):
207 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700208 self.version = OFP_VERSION
209 self.type = OFPT_ERROR
210 self.err_type = OFPET_PORT_MOD_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -0800211 self.data = ""
212
213 def pack(self, assertstruct=True):
214 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700215 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800216 packed += ofp_error_msg.pack(self)
217 packed += self.data
218 return packed
219
220 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800221 binary_string = ofp_error_msg.unpack(self, binary_string)
222 self.data = binary_string
223 return ""
224
225 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700226 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800227
228 def show(self, prefix=''):
229 outstr = prefix + "port_mod_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800230 outstr += ofp_error_msg.show(self, prefix + ' ')
231 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
232 ##@todo Consider trying to parse the string
233 return outstr
234
235 def __eq__(self, other):
236 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700237 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800238 self.data == other.data)
239
240 def __ne__(self, other): return not self.__eq__(other)
241
242
243class queue_op_failed_error_msg(ofp_error_msg):
244 """
245 Wrapper class for queue_op_failed error message class
246
247 Data members inherited from ofp_error_msg:
248 @arg type
249 @arg code
250 @arg data: Binary string following message members
251
252 """
253 def __init__(self):
254 ofp_error_msg.__init__(self)
Rich Laneb73808c2013-03-11 15:22:23 -0700255 self.version = OFP_VERSION
256 self.type = OFPT_ERROR
257 self.err_type = OFPET_QUEUE_OP_FAILED
Rich Lane6242d9f2013-01-06 17:35:39 -0800258 self.data = ""
259
260 def pack(self, assertstruct=True):
261 self.header.length = self.__len__()
Rich Laneb73808c2013-03-11 15:22:23 -0700262 packed = ""
Rich Lane6242d9f2013-01-06 17:35:39 -0800263 packed += ofp_error_msg.pack(self)
264 packed += self.data
265 return packed
266
267 def unpack(self, binary_string):
Rich Lane6242d9f2013-01-06 17:35:39 -0800268 binary_string = ofp_error_msg.unpack(self, binary_string)
269 self.data = binary_string
270 return ""
271
272 def __len__(self):
Rich Laneb73808c2013-03-11 15:22:23 -0700273 return OFP_ERROR_MSG_BYTES + len(self.data)
Rich Lane6242d9f2013-01-06 17:35:39 -0800274
275 def show(self, prefix=''):
276 outstr = prefix + "queue_op_failed_error_msg\m"
Rich Lane6242d9f2013-01-06 17:35:39 -0800277 outstr += ofp_error_msg.show(self, prefix + ' ')
278 outstr += prefix + "data is of length " + str(len(self.data)) + '\n'
279 ##@todo Consider trying to parse the string
280 return outstr
281
282 def __eq__(self, other):
283 if type(self) != type(other): return False
Rich Laneb73808c2013-03-11 15:22:23 -0700284 return (ofp_error_msg.__eq__(self, other) and
Rich Lane6242d9f2013-01-06 17:35:39 -0800285 self.data == other.data)
286
287 def __ne__(self, other): return not self.__eq__(other)
288