Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.19 retrieving revision 1.23 diff -u -p -r1.19 -r1.23 --- src/sys/netinet/ip_input.c 1995/06/04 05:07:03 1.19 +++ src/sys/netinet/ip_input.c 1995/06/12 06:46:36 1.23 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.19 1995/06/04 05:07:03 mycroft Exp $ */ +/* $NetBSD: ip_input.c,v 1.23 1995/06/12 06:46:36 mycroft Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1993 @@ -78,7 +78,7 @@ extern struct domain inetdomain; extern struct protosw inetsw[]; u_char ip_protox[IPPROTO_MAX]; int ipqmaxlen = IFQ_MAXLEN; -struct in_ifaddr *in_ifaddr; /* first inet address */ +struct in_ifaddrhead in_ifaddr; struct ifqueue ipintrq; /* @@ -96,11 +96,6 @@ static struct ip_srcrt { struct in_addr route[MAX_IPOPTLEN/sizeof(struct in_addr)]; } ip_srcrt; -#ifdef GATEWAY -extern int if_index; -u_int32_t *ip_ifmatrix; -#endif - static void save_rte __P((u_char *, struct in_addr)); /* * IP initialization: fill in IP protocol switch table. @@ -125,11 +120,7 @@ ip_init() ipq.next = ipq.prev = &ipq; ip_id = time.tv_sec & 0xffff; ipintrq.ifq_maxlen = ipqmaxlen; -#ifdef GATEWAY - i = (if_index + 1) * (if_index + 1) * sizeof (u_int32_t); - ip_ifmatrix = (u_int32_t *) malloc(i, M_RTABLE, M_WAITOK); - bzero((char *)ip_ifmatrix, i); -#endif + TAILQ_INIT(&in_ifaddr); } struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; @@ -166,7 +157,7 @@ next: * If no IP addresses have been set yet but the interfaces * are receiving, can't do anything with incoming packets yet. */ - if (in_ifaddr == NULL) + if (in_ifaddr.tqh_first == 0) goto bad; ipstat.ips_total++; if (m->m_len < sizeof (struct ip) && @@ -238,24 +229,21 @@ next: /* * Check our list of addresses, to see if the packet is for us. */ - for (ia = in_ifaddr; ia; ia = ia->ia_next) { - if (IA_SIN(ia)->sin_addr.s_addr == ip->ip_dst.s_addr) + for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { + if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr) goto ours; if ( #ifdef DIRECTED_BROADCAST ia->ia_ifp == m->m_pkthdr.rcvif && #endif (ia->ia_ifp->if_flags & IFF_BROADCAST)) { - if (ip->ip_dst.s_addr == - satosin(&ia->ia_broadaddr)->sin_addr.s_addr) - goto ours; - if (ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr) - goto ours; - /* - * Look for all-0's host part (old broadcast addr), - * either for subnet or net. - */ - if (ip->ip_dst.s_addr == ia->ia_subnet || + if (ip->ip_dst.s_addr == ia->ia_broadaddr.sin_addr.s_addr || + ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr || + /* + * Look for all-0's host part (old broadcast addr), + * either for subnet or net. + */ + ip->ip_dst.s_addr == ia->ia_subnet || ip->ip_dst.s_addr == ia->ia_net) goto ours; } @@ -732,7 +720,7 @@ ip_dooptions(m) goto bad; } ip->ip_dst = ipaddr.sin_addr; - bcopy((caddr_t)&(IA_SIN(ia)->sin_addr), + bcopy((caddr_t)&ia->ia_addr.sin_addr, (caddr_t)(cp + off), sizeof(struct in_addr)); cp[IPOPT_OFFSET] += sizeof(struct in_addr); /* @@ -764,7 +752,7 @@ ip_dooptions(m) code = ICMP_UNREACH_HOST; goto bad; } - bcopy((caddr_t)&(IA_SIN(ia)->sin_addr), + bcopy((caddr_t)&ia->ia_addr.sin_addr, (caddr_t)(cp + off), sizeof(struct in_addr)); cp[IPOPT_OFFSET] += sizeof(struct in_addr); break; @@ -794,7 +782,7 @@ ip_dooptions(m) m->m_pkthdr.rcvif); if (ia == 0) continue; - bcopy((caddr_t)&IA_SIN(ia)->sin_addr, + bcopy((caddr_t)&ia->ia_addr.sin_addr, (caddr_t)sin, sizeof(struct in_addr)); ipt->ipt_ptr += sizeof(struct in_addr); break; @@ -978,7 +966,7 @@ ip_stripoptions(m, mopt) ip->ip_hl = sizeof(struct ip) >> 2; } -u_char inetctlerrmap[PRC_NCMDS] = { +int inetctlerrmap[PRC_NCMDS] = { 0, 0, 0, 0, 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED, @@ -1057,10 +1045,6 @@ ip_forward(m, srcrt) */ mcopy = m_copy(m, 0, imin((int)ip->ip_len, 64)); -#ifdef GATEWAY - ip_ifmatrix[rt->rt_ifp->if_index + - if_index * m->m_pkthdr.rcvif->if_index]++; -#endif /* * If forwarding packet using same interface that it came in on, * perhaps should send a redirect to sender to shortcut a hop.