ROFL-pipeline  v0.6.0dev
Functions
packet.h File Reference

Defines the interface for packet mangling. The user of the library MUST provide an implementation for his/her platform. More...

#include <stdint.h>
#include "rofl.h"
#include "../common/datapacket.h"
#include "../common/ternary_fields.h"
#include "../switch_port.h"

Go to the source code of this file.

Functions

ROFL_BEGIN_DECLS uint32_t platform_packet_get_size_bytes (datapacket_t *const pkt)
 Gets the complete packet size in bytes. More...
 
void platform_packet_output (datapacket_t *pkt, switch_port_t *port)
 Output packet to the port(s) The action HAS to implement the destruction/release of the pkt (including if this pkt is a replica). More...
 
void platform_packet_drop (datapacket_t *pkt)
 Creates a copy (in heap) of the datapacket_t structure including any platform specific state (->platform_state). More...
 
datapacket_tplatform_packet_replicate (datapacket_t *pkt)
 Creates a copy (in heap) of the datapacket_t structure including any platform specific state (->platform_state). More...
 
uint32_t * platform_packet_get_port_in (datapacket_t *const pkt)
 Retrieves the port in identifier (position in the of1x_switch_t->logical_ports array) where the packet got in. More...
 
uint32_t * platform_packet_get_phy_port_in (datapacket_t *const pkt)
 Retrieves the PHY port in identifier where the packet got in. More...
 
void platform_packet_set_queue (datapacket_t *pkt, uint32_t queue)
 Set output queue of the packet. More...
 
uint64_t * platform_packet_get_eth_src (datapacket_t *const pkt)
 Retrieve the Ethernet src MAC address of the packet. More...
 
uint64_t * platform_packet_get_eth_dst (datapacket_t *const pkt)
 Retrieve the Ethernet dst MAC address of the packet. More...
 
uint16_t * platform_packet_get_eth_type (datapacket_t *const pkt)
 Retrieve the Ethernet ETH_TYPE of the packet. More...
 
void platform_packet_set_eth_src (datapacket_t *pkt, uint64_t eth_src)
 Set a new Ethernet src MAC address to the packet. More...
 
void platform_packet_set_eth_dst (datapacket_t *pkt, uint64_t eth_dst)
 Set a new Ethernet dst MAC address to the packet. More...
 
void platform_packet_set_eth_type (datapacket_t *pkt, uint16_t eth_type)
 Set a new ETH_TYPE to the packet if it is 802.X. More...
 
bool platform_packet_has_vlan (datapacket_t *const pkt)
 Retrieves boolean if the packet contains a 802.1q VLAN tag. More...
 
uint16_t * platform_packet_get_vlan_vid (datapacket_t *const pkt)
 Retrieves the VLAN id of the outer-most 802.1q VLAN tag. More...
 
uint8_t * platform_packet_get_vlan_pcp (datapacket_t *const pkt)
 Retrieves the VLAN PCP of the outer-most 802.1q VLAN tag. More...
 
void platform_packet_set_vlan_vid (datapacket_t *pkt, uint16_t vlan_vid)
 Set a new VLAN VID value to the outer-most VLAN of the packet. More...
 
void platform_packet_set_vlan_pcp (datapacket_t *pkt, uint8_t vlan_pcp)
 Set a new VLAN PCP value to the outer-most VLAN of the packet. More...
 
void platform_packet_pop_vlan (datapacket_t *pkt)
 Pop the outer-most 802.1q VLAN tag. More...
 
void platform_packet_push_vlan (datapacket_t *pkt, uint16_t ether_type)
 Push a new 802.1q VLAN tag (outer-most) More...
 
uint32_t * platform_packet_get_mpls_label (datapacket_t *const pkt)
 Retrieves the outer-most MPLS tag label. More...
 
uint8_t * platform_packet_get_mpls_tc (datapacket_t *const pkt)
 Retrieves the outer-most MPLS tag tc flag. More...
 
bool platform_packet_get_mpls_bos (datapacket_t *const pkt)
 Retrieves the outer-most MPLS tag BoS flag. More...
 
void platform_packet_set_mpls_label (datapacket_t *pkt, uint32_t label)
 Set a new label to the outer-most MPLS tag of the packet. More...
 
void platform_packet_set_mpls_tc (datapacket_t *pkt, uint8_t tc)
 Set a new TC value to the outer-most MPLS MPLS tag of the packet. More...
 
void platform_packet_set_mpls_bos (datapacket_t *pkt, bool bos)
 Set a new MPLS BoS value to the outer-most MPLS tag of the packet. More...
 
void platform_packet_set_mpls_ttl (datapacket_t *pkt, uint8_t new_ttl)
 Set a new TTL value to the outer-most MPLS tag of the packet. More...
 
void platform_packet_dec_mpls_ttl (datapacket_t *pkt)
 Decrement the ttl from the outer-most MPLS tag of the packet. More...
 
void platform_packet_pop_mpls (datapacket_t *pkt, uint16_t ether_type)
 Pop outer-most MPLS tag, setting the BoS accordingly. More...
 
void platform_packet_push_mpls (datapacket_t *pkt, uint16_t ether_type)
 Push a new MPLS tag (outer-most), and set inner and outer tag BoS accordingly. More...
 
uint64_t * platform_packet_get_tunnel_id (datapacket_t *const pkt)
 Get Tunnel ID. More...
 
void platform_packet_set_tunnel_id (datapacket_t *pkt, uint64_t tunnel_id)
 Set Tunnel ID. More...
 
uint32_t * platform_packet_get_pbb_isid (datapacket_t *const pkt)
 Get PBB I-SID value of the packet. More...
 
void platform_packet_set_pbb_isid (datapacket_t *pkt, uint32_t pbb_isid)
 Set a new value for the PBB I-SID of the packet. More...
 
void platform_packet_pop_pbb (datapacket_t *pkt)
 Pop outer-most PBB header. More...
 
void platform_packet_push_pbb (datapacket_t *pkt, uint16_t ether_type)
 Push PBB header (outer-most) More...
 
void platform_packet_copy_ttl_in (datapacket_t *pkt)
 Copy ttl in. More...
 
void platform_packet_copy_ttl_out (datapacket_t *pkt)
 Copy ttl out. More...
 
void platform_packet_dec_nw_ttl (datapacket_t *pkt)
 Decrement ttl. More...
 
void platform_packet_set_nw_ttl (datapacket_t *pkt, uint8_t new_ttl)
 Set new ttl value. More...
 
uint8_t * platform_packet_get_ip_proto (datapacket_t *const pkt)
 Get the ip proto value of the packet. More...
 
uint8_t platform_packet_get_ip_ecn (datapacket_t *const pkt)
 Get the ip ECN value of the packet. More...
 
uint8_t platform_packet_get_ip_dscp (datapacket_t *const pkt)
 Get the ip DSCP value of the packet. More...
 
void platform_packet_set_ip_proto (datapacket_t *pkt, uint8_t ip_proto)
 Set a new value for the IP PROTO header field. More...
 
void platform_packet_set_ip_dscp (datapacket_t *pkt, uint8_t ip_dscp)
 Set a new value for the IP DSCP header field. More...
 
void platform_packet_set_ip_ecn (datapacket_t *pkt, uint8_t ip_ecn)
 Set a new value for the IP ECN header field. More...
 
uint16_t * platform_packet_get_arp_opcode (datapacket_t *const pkt)
 Get the ARP OPCODE value of the packet. More...
 
uint64_t * platform_packet_get_arp_sha (datapacket_t *const pkt)
 Get the ARP SHA value of the packet. More...
 
uint32_t * platform_packet_get_arp_spa (datapacket_t *const pkt)
 Get the ARP SPA value of the packet. More...
 
uint64_t * platform_packet_get_arp_tha (datapacket_t *const pkt)
 Get the ARP THA value of the packet. More...
 
uint32_t * platform_packet_get_arp_tpa (datapacket_t *const pkt)
 Get the ARP TPA value of the packet. More...
 
void platform_packet_set_arp_opcode (datapacket_t *pkt, uint16_t arp_opcode)
 Set a new value for the ARP OPCODE header field. More...
 
void platform_packet_set_arp_sha (datapacket_t *pkt, uint64_t arp_sha)
 Set a new value for the ARP SHA header field. More...
 
void platform_packet_set_arp_spa (datapacket_t *pkt, uint32_t arp_spa)
 Set a new value for the ARP SPA header field. More...
 
void platform_packet_set_arp_tha (datapacket_t *pkt, uint64_t arp_tha)
 Set a new value for the ARP THA header field. More...
 
void platform_packet_set_arp_tpa (datapacket_t *pkt, uint32_t arp_tpa)
 Set a new value for the ARP TPA header field. More...
 
uint32_t * platform_packet_get_ipv4_src (datapacket_t *const pkt)
 Get the IPv4 src address of the packet. More...
 
uint32_t * platform_packet_get_ipv4_dst (datapacket_t *const pkt)
 Get the IPv4 dst address of the packet. More...
 
void platform_packet_set_ipv4_src (datapacket_t *pkt, uint32_t ip_src)
 Set a new value for the IPv4 src address. More...
 
void platform_packet_set_ipv4_dst (datapacket_t *pkt, uint32_t ip_dst)
 Set a new value for the IPv4 dst address. More...
 
uint128__tplatform_packet_get_ipv6_src (datapacket_t *const pkt)
 Get the IPv6 src address of the packet. More...
 
uint128__tplatform_packet_get_ipv6_dst (datapacket_t *const pkt)
 Get the IPv6 dst address of the packet. More...
 
uint32_t * platform_packet_get_ipv6_flabel (datapacket_t *const pkt)
 Get the IPv6 label of the packet. More...
 
uint128__tplatform_packet_get_ipv6_nd_target (datapacket_t *const pkt)
 Get the IPv6 nd target of the packet. More...
 
uint64_t * platform_packet_get_ipv6_nd_sll (datapacket_t *const pkt)
 Get the IPv6 nd sll of the packet. More...
 
uint64_t * platform_packet_get_ipv6_nd_tll (datapacket_t *const pkt)
 Get the IPv6 nd tll of the packet. More...
 
uint16_t * platform_packet_get_ipv6_exthdr (datapacket_t *const pkt)
 Get the IPv6 exthdr of the packet. More...
 
void platform_packet_set_ipv6_src (datapacket_t *pkt, uint128__t ipv6_src)
 Set a new value for the IPv6 src address. More...
 
void platform_packet_set_ipv6_dst (datapacket_t *pkt, uint128__t ipv6_dst)
 Set a new value for the IPv6 dst address. More...
 
void platform_packet_set_ipv6_flabel (datapacket_t *pkt, uint64_t ipv6_flabel)
 Set a new value for the IPv6 label. More...
 
void platform_packet_set_ipv6_nd_target (datapacket_t *pkt, uint128__t ipv6_nd_target)
 Set a new value for the IPv6 nd target. More...
 
void platform_packet_set_ipv6_nd_sll (datapacket_t *pkt, uint64_t ipv6_nd_sll)
 Set a new value for the IPv6 nd sll. More...
 
void platform_packet_set_ipv6_nd_tll (datapacket_t *pkt, uint64_t ipv6_nd_tll)
 Set a new value for the IPv6 nd tll. More...
 
void platform_packet_set_ipv6_exthdr (datapacket_t *pkt, uint16_t ipv6_exthdr)
 Set a new value for the IPv6 exthdr. More...
 
uint16_t * platform_packet_get_tcp_src (datapacket_t *const pkt)
 Get the TCP src port. More...
 
uint16_t * platform_packet_get_tcp_dst (datapacket_t *const pkt)
 Get the TCP dst port. More...
 
void platform_packet_set_tcp_src (datapacket_t *pkt, uint16_t tcp_src)
 Set a new value for the TCP src port. More...
 
void platform_packet_set_tcp_dst (datapacket_t *pkt, uint16_t tcp_dst)
 Set a new value for the TCP dst port. More...
 
uint16_t * platform_packet_get_udp_src (datapacket_t *const pkt)
 Get the UDP src port. More...
 
uint16_t * platform_packet_get_udp_dst (datapacket_t *const pkt)
 Get the UDP dst port. More...
 
void platform_packet_set_udp_src (datapacket_t *pkt, uint16_t udp_src)
 Set a new value for the UDP src port. More...
 
void platform_packet_set_udp_dst (datapacket_t *pkt, uint16_t udp_dst)
 Set a new value for the UDP dst port. More...
 
uint16_t * platform_packet_get_sctp_src (datapacket_t *const pkt)
 Get the SCTP src port. More...
 
uint16_t * platform_packet_get_sctp_dst (datapacket_t *const pkt)
 Get the SCTP dst port. More...
 
void platform_packet_set_sctp_src (datapacket_t *pkt, uint16_t sctp_src)
 Set a new value for the SCTP src port. More...
 
void platform_packet_set_sctp_dst (datapacket_t *pkt, uint16_t sctp_dst)
 Set a new value for the SCTP dst port. More...
 
uint8_t * platform_packet_get_icmpv4_type (datapacket_t *const pkt)
 Get the ICMPv4 type. More...
 
uint8_t * platform_packet_get_icmpv4_code (datapacket_t *const pkt)
 Get the ICMPv4 code. More...
 
void platform_packet_set_icmpv4_type (datapacket_t *pkt, uint8_t type)
 Set a new value for the ICMPv4 type. More...
 
void platform_packet_set_icmpv4_code (datapacket_t *pkt, uint8_t code)
 Set a new value for the ICMPv4 code. More...
 
uint8_t * platform_packet_get_icmpv6_type (datapacket_t *const pkt)
 Get the ICMPv6 type. More...
 
uint8_t * platform_packet_get_icmpv6_code (datapacket_t *const pkt)
 Get the ICMPv6 code. More...
 
void platform_packet_set_icmpv6_type (datapacket_t *pkt, uint8_t icmpv6_type)
 Set a new value for the ICMPv6 type. More...
 
void platform_packet_set_icmpv6_code (datapacket_t *pkt, uint8_t icmpv6_code)
 Set a new value for the ICMPv6 code. More...
 

Detailed Description

Defines the interface for packet mangling. The user of the library MUST provide an implementation for his/her platform.

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

The packet mangling platform API is the set of calls used by library to perform operations over the packet. These operations are:

If the platform does NOT support some of the operations contained in this API, getters MUST always return 0x0 and actions must return immediately. If this is the case, the bitmap of the supported actions and matches shall be set appropiately in the platform_post_init_of1x_switch() hook, in ALL of the switch tables, to prevent invalid flow mods to be installed

Definition in file packet.h.