From 264274bbfe36cc723813bea96e45fc438229f6ab Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 11 Sep 1997 19:40:09 +0000 Subject: Supply inet_aton if needed. svn path=/trunk/; revision=1331 --- interface.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'interface.c') diff --git a/interface.c b/interface.c index 58f6e0a4..3e20f7af 100644 --- a/interface.c +++ b/interface.c @@ -110,6 +110,34 @@ static int get_ifinfo(const char *ifname, ifinfo_t *ifinfo) return(result); } +#ifndef HAVE_INET_ATON +/* + * Note: This is not a true replacement for inet_aton(), as it won't + * do the right thing on "255.255.255.255" (which translates to -1 on + * most machines). Fortunately this code will be used only if you're + * on an older Linux that lacks a real implementation. + */ +#ifdef HAVE_NETINET_IN_SYSTM_H +# include +# include +#endif + +#include +#include +#include +#include + +static int inet_aton(const char *cp, struct in_addr *inp) { + long addr; + + addr = inet_addr(cp); + if (addr == ((long) -1)) return 0; + + memcpy(inp, &addr, sizeof(addr)); + return 1; +} +#endif HAVE_INET_ATON + void interface_parse(char *buf, struct hostdata *hp) /* parse 'interface' specification */ { -- cgit v1.2.3