ROFL-pipeline  v0.6.0dev
of1x_match.c
1 #include <assert.h>
2 #include "of1x_match.h"
3 
4 #include "../../../common/datapacket.h"
5 #include "../../../common/protocol_constants.h"
6 #include "../../../platform/memory.h"
7 #include "../../../platform/likely.h"
8 #include "../../../util/logging.h"
9 
10 /*
11 * Initializers
12 */
13 
14 #define OF1X_MIN_VERSION OF_VERSION_10
15 #define OF1X_MAX_VERSION OF_VERSION_13
16 
17 //Phy
20 
21  if(unlikely(match == NULL))
22  return NULL;
23 
24  match->type = OF1X_MATCH_IN_PORT;
25  match->__tern = __init_utern32(value,OF1X_4_BYTE_MASK); //No wildcard
26 
27  //Set fast validation flags
28  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
29  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
30  match->has_wildcard = false; //Not accepting wildcards
31 
32  //Initialize linked-list
33  match->prev=match->next=NULL;
34 
35  return match;
36 }
37 
40 
41  if(unlikely(match == NULL))
42  return NULL;
43 
44  match->type = OF1X_MATCH_IN_PHY_PORT;
45  match->__tern = __init_utern32(value,OF1X_4_BYTE_MASK); //No wildcard
46 
47  //Set fast validation flags
48  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
49  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
50  match->has_wildcard = false; //Not accepting wildcards
51 
52  //Initialize linked-list
53  match->prev=match->next=NULL;
54 
55  return match;
56 }
57 
58 //METADATA
59 of1x_match_t* of1x_init_metadata_match(uint64_t value, uint64_t mask){
61 
62  if(unlikely(match == NULL))
63  return NULL;
64 
65  match->type = OF1X_MATCH_METADATA;
66  match->__tern = __init_utern64(value, mask);
67 
68  //Set fast validation flags
69  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
70  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
71  if( (mask&OF1X_8_BYTE_MASK) != OF1X_8_BYTE_MASK)
72  match->has_wildcard = true;
73  else
74  match->has_wildcard = false;
75 
76  //Initialize linked-list
77  match->prev=match->next=NULL;
78 
79  return match;
80 }
81 
82 //ETHERNET
83 of1x_match_t* of1x_init_eth_dst_match(uint64_t value, uint64_t mask){
85 
86  if(unlikely(match == NULL))
87  return NULL;
88 
89  // Align to pipeline convention (NBO, lower memory address)
90  value = HTONB64(OF1X_MAC_ALIGN(value));
91  mask = HTONB64(OF1X_MAC_ALIGN(mask));
92 
93  match->type = OF1X_MATCH_ETH_DST;
94  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
95 
96 
97  //Set fast validation flags
98  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
99  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
100  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK)
101  match->has_wildcard = true;
102  else
103  match->has_wildcard = false;
104 
105  //Initialize linked-list
106  match->prev=match->next=NULL;
107 
108  return match;
109 }
110 of1x_match_t* of1x_init_eth_src_match(uint64_t value, uint64_t mask){
112 
113  if(unlikely(match == NULL))
114  return NULL;
115 
116  // Align to pipeline convention (NBO, lower memory address)
117  value = HTONB64(OF1X_MAC_ALIGN(value));
118  mask = HTONB64(OF1X_MAC_ALIGN(mask));
119 
120  match->type = OF1X_MATCH_ETH_SRC;
121  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
122 
123  //Set fast validation flags
124  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
125  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
126  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK )
127  match->has_wildcard = true;
128  else
129  match->has_wildcard = false;
130 
131  //Initialize linked-list
132  match->prev=match->next=NULL;
133 
134  return match;
135 }
138 
139  if(unlikely(match == NULL))
140  return NULL;
141 
142  value = HTONB16(value);
143 
144  match->type = OF1X_MATCH_ETH_TYPE;
145  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //No wildcard
146 
147  //Set fast validation flags
148  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
149  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
150  match->has_wildcard = false; //Not accepting wildcards
151 
152  //Initialize linked-list
153  match->prev=match->next=NULL;
154 
155  return match;
156 }
157 
158 //8021.q
159 of1x_match_t* of1x_init_vlan_vid_match(uint16_t value, uint16_t mask, enum of1x_vlan_present vlan_present){
161 
162  if(unlikely(match == NULL))
163  return NULL;
164 
165  // Align to pipeline convention (NBO, lower memory address)
166  value = HTONB16(value);
167  mask = HTONB16(mask);
168 
169  match->type = OF1X_MATCH_VLAN_VID;
170  //Setting values; note that value includes the flag HAS_VLAN in the 13th bit
171  //The mask is set to be strictly 12 bits, so only matching the VLAN ID itself
172  match->__tern = __init_utern16(value&OF1X_VLAN_ID_MASK,mask&OF1X_VLAN_ID_MASK);
173  match->vlan_present = vlan_present;
174 
175  //Set fast validation flags
176  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
177  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
178  if( (mask&OF1X_VLAN_ID_MASK) != OF1X_VLAN_ID_MASK)
179  match->has_wildcard = true;
180  else
181  match->has_wildcard = false;
182 
183  //Initialize linked-list
184  match->prev=match->next=NULL;
185 
186  return match;
187 }
190 
191  if(unlikely(match == NULL))
192  return NULL;
193 
194  // Align to pipeline convention (NBO, lower memory address)
195  value = OF1X_VLAN_PCP_ALIGN(value);
196 
197  match->type = OF1X_MATCH_VLAN_PCP;
198  match->__tern = __init_utern8(value&OF1X_3MSBITS_MASK,OF1X_3MSBITS_MASK); //Ensure only 3 bit value, no wildcard
199 
200  //Set fast validation flags
201  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
202  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
203  match->has_wildcard = false; //Not accepting wildcards
204 
205  //Initialize linked-list
206  match->prev=match->next=NULL;
207 
208  return match;
209 }
210 
211 //MPLS
214 
215  if(unlikely(match == NULL))
216  return NULL;
217 
218  // Align to pipeline convention (NBO, lower memory address)
219  value = HTONB32(OF1X_MPLS_LABEL_ALIGN(value));
220 
221  match->type = OF1X_MATCH_MPLS_LABEL;
222  match->__tern = __init_utern32(value&OF1X_20_BITS_MASK,OF1X_20_BITS_MASK); //no wildcard?? wtf!
223 
224  //Set fast validation flags
225  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
226  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
227  match->has_wildcard = false; //Not accepting wildcards
228 
229  //Initialize linked-list
230  match->prev=match->next=NULL;
231 
232  return match;
233 }
236 
237  if(unlikely(match == NULL))
238  return NULL;
239 
240  // Align to pipeline convention (NBO, lower memory address)
241  value = OF1X_MPLS_TC_ALIGN(value);
242 
243  match->type = OF1X_MATCH_MPLS_TC;
244  match->__tern = __init_utern8(value&OF1X_BITS_12AND3_MASK,OF1X_BITS_12AND3_MASK); //Ensure only 3 bit value, no wildcard
245 
246  //Set fast validation flags
247  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
248  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
249  match->has_wildcard = false; //Not accepting wildcards
250 
251  //Initialize linked-list
252  match->prev=match->next=NULL;
253 
254  return match;
255 }
258 
259  if(unlikely(match == NULL))
260  return NULL;
261 
262  match->type = OF1X_MATCH_MPLS_BOS;
263  match->__tern = __init_utern8(value&OF1X_BIT0_MASK,OF1X_BIT0_MASK); //Ensure only 1 bit value, no wildcard
264 
265  //Set fast validation flags
266  match->ver_req.min_ver = OF_VERSION_13; //First supported in OF1.3
267  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
268  match->has_wildcard = false; //Not accepting wildcards
269 
270  //Initialize linked-list
271  match->prev=match->next=NULL;
272 
273  return match;
274 }
275 
276 //ARP
279 
280  if(unlikely(match == NULL))
281  return NULL;
282 
283  // Align to pipeline convention (NBO, lower memory address)
284  value = HTONB16(value);
285 
286  match->type = OF1X_MATCH_ARP_OP;
287  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //No wildcard
288 
289  //Set fast validation flags
290  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0 (1.0: lower 8bits of opcode)
291  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
292  match->has_wildcard = false; //Not accepting wildcards
293 
294  //Initialize linked-list
295  match->prev=match->next=NULL;
296 
297  return match;
298 }
299 of1x_match_t* of1x_init_arp_tha_match(uint64_t value, uint64_t mask){
301 
302  if(unlikely(match == NULL))
303  return NULL;
304 
305  // Align to pipeline convention (NBO, lower memory address)
306  value = HTONB64(OF1X_MAC_ALIGN(value));
307  mask = HTONB64(OF1X_MAC_ALIGN(mask));
308 
309  match->type = OF1X_MATCH_ARP_THA;
310  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
311 
312 
313  //Set fast validation flags
314  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
315  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
316  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK)
317  match->has_wildcard = true;
318  else
319  match->has_wildcard = false;
320 
321  //Initialize linked-list
322  match->prev=match->next=NULL;
323 
324  return match;
325 }
326 of1x_match_t* of1x_init_arp_sha_match(uint64_t value, uint64_t mask){
328 
329  if(unlikely(match == NULL))
330  return NULL;
331 
332  // Align to pipeline convention (NBO, lower memory address)
333  value = HTONB64(OF1X_MAC_ALIGN(value));
334  mask = HTONB64(OF1X_MAC_ALIGN(mask));
335 
336  match->type = OF1X_MATCH_ARP_SHA;
337  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
338 
339  //Set fast validation flags
340  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
341  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
342  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK)
343  match->has_wildcard = true;
344  else
345  match->has_wildcard = false;
346 
347  //Initialize linked-list
348  match->prev=match->next=NULL;
349 
350  return match;
351 }
352 of1x_match_t* of1x_init_arp_tpa_match(uint32_t value, uint32_t mask){
354 
355  if(unlikely(match == NULL))
356  return NULL;
357 
358  // Align to pipeline convention (NBO, lower memory address)
359  value = HTONB32(value);
360  mask = HTONB32(mask);
361 
362  match->type = OF1X_MATCH_ARP_TPA;
363  match->__tern = __init_utern32(value,mask);
364 
365  //Set fast validation flags
366  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
367  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
368  if( mask != OF1X_4_BYTE_MASK )
369  match->has_wildcard = true;
370  else
371  match->has_wildcard = false;
372 
373  //Initialize linked-list
374  match->prev=match->next=NULL;
375 
376  return match;
377 }
378 of1x_match_t* of1x_init_arp_spa_match(uint32_t value, uint32_t mask){
380 
381  if(unlikely(match == NULL))
382  return NULL;
383 
384  // Align to pipeline convention (NBO, lower memory address)
385  value = HTONB32(value);
386  mask = HTONB32(mask);
387 
388  match->type = OF1X_MATCH_ARP_SPA;
389  match->__tern = __init_utern32(value,mask);
390 
391  //Set fast validation flags
392  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
393  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
394  if( mask != OF1X_4_BYTE_MASK )
395  match->has_wildcard = true;
396  else
397  match->has_wildcard = false;
398 
399  //Initialize linked-list
400  match->prev=match->next=NULL;
401 
402  return match;
403 }
404 
405 //NW
408 
409  if(unlikely(match == NULL))
410  return NULL;
411 
412  match->type = OF1X_MATCH_NW_PROTO;
413  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK); //no wildcard
414 
415  //Set fast validation flags
416  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
417  match->ver_req.max_ver = OF_VERSION_10; //Last supported in OF1.0
418  match->has_wildcard = false; //Not accepting wildcards
419 
420  //Initialize linked-list
421  match->prev=match->next=NULL;
422 
423  return match;
424 }
425 of1x_match_t* of1x_init_nw_src_match(uint32_t value, uint32_t mask){
427 
428  if(unlikely(match == NULL))
429  return NULL;
430 
431  // Align to pipeline convention (NBO, lower memory address)
432  value = HTONB32(value);
433  mask = HTONB32(mask);
434 
435  match->type = OF1X_MATCH_NW_SRC;
436  match->__tern = __init_utern32(value,mask);
437 
438  //Set fast validation flags
439  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
440  match->ver_req.max_ver = OF_VERSION_10; //Last supported in OF1.0
441  if( (mask&OF1X_4_BYTE_MASK) != OF1X_4_BYTE_MASK)
442  match->has_wildcard = true;
443  else
444  match->has_wildcard = false;
445 
446  //Initialize linked-list
447  match->prev=match->next=NULL;
448 
449  return match;
450 }
451 of1x_match_t* of1x_init_nw_dst_match(uint32_t value, uint32_t mask){
453 
454  if(unlikely(match == NULL))
455  return NULL;
456 
457  // Align to pipeline convention (NBO, lower memory address)
458  value = HTONB32(value);
459  mask = HTONB32(mask);
460 
461  match->type = OF1X_MATCH_NW_DST;
462  match->__tern = __init_utern32(value,mask);
463 
464  //Set fast validation flags
465  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
466  match->ver_req.max_ver = OF_VERSION_10; //Last supported in OF1.0
467  if( (mask&OF1X_4_BYTE_MASK) != OF1X_4_BYTE_MASK)
468  match->has_wildcard = true;
469  else
470  match->has_wildcard = false;
471 
472  //Initialize linked-list
473  match->prev=match->next=NULL;
474 
475  return match;
476 }
477 
478 //IPv4
479 of1x_match_t* of1x_init_ip4_src_match(uint32_t value, uint32_t mask){
481 
482  if(unlikely(match == NULL))
483  return NULL;
484 
485  // Align to pipeline convention (NBO, lower memory address)
486  value = HTONB32(value);
487  mask = HTONB32(mask);
488 
489  match->type = OF1X_MATCH_IPV4_SRC;
490  match->__tern = __init_utern32(value,mask);
491 
492  //Set fast validation flags
493  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
494  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
495  if( (mask&OF1X_4_BYTE_MASK) != OF1X_4_BYTE_MASK)
496  match->has_wildcard = true;
497  else
498  match->has_wildcard = false;
499 
500  //Initialize linked-list
501  match->prev=match->next=NULL;
502 
503  return match;
504 }
505 of1x_match_t* of1x_init_ip4_dst_match(uint32_t value, uint32_t mask){
507 
508  if(unlikely(match == NULL))
509  return NULL;
510 
511  // Align to pipeline convention (NBO, lower memory address)
512  value = HTONB32(value);
513  mask = HTONB32(mask);
514 
515  match->type = OF1X_MATCH_IPV4_DST;
516  match->__tern = __init_utern32(value,mask);
517 
518  //Set fast validation flags
519  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
520  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
521  if( (mask&OF1X_4_BYTE_MASK) != OF1X_4_BYTE_MASK)
522  match->has_wildcard = true;
523  else
524  match->has_wildcard = false;
525 
526  //Initialize linked-list
527  match->prev=match->next=NULL;
528 
529  return match;
530 }
533 
534  if(unlikely(match == NULL))
535  return NULL;
536 
537  match->type = OF1X_MATCH_IP_PROTO;
538  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK); //no wildcard
539 
540  //Set fast validation flags
541  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
542  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
543  match->has_wildcard = false; //Not accepting wildcards
544 
545  //Initialize linked-list
546  match->prev=match->next=NULL;
547 
548  return match;
549 }
552 
553  if(unlikely(match == NULL))
554  return NULL;
555 
556  // Align to pipeline convention (NBO, lower memory address)
557  value = OF1X_IP_DSCP_ALIGN(value);
558 
559  match->type = OF1X_MATCH_IP_DSCP;
560  match->__tern = __init_utern8(value&OF1X_6MSBITS_MASK,OF1X_6MSBITS_MASK); //no wildcard
561 
562  //Set fast validation flags
563  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0 (ToS)
564  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
565  match->has_wildcard = false; //Not accepting wildcards
566 
567  //Initialize linked-list
568  match->prev=match->next=NULL;
569 
570  return match;
571 }
572 
575 
576  if(unlikely(match == NULL))
577  return NULL;
578 
579  match->type = OF1X_MATCH_IP_ECN;
580  match->__tern = __init_utern8(value&OF1X_2LSBITS_MASK,OF1X_2LSBITS_MASK); //no wildcard
581 
582  //Set fast validation flags
583  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
584  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
585  match->has_wildcard = false; //Not accepting wildcards
586 
587  //Initialize linked-list
588  match->prev=match->next=NULL;
589 
590  return match;
591 }
592 
593 //IPv6
596 
597  if(unlikely(match == NULL))
598  return NULL;
599 
600  // Align to pipeline convention (NBO, lower memory address)
601  HTONB128(value);
602  HTONB128(mask);
603 
604  uint128__t fixed_mask = {{0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}};
605  match->type = OF1X_MATCH_IPV6_SRC;
606  match->__tern = __init_utern128(value,mask);
607 
608  //Set fast validation flags
609  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
610  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
611  if(memcmp(&fixed_mask,&mask, sizeof(mask)) != 0)
612  match->has_wildcard = true;
613  else
614  match->has_wildcard = false;
615 
616  //Initialize linked-list
617  match->prev=match->next=NULL;
618 
619  return match;
620 }
623 
624  if(unlikely(match == NULL))
625  return NULL;
626 
627  // Align to pipeline convention (NBO, lower memory address)
628  HTONB128(value);
629  HTONB128(mask);
630 
631  uint128__t fixed_mask = {{0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}};
632  match->type = OF1X_MATCH_IPV6_DST;
633  match->__tern = __init_utern128(value,mask);
634 
635  //Set fast validation flags
636  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
637  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
638  if(memcmp(&fixed_mask,&mask, sizeof(mask)) != 0)
639  match->has_wildcard = true;
640  else
641  match->has_wildcard = false;
642 
643  //Initialize linked-list
644  match->prev=match->next=NULL;
645 
646  return match;
647 }
648 of1x_match_t* of1x_init_ip6_flabel_match(uint32_t value, uint32_t mask){
650 
651  if(unlikely(match == NULL))
652  return NULL;
653 
654  // Align to pipeline convention (NBO, lower memory address)
655  value = HTONB32(OF1X_IP6_FLABEL_ALIGN(value));
656  mask = HTONB32(OF1X_IP6_FLABEL_ALIGN(mask));
657 
658  match->type = OF1X_MATCH_IPV6_FLABEL;
659  match->__tern = __init_utern32(value&OF1X_20_BITS_IPV6_FLABEL_MASK,mask&OF1X_20_BITS_IPV6_FLABEL_MASK); // ensure 20 bits.
660 
661  //Set fast validation flags
662  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
663  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
664  match->has_wildcard = false; //Not accepting wildcards
665 
666  //Initialize linked-list
667  match->prev=match->next=NULL;
668 
669  return match;
670 }
673 
674  if(unlikely(match == NULL))
675  return NULL;
676 
677  // Align to pipeline convention (NBO, lower memory address)
678  HTONB128(value);
679 
680  uint128__t mask = {{0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff}};
681 
682  match->type = OF1X_MATCH_IPV6_ND_TARGET;
683  match->__tern = __init_utern128(value,mask); //No wildcard
684 
685  //Set fast validation flags
686  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
687  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
688  match->has_wildcard = false; //Not accepting wildcards
689 
690  //Initialize linked-list
691  match->prev=match->next=NULL;
692 
693  return match;
694 }
697 
698  if(unlikely(match == NULL))
699  return NULL;
700 
701  // Align to pipeline convention (NBO, lower memory address)
702  value = HTONB64(OF1X_MAC_ALIGN(value));
703 
704  match->type = OF1X_MATCH_IPV6_ND_SLL;
705  match->__tern = __init_utern64(value & OF1X_48_BITS_MASK, OF1X_48_BITS_MASK); //ensure 48 bits. No wildcard
706 
707  //Set fast validation flags
708  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
709  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
710  match->has_wildcard = false; //Not accepting wildcards
711 
712  //Initialize linked-list
713  match->prev=match->next=NULL;
714 
715  return match;
716 }
719 
720  if(unlikely(match == NULL))
721  return NULL;
722 
723  // Align to pipeline convention (NBO, lower memory address)
724  value = HTONB64(OF1X_MAC_ALIGN(value));
725 
726  match->type = OF1X_MATCH_IPV6_ND_TLL;
727  match->__tern = __init_utern64(value & OF1X_48_BITS_MASK, OF1X_48_BITS_MASK); //ensure 48 bits. No wildcard
728 
729  //Set fast validation flags
730  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
731  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
732  match->has_wildcard = false; //Not accepting wildcards
733 
734  //Initialize linked-list
735  match->prev=match->next=NULL;
736 
737  return match;
738 }
739 of1x_match_t* of1x_init_ip6_exthdr_match(uint16_t value, uint16_t mask){
741 
742  if(unlikely(match == NULL))
743  return NULL;
744 
745  // TODO Align to pipeline convention (NBO, lower memory address) -- currently not implemented
746 
747  match->type = OF1X_MATCH_IPV6_EXTHDR;
748  match->__tern = __init_utern16(value&OF1X_9_BITS_MASK, mask & OF1X_9_BITS_MASK ); //ensure 9 bits, with Wildcard
749 
750  //Set fast validation flags
751  match->ver_req.min_ver = OF_VERSION_13; //First supported in OF1.2
752  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
753  if( (mask&OF1X_9_BITS_MASK) != OF1X_9_BITS_MASK)
754  match->has_wildcard = true;
755  else
756  match->has_wildcard = false;
757 
758  //Initialize linked-list
759  match->prev=match->next=NULL;
760 
761  return match;
762 }
763 
764 //ICMPV6
767 
768  if(unlikely(match == NULL))
769  return NULL;
770 
771  match->type = OF1X_MATCH_ICMPV6_TYPE;
772  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK);
773 
774  //Set fast validation flags
775  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
776  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
777  match->has_wildcard = false; //Not accepting wildcards
778 
779  //Initialize linked-list
780  match->prev=match->next=NULL;
781 
782  return match;
783 }
786 
787  if(unlikely(match == NULL))
788  return NULL;
789 
790  match->type = OF1X_MATCH_ICMPV6_CODE;
791  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK);
792 
793  //Set fast validation flags
794  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
795  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
796  match->has_wildcard = false; //Not accepting wildcards
797 
798  //Initialize linked-list
799  match->prev=match->next=NULL;
800 
801  return match;
802 }
803 
804 //TCP
807 
808  if(unlikely(match == NULL))
809  return NULL;
810 
811  // Align to pipeline convention (NBO, lower memory address)
812  value = HTONB16(value);
813 
814  match->type = OF1X_MATCH_TCP_SRC;
815  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
816 
817  //Set fast validation flags
818  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
819  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
820  match->has_wildcard = false; //Not accepting wildcards
821 
822 
823  //Initialize linked-list
824  match->prev=match->next=NULL;
825 
826  return match;
827 }
830 
831  if(unlikely(match == NULL))
832  return NULL;
833 
834  // Align to pipeline convention (NBO, lower memory address)
835  value = HTONB16(value);
836 
837  match->type = OF1X_MATCH_TCP_DST;
838  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
839 
840  //Set fast validation flags
841  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
842  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
843  match->has_wildcard = false; //Not accepting wildcards
844 
845  //Initialize linked-list
846  match->prev=match->next=NULL;
847 
848  return match;
849 }
850 //UDP
853 
854  if(unlikely(match == NULL))
855  return NULL;
856 
857  // Align to pipeline convention (NBO, lower memory address)
858  value = HTONB16(value);
859 
860  match->type = OF1X_MATCH_UDP_SRC;
861  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
862 
863  //Set fast validation flags
864  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
865  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
866  match->has_wildcard = false; //Not accepting wildcards
867 
868  //Initialize linked-list
869  match->prev=match->next=NULL;
870 
871  return match;
872 }
875 
876  if(unlikely(match == NULL))
877  return NULL;
878 
879  // Align to pipeline convention (NBO, lower memory address)
880  value = HTONB16(value);
881 
882  match->type = OF1X_MATCH_UDP_DST;
883  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
884 
885  //Set fast validation flags
886  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
887  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
888  match->has_wildcard = false; //Not accepting wildcards
889 
890  //Initialize linked-list
891  match->prev=match->next=NULL;
892 
893  return match;
894 }
895 
896 //SCTP
899 
900  if(unlikely(match == NULL))
901  return NULL;
902 
903  // Align to pipeline convention (NBO, lower memory address)
904  value = HTONB16(value);
905 
906  match->type = OF1X_MATCH_SCTP_SRC;
907  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
908 
909  //Set fast validation flags
910  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
911  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
912  match->has_wildcard = false; //Not accepting wildcards
913 
914 
915  //Initialize linked-list
916  match->prev=match->next=NULL;
917 
918  return match;
919 }
922 
923  if(unlikely(match == NULL))
924  return NULL;
925 
926  // Align to pipeline convention (NBO, lower memory address)
927  value = HTONB16(value);
928 
929  match->type = OF1X_MATCH_SCTP_DST;
930  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
931 
932  //Set fast validation flags
933  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
934  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
935  match->has_wildcard = false; //Not accepting wildcards
936 
937  //Initialize linked-list
938  match->prev=match->next=NULL;
939 
940  return match;
941 }
942 
943 //TP
946 
947  if(unlikely(match == NULL))
948  return NULL;
949 
950  // Align to pipeline convention (NBO, lower memory address)
951  value = HTONB16(value);
952 
953  match->type = OF1X_MATCH_TP_SRC;
954  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
955 
956  //Set fast validation flags
957  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
958  match->ver_req.max_ver = OF_VERSION_10; //Last supported in OF1.0
959  match->has_wildcard = false; //Not accepting wildcards
960 
961  //Initialize linked-list
962  match->prev=match->next=NULL;
963 
964  return match;
965 }
968 
969  if(unlikely(match == NULL))
970  return NULL;
971 
972  // Align to pipeline convention (NBO, lower memory address)
973  value = HTONB16(value);
974 
975  match->type = OF1X_MATCH_TP_DST;
976  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
977 
978  //Set fast validation flags
979  match->ver_req.min_ver = OF_VERSION_10; //First supported in OF1.0
980  match->ver_req.max_ver = OF_VERSION_10; //Last supported in OF1.0
981  match->has_wildcard = false; //Not accepting wildcards
982 
983  //Initialize linked-list
984  match->prev=match->next=NULL;
985 
986  return match;
987 }
988 //ICMPv4
991 
992  if(unlikely(match == NULL))
993  return NULL;
994 
995  match->type = OF1X_MATCH_ICMPV4_TYPE;
996  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK); //no wildcard
997 
998  //Set fast validation flags
999  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
1000  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1001  match->has_wildcard = false; //Not accepting wildcards
1002 
1003  //Initialize linked-list
1004  match->prev=match->next=NULL;
1005 
1006  return match;
1007 }
1010 
1011  if(unlikely(match == NULL))
1012  return NULL;
1013 
1014  match->type = OF1X_MATCH_ICMPV4_CODE;
1015  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK); //no wildcard
1016 
1017  //Set fast validation flags
1018  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
1019  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1020  match->has_wildcard = false; //Not accepting wildcards
1021 
1022  //Initialize linked-list
1023  match->prev=match->next=NULL;
1024 
1025  return match;
1026 }
1027 
1028 //PBB
1029 of1x_match_t* of1x_init_pbb_isid_match(uint32_t value, uint32_t mask){
1031 
1032  if(unlikely(match == NULL))
1033  return NULL;
1034 
1035  //TODO Align to pipeline convention (NBO, lower memory address) -- currently not implemented
1036 
1037  match->type = OF1X_MATCH_PBB_ISID;
1038  match->__tern = __init_utern32(value&OF1X_3_BYTE_MASK, mask&OF1X_3_BYTE_MASK); //no wildcard
1039 
1040  //Set fast validation flags
1041  match->ver_req.min_ver = OF_VERSION_13; //First supported in OF1.3
1042  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1043  if( (mask&OF1X_3_BYTE_MASK) == OF1X_3_BYTE_MASK)
1044  match->has_wildcard = false;
1045  else
1046  match->has_wildcard = false;
1047 
1048  //Initialize linked-list
1049  match->prev=match->next=NULL;
1050 
1051  return match;
1052 }
1053 
1054 //Tunnel Id
1055 of1x_match_t* of1x_init_tunnel_id_match(uint64_t value, uint64_t mask){
1057 
1058  if(unlikely(match == NULL))
1059  return NULL;
1060 
1061  //TODO align?
1062 
1063  match->type = OF1X_MATCH_TUNNEL_ID;
1064  match->__tern = __init_utern64(value, mask); //no wildcard
1065 
1066  //Set fast validation flags
1067  match->ver_req.min_ver = OF_VERSION_13; //First supported in OF1.3
1068  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1069  if(mask != OF1X_8_BYTE_MASK)
1070  match->has_wildcard = true;
1071  else
1072  match->has_wildcard = false;
1073 
1074  //Initialize linked-list
1075  match->prev=match->next=NULL;
1076 
1077  return match;
1078 }
1079 
1080 //Add more here...
1081 
1082 /* Extensions */
1083 
1084 //PPPoE
1087 
1088  if(unlikely(match == NULL))
1089  return NULL;
1090 
1091  match->type = OF1X_MATCH_PPPOE_CODE;
1092  match->__tern = __init_utern8(value&OF1X_1_BYTE_MASK,OF1X_1_BYTE_MASK); //no wildcard
1093 
1094  //Set fast validation flags
1095  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1096  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1097  match->has_wildcard = false; //Not accepting wildcards
1098 
1099  //Initialize linked-list
1100  match->prev=match->next=NULL;
1101 
1102  return match;
1103 }
1106 
1107  if(unlikely(match == NULL))
1108  return NULL;
1109 
1110  match->type = OF1X_MATCH_PPPOE_TYPE;
1111  match->__tern = __init_utern8(value&OF1X_4_BITS_MASK,OF1X_4_BITS_MASK); //Ensure only 4 bit value, no wildcard
1112 
1113  //Set fast validation flags
1114  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1115  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1116  match->has_wildcard = false; //Not accepting wildcards
1117 
1118  //Initialize linked-list
1119  match->prev=match->next=NULL;
1120 
1121  return match;
1122 }
1125 
1126  if(unlikely(match == NULL))
1127  return NULL;
1128 
1129  // Align to pipeline convention (NBO, lower memory address)
1130  value = HTONB16(value);
1131 
1132  match->type = OF1X_MATCH_PPPOE_SID;
1133  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
1134 
1135  //Set fast validation flags
1136  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1137  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1138  match->has_wildcard = false; //Not accepting w
1139  //Initialize linked-list
1140  match->prev=match->next=NULL;
1141 
1142  return match;
1143 }
1144 //PPP
1147 
1148  if(unlikely(match == NULL))
1149  return NULL;
1150 
1151  // Align to pipeline convention (NBO, lower memory address)
1152  value = HTONB16(value);
1153 
1154  match->type = OF1X_MATCH_PPP_PROT;
1155  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
1156 
1157  //Set fast validation flags
1158  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1159  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1160  match->has_wildcard = false; //Not accepting wildcards
1161 
1162  //Initialize linked-list
1163  match->prev=match->next=NULL;
1164 
1165  return match;
1166 }
1167 //GTP
1170 
1171  if(unlikely(match == NULL))
1172  return NULL;
1173 
1174  match->type = OF1X_MATCH_GTP_MSG_TYPE;
1175  match->__tern = __init_utern8(value,OF1X_1_BYTE_MASK); //no wildcard
1176 
1177  //Set fast validation flags
1178  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1179  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1180  match->has_wildcard = false; //Not accepting wildcards
1181 
1182  //Initialize linked-list
1183  match->prev=match->next=NULL;
1184 
1185  return match;
1186 }
1187 of1x_match_t* of1x_init_gtp_teid_match(uint32_t value, uint32_t mask){
1189 
1190  if(unlikely(match == NULL))
1191  return NULL;
1192 
1193  // Align to pipeline convention (NBO, lower memory address)
1194  value = HTONB32(value);
1195 
1196  match->type = OF1X_MATCH_GTP_TEID;
1197  match->__tern = __init_utern32(value, mask);
1198 
1199  //Set fast validation flags
1200  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1201  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1202  if( mask != OF1X_4_BYTE_MASK )
1203  match->has_wildcard = true;
1204  else
1205  match->has_wildcard = false;
1206 
1207  //Initialize linked-list
1208  match->prev=match->next=NULL;
1209 
1210  return match;
1211 }
1212 //CAPWAP
1213 of1x_match_t* of1x_init_capwap_wbid_match(uint8_t value, uint8_t mask){
1215 
1216  if(unlikely(match == NULL))
1217  return NULL;
1218 
1219  match->type = OF1X_MATCH_CAPWAP_WBID;
1220  match->__tern = __init_utern8(value, mask);
1221 
1222  //Set fast validation flags
1223  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1224  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1225  if( mask != OF1X_1_BYTE_MASK )
1226  match->has_wildcard = true;
1227  else
1228  match->has_wildcard = false;
1229 
1230  //Initialize linked-list
1231  match->prev=match->next=NULL;
1232 
1233  return match;
1234 }
1235 of1x_match_t* of1x_init_capwap_rid_match(uint8_t value, uint8_t mask){
1237 
1238  if(unlikely(match == NULL))
1239  return NULL;
1240 
1241  match->type = OF1X_MATCH_CAPWAP_RID;
1242  match->__tern = __init_utern8(value, mask);
1243 
1244  //Set fast validation flags
1245  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1246  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1247  if( mask != OF1X_1_BYTE_MASK )
1248  match->has_wildcard = true;
1249  else
1250  match->has_wildcard = false;
1251 
1252  //Initialize linked-list
1253  match->prev=match->next=NULL;
1254 
1255  return match;
1256 }
1257 of1x_match_t* of1x_init_capwap_flags_match(uint16_t value, uint16_t mask){
1259 
1260  if(unlikely(match == NULL))
1261  return NULL;
1262 
1263  // Align to pipeline convention (NBO, lower memory address)
1264  value = HTONB16(value);
1265  mask = HTONB16(mask);
1266 
1267  match->type = OF1X_MATCH_CAPWAP_FLAGS;
1268  match->__tern = __init_utern16(value, mask);
1269 
1270  //Set fast validation flags
1271  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1272  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1273  if( mask != OF1X_2_BYTE_MASK )
1274  match->has_wildcard = true;
1275  else
1276  match->has_wildcard = false;
1277 
1278  //Initialize linked-list
1279  match->prev=match->next=NULL;
1280 
1281  return match;
1282 }
1283 //WLAN
1284 of1x_match_t* of1x_init_wlan_fc_match(uint16_t value, uint16_t mask){
1286 
1287  if(unlikely(match == NULL))
1288  return NULL;
1289 
1290  // Align to pipeline convention (NBO, lower memory address)
1291  value = HTONB16(value);
1292  mask = HTONB16(mask);
1293 
1294  match->type = OF1X_MATCH_WLAN_FC;
1295  match->__tern = __init_utern16(value, mask);
1296 
1297  //Set fast validation flags
1298  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1299  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1300  if( mask != OF1X_2_BYTE_MASK )
1301  match->has_wildcard = true;
1302  else
1303  match->has_wildcard = false;
1304 
1305  //Initialize linked-list
1306  match->prev=match->next=NULL;
1307 
1308  return match;
1309 }
1310 of1x_match_t* of1x_init_wlan_type_match(uint8_t value, uint8_t mask){
1312 
1313  if(unlikely(match == NULL))
1314  return NULL;
1315 
1316  match->type = OF1X_MATCH_WLAN_TYPE;
1317  match->__tern = __init_utern8(value, mask);
1318 
1319  //Set fast validation flags
1320  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1321  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1322  if( mask != OF1X_1_BYTE_MASK )
1323  match->has_wildcard = true;
1324  else
1325  match->has_wildcard = false;
1326 
1327  //Initialize linked-list
1328  match->prev=match->next=NULL;
1329 
1330  return match;
1331 }
1332 of1x_match_t* of1x_init_wlan_subtype_match(uint8_t value, uint8_t mask){
1334 
1335  if(unlikely(match == NULL))
1336  return NULL;
1337 
1338  match->type = OF1X_MATCH_WLAN_SUBTYPE;
1339  match->__tern = __init_utern8(value, mask);
1340 
1341  //Set fast validation flags
1342  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1343  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1344  if( mask != OF1X_1_BYTE_MASK )
1345  match->has_wildcard = true;
1346  else
1347  match->has_wildcard = false;
1348 
1349  //Initialize linked-list
1350  match->prev=match->next=NULL;
1351 
1352  return match;
1353 }
1354 of1x_match_t* of1x_init_wlan_direction_match(uint8_t value, uint8_t mask){
1356 
1357  if(unlikely(match == NULL))
1358  return NULL;
1359 
1360  match->type = OF1X_MATCH_WLAN_DIRECTION;
1361  match->__tern = __init_utern8(value, mask);
1362 
1363  //Set fast validation flags
1364  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1365  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1366  if( mask != OF1X_1_BYTE_MASK )
1367  match->has_wildcard = true;
1368  else
1369  match->has_wildcard = false;
1370 
1371  //Initialize linked-list
1372  match->prev=match->next=NULL;
1373 
1374  return match;
1375 }
1376 of1x_match_t* of1x_init_wlan_address_1_match(uint64_t value, uint64_t mask){
1378 
1379  if(unlikely(match == NULL))
1380  return NULL;
1381 
1382  // Align to pipeline convention (NBO, lower memory address)
1383  value = HTONB64(OF1X_MAC_ALIGN(value));
1384  mask = HTONB64(OF1X_MAC_ALIGN(mask));
1385 
1386  match->type = OF1X_MATCH_WLAN_ADDRESS_1;
1387  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
1388 
1389  //Set fast validation flags
1390  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
1391  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1392  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK)
1393  match->has_wildcard = true;
1394  else
1395  match->has_wildcard = false;
1396 
1397  //Initialize linked-list
1398  match->prev=match->next=NULL;
1399 
1400  return match;
1401 }
1402 of1x_match_t* of1x_init_wlan_address_2_match(uint64_t value, uint64_t mask){
1404 
1405  if(unlikely(match == NULL))
1406  return NULL;
1407 
1408  // Align to pipeline convention (NBO, lower memory address)
1409  value = HTONB64(OF1X_MAC_ALIGN(value));
1410  mask = HTONB64(OF1X_MAC_ALIGN(mask));
1411 
1412  match->type = OF1X_MATCH_WLAN_ADDRESS_2;
1413  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
1414 
1415  //Set fast validation flags
1416  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
1417  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1418  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK)
1419  match->has_wildcard = true;
1420  else
1421  match->has_wildcard = false;
1422 
1423  //Initialize linked-list
1424  match->prev=match->next=NULL;
1425 
1426  return match;
1427 }
1428 of1x_match_t* of1x_init_wlan_address_3_match(uint64_t value, uint64_t mask){
1430 
1431  if(unlikely(match == NULL))
1432  return NULL;
1433 
1434  // Align to pipeline convention (NBO, lower memory address)
1435  value = HTONB64(OF1X_MAC_ALIGN(value));
1436  mask = HTONB64(OF1X_MAC_ALIGN(mask));
1437 
1438  match->type = OF1X_MATCH_WLAN_ADDRESS_3;
1439  match->__tern = __init_utern64(value&OF1X_48_BITS_MASK, mask&OF1X_48_BITS_MASK); //Enforce mask bits are always 00 for the first bits
1440 
1441  //Set fast validation flags
1442  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2
1443  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1444  if( (mask&OF1X_48_BITS_MASK) != OF1X_48_BITS_MASK)
1445  match->has_wildcard = true;
1446  else
1447  match->has_wildcard = false;
1448 
1449  //Initialize linked-list
1450  match->prev=match->next=NULL;
1451 
1452  return match;
1453 }
1454 //GRE
1457 
1458  if(unlikely(match == NULL))
1459  return NULL;
1460 
1461  value = HTONB16(value);
1462 
1463  match->type = OF1X_MATCH_GRE_VERSION;
1464  match->__tern = __init_utern16(value&OF1X_3_BITS_MASK,OF1X_3_BITS_MASK); //no wildcard
1465 
1466  //Set fast validation flags
1467  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1468  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1469  match->has_wildcard = false; //Not accepting wildcards
1470 
1471  //Initialize linked-list
1472  match->prev=match->next=NULL;
1473 
1474  return match;
1475 }
1478 
1479  if(unlikely(match == NULL))
1480  return NULL;
1481 
1482  value = HTONB16(value);
1483 
1484  match->type = OF1X_MATCH_GRE_PROT_TYPE;
1485  match->__tern = __init_utern16(value,OF1X_2_BYTE_MASK); //no wildcard
1486 
1487  //Set fast validation flags
1488  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1489  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1490  match->has_wildcard = false; //Not accepting wildcards
1491 
1492  //Initialize linked-list
1493  match->prev=match->next=NULL;
1494 
1495  return match;
1496 }
1499 
1500  if(unlikely(match == NULL))
1501  return NULL;
1502 
1503  // Align to pipeline convention (NBO, lower memory address)
1504  value = HTONB32(value);
1505 
1506  match->type = OF1X_MATCH_GRE_KEY;
1507  match->__tern = __init_utern32(value, OF1X_4_BYTE_MASK);
1508 
1509  //Set fast validation flags
1510  match->ver_req.min_ver = OF_VERSION_12; //First supported in OF1.2 (extensions)
1511  match->ver_req.max_ver = OF1X_MAX_VERSION; //No limitation on max
1512  match->has_wildcard = false;
1513 
1514  //Initialize linked-list
1515  match->prev=match->next=NULL;
1516 
1517  return match;
1518 }
1519 
1520 //Add more here...
1521 
1522 /* Instruction groups init and destroy */
1523 void __of1x_init_match_group(of1x_match_group_t* group){
1524 
1525  platform_memset(group,0,sizeof(of1x_match_group_t));
1526 
1527  //Set min max
1528  group->ver_req.min_ver = OF1X_MIN_VERSION;
1529  group->ver_req.max_ver = OF1X_MAX_VERSION;
1530 
1531  //OF1.0 full wildcard
1532  bitmap128_set(&group->of10_wildcard_bm, OF1X_MATCH_ETH_DST);
1533  bitmap128_set(&group->of10_wildcard_bm, OF1X_MATCH_ETH_SRC);
1534  bitmap128_set(&group->of10_wildcard_bm, OF1X_MATCH_NW_SRC);
1535  bitmap128_set(&group->of10_wildcard_bm, OF1X_MATCH_NW_DST);
1536 }
1537 
1538 void __of1x_destroy_match_group(of1x_match_group_t* group){
1539  of1x_match_t *match;
1540 
1541  if ( unlikely(group->head==NULL) )
1542  return;
1543 
1544  match = group->head;
1545 
1546  while (match){
1547  of1x_match_t *next = match->next;
1548  of1x_destroy_match(match);
1549  match = next;
1550  }
1551 
1552  group->head = NULL;
1553  group->tail = NULL;
1554 }
1555 
1556 
1557 
1558 void __of1x_match_group_push_back(of1x_match_group_t* group, of1x_match_t* match){
1559 
1560  if ( unlikely(group==NULL) || unlikely(match==NULL) )
1561  return;
1562 
1563  match->next = match->prev = NULL;
1564 
1565  if(!group->head){
1566  group->head = match;
1567  }else{
1568  match->prev = group->tail;
1569  group->tail->next = match;
1570  }
1571 
1572  //Deduce new tail and update validation flags and num of elements
1573  do{
1574  //Update fast validation flags (required versions)
1575  if(group->ver_req.min_ver < match->ver_req.min_ver)
1576  group->ver_req.min_ver = match->ver_req.min_ver;
1577  if(group->ver_req.max_ver > match->ver_req.max_ver)
1578  group->ver_req.max_ver = match->ver_req.max_ver;
1579 
1580  //Update matches
1581  bitmap128_set(&group->match_bm, match->type);
1582 
1583  if(!match->has_wildcard)
1584  bitmap128_unset(&group->of10_wildcard_bm, match->type);
1585  else
1586  bitmap128_set(&group->wildcard_bm, match->type);
1587 
1588  group->num_elements++;
1589 
1590  if(match->next == NULL)
1591  break;
1592  else
1593  match = match->next;
1594  }while(1);
1595 
1596  //Add new tail
1597  group->tail = match;
1598 
1599 }
1600 
1601 /*
1602 * Copy match to heap. Leaves next and prev pointers to NULL
1603 */
1604 of1x_match_t* __of1x_copy_match(of1x_match_t* match){
1605 
1607 
1608  if(!tmp)
1609  return tmp;
1610 
1611  //Copy contents
1612  *tmp = *match;
1613 
1614  //Initialize linked-list to null
1615  tmp->prev=tmp->next=NULL;
1616 
1617  //Create a whatever type utern and copy from the orignal tern
1618  tmp->__tern = __init_utern8(0x0, 0x0);
1619 
1620  if(!tmp->__tern)
1621  return NULL;
1622 
1623  *tmp->__tern = *match->__tern;
1624 
1625  return tmp;
1626 }
1627 
1628 /*
1629 * Whole (linked list) Match copy -> this should be deprecated in favour of the match group
1630 */
1631 of1x_match_t* __of1x_copy_matches(of1x_match_t* matches){
1632 
1633  of1x_match_t* prev, *curr, *it, *copy;
1634 
1635  if( unlikely(matches==NULL) )
1636  return NULL;
1637 
1638  for(prev=NULL,copy=NULL, it=matches; it; it = it->next){
1639 
1640  curr = __of1x_copy_match(it);
1641 
1642  if(!curr){
1643  //FIXME: attempt to delete previous
1644  return NULL;
1645  }
1646 
1647  //Set initial match
1648  if(!copy)
1649  copy = curr;
1650 
1651  if(prev)
1652  prev->next = curr;
1653 
1654  curr->prev = prev;
1655  prev = curr;
1656  }
1657 
1658  return copy;
1659 }
1660 
1661 
1662 
1663 /*
1664 * Try to find the largest common value among match1 and match2, being ALWAYS match2 with a more strict mask
1665 */
1666 of1x_match_t* __of1x_get_alike_match(of1x_match_t* match1, of1x_match_t* match2){
1667  utern_t* common_tern = NULL;
1668 
1669  if( match1->type != match2->type )
1670  return NULL;
1671 
1672  common_tern = __utern_get_alike(*match1->__tern,*match2->__tern);
1673 
1674  if(common_tern){
1676  match->__tern = common_tern;
1677  match->type = match1->type;
1678  match->next = NULL;
1679  match->prev = NULL;
1680  return match;
1681  }
1682  return NULL;
1683 }
1684 /*
1685 * Common destructor
1686 */
1688  __destroy_utern(match->__tern);
1689  platform_free_shared(match);
1690 }
1691 
1692 /*
1693 *
1694 * Matching routines...
1695 *
1696 */
1697 
1698 //Compare matches
1699 bool __of1x_equal_matches(of1x_match_t* match1, of1x_match_t* match2){
1700 
1701  if( match1->type != match2->type )
1702  return false;
1703 
1704  return __utern_equals(match1->__tern,match2->__tern);
1705 }
1706 
1707 //Finds out if sub_match is a submatch of match
1708 bool __of1x_is_submatch(of1x_match_t* sub_match, of1x_match_t* match){
1709 
1710  if( match->type != sub_match->type )
1711  return false;
1712 
1713  return __utern_is_contained(sub_match->__tern,match->__tern);
1714 }
1715 
1716 //Matches with mask (including matches that do not support)
1717 void __of1x_dump_matches(of1x_match_t* matches, bool raw_nbo){
1718  of1x_match_t* it;
1719  for(it=matches;it;it=it->next){
1720  switch(it->type){
1721  case OF1X_MATCH_IN_PORT: ROFL_PIPELINE_INFO_NO_PREFIX("[PORT_IN:%u], ", __of1x_get_match_val32(it, false, raw_nbo));
1722  break;
1723  case OF1X_MATCH_IN_PHY_PORT: ROFL_PIPELINE_INFO_NO_PREFIX("[PHY_PORT_IN:%u], ", __of1x_get_match_val32(it, false, raw_nbo));
1724  break;
1725 
1726  case OF1X_MATCH_METADATA: ROFL_PIPELINE_INFO_NO_PREFIX("[METADATA:0x%"PRIx64"|0x%"PRIx64"], ", __of1x_get_match_val64(it, false, raw_nbo), __of1x_get_match_val64(it, true, raw_nbo));
1727  break;
1728 
1729  case OF1X_MATCH_ETH_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[ETH_DST:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
1730  break;
1731  case OF1X_MATCH_ETH_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[ETH_SRC:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
1732  break;
1733  case OF1X_MATCH_ETH_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[ETH_TYPE:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
1734  break;
1735 
1736  case OF1X_MATCH_VLAN_VID: if(it->vlan_present == OF1X_MATCH_VLAN_NONE)
1737  ROFL_PIPELINE_INFO_NO_PREFIX("[NO_VLAN], ");
1738  else if(it->vlan_present == OF1X_MATCH_VLAN_ANY)
1739  ROFL_PIPELINE_INFO_NO_PREFIX("[ANY_VLAN], ");
1740  else
1741  ROFL_PIPELINE_INFO_NO_PREFIX("[VLAN_ID:%u|0x%x], ",__of1x_get_match_val16(it, false, raw_nbo),__of1x_get_match_val16(it, true, raw_nbo));
1742  break;
1743  case OF1X_MATCH_VLAN_PCP: ROFL_PIPELINE_INFO_NO_PREFIX("[VLAN_PCP:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
1744  break;
1745 
1746  case OF1X_MATCH_MPLS_LABEL: ROFL_PIPELINE_INFO_NO_PREFIX("[MPLS_LABEL:0x%x], ",__of1x_get_match_val32(it, false, raw_nbo));
1747  break;
1748  case OF1X_MATCH_MPLS_TC: ROFL_PIPELINE_INFO_NO_PREFIX("[MPLS_TC:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1749  break;
1750  case OF1X_MATCH_MPLS_BOS: ROFL_PIPELINE_INFO_NO_PREFIX("[MPLS_BOS:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1751  break;
1752 
1753  case OF1X_MATCH_ARP_OP: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_OPCODE:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
1754  break;
1755  case OF1X_MATCH_ARP_SHA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_SHA:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
1756  break;
1757  case OF1X_MATCH_ARP_SPA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_SPA:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1758  break;
1759  case OF1X_MATCH_ARP_THA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_THA:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
1760  break;
1761  case OF1X_MATCH_ARP_TPA: ROFL_PIPELINE_INFO_NO_PREFIX("[ARP_TPA:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1762  break;
1763 
1764  case OF1X_MATCH_NW_PROTO: ROFL_PIPELINE_INFO_NO_PREFIX("[NW_PROTO:%u|0x%x], ",__of1x_get_match_val8(it, false, raw_nbo),__of1x_get_match_val8(it, true, raw_nbo));
1765  break;
1766  case OF1X_MATCH_NW_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[NW_SRC:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1767  break;
1768  case OF1X_MATCH_NW_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[NW_DST:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1769  break;
1770 
1771  case OF1X_MATCH_IP_ECN: ROFL_PIPELINE_INFO_NO_PREFIX("[IP_ECN:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1772  break;
1773  case OF1X_MATCH_IP_DSCP: ROFL_PIPELINE_INFO_NO_PREFIX("[IP_DSCP:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1774  break;
1775  case OF1X_MATCH_IP_PROTO: ROFL_PIPELINE_INFO_NO_PREFIX("[IP_PROTO:%u|0x%x], ",__of1x_get_match_val8(it, false, raw_nbo),__of1x_get_match_val8(it, true, raw_nbo));
1776  break;
1777 
1778  case OF1X_MATCH_IPV4_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[IP4_SRC:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1779  break;
1780  case OF1X_MATCH_IPV4_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[IP4_DST:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1781  break;
1782 
1783  case OF1X_MATCH_TCP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[TCP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1784  break;
1785  case OF1X_MATCH_TCP_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[TCP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1786  break;
1787 
1788  case OF1X_MATCH_UDP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[UDP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1789  break;
1790  case OF1X_MATCH_UDP_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[UDP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1791  break;
1792 
1793  case OF1X_MATCH_SCTP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[SCTP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1794  break;
1795  case OF1X_MATCH_SCTP_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[SCTP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1796  break;
1797 
1798  //OF1.0 only
1799  case OF1X_MATCH_TP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX("[TP_SRC:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1800  break;
1801  case OF1X_MATCH_TP_DST: ROFL_PIPELINE_INFO_NO_PREFIX("[TP_DST:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1802  break;
1803 
1804 
1805  case OF1X_MATCH_ICMPV4_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV4_TYPE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
1806  break;
1807  case OF1X_MATCH_ICMPV4_CODE: ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV4_CODE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
1808  break;
1809 
1810  //IPv6
1811  case OF1X_MATCH_IPV6_SRC:
1812  {
1813  uint128__t value = __of1x_get_match_val128(it, false, raw_nbo);
1814  uint128__t mask = __of1x_get_match_val128(it, true, raw_nbo);
1815  (void)value;
1816  (void)mask;
1817  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_SRC:0x%lx:%lx|0x%lx:%lx], ",UINT128__T_HI(value),UINT128__T_LO(value),UINT128__T_HI(mask),UINT128__T_LO(mask));
1818  }
1819  break;
1820  case OF1X_MATCH_IPV6_DST:
1821  {
1822  uint128__t value = __of1x_get_match_val128(it, false, raw_nbo);
1823  uint128__t mask = __of1x_get_match_val128(it, true, raw_nbo);
1824  (void)value;
1825  (void)mask;
1826 
1827  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_DST:0x%lx:%lx|0x%lx:%lx], ",UINT128__T_HI(value),UINT128__T_LO(value),UINT128__T_HI(mask),UINT128__T_LO(mask));
1828  }
1829  break;
1830  case OF1X_MATCH_IPV6_FLABEL: ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_FLABEL:%lu], ",__of1x_get_match_val32(it, false, raw_nbo));
1831  break;
1832  case OF1X_MATCH_IPV6_ND_TARGET: {
1833  uint128__t value = __of1x_get_match_val128(it, false, raw_nbo);
1834  uint128__t mask = __of1x_get_match_val128(it, true, raw_nbo);
1835  (void)value;
1836  (void)mask;
1837 
1838  ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_ND_TARGET:0x%lx:%lx], ",UINT128__T_HI(value),UINT128__T_LO(mask));
1839  }
1840  break;
1841  case OF1X_MATCH_IPV6_ND_SLL: ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_ND_SLL:0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo));
1842  break;
1843  case OF1X_MATCH_IPV6_ND_TLL: ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_ND_TLL:0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo));
1844  break;
1845  case OF1X_MATCH_IPV6_EXTHDR: ROFL_PIPELINE_INFO_NO_PREFIX("[IPV6_EXTHDR:%lu|0x%lx], ",__of1x_get_match_val16(it, false, raw_nbo),__of1x_get_match_val16(it, true, raw_nbo));
1846  break;
1847  //ICMPv6
1848  case OF1X_MATCH_ICMPV6_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV6_TYPE:%lu], ",__of1x_get_match_val8(it, false, raw_nbo));
1849  break;
1850  case OF1X_MATCH_ICMPV6_CODE: ROFL_PIPELINE_INFO_NO_PREFIX("[ICMPV6_CODE:%lu], ",__of1x_get_match_val8(it, false, raw_nbo));
1851  break;
1852 
1853  //PBB
1854  case OF1X_MATCH_PBB_ISID: ROFL_PIPELINE_INFO_NO_PREFIX("[PBB_ISID:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1855  break;
1856  //TUNNEL ID
1857  case OF1X_MATCH_TUNNEL_ID: ROFL_PIPELINE_INFO_NO_PREFIX("[TUNNEL_ID:0x%"PRIx64"|0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo),__of1x_get_match_val64(it, true, raw_nbo));
1858  break;
1859 
1860  /* PPP/PPPoE related extensions */
1861  case OF1X_MATCH_PPPOE_CODE: ROFL_PIPELINE_INFO_NO_PREFIX("[PPPOE_CODE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
1862  break;
1863  case OF1X_MATCH_PPPOE_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[PPPOE_TYPE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
1864  break;
1865  case OF1X_MATCH_PPPOE_SID: ROFL_PIPELINE_INFO_NO_PREFIX("[PPPOE_SID:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1866  break;
1867 
1868  case OF1X_MATCH_PPP_PROT: ROFL_PIPELINE_INFO_NO_PREFIX("[PPP_PROT:%u] ",__of1x_get_match_val16(it, false, raw_nbo));
1869  break;
1870 
1871  /* GTP related extensions */
1872  case OF1X_MATCH_GTP_MSG_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[GTP_MSG_TYPE:%u], ",__of1x_get_match_val8(it, false, raw_nbo));
1873  break;
1874  case OF1X_MATCH_GTP_TEID: ROFL_PIPELINE_INFO_NO_PREFIX("[GTP_TEID:0x%x|0x%x], ",__of1x_get_match_val32(it, false, raw_nbo),__of1x_get_match_val32(it, true, raw_nbo));
1875  break;
1876 
1877  /* CAPWAP related extensions */
1878  case OF1X_MATCH_CAPWAP_WBID: ROFL_PIPELINE_INFO_NO_PREFIX("[CAPWAP_WBID:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1879  break;
1880  case OF1X_MATCH_CAPWAP_RID: ROFL_PIPELINE_INFO_NO_PREFIX("[CAPWAP_RID:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1881  break;
1882  case OF1X_MATCH_CAPWAP_FLAGS: ROFL_PIPELINE_INFO_NO_PREFIX("[CAPWAP_FLAGS:%u], ",__of1x_get_match_val16(it, false, raw_nbo));
1883  break;
1884 
1885  /* WLAN related extensions */
1886  case OF1X_MATCH_WLAN_FC: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_FC:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
1887  break;
1888  case OF1X_MATCH_WLAN_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_TYPE:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1889  break;
1890  case OF1X_MATCH_WLAN_SUBTYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_SUBTYPE:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1891  break;
1892  case OF1X_MATCH_WLAN_DIRECTION: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_DIRECTION:0x%x], ",__of1x_get_match_val8(it, false, raw_nbo));
1893  break;
1894  case OF1X_MATCH_WLAN_ADDRESS_1: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_ADDRESS_1:0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo));
1895  break;
1896  case OF1X_MATCH_WLAN_ADDRESS_2: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_ADDRESS_2:0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo));
1897  break;
1898  case OF1X_MATCH_WLAN_ADDRESS_3: ROFL_PIPELINE_INFO_NO_PREFIX("[WLAN_ADDRESS_3:0x%"PRIx64"], ",__of1x_get_match_val64(it, false, raw_nbo));
1899  break;
1900 
1901  /* GRE related extensions */
1902  case OF1X_MATCH_GRE_VERSION: ROFL_PIPELINE_INFO_NO_PREFIX("[GRE_VERSION:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
1903  break;
1904  case OF1X_MATCH_GRE_PROT_TYPE: ROFL_PIPELINE_INFO_NO_PREFIX("[GRE_PROT_TYPE:0x%x], ",__of1x_get_match_val16(it, false, raw_nbo));
1905  break;
1906  case OF1X_MATCH_GRE_KEY: ROFL_PIPELINE_INFO_NO_PREFIX("[GRE_KEY:0x%x], ",__of1x_get_match_val32(it, false, raw_nbo));
1907  break;
1908 
1909  case OF1X_MATCH_MAX: assert(0);
1910  break;
1911 
1912  //Add more here ...
1913  //Warning: NEVER add a default clause
1914  }
1915  }
1916 }
1917 
of1x_match_t * of1x_init_ip6_flabel_match(uint32_t value, uint32_t mask)
Create an IP6_FLABEL match.
Definition: of1x_match.c:648
of1x_match_t * of1x_init_tunnel_id_match(uint64_t value, uint64_t mask)
Create an TUNNEL_ID match.
Definition: of1x_match.c:1055
of1x_match_t * of1x_init_tp_dst_match(uint16_t value)
Create an TP_DST match (TCP/UDP), OF1.0 ONLY!
Definition: of1x_match.c:966
of1x_match_t * of1x_init_arp_sha_match(uint64_t value, uint64_t mask)
Create an ARP_SHA match.
Definition: of1x_match.c:326
of1x_match_t * of1x_init_capwap_wbid_match(uint8_t value, uint8_t mask)
Create a CAPWAP_WBID match.
Definition: of1x_match.c:1213
of1x_match_t * of1x_init_vlan_vid_match(uint16_t value, uint16_t mask, enum of1x_vlan_present vlan_present)
Create an VLAN_VID match according to 1.2 semantics (13th bit is a flag)
Definition: of1x_match.c:159
of1x_match_t * of1x_init_pppoe_code_match(uint8_t value)
Create an PPPOE_CODE match.
Definition: of1x_match.c:1085
of1x_match_t * of1x_init_mpls_label_match(uint32_t value)
Create an MPLS_LABEL match.
Definition: of1x_match.c:212
of1x_match_t * of1x_init_ip4_dst_match(uint32_t value, uint32_t mask)
Create an IP4_DST match.
Definition: of1x_match.c:505
of1x_match_t * of1x_init_gre_version_match(uint16_t value)
Create a GRE_VERSION match.
Definition: of1x_match.c:1455
of1x_match_t * of1x_init_wlan_address_2_match(uint64_t value, uint64_t mask)
Create an WLAN_ADDRESS_2 match.
Definition: of1x_match.c:1402
of1x_match_t * of1x_init_capwap_rid_match(uint8_t value, uint8_t mask)
Create a CAPWAP_RID match.
Definition: of1x_match.c:1235
of1x_match_t * of1x_init_port_in_phy_match(uint32_t value)
Create an PHY_PORT_IN match.
Definition: of1x_match.c:38
of1x_match_t * of1x_init_ip6_src_match(uint128__t value, uint128__t mask)
Create an IP6_SRC match.
Definition: of1x_match.c:594
of1x_match_t * of1x_init_eth_type_match(uint16_t value)
Create an ETH_TYPE match.
Definition: of1x_match.c:136
of1x_match_t * of1x_init_eth_dst_match(uint64_t value, uint64_t mask)
Create an ETH_DST match.
Definition: of1x_match.c:83
of1x_match_t * of1x_init_gtp_msg_type_match(uint8_t value)
Create an PPP_PROTO match.
Definition: of1x_match.c:1168
of1x_match_t * of1x_init_gtp_teid_match(uint32_t value, uint32_t mask)
Create an PPP_PROTO match.
Definition: of1x_match.c:1187
void * platform_memset(void *src, int c, size_t length)
Sets 'c' to the whole chunk of memory.
of1x_match_t * of1x_init_mpls_tc_match(uint8_t value)
Create an MPLS_TC match.
Definition: of1x_match.c:234
of1x_match_t * of1x_init_wlan_subtype_match(uint8_t value, uint8_t mask)
Create a WLAN_SUBTYPE match.
Definition: of1x_match.c:1332
of1x_match_t * of1x_init_wlan_fc_match(uint16_t value, uint16_t mask)
Create a WLAN_FC match.
Definition: of1x_match.c:1284
of1x_match_t * of1x_init_icmpv4_type_match(uint8_t value)
Create an ICMPv4_TYPE match.
Definition: of1x_match.c:989
of1x_match_t * of1x_init_vlan_pcp_match(uint8_t value)
Create an VLAN_PCP match.
Definition: of1x_match.c:188
of1x_match_t * of1x_init_icmpv6_code_match(uint8_t value)
Create an ICMPV6_CODE match.
Definition: of1x_match.c:784
of1x_match_t * of1x_init_mpls_bos_match(uint8_t value)
Create an MPLS_BOS match.
Definition: of1x_match.c:256
void of1x_destroy_match(of1x_match_t *match)
Destroys whichever match previously created using of1x_init_match_*()
Definition: of1x_match.c:1687
of1x_match_t * of1x_init_capwap_flags_match(uint16_t value, uint16_t mask)
Create a CAPWAP_FLAGS match.
Definition: of1x_match.c:1257
of1x_match_t * of1x_init_arp_tpa_match(uint32_t value, uint32_t mask)
Create an ARP_TPA match.
Definition: of1x_match.c:352
of1x_match_t * of1x_init_ip_ecn_match(uint8_t value)
Create an IPC_ECN match.
Definition: of1x_match.c:573
of1x_match_t * of1x_init_nw_dst_match(uint32_t value, uint32_t mask)
Create an NW_DST match (IP/ARP), OF1.0 ONLY!
Definition: of1x_match.c:451
of1x_match_t * of1x_init_port_in_match(uint32_t value)
Create an PORT_IN match.
Definition: of1x_match.c:18
of1x_match_t * of1x_init_arp_spa_match(uint32_t value, uint32_t mask)
Create an ARP_SPA match.
Definition: of1x_match.c:378
of1x_match_t * of1x_init_ip_dscp_match(uint8_t value)
Create an IP_DSCP match.
Definition: of1x_match.c:550
#define OF1X_MAC_ALIGN(x)
ALIGNING FUNCTIONS FOR THE PROTOCOL VALUES ///.
Definition: of1x_utils.h:166
of1x_match_t * of1x_init_gre_prot_type_match(uint16_t value)
Create a GRE_PROT_TYPE match.
Definition: of1x_match.c:1476
of1x_match_t * of1x_init_arp_tha_match(uint64_t value, uint64_t mask)
Create an ARP_THA match.
Definition: of1x_match.c:299
of1x_match_t * of1x_init_gre_key_match(uint32_t value)
Create a GRE_KEY match.
Definition: of1x_match.c:1497
of1x_match_t * of1x_init_wlan_direction_match(uint8_t value, uint8_t mask)
Create a WLAN_DIRECTION match.
Definition: of1x_match.c:1354
of1x_match_t * of1x_init_nw_proto_match(uint8_t value)
Create an NW_PROTO match, OF1.0 ONLY!
Definition: of1x_match.c:406
of1x_match_t * of1x_init_wlan_address_3_match(uint64_t value, uint64_t mask)
Create an WLAN_ADDRESS_3 match.
Definition: of1x_match.c:1428
of1x_match_t * of1x_init_wlan_address_1_match(uint64_t value, uint64_t mask)
Create an WLAN_ADDRESS_1 match.
Definition: of1x_match.c:1376
of1x_match_t * of1x_init_arp_opcode_match(uint16_t value)
Create an ARP_OPCODE match.
Definition: of1x_match.c:277
of1x_match_t * of1x_init_sctp_src_match(uint16_t value)
Create an SCTP_SRC match.
Definition: of1x_match.c:897
of1x_match_t * of1x_init_ip4_src_match(uint32_t value, uint32_t mask)
Create an IP4_SRC match.
Definition: of1x_match.c:479
of1x_match_t * of1x_init_ip6_dst_match(uint128__t value, uint128__t mask)
Create an IP6_DST match.
Definition: of1x_match.c:621
of1x_match_t * of1x_init_ip6_nd_tll_match(uint64_t value)
Create an IP6_ND_TLL match.
Definition: of1x_match.c:717
of1x_match_t * of1x_init_icmpv4_code_match(uint8_t value)
Create an ICMPv4_CODE match.
Definition: of1x_match.c:1008
of1x_match_t * of1x_init_tp_src_match(uint16_t value)
Create an TP_SRC match (TCP/UDP), OF1.0 ONLY!
Definition: of1x_match.c:944
of1x_match_t * of1x_init_ip6_exthdr_match(uint16_t value, uint16_t mask)
Create an IP6_EXTHDR match.
Definition: of1x_match.c:739
of1x_match_t * of1x_init_tcp_dst_match(uint16_t value)
Create an TCP_DST match.
Definition: of1x_match.c:828
of1x_match_t * of1x_init_pppoe_type_match(uint8_t value)
Create an PPPOE_TYPE match.
Definition: of1x_match.c:1104
OpenFlow v1.0, 1.2 and 1.3.2 matches.
of1x_match_t * of1x_init_ip6_nd_target_match(uint128__t value)
Create an IP6_ND_TARGET match.
Definition: of1x_match.c:671
of1x_match_t * of1x_init_sctp_dst_match(uint16_t value)
Create an SCTP_DST match.
Definition: of1x_match.c:920
of1x_match_t * of1x_init_metadata_match(uint64_t value, uint64_t mask)
Create an METADATA match.
Definition: of1x_match.c:59
of1x_match_t * of1x_init_udp_src_match(uint16_t value)
Create an UDP_SRC match.
Definition: of1x_match.c:851
of1x_match_t * of1x_init_wlan_type_match(uint8_t value, uint8_t mask)
Create a WLAN_TYPE match.
Definition: of1x_match.c:1310
void * platform_malloc_shared(size_t length)
Allocates a chunk of dynamic memory of size length, which must be accessible (R/W) for all the thread...
of1x_match_t * of1x_init_udp_dst_match(uint16_t value)
Create an UDP_DST match.
Definition: of1x_match.c:873
of1x_match_t * of1x_init_ip6_nd_sll_match(uint64_t value)
Create an IP6_ND_SLL match.
Definition: of1x_match.c:695
void platform_free_shared(void *data)
Frees a chunk of dynamic memory previously allocated with platform_malloc_shared().
of1x_match_t * of1x_init_pppoe_session_match(uint16_t value)
Create an PPPOE_SESSION match.
Definition: of1x_match.c:1123
of1x_match_t * of1x_init_nw_src_match(uint32_t value, uint32_t mask)
Create an NW_SRC match (IP/ARP), OF1.0 ONLY!
Definition: of1x_match.c:425
of1x_match_t * of1x_init_ip_proto_match(uint8_t value)
Create an IP_PROTO match.
Definition: of1x_match.c:531
of1x_match_t * of1x_init_ppp_prot_match(uint16_t value)
Create an PPP_PROTO match.
Definition: of1x_match.c:1145
of1x_match_t * of1x_init_icmpv6_type_match(uint8_t value)
Create an ICMPV6_TYPE match.
Definition: of1x_match.c:765
of1x_match_t * of1x_init_tcp_src_match(uint16_t value)
Create an TCP_SRC match.
Definition: of1x_match.c:805
static void bitmap128_unset(bitmap128_t *bitmap, unsigned int pos)
Unset(zero) a bit in the 128bit bitmap.
Definition: bitmap.h:65
static void bitmap128_set(bitmap128_t *bitmap, unsigned int pos)
Set a bit in the 128bit bitmap.
Definition: bitmap.h:55
of1x_match_t * of1x_init_eth_src_match(uint64_t value, uint64_t mask)
Create an ETH_SRC match.
Definition: of1x_match.c:110