summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/socket.h2
-rw-r--r--src/dns.cpp26
-rw-r--r--src/inspsocket.cpp6
-rw-r--r--src/modules/extra/m_mysql.cpp4
-rw-r--r--src/socket.cpp4
5 files changed, 22 insertions, 20 deletions
diff --git a/include/socket.h b/include/socket.h
index 4387797df..01005305b 100644
--- a/include/socket.h
+++ b/include/socket.h
@@ -37,11 +37,13 @@
typedef struct sockaddr_in6 insp_sockaddr;
typedef struct in6_addr insp_inaddr;
+#define AF_FAMILY AF_INET6
#else
typedef struct sockaddr_in insp_sockaddr;
typedef struct in_addr insp_inaddr;
+#define AF_FAMILY AF_INET
#endif
diff --git a/src/dns.cpp b/src/dns.cpp
index d65ec8c88..59aadd23f 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -183,7 +183,7 @@ void DNS::dns_init()
{
FILE *f;
int i;
- insp_inaddr addr4;
+ insp_inaddr addr;
char buf[1024];
if (initdone == 1)
return;
@@ -203,8 +203,8 @@ void DNS::dns_init()
i++;
if (i4 < 8)
{
- if (dns_aton4_s(&buf[i],&addr4) != NULL)
- memcpy(&servers4[i4++],&addr4,sizeof(insp_inaddr));
+ if (dns_aton4_s(&buf[i],&addr) != NULL)
+ memcpy(&servers4[i4++],&addr,sizeof(insp_inaddr));
}
}
}
@@ -213,19 +213,19 @@ void DNS::dns_init()
void DNS::dns_init_2(const char* dnsserver)
{
- insp_inaddr addr4;
+ insp_inaddr addr;
i4 = 0;
srand((unsigned int) TIME);
memset(servers4,'\0',sizeof(insp_inaddr) * 8);
- if (dns_aton4_s(dnsserver,&addr4) != NULL)
- memcpy(&servers4[i4++],&addr4,sizeof(insp_inaddr));
+ if (dns_aton4_s(dnsserver,&addr) != NULL)
+ memcpy(&servers4[i4++],&addr,sizeof(insp_inaddr));
}
int dns_send_requests(const s_header *h, const s_connection *s, const int l)
{
int i;
- insp_sockaddr addr4;
+ insp_sockaddr addr;
unsigned char payload[sizeof(s_header)];
dns_empty_header(payload,h,l);
@@ -234,11 +234,11 @@ int dns_send_requests(const s_header *h, const s_connection *s, const int l)
i = 0;
/* otherwise send via standard ipv4 boringness */
- memset(&addr4,0,sizeof(addr4));
- memcpy(&addr4.sin_addr,&servers4[i],sizeof(addr4.sin_addr));
- addr4.sin_family = AF_INET;
- addr4.sin_port = htons(53);
- if (sendto(s->fd, payload, l + 12, 0, (sockaddr *) &addr4, sizeof(addr4)) == -1)
+ memset(&addr,0,sizeof(addr));
+ memcpy(&addr.sin_addr,&servers4[i],sizeof(addr.sin_addr));
+ addr.sin_family = AF_FAMILY;
+ addr.sin_port = htons(53);
+ if (sendto(s->fd, payload, l + 12, 0, (sockaddr *) &addr, sizeof(addr)) == -1)
{
return -1;
}
@@ -276,7 +276,7 @@ s_connection *dns_add_query(s_header *h)
{
insp_sockaddr addr;
memset(&addr,0,sizeof(addr));
- addr.sin_family = AF_INET;
+ addr.sin_family = AF_FAMILY;
addr.sin_port = 0;
addr.sin_addr.s_addr = INADDR_ANY;
if (bind(s->fd,(sockaddr *)&addr,sizeof(addr)) != 0)
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 2d49c19db..66ba5c58e 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -215,7 +215,7 @@ bool InspSocket::BindAddr()
{
log(DEBUG,"Found an IP to bind to: %s",IP.c_str());
s.sin_addr = n;
- s.sin_family = AF_INET;
+ s.sin_family = AF_FAMILY;
if (bind(this->fd,(struct sockaddr*)&s,sizeof(s)) < 0)
{
log(DEBUG,"Cant bind()");
@@ -241,7 +241,7 @@ bool InspSocket::BindAddr()
bool InspSocket::DoConnect()
{
log(DEBUG,"In DoConnect()");
- if ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ if ((this->fd = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1)
{
log(DEBUG,"Cant socket()");
this->state = I_ERROR;
@@ -255,7 +255,7 @@ bool InspSocket::DoConnect()
log(DEBUG,"Part 2 DoConnect() %s",this->IP);
inet_aton(this->IP,&addy);
- addr.sin_family = AF_INET;
+ addr.sin_family = AF_FAMILY;
addr.sin_addr = addy;
addr.sin_port = htons(this->port);
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 82348d40d..e3639436b 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -832,7 +832,7 @@ void* DispatcherThread(void* arg)
/* Connect back to the Notifier */
- if ((QueueFD = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ if ((QueueFD = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1)
{
/* crap, we're out of sockets... */
log(DEBUG,"QueueFD cant be created");
@@ -844,7 +844,7 @@ void* DispatcherThread(void* arg)
insp_sockaddr addr;
insp_inaddr ia;
inet_aton("127.0.0.1", &ia);
- addr.sin_family = AF_INET;
+ addr.sin_family = AF_FAMILY;
addr.sin_addr = ia;
addr.sin_port = htons(MessagePipe->GetPort());
diff --git a/src/socket.cpp b/src/socket.cpp
index 56358c503..22069b87d 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -60,7 +60,7 @@ bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port
return false;
}
}
- server.sin_family = AF_INET;
+ server.sin_family = AF_FAMILY;
if (!resolved)
{
if (!*addr)
@@ -101,7 +101,7 @@ int OpenTCPSocket()
int on = 1;
struct linger linger = { 0 };
- if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+ if ((sockfd = socket (AF_FAMILY, SOCK_STREAM, 0)) < 0)
{
log(DEFAULT,"Error creating TCP socket: %s",strerror(errno));
return (ERROR);