From 3787d34ade9660a55f546ec7fc11c34b0451fa57 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 20 Feb 2001 01:20:24 +0000 Subject: Don't do anything with 64-bit integral types if G_HAVE_GINT64 isn't defined. Use "gint64" and "guint64", not "long long int", for 64-bit integral types, so that this code works with compilers (such as Microsoft Visual C++) that have 64-bit integral types but that don't call them "long long". Use "pntohll()" to extract 64-bit integral types from a field. Put a "break;" into a "default:" clause - MSVC++ doesn't like switch (XXX) { ... default: } svn path=/trunk/; revision=3051 --- packet-diameter.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'packet-diameter.c') diff --git a/packet-diameter.c b/packet-diameter.c index 2de12232cf..a4de029f56 100644 --- a/packet-diameter.c +++ b/packet-diameter.c @@ -1,7 +1,7 @@ /* packet-diameter.c * Routines for DIAMETER packet disassembly * - * $Id: packet-diameter.c,v 1.17 2001/02/19 23:16:36 guy Exp $ + * $Id: packet-diameter.c,v 1.18 2001/02/20 01:20:24 guy Exp $ * * Copyright (c) 2001 by David Frascone * @@ -660,21 +660,27 @@ static gchar *rd_value_to_str(e_avphdr *avph, const u_char *input, int length) sprintf(buffer,"%u", intval); } break; +#ifdef G_HAVE_GINT64 + /* XXX - have to handle platforms without 64-bit integral + types. + Have to handle platforms where "%lld" and "%llu" + aren't the right formats to use to print 64-bit integral + types. */ case DIAMETER_INTEGER64: { - long long llval; - llval = *((long long *)input); - sprintf(buffer,"%lld (Unsupported Conversion. Byte ordering probably incorrect)", - llval); + gint64 llval; + llval = pntohll(input); + sprintf(buffer,"%lld", llval); } + break; case DIAMETER_UNSIGNED64: { - long long llval; - llval = *((long long *)input); - sprintf(buffer,"%llu (Unsupported Conversion. Byte ordering probably incorrect)", - llval); + guint64 llval; + llval = pntohll(input); + sprintf(buffer,"%llu", llval); } break; +#endif case DIAMETER_TIME: { struct tm lt; @@ -686,7 +692,7 @@ static gchar *rd_value_to_str(e_avphdr *avph, const u_char *input, int length) } default: /* Do nothing */ - + ; } return buffer; } /* rd value to str */ -- cgit v1.2.3