diff options
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in.h | 17 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_fw.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_icmp.c | 6 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 16 | ||||
-rw-r--r-- | sys/netinet/ip_mroute.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 28 | ||||
-rw-r--r-- | sys/netinet/tcp_input.c | 22 | ||||
-rw-r--r-- | sys/netinet/tcp_reass.c | 22 |
9 files changed, 70 insertions, 53 deletions
diff --git a/sys/netinet/in.h b/sys/netinet/in.h index cf72e57..cfd55ca 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -496,6 +496,23 @@ char *inet_ntoa_r __P((struct in_addr ina, char *buf)); /* in libkern */ #define sintosa(sin) ((struct sockaddr *)(sin)) #define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) +#else /* !_KERNEL */ + +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) #endif +__BEGIN_DECLS +__uint32_t htonl __P((__uint32_t)); +__uint16_t htons __P((__uint16_t)); +__uint32_t ntohl __P((__uint32_t)); +__uint16_t ntohs __P((__uint16_t)); +__END_DECLS + +#endif /* _KERNEL */ + #endif diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 1341e18..2fa823f 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -291,8 +291,8 @@ div_output(so, m, addr, control) } /* Convert fields to host order for ip_output() */ - NTOHS(ip->ip_len); - NTOHS(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); /* Send packet to output processing */ ipstat.ips_rawout++; /* XXX */ diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c index b176512..5c6e155 100644 --- a/sys/netinet/ip_fw.c +++ b/sys/netinet/ip_fw.c @@ -1575,8 +1575,8 @@ got_match: ti.ti_i = *((struct ipovly *) ip); ti.ti_t = *tcp; bcopy(&ti, ip, sizeof(ti)); - NTOHL(tip->ti_seq); - NTOHL(tip->ti_ack); + tip->ti_seq = ntohl(tip->ti_seq); + tip->ti_ack = ntohl(tip->ti_ack); tip->ti_len = ip_len - hlen - (tip->ti_off << 2); if (tcp->th_flags & TH_ACK) { tcp_respond(NULL, (void *)ip, tcp, *m, diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index b1d37dc..e19c642 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -193,8 +193,8 @@ icmp_error(n, type, code, dest, destifp) /* * Convert fields to network representation. */ - HTONS(nip->ip_len); - HTONS(nip->ip_off); + nip->ip_len = htons(nip->ip_len); + nip->ip_off = htons(nip->ip_off); /* * Now, copy old ip header (without options) @@ -363,7 +363,7 @@ icmp_input(m, off) icmpstat.icps_badlen++; goto freeit; } - NTOHS(icp->icmp_ip.ip_len); + icp->icmp_ip.ip_len = ntohs(icp->icmp_ip.ip_len); /* Discard ICMP's in response to multicast packets */ if (IN_MULTICAST(ntohl(icp->icmp_ip.ip_dst.s_addr))) goto badcode; diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 9a4c248..e82e66f 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -369,12 +369,12 @@ ip_input(struct mbuf *m) /* * Convert fields to host representation. */ - NTOHS(ip->ip_len); + ip->ip_len = ntohs(ip->ip_len); if (ip->ip_len < hlen) { ipstat.ips_badlen++; goto bad; } - NTOHS(ip->ip_off); + ip->ip_off = ntohs(ip->ip_off); /* * Check that the amount of data in the buffers @@ -762,15 +762,15 @@ found: /* Restore original checksum before diverting packet */ if (divert_info != 0) { ip->ip_len += hlen; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (hlen == sizeof(struct ip)) ip->ip_sum = in_cksum_hdr(ip); else ip->ip_sum = in_cksum(m, hlen); - NTOHS(ip->ip_off); - NTOHS(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); ip->ip_len -= hlen; } #endif @@ -793,8 +793,8 @@ found: /* Restore packet header fields to original values */ ip->ip_len += hlen; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); /* Deliver packet to divert input routine */ ip_divert_cookie = divert_cookie; diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 956c466..54d5cd7 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1661,8 +1661,8 @@ encap_send(ip, vifp, m) */ ip = (struct ip *)((caddr_t)ip_copy + sizeof(multicast_encap_iphdr)); --ip->ip_ttl; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; mb_copy->m_data += sizeof(multicast_encap_iphdr); ip->ip_sum = in_cksum(mb_copy, ip->ip_hl << 2); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index aab04c9..d6ee761 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -513,8 +513,8 @@ sendit: m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); error = ipsec4_output(&state, sp, flags); @@ -573,8 +573,8 @@ sendit: } /* make it flipped, again. */ - NTOHS(ip->ip_len); - NTOHS(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); skip_ipsec: #endif /*IPSEC*/ @@ -681,8 +681,8 @@ skip_ipsec: } /* Restore packet header fields to original values */ - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); /* Deliver packet to divert input routine */ ip_divert_cookie = divert_cookie; @@ -755,8 +755,8 @@ skip_ipsec: } m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip_input(m); goto done; } @@ -837,8 +837,8 @@ pass: */ if ((u_short)ip->ip_len <= ifp->if_mtu || ifp->if_hwassist & CSUM_FRAGMENT) { - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (sw_csum & CSUM_DELAY_IP) { if (ip->ip_vhl == IP_VHL_BORING) { @@ -943,7 +943,7 @@ pass: m->m_pkthdr.len = mhlen + len; m->m_pkthdr.rcvif = (struct ifnet *)0; m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags; - HTONS(mhip->ip_off); + mhip->ip_off = htons(mhip->ip_off); mhip->ip_sum = 0; if (sw_csum & CSUM_DELAY_IP) { if (mhip->ip_vhl == IP_VHL_BORING) { @@ -972,7 +972,7 @@ pass: m->m_pkthdr.len = hlen + firstlen; ip->ip_len = htons((u_short)m->m_pkthdr.len); ip->ip_off |= IP_MF; - HTONS(ip->ip_off); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (sw_csum & CSUM_DELAY_IP) { if (ip->ip_vhl == IP_VHL_BORING) { @@ -1950,8 +1950,8 @@ ip_mloopback(ifp, m, dst, hlen) * than the interface's MTU. Can this possibly matter? */ ip = mtod(copym, struct ip *); - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (ip->ip_vhl == IP_VHL_BORING) { ip->ip_sum = in_cksum_hdr(ip); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index d6a1760..dc06328 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -424,7 +424,7 @@ tcp_input(m, off0) len = sizeof (struct ip) + tlen; bzero(ipov->ih_x1, sizeof(ipov->ih_x1)); ipov->ih_len = (u_short)tlen; - HTONS(ipov->ih_len); + ipov->ih_len = htons(ipov->ih_len); th->th_sum = in_cksum(m, len); } if (th->th_sum) { @@ -486,10 +486,10 @@ tcp_input(m, off0) /* * Convert TCP protocol specific fields to host format. */ - NTOHL(th->th_seq); - NTOHL(th->th_ack); - NTOHS(th->th_win); - NTOHS(th->th_urp); + th->th_seq = ntohl(th->th_seq); + th->th_ack = ntohl(th->th_ack); + th->th_win = ntohs(th->th_win); + th->th_urp = ntohs(th->th_urp); /* * Delay droping TCP, IP headers, IPv6 ext headers, and TCP options, @@ -2246,7 +2246,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_MSS; bcopy((char *)cp + 2, (char *)&to->to_mss, sizeof(to->to_mss)); - NTOHS(to->to_mss); + to->to_mss = ntohs(to->to_mss); break; case TCPOPT_WINDOW: if (optlen != TCPOLEN_WINDOW) @@ -2262,10 +2262,10 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_TS; bcopy((char *)cp + 2, (char *)&to->to_tsval, sizeof(to->to_tsval)); - NTOHL(to->to_tsval); + to->to_tsval = ntohl(to->to_tsval); bcopy((char *)cp + 6, (char *)&to->to_tsecr, sizeof(to->to_tsecr)); - NTOHL(to->to_tsecr); + to->to_tsecr = ntohl(to->to_tsecr); break; case TCPOPT_CC: if (optlen != TCPOLEN_CC) @@ -2273,7 +2273,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CC; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCNEW: if (optlen != TCPOLEN_CC) @@ -2283,7 +2283,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCNEW; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCECHO: if (optlen != TCPOLEN_CC) @@ -2293,7 +2293,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCECHO; bcopy((char *)cp + 2, (char *)&to->to_ccecho, sizeof(to->to_ccecho)); - NTOHL(to->to_ccecho); + to->to_ccecho = ntohl(to->to_ccecho); break; default: continue; diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index d6a1760..dc06328 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -424,7 +424,7 @@ tcp_input(m, off0) len = sizeof (struct ip) + tlen; bzero(ipov->ih_x1, sizeof(ipov->ih_x1)); ipov->ih_len = (u_short)tlen; - HTONS(ipov->ih_len); + ipov->ih_len = htons(ipov->ih_len); th->th_sum = in_cksum(m, len); } if (th->th_sum) { @@ -486,10 +486,10 @@ tcp_input(m, off0) /* * Convert TCP protocol specific fields to host format. */ - NTOHL(th->th_seq); - NTOHL(th->th_ack); - NTOHS(th->th_win); - NTOHS(th->th_urp); + th->th_seq = ntohl(th->th_seq); + th->th_ack = ntohl(th->th_ack); + th->th_win = ntohs(th->th_win); + th->th_urp = ntohs(th->th_urp); /* * Delay droping TCP, IP headers, IPv6 ext headers, and TCP options, @@ -2246,7 +2246,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_MSS; bcopy((char *)cp + 2, (char *)&to->to_mss, sizeof(to->to_mss)); - NTOHS(to->to_mss); + to->to_mss = ntohs(to->to_mss); break; case TCPOPT_WINDOW: if (optlen != TCPOLEN_WINDOW) @@ -2262,10 +2262,10 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_TS; bcopy((char *)cp + 2, (char *)&to->to_tsval, sizeof(to->to_tsval)); - NTOHL(to->to_tsval); + to->to_tsval = ntohl(to->to_tsval); bcopy((char *)cp + 6, (char *)&to->to_tsecr, sizeof(to->to_tsecr)); - NTOHL(to->to_tsecr); + to->to_tsecr = ntohl(to->to_tsecr); break; case TCPOPT_CC: if (optlen != TCPOLEN_CC) @@ -2273,7 +2273,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CC; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCNEW: if (optlen != TCPOLEN_CC) @@ -2283,7 +2283,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCNEW; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCECHO: if (optlen != TCPOLEN_CC) @@ -2293,7 +2293,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCECHO; bcopy((char *)cp + 2, (char *)&to->to_ccecho, sizeof(to->to_ccecho)); - NTOHL(to->to_ccecho); + to->to_ccecho = ntohl(to->to_ccecho); break; default: continue; |