tcpdump mailing list archives
Re: [Patch] Host Identity Protocol
From: Guy Harris <guy () alum mit edu>
Date: Fri, 10 Jul 2009 13:38:52 -0700
On Jul 10, 2009, at 2:16 AM, Varjonen Samu wrote:
+/* supports only hex print, modified from print_int64 in print- nfs.c */+static void +hip_print_int64_hex (const u_int32_t *dp, int hostorder) +{ +#ifdef INT64_FORMAT + u_int64_t res; + + if (hostorder) + res = ((u_int64_t)ntohl(dp[0]) << 32) | (u_int64_t)ntohl(dp[1]); + else + res = ((u_int64_t)dp[0] << 32) | (u_int64_t)dp[1]; + printf(HEX_INT64_FORMAT, res); +#else + if (hostorder)+ printf("0x%08x%08x", (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1]));+ else + printf("0x%08x%08x", (u_int32_t)dp[0], (u_int32_t)dp[1]); +#endif +}
There's no guarantee that dp is aligned on a 4-byte boundary; you should probably pass it as a u_char *, and use EXTRACT_64BITS() and EXTRACT_LE_64BITS() to fetch the value.
In addition, the right way to print a 64-bit number in hex would be printf("0x%016" PRIx64, res);(tcpdump now requires that the platform's compiler support 64-bit integral data types and that printf routines support printing them).
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- [Patch] Host Identity Protocol Varjonen Samu (Jul 10)
- Re: [Patch] Host Identity Protocol Guy Harris (Jul 10)
- Re: [Patch] Host Identity Protocol Guy Harris (Jul 10)
- Re: [Patch] Host Identity Protocol Samu Varjonen (Jul 16)
- Re: [Patch] Host Identity Protocol Varjonen Samu (Jul 28)
- Re: [Patch] Host Identity Protocol Samu Varjonen (Jul 16)