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 |
| 22 | self.err_type = OFPET_HELLO_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 23 | self.data = "" |
| 24 | |
| 25 | def pack(self, assertstruct=True): |
| 26 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 27 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 28 | packed += ofp_error_msg.pack(self) |
| 29 | packed += self.data |
| 30 | return packed |
| 31 | |
| 32 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 33 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 34 | self.data = binary_string |
| 35 | return "" |
| 36 | |
| 37 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 38 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 39 | |
| 40 | def show(self, prefix=''): |
| 41 | outstr = prefix + "hello_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 42 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 49 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 50 | self.data == other.data) |
| 51 | |
| 52 | def __ne__(self, other): return not self.__eq__(other) |
| 53 | |
| 54 | |
| 55 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 67 | self.version = OFP_VERSION |
| 68 | self.type = OFPT_ERROR |
| 69 | self.err_type = OFPET_BAD_REQUEST |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 70 | self.data = "" |
| 71 | |
| 72 | def pack(self, assertstruct=True): |
| 73 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 74 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 75 | packed += ofp_error_msg.pack(self) |
| 76 | packed += self.data |
| 77 | return packed |
| 78 | |
| 79 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 80 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 81 | self.data = binary_string |
| 82 | return "" |
| 83 | |
| 84 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 85 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 86 | |
| 87 | def show(self, prefix=''): |
| 88 | outstr = prefix + "bad_request_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 89 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 96 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 97 | self.data == other.data) |
| 98 | |
| 99 | def __ne__(self, other): return not self.__eq__(other) |
| 100 | |
| 101 | |
| 102 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 114 | self.version = OFP_VERSION |
| 115 | self.type = OFPT_ERROR |
| 116 | self.err_type = OFPET_BAD_ACTION |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 117 | self.data = "" |
| 118 | |
| 119 | def pack(self, assertstruct=True): |
| 120 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 121 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 122 | packed += ofp_error_msg.pack(self) |
| 123 | packed += self.data |
| 124 | return packed |
| 125 | |
| 126 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 127 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 128 | self.data = binary_string |
| 129 | return "" |
| 130 | |
| 131 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 132 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 133 | |
| 134 | def show(self, prefix=''): |
| 135 | outstr = prefix + "bad_action_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 136 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 143 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 144 | self.data == other.data) |
| 145 | |
| 146 | def __ne__(self, other): return not self.__eq__(other) |
| 147 | |
| 148 | |
| 149 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 161 | self.version = OFP_VERSION |
| 162 | self.type = OFPT_ERROR |
| 163 | self.err_type = OFPET_FLOW_MOD_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 164 | self.data = "" |
| 165 | |
| 166 | def pack(self, assertstruct=True): |
| 167 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 168 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 169 | packed += ofp_error_msg.pack(self) |
| 170 | packed += self.data |
| 171 | return packed |
| 172 | |
| 173 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 174 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 175 | self.data = binary_string |
| 176 | return "" |
| 177 | |
| 178 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 179 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 180 | |
| 181 | def show(self, prefix=''): |
| 182 | outstr = prefix + "flow_mod_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 183 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 190 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 191 | self.data == other.data) |
| 192 | |
| 193 | def __ne__(self, other): return not self.__eq__(other) |
| 194 | |
| 195 | |
| 196 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 208 | self.version = OFP_VERSION |
| 209 | self.type = OFPT_ERROR |
| 210 | self.err_type = OFPET_PORT_MOD_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 211 | self.data = "" |
| 212 | |
| 213 | def pack(self, assertstruct=True): |
| 214 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 215 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 216 | packed += ofp_error_msg.pack(self) |
| 217 | packed += self.data |
| 218 | return packed |
| 219 | |
| 220 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 221 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 222 | self.data = binary_string |
| 223 | return "" |
| 224 | |
| 225 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 226 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 227 | |
| 228 | def show(self, prefix=''): |
| 229 | outstr = prefix + "port_mod_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 230 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 237 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 238 | self.data == other.data) |
| 239 | |
| 240 | def __ne__(self, other): return not self.__eq__(other) |
| 241 | |
| 242 | |
| 243 | class 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 255 | self.version = OFP_VERSION |
| 256 | self.type = OFPT_ERROR |
| 257 | self.err_type = OFPET_QUEUE_OP_FAILED |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 258 | self.data = "" |
| 259 | |
| 260 | def pack(self, assertstruct=True): |
| 261 | self.header.length = self.__len__() |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 262 | packed = "" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 263 | packed += ofp_error_msg.pack(self) |
| 264 | packed += self.data |
| 265 | return packed |
| 266 | |
| 267 | def unpack(self, binary_string): |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 268 | binary_string = ofp_error_msg.unpack(self, binary_string) |
| 269 | self.data = binary_string |
| 270 | return "" |
| 271 | |
| 272 | def __len__(self): |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 273 | return OFP_ERROR_MSG_BYTES + len(self.data) |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 274 | |
| 275 | def show(self, prefix=''): |
| 276 | outstr = prefix + "queue_op_failed_error_msg\m" |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 277 | 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 Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame^] | 284 | return (ofp_error_msg.__eq__(self, other) and |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 285 | self.data == other.data) |
| 286 | |
| 287 | def __ne__(self, other): return not self.__eq__(other) |
| 288 | |