Embedded TCP/IP stack: fnet_netif.h Source File

FNET

fnet_netif.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2016 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 * Copyright 2003 by Andrey Butok, Alexey Shervashidze. Motorola SPS
6 *
7 ***************************************************************************
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 ***************************************************************************
22 *
23 * FNET Network interface API.
24 *
25 ***************************************************************************/
26 
27 #ifndef _FNET_NETIF_H_
28 
29 #define _FNET_NETIF_H_
30 
31 #include "fnet_ip4.h"
32 #include "fnet_ip6.h"
33 #include "fnet_eth.h"
34 #include "fnet_socket.h"
35 
43 /**************************************************************************/
46 typedef enum
47 {
53 
54 /**************************************************************************/
58 {
59  fnet_uint32_t tx_packet;
60  fnet_uint32_t rx_packet;
61 };
62 
63 /**************************************************************************/
66 #define FNET_NETIF_NAMELEN (8U)
67 
68 /**************************************************************************/
71 typedef void *fnet_netif_desc_t;
72 
73 #define FNET_NETIF_LL_ADDR_MAX (16)
74 /**************************************************************************/
78 typedef fnet_uint8_t fnet_netif_ll_addr_t[FNET_NETIF_LL_ADDR_MAX];
79 
80 /**************************************************************************/
83 #define FNET_NETIF_LL_ADDR_COPY(from_addr, to_addr, ll_size) \
84  (fnet_memcpy(&(to_addr)[0], &(from_addr)[0], (ll_size)))
85 
86 /**************************************************************************/
89 #define FNET_NETIF_LL_ADDR_ARE_EQUAL(a, b, size) \
90  (fnet_memcmp(&(a)[0], &(b)[0], (size)) == 0)
91 
92 /**************************************************************************/
96 typedef enum
97 {
112 
113 /**************************************************************************/
117 typedef enum
118 {
123 
124 /**************************************************************************/
129 {
134 
135 /**************************************************************************/
139 typedef struct fnet_netif_ip6_prefix
140 {
145 
146 /**************************************************************************/
151 {
157 
158 #if defined(__cplusplus)
159 extern "C" {
160 #endif
161 
162 /***************************************************************************/
183 
184 /***************************************************************************/
203 
204 /***************************************************************************/
224 
225 /***************************************************************************/
246 void fnet_netif_get_name( fnet_netif_desc_t netif_desc, fnet_char_t *name, fnet_size_t name_size );
247 
248 /***************************************************************************/
265 void fnet_netif_set_default( fnet_netif_desc_t netif_desc );
266 
267 /***************************************************************************/
285 
286 /***************************************************************************/
304 void fnet_netif_set_ip4_addr( fnet_netif_desc_t netif_desc, fnet_ip4_addr_t ipaddr, fnet_ip4_addr_t subnet_mask);
305 
306 /***************************************************************************/
322 
323 /***************************************************************************/
340 
341 /***************************************************************************/
358 
359 /***************************************************************************/
376 
377 /***************************************************************************/
394 
395 
396 #if FNET_CFG_DNS || defined(__DOXYGEN__)
397 /***************************************************************************/
415 
416 /***************************************************************************/
435 
436 #endif /*FNET_CFG_DNS*/
437 
438 /***************************************************************************/
466 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 );
467 
468 /***************************************************************************/
496 fnet_return_t fnet_netif_get_hw_addr( fnet_netif_desc_t netif_desc, fnet_uint8_t *hw_addr, fnet_size_t hw_addr_size );
497 
498 /***************************************************************************/
515 
516 /***************************************************************************/
535 
536 /***************************************************************************/
557 
558 /***************************************************************************/
576 
577 /***************************************************************************/
599 
600 /**************************************************************************/
611 
612 /***************************************************************************/
630 
631 /***************************************************************************/
653 
654 /***************************************************************************/
671 
672 #if (FNET_CFG_MULTICAST & FNET_CFG_IP4) || defined(__DOXYGEN__)
673 
674 /***************************************************************************/
696 void fnet_netif_join_ip4_multicast ( fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr );
697 
698 /***************************************************************************/
717 void fnet_netif_leave_ip4_multicast ( fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr );
718 
719 #endif /* FNET_CFG_MULTICAST & FNET_CFG_IP4*/
720 
721 #if FNET_CFG_IP6 || defined(__DOXYGEN__)
722 
723 /***************************************************************************/
744 void fnet_netif_join_ip6_multicast ( fnet_netif_desc_t netif_desc, const fnet_ip6_addr_t *multicast_addr );
745 
746 /***************************************************************************/
764 void fnet_netif_leave_ip6_multicast ( fnet_netif_desc_t netif_desc, fnet_ip6_addr_t *multicast_addr );
765 
766 /***************************************************************************/
787 
788 #if FNET_CFG_DNS || defined(__DOXYGEN__)
789 /***************************************************************************/
812 #endif /* FNET_CFG_DNS */
813 
814 /***************************************************************************/
847 
848 /***************************************************************************/
868 
869 /***************************************************************************/
891 
892 /***************************************************************************/
914 
915 #endif /* FNET_CFG_IP6 */
916 
917 /***************************************************************************/
933 
934 /***************************************************************************/
949 
950 /***************************************************************************/
969 
970 /***************************************************************************/
990 
991 /***************************************************************************/
1017 fnet_return_t fnet_netif_init(fnet_netif_desc_t netif_desc, fnet_uint8_t *hw_addr, fnet_size_t hw_addr_size );
1018 
1019 /***************************************************************************/
1035 void fnet_netif_release(fnet_netif_desc_t netif_desc);
1036 
1037 /***************************************************************************/
1054 
1055 #if defined(__cplusplus)
1056 }
1057 #endif
1058 
1061 #endif /* _FNET_NETIF_H_ */
fnet_netif_desc_t fnet_netif_get_by_name(const fnet_char_t *name)
Looks for a network interface according to the specified name.
fnet_ip6_addr_t address
IPv6 address.
Definition: fnet_netif.h:130
Ethernet interface.
Definition: fnet_netif.h:49
struct fnet_netif_ip6_addr_info fnet_netif_ip6_addr_info_t
Interface IPv6 address information structure.
struct fnet_netif_ip6_prefix fnet_netif_ip6_prefix_t
Interface IPv6 Prefix structure.
fnet_scope_id_t fnet_netif_get_scope_id(fnet_netif_desc_t netif_desc)
Retrieves an Scope ID of the specified network interface.
struct fnet_netif_ip6_neighbor_cache fnet_netif_ip6_neighbor_cache_t
Interface IPv6 Neighbor Cache structure.
fnet_netif_ip_addr_type_t fnet_netif_get_ip4_addr_type(fnet_netif_desc_t netif_desc)
Determines the way IPv4 address parameters were obtained.
Interface IPv6 address information structure.
Definition: fnet_netif.h:128
fnet_netif_ip_addr_type_t
Possible IPv6 address types.
Definition: fnet_netif.h:117
Interface IPv6 Neighbor Cache structure.
Definition: fnet_netif.h:150
fnet_netif_desc_t fnet_netif_get_default(void)
Retrieves the default network interface.
fnet_ip4_addr_t fnet_netif_get_ip4_dns(fnet_netif_desc_t netif_desc)
Retrieves the DNS server IP address of the specified network interface.
fnet_uint32_t fnet_scope_id_t
cope zone index type, defining network interface.
Definition: fnet_socket.h:144
fnet_ip4_addr_t fnet_netif_get_ip4_subnet_mask(fnet_netif_desc_t netif_desc)
Retrieves a subnet mask of the specified network interface.
fnet_bool_t fnet_netif_is_initialized(fnet_netif_desc_t netif_desc)
Determines if the network interface is initialized.
fnet_netif_ip6_addr_state_t state
Address current state.
Definition: fnet_netif.h:131
fnet_return_t fnet_netif_bind_ip6_addr(fnet_netif_desc_t netif_desc, const fnet_ip6_addr_t *addr, fnet_netif_ip_addr_type_t addr_type)
Binds the IPv6 address to the specified network interface.
fnet_netif_ll_addr_t ll_addr
Its link-layer address. Actual size is defiined by ll_addr_size.
Definition: fnet_netif.h:153
fnet_size_t prefix_length
Prefix length (in bits). The number of leading bits in the Prefix that are valid. ...
Definition: fnet_netif.h:142
fnet_netif_type_t fnet_netif_get_type(fnet_netif_desc_t netif_desc)
Retrieves the type of the specified network interface.
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:90
fnet_return_t fnet_netif_unbind_ip6_addr(fnet_netif_desc_t netif_desc, const fnet_ip6_addr_t *addr)
Unbinds the IPv6 address from the specified network interface.
void fnet_netif_leave_ip6_multicast(fnet_netif_desc_t netif_desc, fnet_ip6_addr_t *multicast_addr)
Leaves the specified network interface from IPv6 multicast group.
Preferred address - (RFC4862) an address assigned to an interface whose use by upper-layer protocols ...
Definition: fnet_netif.h:106
The address is set using "Auto-IP" link-local autoconfiguration.
Definition: fnet_netif.h:120
fnet_bool_t fnet_netif_get_ip6_neighbor_cache(fnet_netif_desc_t netif_desc, fnet_index_t n, fnet_netif_ip6_neighbor_cache_t *ip6_neighbor_cache)
Retrieves the n-th IPv6 neighbor cache entry of the specified network interface.
void fnet_netif_set_ip4_addr(fnet_netif_desc_t netif_desc, fnet_ip4_addr_t ipaddr, fnet_ip4_addr_t subnet_mask)
Sets the IPv4 address of the specified network interface.
fnet_size_t ll_addr_size
Size of link-layer address.
Definition: fnet_netif.h:154
fnet_ip6_addr_t prefix
Prefix of an IPv6 address.
Definition: fnet_netif.h:141
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:56
128-bit IPv6 address type.
Definition: fnet_ip6.h:38
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)
Sets the hardware address of the specified network interface.
void fnet_netif_set_default(fnet_netif_desc_t netif_desc)
Assigns the default network interface.
fnet_bool_t fnet_netif_get_ip6_addr(fnet_netif_desc_t netif_desc, fnet_index_t n, fnet_netif_ip6_addr_info_t *addr_info)
Retrieves an IPv6 address of the specified network interface.
void fnet_netif_get_name(fnet_netif_desc_t netif_desc, fnet_char_t *name, fnet_size_t name_size)
Retrieves a name of the specified network interface.
fnet_uint32_t tx_packet
Tx packet count.
Definition: fnet_netif.h:59
fnet_ip4_addr_t fnet_netif_get_ip4_addr(fnet_netif_desc_t netif_desc)
Retrieves an IPv4 address of the specified network interface.
fnet_return_t fnet_netif_init(fnet_netif_desc_t netif_desc, fnet_uint8_t *hw_addr, fnet_size_t hw_addr_size)
Initializes network interface and adds it to FNET stack.
void fnet_netif_join_ip4_multicast(fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr)
Joins the specified network interface to IPv4 multicast group.
fnet_netif_ip6_addr_state_t
Possible IPv6 address states.
Definition: fnet_netif.h:96
void fnet_netif_join_ip6_multicast(fnet_netif_desc_t netif_desc, const fnet_ip6_addr_t *multicast_addr)
Joins the specified network interface to IPv6 multicast group.
void fnet_netif_set_ip4_subnet_mask(fnet_netif_desc_t netif_desc, fnet_ip4_addr_t subnet_mask)
Sets the subnet mask of the specified network interface.
fnet_netif_desc_t fnet_netif_get_by_scope_id(fnet_scope_id_t scope_id)
Looks for a network interface according to the specified Scope ID.
Loopback interface.
Definition: fnet_netif.h:51
Interface IPv6 Prefix structure.
Definition: fnet_netif.h:139
void fnet_netif_clear_ip4_addr_conflict(fnet_netif_desc_t netif_desc)
Clears IPv4 address conflict flag.
Network interface statistics, used by the fnet_netif_get_statistics().
Definition: fnet_netif.h:57
fnet_uint32_t rx_packet
Rx packet count.
Definition: fnet_netif.h:60
fnet_return_t fnet_netif_get_hw_addr(fnet_netif_desc_t netif_desc, fnet_uint8_t *hw_addr, fnet_size_t hw_addr_size)
Retrieves a hardware address of the specified network interface.
Tentative address - (RFC4862) an address whose uniqueness on a link is being verified, prior to its assignment to an interface. A tentative address is not considered assigned to an interface in the usual sense. An interface discards received packets addressed to a tentative address, but accepts Neighbor Discovery packets related to Duplicate Address Detection for the tentative address.
Definition: fnet_netif.h:99
The address is set using DHCP.
Definition: fnet_netif.h:121
fnet_uint8_t fnet_netif_ll_addr_t[FNET_NETIF_LL_ADDR_MAX]
Link-layer address. For example, Ethernet interafce uses the address with size set to 6...
Definition: fnet_netif.h:78
fnet_bool_t
Boolean type.
Definition: fnet_stdlib.h:81
void fnet_netif_leave_ip4_multicast(fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr)
Leaves the specified network interface from IPv4 multicast group.
void fnet_netif_set_ip4_gateway(fnet_netif_desc_t netif_desc, fnet_ip4_addr_t gw)
Sets the gateway IP address of the specified network interface.
Wi-Fi interface.
Definition: fnet_netif.h:50
void fnet_netif_set_ip4_dns(fnet_netif_desc_t netif_desc, fnet_ip4_addr_t dns)
Sets the DNS server IPv4 address of the specified network interface.
Unspecified interface.
Definition: fnet_netif.h:48
fnet_bool_t fnet_netif_get_ip6_dns(fnet_netif_desc_t netif_desc, fnet_index_t n, fnet_ip6_addr_t *addr_dns)
Retrieves the n-th DNS IPv6 address of the specified network interface.
fnet_netif_desc_t fnet_netif_get_by_sockaddr(const struct fnet_sockaddr *addr)
Looks for a network interface according to the specified socket address.
fnet_ip4_addr_t fnet_netif_get_ip4_gateway(fnet_netif_desc_t netif_desc)
Retrieves a gateway IPv4 address of the specified network interface.
fnet_bool_t is_router
A flag indicating whether the neighbor is a router (FNET_TRUE) or a host (FNET_FALSE).
Definition: fnet_netif.h:155
fnet_ip6_addr_t ip_addr
Neighbor�s on-link unicast IP address.
Definition: fnet_netif.h:152
fnet_bool_t fnet_netif_get_ip6_prefix(fnet_netif_desc_t netif_desc, fnet_index_t n, fnet_netif_ip6_prefix_t *ip6_prefix)
Retrieves the n-th IPv6 prefix of the specified network interface.
unsigned int fnet_index_t
Unsigned integer type representing the index.
Definition: fnet_stdlib.h:71
fnet_uint32_t fnet_ip4_addr_t
32-bit IPv4 address type.
Definition: fnet_ip4.h:36
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:76
void fnet_netif_release(fnet_netif_desc_t netif_desc)
Releases network interface and removes it from FNET stack.
fnet_bool_t fnet_netif_is_connected(fnet_netif_desc_t netif_desc)
Determines the link status of the network interface.
fnet_return_t fnet_netif_get_statistics(fnet_netif_desc_t netif_desc, struct fnet_netif_statistics *statistics)
Retrieves the network interface statistics.
fnet_size_t fnet_netif_get_mtu(fnet_netif_desc_t netif_desc)
Retrieves a Maximum Transmission Unit (MTU) of the specified network interface.
fnet_netif_desc_t fnet_netif_get_by_number(fnet_index_t n)
Looks for a network interface according to its number.
void * fnet_netif_desc_t
Network interface descriptor.
Definition: fnet_netif.h:71
fnet_netif_ip_addr_type_t type
How the address was acquired.
Definition: fnet_netif.h:132
The address is set manually.
Definition: fnet_netif.h:119
Socket address structure.
Definition: fnet_socket.h:270
void fnet_netif_set_ip4_addr_type(fnet_netif_desc_t netif_desc, fnet_netif_ip_addr_type_t ipaddr_type)
Sets the way IPv4 address parameters were obtained.
fnet_netif_type_t
Network interface types.
Definition: fnet_netif.h:46
fnet_bool_t fnet_netif_is_ip4_addr_conflict(fnet_netif_desc_t netif_desc)
Determines if there is IPv4 address conflict.
fnet_netif_desc_t fnet_netif_get_by_ip4_addr(fnet_ip4_addr_t addr)
Looks for a network interface according to the specified IPv4 address.
void fnet_netif_set_callback_on_ip4_addr_conflict(fnet_netif_callback_ip4_addr_conflict_t callback)
Registers the "IPv4 address conflict" event handler.
void(* fnet_netif_callback_ip4_addr_conflict_t)(fnet_netif_desc_t netif)
Event handler callback function prototype, that is called when there is an IP address conflict with a...
Definition: fnet_netif.h:610

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net