Bumping gaia.json for 1 gaia revision(s) a=gaia-bump
[gecko.git] / dom / network / NetUtils.h
blob0d4116d2cb46bacd4712907bd7bceadfccb87b47
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"
14 #include "prlock.h"
16 // Copied from ifc.h
17 #define RESET_IPV4_ADDRESSES 0x01
18 #define RESET_IPV6_ADDRESSES 0x02
19 #define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
21 // Implements netutils functions. No need for an abstract class here since we
22 // only have a one sdk specific method (dhcp_do_request)
23 class NetUtils
25 public:
26 static void* GetSharedLibrary();
28 NetUtils();
30 int32_t do_ifc_enable(const char *ifname);
31 int32_t do_ifc_disable(const char *ifname);
32 int32_t do_ifc_configure(const char *ifname,
33 in_addr_t address,
34 uint32_t prefixLength,
35 in_addr_t gateway,
36 in_addr_t dns1,
37 in_addr_t dns2);
38 int32_t do_ifc_reset_connections(const char *ifname, const int32_t resetMask);
39 int32_t do_ifc_set_default_route(const char *ifname, in_addr_t gateway);
40 int32_t do_ifc_add_route(const char *ifname,
41 const char *dst,
42 uint32_t prefixLength,
43 const char *gateway);
44 int32_t do_ifc_remove_route(const char *ifname,
45 const char *dst,
46 uint32_t prefixLength,
47 const char *gateway);
48 int32_t do_ifc_remove_host_routes(const char *ifname);
49 int32_t do_ifc_remove_default_route(const char *ifname);
50 int32_t do_dhcp_stop(const char *ifname);
51 int32_t do_dhcp_do_request(const char *ifname,
52 char *ipaddr,
53 char *gateway,
54 uint32_t *prefixLength,
55 char *dns1,
56 char *dns2,
57 char *server,
58 uint32_t *lease,
59 char* vendorinfo);
61 static int32_t SdkVersion();
63 private:
64 static PRLock* sIfcLock;
67 // Defines a function type with the right arguments and return type.
68 #define DEFINE_DLFUNC(name, ret, args...) typedef ret (*FUNC##name)(args);
70 // Set up a dlsymed function ready to use.
71 #define USE_DLFUNC(name) \
72 FUNC##name name = (FUNC##name) dlsym(GetSharedLibrary(), #name); \
73 if (!name) { \
74 MOZ_CRASH("Symbol not found in shared library : " #name); \
77 #endif // NetUtils_h