summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-10 00:36:07 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-10 00:36:07 +0000
commitd7336f351d9740fc4bfc1289c2b090a0f272d201 (patch)
tree6146e8b695945f64503050968c3d83c3aa34cfd6 /include
parentad3c37e38c6c170c1f7cc3232db748ebdc62aa94 (diff)
Move the socket functions like insp_ntoa into their own namespace. They arent really sensible to put into a class, but namespacing them out discourages developers from directly using them without explicitly saing 'using irc::sockets::BindPorts' or whatever first. Some functions such as insp_ntoa are already 'exposed' by headers that use them so 'using irc::sockets::inet_ntoa' isnt required.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4828 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/dns.h6
-rw-r--r--include/hashcomp.h3
-rw-r--r--include/inspsocket.h5
-rw-r--r--include/socket.h37
4 files changed, 36 insertions, 15 deletions
diff --git a/include/dns.h b/include/dns.h
index ebe628bb9..c3b74fdca 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -40,6 +40,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "socket.h"
#include "base.h"
+using namespace std;
+using irc::sockets::insp_aton;
+using irc::sockets::insp_ntoa;
+using irc::sockets::insp_sockaddr;
+using irc::sockets::insp_inaddr;
+
class InspIRCd;
/**
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 714d3286f..6c90ee919 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -37,6 +37,9 @@
*******************************************************/
using namespace std;
+using irc::sockets::insp_aton;
+using irc::sockets::insp_ntoa;
+using irc::sockets::insp_inaddr;
namespace nspace
{
diff --git a/include/inspsocket.h b/include/inspsocket.h
index 42ce01a27..ddb0baedb 100644
--- a/include/inspsocket.h
+++ b/include/inspsocket.h
@@ -37,6 +37,11 @@ enum InspSocketError { I_ERR_TIMEOUT, I_ERR_SOCKET, I_ERR_CONNECT, I_ERR_BIND, I
class InspSocket;
class InspIRCd;
+using irc::sockets::insp_sockaddr;
+using irc::sockets::insp_inaddr;
+using irc::sockets::insp_ntoa;
+using irc::sockets::insp_aton;
+
/**
* InspSocket is an extendable socket class which modules
* can use for TCP socket support. It is fully integrated
diff --git a/include/socket.h b/include/socket.h
index ed6373ce8..8219ff5dd 100644
--- a/include/socket.h
+++ b/include/socket.h
@@ -32,35 +32,42 @@
#include "inspircd_config.h"
-/* macros to the relevant system address description structs */
+namespace irc
+{
+ namespace sockets
+ {
+
+ /* macros to the relevant system address description structs */
#ifdef IPV6
-typedef struct sockaddr_in6 insp_sockaddr;
-typedef struct in6_addr insp_inaddr;
+ typedef struct sockaddr_in6 insp_sockaddr;
+ typedef struct in6_addr insp_inaddr;
#define AF_FAMILY AF_INET6
#define PF_PROTOCOL PF_INET6
#else
-typedef struct sockaddr_in insp_sockaddr;
-typedef struct in_addr insp_inaddr;
+ typedef struct sockaddr_in insp_sockaddr;
+ typedef struct in_addr insp_inaddr;
#define AF_FAMILY AF_INET
#define PF_PROTOCOL PF_INET
#endif
-bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits);
-bool MatchCIDR(const char* address, const char* cidr_mask);
-bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username);
+ bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits);
+ bool MatchCIDR(const char* address, const char* cidr_mask);
+ bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username);
-const char* insp_ntoa(insp_inaddr n);
-int insp_aton(const char* a, insp_inaddr* n);
+ const char* insp_ntoa(insp_inaddr n);
+ int insp_aton(const char* a, insp_inaddr* n);
-void Blocking(int s);
-void NonBlocking(int s);
+ void Blocking(int s);
+ void NonBlocking(int s);
-int OpenTCPSocket();
-bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr);
-int BindPorts(bool bail);
+ int OpenTCPSocket();
+ bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr);
+ int BindPorts(bool bail);
+ };
+};
#endif