/* ****************************************************************************** * HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iplite_netif.h,v $ $Revision: 1.14.26.1 $ * $Source: /home/interpeak/CVSRoot/iplite2/src/iplite_netif.h,v $ * $Author: svc-cmnet $ $Date: 2013-03-13 07:45:29 $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Kenneth Jonsson ****************************************************************************** */ #ifndef IPLITE_NETIF_H #define IPLITE_NETIF_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* Types and function for network interface support in IPLITE */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "iplite_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include #include #ifdef IPLITE_USE_RFC3927 #include "iplite_timeout.h" #endif #ifdef IPCOM_USE_INET6 #include "iplite_ip6.h" #endif #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ #define IPLITE_IF_UNSPECIFIED_INDEX 0 #define IPLITE_IF_UNSPECIFIED_NAME IP_NULL #define IPLITE_IF_END ((IP_CONST char *) -1) /* **************************************************************************** * 5 TYPES **************************************************************************** */ /* Forward declaration */ struct Iplite_netif_struct; struct Iplite_netif_eth_struct; struct Iplite_ip6_nc_entry_struct; struct Iplite_ipsec_tdb_struct; struct Iplite_ip4_data_struct; struct Iplite_route_entry_struct; struct Iplite_ip6_dr_entry_struct; struct Iplite_netif_wlan_struct; /* *=========================================================================== * Iplite_link_tick *=========================================================================== * Description: Performes tasks that must be timer triggered. * Parameters: netif - A pointer to the network interface structure for this * driver. * Returns: * */ typedef void (*Iplite_link_tick)(struct Iplite_netif_struct *netif); /* *=========================================================================== * Iplite_link_input *=========================================================================== * Description: Process the link header and dispatch IPv4 packets to * iplite_ip4_input() and IPv6 packets to iplite_ip6_input(). * The pkt->start must be changed to be the offset to the * IPv4 or IPv6 header for IPv4 and IPv6 packets. * Parameters: netif - A pointer to the network interface structure for this * driver. * pkt - The received packet. pkt->start is the offset to the * link header. * Returns: * */ typedef void (*Iplite_link_input)(struct Iplite_netif_struct *netif, Ipcom_pkt *pkt); /* *=========================================================================== * Iplite_link_ip4_output *=========================================================================== * Description: Adds the link header to a IPv4 packet and calls the * Iplite_drv_output function for the interface. * Parameters: netif - A pointer to the network interface structure for this * driver. * rt - The route to the next hop. Link specific data can be * stored at rt->data. The 'data' buffer is * IPLITE_ROUTE_ENTRY_DATA_LEN octets long. * pkt - The packet to send. pkt->start is the offset to the * IP header. pkt->start must be updated to be the offset to * the link layer before calling netif->drv_output(). * Returns: 0 = success, <0 = error code (-IPLITE_ERRNO_xxx) * */ typedef int (*Iplite_link_ip4_output)(struct Iplite_netif_struct *netif, struct Ip_in_addr *next_hop, Ipcom_pkt *pkt); /* *=========================================================================== * Iplite_link_ip6_output *=========================================================================== * Description: Adds the link header to a IPv6 packet and calls the * Iplite_drv_output function for the interface. * Parameters: netif - A pointer to the network interface structure for this * driver. * nc - The neighbor entry for the first hop (contains IPv6 to link * addr information). * pkt - The packet to send. pkt->start is the offset to the * IP header. pkt->start must be updated to be the offset to * the link layer before calling netif->drv_output(). * Returns: 0 = success, <0 = error code (-IPLITE_ERRNO_xxx) * */ typedef int (*Iplite_link_ip6_output)(struct Iplite_netif_struct *netif, struct Iplite_ip6_nc_entry_struct *nc, Ipcom_pkt *pkt); /* *=========================================================================== * Iplite_link_ip6_create_addr *=========================================================================== * Description: Creates a * Parameters: netif - A pointer to the network interface structure for this * driver. * prefix - The prefix to use (the topmost * 128 - netif->inet6_if_id_bits is used). * in6_addr - Will contain the auto address if the call is * successful. * Returns: * */ #ifdef IPCOM_USE_INET6 typedef void (*Iplite_link_ip6_create_addr)(struct Iplite_netif_struct *netif, IP_CONST struct Ip_in6_addr* prefix, struct Ip_in6_addr* in6_addr); #endif /* *=========================================================================== * Iplite_link_ioctl *=========================================================================== * Description: IO control function for the link layer. * Parameters: netif - A pointer to the network interface structure for this * driver. * command - IPLITE_IP4_SIOCxxx or IPLITE_IP6_SIOCxxx style command. * data - Depends on command. * Returns: 0 = success, <0 = error code (-IPLITE_ERRNO_xxx) * */ typedef int (*Iplite_link_ioctl)(struct Iplite_netif_struct *netif, Ip_u32 command, void *data); /* *=========================================================================== * Iplite_link_raw_output *=========================================================================== * Description: Adds a link layer header and outputs the frame to the driver * ARP (or similar) is bypassed. * Parameters: netif - A pointer to the network interface structure for this * driver. * to - The link layer address of the recipient of this frame. * pkt - The packet which should have a link layer header appended. * Returns: 0 = success, <0 = error code (-IPLITE_ERRNO_xxx) * */ #ifdef IPCOM_USE_PACKET typedef int (*Iplite_link_raw_output)(struct Iplite_netif_struct *netif, IP_CONST struct Ip_sockaddr_ll *to, Ipcom_pkt *pkt); /* *=========================================================================== * Iplite_link_get_frame_info *=========================================================================== * Description: Gets header information from the frame header. * Parameters: netif - A pointer to the network interface structure for this * driver. * frame - A complete link layer frame. pkt->start is the offset * to the link layer header. * pkt_type - Will be set to one of the IP_PACKET_xxx type, * can be IP_NULL if this value is not needed. * frame_type - Will be set to the frame type (i.e. one of the * IPLITE_ETH_P_xxx constants for Ethernet). can be IP_NULL if * this information is not needed. * src - Points to a buffer to where the source link address * will be copied. Can be IP_NULL if not needed. * dst - Points to a buffer to where the destination link address * will be copied. Can be IP_NULL if not needed. * Returns: 0 = success, <0 = error code (-IPLITE_ERRNO_xxx) * */ typedef int (*Iplite_link_get_frame_info)(struct Iplite_netif_struct *netif, Ipcom_pkt *frame, Ip_u8 *pkt_type, Ip_u16 *frame_type, Ip_u8 *src, Ip_u8 *dst); #endif /* IPCOM_USE_PACKET */ /* *=========================================================================== * Iplite_netif *=========================================================================== */ typedef struct Iplite_netif_struct { Ipcom_netif ipcom; /* IPCOM Ipcom_netif structure. See IPCOM/include/ipcom_netif.h */ int ref_count; /* Reference count used with ipcom_if_detach() */ /* Additional interface data. */ struct Iplite_netif_eth_struct *eth; /* Pointer to Ethernet info. IP_NULL if not Eth if */ #ifdef IPCOM_USE_INET struct Iplite_ip4_addr_entry_struct *inet4_addr_list; /* List of IPv4 addresses */ #ifdef IPPPP Ip_u32 inet4_peeraddr_n; #endif #ifdef IPLITE_USE_RFC3927 Ip_u8 inet4_lladdr_state; /* IPLITE_IP4_LLADDR_STATE_xxx */ Ip_u8 inet4_lladdr_num; /* Number of probes or announcement left */ Ip_u8 inet4_lladdr_conflics; /* Number of address conflicts seen */ struct Ip_in_addr inet4_lladdr; /* The current link local address */ Iplite_timeout *inet4_lladdr_tmo; /* Timeout structure for link-local IPv4 address */ #endif #endif /* IPCOM_USE_INET */ #ifdef IPCOM_USE_INET6 Ip_u16 inet6_if_id_bits; /* Number of bits that should be used for host id when creating a IPv6 from the link address */ Ip_u16 inet6_pad; struct Iplite_ip6_addr_entry_struct *inet6_addr_list; /* All addresses on this interface */ struct Iplite_ip6_dr_entry_struct dr; /* Support only single Default router */ struct Iplite_ip6_nc_entry_struct *nc_list; #ifdef IPPPP struct Ip_in6_addr inet6_peeraddr; #endif #endif /* IPCOM_USE_INET6 */ /***** IPLITE to link layer functions (downcall) *****/ Iplite_link_tick link_tick; /* Can be IP_NULL if no tick is needed */ Iplite_link_input link_input; /* Parse packet in link layer. */ Iplite_link_ioctl link_ioctl; #ifdef IPCOM_USE_INET Iplite_link_ip4_output link_ip4_output; #endif #ifdef IPCOM_USE_INET6 Iplite_link_ip6_output link_ip6_output; Iplite_link_ip6_create_addr link_ip6_create_addr; #endif /* IPCOM_USE_INET6 */ /* IPLITE to link layer packet functions. */ #ifdef IPCOM_USE_PACKET Iplite_link_raw_output link_raw_output; Iplite_link_get_frame_info link_get_frame_info; #endif /***** Interface output queue *****/ Ipcom_sem snd_sem; Ipcom_pkt *snd_head; Ipcom_pkt *snd_tail; int snd_num; int snd_max; int snd_id; #ifdef IPLITE_USE_WLAN struct Iplite_netif_wlan_struct *wlan; #endif } Iplite_netif; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ /* *=========================================================================== * internal funcs *=========================================================================== */ IP_GLOBAL void iplite_if_clean(Iplite_netif *netif, Ip_bool clean_ip4, Ip_bool clean_ip6); IP_GLOBAL int iplite_if_output(Iplite_netif *netif, Ipcom_pkt *pkt); IP_GLOBAL int iplite_if_drv_output(Iplite_netif *netif, Ipcom_pkt *pkt); IP_GLOBAL int iplite_if_configure(void); IP_GLOBAL void iplite_if_lock(Iplite_netif *netif); IP_GLOBAL int iplite_if_unlock(Iplite_netif *netif); IP_GLOBAL int iplite_if_drv_ioctl(Iplite_netif *netif, Ip_u32 command, void *data); IP_GLOBAL Iplite_netif *iplite_if_indextonetif(Ip_u32 ifindex); IP_GLOBAL Iplite_netif *iplite_if_nametonetif(IP_CONST char *ifname); #ifdef IPPPP IP_PUBLIC int iplite_ppp_if_init(Iplite_netif *netif); #endif #ifdef __cplusplus } #endif #endif /* **************************************************************************** * END OF FILE **************************************************************************** */