]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Only do the unaligned_mem{cpy,cmp} hack if necessary.
authorGuy Harris <[email protected]>
Sat, 18 Jan 2014 01:51:04 +0000 (17:51 -0800)
committerGuy Harris <[email protected]>
Sat, 18 Jan 2014 01:51:04 +0000 (17:51 -0800)
If the processor does unaligned accesses, it's not necessary.

netdissect.h
print-esp.c
print-ip.c
print-ip6.c
print-isakmp.c
print-tcp.c
util.c

index 01a2c2a8ffda85391f30795ec6fcf0b55a308aa5..b4c24e64b7fec6597fec2e72eb2d219d167ba237 100644 (file)
@@ -270,8 +270,30 @@ extern char *copy_argv(netdissect_options *, char **);
 extern void safeputchar(int);
 extern void safeputs(const char *, int);
 
+#ifdef LBL_ALIGN
+/*
+ * The processor doesn't natively handle unaligned loads,
+ * and the compiler might "helpfully" optimize memcpy()
+ * and memcmp(), when handed pointers that would normally
+ * be properly aligned, into sequences that assume proper
+ * alignment.
+ *
+ * Do copies and compares of possibly-unaligned data by
+ * calling routines that wrap memcpy() and memcmp(), to
+ * prevent that optimization.
+ */
 extern void unaligned_memcpy(void *, const void *, size_t);
 extern int unaligned_memcmp(const void *, const void *, size_t);
+#define UNALIGNED_MEMCPY(p, q, l)      unaligned_memcpy((p), (q), (l))
+#define UNALIGNED_MEMCMP(p, q, l)      unaligned_memcmp((p), (q), (l))
+#else
+/*
+ * The procesor natively handles unaligned loads, so just use memcpy()
+ * and memcmp(), to enable those optimizations.
+ */
+#define UNALIGNED_MEMCPY(p, q, l)      memcpy((p), (q), (l))
+#define UNALIGNED_MEMCMP(p, q, l)      memcmp((p), (q), (l))
+#endif
 
 #define PLURAL_SUFFIX(n) \
        (((n) != 1) ? "s" : "")
index 241030204b293743acc50e8c53f68451202ebb67..7e6f9302c6d81639624195e09c57de01fbe850e7 100644 (file)
@@ -633,7 +633,7 @@ esp_print(netdissect_options *ndo,
                for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
                        if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
                            sa->daddr_version == 6 &&
-                           unaligned_memcmp(&sa->daddr.in6, &ip6->ip6_dst,
+                           UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst,
                                   sizeof(struct in6_addr)) == 0) {
                                break;
                        }
@@ -650,7 +650,7 @@ esp_print(netdissect_options *ndo,
                for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
                        if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
                            sa->daddr_version == 4 &&
-                           unaligned_memcmp(&sa->daddr.in4, &ip->ip_dst,
+                           UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst,
                                   sizeof(struct in_addr)) == 0) {
                                break;
                        }
index 2a3f1e67fa8329de905699aa25ba72c962a2df0f..eeaee9ae30714fdaff4035e10c8c942b9d50e4d0 100644 (file)
@@ -117,12 +117,12 @@ ip_finddst(const struct ip *ip)
                case IPOPT_LSRR:
                        if (len < 7)
                                break;
-                       unaligned_memcpy(&retval, cp + len - 4, 4);
+                       UNALIGNED_MEMCPY(&retval, cp + len - 4, 4);
                        return retval;
                }
        }
 trunc:
-       unaligned_memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+       UNALIGNED_MEMCPY(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
        return retval;
 }
 
@@ -146,9 +146,9 @@ nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
        ph.len = htons((u_int16_t)len);
        ph.mbz = 0;
        ph.proto = next_proto;
-       unaligned_memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+       UNALIGNED_MEMCPY(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
        if (IP_HL(ip) == 5)
-               unaligned_memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+               UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
        else
                ph.dst = ip_finddst(ip);
 
index 35c9210170e91d2c8968c4d9c2830ff0b3924567..908a5deed4194f7053b6ffcae49a5d1e3a6c55a0 100644 (file)
@@ -57,8 +57,8 @@ nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
 
         /* pseudo-header */
         memset(&ph, 0, sizeof(ph));
-        unaligned_memcpy(&ph.ph_src, &ip6->ip6_src, sizeof (struct in6_addr));
-        unaligned_memcpy(&ph.ph_dst, &ip6->ip6_dst, sizeof (struct in6_addr));
+        UNALIGNED_MEMCPY(&ph.ph_src, &ip6->ip6_src, sizeof (struct in6_addr));
+        UNALIGNED_MEMCPY(&ph.ph_dst, &ip6->ip6_dst, sizeof (struct in6_addr));
         ph.ph_len = htonl(len);
         ph.ph_nxt = next_proto;
 
index f3714b808ccfba70a8ca98e064c037d287b21f66..a40143649efd94385bd64e31af37f6d1aca85326 100644 (file)
@@ -798,21 +798,21 @@ cookie_record(cookie_t *in, const u_char *bp2)
        switch (IP_V(ip)) {
        case 4:
                cookiecache[ninitiator].version = 4;
-               unaligned_memcpy(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr));
-               unaligned_memcpy(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr));
+               UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr));
+               UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr));
                break;
 #ifdef INET6
        case 6:
                ip6 = (struct ip6_hdr *)bp2;
                cookiecache[ninitiator].version = 6;
-               unaligned_memcpy(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr));
-               unaligned_memcpy(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr));
+               UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr));
+               UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr));
                break;
 #endif
        default:
                return;
        }
-       unaligned_memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in));
+       UNALIGNED_MEMCPY(&cookiecache[ninitiator].initiator, in, sizeof(*in));
        ninitiator = (ninitiator + 1) % MAXINITIATORS;
 }
 
@@ -832,10 +832,10 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
                if (cookiecache[i].version != 4)
                        return 0;
                if (initiator) {
-                       if (unaligned_memcmp(&ip->ip_src, &cookiecache[i].iaddr.in4, sizeof(struct in_addr)) == 0)
+                       if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].iaddr.in4, sizeof(struct in_addr)) == 0)
                                return 1;
                } else {
-                       if (unaligned_memcmp(&ip->ip_src, &cookiecache[i].raddr.in4, sizeof(struct in_addr)) == 0)
+                       if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].raddr.in4, sizeof(struct in_addr)) == 0)
                                return 1;
                }
                break;
@@ -845,10 +845,10 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
                        return 0;
                ip6 = (struct ip6_hdr *)bp2;
                if (initiator) {
-                       if (unaligned_memcmp(&ip6->ip6_src, &cookiecache[i].iaddr.in6, sizeof(struct in6_addr)) == 0)
+                       if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].iaddr.in6, sizeof(struct in6_addr)) == 0)
                                return 1;
                } else {
-                       if (unaligned_memcmp(&ip6->ip6_src, &cookiecache[i].raddr.in6, sizeof(struct in6_addr)) == 0)
+                       if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].raddr.in6, sizeof(struct in6_addr)) == 0)
                                return 1;
                }
                break;
@@ -1007,7 +1007,7 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_sa *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&sa, ext, sizeof(sa));
+       UNALIGNED_MEMCPY(&sa, ext, sizeof(sa));
        doi = ntohl(sa.doi);
        sit = ntohl(sa.sit);
        if (doi != 1) {
@@ -1033,7 +1033,7 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
        np = (u_char *)ext + sizeof(sa);
        if (sit != 0x01) {
                ND_TCHECK2(*(ext + 1), sizeof(ident));
-               unaligned_memcpy(&ident, ext + 1, sizeof(ident));
+               UNALIGNED_MEMCPY(&ident, ext + 1, sizeof(ident));
                ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident)));
                np += sizeof(ident);
        }
@@ -1064,7 +1064,7 @@ ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_p *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&prop, ext, sizeof(prop));
+       UNALIGNED_MEMCPY(&prop, ext, sizeof(prop));
        ND_PRINT((ndo," #%d protoid=%s transform=%d",
                  prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t));
        if (prop.spi_size) {
@@ -1231,7 +1231,7 @@ ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_t *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&t, ext, sizeof(t));
+       UNALIGNED_MEMCPY(&t, ext, sizeof(t));
 
        switch (proto) {
        case 1:
@@ -1293,7 +1293,7 @@ ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_,
        ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE)));
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ND_PRINT((ndo," key len=%d", ntohs(e.len) - 4));
        if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
                ND_PRINT((ndo," "));
@@ -1330,7 +1330,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_id *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&id, ext, sizeof(id));
+       UNALIGNED_MEMCPY(&id, ext, sizeof(id));
        if (sizeof(*p) < item_len) {
                data = (u_char *)(p + 1);
                len = item_len - sizeof(*p);
@@ -1363,7 +1363,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
 
                p = (struct ipsecdoi_id *)ext;
                ND_TCHECK(*p);
-               unaligned_memcpy(&id, ext, sizeof(id));
+               UNALIGNED_MEMCPY(&id, ext, sizeof(id));
                ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)));
                if (id.proto_id) {
 #ifndef WIN32
@@ -1507,7 +1507,7 @@ ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_cert *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&cert, ext, sizeof(cert));
+       UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
        ND_PRINT((ndo," len=%d", item_len - 4));
        ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
        if (2 < ndo->ndo_vflag && 4 < item_len) {
@@ -1539,7 +1539,7 @@ ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_cert *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&cert, ext, sizeof(cert));
+       UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
        ND_PRINT((ndo," len=%d", item_len - 4));
        ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
        if (2 < ndo->ndo_vflag && 4 < item_len) {
@@ -1564,7 +1564,7 @@ ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,
        ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH)));
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
        if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
                ND_PRINT((ndo," "));
@@ -1588,7 +1588,7 @@ ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_,
        ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG)));
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
        if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
                ND_PRINT((ndo," "));
@@ -1614,7 +1614,7 @@ ikev1_nonce_print(netdissect_options *ndo, u_char tpay _U_,
        ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE)));
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ND_PRINT((ndo," n len=%d", ntohs(e.len) - 4));
        if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
                ND_PRINT((ndo," "));
@@ -1692,7 +1692,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_n *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&n, ext, sizeof(n));
+       UNALIGNED_MEMCPY(&n, ext, sizeof(n));
        doi = ntohl(n.doi);
        proto = n.prot_id;
        if (doi != 1) {
@@ -1789,7 +1789,7 @@ ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev1_pl_d *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&d, ext, sizeof(d));
+       UNALIGNED_MEMCPY(&d, ext, sizeof(d));
        doi = ntohl(d.doi);
        proto = d.prot_id;
        if (doi != 1) {
@@ -1828,7 +1828,7 @@ ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_,
        ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID)));
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
        if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
                ND_PRINT((ndo," "));
@@ -1860,7 +1860,7 @@ ikev2_gen_print(netdissect_options *ndo, u_char tpay,
        struct isakmp_gen e;
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
 
        ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
@@ -1892,7 +1892,7 @@ ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
 
        p = (struct ikev2_t *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&t, ext, sizeof(t));
+       UNALIGNED_MEMCPY(&t, ext, sizeof(t));
        ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical);
 
        t_id = ntohs(t.t_id);
@@ -1965,7 +1965,7 @@ ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
 
        p = (struct ikev2_p *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&prop, ext, sizeof(prop));
+       UNALIGNED_MEMCPY(&prop, ext, sizeof(prop));
        ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical);
 
        ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u",
@@ -2000,7 +2000,7 @@ ikev2_sa_print(netdissect_options *ndo, u_char tpay,
        int    osa_length, sa_length;
 
        ND_TCHECK(*ext1);
-       unaligned_memcpy(&e, ext1, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext1, sizeof(e));
        ikev2_pay_print(ndo, "sa", e.critical);
 
        osa_length= ntohs(e.len);
@@ -2029,7 +2029,7 @@ ikev2_ke_print(netdissect_options *ndo, u_char tpay,
 
        k = (struct ikev2_ke *)ext;
        ND_TCHECK(*ext);
-       unaligned_memcpy(&ke, ext, sizeof(ke));
+       UNALIGNED_MEMCPY(&ke, ext, sizeof(ke));
        ikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical);
 
        ND_PRINT((ndo," len=%u group=%s", ntohs(ke.h.len) - 8,
@@ -2059,7 +2059,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
        unsigned char *typedata;
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&id, ext, sizeof(id));
+       UNALIGNED_MEMCPY(&id, ext, sizeof(id));
        ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical);
 
        id_len = ntohs(id.h.len);
@@ -2162,7 +2162,7 @@ ikev2_auth_print(netdissect_options *ndo, u_char tpay,
        unsigned int len;
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&a, ext, sizeof(a));
+       UNALIGNED_MEMCPY(&a, ext, sizeof(a));
        ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
        len = ntohs(a.h.len);
 
@@ -2194,7 +2194,7 @@ ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
        struct isakmp_gen e;
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ikev2_pay_print(ndo, "nonce", e.critical);
 
        ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
@@ -2229,7 +2229,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
 
        p = (struct ikev2_n *)ext;
        ND_TCHECK(*p);
-       unaligned_memcpy(&n, ext, sizeof(n));
+       UNALIGNED_MEMCPY(&n, ext, sizeof(n));
        ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical);
 
        showspi = 1;
@@ -2443,7 +2443,7 @@ ikev2_vid_print(netdissect_options *ndo, u_char tpay,
        int i, len;
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
        ND_PRINT((ndo," len=%d vid=", ntohs(e.len) - 4));
 
@@ -2506,7 +2506,7 @@ ikev2_e_print(netdissect_options *ndo,
        volatile int dlen;
 
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
        ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
 
        dlen = ntohs(e.len)-4;
@@ -2578,7 +2578,7 @@ ike_sub0_print(netdissect_options *ndo,
 
        cp = (u_char *)ext;
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
 
        /*
         * Since we can't have a payload length of less than 4 bytes,
@@ -2621,7 +2621,7 @@ ikev1_sub_print(netdissect_options *ndo,
        while (np) {
                ND_TCHECK(*ext);
 
-               unaligned_memcpy(&e, ext, sizeof(e));
+               UNALIGNED_MEMCPY(&e, ext, sizeof(e));
 
                ND_TCHECK2(*ext, ntohs(e.len));
 
@@ -2742,7 +2742,7 @@ ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
 
        cp = (u_char *)ext;
        ND_TCHECK(*ext);
-       unaligned_memcpy(&e, ext, sizeof(e));
+       UNALIGNED_MEMCPY(&e, ext, sizeof(e));
 
        /*
         * Since we can't have a payload length of less than 4 bytes,
@@ -2798,7 +2798,7 @@ ikev2_sub_print(netdissect_options *ndo,
                pcount++;
                ND_TCHECK(*ext);
 
-               unaligned_memcpy(&e, ext, sizeof(e));
+               UNALIGNED_MEMCPY(&e, ext, sizeof(e));
 
                ND_TCHECK2(*ext, ntohs(e.len));
 
@@ -2910,7 +2910,7 @@ isakmp_print(netdissect_options *ndo,
                return;
        }
 
-       unaligned_memcpy(&base, p, sizeof(base));
+       UNALIGNED_MEMCPY(&base, p, sizeof(base));
 
        ND_PRINT((ndo,"isakmp"));
        major = (base.vers & ISAKMP_VERS_MAJOR)
index 658032e5faac7dfce6cf35125bbb6ebf72cba7f5..16aa8b60019a384dc6440e4893f9d9112d387abb 100644 (file)
@@ -314,16 +314,16 @@ tcp_print(register const u_char *bp, register u_int length,
                         if (sport > dport)
                                 rev = 1;
                         else if (sport == dport) {
-                                if (unaligned_memcmp(src, dst, sizeof ip->ip_dst) > 0)
+                                if (UNALIGNED_MEMCMP(src, dst, sizeof ip->ip_dst) > 0)
                                         rev = 1;
                         }
                         if (rev) {
-                                unaligned_memcpy(&tha.src, dst, sizeof ip->ip_dst);
-                                unaligned_memcpy(&tha.dst, src, sizeof ip->ip_src);
+                                UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip->ip_dst);
+                                UNALIGNED_MEMCPY(&tha.dst, src, sizeof ip->ip_src);
                                 tha.port = dport << 16 | sport;
                         } else {
-                                unaligned_memcpy(&tha.dst, dst, sizeof ip->ip_dst);
-                                unaligned_memcpy(&tha.src, src, sizeof ip->ip_src);
+                                UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip->ip_dst);
+                                UNALIGNED_MEMCPY(&tha.src, src, sizeof ip->ip_src);
                                 tha.port = sport << 16 | dport;
                         }
 
diff --git a/util.c b/util.c
index 5b92b47438ef2e9b069cc61add82b0f71302bc70..c58927172f2f693598d4c18f138a8e684dae3639 100644 (file)
--- a/util.c
+++ b/util.c
@@ -602,8 +602,9 @@ safeputchar(int c)
                printf("\\0x%02x", ch);
 }
 
+#ifdef LBL_ALIGN
 /*
- * some compiler tries to optimize memcpy(), using the alignment constraint
+ * Some compilers try to optimize memcpy(), using the alignment constraint
  * on the argument pointer type.  by using this function, we try to avoid the
  * optimization.
  */
@@ -619,4 +620,4 @@ unaligned_memcmp(const void *p, const void *q, size_t l)
 {
        return (memcmp(p, q, l));
 }
-
+#endif