Michael Tuexen's changes to define a port type for SCTP ports, handle

SCTP ports in "col_set_port()", and add a "get_sctp_port()" routine to
resolve SCTP port numbers to services.

Also, make the "get_XXX_port()" routines format the port number as an
unsigned integer, rather than a signed integer, if the service name for
the port isn't found (the port number passed in is unsigned).

svn path=/trunk/; revision=2295
This commit is contained in:
Guy Harris 2000-08-19 08:26:04 +00:00
parent e2eb846d0f
commit b0e0ec1763
4 changed files with 50 additions and 13 deletions

View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.99 2000/08/12 00:15:38 guy Exp $
* $Id: packet.c,v 1.100 2000/08/19 08:26:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -937,6 +937,13 @@ col_set_port(frame_data *fd, int col, port_type ptype, guint32 port,
{
switch (ptype) {
case PT_SCTP:
if (is_res)
strncpy(fd->cinfo->col_data[col], get_sctp_port(port), COL_MAX_LEN);
else
snprintf(fd->cinfo->col_data[col], COL_MAX_LEN, "%u", port);
break;
case PT_TCP:
if (is_res)
strncpy(fd->cinfo->col_data[col], get_tcp_port(port), COL_MAX_LEN);

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.194 2000/08/12 00:15:40 guy Exp $
* $Id: packet.h,v 1.195 2000/08/19 08:26:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -189,6 +189,7 @@ typedef struct _address {
/* Types of port numbers Ethereal knows about. */
typedef enum {
PT_NONE, /* no port number */
PT_SCTP, /* SCTP */
PT_TCP, /* TCP */
PT_UDP, /* UDP */
PT_NCP /* NCP connection */

View File

@ -1,7 +1,7 @@
/* resolv.c
* Routines for network object lookup
*
* $Id: resolv.c,v 1.27 2000/08/10 22:35:30 deniel Exp $
* $Id: resolv.c,v 1.28 2000/08/19 08:26:03 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -138,6 +138,7 @@ typedef struct _ipxnet
static hashname_t *host_table[HASHHOSTSIZE];
static hashname_t *udp_port_table[HASHPORTSIZE];
static hashname_t *tcp_port_table[HASHPORTSIZE];
static hashname_t *sctp_port_table[HASHPORTSIZE];
static hashether_t *eth_table[HASHETHSIZE];
static hashmanuf_t *manuf_table[HASHMANUFSIZE];
static hashipxnet_t *ipxnet_table[HASHIPXNETSIZE];
@ -162,7 +163,7 @@ gchar *g_manuf_path = EPATH_MANUF; /* may only be changed before the */
* Local function definitions
*/
static u_char *serv_name_lookup(u_int port, u_int proto)
static u_char *serv_name_lookup(u_int port, port_type proto)
{
hashname_t *tp;
@ -172,14 +173,18 @@ static u_char *serv_name_lookup(u_int port, u_int proto)
int i;
switch(proto) {
case IPPROTO_UDP:
case PT_UDP:
table = udp_port_table;
serv_proto = "udp";
break;
case IPPROTO_TCP:
case PT_TCP:
table = tcp_port_table;
serv_proto = "tcp";
break;
case PT_SCTP:
table = sctp_port_table;
serv_proto = "sctp";
break;
default:
/* not yet implemented */
return NULL;
@ -1099,11 +1104,11 @@ extern u_char *get_udp_port(u_int port)
} else {
cur = &str[0][0];
}
sprintf(cur, "%d", port);
sprintf(cur, "%u", port);
return cur;
}
return serv_name_lookup(port, IPPROTO_UDP);
return serv_name_lookup(port, PT_UDP);
} /* get_udp_port */
@ -1120,14 +1125,35 @@ extern u_char *get_tcp_port(u_int port)
} else {
cur = &str[0][0];
}
sprintf(cur, "%d", port);
sprintf(cur, "%u", port);
return cur;
}
return serv_name_lookup(port, IPPROTO_TCP);
return serv_name_lookup(port, PT_TCP);
} /* get_tcp_port */
extern u_char *get_sctp_port(u_int port)
{
static gchar str[3][MAXNAMELEN];
static gchar *cur;
if (!g_resolving_actif) {
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, "%u", port);
return cur;
}
return serv_name_lookup(port, PT_SCTP);
} /* get_sctp_port */
extern u_char *get_ether_name(const u_char *addr)
{
if (!g_resolving_actif)

View File

@ -1,7 +1,7 @@
/* resolv.h
* Definitions for network object lookup
*
* $Id: resolv.h,v 1.12 2000/08/10 20:09:29 deniel Exp $
* $Id: resolv.h,v 1.13 2000/08/19 08:26:04 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -52,12 +52,15 @@ extern gchar *g_pipxnets_path;
/* Functions in resolv.c */
/* get_tcp_port returns the UDP port name or "%d" if not found */
/* get_tcp_port returns the UDP port name or "%u" if not found */
extern u_char *get_udp_port(u_int port);
/* get_tcp_port returns the TCP port name or "%d" if not found */
/* get_tcp_port returns the TCP port name or "%u" if not found */
extern u_char *get_tcp_port(u_int port);
/* get_sctp_port returns the SCTP port name or "%u" if not found */
extern u_char *get_sctp_port(u_int port);
/* get_hostname returns the host name or "%d.%d.%d.%d" if not found */
extern u_char *get_hostname(u_int addr);