From 82d32ffb28262b302fb435739e4c81bd3c1a1b85 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 23 Nov 2007 16:26:03 +0000 Subject: 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. --- src/tool/tool.c | 25 ++++++++++++++++++++++++- src/tool/tool.h | 6 +++--- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src/tool') 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 @@ -22,6 +22,11 @@ static char UNUSED id[] = "$Id: tool.c,v 1.6 2006/04/09 12:53:07 alex Exp $"; #include #include +#include +#ifdef HAVE_ARPA_INET_H +# include +#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- */ diff --git a/src/tool/tool.h b/src/tool/tool.h index 5b386e59..bdd846f7 100644 --- a/src/tool/tool.h +++ b/src/tool/tool.h @@ -8,7 +8,7 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: tool.h,v 1.3 2005/03/19 18:43:53 fw Exp $ + * $Id: tool.h,v 1.4 2007/11/23 16:26:05 fw Exp $ * * Tool functions (Header) */ @@ -16,7 +16,7 @@ #ifndef __tool_h__ #define __tool_h__ - +#include "portab.h" GLOBAL void ngt_TrimLastChr PARAMS((char *String, const char Chr )); @@ -24,7 +24,7 @@ GLOBAL void ngt_TrimStr PARAMS((char *String )); GLOBAL char *ngt_LowerStr PARAMS((char *String )); - +GLOBAL bool ngt_IPStrToBin PARAMS((const char *ip_str, struct in_addr *inaddr)); #endif -- cgit 1.4.1