gecko/dom/network/NetUtils.h
Birunthan Mohanathas 882fe73908 Bug 1058101 - Flatten dom/network/src/ into parent directory. r=mccr8
--HG--
rename : dom/network/src/Connection.cpp => dom/network/Connection.cpp
rename : dom/network/src/Connection.h => dom/network/Connection.h
rename : dom/network/src/Constants.h => dom/network/Constants.h
rename : dom/network/src/NetUtils.cpp => dom/network/NetUtils.cpp
rename : dom/network/src/NetUtils.h => dom/network/NetUtils.h
rename : dom/network/src/NetworkStatsDB.jsm => dom/network/NetworkStatsDB.jsm
rename : dom/network/src/NetworkStatsManager.js => dom/network/NetworkStatsManager.js
rename : dom/network/src/NetworkStatsManager.manifest => dom/network/NetworkStatsManager.manifest
rename : dom/network/src/NetworkStatsService.jsm => dom/network/NetworkStatsService.jsm
rename : dom/network/src/NetworkStatsServiceProxy.js => dom/network/NetworkStatsServiceProxy.js
rename : dom/network/src/NetworkStatsServiceProxy.manifest => dom/network/NetworkStatsServiceProxy.manifest
rename : dom/network/src/PTCPServerSocket.ipdl => dom/network/PTCPServerSocket.ipdl
rename : dom/network/src/PTCPSocket.ipdl => dom/network/PTCPSocket.ipdl
rename : dom/network/src/PUDPSocket.ipdl => dom/network/PUDPSocket.ipdl
rename : dom/network/src/TCPServerSocket.js => dom/network/TCPServerSocket.js
rename : dom/network/src/TCPServerSocketChild.cpp => dom/network/TCPServerSocketChild.cpp
rename : dom/network/src/TCPServerSocketChild.h => dom/network/TCPServerSocketChild.h
rename : dom/network/src/TCPServerSocketParent.cpp => dom/network/TCPServerSocketParent.cpp
rename : dom/network/src/TCPServerSocketParent.h => dom/network/TCPServerSocketParent.h
rename : dom/network/src/TCPSocket.js => dom/network/TCPSocket.js
rename : dom/network/src/TCPSocket.manifest => dom/network/TCPSocket.manifest
rename : dom/network/src/TCPSocketChild.cpp => dom/network/TCPSocketChild.cpp
rename : dom/network/src/TCPSocketChild.h => dom/network/TCPSocketChild.h
rename : dom/network/src/TCPSocketParent.cpp => dom/network/TCPSocketParent.cpp
rename : dom/network/src/TCPSocketParent.h => dom/network/TCPSocketParent.h
rename : dom/network/src/TCPSocketParentIntermediary.js => dom/network/TCPSocketParentIntermediary.js
rename : dom/network/src/Types.h => dom/network/Types.h
rename : dom/network/src/UDPSocket.cpp => dom/network/UDPSocket.cpp
rename : dom/network/src/UDPSocket.h => dom/network/UDPSocket.h
rename : dom/network/src/UDPSocketChild.cpp => dom/network/UDPSocketChild.cpp
rename : dom/network/src/UDPSocketChild.h => dom/network/UDPSocketChild.h
rename : dom/network/src/UDPSocketParent.cpp => dom/network/UDPSocketParent.cpp
rename : dom/network/src/UDPSocketParent.h => dom/network/UDPSocketParent.h
2014-08-27 10:13:39 -07:00

72 lines
2.7 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Abstraction on top of the network support from libnetutils that we
* use to set up network connections.
*/
#ifndef NetUtils_h
#define NetUtils_h
#include "arpa/inet.h"
// Copied from ifc.h
#define RESET_IPV4_ADDRESSES 0x01
#define RESET_IPV6_ADDRESSES 0x02
#define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES)
// Implements netutils functions. No need for an abstract class here since we
// only have a one sdk specific method (dhcp_do_request)
class NetUtils
{
public:
static void* GetSharedLibrary();
int32_t do_ifc_enable(const char *ifname);
int32_t do_ifc_disable(const char *ifname);
int32_t do_ifc_configure(const char *ifname,
in_addr_t address,
uint32_t prefixLength,
in_addr_t gateway,
in_addr_t dns1,
in_addr_t dns2);
int32_t do_ifc_reset_connections(const char *ifname, const int32_t resetMask);
int32_t do_ifc_set_default_route(const char *ifname, in_addr_t gateway);
int32_t do_ifc_add_route(const char *ifname,
const char *dst,
uint32_t prefixLength,
const char *gateway);
int32_t do_ifc_remove_route(const char *ifname,
const char *dst,
uint32_t prefixLength,
const char *gateway);
int32_t do_ifc_remove_host_routes(const char *ifname);
int32_t do_ifc_remove_default_route(const char *ifname);
int32_t do_dhcp_stop(const char *ifname);
int32_t do_dhcp_do_request(const char *ifname,
char *ipaddr,
char *gateway,
uint32_t *prefixLength,
char *dns1,
char *dns2,
char *server,
uint32_t *lease,
char* vendorinfo);
static int32_t SdkVersion();
};
// Defines a function type with the right arguments and return type.
#define DEFINE_DLFUNC(name, ret, args...) typedef ret (*FUNC##name)(args);
// Set up a dlsymed function ready to use.
#define USE_DLFUNC(name) \
FUNC##name name = (FUNC##name) dlsym(GetSharedLibrary(), #name); \
if (!name) { \
MOZ_CRASH("Symbol not found in shared library : " #name); \
}
#endif // NetUtils_h