ROFL-pipeline  v0.6.0dev
Data Structures | Macros | Typedefs | Enumerations | Functions
of1x_action.h File Reference

OpenFlow v1.0, 1.2 and 1.3.2 actions. More...

#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#include "rofl.h"
#include "of1x_utils.h"
#include "../../../common/ternary_fields.h"

Go to the source code of this file.

Data Structures

struct  of1x_packet_action
 Packet action abstraction data structure. More...
 
struct  of1x_action_group
 Action group (apply-actions) structure. More...
 
struct  of1x_write_actions_t
 Write actions structure. More...
 

Macros

#define OF1X_AT_NUMBER   OF1X_AT_OUTPUT+1
 

Typedefs

typedef struct of1x_packet_action of1x_packet_action_t
 Packet action abstraction data structure. More...
 
typedef struct of1x_action_group of1x_action_group_t
 Action group (apply-actions) structure. More...
 

Enumerations

enum  of1x_packet_action_type_t {
  OF1X_AT_NO_ACTION = 0, OF1X_AT_COPY_TTL_IN, OF1X_AT_POP_VLAN, OF1X_AT_POP_MPLS,
  OF1X_AT_POP_GTP, OF1X_AT_POP_CAPWAP, OF1X_AT_POP_PPPOE, OF1X_AT_POP_PBB,
  OF1X_AT_POP_WLAN, OF1X_AT_POP_GRE, OF1X_AT_PUSH_GRE, OF1X_AT_PUSH_WLAN,
  OF1X_AT_PUSH_PBB, OF1X_AT_PUSH_PPPOE, OF1X_AT_PUSH_CAPWAP, OF1X_AT_PUSH_GTP,
  OF1X_AT_PUSH_MPLS, OF1X_AT_PUSH_VLAN, OF1X_AT_COPY_TTL_OUT, OF1X_AT_DEC_NW_TTL,
  OF1X_AT_DEC_MPLS_TTL, OF1X_AT_SET_MPLS_TTL, OF1X_AT_SET_NW_TTL, OF1X_AT_SET_QUEUE,
  OF1X_AT_SET_FIELD_ETH_DST, OF1X_AT_SET_FIELD_ETH_SRC, OF1X_AT_SET_FIELD_ETH_TYPE, OF1X_AT_SET_FIELD_MPLS_LABEL,
  OF1X_AT_SET_FIELD_MPLS_TC, OF1X_AT_SET_FIELD_MPLS_BOS, OF1X_AT_SET_FIELD_VLAN_VID, OF1X_AT_SET_FIELD_VLAN_PCP,
  OF1X_AT_SET_FIELD_ARP_OPCODE, OF1X_AT_SET_FIELD_ARP_SHA, OF1X_AT_SET_FIELD_ARP_SPA, OF1X_AT_SET_FIELD_ARP_THA,
  OF1X_AT_SET_FIELD_ARP_TPA, OF1X_AT_SET_FIELD_NW_PROTO, OF1X_AT_SET_FIELD_NW_SRC, OF1X_AT_SET_FIELD_NW_DST,
  OF1X_AT_SET_FIELD_IP_DSCP, OF1X_AT_SET_FIELD_IP_ECN, OF1X_AT_SET_FIELD_IP_PROTO, OF1X_AT_SET_FIELD_IPV4_SRC,
  OF1X_AT_SET_FIELD_IPV4_DST, OF1X_AT_SET_FIELD_IPV6_SRC, OF1X_AT_SET_FIELD_IPV6_DST, OF1X_AT_SET_FIELD_IPV6_FLABEL,
  OF1X_AT_SET_FIELD_IPV6_ND_TARGET, OF1X_AT_SET_FIELD_IPV6_ND_SLL, OF1X_AT_SET_FIELD_IPV6_ND_TLL, OF1X_AT_SET_FIELD_IPV6_EXTHDR,
  OF1X_AT_SET_FIELD_TCP_SRC, OF1X_AT_SET_FIELD_TCP_DST, OF1X_AT_SET_FIELD_UDP_SRC, OF1X_AT_SET_FIELD_UDP_DST,
  OF1X_AT_SET_FIELD_SCTP_SRC, OF1X_AT_SET_FIELD_SCTP_DST, OF1X_AT_SET_FIELD_TP_SRC, OF1X_AT_SET_FIELD_TP_DST,
  OF1X_AT_SET_FIELD_ICMPV4_TYPE, OF1X_AT_SET_FIELD_ICMPV4_CODE, OF1X_AT_SET_FIELD_ICMPV6_TYPE, OF1X_AT_SET_FIELD_ICMPV6_CODE,
  OF1X_AT_SET_FIELD_PBB_ISID, OF1X_AT_SET_FIELD_TUNNEL_ID, OF1X_AT_SET_FIELD_PPPOE_CODE, OF1X_AT_SET_FIELD_PPPOE_TYPE,
  OF1X_AT_SET_FIELD_PPPOE_SID, OF1X_AT_SET_FIELD_PPP_PROT, OF1X_AT_SET_FIELD_GTP_MSG_TYPE, OF1X_AT_SET_FIELD_GTP_TEID,
  OF1X_AT_SET_FIELD_CAPWAP_WBID, OF1X_AT_SET_FIELD_CAPWAP_RID, OF1X_AT_SET_FIELD_CAPWAP_FLAGS, OF1X_AT_SET_FIELD_WLAN_FC,
  OF1X_AT_SET_FIELD_WLAN_TYPE, OF1X_AT_SET_FIELD_WLAN_SUBTYPE, OF1X_AT_SET_FIELD_WLAN_DIRECTION, OF1X_AT_SET_FIELD_WLAN_ADDRESS_1,
  OF1X_AT_SET_FIELD_WLAN_ADDRESS_2, OF1X_AT_SET_FIELD_WLAN_ADDRESS_3, OF1X_AT_SET_FIELD_GRE_VERSION, OF1X_AT_SET_FIELD_GRE_PROT_TYPE,
  OF1X_AT_SET_FIELD_GRE_KEY, OF1X_AT_GROUP, OF1X_AT_EXPERIMENTER, OF1X_AT_OUTPUT
}
 Actions over a packet as per defined in OF10, OF12, OF13. More...
 
enum  of1x_port_numbers {
  OF1X_PORT_MAX = 0xffffff00, OF1X_PORT_IN_PORT = 0xfffffff8, OF1X_PORT_TABLE = 0xfffffff9, OF1X_PORT_NORMAL = 0xfffffffa,
  OF1X_PORT_FLOOD = 0xfffffffb, OF1X_PORT_ALL = 0xfffffffc, OF1X_PORT_CONTROLLER = 0xfffffffd, OF1X_PORT_LOCAL = 0xfffffffe,
  OF1X_PORT_ANY = 0xffffffff
}
 Special port numbers, according to OF1X (of1xp_port_no ) More...
 

Functions

ROFL_BEGIN_DECLS
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) More...
 
void of1x_destroy_packet_action (of1x_packet_action_t *action)
 Destroys packet action (OF action) More...
 
static uint8_t __of1x_get_packet_action_field8 (const of1x_packet_action_t *action, bool raw_nbo)
 
static uint8_t of1x_get_packet_action_field8 (const of1x_packet_action_t *action)
 Retrieve the action field for 8 bit values (or less) in HOST BYTE ORDER. More...
 
static uint16_t __of1x_get_packet_action_field16 (const of1x_packet_action_t *action, bool raw_nbo)
 
static uint16_t of1x_get_packet_action_field16 (const of1x_packet_action_t *action)
 Retrieve the action field for 16 bit values (or less) in HOST BYTE ORDER. More...
 
static uint32_t __of1x_get_packet_action_field32 (const of1x_packet_action_t *action, bool raw_nbo)
 
static uint32_t of1x_get_packet_action_field32 (const of1x_packet_action_t *action)
 Retrieve the action field for 32 bit values (or less) in HOST BYTE ORDER. More...
 
static uint64_t __of1x_get_packet_action_field64 (const of1x_packet_action_t *action, bool raw_nbo)
 
static uint64_t of1x_get_packet_action_field64 (const of1x_packet_action_t *action)
 Retrieve the action field for 64 bit values (or less) in HOST BYTE ORDER. More...
 
static uint128__t __of1x_get_packet_action_field128 (const of1x_packet_action_t *action, bool raw_nbo)
 
static uint128__t of1x_get_packet_action_field128 (const of1x_packet_action_t *action)
 Retrieve the action field for 128 bit values (or less) in HOST BYTE ORDER. More...
 
of1x_action_group_tof1x_init_action_group (of1x_packet_action_t *actions)
 Create an action group (apply actions) More...
 
void of1x_destroy_action_group (of1x_action_group_t *group)
 Destroy an action group. More...
 
void of1x_push_packet_action_to_group (of1x_action_group_t *group, of1x_packet_action_t *action)
 Push an action to the group. More...
 
of1x_write_actions_tof1x_init_write_actions (void)
 Create a write actions group. More...
 
void __of1x_destroy_write_actions (of1x_write_actions_t *write_actions)
 
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. More...
 
rofl_result_t __of1x_update_apply_actions (of1x_action_group_t **group, of1x_action_group_t *new_group)
 
rofl_result_t __of1x_update_write_actions (of1x_write_actions_t **group, of1x_write_actions_t *new_group)
 
bool __of1x_write_actions_has (of1x_write_actions_t *write_actions, of1x_packet_action_type_t type, uint64_t value)
 
bool __of1x_apply_actions_has (const of1x_action_group_t *apply_actions_group, of1x_packet_action_type_t type, uint64_t value)
 
of1x_action_group_t__of1x_copy_action_group (of1x_action_group_t *origin)
 
of1x_write_actions_t__of1x_copy_write_actions (of1x_write_actions_t *origin)
 
void __of1x_dump_write_actions (of1x_write_actions_t *write_actions_group, bool raw_nbo)
 
void __of1x_dump_action_group (of1x_action_group_t *action_group, bool raw_nbo)
 
rofl_result_t __of1x_validate_action_group (bitmap128_t *supported, of1x_action_group_t *ag, struct of1x_group_table *gt, bool is_pkt_out_ag)
 
rofl_result_t __of1x_validate_write_actions (bitmap128_t *supported, of1x_write_actions_t *wa, struct of1x_group_table *gt)
 

Detailed Description

OpenFlow v1.0, 1.2 and 1.3.2 actions.

Author
Marc Sune<marc.sune (at) bisdn.de>

Actions are a part of a of1x_flow_entry. The typical workflow for creation of actions is:

Apply actions(pseudo-code):

for(i in openflow_msg->apply_actions)
action = of1x_init_packet_action(i->type, i->field)
//Action can never be accessed or freed now!
//This is forbidded
//of1x_destroy_packet_action(action)
//action->type = something; //R/W access is also forbidden
//To release resources

Write actions(pseudo-code):

write_actions = of1x_init_write_actions()
for(i in openflow_msg->write_actions)
action = of1x_init_packet_action(i->type, i->field)
//Action must be freed(set only copies the action)
//To release resources
of1x_destroy_write_actions(group)

Note regarding endianness: Conforming the convention that the pipeline works in Network Byte Order the matches need to to be initialized in NBO (Big Endian). This applies to the values comming from the packet (eth_src, eth_dst, ...) and NOT to the ones that are external to it:

There is an special alignment for non complete values as

Definition in file of1x_action.h.