Add "tvb_get_ntoh64()" and "tvb_get_letoh64()" routines to fetch 64-bit
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 22 Aug 2004 00:31:58 +0000 (00:31 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 22 Aug 2004 00:31:58 +0000 (00:31 +0000)
integers.

Make FT_INT64 and FT_UINT64 add numerical values, rather than byte-array
values, to the protocol tree, and add routines to add specified 64-bit
integer values to the protocol tree.

Use those routines in the RSVP dissector.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11796 f5534014-38df-0310-8fa8-9805f1628bb7

30 files changed:
config.h.win32
doc/README.developer
doc/README.tvbuff
epan/Makefile.common
epan/dissectors/packet-aodv.c
epan/dissectors/packet-ber.c
epan/dissectors/packet-bootp.c
epan/dissectors/packet-dhcpv6.c
epan/dissectors/packet-nfs.c
epan/dissectors/packet-rsvp.c
epan/dissectors/packet-scsi.c
epan/dissectors/packet-smb.c
epan/ftypes/ftype-bytes.c
epan/ftypes/ftype-double.c
epan/ftypes/ftype-integer.c
epan/ftypes/ftype-ipv4.c
epan/ftypes/ftype-none.c
epan/ftypes/ftype-pcre.c
epan/ftypes/ftype-string.c
epan/ftypes/ftype-time.c
epan/ftypes/ftype-tvbuff.c
epan/ftypes/ftypes.c
epan/ftypes/ftypes.h
epan/int-64bit.c [deleted file]
epan/int-64bit.h [deleted file]
epan/pint.h
epan/proto.c
epan/proto.h
epan/tvbuff.c
epan/tvbuff.h

index 49b178bfe5e1c6d9bbfce6dba3355a0e37e3d013..05c0f6b2edeb05466305ff255cb21aa1e5ee9a6a 100644 (file)
 #endif /* _MSC_EXTENSIONS */
 #endif /* PRIx64 */   
 
+/* Map "_strtoui64()" to "strtoll()" */
+#define        strtoll _strtoui64
+
 /* Define if you have the z library (-lz).  */
 @HAVE_LIBZ@
 
index c6de0b2ad63c50cb0dcb406094b715cd5f54e2e6..eb5da52d764e747e40a34658adab151b5d2b5256 100644 (file)
@@ -1442,6 +1442,13 @@ protocol or field labels to the proto_tree:
        proto_tree_add_uint_format(tree, id, tvb, start, length, value,
            format, ...);
 
+       proto_item *
+       proto_tree_add_uint64(tree, id, tvb, start, length, value);
+
+       proto_item *
+       proto_tree_add_uint64_format(tree, id, tvb, start, length, value,
+           format, ...);
+
        proto_item *
        proto_tree_add_int(tree, id, tvb, start, length, value);
 
@@ -1452,6 +1459,13 @@ protocol or field labels to the proto_tree:
        proto_tree_add_int_format(tree, id, tvb, start, length, value,
            format, ...);
 
+       proto_item *
+       proto_tree_add_int64(tree, id, tvb, start, length, value);
+
+       proto_item *
+       proto_tree_add_int64_format(tree, id, tvb, start, length, value,
+           format, ...);
+
        proto_item*
        proto_tree_add_text(tree, tvb, start, length, format, ...);
 
@@ -1605,7 +1619,9 @@ proto_tree_add_boolean()
 proto_tree_add_float()
 proto_tree_add_double()
 proto_tree_add_uint()
+proto_tree_add_uint64()
 proto_tree_add_int()
+proto_tree_add_int64()
 ----------------------------
 These routines are used to add items to the protocol tree if either:
 
@@ -1658,11 +1674,17 @@ host's floating-point format.
 
 For proto_tree_add_uint(), the 'value' argument is a 32-bit unsigned
 integer value, in host byte order.  (This routine cannot be used to add
-64-bit integers; they can only be added with proto_tree_add_item().)
+64-bit integers.)
+
+For proto_tree_add_uint64(), the 'value' argument is a 64-bit unsigned
+integer value, in host byte order.
 
 For proto_tree_add_int(), the 'value' argument is a 32-bit signed
 integer value, in host byte order.  (This routine cannot be used to add
-64-bit integers; they can only be added with proto_tree_add_item().)
+64-bit integers.)
+
+For proto_tree_add_int64(), the 'value' argument is a 64-bit signed
+integer value, in host byte order.
 
 proto_tree_add_bytes_hidden()
 proto_tree_add_time_hidden()
@@ -1692,7 +1714,9 @@ proto_tree_add_boolean_format()
 proto_tree_add_float_format()
 proto_tree_add_double_format()
 proto_tree_add_uint_format()
+proto_tree_add_uint64_format()
 proto_tree_add_int_format()
+proto_tree_add_int64_format()
 ----------------------------
 These routines are used to add items to the protocol tree when the
 dissector routines wants complete control over how the field and value
index 5cce7fb92598122b0fd5ac3f22f56c9b862482f0..2aad9d8dccc7e52bcbce4462b1bb5c9ce1cec02d 100644 (file)
@@ -115,19 +115,21 @@ Single-byte accessor:
 
 guint8  tvb_get_guint8(tvbuff_t*, gint offset);
 
-Network-to-host-order access for shorts (guint16), longs (guint24), and
-24-bit ints:
+Network-to-host-order access for 16-bit integers (guint16), 32-bit
+integers (guint32), 24-bit integers, and 64-bit integers (guint64):
 
 guint16 tvb_get_ntohs(tvbuff_t*, gint offset);
 guint32 tvb_get_ntohl(tvbuff_t*, gint offset);
 guint32 tvb_get_ntoh24(tvbuff_t*, gint offset);
+guint64 tvb_get_ntoh64(tvbuff_t*, gint offset);
 
-Little-Endian-to-host-order access for shorts (guint16), longs (guint24), and
-24-bit ints:
+Little-Endian-to-host-order access for 16-bit integers (guint16), 32-bit
+integers (guint32), 24-bit integers, and 64-bit integers (guint64):
 
 guint16 tvb_get_letohs(tvbuff_t*, gint offset);
 guint32 tvb_get_letohl(tvbuff_t*, gint offset);
 guint32 tvb_get_letoh24(tvbuff_t*, gint offset);
+guint64 tvb_get_letoh64(tvbuff_t*, gint offset);
 
 
 Copying memory:
index d00a96bc9897db8f185a7734f03fcb9f7092df37..b1da34b1a9480f2a2e9e4873b8c8388ed9d68435 100644 (file)
@@ -35,7 +35,6 @@ LIBETHEREAL_SRC =             \
        except.c                \
        filesystem.c            \
        frame_data.c            \
-       int-64bit.c             \
        ipv4.c                  \
        osi-utils.c             \
        packet.c                \
@@ -65,7 +64,6 @@ LIBETHEREAL_INCLUDES =                \
        filesystem.h            \
        frame_data.h            \
        gdebug.h                \
-       int-64bit.h             \
        ipv4.h                  \
        ipv6-utils.h            \
        nstime.h                \
index b262dccc79c30cbba52e4a737b7e3639e2746661..0d5ac4e0152b85fd14b3de5e6800468773ad9a54 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <glib.h>
 
-#include <epan/int-64bit.h>
 #include <epan/packet.h>
 #include <epan/ipv6-utils.h>
 
index d1b2c902f8e79c63c0faf460c92a68623d79d89f..b1891d76d1005653987208510f3adeda9e9f027a 100644 (file)
@@ -43,7 +43,6 @@
 #include <epan/packet.h>
 
 #include <epan/strutil.h>
-#include <epan/int-64bit.h>
 #include "prefs.h"
 #include "packet-ber.h"
 
@@ -344,6 +343,7 @@ dissect_ber_integer(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int off
        guint32 tag;
        guint32 len;
        gint32 val;
+       gint64 val64;
        guint32 i;
 
        offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &class, &pc, &tag);
@@ -367,11 +367,19 @@ dissect_ber_integer(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int off
        }
        if(len>4){
                header_field_info *hfinfo;
-               char buf[8]={0,0,0,0,0,0,0,0};
 
-               tvb_memcpy(tvb, buf+8-len, offset, len);
+               val64=0;
+               if (len > 0) {
+                       /* extend sign bit */
+                       val64 = (gint8)tvb_get_guint8(tvb, offset);
+                       offset++;
+               }
+               for(i=1;i<len;i++){
+                       val64=(val64<<8)|tvb_get_guint8(tvb, offset);
+                       offset++;
+               }
                hfinfo = proto_registrar_get_nth(hf_id);
-               proto_tree_add_text(tree, tvb, offset, len, "%s: %s", hfinfo->name, u64toa(buf));
+               proto_tree_add_text(tree, tvb, offset, len, "%s: %" PRIu64, hfinfo->name, val64);
                return 0xdeadbeef;
        }
        
index bf15e2104bdb5d8e320ab753d78fc23931740075..a7d7cb642b58138fd725d325e4750ff10294c90c 100644 (file)
@@ -46,7 +46,6 @@
 
 #include <string.h>
 #include <glib.h>
-#include <epan/int-64bit.h>
 #include <epan/packet.h>
 #include "packet-arp.h"
 #include "packet-dns.h"                                /* for get_dns_name() */
@@ -850,8 +849,8 @@ bootp_option(tvbuff_t *tvb, proto_tree *bp_tree, int voff, int eoff,
 
                case AUTHEN_RDM_MONOTONIC_COUNTER:
                        proto_tree_add_text(v_tree, tvb, voff+5, 8,
-                                   "Replay Detection Value: %s",
-                                   u64toh(tvb_get_ptr(tvb, voff+5, 8)));
+                                   "Replay Detection Value: %" PRIx64,
+                                   tvb_get_ntoh64(tvb, voff+5));
                        break;
 
                default:
index 786a734aa5af694aa5fcfe973b1b55c82da256dd..955b0507b45ded4b54de4f75bd037895407da566 100644 (file)
@@ -42,7 +42,6 @@
 
 #include <string.h>
 #include <glib.h>
-#include <epan/int-64bit.h>
 #include <epan/packet.h>
 #include <epan/ipv6-utils.h>
 
index 3b73d5640e90b2369d2aebc54d054d5729cb8324..8cf3c0bf3d131e3b6aa49496d86b535c24a89954 100644 (file)
@@ -37,7 +37,6 @@
 #include "packet-rpc.h"
 #include "packet-nfs.h"
 #include "prefs.h"
-#include "epan/int-64bit.h"
 
 static int proto_nfs = -1;
 
@@ -4288,13 +4287,13 @@ static int
 dissect_nfs3_read_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
        proto_tree* tree)
 {
-       unsigned char *off;
+       guint64 off;
        guint32 len;
        guint32 hash;
 
        offset = dissect_nfs_fh3(tvb, offset, pinfo, tree, "file", &hash);
 
-       off=u64toa(tvb_get_ptr(tvb, offset, 8));
+       off=tvb_get_ntoh64(tvb, offset);
        offset = dissect_rpc_uint64(tvb, tree, hf_nfs_offset3, offset);
 
        len=tvb_get_ntohl(tvb, offset);
@@ -4302,9 +4301,9 @@ dissect_nfs3_read_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
 
        
        if (check_col(pinfo->cinfo, COL_INFO)) {
-               col_append_fstr(pinfo->cinfo, COL_INFO,", FH:0x%08x Offset:%s Len:%d", hash, off, len);
+               col_append_fstr(pinfo->cinfo, COL_INFO,", FH:0x%08x Offset:%" PRIu64 " Len:%u", hash, off, len);
        }
-       proto_item_append_text(tree, ", READ Call FH:0x%08x Offset:%s Len:%d", hash, off, len);
+       proto_item_append_text(tree, ", READ Call FH:0x%08x Offset:%" PRIu64 " Len:%u", hash, off, len);
 
        return offset;
 }
@@ -4382,14 +4381,14 @@ static int
 dissect_nfs3_write_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
        proto_tree* tree)
 {
-       unsigned char *off;
+       guint64 off;
        guint32 len;
        guint32 stable;
        guint32 hash;
 
        offset = dissect_nfs_fh3   (tvb, offset, pinfo, tree, "file", &hash);
 
-       off=u64toa(tvb_get_ptr(tvb, offset, 8));
+       off=tvb_get_ntoh64(tvb, offset);
        offset = dissect_rpc_uint64(tvb, tree, hf_nfs_offset3, offset);
 
        len=tvb_get_ntohl(tvb, offset);
@@ -4399,9 +4398,9 @@ dissect_nfs3_write_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
        offset = dissect_stable_how(tvb, offset, tree, hf_nfs_write_stable);
 
        if (check_col(pinfo->cinfo, COL_INFO)) {
-               col_append_fstr(pinfo->cinfo, COL_INFO,", FH:0x%08x Offset:%s Len:%d %s", hash, off, len, val_to_str(stable, names_stable_how, "Stable:%u"));
+               col_append_fstr(pinfo->cinfo, COL_INFO,", FH:0x%08x Offset:%" PRIu64 " Len:%u %s", hash, off, len, val_to_str(stable, names_stable_how, "Stable:%u"));
        }
-       proto_item_append_text(tree, ", WRITE Call FH:0x%08x Offset:%s Len:%d %s", hash, off, len, val_to_str(stable, names_stable_how, "Stable:%u"));
+       proto_item_append_text(tree, ", WRITE Call FH:0x%08x Offset:%" PRIu64 " Len:%u %s", hash, off, len, val_to_str(stable, names_stable_how, "Stable:%u"));
 
        offset = dissect_nfsdata   (tvb, offset, tree, hf_nfs_data);
 
index a755f01d22a7fe7d8d2655bb5cb6de57042c795e..c7509f798061be47b22a3cde781dc7949ea3ab9a 100644 (file)
@@ -2632,9 +2632,7 @@ dissect_rsvp_integrity (proto_tree *ti, tvbuff_t *tvb,
        decode_boolean_bitfield(flags, 0x01, 8, "Handshake capable", "Handshake not capable"));
     proto_tree_add_text(rsvp_object_tree, tvb, offset2+2, 6,
                        "Key Identifier: %s", tvb_bytes_to_str(tvb, offset2+2, 6));
-    sequence_number = tvb_get_ntohl(tvb, offset2+8);
-    sequence_number <<= 32;
-    sequence_number = tvb_get_ntohl(tvb, offset2+12);
+    sequence_number = tvb_get_ntoh64(tvb, offset2+8);
     proto_tree_add_text(rsvp_object_tree, tvb, offset2+8, 8,
                        "Sequence Number: %" PRIu64, sequence_number);
     proto_tree_add_text(rsvp_object_tree, tvb, offset2+16, obj_length - 20,
index 0e34fb9d70518974d4ef49364b0b4bde96e14f0c..370be66c0c5f62f4243864e732bf5d2e71e83274 100644 (file)
@@ -83,7 +83,6 @@
 #include <string.h>
 #include <epan/strutil.h>
 #include <epan/packet.h>
-#include <epan/int-64bit.h>
 #include "prefs.h"
 #include "packet-scsi.h"
 
@@ -1827,8 +1826,8 @@ dissect_scsi_blockdescs (tvbuff_t *tvb, packet_info *pinfo _U_,
                 payload_len -= desclen;
                 break;
             }
-            proto_tree_add_text (scsi_tree, tvb, offset, 8, "No. of Blocks: %s",
-                                 u64toa (tvb_get_ptr (tvb, offset, 8)));
+            proto_tree_add_text (scsi_tree, tvb, offset, 8, "No. of Blocks: %" PRIu64,
+                                 tvb_get_ntoh64 (tvb, offset));
             offset += 8;
             payload_len -= 8;
             desclen -= 8;
@@ -3755,21 +3754,21 @@ dissect_scsi_ssc2_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
                 offset += 4;
 
                 proto_tree_add_text (tree, tvb, offset, 8,
-                                     "Block Number: %s",
-                                     u64toa (tvb_get_ptr (tvb, offset, 8)));
+                                     "Block Number: %" PRIu64,
+                                     tvb_get_ntoh64 (tvb, offset));
                  offset += 8;
             } else
                 offset += 12;
 
             if (!(flags & MPU)) {
                 proto_tree_add_text (tree, tvb, offset, 8,
-                                     "File Number: %s",
-                                     u64toa (tvb_get_ptr (tvb, offset, 8)));
+                                     "File Number: %" PRIu64,
+                                     tvb_get_ntoh64 (tvb, offset));
                 offset += 8;
 
                 proto_tree_add_text (tree, tvb, offset, 8,
-                                     "Set Number: %s",
-                                     u64toa (tvb_get_ptr (tvb, offset, 8)));
+                                     "Set Number: %" PRIu64,
+                                     tvb_get_ntoh64 (tvb, offset));
                 offset += 8;
             } else
                 offset += 16;
@@ -3806,13 +3805,13 @@ dissect_scsi_ssc2_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
 
             if (!(flags & BPU)) {
                 proto_tree_add_text (tree, tvb, offset, 8,
-                                     "First Block Location: %s",
-                                     u64toa (tvb_get_ptr (tvb, offset, 8)));
+                                     "First Block Location: %" PRIu64,
+                                     tvb_get_ntoh64 (tvb, offset));
                 offset += 8;
 
                 proto_tree_add_text (tree, tvb, offset, 8,
-                                     "Last Block Location: %s",
-                                     u64toa (tvb_get_ptr (tvb, offset, 8)));
+                                     "Last Block Location: %" PRIu64,
+                                     tvb_get_ntoh64 (tvb, offset));
                 offset += 8;
             } else
                 offset += 16;
@@ -3821,8 +3820,8 @@ dissect_scsi_ssc2_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
 
             if (!(flags & BYCU)) {
                 proto_tree_add_text (tree, tvb, offset, 8,
-                                     "Number of Bytes in Buffer: %s",
-                                     u64toa (tvb_get_ptr (tvb, offset, 8)));
+                                     "Number of Bytes in Buffer: %" PRIu64,
+                                     tvb_get_ntoh64 (tvb, offset));
             }
             offset += 8;
             break;
index a9cc387d067370a949d4c63f669b18d9e1c73907..db97ee34ac4a611c3b4bf6edf11489c46a3ad58e 100644 (file)
@@ -36,7 +36,6 @@
 #include <string.h>
 #include <glib.h>
 #include <ctype.h>
-#include <epan/int-64bit.h>
 #include <epan/packet.h>
 #include <epan/conversation.h>
 #include "smb.h"
@@ -4665,8 +4664,7 @@ dissect_locking_andx_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
                        proto_item *litem = NULL;
                        proto_tree *ltree = NULL;
                        if(lt&0x10){
-                               guint8 buf[8];
-                               guint32 val;
+                               guint64 val;
 
                                /* large lock format */
                                litem = proto_tree_add_text(tr, tvb, offset, 20,
@@ -4685,32 +4683,16 @@ dissect_locking_andx_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
 
                                /* offset */
                                CHECK_BYTE_COUNT(8);
-                               val=tvb_get_letohl(tvb, offset);
-                               buf[3]=(val>>24)&0xff;
-                               buf[2]=(val>>16)&0xff;
-                               buf[1]=(val>> 8)&0xff;
-                               buf[0]=(val    )&0xff;
-                               val=tvb_get_letohl(tvb, offset+4);
-                               buf[7]=(val>>24)&0xff;
-                               buf[6]=(val>>16)&0xff;
-                               buf[5]=(val>> 8)&0xff;
-                               buf[4]=(val    )&0xff;
-                               proto_tree_add_string(ltree, hf_smb_lock_long_offset, tvb, offset, 8, u64toa(buf));
+                               val=((guint64)tvb_get_letohl(tvb, offset)) << 32
+                                   | tvb_get_letohl(tvb, offset+4);
+                               proto_tree_add_uint64(ltree, hf_smb_lock_long_offset, tvb, offset, 8, val);
                                COUNT_BYTES(8);
 
                                /* length */
                                CHECK_BYTE_COUNT(8);
-                               val=tvb_get_letohl(tvb, offset);
-                               buf[3]=(val>>24)&0xff;
-                               buf[2]=(val>>16)&0xff;
-                               buf[1]=(val>> 8)&0xff;
-                               buf[0]=(val    )&0xff;
-                               val=tvb_get_letohl(tvb, offset+4);
-                               buf[7]=(val>>24)&0xff;
-                               buf[6]=(val>>16)&0xff;
-                               buf[5]=(val>> 8)&0xff;
-                               buf[4]=(val    )&0xff;
-                               proto_tree_add_string(ltree, hf_smb_lock_long_length, tvb, offset, 8, u64toa(buf));
+                               val=((guint64)tvb_get_letohl(tvb, offset)) << 32
+                                   | tvb_get_letohl(tvb, offset+4);
+                               proto_tree_add_uint64(ltree, hf_smb_lock_long_length, tvb, offset, 8, val);
                                COUNT_BYTES(8);
                        } else {
                                /* normal lock format */
@@ -4749,8 +4731,7 @@ dissect_locking_andx_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
                        proto_item *litem = NULL;
                        proto_tree *ltree = NULL;
                        if(lt&0x10){
-                               guint8 buf[8];
-                               guint32 val;
+                               guint64 val;
 
                                /* large lock format */
                                litem = proto_tree_add_text(tr, tvb, offset, 20,
@@ -4769,32 +4750,16 @@ dissect_locking_andx_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
 
                                /* offset */
                                CHECK_BYTE_COUNT(8);
-                               val=tvb_get_letohl(tvb, offset);
-                               buf[3]=(val    )&0xff;
-                               buf[2]=(val>> 8)&0xff;
-                               buf[1]=(val>>16)&0xff;
-                               buf[0]=(val>>24)&0xff;
-                               val=tvb_get_letohl(tvb, offset+4);
-                               buf[7]=(val    )&0xff;
-                               buf[6]=(val>> 8)&0xff;
-                               buf[5]=(val>>16)&0xff;
-                               buf[4]=(val>>24)&0xff;
-                               proto_tree_add_string(ltree, hf_smb_lock_long_offset, tvb, offset, 8, u64toa(buf));
+                               val=((guint64)tvb_get_letohl(tvb, offset)) << 32
+                                   | tvb_get_letohl(tvb, offset+4);
+                               proto_tree_add_uint64(ltree, hf_smb_lock_long_offset, tvb, offset, 8, val);
                                COUNT_BYTES(8);
 
                                /* length */
                                CHECK_BYTE_COUNT(8);
-                               val=tvb_get_letohl(tvb, offset);
-                               buf[3]=(val    )&0xff;
-                               buf[2]=(val>> 8)&0xff;
-                               buf[1]=(val>>16)&0xff;
-                               buf[0]=(val>>24)&0xff;
-                               val=tvb_get_letohl(tvb, offset+4);
-                               buf[7]=(val    )&0xff;
-                               buf[6]=(val>> 8)&0xff;
-                               buf[5]=(val>>16)&0xff;
-                               buf[4]=(val>>24)&0xff;
-                               proto_tree_add_string(ltree, hf_smb_lock_long_length, tvb, offset, 8, u64toa(buf));
+                               val=((guint64)tvb_get_letohl(tvb, offset)) << 32
+                                   | tvb_get_letohl(tvb, offset+4);
+                               proto_tree_add_uint64(ltree, hf_smb_lock_long_length, tvb, offset, 8, val);
                                COUNT_BYTES(8);
                        } else {
                                /* normal lock format */
@@ -15932,11 +15897,11 @@ proto_register_smb(void)
                NULL, 0, "Number of unlock requests in this request", HFILL }},
 
        { &hf_smb_lock_long_length,
-               { "Length", "smb.lock.length", FT_STRING, BASE_DEC,
+               { "Length", "smb.lock.length", FT_UINT64, BASE_DEC,
                NULL, 0, "Length of lock/unlock region", HFILL }},
 
        { &hf_smb_lock_long_offset,
-               { "Offset", "smb.lock.offset", FT_STRING, BASE_DEC,
+               { "Offset", "smb.lock.offset", FT_UINT64, BASE_DEC,
                NULL, 0, "Offset in the file of lock/unlock region", HFILL }},
 
        { &hf_smb_file_type,
index 7a94012ce08e5aac568b3f443d6d0b6ce7fe50f9..0284fa41d786056224f0708a0f69cf4eb8140455 100644 (file)
@@ -29,7 +29,6 @@
 #include <ctype.h>
 #include <epan/addr_resolv.h>
 #include <epan/strutil.h>
-#include <epan/int-64bit.h>
 
 #ifdef HAVE_LIBPCRE
 #include <pcre.h>
@@ -40,7 +39,6 @@
 
 #define ETHER_LEN      6
 #define IPv6_LEN       16
-#define U64_LEN                8
 
 static void
 bytes_fvalue_new(fvalue_t *fv)
@@ -123,13 +121,6 @@ ipv6_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
        common_fvalue_set(fv, value, IPv6_LEN);
 }
 
-static void
-u64_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
-{
-       g_assert(!already_copied);
-       common_fvalue_set(fv, value, U64_LEN);
-}
-
 static gpointer
 value_get(fvalue_t *fv)
 {
@@ -227,34 +218,6 @@ ipv6_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogF
        return TRUE;
 }
 
-static gboolean
-u64_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
-{
-       guint8  buffer[8];
-
-       if (atou64(s, buffer) == NULL) {
-               logfunc("\"%s\" is not a valid integer", s);
-               return FALSE;
-       }
-
-       u64_fvalue_set(fv, buffer, FALSE);
-       return TRUE;
-}
-
-static gboolean
-i64_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
-{
-       guint8  buffer[8];
-
-       if (atoi64(s, buffer) == NULL) {
-               logfunc("\"%s\" is not a valid integer", s);
-               return FALSE;
-       }
-
-       u64_fvalue_set(fv, buffer, FALSE);
-       return TRUE;
-}
-
 static guint
 len(fvalue_t *fv)
 {
@@ -368,178 +331,6 @@ cmp_le(fvalue_t *fv_a, fvalue_t *fv_b)
        return (memcmp(a->data, b->data, a->len) <= 0);
 }
 
-static gboolean
-cmp_gt_i64(fvalue_t *fv_a, fvalue_t *fv_b)
-{
-       GByteArray      *a = fv_a->value.bytes;
-       GByteArray      *b = fv_b->value.bytes;
-
-       if (a->len > b->len) {
-               return TRUE;
-       }
-
-       if (a->len < b->len) {
-               return FALSE;
-       }
-
-       if ((a->data[0] & 0x80) == 0) {
-               /*
-                * "a" is positive.
-                */
-               if (b->data[0] & 0x80) {
-                       /*
-                        * "b" is negative, so a > b.
-                        */
-                       return TRUE;
-               }
-       } else {
-               /*
-                * "a" is negative.
-                */
-               if ((b->data[0] & 0x80) == 0) {
-                       /*
-                        * "b" is positive, so a < b.
-                        */
-                       return FALSE;
-               }
-       }
-
-       /*
-        * "a" and "b" have the same sign, so "memcmp()" should
-        * give the right answer.
-        */
-       return (memcmp(a->data, b->data, a->len) > 0);
-}
-
-static gboolean
-cmp_ge_i64(fvalue_t *fv_a, fvalue_t *fv_b)
-{
-       GByteArray      *a = fv_a->value.bytes;
-       GByteArray      *b = fv_b->value.bytes;
-
-       if (a->len > b->len) {
-               return TRUE;
-       }
-
-       if (a->len < b->len) {
-               return FALSE;
-       }
-
-       if ((a->data[0] & 0x80) == 0) {
-               /*
-                * "a" is positive.
-                */
-               if (b->data[0] & 0x80) {
-                       /*
-                        * "b" is negative, so a > b.
-                        */
-                       return TRUE;
-               }
-       } else {
-               /*
-                * "a" is negative.
-                */
-               if ((b->data[0] & 0x80) == 0) {
-                       /*
-                        * "b" is positive, so a < b.
-                        */
-                       return FALSE;
-               }
-       }
-
-       /*
-        * "a" and "b" have the same sign, so "memcmp()" should
-        * give the right answer.
-        */
-       return (memcmp(a->data, b->data, a->len) >= 0);
-}
-
-static gboolean
-cmp_lt_i64(fvalue_t *fv_a, fvalue_t *fv_b)
-{
-       GByteArray      *a = fv_a->value.bytes;
-       GByteArray      *b = fv_b->value.bytes;
-
-       if (a->len < b->len) {
-               return TRUE;
-       }
-
-       if (a->len > b->len) {
-               return FALSE;
-       }
-
-       if (a->data[0] & 0x80) {
-               /*
-                * "a" is negative.
-                */
-               if ((b->data[0] & 0x80) == 0) {
-                       /*
-                        * "b" is positive, so a < b.
-                        */
-                       return TRUE;
-               }
-       } else {
-               /*
-                * "a" is positive.
-                */
-               if (b->data[0] & 0x80) {
-                       /*
-                        * "b" is negative, so a > b.
-                        */
-                       return FALSE;
-               }
-       }
-
-       /*
-        * "a" and "b" have the same sign, so "memcmp()" should
-        * give the right answer.
-        */
-       return (memcmp(a->data, b->data, a->len) < 0);
-}
-
-static gboolean
-cmp_le_i64(fvalue_t *fv_a, fvalue_t *fv_b)
-{
-       GByteArray      *a = fv_a->value.bytes;
-       GByteArray      *b = fv_b->value.bytes;
-
-       if (a->len < b->len) {
-               return TRUE;
-       }
-
-       if (a->len > b->len) {
-               return FALSE;
-       }
-
-       if (a->data[0] & 0x80) {
-               /*
-                * "a" is negative.
-                */
-               if ((b->data[0] & 0x80) == 0) {
-                       /*
-                        * "b" is positive, so a < b.
-                        */
-                       return TRUE;
-               }
-       } else {
-               /*
-                * "a" is positive.
-                */
-               if (b->data[0] & 0x80) {
-                       /*
-                        * "b" is negative, so a > b.
-                        */
-                       return FALSE;
-               }
-       }
-
-       /*
-        * "a" and "b" have the same sign, so "memcmp()" should
-        * give the right answer.
-        */
-       return (memcmp(a->data, b->data, a->len) <= 0);
-}
-
 static gboolean cmp_bytes_bitwise_and(fvalue_t *fv_a, fvalue_t *fv_b)
 {
        GByteArray      *a = fv_a->value.bytes;
@@ -629,10 +420,12 @@ ftype_register_bytes(void)
 
                bytes_fvalue_set,               /* set_value */
                NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                value_get,                      /* get_value */
                NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -662,10 +455,12 @@ ftype_register_bytes(void)
 
                bytes_fvalue_set,               /* set_value */
                NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                value_get,                      /* get_value */
                NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -695,10 +490,12 @@ ftype_register_bytes(void)
 
                ether_fvalue_set,               /* set_value */
                NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                value_get,                      /* get_value */
                NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -728,10 +525,12 @@ ftype_register_bytes(void)
 
                ipv6_fvalue_set,                /* set_value */
                NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                value_get,                      /* get_value */
                NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -748,76 +547,8 @@ ftype_register_bytes(void)
                slice,
        };
 
-       static ftype_t u64_type = {
-               "FT_UINT64",                    /* name */
-               "Unsigned 64-bit integer",      /* pretty_name */
-               U64_LEN,                        /* wire_size */
-               bytes_fvalue_new,               /* new_value */
-               bytes_fvalue_free,              /* free_value */
-               u64_from_unparsed,              /* val_from_unparsed */
-               NULL,                           /* val_from_string */
-               NULL,                           /* val_to_string_repr */
-               NULL,                           /* len_string_repr */
-
-               u64_fvalue_set,                 /* set_value */
-               NULL,                           /* set_value_integer */
-               NULL,                           /* set_value_floating */
-
-               value_get,                      /* get_value */
-               NULL,                           /* get_value_integer */
-               NULL,                           /* get_value_floating */
-
-               cmp_eq,
-               cmp_ne,
-               cmp_gt,
-               cmp_ge,
-               cmp_lt,
-               cmp_le,
-               cmp_bytes_bitwise_and,
-               NULL,                           /* cmp_contains */
-               NULL,                           /* cmp_matches */
-
-               len,
-               slice,
-       };
-
-       static ftype_t i64_type = {
-               "FT_INT64",                     /* name */
-               "Signed 64-bit integer",        /* pretty_name */
-               U64_LEN,                        /* wire_size */
-               bytes_fvalue_new,               /* new_value */
-               bytes_fvalue_free,              /* free_value */
-               i64_from_unparsed,              /* val_from_unparsed */
-               NULL,                           /* val_from_string */
-               NULL,                           /* val_to_string_repr */
-               NULL,                           /* len_string_repr */
-
-               u64_fvalue_set,                 /* set_value */
-               NULL,                           /* set_value_integer */
-               NULL,                           /* set_value_floating */
-
-               value_get,                      /* get_value */
-               NULL,                           /* get_value_integer */
-               NULL,                           /* get_value_floating */
-
-               cmp_eq,
-               cmp_ne,
-               cmp_gt_i64,
-               cmp_ge_i64,
-               cmp_lt_i64,
-               cmp_le_i64,
-               cmp_bytes_bitwise_and,
-               NULL,                           /* cmp_contains */
-               NULL,                           /* cmp_matches */
-
-               len,
-               slice,
-       };
-
        ftype_register(FT_BYTES, &bytes_type);
        ftype_register(FT_UINT_BYTES, &uint_bytes_type);
        ftype_register(FT_ETHER, &ether_type);
        ftype_register(FT_IPv6, &ipv6_type);
-       ftype_register(FT_UINT64, &u64_type);
-       ftype_register(FT_INT64, &i64_type);
 }
index 5c60941d2ec0b8c3e62d029e2013ce741c8880f4..af45990cdc7560758d7abe0d63aa1551ced41586 100644 (file)
@@ -157,23 +157,25 @@ ftype_register_double(void)
 {
 
        static ftype_t float_type = {
-               "FT_FLOAT",
-               "floating point (single-precision)",
-               0,
-               double_fvalue_new,
-               NULL,
+               "FT_FLOAT",                     /* name */
+               "floating point (single-precision)", /* pretty_name */
+               0,                              /* wire_size */
+               double_fvalue_new,              /* new_value */
+               NULL,                           /* free_value */
                val_from_unparsed,              /* val_from_unparsed */
                NULL,                           /* val_from_string */
                float_val_to_repr,              /* val_to_string_repr */
                float_val_repr_len,             /* len_string_repr */
 
-               NULL,
-               NULL,
-               double_fvalue_set_floating,
+               NULL,                           /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               double_fvalue_set_floating,     /* set_value_floating */
 
-               NULL,
-               NULL,
-               value_get_floating,
+               NULL,                           /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               value_get_floating,             /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
@@ -190,23 +192,25 @@ ftype_register_double(void)
        };
 
        static ftype_t double_type = {
-               "FT_DOUBLE",
-               "floating point (double-precision)",
-               0,
-               double_fvalue_new,
-               NULL,
+               "FT_DOUBLE",                    /* name */
+               "floating point (double-precision)", /* pretty_name */
+               0,                              /* wire_size */
+               double_fvalue_new,              /* new_value */
+               NULL,                           /* free_value */
                val_from_unparsed,              /* val_from_unparsed */
                NULL,                           /* val_from_string */
                double_val_to_repr,             /* val_to_string_repr */
                double_val_repr_len,            /* len_string_repr */
 
-               NULL,
-               NULL,
-               double_fvalue_set_floating,
+               NULL,                           /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               double_fvalue_set_floating,     /* set_value_floating */
 
-               NULL,
-               NULL,
-               value_get_floating,
+               NULL,                           /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               value_get_floating,             /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
index a347d88a983c585718e79fc16c41f60c41800c1e..f15dceed6a1be110507a8dd13b585f9767a46c08 100644 (file)
@@ -191,6 +191,135 @@ cmp_bitwise_and(fvalue_t *a, fvalue_t *b)
        return (a->value.integer & b->value.integer);
 }
 
+static void
+int64_fvalue_new(fvalue_t *fv)
+{
+       fv->value.integer64 = 0;
+}
+
+static void
+set_integer64(fvalue_t *fv, guint64 value)
+{
+       fv->value.integer64 = value;
+}
+
+static guint64
+get_integer64(fvalue_t *fv)
+{
+       return fv->value.integer64;
+}
+
+static gboolean
+val64_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
+{
+       guint64 value;
+       char    *endptr;
+
+       errno = 0;
+       value = strtoull(s, &endptr, 0);
+
+       if (errno == EINVAL || endptr == s || *endptr != '\0') {
+               /* This isn't a valid number. */
+               if (logfunc != NULL)
+                       logfunc("\"%s\" is not a valid number.", s);
+               return FALSE;
+       }
+       if (errno == ERANGE) {
+               if (logfunc != NULL) {
+                       if (value == ULONG_MAX) {
+                               logfunc("\"%s\" causes an integer overflow.",
+                                   s);
+                       }
+                       else {
+                               /*
+                                * XXX - can "strtoul()" set errno to
+                                * ERANGE without returning ULONG_MAX?
+                                */
+                               logfunc("\"%s\" is not an integer.", s);
+                       }
+               }
+               return FALSE;
+       }
+       if (value > G_MAXUINT64) {
+               /*
+                * Fits in an unsigned long, but not in a guint64
+                * (unlikely, but not impossible).
+                */
+               if (logfunc != NULL)
+                       logfunc("\"%s\" causes an integer overflow.", s);
+               return FALSE;
+       }
+
+       fv->value.integer64 = value;
+       return TRUE;
+}
+
+static gboolean
+cmp_eq64(fvalue_t *a, fvalue_t *b)
+{
+       return a->value.integer64 == b->value.integer64;
+}
+
+static gboolean
+cmp_ne64(fvalue_t *a, fvalue_t *b)
+{
+       return a->value.integer64 != b->value.integer64;
+}
+
+static gboolean
+u_cmp_gt64(fvalue_t *a, fvalue_t *b)
+{
+       return (gint64)a->value.integer64 > (gint64)b->value.integer64;
+}
+
+static gboolean
+u_cmp_ge64(fvalue_t *a, fvalue_t *b)
+{
+       return (gint64)a->value.integer64 >= (gint64)b->value.integer64;
+}
+
+static gboolean
+u_cmp_lt64(fvalue_t *a, fvalue_t *b)
+{
+       return (gint64)a->value.integer64 < (gint64)b->value.integer64;
+}
+
+static gboolean
+u_cmp_le64(fvalue_t *a, fvalue_t *b)
+{
+       return (gint64)a->value.integer64 <= (gint64)b->value.integer64;
+}
+
+static gboolean
+s_cmp_gt64(fvalue_t *a, fvalue_t *b)
+{
+       return a->value.integer64 > b->value.integer64;
+}
+
+static gboolean
+s_cmp_ge64(fvalue_t *a, fvalue_t *b)
+{
+       return a->value.integer64 >= b->value.integer64;
+}
+
+static gboolean
+s_cmp_lt64(fvalue_t *a, fvalue_t *b)
+{
+       return a->value.integer64 < b->value.integer64;
+}
+
+static gboolean
+s_cmp_le64(fvalue_t *a, fvalue_t *b)
+{
+       return a->value.integer64 <= b->value.integer64;
+}
+
+static gboolean
+cmp_bitwise_and64(fvalue_t *a, fvalue_t *b)
+{
+       return (a->value.integer64 & b->value.integer64);
+}
+
 /* BOOLEAN-specific */
 
 static void
@@ -259,10 +388,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -291,10 +422,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -323,10 +456,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -355,10 +490,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -374,6 +511,40 @@ ftype_register_integers(void)
                NULL,                           /* len */
                NULL,                           /* slice */
        };
+       static ftype_t uint64_type = {
+               "FT_UINT64",                    /* name */
+               "unsigned, 8 bytes",            /* pretty_name */
+               8,                              /* wire_size */
+               int64_fvalue_new,               /* new_value */
+               NULL,                           /* free_value */
+               val64_from_unparsed,            /* val_from_unparsed */
+               NULL,                           /* val_from_string */
+               NULL,                           /* val_to_string_repr */
+               NULL,                           /* len_string_repr */
+
+               NULL,                           /* set_value */
+               NULL,                           /* set_value_integer */
+               set_integer64,                  /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
+
+               NULL,                           /* get_value */
+               NULL,                           /* get_value_integer */
+               get_integer64,                  /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
+
+               cmp_eq64,
+               cmp_ne64,
+               u_cmp_gt64,
+               u_cmp_ge64,
+               u_cmp_lt64,
+               u_cmp_le64,
+               cmp_bitwise_and64,
+               NULL,                           /* cmp_contains */
+               NULL,                           /* cmp_matches */
+
+               NULL,
+               NULL,
+       };
        static ftype_t int8_type = {
                "FT_INT8",                      /* name */
                "signed, 1 byte",               /* pretty_name */
@@ -387,10 +558,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -419,10 +592,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -451,10 +626,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -483,10 +660,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -502,6 +681,40 @@ ftype_register_integers(void)
                NULL,                           /* len */
                NULL,                           /* slice */
        };
+       static ftype_t int64_type = {
+               "FT_INT64",                     /* name */
+               "signed, 8 bytes",              /* pretty_name */
+               8,                              /* wire_size */
+               int64_fvalue_new,               /* new_value */
+               NULL,                           /* free_value */
+               val64_from_unparsed,            /* val_from_unparsed */
+               NULL,                           /* val_from_string */
+               NULL,                           /* val_to_string_repr */
+               NULL,                           /* len_string_repr */
+
+               NULL,                           /* set_value */
+               NULL,                           /* set_value_integer */
+               set_integer64,                  /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
+
+               NULL,                           /* get_value */
+               NULL,                           /* get_value_integer */
+               get_integer64,                  /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
+
+               cmp_eq64,
+               cmp_ne64,
+               s_cmp_gt64,
+               s_cmp_ge64,
+               s_cmp_lt64,
+               s_cmp_le64,
+               cmp_bitwise_and64,
+               NULL,                           /* cmp_contains */
+               NULL,                           /* cmp_matches */
+
+               NULL,
+               NULL,
+       };
        static ftype_t boolean_type = {
                "FT_BOOLEAN",                   /* name */
                "Boolean",                      /* pretty_name */
@@ -515,10 +728,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                bool_eq,                        /* cmp_eq */
@@ -548,10 +763,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -581,10 +798,12 @@ ftype_register_integers(void)
 
                NULL,                           /* set_value */
                set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                get_integer,                    /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -605,10 +824,12 @@ ftype_register_integers(void)
        ftype_register(FT_UINT16, &uint16_type);
        ftype_register(FT_UINT24, &uint24_type);
        ftype_register(FT_UINT32, &uint32_type);
+       ftype_register(FT_UINT64, &uint64_type);
        ftype_register(FT_INT8, &int8_type);
        ftype_register(FT_INT16, &int16_type);
        ftype_register(FT_INT24, &int24_type);
        ftype_register(FT_INT32, &int32_type);
+       ftype_register(FT_INT64, &int64_type);
        ftype_register(FT_BOOLEAN, &boolean_type);
        ftype_register(FT_IPXNET, &ipxnet_type);
        ftype_register(FT_FRAMENUM, &framenum_type);
index 5a8c9a36b7f181f3de3701cc1306b5ce2f24421b..0691b441173c165575f761704aca427ff0289099 100644 (file)
@@ -199,23 +199,25 @@ ftype_register_ipv4(void)
 {
 
        static ftype_t ipv4_type = {
-               "FT_IPv4",
-               "IPv4 address",
-               4,
-               NULL,
-               NULL,
+               "FT_IPv4",                      /* name */
+               "IPv4 address",                 /* pretty_name */
+               4,                              /* wire_size */
+               NULL,                           /* new_value */
+               NULL,                           /* free_value */
                val_from_unparsed,              /* val_from_unparsed */
                NULL,                           /* val_from_string */
                val_to_repr,                    /* val_to_string_repr */
                val_repr_len,                   /* len_string_repr */
 
-               NULL,
-               set_integer,
-               NULL,
+               NULL,                           /* set_value */
+               set_integer,                    /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
 
-               value_get,
-               NULL,
-               NULL,
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
index 61e23937c7570fe342d40e6736a8a8d1a65b0537..4eb037eed9a2542ff546de23203c96bee70d1ecd 100644 (file)
@@ -2,10 +2,9 @@
  * $Id$
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 2001 Gerald Combs
  *
- *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -33,23 +32,25 @@ ftype_register_none(void)
 {
 
        static ftype_t none_type = {
-               "FT_NONE",
-               "label",
-               0,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
+               "FT_NONE",                      /* name */
+               "label",                        /* pretty_name */
+               0,                              /* wire_size */
+               NULL,                           /* new_value */
+               NULL,                           /* free_value */
+               NULL,                           /* val_from_unparsed */
+               NULL,                           /* val_from_string */
                NULL,                           /* val_to_string_repr */
                NULL,                           /* len_string_repr */
 
-               NULL,
-               NULL,
-               NULL,
+               NULL,                           /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
 
-               NULL,
-               NULL,
-               NULL,
+               NULL,                           /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
                NULL,                           /* cmp_eq */
                NULL,                           /* cmp_ne */
index dea1f04ec52cc4d1f84a7bfe5237948ae4613b59..fa0e6258f5420d8fb2b7049ed78219ef5ba825dc 100755 (executable)
@@ -160,36 +160,38 @@ void
 ftype_register_pcre(void)
 {
        static ftype_t pcre_type = {
-               "FT_PCRE",
-               "Compiled Perl-Compatible Regular Expression object",
-               0,                                      /* wire_size */
+               "FT_PCRE",              /* name */
+               "Compiled Perl-Compatible Regular Expression object", /* pretty_name */
+               0,                      /* wire_size */
                pcre_fvalue_new,        /* new_value */
                pcre_fvalue_free,       /* free_value */
                val_from_unparsed,      /* val_from_unparsed */
                val_from_string,        /* val_from_string */
-               NULL,                           /* val_to_string_repr */
-               NULL,                           /* len_string_repr */
+               NULL,                   /* val_to_string_repr */
+               NULL,                   /* len_string_repr */
 
                pcre_fvalue_set,        /* set_value */
-               NULL,                           /* set_value_integer */
-               NULL,                           /* set_value_floating */
+               NULL,                   /* set_value_integer */
+               NULL,                   /* set_value_integer64 */
+               NULL,                   /* set_value_floating */
 
                pcre_fvalue_get,        /* get_value */
-               NULL,                           /* get_value_integer */
-               NULL,                           /* get_value_floating */
-
-               NULL,                           /* cmp_eq */
-               NULL,                           /* cmp_ne */
-               NULL,                           /* cmp_gt */
-               NULL,                           /* cmp_ge */
-               NULL,                           /* cmp_lt */
-               NULL,                           /* cmp_le */
-               NULL,                           /* cmp_bitwise_and */
-               NULL,                           /* cmp_contains */
-               NULL,                           /* cmp_matches */
-
-               NULL,                           /* len */
-               NULL,                           /* slice */
+               NULL,                   /* get_value_integer */
+               NULL,                   /* get_value_integer64 */
+               NULL,                   /* get_value_floating */
+
+               NULL,                   /* cmp_eq */
+               NULL,                   /* cmp_ne */
+               NULL,                   /* cmp_gt */
+               NULL,                   /* cmp_ge */
+               NULL,                   /* cmp_lt */
+               NULL,                   /* cmp_le */
+               NULL,                   /* cmp_bitwise_and */
+               NULL,                   /* cmp_contains */
+               NULL,                   /* cmp_matches */
+
+               NULL,                   /* len */
+               NULL,                   /* slice */
        };
        ftype_register(FT_PCRE, &pcre_type);
 }
@@ -200,9 +202,9 @@ void
 ftype_register_pcre(void)
 {
        static ftype_t pcre_type = {
-               "FT_PCRE",
-               "Compiled Perl-Compatible Regular Expression object",
-               0,                                      /* wire_size */
+               "FT_PCRE",                      /* name */
+               "Compiled Perl-Compatible Regular Expression object", /* pretty_name */
+               0,                              /* wire_size */
                NULL,                           /* new_value */
                NULL,                           /* free_value */
                NULL,                           /* val_from_unparsed */
@@ -212,10 +214,12 @@ ftype_register_pcre(void)
 
                NULL,                           /* set_value */
                NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                NULL,                           /* get_value */
                NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */ 
 
                NULL,                           /* cmp_eq */
index fcbc0b4daad61a49a3b2225622970f420ba89c8a..5a2c9c733dc2cb98461bd0a278a74d9765e56a94 100644 (file)
@@ -312,10 +312,12 @@ ftype_register_string(void)
 
                string_fvalue_set,              /* set_value */
                NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
                NULL,                           /* set_value_floating */
 
                value_get,                      /* get_value */
                NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
                NULL,                           /* get_value_floating */
 
                cmp_eq,
@@ -332,23 +334,25 @@ ftype_register_string(void)
                slice,
        };
        static ftype_t stringz_type = {
-               "FT_STRINGZ",
-               "character string",
-               0,
-               string_fvalue_new,
-               string_fvalue_free,
+               "FT_STRINGZ",                   /* name */
+               "character string",             /* pretty name */
+               0,                              /* wire_size */
+               string_fvalue_new,              /* new_value */
+               string_fvalue_free,             /* free_value */
                val_from_unparsed,              /* val_from_unparsed */
                val_from_string,                /* val_from_string */
                NULL,                           /* val_to_string_repr */
                NULL,                           /* len_string_repr */
 
-               string_fvalue_set,
-               NULL,
-               NULL,
+               string_fvalue_set,              /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
 
-               value_get,
-               NULL,
-               NULL,
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
@@ -364,23 +368,25 @@ ftype_register_string(void)
                slice,
        };
        static ftype_t uint_string_type = {
-               "FT_UINT_STRING",
-               "character string",
-               0,
-               string_fvalue_new,
-               string_fvalue_free,
+               "FT_UINT_STRING",               /* name */
+               "character string",             /* pretty_name */
+               0,                              /* wire_size */
+               string_fvalue_new,              /* new_value */
+               string_fvalue_free,             /* free_value */
                val_from_unparsed,              /* val_from_unparsed */
                val_from_string,                /* val_from_string */
                NULL,                           /* val_to_string_repr */
                NULL,                           /* len_string_repr */
 
-               string_fvalue_set,
-               NULL,
-               NULL,
+               string_fvalue_set,              /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
 
-               value_get,
-               NULL,
-               NULL,
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
index 9f6c6c177b0ba08ae118c96d56d334b95969e335..582e42987fc1728499554f7176e66d602d2b3372 100644 (file)
@@ -338,23 +338,25 @@ ftype_register_time(void)
 {
 
        static ftype_t abstime_type = {
-               "FT_ABSOLUTE_TIME",
-               "date/time",
-               0,
-               time_fvalue_new,
-               NULL,
+               "FT_ABSOLUTE_TIME",             /* name */
+               "date/time",                    /* pretty_name */
+               0,                              /* wire_size */
+               time_fvalue_new,                /* new_value */
+               NULL,                           /* free_value */
                absolute_val_from_unparsed,     /* val_from_unparsed */
                absolute_val_from_string,       /* val_from_string */
                absolute_val_to_repr,           /* val_to_string_repr */
                absolute_val_repr_len,          /* len_string_repr */
 
-               time_fvalue_set,
-               NULL,
-               NULL,
+               time_fvalue_set,                /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
 
-               value_get,
-               NULL,
-               NULL,
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
@@ -370,23 +372,25 @@ ftype_register_time(void)
                NULL
        };
        static ftype_t reltime_type = {
-               "FT_RELATIVE_TIME",
-               "time offset",
-               0,
-               time_fvalue_new,
-               NULL,
+               "FT_RELATIVE_TIME",             /* name */
+               "time offset",                  /* pretty_name */
+               0,                              /* wire_size */
+               time_fvalue_new,                /* new_value */
+               NULL,                           /* free_value */
                relative_val_from_unparsed,     /* val_from_unparsed */
                NULL,                           /* val_from_string */
                relative_val_to_repr,           /* val_to_string_repr */
                relative_val_repr_len,          /* len_string_repr */
 
-               time_fvalue_set,
-               NULL,
-               NULL,
+               time_fvalue_set,                /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
 
-               value_get,
-               NULL,
-               NULL,
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
                cmp_eq,
                cmp_ne,
index 7ee00a63651b483345cb7abc2a0afc16c1bf69b8..4cf78ddcbd39b916daf99a15b4fde1376acd889f 100644 (file)
@@ -234,13 +234,15 @@ ftype_register_tvbuff(void)
                NULL,                           /* val_to_string_repr */
                NULL,                           /* len_string_repr */
 
-               value_set,
-               NULL,
-               NULL,
-
-               value_get,
-               NULL,
-               NULL,
+               value_set,                      /* set_value */
+               NULL,                           /* set_value_integer */
+               NULL,                           /* set_value_integer64 */
+               NULL,                           /* set_value_floating */
+
+               value_get,                      /* get_value */
+               NULL,                           /* get_value_integer */
+               NULL,                           /* get_value_integer64 */
+               NULL,                           /* get_value_floating */
 
 
                /* TODO - tvb's *can* do 'eq', etc. */
index ca0ea446ec8f9bbb862f5ff8cbaf21c484b0588e..e4472137aa4fe214fdfabda3ce96cc82ccc962b1 100644 (file)
@@ -427,6 +427,13 @@ fvalue_set_integer(fvalue_t *fv, guint32 value)
        fv->ftype->set_value_integer(fv, value);
 }
 
+void
+fvalue_set_integer64(fvalue_t *fv, guint64 value)
+{
+       g_assert(fv->ftype->set_value_integer64);
+       fv->ftype->set_value_integer64(fv, value);
+}
+
 void
 fvalue_set_floating(fvalue_t *fv, gdouble value)
 {
@@ -449,6 +456,13 @@ fvalue_get_integer(fvalue_t *fv)
        return fv->ftype->get_value_integer(fv);
 }
 
+guint64
+fvalue_get_integer64(fvalue_t *fv)
+{
+       g_assert(fv->ftype->get_value_integer64);
+       return fv->ftype->get_value_integer64(fv);
+}
+
 double
 fvalue_get_floating(fvalue_t *fv)
 {
index 93050f4f78306af6c6fc251b7b24464b2de24753..184efc425bbd4577cfb856c281f73e6df4ea5c9b 100644 (file)
@@ -147,6 +147,7 @@ typedef struct _fvalue_t {
                /* Put a few basic types in here */
                gpointer        pointer;
                guint32         integer;
+               guint64         integer64;
                gdouble         floating;
                gchar           *string;
                guchar          *ustring;
@@ -177,10 +178,12 @@ typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t);
 
 typedef void (*FvalueSetFunc)(fvalue_t*, gpointer, gboolean);
 typedef void (*FvalueSetIntegerFunc)(fvalue_t*, guint32);
+typedef void (*FvalueSetInteger64Func)(fvalue_t*, guint64);
 typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
 
 typedef gpointer (*FvalueGetFunc)(fvalue_t*);
 typedef guint32 (*FvalueGetIntegerFunc)(fvalue_t*);
+typedef guint64 (*FvalueGetInteger64Func)(fvalue_t*);
 typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
 
 typedef gboolean (*FvalueCmp)(fvalue_t*, fvalue_t*);
@@ -202,11 +205,13 @@ struct _ftype_t {
        /* could be union */
        FvalueSetFunc           set_value;
        FvalueSetIntegerFunc    set_value_integer;
+       FvalueSetInteger64Func  set_value_integer64;
        FvalueSetFloatingFunc   set_value_floating;
 
        /* could be union */
        FvalueGetFunc           get_value;
        FvalueGetIntegerFunc    get_value_integer;
+       FvalueGetInteger64Func  get_value_integer64;
        FvalueGetFloatingFunc   get_value_floating;
 
        FvalueCmp               cmp_eq;
@@ -288,6 +293,9 @@ fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied);
 void
 fvalue_set_integer(fvalue_t *fv, guint32 value);
 
+void
+fvalue_set_integer64(fvalue_t *fv, guint64 value);
+
 void
 fvalue_set_floating(fvalue_t *fv, gdouble value);
 
@@ -297,6 +305,9 @@ fvalue_get(fvalue_t *fv);
 guint32
 fvalue_get_integer(fvalue_t *fv);
 
+guint64
+fvalue_get_integer64(fvalue_t *fv);
+
 double
 fvalue_get_floating(fvalue_t *fv);
 
diff --git a/epan/int-64bit.c b/epan/int-64bit.c
deleted file mode 100644 (file)
index 060003d..0000000
+++ /dev/null
@@ -1,551 +0,0 @@
-/* int-64bit.c
- * Routines for handling of 64-bit integers
- * 2001 Ronnie Sahlberg
- *
- * $Id$
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <string.h>
-#include "int-64bit.h"
-
-/* all functions take the 64bit integer parameter as a
-   pointer to a 64bit integer in network order.
-   that is ptr[0] is the most significant byte and
-   ptr[7] is the least significant byte.
-*/
-
-#define U64STRLEN      21
-
-
-/* this must be signed. if it is not clear why, please dont
-   modify the functions in this file. it will break.
-*/
-static const signed char u64val[64][U64STRLEN] =
-{
-/* 1  */       { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 2  */       { 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 3  */       { 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 4  */       { 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 5  */       { 6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 6  */       { 2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 7  */       { 4,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 8  */       { 8,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 9  */       { 6,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 10 */       { 2,1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 11 */       { 4,2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 12 */       { 8,4,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 13 */       { 6,9,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 14 */       { 2,9,1,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 15 */       { 4,8,3,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 16 */       { 8,6,7,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 17 */       { 6,3,5,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 18 */       { 2,7,0,1,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 19 */       { 4,4,1,2,6,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 20 */       { 8,8,2,4,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 21 */       { 6,7,5,8,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 22 */       { 2,5,1,7,9,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 23 */       { 4,0,3,4,9,1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 24 */       { 8,0,6,8,8,3,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 25 */       { 6,1,2,7,7,7,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 26 */       { 2,3,4,4,5,5,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 27 */       { 4,6,8,8,0,1,7,6,0,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 28 */       { 8,2,7,7,1,2,4,3,1,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 29 */       { 6,5,4,5,3,4,8,6,2,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 30 */       { 2,1,9,0,7,8,6,3,5,0,0,0,0,0,0,0,0,0,0,0,0 },
-/* 31 */       { 4,2,8,1,4,7,3,7,0,1,0,0,0,0,0,0,0,0,0,0,0 },
-/* 32 */       { 8,4,6,3,8,4,7,4,1,2,0,0,0,0,0,0,0,0,0,0,0 },
-/* 33 */       { 6,9,2,7,6,9,4,9,2,4,0,0,0,0,0,0,0,0,0,0,0 },
-/* 34 */       { 2,9,5,4,3,9,9,8,5,8,0,0,0,0,0,0,0,0,0,0,0 },
-/* 35 */       { 4,8,1,9,6,8,9,7,1,7,1,0,0,0,0,0,0,0,0,0,0 },
-/* 36 */       { 8,6,3,8,3,7,9,5,3,4,3,0,0,0,0,0,0,0,0,0,0 },
-/* 37 */       { 6,3,7,6,7,4,9,1,7,8,6,0,0,0,0,0,0,0,0,0,0 },
-/* 38 */       { 2,7,4,3,5,9,8,3,4,7,3,1,0,0,0,0,0,0,0,0,0 },
-/* 39 */       { 4,4,9,6,0,9,7,7,8,4,7,2,0,0,0,0,0,0,0,0,0 },
-/* 40 */       { 8,8,8,3,1,8,5,5,7,9,4,5,0,0,0,0,0,0,0,0,0 },
-/* 41 */       { 6,7,7,7,2,6,1,1,5,9,9,0,1,0,0,0,0,0,0,0,0 },
-/* 42 */       { 2,5,5,5,5,2,3,2,0,9,9,1,2,0,0,0,0,0,0,0,0 },
-/* 43 */       { 4,0,1,1,1,5,6,4,0,8,9,3,4,0,0,0,0,0,0,0,0 },
-/* 44 */       { 8,0,2,2,2,0,3,9,0,6,9,7,8,0,0,0,0,0,0,0,0 },
-/* 45 */       { 6,1,4,4,4,0,6,8,1,2,9,5,7,1,0,0,0,0,0,0,0 },
-/* 46 */       { 2,3,8,8,8,0,2,7,3,4,8,1,5,3,0,0,0,0,0,0,0 },
-/* 47 */       { 4,6,6,7,7,1,4,4,7,8,6,3,0,7,0,0,0,0,0,0,0 },
-/* 48 */       { 8,2,3,5,5,3,8,8,4,7,3,7,0,4,1,0,0,0,0,0,0 },
-/* 49 */       { 6,5,6,0,1,7,6,7,9,4,7,4,1,8,2,0,0,0,0,0,0 },
-/* 50 */       { 2,1,3,1,2,4,3,5,9,9,4,9,2,6,5,0,0,0,0,0,0 },
-/* 51 */       { 4,2,6,2,4,8,6,0,9,9,9,8,5,2,1,1,0,0,0,0,0 },
-/* 52 */       { 8,4,2,5,8,6,3,1,8,9,9,7,1,5,2,2,0,0,0,0,0 },
-/* 53 */       { 6,9,4,0,7,3,7,2,6,9,9,5,3,0,5,4,0,0,0,0,0 },
-/* 54 */       { 2,9,9,0,4,7,4,5,2,9,9,1,7,0,0,9,0,0,0,0,0 },
-/* 55 */       { 4,8,9,1,8,4,9,0,5,8,9,3,4,1,0,8,1,0,0,0,0 },
-/* 56 */       { 8,6,9,3,6,9,8,1,0,7,9,7,8,2,0,6,3,0,0,0,0 },
-/* 57 */       { 6,3,9,7,2,9,7,3,0,4,9,5,7,5,0,2,7,0,0,0,0 },
-/* 58 */       { 2,7,8,5,5,8,5,7,0,8,8,1,5,1,1,4,4,1,0,0,0 },
-/* 59 */       { 4,4,7,1,1,7,1,5,1,6,7,3,0,3,2,8,8,2,0,0,0 },
-/* 60 */       { 8,8,4,3,2,4,3,0,3,2,5,7,0,6,4,6,7,5,0,0,0 },
-/* 61 */       { 6,7,9,6,4,8,6,0,6,4,0,5,1,2,9,2,5,1,1,0,0 },
-/* 62 */       { 2,5,9,3,9,6,3,1,2,9,0,0,3,4,8,5,0,3,2,0,0 },
-/* 63 */       { 4,0,9,7,8,3,7,2,4,8,1,0,6,8,6,1,1,6,4,0,0 },
-/* 64 */       { 8,0,8,5,7,7,4,5,8,6,3,0,2,7,3,3,2,2,9,0,0 }
-};
-
-
-/* convert an unsigned  64 bit integer into a string
-   it is important that this function is efficient
-   since it will be used for every 64bit integer in
-   any capture.
-   It is much less important that the inverse: atou64
-   be efficient since it is only called when
-   diplayfilters are entered.
-
-   "neg" should be 1 if the number should have a "-" put in
-   front of it.
-*/
-static char *
-n64toa(const unsigned char *u64ptr, int neg)
-{
-       unsigned char acc[U64STRLEN]; /* accumulator */
-       int i,j,k,pos;
-       static char str[U64STRLEN+1]; /* 1 extra for the sign */
-
-       /* clear out the accumulator */
-       for(i=0;i<U64STRLEN-1;i++){
-               acc[i]=0;
-       }
-
-       pos=0;
-       /* loop over the 8 bytes of the 64bit integer,
-          lsb to msb */
-       for(i=7;i>=0;i--){
-               /* optimize, most of these bytes will be 0 ?*/
-               if(u64ptr[i]==0){
-                       pos+=8;
-               } else {
-                       for(j=0;j<8;j++,pos++){
-                               if(u64ptr[i]&(1<<j)){
-                                       for(k=0;k<U64STRLEN-1;k++){
-                                               acc[k]+=u64val[pos][k];
-                                       }
-                               }
-                       }
-               }
-               /* we must handle carries inside this loop
-                  since othevise the signed char in acc will
-                  owerflow/wrap, but we dont need to do it
-                  for every iteration. its enough if we
-                  do it halfway through and at the end
-                  and we will prevent any overflow.
-               */
-               if((i%4)==0){
-                       /* handle carries */
-                       for(j=0;j<U64STRLEN-1;j++){
-                               if(acc[j]>9){
-                                       int x;
-                                       x=acc[j]/10;
-                                       acc[j+1]+=x;
-                                       acc[j]-=x*10;
-                               }
-                       }
-               }
-       }
-
-       /* convert to a string */
-       str[U64STRLEN-1+neg]=0;
-       for(i=0;i<U64STRLEN-1;i++){
-               str[U64STRLEN-2-i+neg]='0'+acc[i];
-       }
-
-       /* skip the initial zeros */
-       for(i=0;i<U64STRLEN-2;i++){
-               if(str[i+neg]>'0'){
-                       break;
-               }
-       }
-
-       /* insert the sign */
-       if (neg)
-               str[i] = '-';
-
-       return str+i;
-}
-
-/*
- * Convert an unsigned 64-bit integer into a string, in decimal.
- */
-char *
-u64toa(const unsigned char *u64ptr)
-{
-       /*
-        * Just use "n64toa()".
-        */
-       return n64toa(u64ptr, 0);
-}
-
-/*
- * Convert a signed 64-bit integer into a string, in decimal.
- */
-char *
-i64toa(const unsigned char *i64ptr)
-{
-       unsigned char neg[8];
-       int i;
-       int carry;
-       int byte;
-
-       /*
-        * The bytes of the integer go from msb to lsb, so the
-        * msb is "i64ptr[0]".
-        *
-        * The sign bit, therefore, is "i64ptr[0] & 0x80".
-        */
-       if (i64ptr[0] & 0x80) {
-               /*
-                * It's negative - compute the absolute value,
-                * by taking the two's complement; take the
-                * one's complement of the low-order byte, add
-                * 1, take the one's complement of the next byte
-                * up, add the carry from the previous addition,
-                * etc.
-                *
-                * If it's the maximum negative value, which is
-                * 0x8000000000000000, this will turn it back
-                * into 0x8000000000000000, which "n64toa()"
-                * will handle correctly, reporting the absolute
-                * value of the maximum negative value;
-                * thus, we don't have to worry about it.
-                */
-               carry = 1;
-               for (i = 7; i >= 0; i--) {
-                       byte = ((unsigned char)~i64ptr[i]) + carry;
-                       neg[i] = byte;
-                       if (byte & 0x100)
-                               carry = 1;
-                       else
-                               carry = 0;
-               }
-
-               /*
-                * Use "n64toa()" on the negative, and tell it to insert
-                * a "-".
-                */
-               return n64toa(neg, 1);
-       } else {
-               /*
-                * It's positive, so just use "n64toa()".
-                */
-               return n64toa(i64ptr, 0);
-       }
-}
-
-/* like memcmp but compares in reverse */
-static int
-revcmp(const signed char *s1, const signed char *s2, int len)
-{
-       int i;
-
-       for(i=len-1;i>=0;i--){
-               if(s1[i]==s2[i]){
-                       continue;
-               }
-               if(s1[i]>s2[i]){
-                       return 1;
-               } else {
-                       return -1;
-               }
-       }
-       return 0;
-}
-
-/*
- * Convert a string to an unsigned 64-bit integer.
- */
-unsigned char *
-atou64(const char *u64str, unsigned char *u64int)
-{
-       signed char res[U64STRLEN]; /* residual */
-       int i,j,len;
-       const char *strp;
-
-       if(!u64str){
-               return NULL;
-       }
-
-       /* if it is a hex string */
-       if( (u64str[0]=='0')
-       &&  (u64str[1]=='x') ){
-               return htou64(u64str, u64int);
-       }
-
-       /* verify that the string is ok */
-       for(strp=u64str;*strp;strp++){
-               if((*strp>='0')&&(*strp<='9')){
-                       continue;
-               }
-               return NULL;
-       }
-
-       /* clear the result vector */
-       for(i=0;i<8;i++){
-               u64int[i]=0;
-       }
-
-       /* clear the residual string and copy the
-          original to it (subtracting '0')
-       */
-       for(i=0;i<U64STRLEN;i++){
-               res[i]=0;
-       }
-       while(*u64str=='0'){ /* skip initial blanks */
-               u64str++;
-       }
-       len=strlen(u64str)-1;
-       for(i=0;len>=0;i++,len--){
-               res[i]=u64str[len]-'0';
-       }
-
-       /* go through all bits and subtract their
-          value */
-       for(i=63;i>=0;i--){
-               if(revcmp(u64val[i], res, U64STRLEN)<=0){
-                       u64int[7-(i>>3)]|=(1<<(i&0x07));
-                       for(j=0;j<U64STRLEN;j++){
-                               res[j]-=u64val[i][j];
-                               /*underflow*/
-                               if(res[j]<0){
-                                       res[j]+=10;
-                                       res[j+1]-=1;
-                               }
-                       }
-               }
-       }
-
-       return u64int;
-}
-
-/*
- * Convert a string to a signed 64-bit integer.
- */
-unsigned char *
-atoi64(const char *i64str, unsigned char *i64int)
-{
-       int i;
-       int carry;
-       int byte;
-
-       if(!i64str){
-               return NULL;
-       }
-
-       /*
-        * Does it begin with a minus sign?
-        */
-       if (i64str[0] == '-') {
-               /*
-                * Yes - convert the rest of the string to a number...
-                */
-               if (atou64(&i64str[1], i64int) == NULL) {
-                       /*
-                        * We failed.
-                        */
-                       return NULL;
-               }
-
-               /*
-                * ...and then take its negative.
-                */
-               carry = 1;
-               for (i = 7; i >= 0; i--) {
-                       byte = ((unsigned char)~i64int[i]) + carry;
-                       i64int[i] = byte;
-                       if (byte & 0x100)
-                               carry = 1;
-                       else
-                               carry = 0;
-               }
-               return i64int;
-       } else {
-               /*
-                * No - just let "atou64()" handle it.
-                */
-               return atou64(i64str, i64int);
-       }
-}
-
-/*
- * Convert an unsigned 64-bit integer to a string, in hex.
- */
-char *
-u64toh(const unsigned char *u64ptr)
-{
-       static char str[19], *strp;
-       static char ntoh[] = {'0','1','2','3','4','5','6','7',
-               '8','9','a','b','c','d','e','f'};
-       int i;
-
-       str[0]='0';
-       str[1]='x';
-       strp=str+2;
-       for(i=0;i<8;i++){
-               *strp++ = ntoh[u64ptr[i]>>4];
-               *strp++ = ntoh[u64ptr[i]&0x0f];
-       }
-       *strp=0;
-
-       return str;
-}
-
-static unsigned int
-ntoh(unsigned char h)
-{
-       if((h>='0')&&(h<='9')){
-               return h-'0';
-       }
-
-       if((h>='A')&&(h<='F')){
-               return h+10-'A';
-       }
-
-       if((h>='a')&&(h<='f')){
-               return h+10-'a';
-       }
-
-       return 0;
-}
-
-/*
- * Convert a hex string to an unsigned 64-bit integer.
- */
-unsigned char *
-htou64(const char *u64str, unsigned char *u64int)
-{
-       int i,len;
-       char str[16];
-       const char *strp;
-
-       if(!u64str){
-               return NULL;
-       }
-
-       /* verify that the string is ok */
-       if( (u64str[0]!='0')
-       ||  (u64str[1]!='x') ){
-               return NULL;
-       }
-
-       for(strp=u64str+2;*strp;strp++){
-               if((*strp>='0')&&(*strp<='9')){
-                       continue;
-               }
-               if((*strp>='A')&&(*strp<='F')){
-                       continue;
-               }
-               if((*strp>='a')&&(*strp<='f')){
-                       continue;
-               }
-               return NULL;
-       }
-
-       /* clear the result vector */
-       for(i=0;i<8;i++){
-               u64int[i]=0;
-       }
-
-       /* get len of input string */
-       for(len=0,strp=u64str+2;len<16;len++,strp++){
-               if((*strp>='0')&&(*strp<='9')){
-                       continue;
-               }
-               if((*strp>='A')&&(*strp<='F')){
-                       continue;
-               }
-               if((*strp>='a')&&(*strp<='f')){
-                       continue;
-               }
-               break;
-       }
-       for(i=0;i<16;i++){
-               str[i]='0';
-       }
-       for(i=0;i<len;i++){
-               str[15-i]=u64str[len+1-i];
-       }
-
-
-       for(i=0;i<8;i++){
-               u64int[i]=(ntoh(str[i*2])<<4)
-                       | ntoh(str[1+i*2]);
-       }
-
-       return u64int;
-}
-
-#ifdef TEST_DEBUG
-#include <stdio.h>
-
-int main(void)
-{
-       char i998877665544331[8] =
-           {0x0, 0x23, 0x7c, 0xbd, 0x4c, 0x49, 0xd5, 0x6f};
-       char iminus9988776655443311[8] =
-           {0xff, 0xdc, 0x83, 0x42, 0xb3, 0xb6, 0x2a, 0x91};
-       char i9223372036854775807[8] =
-           {0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-       char iminus1[8] =
-           {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-       char iminus9223372036854775808[8] =
-           {0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
-       char u9223372036854775808[8] =
-           {0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
-       char u18446744073709551615[8] =
-           {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-       char u0xaabbccdd00112233[8] =
-           {0xaa, 0xbb, 0xcc, 0xdd, 0x0, 0x11, 0x22, 0x33};
-       char t[8];
-
-       printf("%s (9988776655443311)\n",i64toa(i998877665544331));
-       printf("%s (-9988776655443311)\n",i64toa(iminus9988776655443311));
-       printf("%s (9223372036854775807)\n",i64toa(i9223372036854775807));
-       printf("%s (-1)\n",i64toa(iminus1));
-       printf("%s (-9223372036854775808)\n",i64toa(iminus9223372036854775808));
-
-       printf("%s (9988776655443311)\n",u64toa(i998877665544331));
-       printf("%s (9223372036854775807)\n",u64toa(i9223372036854775807));
-       printf("%s (9223372036854775808)\n",u64toa(u9223372036854775808));
-       printf("%s (18446744073709551615)\n",u64toa(u18446744073709551615));
-
-       printf("%s (0xaabbccdd00112233)\n",u64toh(u0xaabbccdd00112233));
-
-       printf("%s (55443311)\n",i64toa(atoi64("55443311",t)));
-       printf("%s (-55443311)\n",i64toa(atoi64("-55443311",t)));
-       printf("%s (9988776655443311)\n",i64toa(atoi64("9988776655443311",t)));
-       printf("%s (-9988776655443311)\n",i64toa(atoi64("-9988776655443311",t)));
-       printf("%s (9223372036854775807)\n",i64toa(atoi64("9223372036854775807",t)));
-       printf("%s (-1)\n",i64toa(atoi64("-1",t)));
-       printf("%s (-9223372036854775808)\n",i64toa(atoi64("-9223372036854775808",t)));
-
-       printf("%s (55443311)\n",u64toa(atou64("55443311",t)));
-       printf("%s (0x55443311)\n",u64toh(htou64("0x55443311",t)));
-       return 0;
-}
-#endif
diff --git a/epan/int-64bit.h b/epan/int-64bit.h
deleted file mode 100644 (file)
index bd15a37..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* int-64bit.h
- * Handling of 64-bit integers
- *
- * $Id$
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef _INT_64BIT_H_
-#define _INT_64BIT_H_
-
-/*
- * Routines to convert between 64-bit integers, represented as
- * arrays of 8 bytes in network byte order (bit-endian), and ASCII strings
- * giving integer values in decimal or hexadecimal.
- */
-
-/*
- * Convert an unsigned 64-bit integer into a string, in decimal.
- */
-extern char *u64toa(const unsigned char *u64ptr);
-
-/*
- * Convert a signed 64-bit integer into a string, in decimal.
- */
-extern char *i64toa(const unsigned char *i64ptr);
-
-/*
- * Convert a string to an unsigned 64-bit integer.
- */
-unsigned char *atou64(const char *u64str, unsigned char *u64int);
-
-/*
- * Convert a string to a signed 64-bit integer.
- */
-unsigned char *atoi64(const char *i64str, unsigned char *i64int);
-
-/*
- * Convert an unsigned 64-bit integer to a string, in hex.
- */
-char *u64toh(const unsigned char *u64ptr);
-
-/*
- * Convert a hex string to an unsigned 64-bit integer.
- */
-unsigned char *htou64(const char *u64str, unsigned char *u64int);
-
-#endif
-
index 8e1f5e05f3a43a0f7396752d2c57f71948bb5fe1..400cd8d7ebf6866a14478c657103ae55fa190bba 100644 (file)
                      (guint32)*((const guint8 *)(p)+1)<<16|  \
                      (guint32)*((const guint8 *)(p)+2)<<8|   \
                      (guint32)*((const guint8 *)(p)+3)<<0)
+#define pntoh64(p)  ((guint64)*((const guint8 *)(p)+0)<<56|  \
+                     (guint64)*((const guint8 *)(p)+1)<<48|  \
+                     (guint64)*((const guint8 *)(p)+2)<<40|  \
+                     (guint64)*((const guint8 *)(p)+3)<<32|  \
+                     (guint64)*((const guint8 *)(p)+4)<<24|  \
+                     (guint64)*((const guint8 *)(p)+5)<<16|  \
+                     (guint64)*((const guint8 *)(p)+6)<<8|   \
+                     (guint64)*((const guint8 *)(p)+7)<<0)
 
 
 #define pletohs(p)  ((guint16)                       \
                      (guint32)*((const guint8 *)(p)+2)<<16|  \
                      (guint32)*((const guint8 *)(p)+1)<<8|   \
                      (guint32)*((const guint8 *)(p)+0)<<0)
+#define pletoh64(p) ((guint64)*((const guint8 *)(p)+7)<<56|  \
+                     (guint64)*((const guint8 *)(p)+6)<<48|  \
+                     (guint64)*((const guint8 *)(p)+5)<<40|  \
+                     (guint64)*((const guint8 *)(p)+4)<<32|  \
+                     (guint64)*((const guint8 *)(p)+3)<<24|  \
+                     (guint64)*((const guint8 *)(p)+2)<<16|  \
+                     (guint64)*((const guint8 *)(p)+1)<<8|   \
+                     (guint64)*((const guint8 *)(p)+0)<<0)
 
 
 
index a758b924545daf0e24b4763914c5a56d27220e27..402580c3706d5d07481959a2b2218329099cb788 100644 (file)
@@ -42,7 +42,6 @@
 #include "plugins.h"
 #include "ipv6-utils.h"
 #include "proto.h"
-#include "int-64bit.h"
 #include "epan_dissect.h"
 #include "slab.h"
 #include "tvbuff.h"
@@ -55,18 +54,20 @@ proto_tree_free_node(proto_node *node, gpointer data);
 static void fill_label_boolean(field_info *fi, gchar *label_str);
 static void fill_label_uint(field_info *fi, gchar *label_str);
 static void fill_label_uint64(field_info *fi, gchar *label_str);
-static void fill_label_int64(field_info *fi, gchar *label_str);
 static void fill_label_enumerated_uint(field_info *fi, gchar *label_str);
 static void fill_label_enumerated_bitfield(field_info *fi, gchar *label_str);
 static void fill_label_numeric_bitfield(field_info *fi, gchar *label_str);
 static void fill_label_int(field_info *fi, gchar *label_str);
+static void fill_label_int64(field_info *fi, gchar *label_str);
 static void fill_label_enumerated_int(field_info *fi, gchar *label_str);
 
 int hfinfo_bitwidth(header_field_info *hfinfo);
 static char* hfinfo_uint_vals_format(header_field_info *hfinfo);
 static char* hfinfo_uint_format(header_field_info *hfinfo);
+static char* hfinfo_uint64_format(header_field_info *hfinfo);
 static char* hfinfo_int_vals_format(header_field_info *hfinfo);
 static char* hfinfo_int_format(header_field_info *hfinfo);
+static char* hfinfo_int64_format(header_field_info *hfinfo);
 
 static proto_item*
 proto_tree_add_node(proto_tree *tree, field_info *fi);
@@ -85,10 +86,6 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap);
 static void
 proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb);
 static void
-proto_tree_set_uint64(field_info *fi, const guint8 *value_ptr, gboolean little_endian);
-static void
-proto_tree_set_uint64_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian);
-static void
 proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length);
 static void
 proto_tree_set_bytes_tvb(field_info *fi, tvbuff_t *tvb, gint offset, gint length);
@@ -120,6 +117,10 @@ static void
 proto_tree_set_uint(field_info *fi, guint32 value);
 static void
 proto_tree_set_int(field_info *fi, gint32 value);
+static void
+proto_tree_set_uint64(field_info *fi, guint64 value);
+static void
+proto_tree_set_uint64_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian);
 
 static int proto_register_field_init(header_field_info *hfinfo, int parent);
 
@@ -1281,25 +1282,20 @@ proto_tree_set_ipv6_tvb(field_info *fi, tvbuff_t *tvb, gint start)
 }
 
 static void
-proto_tree_set_uint64(field_info *fi, const guint8 *value_ptr, gboolean little_endian)
+proto_tree_set_uint64(field_info *fi, guint64 value)
 {
-       if(little_endian){
-               unsigned char buffer[8];
-               int i;
-
-               for(i=0;i<8;i++){
-                       buffer[i]=value_ptr[7-i];
-               }
-               fvalue_set(&fi->value, (gpointer)buffer, FALSE);
-       } else {
-               fvalue_set(&fi->value, (gpointer)value_ptr, FALSE);
-       }
+       fvalue_set_integer64(&fi->value, value);
 }
 
 static void
 proto_tree_set_uint64_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian)
 {
-       proto_tree_set_uint64(fi, tvb_get_ptr(tvb, start, 8), little_endian);
+       guint64 value;
+
+       value = little_endian ? tvb_get_letoh64(tvb, start)
+                             : tvb_get_ntoh64(tvb, start);
+
+       proto_tree_set_uint64(fi, value);
 }
 
 /* Add a FT_STRING or FT_STRINGZ to a proto_tree. Creates own copy of string,
@@ -1654,7 +1650,7 @@ proto_tree_set_double(field_info *fi, double value)
        fvalue_set_floating(&fi->value, value);
 }
 
-/* Add any FT_UINT* to a proto_tree */
+/* Add FT_UINT{8,16,24,32} to a proto_tree */
 proto_item *
 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
                guint32 value)
@@ -1718,7 +1714,7 @@ proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
        return pi;
 }
 
-/* Set the FT_UINT* value */
+/* Set the FT_UINT{8,16,24,32} value */
 static void
 proto_tree_set_uint(field_info *fi, guint32 value)
 {
@@ -1740,7 +1736,46 @@ proto_tree_set_uint(field_info *fi, guint32 value)
        fvalue_set_integer(&fi->value, integer);
 }
 
-/* Add any FT_INT* to a proto_tree */
+/* Add FT_UINT64 to a proto_tree */
+proto_item *
+proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
+               guint64 value)
+{
+       proto_item              *pi = NULL;
+       field_info              *new_fi;
+       header_field_info       *hfinfo;
+
+       if (!tree)
+               return (NULL);
+
+       PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
+       g_assert(hfinfo->type == FT_UINT64);
+
+       pi = proto_tree_add_pi(tree, hfindex, tvb, start, &length, &new_fi);
+       proto_tree_set_uint64(new_fi, value);
+
+       return pi;
+}
+
+proto_item *
+proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
+               guint64 value, const char *format, ...)
+{
+       proto_item              *pi;
+       va_list                 ap;
+
+       pi = proto_tree_add_uint64(tree, hfindex, tvb, start, length, value);
+       if (pi == NULL)
+               return (NULL);
+
+       va_start(ap, format);
+       proto_tree_set_representation(pi, format, ap);
+       va_end(ap);
+
+       return pi;
+}
+
+/* Add FT_INT{8,16,24,32} to a proto_tree */
 proto_item *
 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
                gint32 value)
@@ -1803,7 +1838,7 @@ proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint sta
        return pi;
 }
 
-/* Set the FT_INT* value */
+/* Set the FT_INT{8,16,24,32} value */
 static void
 proto_tree_set_int(field_info *fi, gint32 value)
 {
@@ -1825,6 +1860,45 @@ proto_tree_set_int(field_info *fi, gint32 value)
        fvalue_set_integer(&fi->value, integer);
 }
 
+/* Add FT_INT64 to a proto_tree */
+proto_item *
+proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
+               gint64 value)
+{
+       proto_item              *pi = NULL;
+       field_info              *new_fi;
+       header_field_info       *hfinfo;
+
+       if (!tree)
+               return (NULL);
+
+       PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
+       g_assert(hfinfo->type == FT_INT64);
+
+       pi = proto_tree_add_pi(tree, hfindex, tvb, start, &length, &new_fi);
+       proto_tree_set_uint64(new_fi, (guint64)value);
+
+       return pi;
+}
+
+proto_item *
+proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
+               gint64 value, const char *format, ...)
+{
+       proto_item              *pi;
+       va_list                 ap;
+
+       pi = proto_tree_add_int64(tree, hfindex, tvb, start, length, value);
+       if (pi == NULL)
+               return (NULL);
+
+       va_start(ap, format);
+       proto_tree_set_representation(pi, format, ap);
+       va_end(ap);
+
+       return pi;
+}
+
 
 /* Add a field_info struct to the proto_tree, encapsulating it in a proto_node */
 static proto_item *
@@ -2825,64 +2899,6 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
        }
 }
 
-static void
-fill_label_uint64(field_info *fi, gchar *label_str)
-{
-       unsigned char *bytes;
-       header_field_info *hfinfo = fi->hfinfo;
-       int                                     ret;    /*tmp return value */
-
-       bytes=fvalue_get(&fi->value);
-       switch(hfinfo->display){
-       case BASE_DEC:
-               ret = snprintf(label_str, ITEM_LABEL_LENGTH,
-                       "%s: %s", hfinfo->name,
-                       u64toa(bytes));
-               if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
-                       label_str[ITEM_LABEL_LENGTH - 1] = '\0';
-               break;
-       case BASE_HEX:
-               ret = snprintf(label_str, ITEM_LABEL_LENGTH,
-                       "%s: %s", hfinfo->name,
-                       u64toh(bytes));
-               if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
-                       label_str[ITEM_LABEL_LENGTH - 1] = '\0';
-               break;
-       default:
-               g_assert_not_reached();
-               ;
-       }
-}
-
-static void
-fill_label_int64(field_info *fi, gchar *label_str)
-{
-       unsigned char *bytes;
-       header_field_info *hfinfo = fi->hfinfo;
-       int                                     ret;    /*tmp return value */
-
-       bytes=fvalue_get(&fi->value);
-       switch(hfinfo->display){
-       case BASE_DEC:
-               ret = snprintf(label_str, ITEM_LABEL_LENGTH,
-                       "%s: %s", hfinfo->name,
-                       i64toa(bytes));
-               if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
-                       label_str[ITEM_LABEL_LENGTH - 1] = '\0';
-               break;
-       case BASE_HEX:
-               ret = snprintf(label_str, ITEM_LABEL_LENGTH,
-                       "%s: %s", hfinfo->name,
-                       u64toh(bytes));
-               if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
-                       label_str[ITEM_LABEL_LENGTH - 1] = '\0';
-               break;
-       default:
-               g_assert_not_reached();
-               ;
-       }
-}
-
 static void
 fill_label_boolean(field_info *fi, gchar *label_str)
 {
@@ -3038,6 +3054,25 @@ fill_label_uint(field_info *fi, gchar *label_str)
                label_str[ITEM_LABEL_LENGTH - 1] = '\0';
 }
 
+static void
+fill_label_uint64(field_info *fi, gchar *label_str)
+{
+       char *format = NULL;
+       header_field_info       *hfinfo = fi->hfinfo;
+       guint64 value;
+       int                                     ret;    /*tmp return value */
+
+       /* Pick the proper format string */
+       format = hfinfo_uint64_format(hfinfo);
+       value = fvalue_get_integer64(&fi->value);
+
+       /* Fill in the textual info */
+       ret = snprintf(label_str, ITEM_LABEL_LENGTH,
+                       format,  hfinfo->name, value);
+       if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
+               label_str[ITEM_LABEL_LENGTH - 1] = '\0';
+}
+
 static void
 fill_label_enumerated_int(field_info *fi, gchar *label_str)
 {
@@ -3077,6 +3112,25 @@ fill_label_int(field_info *fi, gchar *label_str)
                label_str[ITEM_LABEL_LENGTH - 1] = '\0';
 }
 
+static void
+fill_label_int64(field_info *fi, gchar *label_str)
+{
+       char *format = NULL;
+       header_field_info       *hfinfo = fi->hfinfo;
+       guint64 value;
+       int                                     ret;    /*tmp return value */
+
+       /* Pick the proper format string */
+       format = hfinfo_int64_format(hfinfo);
+       value = fvalue_get_integer64(&fi->value);
+
+       /* Fill in the textual info */
+       ret = snprintf(label_str, ITEM_LABEL_LENGTH,
+                       format,  hfinfo->name, value);
+       if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
+               label_str[ITEM_LABEL_LENGTH - 1] = '\0';
+}
+
 int
 hfinfo_bitwidth(header_field_info *hfinfo)
 {
@@ -3235,6 +3289,29 @@ hfinfo_int_vals_format(header_field_info *hfinfo)
        return format;
 }
 
+static char*
+hfinfo_uint64_format(header_field_info *hfinfo)
+{
+       char *format = NULL;
+
+       /* Pick the proper format string */
+       switch(hfinfo->display) {
+               case BASE_DEC:
+                       format = "%s: %" PRIu64;
+                       break;
+               case BASE_OCT: /* I'm lazy */
+                       format = "%s: %" PRIo64;
+                       break;
+               case BASE_HEX:
+                       format = "%s: 0x%016" PRIx64;
+                       break;
+               default:
+                       g_assert_not_reached();
+                       ;
+       }
+       return format;
+}
+
 static char*
 hfinfo_int_format(header_field_info *hfinfo)
 {
@@ -3274,6 +3351,29 @@ hfinfo_int_format(header_field_info *hfinfo)
        return format;
 }
 
+static char*
+hfinfo_int64_format(header_field_info *hfinfo)
+{
+       char *format = NULL;
+
+       /* Pick the proper format string */
+       switch(hfinfo->display) {
+               case BASE_DEC:
+                       format = "%s: %" PRId64;
+                       break;
+               case BASE_OCT: /* I'm lazy */
+                       format = "%s: %" PRIo64;
+                       break;
+               case BASE_HEX:
+                       format = "%s: 0x%016" PRIx64;
+                       break;
+               default:
+                       g_assert_not_reached();
+                       ;
+       }
+       return format;
+}
+
 
 
 int
@@ -3589,12 +3689,18 @@ hfinfo_numeric_format(header_field_info *hfinfo)
                                        case FT_UINT32:
                                                format = "%s == %u";
                                                break;
+                                       case FT_UINT64:
+                                               format = "%s == %" PRIu64;
+                                               break;
                                        case FT_INT8:
                                        case FT_INT16:
                                        case FT_INT24:
                                        case FT_INT32:
                                                format = "%s == %d";
                                                break;
+                                       case FT_INT64:
+                                               format = "%s == %" PRId64;
+                                               break;
                                        default:
                                                g_assert_not_reached();
                                                ;
@@ -3614,6 +3720,9 @@ hfinfo_numeric_format(header_field_info *hfinfo)
                                        case FT_UINT32:
                                                format = "%s == 0x%08x";
                                                break;
+                                       case FT_UINT64:
+                                               format = "%s == 0x%016" PRIx64;
+                                               break;
                                        default:
                                                g_assert_not_reached();
                                                ;
@@ -3789,30 +3898,28 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt)
                        snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer(&finfo->value));
                        break;
 
-               case FT_UINT64:
-                       /*
-                        * 4 bytes for " == ".
-                        * N bytes for the string for the number.
-                        * 1 byte for the trailing '\0'.
-                        */
-                       stringified = u64toa(fvalue_get(&finfo->value));
-                       dfilter_len = abbrev_len + 4 + strlen(stringified) +1;
-                       buf = g_malloc0(dfilter_len);
-                       snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev,
-                                       stringified);
-                       break;
-
                case FT_INT64:
+               case FT_UINT64:
                        /*
                         * 4 bytes for " == ".
-                        * N bytes for the string for the number.
+                        * 22 bytes for:
+                        *
+                        *      a sign + up to 20 digits of 32-bit integer,
+                        *      in decimal;
+                        *
+                        *      "0x" + 16 digits of 32-bit integer, in hex;
+                        *
+                        *      22 digits of 32-bit integer, in octal.
+                        *      (No, we don't do octal, but this way,
+                        *      we know that if we do, this will still
+                        *      work.)
+                        *
                         * 1 byte for the trailing '\0'.
                         */
-                       stringified = i64toa(fvalue_get(&finfo->value));
-                       dfilter_len = abbrev_len + 4 + strlen(stringified) +1;
+                       dfilter_len = abbrev_len + 4 + 22 + 1;
                        buf = g_malloc0(dfilter_len);
-                       snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev,
-                                       stringified);
+                       format = hfinfo_numeric_format(hfinfo);
+                       snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer64(&finfo->value));
                        break;
 
                case FT_IPXNET:
index 253928446ce1b643ef8bda1b218294406ea65b9c..c5ba30cf33e4f40127ad6d61fff8c94fbe941d45 100644 (file)
@@ -747,6 +747,32 @@ extern proto_item *
 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
 
+/** Add an FT_UINT64 to a proto_tree.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, guint64 value);
+
+/** Add a formatted FT_UINT64 to a proto_tree.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, guint64 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
+
 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
  @param tree the tree to append this item to
  @param hfindex field index
@@ -779,6 +805,32 @@ extern proto_item *
 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
        gint length, gint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
 
+/** Add an FT_INT64 to a proto_tree.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, gint64 value);
+
+/** Add a formatted FT_INT64 to a proto_tree.
+ @param tree the tree to append this item to
+ @param hfindex field index
+ @param tvb the tv buffer of the current data
+ @param start start of data in tvb
+ @param length length of data in tvb
+ @param value data to display
+ @param format printf like format string
+ @param ... printf like parameters
+ @return the newly created item */
+extern proto_item *
+proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
+       gint length, gint64 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
+
 /** Useful for quick debugging. Also sends string to STDOUT, so don't
  * leave call to this function in production code.
  @param tree the tree to append the text to
index 575114fdbc361fa21fb13468f7320757c5acaeaf..eee139ff5493328cc25e2a51996949d3b56c89b1 100644 (file)
@@ -1052,6 +1052,15 @@ tvb_get_ntohl(tvbuff_t *tvb, gint offset)
        return pntohl(ptr);
 }
 
+guint64
+tvb_get_ntoh64(tvbuff_t *tvb, gint offset)
+{
+       const guint8* ptr;
+
+       ptr = ensure_contiguous(tvb, offset, sizeof(guint64));
+       return pntoh64(ptr);
+}
+
 /*
  * Stuff for IEEE float handling on platforms that don't have IEEE
  * format as the native floating-point format.
@@ -1282,6 +1291,15 @@ tvb_get_letohl(tvbuff_t *tvb, gint offset)
        return pletohl(ptr);
 }
 
+guint64
+tvb_get_letoh64(tvbuff_t *tvb, gint offset)
+{
+       const guint8* ptr;
+
+       ptr = ensure_contiguous(tvb, offset, sizeof(guint64));
+       return pletoh64(ptr);
+}
+
 /*
  * Fetches an IEEE single-precision floating-point number, in
  * little-endian form, and returns a "float".
index d286ae64f0ba73551b4ee9cad3cc26a2053dd405..afcfad18cfe7e47981ec97e5f073fc65e546c417 100644 (file)
@@ -298,12 +298,14 @@ extern guint8  tvb_get_guint8(tvbuff_t*, gint offset);
 extern guint16 tvb_get_ntohs(tvbuff_t*, gint offset);
 extern guint32 tvb_get_ntoh24(tvbuff_t*, gint offset);
 extern guint32 tvb_get_ntohl(tvbuff_t*, gint offset);
+extern guint64 tvb_get_ntoh64(tvbuff_t*, gint offset);
 extern gfloat tvb_get_ntohieee_float(tvbuff_t*, gint offset);
 extern gdouble tvb_get_ntohieee_double(tvbuff_t*, gint offset);
 
 extern guint16 tvb_get_letohs(tvbuff_t*, gint offset);
 extern guint32 tvb_get_letoh24(tvbuff_t*, gint offset);
 extern guint32 tvb_get_letohl(tvbuff_t*, gint offset);
+extern guint64 tvb_get_letoh64(tvbuff_t*, gint offset);
 extern gfloat tvb_get_letohieee_float(tvbuff_t*, gint offset);
 extern gdouble tvb_get_letohieee_double(tvbuff_t*, gint offset);