Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 1 | |
| 2 | # Python OpenFlow instruction wrapper classes |
| 3 | |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 4 | import struct |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 5 | import ipaddr |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 6 | import socket |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 7 | from cstruct import * |
| 8 | |
| 9 | |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 10 | class oxm_tlv(object): |
| 11 | def __init__(self, field, hasmask, length, value, mask=None, |
| 12 | class_ = 0x8000): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 13 | self.class_ = class_ |
| 14 | self.field = field |
| 15 | self.hasmask = hasmask |
| 16 | self.length = length |
| 17 | self.value = value |
| 18 | self.mask = mask |
| 19 | |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 20 | def __eq__(self, other): |
| 21 | return (self.class_ == other.class_ and self.field == other.field |
| 22 | and self.hasmask == other.hasmask and |
| 23 | self.length == other.length and self.value == other.value and |
| 24 | self.mask == self.mask) |
| 25 | |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 26 | def pack(self, assertstruct=True): |
| 27 | |
| 28 | packed = "" |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 29 | packed += struct.pack("!I", ((self.class_ << 16) | (self.field << 9) | |
| 30 | (self.hasmask << 8) | self.length)) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 31 | if self.length == 1: |
| 32 | packed += struct.pack("B", self.value) |
| 33 | if self.hasmask: |
| 34 | packed += struct.pack("B", self.mask) |
| 35 | elif self.length == 2 or (self.length == 4 and self.hasmask == True): |
| 36 | packed += struct.pack("!H", self.value) |
| 37 | if self.hasmask: |
| 38 | packed += struct.pack("!H", self.mask) |
| 39 | elif self.length == 4 or (self.length == 8 and self.hasmask == True): |
| 40 | packed += struct.pack("!I", self.value) |
| 41 | if self.hasmask: |
| 42 | packed += struct.pack("!I", self.mask) |
| 43 | elif self.length == 6 or self.length == 12: |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 44 | packed += struct.pack("!BBBBBB", self.value[0],self.value[1], |
| 45 | self.value[2],self.value[3],self.value[4],self.value[5]) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 46 | if self.hasmask: |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 47 | packed += struct.pack("!BBBBBB", self.mask[0],self.mask[1], |
| 48 | self.mask[2],self.mask[3],self.mask[4],self.mask[5]) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 49 | elif self.length == 8 or (self.length == 16 and self.hasmask == True): |
| 50 | packed += struct.pack("!Q", self.value) |
| 51 | if self.hasmask: |
| 52 | packed += struct.pack("!Q", self.mask) |
| 53 | elif self.length == 16 or self.length == 32: |
| 54 | packed += self.value.packed |
| 55 | if self.hasmask: |
| 56 | packed += self.mask.packed |
| 57 | return packed |
| 58 | |
| 59 | def __len__(self): |
| 60 | return self.length + 4 |
| 61 | |
| 62 | def show(self, prefix=''): |
| 63 | return "\n".join( |
| 64 | # ("oxm_tlv_class=" + hex(self.class_), |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 65 | (prefix + "oxm_tlv_class=" + hex(self.class_), |
| 66 | prefix + "oxm_tlv_field=" + str(self.field), |
| 67 | prefix +"oxm_tlv_hasmask=" + str(bool(self.hasmask)), |
| 68 | prefix +"oxm_tlv_length: " + str(self.length) + "\n",)) |
| 69 | |
| 70 | |
| 71 | subclasses = {} |
| 72 | |
| 73 | def set_value(self, value): |
| 74 | self.value = value |
| 75 | |
| 76 | def set_hasmask(self, hasmask): |
| 77 | self.hasmask = hasmask |
| 78 | |
| 79 | def set_mask(self, mask): |
| 80 | self.mask = mask |
| 81 | |
| 82 | @staticmethod |
| 83 | def factory(): |
| 84 | for subclass in oxm_tlv.__subclasses__(): |
| 85 | obj = subclass() |
| 86 | oxm_tlv.subclasses[obj.field] = subclass |
| 87 | |
| 88 | @staticmethod |
| 89 | def create(field): |
| 90 | return oxm_tlv.subclasses[field]() |
| 91 | |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 92 | |
| 93 | |
| 94 | def roundup (x,y): |
| 95 | return (((x) + ((y) - 1)) / (y) * (y)) |
| 96 | |
| 97 | class in_port(oxm_tlv): |
| 98 | """ |
| 99 | Wrapper class for in_port match object |
| 100 | |
| 101 | Data members inherited from oxm_tlv: |
| 102 | @arg class |
| 103 | @arg field |
| 104 | @arg hasmask |
| 105 | @arg body |
| 106 | |
| 107 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 108 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 109 | oxm_tlv.__init__(self, OFPXMT_OFB_IN_PORT , hasmask, 4, value) |
| 110 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 111 | outstr = prefix + "name = in_port\n" |
| 112 | outstr += oxm_tlv.show(self, prefix) |
| 113 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 114 | return outstr |
| 115 | |
| 116 | |
| 117 | class in_phy_port(oxm_tlv): |
| 118 | """ |
| 119 | Wrapper class for in_phy_port match object |
| 120 | |
| 121 | Data members inherited from oxm_tlv: |
| 122 | @arg class |
| 123 | @arg field |
| 124 | @arg hasmask |
| 125 | @arg body |
| 126 | |
| 127 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 128 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 129 | oxm_tlv.__init__(self,OFPXMT_OFB_IN_PHY_PORT, hasmask, 4, value) |
| 130 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 131 | outstr = prefix + "name = in_phy_port\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 132 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 133 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 134 | return outstr |
| 135 | |
| 136 | |
| 137 | class metadata(oxm_tlv): |
| 138 | """ |
| 139 | Wrapper class for metadata match object |
| 140 | |
| 141 | Data members inherited from oxm_tlv: |
| 142 | @arg class |
| 143 | @arg field |
| 144 | @arg hasmask |
| 145 | @arg body |
| 146 | |
| 147 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 148 | def __init__(self, value=None, mask =None): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 149 | if mask == None: |
| 150 | oxm_tlv.__init__(self, OFPXMT_OFB_METADATA, False, 8, value) |
| 151 | else: |
| 152 | oxm_tlv.__init__(self, OFPXMT_OFB_METADATA, True, 16, value, mask) |
| 153 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 154 | outstr = prefix + "name = metadata\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 155 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 156 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 157 | return outstr |
| 158 | |
| 159 | class eth_dst(oxm_tlv): |
| 160 | """ |
| 161 | Wrapper class for eth_dst match object |
| 162 | |
| 163 | Data members inherited from oxm_tlv: |
| 164 | @arg class |
| 165 | @arg field |
| 166 | @arg hasmask |
| 167 | @arg body |
| 168 | |
| 169 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 170 | def __init__(self, value=None, mask=None): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 171 | if mask == None: |
| 172 | oxm_tlv.__init__(self, OFPXMT_OFB_ETH_DST, False, 6, value) |
| 173 | else: |
| 174 | oxm_tlv.__init__(self, OFPXMT_OFB_ETH_DST, True, 12, value, mask) |
| 175 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 176 | outstr = prefix + "name = eth_dst\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 177 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 178 | outstr += prefix + "value = " + ":".join(["%.2x" %x |
| 179 | for x in self.value]) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 180 | return outstr |
| 181 | |
| 182 | class eth_src(oxm_tlv): |
| 183 | """ |
| 184 | Wrapper class for eth_src match object |
| 185 | |
| 186 | Data members inherited from oxm_tlv: |
| 187 | @arg class |
| 188 | @arg field |
| 189 | @arg hasmask |
| 190 | @arg body |
| 191 | |
| 192 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 193 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 194 | if not hasmask: |
| 195 | oxm_tlv.__init__(self, OFPXMT_OFB_ETH_SRC, hasmask, 6, value) |
| 196 | else: |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 197 | oxm_tlv.__init__(self, OFPXMT_OFB_ETH_SRC, hasmask, 12, |
| 198 | value, mask) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 199 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 200 | outstr = prefix + "name = eth_src\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 201 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 202 | outstr += prefix + "value = " + ":".join(["%.2x" %x |
| 203 | for x in self.value]) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 204 | return outstr |
| 205 | |
| 206 | class eth_type(oxm_tlv): |
| 207 | """ |
| 208 | Wrapper class for eth_type match object |
| 209 | |
| 210 | Data members inherited from oxm_tlv: |
| 211 | @arg class |
| 212 | @arg field |
| 213 | @arg hasmask |
| 214 | @arg body |
| 215 | |
| 216 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 217 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 218 | oxm_tlv.__init__(self, OFPXMT_OFB_ETH_TYPE, hasmask, 2, value) |
| 219 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 220 | outstr = prefix + "name = eth_type\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 221 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 222 | outstr += prefix + "value = " + hex(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 223 | return outstr |
| 224 | |
| 225 | class vlan_vid(oxm_tlv): |
| 226 | """ |
| 227 | Wrapper class for vlan_vid match object |
| 228 | |
| 229 | Data members inherited from oxm_tlv: |
| 230 | @arg class |
| 231 | @arg field |
| 232 | @arg hasmask |
| 233 | @arg body |
| 234 | |
| 235 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 236 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 237 | oxm_tlv.__init__(self, OFPXMT_OFB_VLAN_VID, hasmask, 2, value) |
| 238 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 239 | outstr = prefix + "name = vlan_vid\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 240 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 241 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 242 | return outstr |
| 243 | |
| 244 | class vlan_pcp(oxm_tlv): |
| 245 | """ |
| 246 | Wrapper class for vlan_pcp match object |
| 247 | |
| 248 | Data members inherited from oxm_tlv: |
| 249 | @arg class |
| 250 | @arg field |
| 251 | @arg hasmask |
| 252 | @arg body |
| 253 | |
| 254 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 255 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 256 | oxm_tlv.__init__(self, OFPXMT_OFB_VLAN_PCP, hasmask, 1, value) |
| 257 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 258 | outstr = prefix + "name = vlan_pcp\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 259 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 260 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 261 | return outstr |
| 262 | |
| 263 | class ip_dscp(oxm_tlv): |
| 264 | """ |
| 265 | Wrapper class for ip_dscp match object |
| 266 | |
| 267 | Data members inherited from oxm_tlv: |
| 268 | @arg class |
| 269 | @arg field |
| 270 | @arg hasmask |
| 271 | @arg body |
| 272 | |
| 273 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 274 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 275 | oxm_tlv.__init__(self, OFPXMT_OFB_IP_DSCP, hasmask, 1, value) |
| 276 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 277 | outstr = prefix + "name = ip_dscp\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 278 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 279 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 280 | return outstr |
| 281 | |
| 282 | class ip_ecn(oxm_tlv): |
| 283 | """ |
| 284 | Wrapper class for ip_dscp match object |
| 285 | |
| 286 | Data members inherited from oxm_tlv: |
| 287 | @arg class |
| 288 | @arg field |
| 289 | @arg hasmask |
| 290 | @arg body |
| 291 | |
| 292 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 293 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 294 | oxm_tlv.__init__(self, OFPXMT_OFB_IP_ECN, hasmask, 1, value) |
| 295 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 296 | outstr = prefix + "name = ip_ecn\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 297 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 298 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 299 | return outstr |
| 300 | |
| 301 | class ip_proto(oxm_tlv): |
| 302 | """ |
| 303 | Wrapper class for ip_proto match object |
| 304 | |
| 305 | Data members inherited from oxm_tlv: |
| 306 | @arg class |
| 307 | @arg field |
| 308 | @arg hasmask |
| 309 | @arg body |
| 310 | |
| 311 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 312 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 313 | oxm_tlv.__init__(self, OFPXMT_OFB_IP_PROTO, hasmask, 1, value) |
| 314 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 315 | outstr = prefix + "name = ip_proto\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 316 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 317 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 318 | return outstr |
| 319 | |
| 320 | class ipv4_src(oxm_tlv): |
| 321 | """ |
| 322 | Wrapper class for ipv4_src match object |
| 323 | |
| 324 | Data members inherited from oxm_tlv: |
| 325 | @arg class |
| 326 | @arg field |
| 327 | @arg hasmask |
| 328 | @arg body |
| 329 | |
| 330 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 331 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 332 | if not hasmask: |
| 333 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_SRC, hasmask, 4, value) |
| 334 | else: |
| 335 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_SRC, hasmask, 4, value, mask) |
| 336 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 337 | outstr = prefix + "name = ipv4_src\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 338 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 339 | #Value can be a long int or a string |
| 340 | try: |
| 341 | addr = ipaddr.IPv4Address(self.value) |
| 342 | except ValueError: |
| 343 | addr = ipaddr.IPv4Address(int(self.value, 16)) |
| 344 | outstr += prefix + "value = " + str(addr) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 345 | return outstr |
| 346 | |
| 347 | class ipv4_dst(oxm_tlv): |
| 348 | """ |
| 349 | Wrapper class for ipv4_dst match object |
| 350 | |
| 351 | Data members inherited from oxm_tlv: |
| 352 | @arg class |
| 353 | @arg field |
| 354 | @arg hasmask |
| 355 | @arg body |
| 356 | |
| 357 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 358 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 359 | if not hasmask: |
| 360 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_DST, hasmask, 4, value) |
| 361 | else: |
| 362 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV4_DST, hasmask, 4, value, mask) |
| 363 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 364 | outstr = prefix + "name = ipv4_dst\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 365 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 366 | #Value can be a long int or a string |
| 367 | #try: |
| 368 | addr = ipaddr.IPv4Address(self.value) |
| 369 | #except ValueError: |
| 370 | # addr = ipaddr.IPv4Address(int(self.value, 16)) |
| 371 | outstr += prefix + "value = " + str(addr) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 372 | return outstr |
| 373 | |
| 374 | class tcp_src(oxm_tlv): |
| 375 | """ |
| 376 | Wrapper class for tcp_src match object |
| 377 | |
| 378 | Data members inherited from oxm_tlv: |
| 379 | @arg class |
| 380 | @arg field |
| 381 | @arg hasmask |
| 382 | @arg body |
| 383 | |
| 384 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 385 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 386 | oxm_tlv.__init__(self, OFPXMT_OFB_TCP_SRC, hasmask, 2, value) |
| 387 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 388 | outstr = prefix + "name = tcp_src\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 389 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 390 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 391 | return outstr |
| 392 | |
| 393 | class tcp_dst(oxm_tlv): |
| 394 | """ |
| 395 | Wrapper class for tcp_src match object |
| 396 | |
| 397 | Data members inherited from oxm_tlv: |
| 398 | @arg class |
| 399 | @arg field |
| 400 | @arg hasmask |
| 401 | @arg body |
| 402 | |
| 403 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 404 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 405 | oxm_tlv.__init__(self, OFPXMT_OFB_TCP_DST, hasmask, 2, value) |
| 406 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 407 | outstr = prefix + "name = tcp_dst\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 408 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 409 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 410 | return outstr |
| 411 | |
| 412 | class udp_src(oxm_tlv): |
| 413 | """ |
| 414 | Wrapper class for udp_src match object |
| 415 | |
| 416 | Data members inherited from oxm_tlv: |
| 417 | @arg class |
| 418 | @arg field |
| 419 | @arg hasmask |
| 420 | @arg body |
| 421 | |
| 422 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 423 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 424 | oxm_tlv.__init__(self, OFPXMT_OFB_UDP_SRC, hasmask, 2, value) |
| 425 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 426 | outstr = prefix + "name = udp_src\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 427 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 428 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 429 | return outstr |
| 430 | |
| 431 | class udp_dst(oxm_tlv): |
| 432 | """ |
| 433 | Wrapper class for udp_dst match object |
| 434 | |
| 435 | Data members inherited from oxm_tlv: |
| 436 | @arg class |
| 437 | @arg field |
| 438 | @arg hasmask |
| 439 | @arg body |
| 440 | |
| 441 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 442 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 443 | oxm_tlv.__init__(self, OFPXMT_OFB_UDP_DST, hasmask, 2, value) |
| 444 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 445 | outstr = prefix + "name = udp_dst\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 446 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 447 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 448 | return outstr |
| 449 | |
| 450 | class sctp_src(oxm_tlv): |
| 451 | """ |
| 452 | Wrapper class for sctp_src match object |
| 453 | |
| 454 | Data members inherited from oxm_tlv: |
| 455 | @arg class |
| 456 | @arg field |
| 457 | @arg hasmask |
| 458 | @arg body |
| 459 | |
| 460 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 461 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 462 | oxm_tlv.__init__(self, OFPXMT_OFB_SCTP_SRC, hasmask, 2, value) |
| 463 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 464 | outstr = prefix + "name = sctp_src\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 465 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 466 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 467 | return outstr |
| 468 | |
| 469 | |
| 470 | class sctp_dst(oxm_tlv): |
| 471 | """ |
| 472 | Wrapper class for sctp_dst match object |
| 473 | |
| 474 | Data members inherited from oxm_tlv: |
| 475 | @arg class |
| 476 | @arg field |
| 477 | @arg hasmask |
| 478 | @arg body |
| 479 | |
| 480 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 481 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 482 | oxm_tlv.__init__(self, OFPXMT_OFB_SCTP_DST, hasmask, 2, value) |
| 483 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 484 | outstr = prefix + "name = sctp_dst\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 485 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 486 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 487 | return outstr |
| 488 | |
| 489 | class icmpv4_type(oxm_tlv): |
| 490 | """ |
| 491 | Wrapper class for icmpv4_type match object |
| 492 | |
| 493 | Data members inherited from oxm_tlv: |
| 494 | @arg class |
| 495 | @arg field |
| 496 | @arg hasmask |
| 497 | @arg body |
| 498 | |
| 499 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 500 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 501 | oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV4_TYPE, hasmask, 1, value) |
| 502 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 503 | outstr = prefix + "name = icmpv4_type\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 504 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 505 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 506 | return outstr |
| 507 | |
| 508 | class icmpv4_code(oxm_tlv): |
| 509 | """ |
| 510 | Wrapper class for icmpv4_code match object |
| 511 | |
| 512 | Data members inherited from oxm_tlv: |
| 513 | @arg class |
| 514 | @arg field |
| 515 | @arg hasmask |
| 516 | @arg body |
| 517 | |
| 518 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 519 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 520 | oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV4_CODE, hasmask, 1, value) |
| 521 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 522 | outstr = prefix + "name = icmpv4_code\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 523 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 524 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 525 | return outs |
| 526 | |
| 527 | class arp_op(oxm_tlv): |
| 528 | """ |
| 529 | Wrapper class for arp_op match object |
| 530 | |
| 531 | Data members inherited from oxm_tlv: |
| 532 | @arg class |
| 533 | @arg field |
| 534 | @arg hasmask |
| 535 | @arg body |
| 536 | |
| 537 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 538 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 539 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_OP, hasmask, 2, value) |
| 540 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 541 | outstr = prefix + "name = arp_op\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 542 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 543 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 544 | return outs |
| 545 | |
| 546 | class arp_spa(oxm_tlv): |
| 547 | """ |
| 548 | Wrapper class for arp_spa match object |
| 549 | |
| 550 | Data members inherited from oxm_tlv: |
| 551 | @arg class |
| 552 | @arg field |
| 553 | @arg hasmask |
| 554 | @arg body |
| 555 | |
| 556 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 557 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 558 | if not hasmask: |
| 559 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SPA, hasmask, 4, value) |
| 560 | else: |
| 561 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SPA, hasmask, 4, value, mask) |
| 562 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 563 | outstr = prefix + "name = arp_spa\n" |
| 564 | #Value can be a long int or a string |
| 565 | try: |
| 566 | addr = ipaddr.IPv4Address(self.value) |
| 567 | except ValueError: |
| 568 | addr = ipaddr.IPv4Address(int(self.value, 16)) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 569 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 570 | outstr += prefix + "value = " + str(addr) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 571 | return outstr |
| 572 | |
| 573 | class arp_tpa(oxm_tlv): |
| 574 | """ |
| 575 | Wrapper class for arp_tpa match object |
| 576 | |
| 577 | Data members inherited from oxm_tlv: |
| 578 | @arg class |
| 579 | @arg field |
| 580 | @arg hasmask |
| 581 | @arg body |
| 582 | |
| 583 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 584 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 585 | if not hasmask: |
| 586 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_TPA, hasmask, 4, value) |
| 587 | else: |
| 588 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_TPA, hasmask, 4, value, mask) |
| 589 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 590 | outstr = prefix + "name = arp_tpa\n" |
| 591 | #Value can be a long int or a string |
| 592 | try: |
| 593 | addr = ipaddr.IPv4Address(self.value) |
| 594 | except ValueError: |
| 595 | addr = ipaddr.IPv4Address(int(self.value, 16)) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 596 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 597 | outstr += prefix + "value = " + ":".join(["%.2x" %x |
| 598 | for x in self.value]) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 599 | return outstr |
| 600 | |
| 601 | |
| 602 | class arp_sha(oxm_tlv): |
| 603 | """ |
| 604 | Wrapper class for arp_sha match object |
| 605 | |
| 606 | Data members inherited from oxm_tlv: |
| 607 | @arg class |
| 608 | @arg field |
| 609 | @arg hasmask |
| 610 | @arg body |
| 611 | |
| 612 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 613 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 614 | if not hasmask: |
| 615 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SHA, hasmask, 6, value) |
| 616 | else: |
| 617 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_SHA, hasmask, 12, value) |
| 618 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 619 | outstr = prefix + "name = arp_sha\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 620 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 621 | outstr += prefix + "value = " + ":".join(["%.2x" %x |
| 622 | for x in self.value]) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 623 | return outstr |
| 624 | |
| 625 | class arp_tha(oxm_tlv): |
| 626 | """ |
| 627 | Wrapper class for arp_tha match object |
| 628 | |
| 629 | Data members inherited from oxm_tlv: |
| 630 | @arg class |
| 631 | @arg field |
| 632 | @arg hasmask |
| 633 | @arg body |
| 634 | |
| 635 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 636 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 637 | if not hasmask: |
| 638 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_THA, hasmask, 6, value) |
| 639 | else: |
| 640 | oxm_tlv.__init__(self, OFPXMT_OFB_ARP_THA, hasmask, 12, value) |
| 641 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 642 | outstr = prefix + "name = arp_tha\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 643 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 644 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 645 | return outstr |
| 646 | |
| 647 | class ipv6_src(oxm_tlv): |
| 648 | """ |
| 649 | Wrapper class for ipv6_src match object |
| 650 | |
| 651 | Data members inherited from oxm_tlv: |
| 652 | @arg class |
| 653 | @arg field |
| 654 | @arg hasmask |
| 655 | @arg body |
| 656 | |
| 657 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 658 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 659 | if not hasmask: |
| 660 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_SRC, False, 16, value) |
| 661 | else: |
| 662 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_SRC, True, 32, value) |
| 663 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 664 | outstr = prefix + "name = ipv6_src\n" |
| 665 | try: |
| 666 | addr = ipaddr.IPv6Address(self.value) |
| 667 | except ValueError: |
| 668 | addr = ipaddr.IPv6Address(int(self.value, 16)) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 669 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 670 | outstr += prefix + "value = " + str(addr) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 671 | return outstr |
| 672 | |
| 673 | class ipv6_dst(oxm_tlv): |
| 674 | """ |
| 675 | Wrapper class for ipv6_dst match object |
| 676 | |
| 677 | Data members inherited from oxm_tlv: |
| 678 | @arg class |
| 679 | @arg field |
| 680 | @arg hasmask |
| 681 | @arg body |
| 682 | |
| 683 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 684 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 685 | if not hasmask: |
| 686 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_DST, False, 16, value) |
| 687 | else: |
| 688 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_DST, True, 32, value) |
| 689 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 690 | outstr = prefix + "name = ipv6_dst\n" |
| 691 | try: |
| 692 | addr = ipaddr.IPv6Address(self.value) |
| 693 | except ValueError: |
| 694 | addr = ipaddr.IPv6Address(int(self.value, 16)) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 695 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 696 | outstr += prefix + "value = " + str(addr) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 697 | return outstr |
| 698 | |
| 699 | class ipv6_flabel(oxm_tlv): |
| 700 | """ |
| 701 | Wrapper class for ipv6_flabel match object |
| 702 | |
| 703 | Data members inherited from oxm_tlv: |
| 704 | @arg class |
| 705 | @arg field |
| 706 | @arg hasmask |
| 707 | @arg body |
| 708 | |
| 709 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 710 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 711 | if not hasmask: |
| 712 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_FLABEL, hasmask, 4, value) |
| 713 | else: |
| 714 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_FLABEL, hasmask, 8, value) |
| 715 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 716 | outstr = prefix + "name = ipv6_flabel\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 717 | outstr += oxm_tlv.show(self, prefix) |
| 718 | return outstr |
| 719 | |
| 720 | class icmpv6_type(oxm_tlv): |
| 721 | """ |
| 722 | Wrapper class for icmpv6_type match object |
| 723 | |
| 724 | Data members inherited from oxm_tlv: |
| 725 | @arg class |
| 726 | @arg field |
| 727 | @arg hasmask |
| 728 | @arg body |
| 729 | |
| 730 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 731 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 732 | oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV6_TYPE, hasmask, 1, value) |
| 733 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 734 | outstr = prefix + "name = icmpv6_type\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 735 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 736 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 737 | return outstr |
| 738 | |
| 739 | class icmpv6_code(oxm_tlv): |
| 740 | """ |
| 741 | Wrapper class for icmpv6_code match object |
| 742 | |
| 743 | Data members inherited from oxm_tlv: |
| 744 | @arg class |
| 745 | @arg field |
| 746 | @arg hasmask |
| 747 | @arg body |
| 748 | |
| 749 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 750 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 751 | oxm_tlv.__init__(self, OFPXMT_OFB_ICMPV6_CODE, hasmask, 1, value) |
| 752 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 753 | outstr = prefix + "name = icmpv6_code\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 754 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 755 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 756 | return outs |
| 757 | |
| 758 | class ipv6_nd_target(oxm_tlv): |
| 759 | """ |
| 760 | Wrapper class for ipv6_nd_target match object |
| 761 | |
| 762 | Data members inherited from oxm_tlv: |
| 763 | @arg class |
| 764 | @arg field |
| 765 | @arg hasmask |
| 766 | @arg body |
| 767 | |
| 768 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 769 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 770 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_ND_TARGET, hasmask, 16, value) |
| 771 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 772 | outstr = prefix + "name = ipv6_nd_target\n" |
| 773 | try: |
| 774 | addr = ipaddr.IPv6Address(self.value) |
| 775 | except ValueError: |
| 776 | addr = ipaddr.IPv6Address(int(self.value, 16)) |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 777 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 778 | outstr += prefix + "value = " + str(addr) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 779 | return outstr |
| 780 | |
| 781 | class ipv6_nd_sll(oxm_tlv): |
| 782 | """ |
| 783 | Wrapper class for ipv6_nd_sll match object |
| 784 | |
| 785 | Data members inherited from oxm_tlv: |
| 786 | @arg class |
| 787 | @arg field |
| 788 | @arg hasmask |
| 789 | @arg body |
| 790 | |
| 791 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 792 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 793 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_ND_SLL, hasmask, 6, value) |
| 794 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 795 | outstr = prefix + "name = ipv6_nd_sll\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 796 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 797 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 798 | return outstr |
| 799 | |
| 800 | class ipv6_nd_tll(oxm_tlv): |
| 801 | """ |
| 802 | Wrapper class for ipv6_nd_tll match object |
| 803 | |
| 804 | Data members inherited from oxm_tlv: |
| 805 | @arg class |
| 806 | @arg field |
| 807 | @arg hasmask |
| 808 | @arg body |
| 809 | |
| 810 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 811 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 812 | oxm_tlv.__init__(self, OFPXMT_OFB_IPV6_ND_TLL, hasmask, 6, value) |
| 813 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 814 | outstr = prefix + "name = ipv6_nd_tll\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 815 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 816 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 817 | return outstr |
| 818 | |
| 819 | class mpls_label(oxm_tlv): |
| 820 | """ |
| 821 | Wrapper class for mpls_label match object |
| 822 | |
| 823 | Data members inherited from oxm_tlv: |
| 824 | @arg class |
| 825 | @arg field |
| 826 | @arg hasmask |
| 827 | @arg body |
| 828 | |
| 829 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 830 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 831 | oxm_tlv.__init__(self, OFPXMT_OFB_MPLS_LABEL, hasmask, 4, value) |
| 832 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 833 | outstr = prefix + "name = mpls_label\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 834 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 835 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 836 | return outstr |
| 837 | |
| 838 | class mpls_tc(oxm_tlv): |
| 839 | """ |
| 840 | Wrapper class for mpls_ltc match object |
| 841 | |
| 842 | Data members inherited from oxm_tlv: |
| 843 | @arg class |
| 844 | @arg field |
| 845 | @arg hasmask |
| 846 | @arg body |
| 847 | |
| 848 | """ |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 849 | def __init__(self, value=None, hasmask=False): |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 850 | oxm_tlv.__init__(self, OFPXMT_OFB_MPLS_TC, hasmask, 1, value) |
| 851 | def show(self, prefix=''): |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 852 | outstr = prefix + "name = mpls_tc\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 853 | outstr += oxm_tlv.show(self, prefix) |
ederlf | fdedc07 | 2013-01-18 09:32:00 -0200 | [diff] [blame^] | 854 | outstr += prefix + "value = " + str(self.value) +"\n" |
Rich Lane | 629393f | 2013-01-10 15:37:33 -0800 | [diff] [blame] | 855 | return outstr |
| 856 | |
| 857 | match_class_list = ( |
| 858 | in_port, |
| 859 | in_phy_port, |
| 860 | metadata, |
| 861 | eth_dst, |
| 862 | eth_src, |
| 863 | eth_type, |
| 864 | vlan_vid, |
| 865 | vlan_pcp, |
| 866 | ip_dscp, |
| 867 | ip_ecn, |
| 868 | ip_proto, |
| 869 | ipv4_src, |
| 870 | ipv4_dst, |
| 871 | tcp_src, |
| 872 | tcp_dst, |
| 873 | udp_src, |
| 874 | udp_dst, |
| 875 | sctp_src, |
| 876 | sctp_dst, |
| 877 | icmpv4_type, |
| 878 | icmpv4_code, |
| 879 | arp_op, |
| 880 | arp_spa, |
| 881 | arp_tpa, |
| 882 | arp_sha, |
| 883 | arp_tha, |
| 884 | ipv6_src, |
| 885 | ipv6_dst, |
| 886 | ipv6_flabel, |
| 887 | icmpv6_type, |
| 888 | icmpv6_code, |
| 889 | ipv6_nd_target, |
| 890 | ipv6_nd_sll, |
| 891 | ipv6_nd_tll, |
| 892 | mpls_label, |
| 893 | mpls_tc) |