Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
fnet_netif_prv.h
00001 /************************************************************************** 00002 * 00003 * Copyright 2011-2016 by Andrey Butok. FNET Community. 00004 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc. 00005 * 00006 *************************************************************************** 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00009 * not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00016 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 * 00020 **********************************************************************/ 00021 /*! 00022 * @brief Private. FNET Network interface API. 00023 * 00024 ***************************************************************************/ 00025 00026 #ifndef _FNET_NETIF_PRV_H_ 00027 00028 #define _FNET_NETIF_PRV_H_ 00029 00030 #include "fnet.h" 00031 #include "fnet_netbuf.h" 00032 #include "fnet_netif.h" 00033 #include "fnet_eth.h" 00034 #include "fnet_nd6.h" 00035 00036 /**************************************************************************/ /*! 00037 * @internal 00038 * @brief Netif features. 00039 ******************************************************************************/ 00040 typedef enum 00041 { 00042 FNET_NETIF_FEATURE_NONE = 0x00, /* No special feature.*/ 00043 FNET_NETIF_FEATURE_HW_TX_IP_CHECKSUM = 0x01, /* If an IP frame is transmitted, the checksum is inserted automatically. The IP header checksum field 00044 * must be cleared. If a non-IP frame is transmitted the frame is not modified.*/ 00045 FNET_NETIF_FEATURE_HW_TX_PROTOCOL_CHECKSUM = 0x02, /* If an IP frame with a known protocol is transmitted (UDP,TCP,ICMP), the checksum is inserted automatically into the 00046 * frame. The checksum field must be cleared. The other frames are not modified.*/ 00047 FNET_NETIF_FEATURE_HW_RX_IP_CHECKSUM = 0x04, /* If an IPv4 frame is received with a mismatching header checksum, 00048 * the frame is discarded.*/ 00049 FNET_NETIF_FEATURE_HW_RX_PROTOCOL_CHECKSUM = 0x08 /* If a TCP/IP, UDP/IP, or ICMP/IP frame is received that has a wrong TCP, UDP, or ICMP checksum, 00050 * the frame is discarded.*/ 00051 } fnet_netif_feature_t; 00052 00053 /**************************************************************************/ /*! 00054 * Interface IPv4 address structure. 00055 ******************************************************************************/ 00056 typedef struct 00057 { 00058 fnet_ip4_addr_t address; /**< The IP address.*/ 00059 fnet_ip4_addr_t net; /**< Network address.*/ 00060 fnet_ip4_addr_t netmask; /**< Network mask.*/ 00061 fnet_ip4_addr_t subnet; /**< Network and subnet address.*/ 00062 fnet_ip4_addr_t subnetmask; /**< Network and subnet mask.*/ 00063 fnet_ip4_addr_t netbroadcast; /**< Network broadcast address.*/ 00064 fnet_ip4_addr_t subnetbroadcast; /**< Subnet broadcast address.*/ 00065 fnet_ip4_addr_t gateway; /**< Gateway.*/ 00066 #if FNET_CFG_DNS 00067 fnet_ip4_addr_t dns; /**< DNS address.*/ 00068 #endif 00069 fnet_netif_ip_addr_type_t address_type; 00070 } fnet_netif_ip4_addr_t ; 00071 00072 /* Maxinmum number of IPv6 addresses per interface.*/ 00073 #define FNET_NETIF_IP6_ADDR_MAX FNET_CFG_NETIF_IP6_ADDR_MAX 00074 /* A lifetime value of all one bits (0xffffffff) represents infinity. */ 00075 #define FNET_NETIF_IP6_ADDR_LIFETIME_INFINITE FNET_ND6_PREFIX_LIFETIME_INFINITE 00076 00077 /********************************************************************* 00078 * Interface IPv6 address structure. 00079 *********************************************************************/ 00080 typedef struct fnet_netif_ip6_addr 00081 { 00082 fnet_ip6_addr_t address; /* IPv6 address.*/ 00083 fnet_netif_ip6_addr_state_t state; /* Address current state.*/ 00084 fnet_netif_ip_addr_type_t type; /* How the address was acquired.*/ 00085 fnet_ip6_addr_t solicited_multicast_addr; /* Solicited-node multicast */ 00086 00087 fnet_time_t creation_time; /* Time of entry creation (in seconds).*/ 00088 fnet_time_t lifetime; /* Address lifetime (in seconds). 0xFFFFFFFF = Infinite Lifetime 00089 * RFC4862. A link-local address has an infinite preferred and valid lifetime; it 00090 * is never timed out.*/ 00091 fnet_size_t prefix_length; /* Prefix length (in bits). The number of leading bits 00092 * in the Prefix that are valid. */ 00093 fnet_index_t dad_transmit_counter; /* Counter used by DAD. Equals to the number 00094 * of NS transmits till DAD is finished.*/ 00095 fnet_time_t state_time; /* Time of last state event.*/ 00096 } fnet_netif_ip6_addr_t; 00097 00098 struct fnet_netif; /* Forward declaration.*/ 00099 /**************************************************************************/ /*! 00100 * @internal 00101 * @brief Network-interface general API structure. 00102 ******************************************************************************/ 00103 typedef struct fnet_netif_api 00104 { 00105 fnet_netif_type_t netif_type; /* Data-link type. */ 00106 fnet_size_t netif_hw_addr_size; /* HW address size.*/ 00107 fnet_return_t (*netif_init)( struct fnet_netif *netif ); /* Initialization function.*/ 00108 void (*netif_release)( struct fnet_netif *netif ); /* Shutdown/release function.*/ 00109 #if FNET_CFG_IP4 00110 void (*netif_output_ip4)(struct fnet_netif *netif, fnet_ip4_addr_t dest_ip_addr, fnet_netbuf_t *nb); /* IPv4 Transmit function.*/ 00111 #endif 00112 void (*netif_set_addr_notify)( struct fnet_netif *netif ); /* Address change notification function.*/ 00113 void (*netif_drain)( struct fnet_netif *netif ); /* Memory drain function.*/ 00114 fnet_return_t (*netif_get_hw_addr)( struct fnet_netif *netif, fnet_uint8_t *hw_addr); /* Change HW address */ 00115 fnet_return_t (*netif_set_hw_addr)( struct fnet_netif *netif, fnet_uint8_t *hw_addr); /* Get HW address */ 00116 fnet_bool_t (*netif_is_connected)( struct fnet_netif *netif ); /* Connection state flag*/ 00117 fnet_return_t (*netif_get_statistics)( struct fnet_netif *netif, struct fnet_netif_statistics *statistics ); /* Get statistics */ 00118 #if FNET_CFG_MULTICAST 00119 #if FNET_CFG_IP4 00120 void (*netif_multicast_join_ip4)( struct fnet_netif *netif, fnet_ip4_addr_t multicast_addr ); /* Join IPv4 multicast group */ 00121 void (*netif_multicast_leave_ip4)( struct fnet_netif *netif, fnet_ip4_addr_t multicast_addr ); /* Leave IPv4 multicast group */ 00122 #endif 00123 #if FNET_CFG_IP6 00124 void (*netif_multicast_join_ip6)( struct fnet_netif *netif, const fnet_ip6_addr_t *multicast_addr ); /* Join IPv4 multicast group */ 00125 void (*netif_multicast_leave_ip6)( struct fnet_netif *netif, fnet_ip6_addr_t *multicast_addr ); /* Leave IPv6 multicast group */ 00126 #endif 00127 #endif 00128 #if FNET_CFG_IP6 00129 void (*netif_output_ip6)(struct fnet_netif *netif, const fnet_ip6_addr_t *src_ip_addr, const fnet_ip6_addr_t *dest_ip_addr, fnet_netbuf_t *nb); /* IPv6 Transmit function.*/ 00130 #endif 00131 } fnet_netif_api_t; 00132 00133 /* Forward declaration.*/ 00134 struct fnet_nd6_if; 00135 struct fnet_arp_if; 00136 00137 /**************************************************************************/ /*! 00138 * @internal 00139 * @brief Network interface structure. 00140 ******************************************************************************/ 00141 typedef struct fnet_netif 00142 { 00143 fnet_char_t netif_name[FNET_NETIF_NAMELEN]; /* Network interface name (e.g. "eth0", "loop"). */ 00144 fnet_size_t netif_mtu; /* Maximum transmission unit. */ 00145 void *netif_prv; /* Points to interface specific control data structure. It is optional. */ 00146 const fnet_netif_api_t *netif_api; /* Pointer to Interafce API structure.*/ 00147 00148 /* Privat structure fields.*/ 00149 struct fnet_netif *next; /* Pointer to the next net_if structure. */ 00150 struct fnet_netif *prev; /* Pointer to the previous net_if structure. */ 00151 fnet_scope_id_t scope_id; /* Scope zone index, defining network interface. Used by IPv6 sockets.*/ 00152 fnet_uint32_t features; /* Supported features. Bitwise of fnet_netif_feature_t.*/ 00153 fnet_bool_t is_connected; /* Connection state, updated by fnet_netif_is_connected() call.*/ 00154 fnet_time_t is_connected_timestamp; /* The timestamp, in milliseconds, when is_connected updated last time.*/ 00155 #if FNET_CFG_IP4 00156 fnet_netif_ip4_addr_t ip4_addr; /* The interface IPv4 address structure. */ 00157 fnet_bool_t ip4_addr_conflict; /* Flag if the ip4_addr is duplicated.*/ 00158 struct fnet_arp_if *arp_if_ptr; /* Pointer to the ARP structure, if the interface supports ARP. */ 00159 #endif 00160 #if FNET_CFG_IP6 00161 fnet_netif_ip6_addr_t ip6_addr[FNET_NETIF_IP6_ADDR_MAX]; /* The interface IPv6 address structure. */ 00162 struct fnet_nd6_if *nd6_if_ptr; /* Pointer to the ND structure, if the interface supports ND. */ 00163 #if FNET_CFG_MLD 00164 fnet_bool_t mld_invalid; /* Flag that, MLD message was sent with the unspecified address. 00165 * Once a valid link-local address is available, a node SHOULD generate 00166 * new MLD Report messages for all multicast addresses joined on the 00167 * interface.*/ 00168 #endif 00169 #if FNET_CFG_IP6_PMTU_DISCOVERY 00170 fnet_size_t pmtu; /* Path MTU, changed by Path MTU Discovery for IPv6. If 0 - is disabled.*/ 00171 fnet_time_t pmtu_timestamp; /* The timestamp, in milliseconds, when PMTU was changed last time.*/ 00172 fnet_timer_desc_t pmtu_timer; /* PMTU timer,used to detect increases in PMTU.*/ 00173 #endif 00174 #endif /* FNET_CFG_IP6 */ 00175 } fnet_netif_t; 00176 00177 /************************************************************************ 00178 * Global Data Structures 00179 *************************************************************************/ 00180 extern fnet_netif_t *fnet_netif_list; /* The list of network interfaces.*/ 00181 extern fnet_netif_t *fnet_netif_default; /* Default net_if. */ 00182 00183 /************************************************************************ 00184 * Function Prototypes 00185 *************************************************************************/ 00186 #if defined(__cplusplus) 00187 extern "C" { 00188 #endif 00189 00190 void fnet_netif_release_all( void ); 00191 void fnet_netif_drain( void ); 00192 void fnet_netif_signal_p4_addr_conflict( fnet_netif_desc_t netif ); 00193 00194 #if FNET_CFG_MULTICAST & FNET_CFG_IP4 00195 void _fnet_netif_join_ip4_multicast (fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr); 00196 void _fnet_netif_leave_ip4_multicast (fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr); 00197 #endif 00198 fnet_return_t _fnet_netif_set_hw_addr(fnet_netif_desc_t netif_desc, fnet_uint8_t *hw_addr, fnet_size_t hw_addr_size); 00199 00200 #if FNET_CFG_IP6 00201 fnet_netif_ip6_addr_t *fnet_netif_get_ip6_addr_info(fnet_netif_t *netif, const fnet_ip6_addr_t *ip_addr); 00202 fnet_return_t fnet_netif_bind_ip6_addr_prv(fnet_netif_t *netif, const fnet_ip6_addr_t *addr, fnet_netif_ip_addr_type_t addr_type, 00203 fnet_time_t lifetime /*in seconds*/, fnet_size_t prefix_length /* bits */ ); 00204 fnet_return_t fnet_netif_unbind_ip6_addr_prv ( fnet_netif_t *netif, fnet_netif_ip6_addr_t *if_addr ); 00205 fnet_bool_t fnet_netif_is_my_ip6_addr(fnet_netif_t *netif, const fnet_ip6_addr_t *ip_addr); 00206 fnet_netif_desc_t fnet_netif_get_by_ip6_addr( const fnet_ip6_addr_t *ip_addr ); 00207 fnet_bool_t fnet_netif_is_my_ip6_solicited_multicast_addr(fnet_netif_t *netif, fnet_ip6_addr_t *ip_addr); 00208 void fnet_netif_ip6_addr_timer ( fnet_netif_t *netif); 00209 fnet_return_t fnet_netif_set_ip6_addr_autoconf(fnet_netif_t *netif, fnet_ip6_addr_t *ip_addr); 00210 fnet_ip6_addr_t *fnet_netif_get_ip6_addr_valid_link_local (fnet_netif_t *netif); 00211 #if FNET_CFG_IP6_PMTU_DISCOVERY 00212 void fnet_netif_pmtu_init(fnet_netif_t *netif); 00213 void fnet_netif_pmtu_release(fnet_netif_t *netif); 00214 void fnet_netif_set_pmtu(fnet_netif_t *netif, fnet_size_t pmtu); 00215 #endif 00216 void _fnet_netif_join_ip6_multicast (fnet_netif_desc_t netif_desc, const fnet_ip6_addr_t *multicast_addr); 00217 void _fnet_netif_leave_ip6_multicast (fnet_netif_desc_t netif_desc, fnet_ip6_addr_t *multicast_addr); 00218 #endif /* FNET_CFG_IP6 */ 00219 00220 #if defined(__cplusplus) 00221 } 00222 #endif 00223 00224 #endif /* _FNET_NETIF_PRV_H_ */
Generated on Tue Jul 12 2022 13:54:22 by
