EtcPal  HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
View other versions:
netint.h
1 /******************************************************************************
2  * Copyright 2022 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************
16  * This file is a part of EtcPal. For more information, go to:
17  * https://github.com/ETCLabs/EtcPal
18  ******************************************************************************/
19 
20 /* etcpal_netint.h: Platform-neutral method for enumerating network interfaces. */
21 
22 #ifndef ETCPAL_NETINT_H_
23 #define ETCPAL_NETINT_H_
24 
25 #include <stdbool.h>
26 #include <stddef.h>
27 #include "etcpal/common.h"
28 #include "etcpal/inet.h"
29 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
106 etcpal_error_t etcpal_netint_get_interfaces(EtcPalNetintInfo* netints, size_t* num_netints);
108  EtcPalNetintInfo* netints,
109  size_t* num_netints);
111 
112 etcpal_error_t etcpal_netint_get_default_interface(etcpal_iptype_t type, unsigned int* netint_index);
113 etcpal_error_t etcpal_netint_get_interface_for_dest(const EtcPalIpAddr* dest, unsigned int* netint_index);
114 
116 
117 bool etcpal_netint_is_up(unsigned int netint_index);
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
127 #endif /* ETCPAL_NETINT_H_ */
etcpal_error_t
A set of error codes that can be returned by library functions.
Definition: error.h:49
etcpal_iptype_t
Used to identify the type of IP address contained in a EtcPalIpAddr.
Definition: inet.h:53
bool etcpal_netint_is_up(unsigned int netint_index)
Determine whether a network interface is currently up and running.
Definition: netint.c:352
etcpal_error_t etcpal_netint_refresh_interfaces()
Refresh the list of network interfaces.
Definition: netint.c:324
etcpal_error_t etcpal_netint_get_interface_with_ip(const EtcPalIpAddr *ip, EtcPalNetintInfo *netint)
Get the network interface that has the specified IP address.
Definition: netint.c:146
etcpal_error_t etcpal_netint_get_interface_for_dest(const EtcPalIpAddr *dest, unsigned int *netint_index)
Get the network interface that the system will choose when routing an IP packet to the specified dest...
Definition: netint.c:225
etcpal_error_t etcpal_netint_get_default_interface(etcpal_iptype_t type, unsigned int *netint_index)
Get information about the default network interface.
Definition: netint.c:179
etcpal_error_t etcpal_netint_get_interfaces(EtcPalNetintInfo *netints, size_t *num_netints)
Get a list of network interfaces on the system (or just the number of interfaces).
Definition: netint.c:90
etcpal_error_t etcpal_netint_get_interfaces_for_index(unsigned int netint_index, EtcPalNetintInfo *netints, size_t *num_netints)
Get a list of network interfaces (or just the number of interfaces) that have the index specified.
Definition: netint.c:120
An IP address.
Definition: inet.h:75
A description of a single address assigned to a network interface.
Definition: inet.h:355