if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr,
sizeof (ea->arp_sha))) {
log(LOG_ERR,
- "arp: ether address is broadcast for IP address %x!\n",
- ntohl(isaddr.s_addr));
+ "arp: ether address is broadcast for IP address %s!\n",
+ inet_ntoa(isaddr));
goto out;
}
if (isaddr.s_addr == myaddr.s_addr) {
log(LOG_ERR,
- "duplicate IP address %08x sent from ethernet address %s\n",
- ntohl(isaddr.s_addr), ether_sprintf(ea->arp_sha));
+ "duplicate IP address %s sent from ethernet address %s\n",
+ inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
itaddr = myaddr;
goto reply;
}
if ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 ||
rt->rt_gateway->sa_family != AF_LINK) {
if (create)
- log(LOG_DEBUG, "arplookup: unable to enter address for %x\n", ntohl(addr));
+ log(LOG_DEBUG,
+ "arplookup: unable to enter address for %s\n",
+ inet_ntoa(sin.sin_addr));
return (0);
}
return ((struct llinfo_arp *)rt->rt_llinfo);
int in_cksum __P((struct mbuf *, int));
int in_localaddr __P((struct in_addr));
void in_socktrim __P((struct sockaddr_in *));
+char *inet_ntoa __P((struct in_addr));
#define satosin(sa) ((struct sockaddr_in *)(sa))
#define sintosa(sin) ((struct sockaddr *)(sin))
* that not corrupted and of at least minimum length.
*/
#ifdef ICMPPRINTFS
- if (icmpprintfs)
- printf("icmp_input from %x to %x, len %d\n",
- ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr),
- icmplen);
+ if (icmpprintfs) {
+ char buf[4*sizeof "123"];
+
+ strcpy(buf, inet_ntoa(ip->ip_dst));
+ printf("icmp_input from %s to %s, len %d\n",
+ inet_ntoa(ip->ip_src), buf, icmplen);
+ }
#endif
if (icmplen < ICMP_MINLEN) {
icmpstat.icps_tooshort++;
icmpgw.sin_addr = ip->ip_src;
icmpdst.sin_addr = icp->icmp_gwaddr;
#ifdef ICMPPRINTFS
- if (icmpprintfs)
- printf("redirect dst %x to %x\n", icp->icmp_ip.ip_dst,
- icp->icmp_gwaddr);
+ if (icmpprintfs) {
+ char buf[4 * sizeof "123"];
+ strcpy(buf, inet_ntoa(icp->icmp_ip.ip_dst));
+
+ printf("redirect dst %s to %s\n",
+ buf, inet_ntoa(icp->icmp_gwaddr));
+ }
#endif
icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
rtredirect(sintosa(&icmpsrc), sintosa(&icmpdst),
m->m_data -= hlen;
m->m_len += hlen;
#ifdef ICMPPRINTFS
- if (icmpprintfs)
- printf("icmp_send dst %x src %x\n", ip->ip_dst, ip->ip_src);
+ if (icmpprintfs) {
+ char buf[4 * sizeof "123"];
+
+ strcpy(buf, inet_ntoa(ip->ip_dst));
+ printf("icmp_send dst %s src %s\n",
+ buf, inet_ntoa(ip->ip_src));
+ }
#endif
(void) ip_output(m, opts, NULL, 0, NULL);
}
struct in_ifaddrhead in_ifaddr;
struct ifqueue ipintrq;
+char *
+inet_ntoa(ina)
+ struct in_addr ina;
+{
+ static char buf[4*sizeof "123"];
+ unsigned char *ucp = (unsigned char *)&ina;
+
+ sprintf(buf, "%d.%d.%d.%d", ucp[0] & 0xff, ucp[1] & 0xff,
+ ucp[2] & 0xff, ucp[3] & 0xff);
+ return (buf);
+}
+
/*
* We need to save the IP options in case a protocol wants to respond
* to an incoming packet over the same route if the packet got here
ip->ip_len -= hlen;
((struct ipasfrag *)ip)->ipf_mff &= ~1;
if (ip->ip_off & IP_MF) {
- /*
- * Make sure that fragments have a data length
+ /*
+ * Make sure that fragments have a data length
* that's a non-zero multiple of 8 bytes.
- */
+ */
if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) {
ipstat.ips_badfrags++;
goto bad;
}
if (!ip_dosourceroute) {
+ char buf[4*sizeof "123"];
+
+ strcpy(buf, inet_ntoa(ip->ip_dst));
log(LOG_WARNING,
- "attempted source route from %x to %x\n",
- ntohl(ip->ip_src.s_addr),
- ntohl(ip->ip_dst.s_addr));
+ "attempted source route from %s to %s\n",
+ inet_ntoa(ip->ip_src), buf);
type = ICMP_UNREACH;
code = ICMP_UNREACH_SRCFAIL;
goto bad;
dest = 0;
#ifdef DIAGNOSTIC
if (ipprintfs)
- printf("forward: src %x dst %x ttl %x\n", ip->ip_src,
- ip->ip_dst, ip->ip_ttl);
+ printf("forward: src %lx dst %x ttl %x\n", ip->ip_src.s_addr,
+ ip->ip_dst.s_addr, ip->ip_ttl);
#endif
if (m->m_flags & M_BCAST || in_canforward(ip->ip_dst) == 0) {
ipstat.ips_cantforward++;