| #ifndef _CM_TOE_H_ | 
 | #define _CM_TOE_H_ | 
 |  | 
 | #include <stdio.h> | 
 | #include <stdlib.h> | 
 | #include <string.h> | 
 | #include <unistd.h> | 
 | #include <sys/types.h> | 
 | #include <sys/socket.h> | 
 | #include <linux/if_ether.h> | 
 | #include <libubox/list.h> | 
 | //#include "../linux/drivers/marvell/toe/toe.h" | 
 |  | 
 | #define MAX_MSG_SIZE 1024 | 
 | #define DEVICE_NAME_MAXSIZE 64 | 
 |  | 
 | #ifndef SOL_NETLINK | 
 | #define SOL_NETLINK 270 | 
 | #endif | 
 |  | 
 | /* attribute type */ | 
 | enum fp_cm_attrs { | 
 | 	CM_ATTR_UNSPEC, | 
 | 	CM_ATTR_PID, | 
 | 	CM_ATTR_SRC_IP, | 
 | 	CM_ATTR_DST_IP, | 
 | 	CM_ATTR_SRC_IP6,		/* struct in6_addr */ | 
 | 	CM_ATTR_DST_IP6,		/* struct in6_addr */ | 
 | 	CM_ATTR_SRC_PORT, | 
 | 	CM_ATTR_DST_PORT, | 
 | 	CM_ATTR_PROTO, | 
 | 	CM_ATTR_SRC_MAC, | 
 | 	CM_ATTR_DST_MAC, | 
 | 	CM_ATTR_SNAT, | 
 | 	CM_ATTR_FWD, | 
 | 	CM_ATTR_NAT_PORT, | 
 | 	CM_ATTR_NAT_IP, | 
 | 	CM_ATTR_DEVICE_NAME, | 
 | 	CM_ATTR_MCID, | 
 | 	CM_ATTR_RBID, | 
 | 	CM_ATTR_QFI, | 
 | 	CM_ATTR_PDU, | 
 | 	CM_ATTR_IN_PKT, | 
 | 	CM_ATTR_OUT_PKT, | 
 | 	CM_ATTR_VLAN_EN, | 
 | 	CM_ATTR_VLANID, | 
 | 	CM_ATTR_XLAT_EN, | 
 | 	CM_ATTR_XLAT_INSTANCE, | 
 | 	CM_ATTR_UPDATE_TUPLE, | 
 | /* private: internal use only */ | 
 | 	__FP_CM_ATTR_AFTER_LAST | 
 | }; | 
 | #define FP_CM_ATTR_MAX (__FP_CM_ATTR_AFTER_LAST - 1) | 
 |  | 
 | /* commands */ | 
 | enum fp_cm_commands { | 
 | 	CM_CMD_UNSPEC, | 
 | 	CM_CMD_SET_PID, | 
 | 	CM_CMD_GET_TUPLE, | 
 | 	CM_CMD_SET_TUPLE, | 
 | 	CM_CMD_DEL_TUPLE, | 
 | 	__FP_CM_CMD_AFTER_LAST, | 
 | }; | 
 | #define FP_CM_CMD_MAX (__FP_CM_CMD_AFTER_LAST - 1) | 
 |  | 
 | enum { | 
 | 	PDU_PKT = 0, | 
 | 	USB_PKT = 1, | 
 | 	WIFI_PKT = 2, | 
 | #ifdef TOE_VER_V3 | 
 | 	ETH_PKT = 3, | 
 | 	AP_PKT = 4, | 
 | 	TX_AP_PKT = 5, | 
 | #else | 
 | 	AP_PKT = 3, | 
 | 	ETH_PKT = 4, | 
 | #endif | 
 | 	MAX_PKT_TYPE, | 
 | }; | 
 |  | 
 | enum toe_prot { | 
 | 	TOE_UDP, | 
 | 	TOE_TCP, | 
 | 	TOE_MAX, | 
 | }; | 
 |  | 
 | typedef unsigned char u8; | 
 | typedef unsigned short u16; | 
 | typedef unsigned int u32; | 
 |  | 
 | #if 0 | 
 | struct tuple_v4 { | 
 | 	u32 src_ip; //little edian | 
 | 	u32 dst_ip; | 
 | 	u16 src_port; //little edian | 
 | 	u16 dst_port; | 
 | 	u16 prot:1; | 
 | 	u16 urg:1; | 
 | 	u16 fwd:1; | 
 | 	u16 crc:1; | 
 | 	u16 nat:2; | 
 | 	u16 rsvd1:6; | 
 | 	u16 in_pkt:2; | 
 | 	u16 out_pkt:2; | 
 | 	u16 nat_port; | 
 | 	u32 pdu:8; | 
 | 	u32 qfi:6; | 
 | 	u32 rbid:5; | 
 | 	u32 mcid:8; | 
 | 	u32 rsvd2:5; | 
 | 	u32 nat_ip; | 
 | }; | 
 |  | 
 | struct tuple_v6 { | 
 | 	u32 src_ip[4]; | 
 | 	u32 dst_ip[4]; | 
 | 	u16 src_port; | 
 | 	u16 dst_port; | 
 | 	u16 prot:1; | 
 | 	u16 urg:1; | 
 | 	u16 fwd:1; | 
 | 	u16 crc:1; | 
 | 	//u16 snat:1; | 
 | 	u16 rsvd1:8; | 
 | 	u16 in_pkt:2; | 
 | 	u16 out_pkt:2; | 
 | 	//u16 nat_port; | 
 | 	u32 pdu:8; | 
 | 	u32 qfi:6; | 
 | 	u32 rbid:5; | 
 | 	u32 mcid:8; | 
 | 	u32 rsvd2:5; | 
 | }; | 
 | #endif | 
 |  | 
 | struct toe_tuple_buff { | 
 | 	u32 src_ip6[4]; | 
 | 	u32 dst_ip6[4]; | 
 | 	u32 src_ip; | 
 | 	u32 dst_ip; | 
 | 	u32 src_port; | 
 | 	u32 dst_port; | 
 | 	u32 prot; | 
 | 	u32 urg; | 
 | 	u32 fwd; | 
 | 	u32 crc; | 
 | 	u32 nat; | 
 | 	u32 in_pkt; | 
 | 	u32 out_pkt; | 
 | 	u32 nat_port; | 
 | 	u32 pdu; | 
 | 	u32 qfi; | 
 | 	u32 rbid; | 
 | 	u32 mcid; | 
 | 	u32 nat_ip; | 
 | 	u32 ip6; | 
 | 	u8 vlan_en; | 
 | 	u16 vlanid; | 
 | 	u8 xlat_en; | 
 | 	char xlat_instance[16]; | 
 | 	u8 update_tuple; | 
 | }; | 
 |  | 
 | struct toe_tuple_list | 
 | { | 
 |         struct list_head list; | 
 |         #if 0 | 
 |         union { | 
 |             struct tuple_v4 v4; | 
 |             struct tuple_v6 v6; | 
 |         } tuple; | 
 |         #endif | 
 |         struct toe_tuple_buff tuple; | 
 |         u8 type; /*1 : V4, 2: V6*/ | 
 |         char dev_name[DEVICE_NAME_MAXSIZE]; | 
 | 	char src_mac[ETH_ALEN];  | 
 | 	char dst_mac[ETH_ALEN]; | 
 | 	u8 status; | 
 | }; | 
 |  | 
 | struct toe_tft_param { | 
 |         u32 mcid; | 
 |         u32 qfi; | 
 |         u32 pdu; | 
 |        //u32 rbid; | 
 | }; | 
 |  | 
 | #ifdef CM_CONFIG_TOE | 
 | int genl_prepare(void); | 
 | void genl_parse_msg(int sock_fd); | 
 | int genl_set_tuplev4_to_kernel(int sock_fd, struct toe_tuple_buff *tuple, | 
 | 			char *src_mac, char *dst_mac, char *dev_name); | 
 | int genl_set_tuplev6_to_kernel(int sock_fd, struct toe_tuple_buff *tuple, | 
 | 			char *src_mac, char *dst_mac, char *dev_name); | 
 | struct list_head *cm_get_toe_tuple_list_head(void); | 
 | #endif | 
 | #endif |