mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-28 08:02:54 +00:00
Remove the explicit definition of inet_aton() as it was introduced as a
general function in r199208. Reported by: np Sponsored by: Sandvine Incorporated MFC: 1 week
This commit is contained in:
parent
823e5e0ebf
commit
718cdf7f80
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199223
@ -112,109 +112,6 @@ struct krping_cb_list krping_cbs;
|
||||
#define RPING_BUFSIZE 128*1024
|
||||
#define RPING_SQ_DEPTH 32
|
||||
|
||||
|
||||
/* lifted from netinet/libalias/alias_proxy.c */
|
||||
static int inet_aton(const char *cp, struct in_addr *addr);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static void krping_wait(struct krping_cb *cb, int state)
|
||||
{
|
||||
int rc;
|
||||
|
Loading…
Reference in New Issue
Block a user