Bumping manifests a=b2g-bump
[gecko.git] / dom / network / NetUtils.h
blob6ae2894ab120b10967782593d78246d091c88706
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /**
6 * Abstraction on top of the network support from libnetutils that we
7 * use to set up network connections.
8 */
10 #ifndef NetUtils_h
11 #define NetUtils_h
13 #include "arpa/inet.h"
15 // Copied from ifc.h
16 #define RESET_IPV4_ADDRESSES 0x01
17 #define RESET_IPV6_ADDRESSES 0x02
18 #define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
20 // Implements netutils functions. No need for an abstract class here since we
21 // only have a one sdk specific method (dhcp_do_request)
22 class NetUtils
24 public:
25 static void* GetSharedLibrary();
27 NetUtils();
29 int32_t do_ifc_enable(const char *ifname);
30 int32_t do_ifc_disable(const char *ifname);
31 int32_t do_ifc_configure(const char *ifname,
32 in_addr_t address,
33 uint32_t prefixLength,
34 in_addr_t gateway,
35 in_addr_t dns1,
36 in_addr_t dns2);
37 int32_t do_ifc_reset_connections(const char *ifname, const int32_t resetMask);
38 int32_t do_ifc_set_default_route(const char *ifname, in_addr_t gateway);
39 int32_t do_ifc_add_route(const char *ifname,
40 const char *dst,
41 uint32_t prefixLength,
42 const char *gateway);
43 int32_t do_ifc_remove_route(const char *ifname,
44 const char *dst,
45 uint32_t prefixLength,
46 const char *gateway);
47 int32_t do_ifc_remove_host_routes(const char *ifname);
48 int32_t do_ifc_remove_default_route(const char *ifname);
49 int32_t do_dhcp_stop(const char *ifname);
50 int32_t do_dhcp_do_request(const char *ifname,
51 char *ipaddr,
52 char *gateway,
53 uint32_t *prefixLength,
54 char *dns1,
55 char *dns2,
56 char *server,
57 uint32_t *lease,
58 char* vendorinfo);
60 static int32_t SdkVersion();
63 // Defines a function type with the right arguments and return type.
64 #define DEFINE_DLFUNC(name, ret, args...) typedef ret (*FUNC##name)(args);
66 // Set up a dlsymed function ready to use.
67 #define USE_DLFUNC(name) \
68 FUNC##name name = (FUNC##name) dlsym(GetSharedLibrary(), #name); \
69 if (!name) { \
70 MOZ_CRASH("Symbol not found in shared library : " #name); \
73 #endif // NetUtils_h