diff options
-rw-r--r-- | packet-ipx.c | 52 | ||||
-rw-r--r-- | packet-ipx.h | 4 | ||||
-rw-r--r-- | resolv.c | 8 |
3 files changed, 46 insertions, 18 deletions
diff --git a/packet-ipx.c b/packet-ipx.c index 70065cc734..28a2fb5539 100644 --- a/packet-ipx.c +++ b/packet-ipx.c @@ -2,7 +2,7 @@ * Routines for NetWare's IPX * Gilbert Ramirez <gram@verdict.uthscsa.edu> * - * $Id: packet-ipx.c,v 1.35 1999/11/21 16:32:14 gram Exp $ + * $Id: packet-ipx.c,v 1.36 1999/11/22 06:03:45 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@unicom.net> @@ -230,19 +230,8 @@ static const value_string ipx_packet_type_vals[] = { gchar* ipxnet_to_string(const guint8 *ad) { - static gchar str[3][8+3+1]; /* 8 digits, 3 spaces, 1 null */ - static gchar *cur; - - if (cur == &str[0][0]) { - cur = &str[1][0]; - } else if (cur == &str[1][0]) { - cur = &str[2][0]; - } else { - cur = &str[0][0]; - } - - sprintf(cur, "%02X %02X %02X %02X", ad[0], ad[1], ad[2], ad[3]); - return cur; + guint32 addr = pntohl(ad); + return ipxnet_to_str_punct(addr, ' '); } /* We use a different representation of hardware addresses @@ -276,6 +265,41 @@ ipx_addr_to_str(guint32 net, const guint8 *ad) return cur; } +gchar * +ipxnet_to_str_punct(const guint32 ad, char punct) { + static gchar str[3][12]; + static gchar *cur; + gchar *p; + int i; + guint32 octet; + static const gchar hex_digits[16] = "0123456789ABCDEF"; + static const guint32 octet_mask[4] = + { 0xff000000 , 0x00ff0000, 0x0000ff00, 0x000000ff }; + + if (cur == &str[0][0]) { + cur = &str[1][0]; + } else if (cur == &str[1][0]) { + cur = &str[2][0]; + } else { + cur = &str[0][0]; + } + p = &cur[12]; + *--p = '\0'; + i = 3; + for (;;) { + octet = (ad & octet_mask[i]) >> ((3 - i) * 8); + *--p = hex_digits[octet&0xF]; + octet >>= 4; + *--p = hex_digits[octet&0xF]; + if (i == 0) + break; + if (punct) + *--p = punct; + i--; + } + return p; +} + void dissect_ipx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { diff --git a/packet-ipx.h b/packet-ipx.h index ce5f20f9e9..4f58ca94da 100644 --- a/packet-ipx.h +++ b/packet-ipx.h @@ -2,7 +2,7 @@ * Routines for NetWare's IPX * Gilbert Ramirez <gram@verdict.uthscsa.edu> * - * $Id: packet-ipx.h,v 1.2 1998/10/14 05:18:31 gram Exp $ + * $Id: packet-ipx.h,v 1.3 1999/11/22 06:03:46 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@unicom.net> @@ -93,3 +93,5 @@ struct ipx_rip_packet gchar* ipxnet_to_string(const guint8 *ad); +gchar * +ipxnet_to_str_punct(const guint32 ad, char punct); @@ -1,7 +1,7 @@ /* resolv.c * Routines for network object lookup * - * $Id: resolv.c,v 1.20 1999/11/21 16:32:16 gram Exp $ + * $Id: resolv.c,v 1.21 1999/11/22 06:03:46 gram Exp $ * * Laurent Deniel <deniel@worldnet.fr> * @@ -1181,8 +1181,10 @@ extern u_char *get_ether_addr(u_char *name) extern u_char *get_ipxnet_name(const guint32 addr) { - if (!g_resolving_actif) - return ipxnet_to_string((guint8 *)&addr); + + if (!g_resolving_actif) { + return ipxnet_to_str_punct(addr, '\0'); + } if (!ipxnet_resolution_initialized) { initialize_ipxnets(); |