summaryrefslogtreecommitdiffstats
path: root/sys/netinet/libalias
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-11-12 00:46:28 +0000
committerattilio <attilio@FreeBSD.org>2009-11-12 00:46:28 +0000
commit01da2349df43dda915c9e7cdd794dff6385b3751 (patch)
tree8fdf5036cd6332512462850f03f188312a671b2b /sys/netinet/libalias
parent5d65dda8ecee783683c731c300a3e781aaa929d2 (diff)
downloadFreeBSD-src-01da2349df43dda915c9e7cdd794dff6385b3751.zip
FreeBSD-src-01da2349df43dda915c9e7cdd794dff6385b3751.tar.gz
Move inet_aton() (specular to inet_ntoa(), already present in libkern)
into libkern in order to made it usable by other modules than alias_proxy. Obtained from: Sandvine Incorporated Sponsored by: Sandvine Incorporated MFC: 1 week
Diffstat (limited to 'sys/netinet/libalias')
-rw-r--r--sys/netinet/libalias/alias_proxy.c104
1 files changed, 0 insertions, 104 deletions
diff --git a/sys/netinet/libalias/alias_proxy.c b/sys/netinet/libalias/alias_proxy.c
index 4e11d4d..d5b1b81 100644
--- a/sys/netinet/libalias/alias_proxy.c
+++ b/sys/netinet/libalias/alias_proxy.c
@@ -137,9 +137,6 @@ struct proxy_entry {
destination of a proxied IP packet
*/
-#ifdef _KERNEL /* XXX: can it be moved to libkern? */
-static int inet_aton(const char *cp, struct in_addr *addr);
-#endif
static int IpMask(int, struct in_addr *);
static int IpAddr(char *, struct in_addr *);
static int IpPort(char *, int, int *);
@@ -149,107 +146,6 @@ static int RuleNumberDelete(struct libalias *la, int);
static void ProxyEncodeTcpStream(struct alias_link *, struct ip *, int);
static void ProxyEncodeIpHeader(struct ip *, int);
-#ifdef _KERNEL
-static int
-inet_aton(cp, addr)
- const char *cp;
- struct in_addr *addr;
-{
- u_long parts[4];
- in_addr_t val;
- const char *c;
- char *endptr;
- int gotend, n;
-
- c = (const char *)cp;
- n = 0;
- /*
- * Run through the string, grabbing numbers until
- * the end of the string, or some error
- */
- gotend = 0;
- while (!gotend) {
- unsigned long l;
-
- l = strtoul(c, &endptr, 0);
-
- if (l == ULONG_MAX || (l == 0 && endptr == c))
- return (0);
-
- val = (in_addr_t)l;
- /*
- * If the whole string is invalid, endptr will equal
- * c.. this way we can make sure someone hasn't
- * gone '.12' or something which would get past
- * the next check.
- */
- if (endptr == c)
- return (0);
- parts[n] = val;
- c = endptr;
-
- /* Check the next character past the previous number's end */
- switch (*c) {
- case '.' :
- /* Make sure we only do 3 dots .. */
- if (n == 3) /* Whoops. Quit. */
- return (0);
- n++;
- c++;
- break;
-
- case '\0':
- gotend = 1;
- break;
-
- default:
- if (isspace((unsigned char)*c)) {
- gotend = 1;
- break;
- } else
- return (0); /* Invalid character, so fail */
- }
-
- }
-
- /*
- * Concoct the address according to
- * the number of parts specified.
- */
-
- switch (n) {
- case 0: /* a -- 32 bits */
- /*
- * Nothing is necessary here. Overflow checking was
- * already done in strtoul().
- */
- break;
- case 1: /* a.b -- 8.24 bits */
- if (val > 0xffffff || parts[0] > 0xff)
- return (0);
- val |= parts[0] << 24;
- break;
-
- case 2: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff)
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 3: /* a.b.c.d -- 8.8.8.8 bits */
- if (val > 0xff || parts[0] > 0xff || parts[1] > 0xff ||
- parts[2] > 0xff)
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- }
-
- if (addr != NULL)
- addr->s_addr = htonl(val);
- return (1);
-}
-#endif
-
static int
IpMask(int nbits, struct in_addr *mask)
{
OpenPOWER on IntegriCloud