rem: if (hlen > sizeof(struct ip)) {
add: if (hlen > (int) sizeof(struct ip)) {
context: static int ipv4_output(struct mbuf *m0, struct mbuf *opt, struct route *ro,                int flags, void *optp){	struct mbuf *m = m0;	struct ip *ip = mtod(m, struct ip*), *mhip;	struct route iproute; /* temporary route we may need */	struct sockaddr_in *dst; /* destination address */	struct in_ifaddr *ia;	int error = 0, hlen = sizeof(struct ip);	struct ifnet *ifp = NULL;	int len, off;	/* handle options... */	if (opt) {		m = ip_insertoptions(m, opt, &len);		hlen = len;	}	ip = mtod(m, struct ip*);		if ((flags & (IP_FORWARDING | IP_RAWOUTPUT)) == 0) {		ip->ip_v = IPVERSION;		ip->ip_off &= IP_DF;		ip->ip_id = htons(ip_id++);		ip->ip_hl = hlen >> 2;		ipstat.ips_localout++;	} else		hlen = ip->ip_hl << 2;			/* route the packet! */	if (!ro) {		ro = &iproute;		memset(ro, 0, sizeof(iproute));	}	dst = (struct sockaddr_in *)&ro->ro_dst;	if (ro && ro->ro_rt && 	    ((ro->ro_rt->rt_flags & RTF_UP) == 0 || /* route isn't available */	     dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { /* not same ip address */		RTFREE(ro->ro_rt);		ro->ro_rt = NULL;	}	if (ro->ro_rt == NULL) {		memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));		dst->sin_family = AF_INET;		dst->sin_len = sizeof(*dst);		dst->sin_addr = ip->ip_dst;	}	if (flags & IP_ROUTETOIF) {		/* we're routing to an interface... */		if (!(ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) &&		    !(ia = ifatoia(ifa_ifwithnet(sintosa(dst))))) {			ipstat.ips_noroute++;			error = ENETUNREACH;			goto bad;		}		ifp = ia->ia_ifp;		ip->ip_ttl = 1;	} else {		/* normal routing */		if (ro->ro_rt == NULL)			rtalloc(ro);		if (ro->ro_rt == NULL) {			ipstat.ips_noroute++;			printf("EHOSTUNREACH\n");			error = EHOSTUNREACH;			goto bad;		}		ia = ifatoia(ro->ro_rt->rt_ifa);		ifp = ro->ro_rt->rt_ifp;		atomic_add((volatile long *)&ro->ro_rt->rt_use, 1);		if (ro->ro_rt->rt_flags & RTF_GATEWAY)			dst = (struct sockaddr_in *) ro->ro_rt->rt_gateway;	}	/* make sure we have an outgoing address. if not yet specified, use the	 * address of the outgoing interface	 */	if (ip->ip_src.s_addr == INADDR_ANY)		ip->ip_src = IA_SIN(ia)->sin_addr;	if ((in_broadcast(dst->sin_addr, ifp))) {		if ((ifp->if_flags & IFF_BROADCAST) == 0) {			error = EADDRNOTAVAIL;			goto bad;		}		if ((flags & IP_ALLOWBROADCAST) == 0) {			error = EACCES;			goto bad;		}		if (ip->ip_len > ifp->if_mtu) {			error = EMSGSIZE;			goto bad;		}		m->m_flags |= M_BCAST;	} else 		m->m_flags &= ~M_BCAST;#if SHOW_ROUTE	/* This just shows which interface we're planning on using */	printf("Sending to address %08lx via device %s using src addr %08lx\n",	       ntohl(ip->ip_dst.s_addr), ifp->if_name, ntohl(ip->ip_src.s_addr));#endif	/* if we're small enough, just send the thing! */	if (ip->ip_len <= ifp->if_mtu) {		ip->ip_len = htons(ip->ip_len);		ip->ip_off = htons(ip->ip_off);		ip->ip_sum = 0;		ip->ip_sum = in_cksum(m, hlen, 0);		/* now send the packet! */		error = (*ifp->output)(ifp, m, (struct sockaddr *)dst, ro->ro_rt);		goto done;	}	/* datagram is too big for interface! */	/* IP_DF = do not fragment, so if we're too big we have a problem */	if ((ip->ip_off & IP_DF)) {		error = EMSGSIZE;		ipstat.ips_cantfrag++;		goto bad;	}	len = (ifp->if_mtu - hlen) & ~7;	/* we need at least 8 bytes per fragment... */	if (len < 8) {		error = EMSGSIZE;		goto bad;	}	{		int mhlen, firstlen = len;		struct mbuf **mnext = &m->m_nextpkt;				m0 = m;		mhlen = sizeof(struct ip);		for (off = hlen + len; off < (uint16)ip->ip_len; off += len) {			m = m_gethdr(MT_HEADER);			if (!m) {				error = ENOBUFS;				ipstat.ips_odropped++;				goto sendorfree;			}			m->m_data += get_max_linkhdr();			mhip = mtod(m, struct ip*);			*mhip = *ip;			if (hlen > sizeof(struct ip)) {				mhlen = ip_optcopy(ip, mhip) + sizeof(struct ip);				mhip->ip_hl = mhlen >> 2;			}			m->m_len = mhlen;			mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);			if (ip->ip_off & IP_MF)				mhip->ip_off |= IP_MF;			if (off + len >= (uint16)ip->ip_len)				len = (uint16) ip->ip_len - off;			else				mhip->ip_off |= IP_MF;			mhip->ip_len = htons(len + mhlen);			m->m_next = m_copym(m0, off, len);			if (!m->m_next) {				m_freem(m);				error = ENOBUFS;				ipstat.ips_odropped++;				goto sendorfree;			}			m->m_pkthdr.len = mhlen + len;			m->m_pkthdr.rcvif = NULL;			mhip->ip_off = htons(mhip->ip_off);			mhip->ip_sum = 0;			mhip->ip_sum = in_cksum(m, mhlen, 0);			*mnext = m;			mnext = &m->m_nextpkt;			ipstat.ips_ofragments++;		}		m = m0;		m_adj(m, hlen + firstlen - ip->ip_len);		m->m_pkthdr.len = hlen + firstlen;		ip->ip_len = htons(m->m_pkthdr.len);		ip->ip_off = htons((ip->ip_off | IP_MF));		ip->ip_sum = 0;		ip->ip_sum = in_cksum(m, hlen, 0);sendorfree:		for (m = m0; m; m = m0) {			m0 = m->m_nextpkt;			m->m_nextpkt = NULL;			if (error == 0)				error = (*ifp->output)(ifp, m, (struct sockaddr *)dst, ro->ro_rt);			else				m_freem(m);		}		if (error == 0)			ipstat.ips_fragmented++;	}done:	if (ro == &iproute && /* we used our own variable */	    (flags & IP_ROUTETOIF) == 0 && /* we didn't route to an iterface */	    ro->ro_rt) { /* we have an allocated route */		RTFREE(ro->ro_rt); /* free the route */	}	return error;bad:	m_free(m0);	goto done;}