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"
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)
25 static void* GetSharedLibrary();
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
,
33 uint32_t prefixLength
,
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
,
41 uint32_t prefixLength
,
43 int32_t do_ifc_remove_route(const char *ifname
,
45 uint32_t prefixLength
,
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
,
53 uint32_t *prefixLength
,
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); \
70 MOZ_CRASH("Symbol not found in shared library : " #name); \