blob: 3b272343d6950977961f58e62d838c1b0d86937b [file] [log] [blame]
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -04001/*
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__BEGIN_DECLS
24
25extern int ifc_init(void);
26extern void ifc_close(void);
27
28extern int ifc_get_ifindex(const char *name, int *if_indexp);
29extern int ifc_get_hwaddr(const char *name, void *ptr);
30
31extern int ifc_up(const char *name);
32extern int ifc_down(const char *name);
33
Sreeram Ramachandraneec23262014-07-23 09:30:53 -070034extern int ifc_enable(const char *ifname);
35extern int ifc_disable(const char *ifname);
36
Alex Yakavenka7c3d1c22011-11-08 20:25:23 +090037#define RESET_IPV4_ADDRESSES 0x01
38#define RESET_IPV6_ADDRESSES 0x02
Sreeram Ramachandran17622d02014-09-08 16:05:09 -070039#define RESET_IGNORE_INTERFACE_ADDRESS 0x04
Alex Yakavenka7c3d1c22011-11-08 20:25:23 +090040#define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
Wink Saville979203e2011-07-07 12:16:12 -070041extern int ifc_reset_connections(const char *ifname, const int reset_mask);
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040042
Dmitry Shmidt9092b912011-01-27 14:16:20 -080043extern int ifc_get_addr(const char *name, in_addr_t *addr);
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040044extern int ifc_set_addr(const char *name, in_addr_t addr);
Lorenzo Colitti47ddb512011-09-26 10:49:41 -070045extern 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);
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040050extern int ifc_set_hwaddr(const char *name, const void *ptr);
Lorenzo Colitti47ddb512011-09-26 10:49:41 -070051extern int ifc_clear_addresses(const char *name);
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040052
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040053extern int ifc_create_default_route(const char *name, in_addr_t addr);
Elliott Hughesc4630252015-02-03 19:56:35 +000054extern int ifc_remove_default_route(const char *ifname);
Lorenzo Colitti47ddb512011-09-26 10:49:41 -070055extern int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength,
56 unsigned *flags);
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040057
58extern int ifc_configure(const char *ifname, in_addr_t address,
Robert Greenwalt09dd8192011-02-01 15:21:21 -080059 uint32_t prefixLength, in_addr_t gateway,
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040060 in_addr_t dns1, in_addr_t dns2);
61
Dmitry Shmidt22bb8fc2012-07-23 15:40:15 -070062extern in_addr_t prefixLengthToIpv4Netmask(int prefix_length);
63
Szymon Jakubczakc88e09c2010-06-09 16:11:09 -040064__END_DECLS
65
66#endif /* _NETUTILS_IFC_H_ */