Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 1 | |
| 2 | # Python OpenFlow error wrapper classes |
| 3 | |
| 4 | from cstruct import * |
| 5 | |
| 6 | |
| 7 | |
| 8 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 20 | self.version = OFP_VERSION |
| 21 | self.type = OFPT_ERROR |
Rich Lane | 8fbfd66 | 2013-03-11 15:30:44 -0700 | [diff] [blame] | 22 | self.xid = None |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 23 | self.err_type = OFPET_HELLO_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 24 | self.data = "" |
| 25 | |
| 26 | def pack(self, assertstruct=True): |
| 27 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 28 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 29 | packed += ofp_error_msg.pack(self) |
| 30 | packed += self.data |
| 31 | return packed |
| 32 | |
| 33 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 34 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 35 | self.data = binary_string |
| 36 | return "" |
| 37 | |
| 38 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 39 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 40 | |
| 41 | def show(self, prefix=''): |
| 42 | outstr = prefix + "hello_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 43 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 50 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 51 | self.data == other.data) |
| 52 | |
| 53 | def __ne__(self, other): return not self.__eq__(other) |
| 54 | |
| 55 | |
| 56 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 68 | self.version = OFP_VERSION |
| 69 | self.type = OFPT_ERROR |
Rich Lane | 8fbfd66 | 2013-03-11 15:30:44 -0700 | [diff] [blame] | 70 | self.xid = None |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 71 | self.err_type = OFPET_BAD_REQUEST |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 72 | self.data = "" |
| 73 | |
| 74 | def pack(self, assertstruct=True): |
| 75 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 76 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 77 | packed += ofp_error_msg.pack(self) |
| 78 | packed += self.data |
| 79 | return packed |
| 80 | |
| 81 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 82 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 83 | self.data = binary_string |
| 84 | return "" |
| 85 | |
| 86 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 87 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 88 | |
| 89 | def show(self, prefix=''): |
| 90 | outstr = prefix + "bad_request_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 91 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 98 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 99 | self.data == other.data) |
| 100 | |
| 101 | def __ne__(self, other): return not self.__eq__(other) |
| 102 | |
| 103 | |
| 104 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 116 | self.version = OFP_VERSION |
| 117 | self.type = OFPT_ERROR |
Rich Lane | 8fbfd66 | 2013-03-11 15:30:44 -0700 | [diff] [blame] | 118 | self.xid = None |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 119 | self.err_type = OFPET_BAD_ACTION |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 120 | self.data = "" |
| 121 | |
| 122 | def pack(self, assertstruct=True): |
| 123 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 124 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 125 | packed += ofp_error_msg.pack(self) |
| 126 | packed += self.data |
| 127 | return packed |
| 128 | |
| 129 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 130 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 131 | self.data = binary_string |
| 132 | return "" |
| 133 | |
| 134 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 135 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 136 | |
| 137 | def show(self, prefix=''): |
| 138 | outstr = prefix + "bad_action_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 139 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 146 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 147 | self.data == other.data) |
| 148 | |
| 149 | def __ne__(self, other): return not self.__eq__(other) |
| 150 | |
| 151 | |
| 152 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 164 | self.version = OFP_VERSION |
| 165 | self.type = OFPT_ERROR |
Rich Lane | 8fbfd66 | 2013-03-11 15:30:44 -0700 | [diff] [blame] | 166 | self.xid = None |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 167 | self.err_type = OFPET_FLOW_MOD_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 168 | self.data = "" |
| 169 | |
| 170 | def pack(self, assertstruct=True): |
| 171 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 172 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 173 | packed += ofp_error_msg.pack(self) |
| 174 | packed += self.data |
| 175 | return packed |
| 176 | |
| 177 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 178 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 179 | self.data = binary_string |
| 180 | return "" |
| 181 | |
| 182 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 183 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 184 | |
| 185 | def show(self, prefix=''): |
| 186 | outstr = prefix + "flow_mod_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 187 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 194 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 195 | self.data == other.data) |
| 196 | |
| 197 | def __ne__(self, other): return not self.__eq__(other) |
| 198 | |
| 199 | |
| 200 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 212 | self.version = OFP_VERSION |
| 213 | self.type = OFPT_ERROR |
Rich Lane | 8fbfd66 | 2013-03-11 15:30:44 -0700 | [diff] [blame] | 214 | self.xid = None |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 215 | self.err_type = OFPET_PORT_MOD_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 216 | self.data = "" |
| 217 | |
| 218 | def pack(self, assertstruct=True): |
| 219 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 220 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 221 | packed += ofp_error_msg.pack(self) |
| 222 | packed += self.data |
| 223 | return packed |
| 224 | |
| 225 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 226 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 227 | self.data = binary_string |
| 228 | return "" |
| 229 | |
| 230 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 231 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 232 | |
| 233 | def show(self, prefix=''): |
| 234 | outstr = prefix + "port_mod_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 235 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 242 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 243 | self.data == other.data) |
| 244 | |
| 245 | def __ne__(self, other): return not self.__eq__(other) |
| 246 | |
| 247 | |
| 248 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 260 | self.version = OFP_VERSION |
| 261 | self.type = OFPT_ERROR |
Rich Lane | 8fbfd66 | 2013-03-11 15:30:44 -0700 | [diff] [blame] | 262 | self.xid = None |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 263 | self.err_type = OFPET_QUEUE_OP_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 264 | self.data = "" |
| 265 | |
| 266 | def pack(self, assertstruct=True): |
| 267 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 268 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 269 | packed += ofp_error_msg.pack(self) |
| 270 | packed += self.data |
| 271 | return packed |
| 272 | |
| 273 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 274 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 275 | self.data = binary_string |
| 276 | return "" |
| 277 | |
| 278 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 279 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 280 | |
| 281 | def show(self, prefix=''): |
| 282 | outstr = prefix + "queue_op_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 283 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 290 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 291 | self.data == other.data) |
| 292 | |
| 293 | def __ne__(self, other): return not self.__eq__(other) |
| 294 | |