From 2c48b3f8dcc5bb4ab49066a82d67cb86a700f2e5 Mon Sep 17 00:00:00 2001 From: Bill Joy Date: Sat, 30 Oct 1982 21:04:43 -0800 Subject: [PATCH] get rid of conditional htons/ntohs etc SCCS-vsn: sys/netinet/in.c 4.10 SCCS-vsn: sys/vax/vax/in_cksum.c 1.15 SCCS-vsn: sys/netinet/in_pcb.c 4.35 SCCS-vsn: sys/netinet/ip_icmp.c 4.23 SCCS-vsn: sys/netinet/ip_input.c 1.57 SCCS-vsn: sys/netinet/ip_output.c 1.41 SCCS-vsn: sys/netinet/tcp_debug.c 4.8 SCCS-vsn: sys/netinet/tcp_input.c 1.82 SCCS-vsn: sys/netinet/tcp_output.c 4.48 SCCS-vsn: sys/netinet/tcp_subr.c 4.34 SCCS-vsn: sys/netinet/tcp_usrreq.c 1.69 --- usr/src/sys/netinet/in.c | 19 ++++--------------- usr/src/sys/netinet/in_pcb.c | 7 ++----- usr/src/sys/netinet/ip_icmp.c | 6 +----- usr/src/sys/netinet/ip_input.c | 4 +--- usr/src/sys/netinet/ip_output.c | 8 +------- usr/src/sys/netinet/tcp_debug.c | 4 +--- usr/src/sys/netinet/tcp_input.c | 8 +------- usr/src/sys/netinet/tcp_output.c | 14 +------------- usr/src/sys/netinet/tcp_subr.c | 18 +++++------------- usr/src/sys/netinet/tcp_usrreq.c | 2 +- usr/src/sys/vax/vax/in_cksum.c | 4 ++-- 11 files changed, 20 insertions(+), 74 deletions(-) diff --git a/usr/src/sys/netinet/in.c b/usr/src/sys/netinet/in.c index b5703fcc68..18b89a6f07 100644 --- a/usr/src/sys/netinet/in.c +++ b/usr/src/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* in.c 4.9 82/10/21 */ +/* in.c 4.10 82/10/30 */ #include "../h/param.h" #include "../h/mbuf.h" @@ -18,10 +18,7 @@ inet_hash(sin, hp) { hp->afh_nethash = in_netof(sin->sin_addr); - hp->afh_hosthash = sin->sin_addr.s_addr; -#if vax || pdp11 || ns16032 - hp->afh_hosthash = ntohl((u_long)hp->afh_hosthash); -#endif + hp->afh_hosthash = ntohl(sin->sin_addr.s_addr); } inet_netmatch(sin1, sin2) @@ -47,9 +44,7 @@ if_makeaddr(net, host) addr = (net << IN_CLASSB_NSHIFT) | host; else addr = (net << IN_CLASSC_NSHIFT) | host; -#ifdef vax || pdp11 || ns16032 addr = htonl(addr); -#endif return (*(struct in_addr *)&addr); } @@ -59,11 +54,8 @@ if_makeaddr(net, host) in_netof(in) struct in_addr in; { - register u_long i = in.s_addr; + register u_long i = ntohl(in.s_addr); -#ifdef vax || pdp11 || ns16032 - i = ntohl(i); -#endif if (IN_CLASSA(i)) return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); else if (IN_CLASSB(i)) @@ -79,11 +71,8 @@ in_netof(in) in_lnaof(in) struct in_addr in; { - register u_long i = in.s_addr; + register u_long i = ntohl(in.s_addr); -#ifdef vax || pdp11 || ns16032 - i = ntohl(i); -#endif if (IN_CLASSA(i)) return ((i)&IN_CLASSA_HOST); else if (IN_CLASSB(i)) diff --git a/usr/src/sys/netinet/in_pcb.c b/usr/src/sys/netinet/in_pcb.c index bc914f7431..9a4e93e92a 100644 --- a/usr/src/sys/netinet/in_pcb.c +++ b/usr/src/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* in_pcb.c 4.34 82/10/20 */ +/* in_pcb.c 4.35 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -78,12 +78,9 @@ in_pcbbind(inp, nam) } lport = sin->sin_port; if (lport) { - u_short aport = lport; + u_short aport = htons(lport); int wild = 0; -#if vax || pdp11 || ns16032 - aport = htons(aport); -#endif /* GROSS */ if (aport < IPPORT_RESERVED && u.u_uid != 0) return (EACCES); diff --git a/usr/src/sys/netinet/ip_icmp.c b/usr/src/sys/netinet/ip_icmp.c index 2da7c96683..4d20b113c4 100644 --- a/usr/src/sys/netinet/ip_icmp.c +++ b/usr/src/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* ip_icmp.c 4.22 82/10/20 */ +/* ip_icmp.c 4.23 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -63,9 +63,7 @@ icmp_error(oip, type, code) bcopy((caddr_t)oip, (caddr_t)&icp->icmp_ip, oiplen + 8); nip = &icp->icmp_ip; nip->ip_len += oiplen; -#if vax || pdp11 || ns16032 nip->ip_len = htons((u_short)nip->ip_len); -#endif /* * Now, copy old ip header in front of icmp @@ -145,9 +143,7 @@ icmp_input(m) * Problem with previous datagram; advise * higher level routines. */ -#if vax || pdp11 || ns16032 icp->icmp_ip.ip_len = ntohs((u_short)icp->icmp_ip.ip_len); -#endif if (icmplen < ICMP_ADVLENMIN || icmplen < ICMP_ADVLEN(icp)) goto free; if (icmpprintfs) diff --git a/usr/src/sys/netinet/ip_input.c b/usr/src/sys/netinet/ip_input.c index 1f2cd30802..0e96cea4c3 100644 --- a/usr/src/sys/netinet/ip_input.c +++ b/usr/src/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* ip_input.c 1.56 82/10/23 */ +/* ip_input.c 1.57 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -91,14 +91,12 @@ next: goto bad; } -#if vax || pdp11 || ns16032 /* * Convert fields to host representation. */ ip->ip_len = ntohs((u_short)ip->ip_len); ip->ip_id = ntohs(ip->ip_id); ip->ip_off = ntohs((u_short)ip->ip_off); -#endif /* * Check that the amount of data in the buffers diff --git a/usr/src/sys/netinet/ip_output.c b/usr/src/sys/netinet/ip_output.c index ee21021f4e..fb9e009b83 100644 --- a/usr/src/sys/netinet/ip_output.c +++ b/usr/src/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* ip_output.c 1.40 82/10/20 */ +/* ip_output.c 1.41 82/10/30 */ #include "../h/param.h" #include "../h/mbuf.h" @@ -92,10 +92,8 @@ gotif: * If small enough for interface, can just send directly. */ if (ip->ip_len <= ifp->if_mtu) { -#if vax || pdp11 || ns16032 ip->ip_len = htons((u_short)ip->ip_len); ip->ip_off = htons((u_short)ip->ip_off); -#endif ip->ip_sum = 0; ip->ip_sum = in_cksum(m, hlen); error = (*ifp->if_output)(ifp, m, dst); @@ -147,18 +145,14 @@ gotif: mhip->ip_off |= IP_MF; } mhip->ip_len += sizeof (struct ip); -#if vax || pdp11 || ns16032 mhip->ip_len = htons((u_short)mhip->ip_len); -#endif mh->m_next = m_copy(m, off, len); if (mh->m_next == 0) { (void) m_free(mh); error = ENOBUFS; /* ??? */ goto bad; } -#if vax || pdp11 || ns16032 mhip->ip_off = htons((u_short)mhip->ip_off); -#endif mhip->ip_sum = 0; mhip->ip_sum = in_cksum(mh, hlen); if (error = (*ifp->if_output)(ifp, mh, dst)) diff --git a/usr/src/sys/netinet/tcp_debug.c b/usr/src/sys/netinet/tcp_debug.c index 0c6382cbd9..0d3bcc0d5f 100644 --- a/usr/src/sys/netinet/tcp_debug.c +++ b/usr/src/sys/netinet/tcp_debug.c @@ -1,4 +1,4 @@ -/* tcp_debug.c 4.7 82/10/17 */ +/* tcp_debug.c 4.8 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -69,13 +69,11 @@ tcp_trace(act, ostate, tp, ti, req) seq = ti->ti_seq; ack = ti->ti_ack; len = ti->ti_len; -#if vax || pdp11 || ns16032 if (act == TA_OUTPUT) { seq = ntohl(seq); ack = ntohl(ack); len = ntohs((u_short)len); } -#endif if (act == TA_OUTPUT) len -= sizeof (struct tcphdr); if (len) diff --git a/usr/src/sys/netinet/tcp_input.c b/usr/src/sys/netinet/tcp_input.c index d20a3fdf3a..ad0a397d79 100644 --- a/usr/src/sys/netinet/tcp_input.c +++ b/usr/src/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* tcp_input.c 1.81 82/10/20 */ +/* tcp_input.c 1.82 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -72,9 +72,7 @@ tcp_input(m0) ti->ti_next = ti->ti_prev = 0; ti->ti_x1 = 0; ti->ti_len = (u_short)tlen; -#if vax || pdp11 || ns16032 ti->ti_len = htons((u_short)ti->ti_len); -#endif if (ti->ti_sum = in_cksum(m, len)) { tcpstat.tcps_badsum++; if (tcpprintfs) @@ -120,7 +118,6 @@ tcp_input(m0) m->m_off += off; m->m_len -= off; -#if vax || pdp11 || ns16032 /* * Convert TCP protocol specific fields to host format. */ @@ -128,7 +125,6 @@ tcp_input(m0) ti->ti_ack = ntohl(ti->ti_ack); ti->ti_win = ntohs(ti->ti_win); ti->ti_urp = ntohs(ti->ti_urp); -#endif /* * Locate pcb for segment. @@ -756,9 +752,7 @@ tcp_dooptions(tp, om) if (optlen != 4) continue; tp->t_maxseg = *(u_short *)(cp + 2); -#if vax || pdp11 || ns16032 tp->t_maxseg = ntohs((u_short)tp->t_maxseg); -#endif break; } } diff --git a/usr/src/sys/netinet/tcp_output.c b/usr/src/sys/netinet/tcp_output.c index e9fa8c3880..866ca28467 100644 --- a/usr/src/sys/netinet/tcp_output.c +++ b/usr/src/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* tcp_output.c 4.47 82/10/17 */ +/* tcp_output.c 4.48 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -162,10 +162,8 @@ send: */ ti->ti_seq = tp->snd_nxt; ti->ti_ack = tp->rcv_nxt; -#if vax || pdp11 || ns16032 ti->ti_seq = htonl(ti->ti_seq); ti->ti_ack = htonl(ti->ti_ack); -#endif /* * Before ESTABLISHED, force sending of initial options * unless TCP set to not do any options. @@ -176,9 +174,7 @@ send: opt = tcp_initopt; optlen = sizeof (tcp_initopt); *(u_short *)(opt + 2) = MIN(so->so_rcv.sb_hiwat / 2, 1024); -#if vax || pdp11 || ns16032 *(u_short *)(opt + 2) = htons(*(u_short *)(opt + 2)); -#endif } else { if (tp->t_tcpopt == 0) goto noopt; @@ -211,16 +207,10 @@ noopt: if (win < so->so_rcv.sb_hiwat / 4) /* avoid silly window */ win = 0; if (win > 0) -#if vax || pdp11 || ns16032 ti->ti_win = htons((u_short)win); -#else - ti->ti_win = win; -#endif if (SEQ_GT(tp->snd_up, tp->snd_nxt)) { ti->ti_urp = tp->snd_up - tp->snd_nxt; -#if vax || pdp11 || ns16032 ti->ti_urp = htons(ti->ti_urp); -#endif ti->ti_flags |= TH_URG; } else /* @@ -244,9 +234,7 @@ noopt: */ if (len + optlen) { ti->ti_len = sizeof (struct tcphdr) + optlen + len; -#if vax || pdp11 || ns16032 ti->ti_len = htons((u_short)ti->ti_len); -#endif } ti->ti_sum = in_cksum(m, sizeof (struct tcpiphdr) + (int)optlen + len); diff --git a/usr/src/sys/netinet/tcp_subr.c b/usr/src/sys/netinet/tcp_subr.c index 47b8e696bf..f3b7542d9d 100644 --- a/usr/src/sys/netinet/tcp_subr.c +++ b/usr/src/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* tcp_subr.c 4.33 82/10/21 */ +/* tcp_subr.c 4.34 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" @@ -123,21 +123,13 @@ tcp_respond(tp, ti, ack, seq, flags) } ti->ti_next = ti->ti_prev = 0; ti->ti_x1 = 0; - ti->ti_len = sizeof (struct tcphdr) + tlen; - ti->ti_seq = seq; - ti->ti_ack = ack; -#if vax || pdp11 || ns16032 - ti->ti_len = htons((u_short)ti->ti_len); - ti->ti_seq = htonl(ti->ti_seq); - ti->ti_ack = htonl(ti->ti_ack); -#endif + ti->ti_len = htons(sizeof (struct tcphdr) + tlen); + ti->ti_seq = htonl(seq); + ti->ti_ack = htonl(ack); ti->ti_x2 = 0; ti->ti_off = sizeof (struct tcphdr) >> 2; ti->ti_flags = flags; - ti->ti_win = win; -#if vax || pdp11 || ns16032 - ti->ti_win = htons(ti->ti_win); -#endif + ti->ti_win = htons(win); ti->ti_urp = 0; ti->ti_sum = in_cksum(m, sizeof (struct tcpiphdr) + tlen); ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen; diff --git a/usr/src/sys/netinet/tcp_usrreq.c b/usr/src/sys/netinet/tcp_usrreq.c index a1274a73ab..f82be14ab5 100644 --- a/usr/src/sys/netinet/tcp_usrreq.c +++ b/usr/src/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* tcp_usrreq.c 1.68 82/10/20 */ +/* tcp_usrreq.c 1.69 82/10/30 */ #include "../h/param.h" #include "../h/systm.h" diff --git a/usr/src/sys/vax/vax/in_cksum.c b/usr/src/sys/vax/vax/in_cksum.c index 154fec19d9..ffb6145eef 100644 --- a/usr/src/sys/vax/vax/in_cksum.c +++ b/usr/src/sys/vax/vax/in_cksum.c @@ -1,4 +1,4 @@ -/* in_cksum.c 1.14 82/10/17 */ +/* in_cksum.c 1.15 82/10/30 */ #include #include "../h/mbuf.h" @@ -11,7 +11,7 @@ * code and should be rewritten for each CPU to be as fast as possible. */ -#if vax || pdp11 || ns16032 +#if vax in_cksum(m, len) register struct mbuf *m; register int len; -- 2.20.1