summary refs log tree commit diff
path: root/src/tool/tool.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2007-11-23 16:26:03 +0000
committerFlorian Westphal <fw@strlen.de>2007-11-23 16:26:03 +0000
commit82d32ffb28262b302fb435739e4c81bd3c1a1b85 (patch)
tree2949b21f9691c7f3bd5718a5dd20341a83a555ce /src/tool/tool.c
parent024588dbe72e25b49439602670be7d8164183a74 (diff)
downloadngircd-82d32ffb28262b302fb435739e4c81bd3c1a1b85.tar.gz
ngircd-82d32ffb28262b302fb435739e4c81bd3c1a1b85.zip
bind ListenAddress for outgoing connections
ngircd would always use INADDR_ANY for outgoing connections;
which might not be desirable. Added new [Server] option
"Bind" to set source ip.
Diffstat (limited to 'src/tool/tool.c')
-rw-r--r--src/tool/tool.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/tool/tool.c b/src/tool/tool.c
index 01d892fd..dc238451 100644
--- a/src/tool/tool.c
+++ b/src/tool/tool.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: tool.c,v 1.6 2006/04/09 12:53:07 alex Exp $";
+static char UNUSED id[] = "$Id: tool.c,v 1.7 2007/11/23 16:26:05 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -22,6 +22,11 @@ static char UNUSED id[] = "$Id: tool.c,v 1.6 2006/04/09 12:53:07 alex Exp $";
 #include <stdio.h>
 #include <string.h>
 
+#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
 #include "exp.h"
 #include "tool.h"
 
@@ -105,4 +110,22 @@ ngt_TrimLastChr( char *String, const char Chr)
 } /* ngt_TrimLastChr */
 
 
+GLOBAL bool
+ngt_IPStrToBin(const char *ip_str, struct in_addr *inaddr)
+{
+	/* AF is always AF_INET for now */
+#ifdef HAVE_INET_ATON
+	if (inet_aton(ip_str, inaddr) == 0)
+		return false;
+#else
+	inaddr->s_addr = inet_addr(ip_str);
+	if (inaddr->s_addr == (unsigned)-1)
+		return false;
+#endif
+	return true;
+}
+
+
+
+
 /* -eof- */