summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-07-16 16:12:16 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-07-16 16:12:16 +0000
commit96c7e2683bd59830d2aaebfd2956afa3bce9323d (patch)
tree9890f5cc1f5ae73015b15463ae9e638007de9361
parent76e68cee595bb0e514f24534e339a911d8f08032 (diff)
Expand ancient NTOHL/NTOHS/HTONS/HTONL macros.
ok guenther@, henning@
-rw-r--r--sys/dev/pci/safe.c4
-rw-r--r--sys/lib/libsa/net.c4
-rw-r--r--sys/lib/libsa/netudp.c10
-rw-r--r--sys/net/if_gre.c4
-rw-r--r--sys/net/pf.c19
-rw-r--r--sys/net/pf_lb.c18
-rw-r--r--sys/net/pf_osfp.c4
-rw-r--r--sys/net/pipex.c10
-rw-r--r--sys/netinet/ip_ipip.c6
-rw-r--r--sys/netinet/tcp_input.c20
-rw-r--r--sys/netinet/tcp_subr.c12
-rw-r--r--sys/netinet6/nd6_rtr.c4
12 files changed, 55 insertions, 60 deletions
diff --git a/sys/dev/pci/safe.c b/sys/dev/pci/safe.c
index 271cb470a1f..73053f62192 100644
--- a/sys/dev/pci/safe.c
+++ b/sys/dev/pci/safe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safe.c,v 1.39 2015/03/14 03:38:49 jsg Exp $ */
+/* $OpenBSD: safe.c,v 1.40 2015/07/16 16:12:15 mpi Exp $ */
/*-
* Copyright (c) 2003 Sam Leffler, Errno Consulting
@@ -56,7 +56,7 @@
#include <dev/pci/safevar.h>
#ifndef bswap32
-#define bswap32 NTOHL
+#define bswap32(x) (x) = ntohl((u_int32_t)(x))
#endif
#define KASSERT_X(x,y)
diff --git a/sys/lib/libsa/net.c b/sys/lib/libsa/net.c
index 068a28a9768..cd9f671c2b5 100644
--- a/sys/lib/libsa/net.c
+++ b/sys/lib/libsa/net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: net.c,v 1.17 2014/11/19 20:28:56 miod Exp $ */
+/* $OpenBSD: net.c,v 1.18 2015/07/16 16:12:15 mpi Exp $ */
/* $NetBSD: net.c,v 1.14 1996/10/13 02:29:02 christos Exp $ */
/*
@@ -208,7 +208,7 @@ intoa(u_int32_t addr)
int n;
static char buf[sizeof(".255.255.255.255")];
- NTOHL(addr);
+ addr = ntohl(addr);
cp = &buf[sizeof buf];
*--cp = '\0';
diff --git a/sys/lib/libsa/netudp.c b/sys/lib/libsa/netudp.c
index 7e9b8563f0b..0199caaede5 100644
--- a/sys/lib/libsa/netudp.c
+++ b/sys/lib/libsa/netudp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netudp.c,v 1.2 2014/11/20 14:51:42 krw Exp $ */
+/* $OpenBSD: netudp.c,v 1.3 2015/07/16 16:12:15 mpi Exp $ */
/* $NetBSD: net.c,v 1.14 1996/10/13 02:29:02 christos Exp $ */
/*
@@ -183,7 +183,7 @@ readudp(struct iodesc *d, void *pkt, size_t len, time_t tleft)
#endif
return -1;
}
- NTOHS(ip->ip_len);
+ ip->ip_len = ntohs(ip->ip_len);
if (n < ip->ip_len) {
#ifdef NET_DEBUG
if (debug)
@@ -238,9 +238,9 @@ readudp(struct iodesc *d, void *pkt, size_t len, time_t tleft)
}
*ip = tip;
}
- NTOHS(uh->uh_dport);
- NTOHS(uh->uh_sport);
- NTOHS(uh->uh_ulen);
+ uh->uh_dport = ntohs(uh->uh_dport);
+ uh->uh_sport = ntohs(uh->uh_sport);
+ uh->uh_ulen = ntohs(uh->uh_ulen);
if (uh->uh_ulen < sizeof(*uh)) {
#ifdef NET_DEBUG
if (debug)
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 9372900b821..93035a15124 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gre.c,v 1.74 2015/03/14 03:38:51 jsg Exp $ */
+/* $OpenBSD: if_gre.c,v 1.75 2015/07/16 16:12:15 mpi Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -294,7 +294,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
msiz = MOB_H_SIZ_L;
}
- HTONS(mob_h.proto);
+ mob_h.proto = htons(mob_h.proto);
mob_h.hcrc = gre_in_cksum((u_int16_t *) &mob_h, msiz);
/* Squeeze in the mobility header */
diff --git a/sys/net/pf.c b/sys/net/pf.c
index 899dbf712ff..f221ec582e4 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.922 2015/07/08 13:03:26 bluhm Exp $ */
+/* $OpenBSD: pf.c,v 1.923 2015/07/16 16:12:15 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1747,9 +1747,8 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, int *icmp_dir,
case ICMP_PARAMPROB:
/* These will not be used, but set them anyway */
*icmp_dir = PF_IN;
- *virtual_type = type;
+ *virtual_type = htons(type);
*virtual_id = 0;
- HTONS(*virtual_type);
return (1); /* These types match to another state */
/*
@@ -1834,9 +1833,8 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, int *icmp_dir,
case ICMP6_PARAM_PROB:
/* These will not be used, but set them anyway */
*icmp_dir = PF_IN;
- *virtual_type = type;
+ *virtual_type = htons(type);
*virtual_id = 0;
- HTONS(*virtual_type);
return (1); /* These types match to another state */
/*
* All remaining ICMP6 types get their own states,
@@ -1851,7 +1849,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, int *icmp_dir,
break;
#endif /* INET6 */
}
- HTONS(*virtual_type);
+ *virtual_type = htons(*virtual_type);
return (0); /* These types match to their own state */
}
@@ -2388,7 +2386,7 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af,
opt = (char *)(th + 1);
opt[0] = TCPOPT_MAXSEG;
opt[1] = 4;
- HTONS(mss);
+ mss = htons(mss);
memcpy((opt + 2), &mss, 2);
}
@@ -2560,10 +2558,7 @@ pf_match(u_int8_t op, u_int32_t a1, u_int32_t a2, u_int32_t p)
int
pf_match_port(u_int8_t op, u_int16_t a1, u_int16_t a2, u_int16_t p)
{
- NTOHS(a1);
- NTOHS(a2);
- NTOHS(p);
- return (pf_match(op, a1, a2, p));
+ return (pf_match(op, ntohs(a1), ntohs(a2), ntohs(p)));
}
int
@@ -2892,7 +2887,7 @@ pf_get_mss(struct pf_pdesc *pd)
break;
case TCPOPT_MAXSEG:
memcpy(&mss, (opt + 2), 2);
- NTOHS(mss);
+ mss = ntohs(mss);
/* FALLTHROUGH */
default:
optlen = opt[1];
diff --git a/sys/net/pf_lb.c b/sys/net/pf_lb.c
index 914ead8185f..3ce14e84055 100644
--- a/sys/net/pf_lb.c
+++ b/sys/net/pf_lb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_lb.c,v 1.43 2015/06/03 11:57:37 yasuoka Exp $ */
+/* $OpenBSD: pf_lb.c,v 1.44 2015/07/16 16:12:15 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -726,35 +726,35 @@ pf_get_transaddr_af(struct pf_rule *r, struct pf_pdesc *pd,
if (pd->proto == IPPROTO_ICMPV6 && pd->naf == AF_INET) {
if (pd->dir == PF_IN) {
- NTOHS(pd->ndport);
+ pd->ndport = ntohs(pd->ndport);
if (pd->ndport == ICMP6_ECHO_REQUEST)
pd->ndport = ICMP_ECHO;
else if (pd->ndport == ICMP6_ECHO_REPLY)
pd->ndport = ICMP_ECHOREPLY;
- HTONS(pd->ndport);
+ pd->ndport = htons(pd->ndport);
} else {
- NTOHS(pd->nsport);
+ pd->nsport = ntohs(pd->nsport);
if (pd->nsport == ICMP6_ECHO_REQUEST)
pd->nsport = ICMP_ECHO;
else if (pd->nsport == ICMP6_ECHO_REPLY)
pd->nsport = ICMP_ECHOREPLY;
- HTONS(pd->nsport);
+ pd->nsport = htons(pd->nsport);
}
} else if (pd->proto == IPPROTO_ICMP && pd->naf == AF_INET6) {
if (pd->dir == PF_IN) {
- NTOHS(pd->ndport);
+ pd->ndport = ntohs(pd->ndport);
if (pd->ndport == ICMP_ECHO)
pd->ndport = ICMP6_ECHO_REQUEST;
else if (pd->ndport == ICMP_ECHOREPLY)
pd->ndport = ICMP6_ECHO_REPLY;
- HTONS(pd->ndport);
+ pd->ndport = htons(pd->ndport);
} else {
- NTOHS(pd->nsport);
+ pd->nsport = ntohs(pd->nsport);
if (pd->nsport == ICMP_ECHO)
pd->nsport = ICMP6_ECHO_REQUEST;
else if (pd->nsport == ICMP_ECHOREPLY)
pd->nsport = ICMP6_ECHO_REPLY;
- HTONS(pd->nsport);
+ pd->nsport = htons(pd->nsport);
}
}
diff --git a/sys/net/pf_osfp.c b/sys/net/pf_osfp.c
index 366452be629..5fe6ca587eb 100644
--- a/sys/net/pf_osfp.c
+++ b/sys/net/pf_osfp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_osfp.c,v 1.29 2014/07/22 11:06:10 mpi Exp $ */
+/* $OpenBSD: pf_osfp.c,v 1.30 2015/07/16 16:12:15 mpi Exp $ */
/*
* Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
@@ -200,7 +200,7 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6,
sizeof(fp.fp_mss));
fp.fp_tcpopts = (fp.fp_tcpopts <<
PF_OSFP_TCPOPT_BITS) | PF_OSFP_TCPOPT_MSS;
- NTOHS(fp.fp_mss);
+ fp.fp_mss = ntohs(fp.fp_mss);
break;
case TCPOPT_WINDOW:
if (optlen >= TCPOLEN_WINDOW)
diff --git a/sys/net/pipex.c b/sys/net/pipex.c
index 6dd12c581be..411eae25dec 100644
--- a/sys/net/pipex.c
+++ b/sys/net/pipex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pipex.c,v 1.71 2015/07/15 22:16:42 deraadt Exp $ */
+/* $OpenBSD: pipex.c,v 1.72 2015/07/16 16:12:15 mpi Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -1356,7 +1356,7 @@ pipex_pppoe_lookup_session(struct mbuf *m0)
m_copydata(m0, sizeof(struct ether_header),
sizeof(struct pipex_pppoe_header), (caddr_t)&pppoe);
- NTOHS(pppoe.session_id);
+ pppoe.session_id = ntohs(pppoe.session_id);
session = pipex_lookup_by_session_id(PIPEX_PROTO_PPPOE,
pppoe.session_id);
#ifdef PIPEX_DEBUG
@@ -1932,7 +1932,7 @@ pipex_l2tp_output(struct mbuf *m0, struct pipex_session *session)
session->proto.l2tp.nr_acked = session->proto.l2tp.nr_nxt - 1;
seq->nr = htons(session->proto.l2tp.nr_acked);
}
- HTONS(l2tp->flagsver);
+ l2tp->flagsver = htons(l2tp->flagsver);
plen += sizeof(struct udphdr);
udp = (struct udphdr *)(mtod(m0, caddr_t) + hlen);
@@ -2608,8 +2608,8 @@ pipex_mppe_output(struct mbuf *m0, struct pipex_session *session,
if (encrypt)
hdr->coher_cnt |= 0x1000;
- HTONS(hdr->protocol);
- HTONS(hdr->coher_cnt);
+ hdr->protocol = htons(hdr->protocol);
+ hdr->coher_cnt = htons(hdr->coher_cnt);
/* encrypt chain */
for (m = m0; m; m = m->m_next) {
diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c
index d75627ac37f..8d42e63e8cc 100644
--- a/sys/netinet/ip_ipip.c
+++ b/sys/netinet/ip_ipip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipip.c,v 1.62 2015/07/15 22:16:42 deraadt Exp $ */
+/* $OpenBSD: ip_ipip.c,v 1.63 2015/07/16 16:12:15 mpi Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -457,9 +457,9 @@ ipip_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int dummy,
m_copydata(m, sizeof(struct ip) +
offsetof(struct ip, ip_off),
sizeof(u_int16_t), (caddr_t) &ipo->ip_off);
- NTOHS(ipo->ip_off);
+ ipo->ip_off = ntohs(ipo->ip_off);
ipo->ip_off &= ~(IP_DF | IP_MF | IP_OFFMASK);
- HTONS(ipo->ip_off);
+ ipo->ip_off = htons(ipo->ip_off);
}
#ifdef INET6
else if (tp == (IPV6_VERSION >> 4)) {
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index d68765f6541..efb2d4cf1d7 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.296 2015/07/15 22:16:42 deraadt Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.297 2015/07/16 16:12:15 mpi Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -569,10 +569,10 @@ tcp_input(struct mbuf *m, ...)
/*
* 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);
/*
* Locate pcb for segment.
@@ -2285,7 +2285,7 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcphdr *th,
if (TCPS_HAVERCVDSYN(tp->t_state))
continue;
bcopy((char *) cp + 2, (char *) &mss, sizeof(mss));
- NTOHS(mss);
+ mss = ntohs(mss);
oi->maxseg = mss;
break;
@@ -2305,9 +2305,9 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcphdr *th,
continue;
oi->ts_present = 1;
bcopy(cp + 2, &oi->ts_val, sizeof(oi->ts_val));
- NTOHL(oi->ts_val);
+ oi->ts_val = ntohl(oi->ts_val);
bcopy(cp + 6, &oi->ts_ecr, sizeof(oi->ts_ecr));
- NTOHL(oi->ts_ecr);
+ oi->ts_ecr = ntohl(oi->ts_ecr);
if (!(th->th_flags & TH_SYN))
continue;
@@ -2560,10 +2560,10 @@ tcp_sack_option(struct tcpcb *tp, struct tcphdr *th, u_char *cp, int optlen)
struct sackblk sack;
bcopy(tmp_cp, (char *) &(sack.start), sizeof(tcp_seq));
- NTOHL(sack.start);
+ sack.start = ntohl(sack.start);
bcopy(tmp_cp + sizeof(tcp_seq),
(char *) &(sack.end), sizeof(tcp_seq));
- NTOHL(sack.end);
+ sack.end = ntohl(sack.end);
tmp_olen -= TCPOLEN_SACK;
tmp_cp += TCPOLEN_SACK;
if (SEQ_LEQ(sack.end, sack.start))
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 12788eb3246..bf7ff297b68 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.143 2015/06/16 11:09:40 mpi Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.144 2015/07/16 16:12:15 mpi Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -410,7 +410,7 @@ tcp_respond(struct tcpcb *tp, caddr_t template, struct tcphdr *th0,
ip6->ip6_nxt = IPPROTO_TCP;
ip6->ip6_hlim = in6_selecthlim(tp ? tp->t_inpcb : NULL, NULL); /*XXX*/
ip6->ip6_plen = tlen - sizeof(struct ip6_hdr);
- HTONS(ip6->ip6_plen);
+ ip6->ip6_plen = htons(ip6->ip6_plen);
ip6_output(m, tp ? tp->t_inpcb->inp_outputopts6 : NULL,
(struct route_in6 *)ro, 0, NULL, NULL,
tp ? tp->t_inpcb : NULL);
@@ -1106,10 +1106,10 @@ tcp_signature(struct tdb *tdb, int af, struct mbuf *m, struct tcphdr *th,
th0.th_sum = 0;
if (doswap) {
- HTONL(th0.th_seq);
- HTONL(th0.th_ack);
- HTONS(th0.th_win);
- HTONS(th0.th_urp);
+ th0.th_seq = htonl(th0.th_seq);
+ th0.th_ack = htonl(th0.th_ack);
+ th0.th_win = htons(th0.th_win);
+ th0.th_urp = htons(th0.th_urp);
}
MD5Update(&ctx, (char *)&th0, sizeof(th0));
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 28ef3f8e674..e3fcac55eb2 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.109 2015/07/16 15:31:35 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.110 2015/07/16 16:12:15 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -433,7 +433,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
dr0.ifp = ifp;
/* unspecified or not? (RFC 2461 6.3.4) */
if (advreachable) {
- NTOHL(advreachable);
+ advreachable = ntohl(advreachable);
if (advreachable <= MAX_REACHABLE_TIME &&
ndi->basereachable != advreachable) {
ndi->basereachable = advreachable;