strcpy(host, *args++);
host[(sizeof host)-1] = 0; strncpy(host, *args++, (sizeof host)-1);
arp_set(char **args){  char host[128];  struct arpreq req;#if HAVE_NEW_SIOCSARP  struct arpreq_old old_req;#endif  struct sockaddr sa;  int flags;  memset((char *) &req, 0, sizeof(req));  /* Resolve the host name. */  if (*args == NULL) {	fprintf(stderr, NLS_CATGETS(catfd, arpSet, arp_hostname, "arp: need host name\n"));	return(-1);  }  strcpy(host, *args++);  if (ap->input(0, host, &sa) < 0) {	ap->herror(host);	return(-1);  }  /* If a host has more than one address, use the correct one! */  memcpy((char *) &req.arp_pa, (char *) &sa, sizeof(struct sockaddr));  /* Fetch the hardware address. */  if (*args == NULL) {	fprintf(stderr, NLS_CATGETS(catfd, arpSet, arp_need_hw, "arp: need hardware address\n"));	return(-1);  }  if (opt_D) {    if (arp_getdevhw(*args++, &req.arp_ha, hw_set?hw:NULL) < 0)      return(-1);  } else {    if (hw->input(*args++, &req.arp_ha) < 0) {	fprintf(stderr, NLS_CATGETS(catfd, arpSet, arp_invalidhw, "arp: invalid hardware address\n"));	return(-1);    }  }    /* Check out any modifiers. */  flags = ATF_PERM | ATF_COM;  while (*args != NULL) {	if (! strcmp(*args, "temp")) {		flags &= ~ATF_PERM;		args++;		continue;	}	if (! strcmp(*args, "pub")) {		flags |= ATF_PUBL;		args++;		continue;	}	if (! strcmp(*args, "priv")) {		flags &= ~ATF_PUBL;		args++;		continue;	}	if (! strcmp(*args, "trail")) {		flags |= ATF_USETRAILERS;		args++;		continue;	}	if (! strcmp(*args, "dontpub")) { #ifdef HAVE_ATF_DONTPUB		flags |= ATF_DONTPUB;#else		ENOSUPP("arp", "ATF_DONTPUB");#endif		args++;		continue;	}			if (! strcmp(*args, "auto")) {#ifdef HAVE_ATF_MAGIC		flags |= ATF_MAGIC;#else		ENOSUPP("arp", "ATF_MAGIC");#endif		args++;		continue;	}	if (! strcmp(*args, "dev")) {		if (*++args == NULL) usage();		strncpy(device,*args,sizeof(device)-1);		device[sizeof(device)-1]='\0';		args++;		continue;	}	if (! strcmp(*args, "netmask")) {		if (*++args == NULL) usage();		if (strcmp(*args,"255.255.255.255") != 0) {			strcpy(host, *args);			if (ap->input(0, host, &sa) < 0) {				ap->herror(host);				return(-1);			}			memcpy((char *) &req.arp_netmask, (char *) &sa,				sizeof(struct sockaddr));			flags |= ATF_NETMASK;	      	}	      	args++;	      	continue;	}	usage();  }  /* Fill in the remainder of the request. */  req.arp_flags = flags;#if HAVE_NEW_SIOCSARP  strcpy(req.arp_dev,device);  memcpy((char *)&old_req,(char *)&req,sizeof(old_req));  /* Call the kernel. */  if (opt_v)  fprintf(stderr,"arp: SIOCSARP()\n");  if (ioctl(sockfd, SIOCSARP, &req) < 0) {	if (errno != EINVAL) {		perror("SIOCSARP");		return(-1);	}	if (opt_v)  fprintf(stderr,"arp: OLD_SIOCSARP()\n");	if (ioctl(sockfd, OLD_SIOCSARP, &old_req) < 0) {		if (errno != EINVAL) {			perror("OLD_SIOCSARP");			return(-1);		}		perror("SIOCSARP and OLD_SIOCSARP");		if (flags & ATF_PUBL)			fprintf(stderr, NLS_CATGETS(catfd, arpSet, arp_einv_pub, 					"Probably route to destination points to interface. See arp(8)\n"));		else			fprintf(stderr, NLS_CATGETS(catfd, arpSet, arp_einv_nopub, 					"No ARP Support or route to destination points to other interface. See arp(8)\n"));		return(-1);	}  }#else  /* Call the kernel. */  if (opt_v)  fprintf(stderr,"arp: old_SIOCSARP()\n");  if (ioctl(sockfd, SIOCSARP, &req) < 0) {	perror("SIOCSARP");	return(-1);  }#endif  return(0);}