From 456095c89dd5fe257ce86d5529179295ebf9151e Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Thu, 8 Jan 2015 11:54:36 -0500 Subject: [PATCH] disperse atalk-utils.[ch] The functionality was suiting for address_to_str.c and the #defines belong in packet-atalk.h. Kept the address structure with the "address string conversion", but that can probably be better cleaned up when the address to str as a whole is cleaned up. Would also consider making AT_ATALK an FT_ type as well. Change-Id: Ia534096c707e6fb94acdfee0d332beda6571c371 Reviewed-on: https://code.wireshark.org/review/6417 Petri-Dish: Hadriel Kaplan Reviewed-by: Anders Broman --- epan/CMakeLists.txt | 1 - epan/Makefile.common | 2 -- epan/address_to_str.c | 17 +++++++++- epan/atalk-utils.c | 53 ----------------------------- epan/atalk-utils.h | 61 ---------------------------------- epan/column-utils.c | 1 - epan/dissectors/packet-atalk.c | 2 +- epan/dissectors/packet-atalk.h | 12 +++++++ epan/dissectors/packet-eigrp.c | 2 +- epan/packet.c | 1 - epan/to_str.h | 15 +++++++++ 11 files changed, 45 insertions(+), 122 deletions(-) delete mode 100644 epan/atalk-utils.c delete mode 100644 epan/atalk-utils.h diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index 53557e98a0..cb78652da3 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -1549,7 +1549,6 @@ set(LIBWIRESHARK_FILES aftypes.c app_mem_usage.c asn1.c - atalk-utils.c charsets.c circuit.c column.c diff --git a/epan/Makefile.common b/epan/Makefile.common index 575a2884d4..4ba1be91d8 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -29,7 +29,6 @@ LIBWIRESHARK_SRC = \ aftypes.c \ app_mem_usage.c \ asn1.c \ - atalk-utils.c \ charsets.c \ circuit.c \ color_dissector_filters.c \ @@ -157,7 +156,6 @@ LIBWIRESHARK_INCLUDES = \ arcnet_pids.h \ arptypes.h \ asn1.h \ - atalk-utils.h \ ax25_pids.h \ bridged_pids.h \ charsets.h \ diff --git a/epan/address_to_str.c b/epan/address_to_str.c index 6d8f26d203..78475398a7 100644 --- a/epan/address_to_str.c +++ b/epan/address_to_str.c @@ -55,7 +55,6 @@ #include "addr_resolv.h" #include "wsutil/pint.h" #include "wsutil/str_util.h" -#include "atalk-utils.h" #include "sna-utils.h" #include "osi-utils.h" #include @@ -359,6 +358,22 @@ fcwwn_addr_to_str_buf(const guint8 *addrp, gchar *buf, int buf_len) } } +static void +atalk_addr_to_str_buf(const struct atalk_ddp_addr *addrp, gchar *buf, int buf_len) +{ + g_snprintf(buf, buf_len, "%u.%u", addrp->net, addrp->node ); +} + +gchar * +atalk_addr_to_str(const struct atalk_ddp_addr *addrp) +{ + gchar *cur; + + cur=(gchar *)wmem_alloc(wmem_packet_scope(), 14); + atalk_addr_to_str_buf(addrp, cur, 14); + return cur; +} + gchar* tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, const gint offset) { diff --git a/epan/atalk-utils.c b/epan/atalk-utils.c deleted file mode 100644 index 78736a62f7..0000000000 --- a/epan/atalk-utils.c +++ /dev/null @@ -1,53 +0,0 @@ -/* atalk-utils.c - * Routines for Appletalk utilities (DDP, currently). - * - * Simon Wilkinson - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include "atalk-utils.h" -#include "emem.h" - -gchar * -atalk_addr_to_str(const struct atalk_ddp_addr *addrp) -{ - gchar *cur; - - cur=(gchar *)ep_alloc(14); - atalk_addr_to_str_buf(addrp, cur, 14); - return cur; -} - -void -atalk_addr_to_str_buf(const struct atalk_ddp_addr *addrp, gchar *buf, int buf_len) -{ - g_snprintf(buf, buf_len, "%u.%u", addrp->net, addrp->node ); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/epan/atalk-utils.h b/epan/atalk-utils.h deleted file mode 100644 index 506fbeeef7..0000000000 --- a/epan/atalk-utils.h +++ /dev/null @@ -1,61 +0,0 @@ -/* atalk-utils.h - * Definitions for Appletalk utilities (DDP, currently). - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __ATALK_UTILS_H__ -#define __ATALK_UTILS_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Structure used to represent a DDP address; gives the layout of the - * data pointed to by an AT_ATALK "address" structure. - */ -struct atalk_ddp_addr { - guint16 net; - guint8 node; -}; - -/* - * DDP packet types. - */ -#define DDP_RTMPDATA 0x01 -#define DDP_NBP 0x02 -#define DDP_ATP 0x03 -#define DDP_AEP 0x04 -#define DDP_RTMPREQ 0x05 -#define DDP_ZIP 0x06 -#define DDP_ADSP 0x07 -#define DDP_EIGRP 0x58 - -/* - * Routines to take a DDP address and generate a string. - */ -extern gchar *atalk_addr_to_str(const struct atalk_ddp_addr *addrp); -extern void atalk_addr_to_str_buf(const struct atalk_ddp_addr *addrp, - gchar *buf, int buf_len); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/epan/column-utils.c b/epan/column-utils.c index 8d088e0098..0da288d121 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -28,7 +28,6 @@ #include "column-utils.h" #include "timestamp.h" #include "sna-utils.h" -#include "atalk-utils.h" #include "to_str.h" #include "packet_info.h" #include "wsutil/pint.h" diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c index 18234dd378..7b873cdad1 100644 --- a/epan/dissectors/packet-atalk.c +++ b/epan/dissectors/packet-atalk.c @@ -31,10 +31,10 @@ #include #include #include -#include #include #include #include +#include #include #include "packet-atalk.h" #include "packet-afp.h" diff --git a/epan/dissectors/packet-atalk.h b/epan/dissectors/packet-atalk.h index 9b564556c1..979b068990 100644 --- a/epan/dissectors/packet-atalk.h +++ b/epan/dissectors/packet-atalk.h @@ -21,6 +21,18 @@ #include "ws_symbol_export.h" +/* + * DDP packet types. + */ +#define DDP_RTMPDATA 0x01 +#define DDP_NBP 0x02 +#define DDP_ATP 0x03 +#define DDP_AEP 0x04 +#define DDP_RTMPREQ 0x05 +#define DDP_ZIP 0x06 +#define DDP_ADSP 0x07 +#define DDP_EIGRP 0x58 + WS_DLL_PUBLIC void capture_llap(packet_counts *ld); #endif diff --git a/epan/dissectors/packet-eigrp.c b/epan/dissectors/packet-eigrp.c index abe2e3c19e..02ba92bf3e 100644 --- a/epan/dissectors/packet-eigrp.c +++ b/epan/dissectors/packet-eigrp.c @@ -28,12 +28,12 @@ #include #include -#include #include #include #include #include "packet-ipx.h" +#include "packet-atalk.h" /** * EIGRP Header size in bytes diff --git a/epan/packet.c b/epan/packet.c index 7f50b3c2f6..b189c229f4 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -37,7 +37,6 @@ #include "packet.h" #include "timestamp.h" -#include "atalk-utils.h" #include "sna-utils.h" #include "osi-utils.h" #include "to_str.h" diff --git a/epan/to_str.h b/epan/to_str.h index 3e1edeb0bc..abbd771df0 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -68,6 +68,7 @@ void ip6_to_str_buf(const struct e_in6_addr *, gchar *); extern gchar* ipx_addr_to_str(const guint32, const guint8 *); extern gchar* ipxnet_to_str_punct(const guint32 ad, const char punct); WS_DLL_PUBLIC gchar* eui64_to_str(const guint64 ad); + WS_DLL_PUBLIC gchar* time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val); gchar* time_secs_to_str_unsigned(wmem_allocator_t *scope, const guint32); WS_DLL_PUBLIC gchar* time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val); @@ -94,6 +95,20 @@ WS_DLL_PUBLIC char *decode_bitfield_value(char *buf, const guint64 val, const gu WS_DLL_PUBLIC const gchar* port_type_to_str (port_type type); +/* + * Routines to take a DDP address and generate a string. + */ +/* + * Structure used to represent a DDP address; gives the layout of the + * data pointed to by an AT_ATALK "address" structure. + */ +struct atalk_ddp_addr { + guint16 net; + guint8 node; +}; + +extern gchar *atalk_addr_to_str(const struct atalk_ddp_addr *addrp); + /** Turn an address type retrieved from a tvb into a string. * * @param scope memory allocation scheme used