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) |
| 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 | |
| 58 | class 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 | |
| 108 | class 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 | |
| 158 | class 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 | |
| 208 | class port_mod_failed_error_msg(ofp_error_msg): |
| 209 | """ |
| 210 | Wrapper class for port_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_PORT_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 + "port_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 | |
| 258 | class queue_op_failed_error_msg(ofp_error_msg): |
| 259 | """ |
| 260 | Wrapper class for queue_op_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_QUEUE_OP_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 + "queue_op_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 | |