if (ntohs(oip->ip_off) &~ (IP_MF|IP_DF))
if (oip->ip_off &~ (IP_MF|IP_DF))
icmp_error(n, type, code, dest, destifp)	struct mbuf *n;	int type, code;	n_long dest;	struct ifnet *destifp;{	register struct ip *oip = mtod(n, struct ip *), *nip;	register unsigned oiplen = oip->ip_hl << 2;	register struct icmp *icp;	struct mbuf *m, m0;	unsigned icmplen;#ifdef ICMPPRINTFS	if (icmpprintfs)		printf("icmp_error(%x, %d, %d)\n", oip, type, code);#endif	if (type != ICMP_REDIRECT)		icmpstat.icps_error++;	/*	 * Don't send error if not the first fragment of message.	 * Don't error if the old packet protocol was ICMP	 * error message, only known informational types.	 */	if (ntohs(oip->ip_off) &~ (IP_MF|IP_DF))		goto freeit;	if (oip->ip_p == IPPROTO_ICMP && type != ICMP_REDIRECT &&	  n->m_len >= oiplen + ICMP_MINLEN &&	  !ICMP_INFOTYPE(((struct icmp *)((caddr_t)oip + oiplen))->icmp_type)) {		icmpstat.icps_oldicmp++;		goto freeit;	}	/* Don't send error in response to a multicast or broadcast packet */	if (n->m_flags & (M_BCAST|M_MCAST))		goto freeit;	/*	 * First, formulate icmp message	 */	m = m_gethdr(M_DONTWAIT, MT_HEADER);	if (m == NULL)		goto freeit;	icmplen = oiplen + min(8, ntohs(oip->ip_len));	m->m_len = icmplen + ICMP_MINLEN;	MH_ALIGN(m, m->m_len);	icp = mtod(m, struct icmp *);	if ((u_int)type > ICMP_MAXTYPE)		panic("icmp_error");	icmpstat.icps_outhist[type]++;	icp->icmp_type = type;	if (type == ICMP_REDIRECT)		icp->icmp_gwaddr.s_addr = dest;	else {		icp->icmp_void = 0;		/* 		 * The following assignments assume an overlay with the		 * zeroed icmp_void field.		 */		if (type == ICMP_PARAMPROB) {			icp->icmp_pptr = code;			code = 0;		} else if (type == ICMP_UNREACH &&		    code == ICMP_UNREACH_NEEDFRAG && destifp)			icp->icmp_nextmtu = htons(destifp->if_mtu);	}	icp->icmp_code = code;	bcopy((caddr_t)oip, (caddr_t)&icp->icmp_ip, icmplen);	nip = &icp->icmp_ip;	nip->ip_len = htons((u_int16_t)(ntohs(nip->ip_len) + oiplen));	m0.m_next = NULL;			/* correct nip->ip_sum */	m0.m_data = (char *)nip;	m0.m_len = nip->ip_hl << 2;	nip->ip_sum = 0;	nip->ip_sum = in_cksum(&m0, nip->ip_hl << 2);	/*	 * Now, copy old ip header (without options)	 * in front of icmp message.	 */	if (m->m_data - sizeof(struct ip) < m->m_pktdat)		panic("icmp len");	m->m_data -= sizeof(struct ip);	m->m_len += sizeof(struct ip);	m->m_pkthdr.len = m->m_len;	m->m_pkthdr.rcvif = n->m_pkthdr.rcvif;	nip = mtod(m, struct ip *);	bcopy((caddr_t)oip, (caddr_t)nip, sizeof(struct ip));	nip->ip_len = m->m_len;	nip->ip_hl = sizeof(struct ip) >> 2;	nip->ip_p = IPPROTO_ICMP;	nip->ip_tos = 0;	icmp_reflect(m);freeit:	m_freem(n);}