summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-01 10:37:16 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-01 10:37:16 +0000
commitc80508b28be5947648f59710e6653f793a73bd76 (patch)
tree87c3c9509ba2ae20312604d13ee14abcbea8b948
parent15a3422e9ef297a6867d3c00b1d46079399739c7 (diff)
Move to entirely using insp_sockaddr and insp_inaddr for socket stuff, first step on the road to ipv6 support
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4609 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/dns.h18
-rw-r--r--include/hashcomp.h8
-rw-r--r--include/users.h4
-rw-r--r--src/dns.cpp36
-rw-r--r--src/hashcomp.cpp6
-rw-r--r--src/modules/extra/m_mysql.cpp6
-rw-r--r--src/modules/m_check.cpp2
-rw-r--r--src/modules/m_ident.cpp4
-rw-r--r--src/users.cpp2
9 files changed, 43 insertions, 43 deletions
diff --git a/include/dns.h b/include/dns.h
index ea02f03bb..9b477e98f 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
struct dns_ip4list
{
- in_addr ip;
+ insp_inaddr ip;
dns_ip4list *next;
};
@@ -51,24 +51,24 @@ enum ResolverError
class DNS : public Extensible
{
private:
- in_addr *binip;
+ insp_inaddr *binip;
char* result;
char localbuf[1024];
int t;
void dns_init();
int myfd;
void dns_init_2(const char* dnsserver);
- in_addr *dns_aton4(const char * const ipstring);
- char *dns_ntoa4(const in_addr * const ip);
+ insp_inaddr *dns_aton4(const char * const ipstring);
+ char *dns_ntoa4(const insp_inaddr * const ip);
int dns_getip4(const char * const name);
int dns_getip4list(const char * const name);
- int dns_getname4(const in_addr * const ip);
+ int dns_getname4(const insp_inaddr * const ip);
char *dns_getresult(const int fd);
- in_addr *dns_aton4_s(const char * const ipstring, in_addr * const ip);
- char *dns_ntoa4_s(const in_addr * const ip, char * const result);
+ insp_inaddr *dns_aton4_s(const char * const ipstring, insp_inaddr * const ip);
+ char *dns_ntoa4_s(const insp_inaddr * const ip, char * const result);
char *dns_getresult_s(const int fd, char * const result);
- in_addr *dns_aton4_r(const char * const ipstring);
- char *dns_ntoa4_r(const in_addr * const ip);
+ insp_inaddr *dns_aton4_r(const char * const ipstring);
+ char *dns_ntoa4_r(const insp_inaddr * const ip);
char *dns_getresult_r(const int fd);
public:
/** The default constructor uses dns addresses read from /etc/resolv.conf.
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 1d3a5d0b1..714d3286f 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -40,9 +40,9 @@ using namespace std;
namespace nspace
{
- template<> struct hash<in_addr>
+ template<> struct hash<insp_inaddr>
{
- size_t operator()(const struct in_addr &a) const;
+ size_t operator()(const insp_inaddr &a) const;
};
template<> struct hash<std::string>
@@ -68,7 +68,7 @@ namespace irc
};
- /** This class returns true if two in_addr structs match.
+ /** This class returns true if two insp_inaddr structs match.
* Checking is done by copying both into a size_t then doing a
* numeric comparison of the two.
*/
@@ -76,7 +76,7 @@ namespace irc
{
/** The operator () does the actual comparison in hash_map
*/
- bool operator()(const in_addr &s1, const in_addr &s2) const;
+ bool operator()(const insp_inaddr &s1, const insp_inaddr &s2) const;
};
/** irc::tokenstream reads a string formatted as per RFC1459 and RFC2812.
diff --git a/include/users.h b/include/users.h
index 52068bb24..c91b2635a 100644
--- a/include/users.h
+++ b/include/users.h
@@ -246,7 +246,7 @@ class userrec : public connection
/** IPV4 ip address
*/
- in_addr ip4;
+ insp_inaddr ip4;
/* Write error string
*/
@@ -429,7 +429,7 @@ void kill_link(userrec *user,const char* r);
void kill_link_silent(userrec *user,const char* r);
void AddWhoWas(userrec* u);
void MaintainWhoWas(time_t TIME);
-void AddClient(int socket, int port, bool iscached, in_addr ip4);
+void AddClient(int socket, int port, bool iscached, insp_inaddr ip4);
void FullConnectUser(userrec* user, CullList* Goners);
userrec* ReHashNick(const char* Old, const char* New);
void force_nickchange(userrec* user,const char* newnick);
diff --git a/src/dns.cpp b/src/dns.cpp
index 1ea9abd55..d65ec8c88 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -74,7 +74,7 @@ connlist connections;
Resolver* dns_classes[MAX_DESCRIPTORS];
-struct in_addr servers4[8];
+insp_inaddr servers4[8];
int i4;
int initdone = 0;
int lastcreate = -1;
@@ -183,7 +183,7 @@ void DNS::dns_init()
{
FILE *f;
int i;
- in_addr addr4;
+ insp_inaddr addr4;
char buf[1024];
if (initdone == 1)
return;
@@ -191,7 +191,7 @@ void DNS::dns_init()
initdone = 1;
srand((unsigned int) TIME);
- memset(servers4,'\0',sizeof(in_addr) * 8);
+ memset(servers4,'\0',sizeof(insp_inaddr) * 8);
f = fopen("/etc/resolv.conf","r");
if (f == NULL)
return;
@@ -204,7 +204,7 @@ void DNS::dns_init()
if (i4 < 8)
{
if (dns_aton4_s(&buf[i],&addr4) != NULL)
- memcpy(&servers4[i4++],&addr4,sizeof(in_addr));
+ memcpy(&servers4[i4++],&addr4,sizeof(insp_inaddr));
}
}
}
@@ -213,19 +213,19 @@ void DNS::dns_init()
void DNS::dns_init_2(const char* dnsserver)
{
- in_addr addr4;
+ insp_inaddr addr4;
i4 = 0;
srand((unsigned int) TIME);
- memset(servers4,'\0',sizeof(in_addr) * 8);
+ memset(servers4,'\0',sizeof(insp_inaddr) * 8);
if (dns_aton4_s(dnsserver,&addr4) != NULL)
- memcpy(&servers4[i4++],&addr4,sizeof(in_addr));
+ memcpy(&servers4[i4++],&addr4,sizeof(insp_inaddr));
}
int dns_send_requests(const s_header *h, const s_connection *s, const int l)
{
int i;
- sockaddr_in addr4;
+ insp_sockaddr addr4;
unsigned char payload[sizeof(s_header)];
dns_empty_header(payload,h,l);
@@ -274,7 +274,7 @@ s_connection *dns_add_query(s_header *h)
}
if (s->fd != -1)
{
- sockaddr_in addr;
+ insp_sockaddr addr;
memset(&addr,0,sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = 0;
@@ -343,15 +343,15 @@ int dns_build_query_payload(const char * const name, const unsigned short rr, co
return payloadpos + 4;
}
-in_addr* DNS::dns_aton4(const char * const ipstring)
+insp_inaddr* DNS::dns_aton4(const char * const ipstring)
{
- static in_addr ip;
+ static insp_inaddr ip;
return dns_aton4_s(ipstring,&ip);
}
-in_addr* DNS::dns_aton4_r(const char *ipstring) { /* ascii to numeric (reentrant): convert string to new 4part IP addr struct */
- in_addr* ip;
- ip = new in_addr;
+insp_inaddr* DNS::dns_aton4_r(const char *ipstring) { /* ascii to numeric (reentrant): convert string to new 4part IP addr struct */
+ insp_inaddr* ip;
+ ip = new insp_inaddr;
if(dns_aton4_s(ipstring,ip) == NULL)
{
DELETE(ip);
@@ -360,7 +360,7 @@ in_addr* DNS::dns_aton4_r(const char *ipstring) { /* ascii to numeric (reentrant
return ip;
}
-in_addr* DNS::dns_aton4_s(const char *ipstring, in_addr *ip) { /* ascii to numeric (buffered): convert string to given 4part IP addr struct */
+insp_inaddr* DNS::dns_aton4_s(const char *ipstring, insp_inaddr *ip) { /* ascii to numeric (buffered): convert string to given 4part IP addr struct */
inet_aton(ipstring,ip);
return ip;
}
@@ -409,7 +409,7 @@ int DNS::dns_getip4list(const char *name) { /* build, add and send A query; retr
return s->fd;
}
-int DNS::dns_getname4(const in_addr *ip) { /* build, add and send PTR query; retrieve result with dns_getresult() */
+int DNS::dns_getname4(const insp_inaddr *ip) { /* build, add and send PTR query; retrieve result with dns_getresult() */
char query[512];
s_header h;
s_connection * s;
@@ -434,12 +434,12 @@ int DNS::dns_getname4(const in_addr *ip) { /* build, add and send PTR query; ret
return s->fd;
}
-char* DNS::dns_ntoa4(const in_addr * const ip) { /* numeric to ascii: convert 4part IP addr struct to static string */
+char* DNS::dns_ntoa4(const insp_inaddr * const ip) { /* numeric to ascii: convert 4part IP addr struct to static string */
static char r[256];
return dns_ntoa4_s(ip,r);
}
-char* DNS::dns_ntoa4_s(const in_addr *ip, char *r) { /* numeric to ascii (buffered): convert 4part IP addr struct to given string */
+char* DNS::dns_ntoa4_s(const insp_inaddr *ip, char *r) { /* numeric to ascii (buffered): convert 4part IP addr struct to given string */
unsigned char *m;
m = (unsigned char *)&ip->s_addr;
sprintf(r,"%d.%d.%d.%d",m[0],m[1],m[2],m[3]);
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 34f53ea28..213d51ffb 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -52,14 +52,14 @@ extern const char lowermap[255];
* be considered the lowercase of {, } and |.
*
* This file also contains hashing methods for hashing
- * in_addr structs, we use this if we want to cache IP
+ * insp_inaddr structs, we use this if we want to cache IP
* addresses.
*
******************************************************/
using namespace std;
-size_t nspace::hash<in_addr>::operator()(const struct in_addr &a) const
+size_t nspace::hash<insp_inaddr>::operator()(const insp_inaddr &a) const
{
size_t q;
memcpy(&q,&a,sizeof(size_t));
@@ -85,7 +85,7 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2)
return (lowermap[*n1] == lowermap[*n2]);
}
-bool irc::InAddr_HashComp::operator()(const in_addr &s1, const in_addr &s2) const
+bool irc::InAddr_HashComp::operator()(const insp_inaddr &s1, const insp_inaddr &s2) const
{
return (s1.s_addr == s1.s_addr);
}
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 035d0b498..82348d40d 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -660,7 +660,7 @@ void* DispatcherThread(void* arg);
class Notifier : public InspSocket
{
- sockaddr_in sock_us;
+ insp_sockaddr sock_us;
socklen_t uslen;
Server* Srv;
@@ -841,8 +841,8 @@ void* DispatcherThread(void* arg)
log(DEBUG,"Initialize QueueFD to %d",QueueFD);
- sockaddr_in addr;
- in_addr ia;
+ insp_sockaddr addr;
+ insp_inaddr ia;
inet_aton("127.0.0.1", &ia);
addr.sin_family = AF_INET;
addr.sin_addr = ia;
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 4dd0f8a62..29aaaa6dc 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -158,7 +158,7 @@ class cmd_check : public command_t
else
{
/* /check on an IP address, or something that doesn't exist */
- struct sockaddr_in addr;
+ insp_sockaddr addr;
long x = 0;
if (inet_aton(parameters[0], &addr.sin_addr) == 0)
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 131c3b117..270457af7 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -33,8 +33,8 @@ class RFC1413 : public InspSocket
{
protected:
Server* Srv; // Server* class used for core communications
- sockaddr_in sock_us; // our port number
- sockaddr_in sock_them; // their port number
+ insp_sockaddr sock_us; // our port number
+ insp_sockaddr sock_them; // their port number
socklen_t uslen; // length of our port number
socklen_t themlen; // length of their port number
char ident_request[128]; // buffer used to make up the request string
diff --git a/src/users.cpp b/src/users.cpp
index cd613fb05..f52f05b10 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -702,7 +702,7 @@ void MaintainWhoWas(time_t TIME)
}
/* add a client connection to the sockets list */
-void AddClient(int socket, int port, bool iscached, in_addr ip4)
+void AddClient(int socket, int port, bool iscached, insp_inaddr ip4)
{
std::string tempnick = ConvToStr(socket) + "-unknown";
user_hash::iterator iter = clientlist.find(tempnick);