- if (hlen > sizeof (struct ip))
- ip_dooptions(ip, hlen);
- if (ip->ip_dst.s_addr != n_lhost.s_addr) {
- if (--ip->ip_ttl == 0) {
- icmp_error(ip, ICMP_TIMXCEED);
- return;
- }
- ip_output(dtom(ip));
- return;
+ if (hlen > sizeof (struct ip) && ip_dooptions(ip))
+ goto next;
+
+ /*
+ * Fast check on the first internet
+ * interface in the list.
+ */
+ if (ifinet) {
+ struct sockaddr_in *sin;
+
+ sin = (struct sockaddr_in *)&ifinet->if_addr;
+ if (sin->sin_addr.s_addr == ip->ip_dst.s_addr)
+ goto ours;
+ sin = (struct sockaddr_in *)&ifinet->if_broadaddr;
+ if ((ifinet->if_flags & IFF_BROADCAST) &&
+ sin->sin_addr.s_addr == ip->ip_dst.s_addr)
+ goto ours;
+ }
+/* BEGIN GROT */
+#include "nd.h"
+#if NND > 0
+ /*
+ * Diskless machines don't initially know
+ * their address, so take packets from them
+ * if we're acting as a network disk server.
+ */
+ if (ip->ip_dst.s_addr == INADDR_ANY &&
+ (in_netof(ip->ip_src) == INADDR_ANY &&
+ in_lnaof(ip->ip_src) != INADDR_ANY))
+ goto ours;
+#endif
+/* END GROT */
+ ipaddr.sin_addr = ip->ip_dst;
+ if (if_ifwithaddr((struct sockaddr *)&ipaddr) == 0) {
+ ip_forward(ip);
+ goto next;