1c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak/*
2c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * Copyright 2008, The Android Open Source Project
3c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak *
4c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * Licensed under the Apache License, Version 2.0 (the "License");
5c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * you may not use this file except in compliance with the License.
6c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * You may obtain a copy of the License at
7c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak *
8c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak *     http://www.apache.org/licenses/LICENSE-2.0
9c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak *
10c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * Unless required by applicable law or agreed to in writing, software
11c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * distributed under the License is distributed on an "AS IS" BASIS,
12c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * See the License for the specific language governing permissions and
14c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak * limitations under the License.
15c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak */
16c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
17c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak#ifndef _NETUTILS_IFC_H_
18c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak#define _NETUTILS_IFC_H_
19c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
20c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak#include <sys/cdefs.h>
21c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak#include <arpa/inet.h>
22c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
23c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak__BEGIN_DECLS
24c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
25c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_init(void);
26c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern void ifc_close(void);
27c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
28c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_get_ifindex(const char *name, int *if_indexp);
29c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_get_hwaddr(const char *name, void *ptr);
30c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
31c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_up(const char *name);
32c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_down(const char *name);
33c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
34eec232603d314e486888e5a0d2dd8d507c266be7Sreeram Ramachandranextern int ifc_enable(const char *ifname);
35eec232603d314e486888e5a0d2dd8d507c266be7Sreeram Ramachandranextern int ifc_disable(const char *ifname);
36eec232603d314e486888e5a0d2dd8d507c266be7Sreeram Ramachandran
377c3d1c291ab5f9efb2efcfd5def1baeea1255917Alex Yakavenka#define RESET_IPV4_ADDRESSES 0x01
387c3d1c291ab5f9efb2efcfd5def1baeea1255917Alex Yakavenka#define RESET_IPV6_ADDRESSES 0x02
3917622d09d5ba54ae3c8b11644c6d7556bdc6644cSreeram Ramachandran#define RESET_IGNORE_INTERFACE_ADDRESS 0x04
407c3d1c291ab5f9efb2efcfd5def1baeea1255917Alex Yakavenka#define RESET_ALL_ADDRESSES  (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
41979203ee34084327bf4f20ad1f878450de94826eWink Savilleextern int ifc_reset_connections(const char *ifname, const int reset_mask);
42c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
439092b91ccaa4c6069036f72163e6473a5ca408c4Dmitry Shmidtextern int ifc_get_addr(const char *name, in_addr_t *addr);
44c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_set_addr(const char *name, in_addr_t addr);
4547ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colittiextern int ifc_add_address(const char *name, const char *address,
4647ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colitti                           int prefixlen);
4747ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colittiextern int ifc_del_address(const char *name, const char *address,
4847ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colitti                           int prefixlen);
4947ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colittiextern int ifc_set_prefixLength(const char *name, int prefixLength);
50c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_set_hwaddr(const char *name, const void *ptr);
5147ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colittiextern int ifc_clear_addresses(const char *name);
52c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
53c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_create_default_route(const char *name, in_addr_t addr);
54c463025a19aff3f9f92cffa3de6462316e8407a7Elliott Hughesextern int ifc_remove_default_route(const char *ifname);
5547ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colittiextern int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength,
5647ddb515b7d59b29d83628c1b4e48642dc0e49baLorenzo Colitti                        unsigned *flags);
57c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
58c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczakextern int ifc_configure(const char *ifname, in_addr_t address,
5909dd819d2794caf1a17cd03592c100755fb25577Robert Greenwalt                         uint32_t prefixLength, in_addr_t gateway,
60c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak                         in_addr_t dns1, in_addr_t dns2);
61c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
6222bb8fc5fe7c10fb9c7b8c4cfeb244c837e3e0c7Dmitry Shmidtextern in_addr_t prefixLengthToIpv4Netmask(int prefix_length);
6322bb8fc5fe7c10fb9c7b8c4cfeb244c837e3e0c7Dmitry Shmidt
64c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak__END_DECLS
65c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak
66c88e09cb98fb3690c3cf49f5a825532e0d9bf300Szymon Jakubczak#endif /* _NETUTILS_IFC_H_ */
67