Date: Fri, 2 Sep 2011 16:40:18 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r225334 - in head/tools/tools/netrate: netblast netsend Message-ID: <201109021640.p82GeIws007216@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Fri Sep 2 16:40:18 2011 New Revision: 225334 URL: http://svn.freebsd.org/changeset/base/225334 Log: Fix alignment assumptions. PR: 160289 Approved by: re (kib) MFC after: 3 days Modified: head/tools/tools/netrate/netblast/netblast.c head/tools/tools/netrate/netsend/netsend.c Modified: head/tools/tools/netrate/netblast/netblast.c ============================================================================== --- head/tools/tools/netrate/netblast/netblast.c Fri Sep 2 16:18:06 2011 (r225333) +++ head/tools/tools/netrate/netblast/netblast.c Fri Sep 2 16:40:18 2011 (r225334) @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include <sys/endian.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> @@ -108,11 +109,9 @@ blast_loop(int s, long duration, u_char * 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) Modified: head/tools/tools/netrate/netsend/netsend.c ============================================================================== --- head/tools/tools/netrate/netsend/netsend.c Fri Sep 2 16:18:06 2011 (r225333) +++ head/tools/tools/netrate/netsend/netsend.c Fri Sep 2 16:40:18 2011 (r225334) @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include <sys/endian.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> @@ -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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109021640.p82GeIws007216>