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/. */
6 * Abstraction on top of the network support from libnetutils that we
7 * use to set up network connections.
13 #include "arpa/inet.h"
14 #include "mozilla/Mutex.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)
26 static void* GetSharedLibrary();
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
,
34 uint32_t prefixLength
,
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
,
42 uint32_t prefixLength
,
44 int32_t do_ifc_remove_route(const char *ifname
,
46 uint32_t prefixLength
,
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
,
54 uint32_t *prefixLength
,
61 static int32_t SdkVersion();
64 mozilla::Mutex mIfcMutex
;
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); \
74 MOZ_CRASH("Symbol not found in shared library : " #name); \