blob: 9233f87f69a67944a8a1640e99c193b1cb8e9f1e [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2 * Copyright 2008, The Android Open Source Project
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
17#ifndef _NETUTILS_IFC_H_
18#define _NETUTILS_IFC_H_
19
20//#include <sys/cdefs.h>
21#include <arpa/inet.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26extern int ifc_init(void);
27extern void ifc_close(void);
28
29extern int ifc_get_ifindex(const char *name, int *if_indexp);
30extern int ifc_get_hwaddr(const char *name, void *ptr);
31
32extern int ifc_up(const char *name);
33extern int ifc_down(const char *name);
34
35extern int ifc_enable(const char *ifname);
36extern int ifc_disable(const char *ifname);
37
38#define RESET_IPV4_ADDRESSES 0x01
39#define RESET_IPV6_ADDRESSES 0x02
40#define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
41extern int ifc_reset_connections(const char *ifname, const int reset_mask);
42
43extern int ifc_get_addr(const char *name, in_addr_t *addr);
44extern int ifc_set_addr(const char *name, in_addr_t addr);
45extern int ifc_add_address(const char *name, const char *address,
46 int prefixlen);
47extern int ifc_del_address(const char *name, const char *address,
48 int prefixlen);
49extern int ifc_set_prefixLength(const char *name, int prefixLength);
50extern int ifc_set_hwaddr(const char *name, const void *ptr);
51extern int ifc_clear_addresses(const char *name);
52
53/* This function is deprecated. Use ifc_add_route instead. */
54extern int ifc_add_host_route(const char *name, in_addr_t addr);
55extern int ifc_remove_host_routes(const char *name);
56extern int ifc_get_default_route(const char *ifname);
57/* This function is deprecated. Use ifc_add_route instead */
58extern int ifc_set_default_route(const char *ifname, in_addr_t gateway);
59/* This function is deprecated. Use ifc_add_route instead */
60extern int ifc_create_default_route(const char *name, in_addr_t addr);
61extern int ifc_remove_default_route(const char *ifname);
62extern int ifc_add_route(const char *name, const char *addr, int prefix_length,
63 const char *gw);
64extern int ifc_remove_route(const char *ifname, const char *dst,
65 int prefix_length, const char *gw);
66extern int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength,
67 unsigned *flags);
68
69extern int ifc_configure(const char *ifname, in_addr_t address,
70 uint32_t prefixLength, in_addr_t gateway,
71 in_addr_t dns1, in_addr_t dns2);
72
73extern in_addr_t prefixLengthToIpv4Netmask(int prefix_length);
74
75#ifdef __cplusplus
76}
77#endif
78#endif /* _NETUTILS_IFC_H_ */