diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-06-04 07:27:50 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-06-04 07:27:50 +0000 |
commit | 671992baabddd865f029490db62a273b03683cba (patch) | |
tree | 18619cd551aa4e1fe5a1b2b9a1d9b5f3c6b59a54 /epan/packet_info.h | |
parent | a5a36589f81c5533db7e595809aa7f9e30069940 (diff) |
Define a "COPY_ADDRESS()" macro, which copies the data in one address to
another (copying the data to a mallocated array) in
"epan/packet_info.h", and use it in the conversation code.
svn path=/trunk/; revision=3510
Diffstat (limited to 'epan/packet_info.h')
-rw-r--r-- | epan/packet_info.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/epan/packet_info.h b/epan/packet_info.h index f1f16df136..be1d1d9622 100644 --- a/epan/packet_info.h +++ b/epan/packet_info.h @@ -1,7 +1,7 @@ /* packet_info.h * Definitions for packet info structures and routines * - * $Id: packet_info.h,v 1.3 2001/06/04 06:46:07 guy Exp $ + * $Id: packet_info.h,v 1.4 2001/06/04 07:27:50 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -54,11 +54,26 @@ typedef struct _address { (addr)->data = (addr_data); \ } +/* + * Given two addresses, return "true" if they're equal, "false" otherwise. + */ #define ADDRESSES_EQUAL(addr1, addr2) \ ((addr1)->type == (addr2)->type && \ (addr1)->len == (addr2)->len && \ memcmp((addr1)->data, (addr2)->data, (addr1)->len) == 0) +/* + * Copy an address, allocating a new buffer for the address data. + */ +#define COPY_ADDRESS(to, from) { \ + guint8 *COPY_ADDRESS_data; \ + (to)->type = (from)->type; \ + (to)->len = (from)->len; \ + COPY_ADDRESS_data = g_malloc((from)->len); \ + memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ + (to)->data = COPY_ADDRESS_data; \ + } + /* Types of port numbers Ethereal knows about. */ typedef enum { PT_NONE, /* no port number */ |