From ccaea5f02e218f575d18adca2836475261e06c28 Mon Sep 17 00:00:00 2001 From: marius Date: Mon, 5 Sep 2011 17:45:22 +0000 Subject: [PATCH] MFC: r225334 Fix alignment assumptions. PR: 160289 git-svn-id: svn://svn.freebsd.org/base/stable/8@225403 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- tools/tools/netrate/netblast/netblast.c | 5 ++--- tools/tools/netrate/netsend/netsend.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/tools/netrate/netblast/netblast.c b/tools/tools/netrate/netblast/netblast.c index 3e901266f..f932fca08 100644 --- a/tools/tools/netrate/netblast/netblast.c +++ b/tools/tools/netrate/netblast/netblast.c @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include #include #include #include @@ -108,11 +109,9 @@ blast_loop(int s, long duration, u_char *packet, u_int packet_len) * previous send, the error will turn up the current send * operation, causing the current sequence number also to be * skipped. - * - * XXXRW: Note alignment assumption. */ if (packet_len >= 4) { - *((u_int32_t *)packet) = htonl(counter); + be32enc(packet, counter); counter++; } if (send(s, packet, packet_len, 0) < 0) diff --git a/tools/tools/netrate/netsend/netsend.c b/tools/tools/netrate/netsend/netsend.c index 5e41f2d74..49cd3436d 100644 --- a/tools/tools/netrate/netsend/netsend.c +++ b/tools/tools/netrate/netsend/netsend.c @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include #include #include #include @@ -203,11 +204,9 @@ timing_loop(struct _a *a) * skipped. * The counter is incremented only on the initial port number, * so all destinations will see the same set of packets. - * - * XXXRW: Note alignment assumption. */ if (cur_port == a->port && a->packet_len >= 4) { - *((u_int32_t *)a->packet) = htonl(counter); + be32enc(a->packet, counter); counter++; } if (a->port == a->port_max) { /* socket already bound */ -- 2.45.0