Embedded TCP/IP stack  4.7.0
fnet_netif.h
1 /**************************************************************************
2 *
3 * Copyright 2008-2018 by Andrey Butok. FNET Community.
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * FNET Network interface API.
22 *
23 ***************************************************************************/
24 
25 #ifndef _FNET_NETIF_H_
26 
27 #define _FNET_NETIF_H_
28 
29 #include "fnet_ip4.h"
30 #include "fnet_ip6.h"
31 #include "fnet_socket.h"
32 
40 /**************************************************************************/
43 typedef enum
44 {
50 
51 /**************************************************************************/
55 {
56  fnet_uint32_t tx_packet;
57  fnet_uint32_t rx_packet;
58 };
59 
60 /**************************************************************************/
63 #define FNET_NETIF_NAMELEN (8U)
64 
65 /**************************************************************************/
68 typedef void *fnet_netif_desc_t;
69 
70 #define FNET_NETIF_LL_ADDR_MAX (16)
71 /**************************************************************************/
75 typedef fnet_uint8_t fnet_netif_ll_addr_t[FNET_NETIF_LL_ADDR_MAX];
76 
77 /**************************************************************************/
80 #define FNET_NETIF_LL_ADDR_COPY(from_addr, to_addr, ll_size) \
81  (fnet_memcpy(&(to_addr)[0], &(from_addr)[0], (ll_size)))
82 
83 /**************************************************************************/
86 #define FNET_NETIF_LL_ADDR_ARE_EQUAL(a, b, size) \
87  (fnet_memcmp(&(a)[0], &(b)[0], (size)) == 0)
88 
89 /**************************************************************************/
93 typedef enum
94 {
107 
108 /**************************************************************************/
112 typedef enum
113 {
118 
119 /**************************************************************************/
124 {
129 
130 /**************************************************************************/
134 typedef struct fnet_netif_ip6_prefix
135 {
140 
141 /**************************************************************************/
146 {
152 
153 #if defined(__cplusplus)
154 extern "C" {
155 #endif
156 
157 /***************************************************************************/
178 
179 /***************************************************************************/
198 
199 /***************************************************************************/
219 
220 /***************************************************************************/
241 void fnet_netif_get_name( fnet_netif_desc_t netif_desc, fnet_char_t *name, fnet_size_t name_size );
242 
243 /***************************************************************************/
260 void fnet_netif_set_default( fnet_netif_desc_t netif_desc );
261 
262 /***************************************************************************/
280 
281 /***************************************************************************/
299 void fnet_netif_set_ip4_addr( fnet_netif_desc_t netif_desc, fnet_ip4_addr_t ipaddr, fnet_ip4_addr_t subnet_mask);
300 
301 /***************************************************************************/
317 
318 /***************************************************************************/
335 
336 /***************************************************************************/
353 
354 /***************************************************************************/
371 
372 
373 #if FNET_CFG_DNS || defined(__DOXYGEN__)
374 /***************************************************************************/
392 
393 /***************************************************************************/
412 
413 #endif /*FNET_CFG_DNS*/
414 
415 /***************************************************************************/
442 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 );
443 
444 /***************************************************************************/
472 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 );
473 
474 /***************************************************************************/
491 
492 /***************************************************************************/
511 
512 /***************************************************************************/
533 
534 /***************************************************************************/
552 
553 /***************************************************************************/
575 
576 
577 #if FNET_CFG_IP4 || defined(__DOXYGEN__)
578 
579 /**************************************************************************/
590 
591 /***************************************************************************/
609 
610 /***************************************************************************/
632 
633 /***************************************************************************/
650 
651 #endif /* FNET_CFG_IP4 */
652 
653 #if (FNET_CFG_MULTICAST & FNET_CFG_IP4) || defined(__DOXYGEN__)
654 
655 /***************************************************************************/
677 void fnet_netif_join_ip4_multicast ( fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr );
678 
679 /***************************************************************************/
698 void fnet_netif_leave_ip4_multicast ( fnet_netif_desc_t netif_desc, fnet_ip4_addr_t multicast_addr );
699 
700 #endif /* FNET_CFG_MULTICAST & FNET_CFG_IP4*/
701 
702 #if FNET_CFG_IP6 || defined(__DOXYGEN__)
703 
704 /***************************************************************************/
725 void fnet_netif_join_ip6_multicast ( fnet_netif_desc_t netif_desc, const fnet_ip6_addr_t *multicast_addr );
726 
727 /***************************************************************************/
745 void fnet_netif_leave_ip6_multicast ( fnet_netif_desc_t netif_desc, fnet_ip6_addr_t *multicast_addr );
746 
747 /***************************************************************************/
768 
769 #if FNET_CFG_DNS || defined(__DOXYGEN__)
770 /***************************************************************************/
793 #endif /* FNET_CFG_DNS */
794 
795 /***************************************************************************/
828 
829 /***************************************************************************/
849 
850 /***************************************************************************/
872 
873 /***************************************************************************/
895 
896 
897 /***************************************************************************/
917 
918 #endif /* FNET_CFG_IP6 */
919 
920 /***************************************************************************/
936 
937 /***************************************************************************/
952 
953 /***************************************************************************/
972 
973 /***************************************************************************/
993 
994 /***************************************************************************/
1020 fnet_return_t fnet_netif_init(fnet_netif_desc_t netif_desc, fnet_uint8_t *hw_addr, fnet_size_t hw_addr_size );
1021 
1022 /***************************************************************************/
1038 void fnet_netif_release(fnet_netif_desc_t netif_desc);
1039 
1040 /***************************************************************************/
1057 
1058 #if defined(__cplusplus)
1059 }
1060 #endif
1061 
1064 #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:125
Ethernet interface.
Definition: fnet_netif.h:46
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:123
fnet_netif_desc_t fnet_netif_get_by_ip6_addr(const fnet_ip6_addr_t *ip_addr)
Looks for a network interface according to the specified IPv6 address.
fnet_netif_ip_addr_type_t
Possible IPv6 address types.
Definition: fnet_netif.h:112
Interface IPv6 Neighbor Cache structure.
Definition: fnet_netif.h:145
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:142
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:126
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:148
fnet_size_t prefix_length
Prefix length (in bits). The number of leading bits in the Prefix that are valid. ...
Definition: fnet_netif.h:137
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:89
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:102
The address is set using "Auto-IP" link-local autoconfiguration.
Definition: fnet_netif.h:115
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:149
fnet_ip6_addr_t prefix
Prefix of an IPv6 address.
Definition: fnet_netif.h:136
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:55
128-bit IPv6 address type.
Definition: fnet_ip6.h:37
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:56
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:93
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.
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:48
Interface IPv6 Prefix structure.
Definition: fnet_netif.h:134
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:54
fnet_uint32_t rx_packet
Rx packet count.
Definition: fnet_netif.h:57
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:96
The address is set using DHCP.
Definition: fnet_netif.h:116
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:75
fnet_bool_t
Boolean type.
Definition: fnet_stdlib.h:80
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:47
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:45
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:150
fnet_ip6_addr_t ip_addr
Neighbor’s on-link unicast IP address.
Definition: fnet_netif.h:147
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:70
fnet_uint32_t fnet_ip4_addr_t
32-bit IPv4 address type.
Definition: fnet_ip4.h:35
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:75
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:68
fnet_netif_ip_addr_type_t type
How the address was acquired.
Definition: fnet_netif.h:127
The address is set manually.
Definition: fnet_netif.h:114
Socket address structure.
Definition: fnet_socket.h:268
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:43
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:589

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net