2 #include "../../../common/datapacket.h"
3 #include "../../../common/protocol_constants.h"
8 #include "../../../common/packet_matches.h"
9 #include "../../../physical_switch.h"
10 #include "../../../util/logging.h"
11 #include "../../../platform/likely.h"
12 #include "../../../platform/memory.h"
13 #include "../of1x_async_events_hooks.h"
25 if( unlikely(type==OF1X_AT_NO_ACTION) )
30 if( unlikely(action==NULL) )
37 action->ver_req.min_ver = OF1X_MIN_VERSION;
38 action->ver_req.max_ver = OF1X_MAX_VERSION;
41 UINT128__T_HI(action->__field.u128) = UINT128__T_LO(action->__field.u128) = 0x0ULL;
48 case OF1X_AT_SET_FIELD_IPV6_ND_TARGET:
49 case OF1X_AT_SET_FIELD_IPV6_SRC:
50 case OF1X_AT_SET_FIELD_IPV6_DST:{
53 action->__field.u128 = tmp;
54 action->ver_req.min_ver = OF_VERSION_12;
58 case OF1X_AT_SET_FIELD_TUNNEL_ID:
59 action->__field.u64 = field.u64&OF1X_8_BYTE_MASK;
60 action->ver_req.min_ver = OF_VERSION_13;
64 case OF1X_AT_SET_FIELD_IPV6_ND_SLL:
66 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
67 action->ver_req.min_ver = OF_VERSION_12;
69 case OF1X_AT_SET_FIELD_IPV6_ND_TLL:
71 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
72 action->ver_req.min_ver = OF_VERSION_12;
74 case OF1X_AT_SET_FIELD_ETH_DST:
76 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
78 case OF1X_AT_SET_FIELD_ETH_SRC:
80 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
82 case OF1X_AT_SET_FIELD_ARP_SHA:
84 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
85 action->ver_req.min_ver = OF_VERSION_12;
87 case OF1X_AT_SET_FIELD_ARP_THA:
89 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
90 action->ver_req.min_ver = OF_VERSION_12;
93 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_1:
94 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_2:
95 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_3:
97 action->__field.u64 = field.u64&OF1X_6_BYTE_MASK;
98 action->ver_req.min_ver = OF_VERSION_12;
103 case OF1X_AT_SET_FIELD_NW_DST:
104 action->ver_req.min_ver = OF_VERSION_10;
105 action->ver_req.max_ver = OF_VERSION_10;
106 case OF1X_AT_SET_FIELD_IPV4_DST:
107 field.u32 = HTONB32(field.u32);
108 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
110 case OF1X_AT_SET_FIELD_NW_SRC:
111 action->ver_req.min_ver = OF_VERSION_10;
112 action->ver_req.max_ver = OF_VERSION_10;
113 case OF1X_AT_SET_FIELD_IPV4_SRC:
114 field.u32 = HTONB32(field.u32);
115 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
117 case OF1X_AT_SET_FIELD_ARP_SPA:
118 field.u32 = HTONB32(field.u32);
119 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
120 action->ver_req.min_ver = OF_VERSION_10;
122 case OF1X_AT_SET_FIELD_ARP_TPA:
123 field.u32 = HTONB32(field.u32);
124 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
125 action->ver_req.min_ver = OF_VERSION_10;
128 action->send_len = output_send_len;
129 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
132 case OF1X_AT_SET_FIELD_GTP_TEID:
133 field.u32 = HTONB32(field.u32);
134 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
135 action->ver_req.min_ver = OF_VERSION_12;
137 case OF1X_AT_SET_FIELD_GRE_KEY:
138 field.u32 = HTONB32(field.u32);
139 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
140 action->ver_req.min_ver = OF_VERSION_12;
145 case OF1X_AT_SET_FIELD_PBB_ISID:
147 action->__field.u32 = field.u32&OF1X_3_BYTE_MASK;
148 action->ver_req.min_ver = OF_VERSION_13;
152 case OF1X_AT_SET_FIELD_IPV6_FLABEL:
153 field.u32 = HTONB32(OF1X_IP6_FLABEL_ALIGN(field.u32));
154 action->__field.u32 = field.u32&OF1X_20_BITS_IPV6_FLABEL_MASK;
155 action->ver_req.min_ver = OF_VERSION_12;
157 case OF1X_AT_SET_FIELD_MPLS_LABEL:
158 field.u32 = HTONB32(OF1X_MPLS_LABEL_ALIGN(field.u32));
159 action->__field.u32 = field.u32&OF1X_20_BITS_MASK;
160 action->ver_req.min_ver = OF_VERSION_12;
164 case OF1X_AT_SET_FIELD_ETH_TYPE:
165 field.u16 = HTONB16(field.u16);
166 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
168 case OF1X_AT_SET_FIELD_ARP_OPCODE:
169 field.u16 = HTONB16(field.u16);
170 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
171 action->ver_req.min_ver = OF_VERSION_10;
173 case OF1X_AT_SET_FIELD_TP_SRC:
174 field.u16 = HTONB16(field.u16);
175 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
176 action->ver_req.min_ver = OF_VERSION_10;
177 action->ver_req.max_ver = OF_VERSION_10;
179 case OF1X_AT_SET_FIELD_TP_DST:
180 field.u16 = HTONB16(field.u16);
181 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
182 action->ver_req.min_ver = OF_VERSION_10;
183 action->ver_req.max_ver = OF_VERSION_10;
185 case OF1X_AT_SET_FIELD_TCP_SRC:
186 field.u16 = HTONB16(field.u16);
187 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
188 action->ver_req.min_ver = OF_VERSION_12;
190 case OF1X_AT_SET_FIELD_TCP_DST:
191 field.u16 = HTONB16(field.u16);
192 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
193 action->ver_req.min_ver = OF_VERSION_12;
195 case OF1X_AT_SET_FIELD_UDP_SRC:
196 field.u16 = HTONB16(field.u16);
197 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
198 action->ver_req.min_ver = OF_VERSION_12;
200 case OF1X_AT_SET_FIELD_UDP_DST:
201 field.u16 = HTONB16(field.u16);
202 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
203 action->ver_req.min_ver = OF_VERSION_12;
205 case OF1X_AT_SET_FIELD_SCTP_SRC:
206 field.u16 = HTONB16(field.u16);
207 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
208 action->ver_req.min_ver = OF_VERSION_12;
210 case OF1X_AT_SET_FIELD_SCTP_DST:
211 field.u16 = HTONB16(field.u16);
212 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
213 action->ver_req.min_ver = OF_VERSION_12;
216 case OF1X_AT_SET_FIELD_PPPOE_SID:
217 field.u16 = HTONB16(field.u16);
218 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
219 action->ver_req.min_ver = OF_VERSION_12;
221 case OF1X_AT_SET_FIELD_PPP_PROT:
222 field.u16 = HTONB16(field.u16);
223 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
224 action->ver_req.min_ver = OF_VERSION_12;
226 case OF1X_AT_SET_FIELD_CAPWAP_FLAGS:
227 field.u16 = HTONB16(field.u16);
228 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
229 action->ver_req.min_ver = OF_VERSION_12;
231 case OF1X_AT_SET_FIELD_WLAN_FC:
232 field.u16 = HTONB16(field.u16);
233 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
234 action->ver_req.min_ver = OF_VERSION_12;
236 case OF1X_AT_SET_FIELD_GRE_VERSION:
237 field.u16 = HTONB16(field.u16);
238 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
239 action->ver_req.min_ver = OF_VERSION_12;
241 case OF1X_AT_SET_FIELD_GRE_PROT_TYPE:
242 field.u16 = HTONB16(field.u16);
243 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
244 action->ver_req.min_ver = OF_VERSION_12;
248 case OF1X_AT_POP_MPLS:
249 field.u16 = HTONB16(field.u16);
250 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
251 action->ver_req.min_ver = OF_VERSION_12;
253 case OF1X_AT_POP_PPPOE:
254 field.u16 = HTONB16(field.u16);
255 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
256 action->ver_req.min_ver = OF_VERSION_12;
258 case OF1X_AT_POP_PBB:
259 field.u16 = HTONB16(field.u16);
260 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
261 action->ver_req.min_ver = OF_VERSION_13;
264 case OF1X_AT_POP_GRE:
265 field.u16 = HTONB16(field.u16);
266 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
267 action->ver_req.min_ver = OF_VERSION_12;
269 case OF1X_AT_POP_WLAN:
270 field.u16 = HTONB16(field.u16);
271 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
272 action->ver_req.min_ver = OF_VERSION_12;
274 case OF1X_AT_POP_GTP:
275 field.u16 = HTONB16(field.u16);
276 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
277 action->ver_req.min_ver = OF_VERSION_12;
279 case OF1X_AT_POP_CAPWAP:
280 field.u16 = HTONB16(field.u16);
281 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
282 action->ver_req.min_ver = OF_VERSION_12;
284 case OF1X_AT_PUSH_GTP:
285 field.u16 = HTONB16(field.u16);
286 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
287 action->ver_req.min_ver = OF_VERSION_12;
289 case OF1X_AT_PUSH_CAPWAP:
290 field.u16 = HTONB16(field.u16);
291 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
292 action->ver_req.min_ver = OF_VERSION_12;
294 case OF1X_AT_PUSH_WLAN:
295 field.u16 = HTONB16(field.u16);
296 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
297 action->ver_req.min_ver = OF_VERSION_12;
299 case OF1X_AT_PUSH_GRE:
300 field.u16 = HTONB16(field.u16);
301 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
302 action->ver_req.min_ver = OF_VERSION_12;
305 case OF1X_AT_PUSH_PPPOE:
306 field.u16 = HTONB16(field.u16);
307 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
308 action->ver_req.min_ver = OF_VERSION_12;
310 case OF1X_AT_PUSH_MPLS:
311 field.u16 = HTONB16(field.u16);
312 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
313 action->ver_req.min_ver = OF_VERSION_12;
315 case OF1X_AT_PUSH_VLAN:
316 field.u16 = HTONB16(field.u16);
317 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
318 action->ver_req.min_ver = OF_VERSION_12;
320 case OF1X_AT_PUSH_PBB:
321 field.u16 = HTONB16(field.u16);
322 action->__field.u16 = field.u16&OF1X_2_BYTE_MASK;
323 action->ver_req.min_ver = OF_VERSION_13;
328 case OF1X_AT_SET_FIELD_VLAN_VID:
329 field.u16 = HTONB16(field.u16);
330 action->__field.u16 = field.u16&OF1X_12_BITS_MASK;
335 case OF1X_AT_SET_FIELD_IPV6_EXTHDR:
337 action->__field.u16 = field.u16&OF1X_9_BITS_MASK;
338 action->ver_req.min_ver = OF_VERSION_13;
342 case OF1X_AT_SET_FIELD_NW_PROTO:
343 action->ver_req.min_ver = OF_VERSION_10;
344 action->ver_req.max_ver = OF_VERSION_10;
345 action->__field.u8 = field.u8&OF1X_1_BYTE_MASK;
347 case OF1X_AT_SET_FIELD_ICMPV6_TYPE:
348 case OF1X_AT_SET_FIELD_ICMPV6_CODE:
349 case OF1X_AT_SET_FIELD_PPPOE_CODE:
350 case OF1X_AT_SET_FIELD_PPPOE_TYPE:
351 case OF1X_AT_SET_MPLS_TTL:
352 case OF1X_AT_SET_NW_TTL:
353 case OF1X_AT_SET_FIELD_IP_PROTO:
354 case OF1X_AT_SET_FIELD_ICMPV4_TYPE:
355 case OF1X_AT_SET_FIELD_ICMPV4_CODE:
356 action->__field.u8 = field.u8&OF1X_1_BYTE_MASK;
357 action->ver_req.min_ver = OF_VERSION_10;
360 case OF1X_AT_SET_FIELD_GTP_MSG_TYPE:
361 case OF1X_AT_SET_FIELD_CAPWAP_WBID:
362 case OF1X_AT_SET_FIELD_CAPWAP_RID:
363 case OF1X_AT_SET_FIELD_WLAN_TYPE:
364 case OF1X_AT_SET_FIELD_WLAN_SUBTYPE:
365 case OF1X_AT_SET_FIELD_WLAN_DIRECTION:
367 action->__field.u8 = field.u8&OF1X_1_BYTE_MASK;
368 action->ver_req.min_ver = OF_VERSION_12;
372 case OF1X_AT_SET_FIELD_IP_DSCP:
373 field.u8 = OF1X_IP_DSCP_ALIGN(field.u8);
374 action->__field.u8 = field.u8&OF1X_6MSBITS_MASK;
378 case OF1X_AT_SET_FIELD_VLAN_PCP:
379 field.u8 = OF1X_VLAN_PCP_ALIGN(field.u8);
380 action->__field.u8 = field.u8&OF1X_3MSBITS_MASK;
383 case OF1X_AT_SET_FIELD_MPLS_TC:
384 field.u8 = OF1X_MPLS_TC_ALIGN(field.u8);
385 action->__field.u8 = field.u8&OF1X_BITS_12AND3_MASK;
386 action->ver_req.min_ver = OF_VERSION_12;
390 case OF1X_AT_SET_FIELD_IP_ECN:
391 action->__field.u8 = field.u8&OF1X_2LSBITS_MASK;
392 action->ver_req.min_ver = OF_VERSION_12;
394 case OF1X_AT_SET_QUEUE:
395 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
396 action->ver_req.min_ver = OF_VERSION_10;
399 action->__field.u32 = field.u32&OF1X_4_BYTE_MASK;
400 action->ver_req.min_ver = OF_VERSION_12;
405 case OF1X_AT_SET_FIELD_MPLS_BOS:
406 action->__field.u8 = field.u8&OF1X_BIT0_MASK;
407 action->ver_req.min_ver = OF_VERSION_13;
411 case OF1X_AT_POP_VLAN:
412 action->__field.u64 = 0x0;
415 case OF1X_AT_COPY_TTL_IN:
416 case OF1X_AT_COPY_TTL_OUT:
417 case OF1X_AT_DEC_NW_TTL:
418 case OF1X_AT_DEC_MPLS_TTL:
419 case OF1X_AT_EXPERIMENTER:
420 action->__field.u64 = 0x0;
421 action->ver_req.min_ver = OF_VERSION_12;
425 case OF1X_AT_NO_ACTION:
427 action->__field.u64 = 0x0;
442 unsigned int number_of_actions=0, number_of_output_actions=0;
447 if( unlikely(action_group==NULL) )
451 action_group->head = actions;
453 for(;actions;actions=actions->next, number_of_actions++){
455 if(actions->type == OF1X_AT_OUTPUT )
456 number_of_output_actions++;
459 action_group->tail = actions;
464 action_group->head = NULL;
465 action_group->tail = NULL;
468 action_group->num_of_actions = number_of_actions;
469 action_group->num_of_output_actions = number_of_output_actions;
472 action_group->ver_req.min_ver = OF1X_MIN_VERSION;
473 action_group->ver_req.max_ver = OF1X_MAX_VERSION;
475 action_group->has_output_table =
false;
484 if( unlikely(group==NULL) )
487 for(it=group->head;it;it=next){
497 if( unlikely(action==NULL) || action->type >= OF1X_AT_NUMBER ){
503 if(action->type == OF1X_AT_OUTPUT && action->__field.u32 == OF1X_PORT_TABLE){
505 if(unlikely(group->has_output_table ==
true)){
506 ROFL_PIPELINE_ERR(
"Trying to add an action OUTPUT to port TABLE to action group(%p) when there is already one. Ignoring...", group);
510 group->has_output_table =
true;
514 group->head = action;
516 group->tail->next = action;
519 group->tail = action;
522 group->num_of_actions++;
533 if(group->ver_req.min_ver < action->ver_req.min_ver)
534 group->ver_req.min_ver = action->ver_req.min_ver;
535 if(group->ver_req.max_ver > action->ver_req.max_ver)
536 group->ver_req.max_ver = action->ver_req.max_ver;
546 if( unlikely(write_actions==NULL) )
552 for(i=0;i<OF1X_AT_NUMBER;i++)
556 write_actions->num_of_actions = 0;
557 write_actions->num_of_output_actions = 0;
560 write_actions->ver_req.min_ver = OF1X_MIN_VERSION;
561 write_actions->ver_req.max_ver = OF1X_MAX_VERSION;
563 return write_actions;
572 if( unlikely(write_actions==NULL) || action->type >= OF1X_AT_NUMBER ){
578 if(action->type == OF1X_AT_OUTPUT && action->__field.u32 == OF1X_PORT_TABLE)
582 write_actions->actions[action->type].__field = action->__field;
583 write_actions->actions[action->type].send_len = action->send_len;
586 write_actions->num_of_actions++;
598 if(write_actions->ver_req.min_ver < action->ver_req.min_ver)
599 write_actions->ver_req.min_ver = action->ver_req.min_ver;
600 if(write_actions->ver_req.max_ver > action->ver_req.max_ver)
601 write_actions->ver_req.max_ver = action->ver_req.max_ver;
630 __of1x_destroy_write_actions(old_group);
638 if( unlikely(write_actions==NULL))
648 if( unlikely(apply_actions_group==NULL) )
651 for(it=apply_actions_group->head; it; it=it->next){
653 if(type != OF1X_AT_GROUP){
655 return (it->type == type) && (value != 0x0 && it->__field.u64 == value);
658 return (it->type == type) && (it->__field.u64 == value);
671 if( unlikely(copy==NULL) )
684 if( unlikely(origin==NULL) )
690 if( unlikely(copy==NULL) )
693 copy->head = copy->tail = NULL;
694 copy->num_of_actions = origin->num_of_actions;
695 copy->num_of_output_actions = origin->num_of_output_actions;
698 for(it=origin->head;it;it=it->next){
701 act = __of1x_copy_packet_action(it);
703 if(unlikely(act == NULL)){
713 copy->tail->next = act;
726 if( unlikely(origin==NULL) )
731 if( unlikely(copy==NULL) )
743 ROFL_PIPELINE_INFO_NO_PREFIX(
"<");
744 switch(action->type){
745 case OF1X_AT_NO_ACTION:
748 case OF1X_AT_COPY_TTL_IN: ROFL_PIPELINE_INFO_NO_PREFIX(
"TTL_IN");
751 case OF1X_AT_POP_VLAN:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_VLAN");
753 case OF1X_AT_POP_MPLS:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_MPLS");
755 case OF1X_AT_POP_PPPOE:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_PPPOE");
758 case OF1X_AT_PUSH_PPPOE:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_PPPOE");
760 case OF1X_AT_PUSH_MPLS:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_MPLS");
762 case OF1X_AT_PUSH_VLAN:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_VLAN");
765 case OF1X_AT_COPY_TTL_OUT:ROFL_PIPELINE_INFO_NO_PREFIX(
"COPY_TTL_OUT");
768 case OF1X_AT_DEC_NW_TTL:ROFL_PIPELINE_INFO_NO_PREFIX(
"DEC_NW_TTL");
770 case OF1X_AT_DEC_MPLS_TTL:ROFL_PIPELINE_INFO_NO_PREFIX(
"DEC_MPLS_TTL");
773 case OF1X_AT_SET_MPLS_TTL:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_MPLS_TTL: %u", __of1x_get_packet_action_field8(action, raw_nbo));
775 case OF1X_AT_SET_NW_TTL:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_NW_TTL: %u", __of1x_get_packet_action_field8(action, raw_nbo));
778 case OF1X_AT_SET_QUEUE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_QUEUE: %u", __of1x_get_packet_action_field32(action, raw_nbo));
781 case OF1X_AT_SET_FIELD_ETH_DST: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ETH_DST: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
783 case OF1X_AT_SET_FIELD_ETH_SRC: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ETH_SRC: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
785 case OF1X_AT_SET_FIELD_ETH_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ETH_TYPE: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
788 case OF1X_AT_SET_FIELD_VLAN_VID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_VLAN_VID: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
790 case OF1X_AT_SET_FIELD_VLAN_PCP:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_VLAN_PCP: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
793 case OF1X_AT_SET_FIELD_ARP_OPCODE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ARP_OPCODE: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
795 case OF1X_AT_SET_FIELD_ARP_SHA: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ARP_SHA: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
797 case OF1X_AT_SET_FIELD_ARP_SPA: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ARP_SPA: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
799 case OF1X_AT_SET_FIELD_ARP_THA: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ARP_THA: 0x%"PRIx64, __of1x_get_packet_action_field64(action, raw_nbo));
801 case OF1X_AT_SET_FIELD_ARP_TPA: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ARP_TPA: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
805 case OF1X_AT_SET_FIELD_NW_PROTO: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_NW_PROTO: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
807 case OF1X_AT_SET_FIELD_NW_SRC: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_NW_SRC: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
809 case OF1X_AT_SET_FIELD_NW_DST: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_NW_DST: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
813 case OF1X_AT_SET_FIELD_IP_DSCP: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IP_DSCP: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
815 case OF1X_AT_SET_FIELD_IP_ECN: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IP_ECN: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
818 case OF1X_AT_SET_FIELD_IP_PROTO:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IP_PROTO: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
821 case OF1X_AT_SET_FIELD_IPV4_SRC:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV4_SRC: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
823 case OF1X_AT_SET_FIELD_IPV4_DST:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV4_DST: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
827 case OF1X_AT_SET_FIELD_TP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_TP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
829 case OF1X_AT_SET_FIELD_TP_DST: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_TP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
832 case OF1X_AT_SET_FIELD_TCP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_TCP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
834 case OF1X_AT_SET_FIELD_TCP_DST: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_TCP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
837 case OF1X_AT_SET_FIELD_UDP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_UDP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
839 case OF1X_AT_SET_FIELD_UDP_DST: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_UDP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
841 case OF1X_AT_SET_FIELD_SCTP_SRC: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_SCTP_SRC: %u", __of1x_get_packet_action_field16(action, raw_nbo));
843 case OF1X_AT_SET_FIELD_SCTP_DST: ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_SCTP_DST: %u", __of1x_get_packet_action_field16(action, raw_nbo));
846 case OF1X_AT_SET_FIELD_ICMPV4_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ICMPV4_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
848 case OF1X_AT_SET_FIELD_ICMPV4_CODE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ICMPV4_CODE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
851 case OF1X_AT_SET_FIELD_MPLS_LABEL:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_MPLS_LABEL: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
853 case OF1X_AT_SET_FIELD_MPLS_TC:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_MPLS_TC: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
855 case OF1X_AT_SET_FIELD_MPLS_BOS:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_MPLS_BOS: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
858 case OF1X_AT_SET_FIELD_PPPOE_CODE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_PPPOE_CODE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
860 case OF1X_AT_SET_FIELD_PPPOE_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_PPPOE_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
862 case OF1X_AT_SET_FIELD_PPPOE_SID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_PPPOE_SID: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
865 case OF1X_AT_SET_FIELD_PPP_PROT:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_PPP_PROT: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
868 case OF1X_AT_SET_FIELD_IPV6_SRC:
870 uint128__t addr = __of1x_get_packet_action_field128(action, raw_nbo);
872 COND_NTOHB128(raw_nbo,addr);
873 ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_SRC: 0x%lx %lx",UINT128__T_HI(addr),UINT128__T_LO(addr));
876 case OF1X_AT_SET_FIELD_IPV6_DST:
878 uint128__t addr = __of1x_get_packet_action_field128(action, raw_nbo);
880 COND_NTOHB128(raw_nbo,addr);
881 ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_DST: 0x%lx %lx",UINT128__T_HI(addr),UINT128__T_LO(addr));
884 case OF1X_AT_SET_FIELD_IPV6_FLABEL:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_FLABEL: 0x%u", __of1x_get_packet_action_field32(action, raw_nbo));
886 case OF1X_AT_SET_FIELD_IPV6_ND_TARGET:
888 uint128__t addr = __of1x_get_packet_action_field128(action, raw_nbo);
890 COND_NTOHB128(raw_nbo,addr);
891 ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_ND_TARGET: 0x%lx %lx",UINT128__T_HI(addr),UINT128__T_LO(addr));
894 case OF1X_AT_SET_FIELD_IPV6_ND_SLL:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_ND_SLL: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
896 case OF1X_AT_SET_FIELD_IPV6_ND_TLL:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_ND_TLL: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
898 case OF1X_AT_SET_FIELD_IPV6_EXTHDR:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_IPV6_EXTHDR: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
901 case OF1X_AT_SET_FIELD_ICMPV6_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ICMPV6_TYPE: 0x%u", __of1x_get_packet_action_field8(action, raw_nbo));
903 case OF1X_AT_SET_FIELD_ICMPV6_CODE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_ICMPV6_CODE: 0x%u", __of1x_get_packet_action_field8(action, raw_nbo));
905 case OF1X_AT_POP_PBB:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_PBB");
907 case OF1X_AT_PUSH_PBB:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_PBB");
909 case OF1X_AT_SET_FIELD_PBB_ISID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_PBB_ISID: 0x%u", __of1x_get_packet_action_field64(action, raw_nbo));
911 case OF1X_AT_SET_FIELD_TUNNEL_ID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_TUNNEL_ID: 0x%u", __of1x_get_packet_action_field64(action, raw_nbo));
915 case OF1X_AT_SET_FIELD_GTP_MSG_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_GTP_MSG_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
917 case OF1X_AT_SET_FIELD_GTP_TEID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_GTP_TEID: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
919 case OF1X_AT_POP_GTP:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_GTP");
921 case OF1X_AT_PUSH_GTP:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_GTP");
924 case OF1X_AT_SET_FIELD_CAPWAP_WBID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_CAPWAP_WBID: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
926 case OF1X_AT_SET_FIELD_CAPWAP_RID:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_CAPWAP_RID: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
928 case OF1X_AT_SET_FIELD_CAPWAP_FLAGS:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_CAPWAP_FLAGS: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
930 case OF1X_AT_POP_CAPWAP:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_CAPWAP");
932 case OF1X_AT_PUSH_CAPWAP:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_CAPWAP");
935 case OF1X_AT_SET_FIELD_WLAN_FC:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_FC: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
937 case OF1X_AT_SET_FIELD_WLAN_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_TYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
939 case OF1X_AT_SET_FIELD_WLAN_SUBTYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_SUBTYPE: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
941 case OF1X_AT_SET_FIELD_WLAN_DIRECTION:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_DIRECTION: 0x%x", __of1x_get_packet_action_field8(action, raw_nbo));
943 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_1:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_ADDRESS_1: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
945 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_2:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_ADDRESS_2: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
947 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_3:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_WLAN_ADDRESS_3: 0x%x", __of1x_get_packet_action_field64(action, raw_nbo));
949 case OF1X_AT_POP_WLAN:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_WLAN");
951 case OF1X_AT_PUSH_WLAN:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_WLAN");
954 case OF1X_AT_SET_FIELD_GRE_VERSION:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_GRE_VERSION: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
956 case OF1X_AT_SET_FIELD_GRE_PROT_TYPE:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_GRE_PROT_TYPE: 0x%x", __of1x_get_packet_action_field16(action, raw_nbo));
958 case OF1X_AT_SET_FIELD_GRE_KEY:ROFL_PIPELINE_INFO_NO_PREFIX(
"SET_GRE_KEY: 0x%x", __of1x_get_packet_action_field32(action, raw_nbo));
960 case OF1X_AT_POP_GRE:ROFL_PIPELINE_INFO_NO_PREFIX(
"POP_GRE");
962 case OF1X_AT_PUSH_GRE:ROFL_PIPELINE_INFO_NO_PREFIX(
"PUSH_GRE");
965 case OF1X_AT_GROUP:ROFL_PIPELINE_INFO_NO_PREFIX(
"GROUP:%u", __of1x_get_packet_action_field32(action, raw_nbo));
968 case OF1X_AT_EXPERIMENTER:ROFL_PIPELINE_INFO_NO_PREFIX(
"EXPERIMENTER");
972 ROFL_PIPELINE_INFO_NO_PREFIX(
"OUTPUT port: ");
973 switch(__of1x_get_packet_action_field32(action, raw_nbo)){
975 case OF1X_PORT_FLOOD:
976 ROFL_PIPELINE_INFO_NO_PREFIX(
"FLOOD");
978 case OF1X_PORT_NORMAL:
979 ROFL_PIPELINE_INFO_NO_PREFIX(
"NORMAL");
981 case OF1X_PORT_CONTROLLER:
982 ROFL_PIPELINE_INFO_NO_PREFIX(
"CONTROLLER");
985 ROFL_PIPELINE_INFO_NO_PREFIX(
"ALL");
987 case OF1X_PORT_TABLE:
988 ROFL_PIPELINE_INFO_NO_PREFIX(
"TABLE");
990 case OF1X_PORT_IN_PORT:
991 ROFL_PIPELINE_INFO_NO_PREFIX(
"IN-PORT");
994 ROFL_PIPELINE_INFO_NO_PREFIX(
"%u", __of1x_get_packet_action_field32(action, raw_nbo));
999 ROFL_PIPELINE_INFO_NO_PREFIX(
">,");
1007 for(i=0,j=0;i<write_actions->num_of_actions && j < OF1X_AT_NUMBER;j++){
1010 __of1x_dump_packet_action(&write_actions->actions[j], raw_nbo);
1020 if( unlikely(action_group==NULL) )
1022 for(action=action_group->head;action;action=action->next){
1023 __of1x_dump_packet_action(action, raw_nbo);
1030 if(unlikely(ag == NULL))
1031 return ROFL_FAILURE;
1035 return ROFL_FAILURE;
1037 for(pa_it=ag->head; pa_it; pa_it=pa_it->next){
1038 if(pa_it->type == OF1X_AT_OUTPUT)
1039 ag->num_of_output_actions++;
1040 else if(pa_it->type == OF1X_AT_GROUP && gt){
1042 return ROFL_FAILURE;
1046 ag->num_of_output_actions+=2;
1052 if(!is_pkt_out_al && ag->has_output_table)
1053 return ROFL_FAILURE;
1055 return ROFL_SUCCESS;
1060 if(unlikely(wa == NULL))
1061 return ROFL_FAILURE;
1063 if(wa->num_of_actions == 0)
1064 return ROFL_SUCCESS;
1067 return ROFL_FAILURE;
1070 wa->num_of_output_actions++;
1073 if((wa->actions[OF1X_AT_GROUP].group=
__of1x_group_search(gt,wa->actions[OF1X_AT_GROUP].__field.u64))==NULL )
1074 return ROFL_FAILURE;
1078 wa->num_of_output_actions+=2;
1082 return ROFL_SUCCESS;
of1x_packet_action_type_t
Actions over a packet as per defined in OF10, OF12, OF13.
OpenFlow v1.0, 1.2 and 1.3.2 flow table abstraction.
Packet action abstraction data structure.
of1x_action_group_t * of1x_init_action_group(of1x_packet_action_t *actions)
Create an action group (apply actions)
static void bitmap128_clean(bitmap128_t *bitmap)
Set bitmap to 0.
void of1x_push_packet_action_to_group(of1x_action_group_t *group, of1x_packet_action_t *action)
Push an action to the group.
void of1x_destroy_action_group(of1x_action_group_t *group)
Destroy an action group.
static bool bitmap128_is_bit_set(const bitmap128_t *bitmap, unsigned int pos)
Check if bit is set in the 128bit bitmap.
OpenFlow v1.0, 1.2 and 1.3.2 actions.
static bool bitmap128_check_mask(bitmap128_t *bitmap, bitmap128_t *mask)
Check whether a bitmap is within a certain mask (bitmap&mask == bitmap)
#define OF1X_MAC_ALIGN(x)
ALIGNING FUNCTIONS FOR THE PROTOCOL VALUES ///.
Action group (apply-actions) structure.
void of1x_destroy_packet_action(of1x_packet_action_t *action)
Destroys packet action (OF action)
rofl_result_t of1x_set_packet_action_on_write_actions(of1x_write_actions_t *write_actions, of1x_packet_action_t *action)
Set (copy) the action to the write actions.
of1x_write_actions_t * of1x_init_write_actions()
Create a write actions group.
of1x_group_t * __of1x_group_search(of1x_group_table_t *gt, uint32_t id)
Searches in the table for an entry with a specific id returns pointer if found or NULL if not...
switch_port_t * flood_meta_port
Special meta port: FLOOD.
of1x_packet_action_t * of1x_init_packet_action(of1x_packet_action_type_t type, wrap_uint_t field, uint16_t output_send_len)
Initializes a packet action (OF action)
static void bitmap128_set(bitmap128_t *bitmap, unsigned int pos)
Set a bit in the 128bit bitmap.