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