* Bjorn Wesen, Axis Communications AB
*
*
- * Authors of the original ifconfig was:
+ * Authors of the original ifconfig was:
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
*
* This program is free software; you can redistribute it
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
- * $Id: ifconfig.c,v 1.26 2003/06/21 09:05:49 andersen Exp $
+ * $Id: ifconfig.c,v 1.30 2004/03/31 11:30:08 andersen Exp $
*
*/
#include <string.h> /* strcmp and friends */
#include <ctype.h> /* isdigit and friends */
#include <stddef.h> /* offsetof */
+#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>
#define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK)
#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST)
#define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER)
-#define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
+#define ARG_POINTOPOINT (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR)
#define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR)
#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME)
safe_strncpy(host, *argv, (sizeof host));
#ifdef CONFIG_FEATURE_IPV6
if ((prefix = strchr(host, '/'))) {
- prefix_len = atol(prefix + 1);
- if ((prefix_len < 0) || (prefix_len > 128)) {
+ if (safe_strtoi(prefix + 1, &prefix_len) ||
+ (prefix_len < 0) || (prefix_len > 128))
+ {
++goterr;
goto LOOP;
}
#endif
} else if (inet_aton(host, &sai.sin_addr) == 0) {
/* It's not a dotted quad. */
- ++goterr;
- continue;
+ struct hostent *hp;
+ if ((hp = gethostbyname(host)) == (struct hostent *)NULL) {
+ ++goterr;
+ continue;
+ }
+ memcpy((char *) &sai.sin_addr, (char *) hp->h_addr_list[0],
+ sizeof(struct in_addr));
}
#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS
if (mask & A_HOSTNAME) {
* a - at the end, since it's deleted already! - Roman
*
* Should really use regex.h here, not sure though how well
- * it'll go with the cross-platform support etc.
+ * it'll go with the cross-platform support etc.
*/
char *ptr;
short int found_colon = 0;