Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame^] | 1 | |
| 2 | # Python OpenFlow action wrapper classes |
| 3 | |
| 4 | from cstruct import * |
| 5 | |
| 6 | |
| 7 | |
| 8 | class vendor(ofp_action_vendor_header): |
| 9 | """ |
| 10 | Wrapper class for vendor action object |
| 11 | |
| 12 | Data members inherited from ofp_action_vendor_header: |
| 13 | @arg type |
| 14 | @arg len |
| 15 | @arg vendor |
| 16 | |
| 17 | """ |
| 18 | def __init__(self, **kwargs): |
| 19 | ofp_action_vendor_header.__init__(self) |
| 20 | self.type = OFPAT_VENDOR |
| 21 | self.len = self.__len__() |
| 22 | for (k, v) in kwargs.items(): |
| 23 | if hasattr(self, k): |
| 24 | setattr(self, k, v) |
| 25 | else: |
| 26 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 27 | def show(self, prefix=''): |
| 28 | outstr = prefix + "action_vendor\n" |
| 29 | outstr += ofp_action_vendor_header.show(self, prefix) |
| 30 | return outstr |
| 31 | |
| 32 | action_vendor = vendor # for backwards compatibility |
| 33 | |
| 34 | |
| 35 | class set_tp_dst(ofp_action_tp_port): |
| 36 | """ |
| 37 | Wrapper class for set_tp_dst action object |
| 38 | |
| 39 | Data members inherited from ofp_action_tp_port: |
| 40 | @arg type |
| 41 | @arg len |
| 42 | @arg tp_port |
| 43 | |
| 44 | """ |
| 45 | def __init__(self, **kwargs): |
| 46 | ofp_action_tp_port.__init__(self) |
| 47 | self.type = OFPAT_SET_TP_DST |
| 48 | self.len = self.__len__() |
| 49 | for (k, v) in kwargs.items(): |
| 50 | if hasattr(self, k): |
| 51 | setattr(self, k, v) |
| 52 | else: |
| 53 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 54 | def show(self, prefix=''): |
| 55 | outstr = prefix + "action_set_tp_dst\n" |
| 56 | outstr += ofp_action_tp_port.show(self, prefix) |
| 57 | return outstr |
| 58 | |
| 59 | action_set_tp_dst = set_tp_dst # for backwards compatibility |
| 60 | |
| 61 | |
| 62 | class set_vlan_pcp(ofp_action_vlan_pcp): |
| 63 | """ |
| 64 | Wrapper class for set_vlan_pcp action object |
| 65 | |
| 66 | Data members inherited from ofp_action_vlan_pcp: |
| 67 | @arg type |
| 68 | @arg len |
| 69 | @arg vlan_pcp |
| 70 | |
| 71 | """ |
| 72 | def __init__(self, **kwargs): |
| 73 | ofp_action_vlan_pcp.__init__(self) |
| 74 | self.type = OFPAT_SET_VLAN_PCP |
| 75 | self.len = self.__len__() |
| 76 | for (k, v) in kwargs.items(): |
| 77 | if hasattr(self, k): |
| 78 | setattr(self, k, v) |
| 79 | else: |
| 80 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 81 | def show(self, prefix=''): |
| 82 | outstr = prefix + "action_set_vlan_pcp\n" |
| 83 | outstr += ofp_action_vlan_pcp.show(self, prefix) |
| 84 | return outstr |
| 85 | |
| 86 | action_set_vlan_pcp = set_vlan_pcp # for backwards compatibility |
| 87 | |
| 88 | |
| 89 | class enqueue(ofp_action_enqueue): |
| 90 | """ |
| 91 | Wrapper class for enqueue action object |
| 92 | |
| 93 | Data members inherited from ofp_action_enqueue: |
| 94 | @arg type |
| 95 | @arg len |
| 96 | @arg port |
| 97 | @arg queue_id |
| 98 | |
| 99 | """ |
| 100 | def __init__(self, **kwargs): |
| 101 | ofp_action_enqueue.__init__(self) |
| 102 | self.type = OFPAT_ENQUEUE |
| 103 | self.len = self.__len__() |
| 104 | for (k, v) in kwargs.items(): |
| 105 | if hasattr(self, k): |
| 106 | setattr(self, k, v) |
| 107 | else: |
| 108 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 109 | def show(self, prefix=''): |
| 110 | outstr = prefix + "action_enqueue\n" |
| 111 | outstr += ofp_action_enqueue.show(self, prefix) |
| 112 | return outstr |
| 113 | |
| 114 | action_enqueue = enqueue # for backwards compatibility |
| 115 | |
| 116 | |
| 117 | class set_tp_src(ofp_action_tp_port): |
| 118 | """ |
| 119 | Wrapper class for set_tp_src action object |
| 120 | |
| 121 | Data members inherited from ofp_action_tp_port: |
| 122 | @arg type |
| 123 | @arg len |
| 124 | @arg tp_port |
| 125 | |
| 126 | """ |
| 127 | def __init__(self, **kwargs): |
| 128 | ofp_action_tp_port.__init__(self) |
| 129 | self.type = OFPAT_SET_TP_SRC |
| 130 | self.len = self.__len__() |
| 131 | for (k, v) in kwargs.items(): |
| 132 | if hasattr(self, k): |
| 133 | setattr(self, k, v) |
| 134 | else: |
| 135 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 136 | def show(self, prefix=''): |
| 137 | outstr = prefix + "action_set_tp_src\n" |
| 138 | outstr += ofp_action_tp_port.show(self, prefix) |
| 139 | return outstr |
| 140 | |
| 141 | action_set_tp_src = set_tp_src # for backwards compatibility |
| 142 | |
| 143 | |
| 144 | class set_nw_tos(ofp_action_nw_tos): |
| 145 | """ |
| 146 | Wrapper class for set_nw_tos action object |
| 147 | |
| 148 | Data members inherited from ofp_action_nw_tos: |
| 149 | @arg type |
| 150 | @arg len |
| 151 | @arg nw_tos |
| 152 | |
| 153 | """ |
| 154 | def __init__(self, **kwargs): |
| 155 | ofp_action_nw_tos.__init__(self) |
| 156 | self.type = OFPAT_SET_NW_TOS |
| 157 | self.len = self.__len__() |
| 158 | for (k, v) in kwargs.items(): |
| 159 | if hasattr(self, k): |
| 160 | setattr(self, k, v) |
| 161 | else: |
| 162 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 163 | def show(self, prefix=''): |
| 164 | outstr = prefix + "action_set_nw_tos\n" |
| 165 | outstr += ofp_action_nw_tos.show(self, prefix) |
| 166 | return outstr |
| 167 | |
| 168 | action_set_nw_tos = set_nw_tos # for backwards compatibility |
| 169 | |
| 170 | |
| 171 | class set_nw_dst(ofp_action_nw_addr): |
| 172 | """ |
| 173 | Wrapper class for set_nw_dst action object |
| 174 | |
| 175 | Data members inherited from ofp_action_nw_addr: |
| 176 | @arg type |
| 177 | @arg len |
| 178 | @arg nw_addr |
| 179 | |
| 180 | """ |
| 181 | def __init__(self, **kwargs): |
| 182 | ofp_action_nw_addr.__init__(self) |
| 183 | self.type = OFPAT_SET_NW_DST |
| 184 | self.len = self.__len__() |
| 185 | for (k, v) in kwargs.items(): |
| 186 | if hasattr(self, k): |
| 187 | setattr(self, k, v) |
| 188 | else: |
| 189 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 190 | def show(self, prefix=''): |
| 191 | outstr = prefix + "action_set_nw_dst\n" |
| 192 | outstr += ofp_action_nw_addr.show(self, prefix) |
| 193 | return outstr |
| 194 | |
| 195 | action_set_nw_dst = set_nw_dst # for backwards compatibility |
| 196 | |
| 197 | |
| 198 | class strip_vlan(ofp_action_header): |
| 199 | """ |
| 200 | Wrapper class for strip_vlan action object |
| 201 | |
| 202 | Data members inherited from ofp_action_header: |
| 203 | @arg type |
| 204 | @arg len |
| 205 | |
| 206 | """ |
| 207 | def __init__(self, **kwargs): |
| 208 | ofp_action_header.__init__(self) |
| 209 | self.type = OFPAT_STRIP_VLAN |
| 210 | self.len = self.__len__() |
| 211 | for (k, v) in kwargs.items(): |
| 212 | if hasattr(self, k): |
| 213 | setattr(self, k, v) |
| 214 | else: |
| 215 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 216 | def show(self, prefix=''): |
| 217 | outstr = prefix + "action_strip_vlan\n" |
| 218 | outstr += ofp_action_header.show(self, prefix) |
| 219 | return outstr |
| 220 | |
| 221 | action_strip_vlan = strip_vlan # for backwards compatibility |
| 222 | |
| 223 | |
| 224 | class set_dl_dst(ofp_action_dl_addr): |
| 225 | """ |
| 226 | Wrapper class for set_dl_dst action object |
| 227 | |
| 228 | Data members inherited from ofp_action_dl_addr: |
| 229 | @arg type |
| 230 | @arg len |
| 231 | @arg dl_addr |
| 232 | |
| 233 | """ |
| 234 | def __init__(self, **kwargs): |
| 235 | ofp_action_dl_addr.__init__(self) |
| 236 | self.type = OFPAT_SET_DL_DST |
| 237 | self.len = self.__len__() |
| 238 | for (k, v) in kwargs.items(): |
| 239 | if hasattr(self, k): |
| 240 | setattr(self, k, v) |
| 241 | else: |
| 242 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 243 | def show(self, prefix=''): |
| 244 | outstr = prefix + "action_set_dl_dst\n" |
| 245 | outstr += ofp_action_dl_addr.show(self, prefix) |
| 246 | return outstr |
| 247 | |
| 248 | action_set_dl_dst = set_dl_dst # for backwards compatibility |
| 249 | |
| 250 | |
| 251 | class set_nw_src(ofp_action_nw_addr): |
| 252 | """ |
| 253 | Wrapper class for set_nw_src action object |
| 254 | |
| 255 | Data members inherited from ofp_action_nw_addr: |
| 256 | @arg type |
| 257 | @arg len |
| 258 | @arg nw_addr |
| 259 | |
| 260 | """ |
| 261 | def __init__(self, **kwargs): |
| 262 | ofp_action_nw_addr.__init__(self) |
| 263 | self.type = OFPAT_SET_NW_SRC |
| 264 | self.len = self.__len__() |
| 265 | for (k, v) in kwargs.items(): |
| 266 | if hasattr(self, k): |
| 267 | setattr(self, k, v) |
| 268 | else: |
| 269 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 270 | def show(self, prefix=''): |
| 271 | outstr = prefix + "action_set_nw_src\n" |
| 272 | outstr += ofp_action_nw_addr.show(self, prefix) |
| 273 | return outstr |
| 274 | |
| 275 | action_set_nw_src = set_nw_src # for backwards compatibility |
| 276 | |
| 277 | |
| 278 | class set_vlan_vid(ofp_action_vlan_vid): |
| 279 | """ |
| 280 | Wrapper class for set_vlan_vid action object |
| 281 | |
| 282 | Data members inherited from ofp_action_vlan_vid: |
| 283 | @arg type |
| 284 | @arg len |
| 285 | @arg vlan_vid |
| 286 | |
| 287 | """ |
| 288 | def __init__(self, **kwargs): |
| 289 | ofp_action_vlan_vid.__init__(self) |
| 290 | self.type = OFPAT_SET_VLAN_VID |
| 291 | self.len = self.__len__() |
| 292 | for (k, v) in kwargs.items(): |
| 293 | if hasattr(self, k): |
| 294 | setattr(self, k, v) |
| 295 | else: |
| 296 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 297 | def show(self, prefix=''): |
| 298 | outstr = prefix + "action_set_vlan_vid\n" |
| 299 | outstr += ofp_action_vlan_vid.show(self, prefix) |
| 300 | return outstr |
| 301 | |
| 302 | action_set_vlan_vid = set_vlan_vid # for backwards compatibility |
| 303 | |
| 304 | |
| 305 | class set_dl_src(ofp_action_dl_addr): |
| 306 | """ |
| 307 | Wrapper class for set_dl_src action object |
| 308 | |
| 309 | Data members inherited from ofp_action_dl_addr: |
| 310 | @arg type |
| 311 | @arg len |
| 312 | @arg dl_addr |
| 313 | |
| 314 | """ |
| 315 | def __init__(self, **kwargs): |
| 316 | ofp_action_dl_addr.__init__(self) |
| 317 | self.type = OFPAT_SET_DL_SRC |
| 318 | self.len = self.__len__() |
| 319 | for (k, v) in kwargs.items(): |
| 320 | if hasattr(self, k): |
| 321 | setattr(self, k, v) |
| 322 | else: |
| 323 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 324 | def show(self, prefix=''): |
| 325 | outstr = prefix + "action_set_dl_src\n" |
| 326 | outstr += ofp_action_dl_addr.show(self, prefix) |
| 327 | return outstr |
| 328 | |
| 329 | action_set_dl_src = set_dl_src # for backwards compatibility |
| 330 | |
| 331 | |
| 332 | class output(ofp_action_output): |
| 333 | """ |
| 334 | Wrapper class for output action object |
| 335 | |
| 336 | Data members inherited from ofp_action_output: |
| 337 | @arg type |
| 338 | @arg len |
| 339 | @arg port |
| 340 | @arg max_len |
| 341 | |
| 342 | """ |
| 343 | def __init__(self, **kwargs): |
| 344 | ofp_action_output.__init__(self) |
| 345 | self.type = OFPAT_OUTPUT |
| 346 | self.len = self.__len__() |
| 347 | for (k, v) in kwargs.items(): |
| 348 | if hasattr(self, k): |
| 349 | setattr(self, k, v) |
| 350 | else: |
| 351 | raise NameError("field %s does not exist in %s" % (k, self.__class__)) |
| 352 | def show(self, prefix=''): |
| 353 | outstr = prefix + "action_output\n" |
| 354 | outstr += ofp_action_output.show(self, prefix) |
| 355 | return outstr |
| 356 | |
| 357 | action_output = output # for backwards compatibility |
| 358 | |
| 359 | action_class_list = ( |
| 360 | action_vendor, |
| 361 | action_set_tp_dst, |
| 362 | action_set_vlan_pcp, |
| 363 | action_enqueue, |
| 364 | action_set_tp_src, |
| 365 | action_set_nw_tos, |
| 366 | action_set_nw_dst, |
| 367 | action_strip_vlan, |
| 368 | action_set_dl_dst, |
| 369 | action_set_nw_src, |
| 370 | action_set_vlan_vid, |
| 371 | action_set_dl_src, |
| 372 | action_output) |