1998-09-16 02:39:15 +00:00
|
|
|
/* packet.c
|
|
|
|
* Routines for packet disassembly
|
|
|
|
*
|
2001-01-13 06:34:35 +00:00
|
|
|
* $Id: packet.c,v 1.18 2001/01/13 06:34:33 guy Exp $
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* 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
|
|
|
|
|
1998-10-10 03:32:20 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
1999-07-13 02:53:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
1999-03-28 18:32:03 +00:00
|
|
|
#include <sys/socket.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_WINSOCK_H
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
1998-10-10 03:32:20 +00:00
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <glib.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2000-03-26 07:59:47 +00:00
|
|
|
#include <stdlib.h>
|
2000-08-11 13:37:21 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_STDARG_H
|
1998-09-16 02:39:15 +00:00
|
|
|
#include <stdarg.h>
|
2000-08-11 13:37:21 +00:00
|
|
|
#endif
|
|
|
|
|
1998-11-18 03:01:44 +00:00
|
|
|
#include <string.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
#include <ctype.h>
|
1998-10-12 01:40:57 +00:00
|
|
|
#include <time.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1998-10-10 03:32:20 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
|
2000-01-10 17:33:17 +00:00
|
|
|
#ifdef HAVE_ARPA_INET_H
|
1999-10-14 07:39:44 +00:00
|
|
|
#include <arpa/inet.h>
|
2000-01-10 17:33:17 +00:00
|
|
|
#endif
|
1999-10-14 07:39:44 +00:00
|
|
|
|
1999-10-14 06:55:11 +00:00
|
|
|
#ifdef NEED_INET_V6DEFS_H
|
|
|
|
# include "inet_v6defs.h"
|
|
|
|
#endif
|
|
|
|
|
1998-09-27 22:12:47 +00:00
|
|
|
#include "packet.h"
|
1999-09-29 22:19:24 +00:00
|
|
|
#include "print.h"
|
1999-12-29 07:25:48 +00:00
|
|
|
#include "timestamp.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "file.h"
|
|
|
|
|
1999-12-29 07:25:48 +00:00
|
|
|
#include "packet-atalk.h"
|
2000-10-06 10:11:40 +00:00
|
|
|
#include "packet-frame.h"
|
1999-12-29 07:25:48 +00:00
|
|
|
#include "packet-ipv6.h"
|
|
|
|
#include "packet-sna.h"
|
|
|
|
#include "packet-vines.h"
|
|
|
|
|
|
|
|
#include "resolv.h"
|
2000-05-11 08:18:09 +00:00
|
|
|
#include "tvbuff.h"
|
2000-04-04 16:33:57 +00:00
|
|
|
#include "plugins.h"
|
|
|
|
|
2000-09-10 06:44:39 +00:00
|
|
|
static void display_signed_time(gchar *, int, gint32, gint32);
|
|
|
|
|
2000-09-21 04:41:37 +00:00
|
|
|
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
/* Protocol-specific data attached to a frame_data structure - protocol
|
2000-08-12 00:15:40 +00:00
|
|
|
index and opaque pointer. */
|
|
|
|
typedef struct _frame_proto_data {
|
|
|
|
int proto;
|
|
|
|
void *proto_data;
|
|
|
|
} frame_proto_data;
|
|
|
|
|
2000-12-03 22:32:10 +00:00
|
|
|
static GMemChunk *frame_proto_data_area = NULL;
|
2000-04-16 04:56:40 +00:00
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2000-04-16 04:56:40 +00:00
|
|
|
/*
|
|
|
|
* Free up any space allocated for frame proto data areas and then
|
|
|
|
* allocate a new area.
|
|
|
|
*
|
|
|
|
* We can free the area, as the structures it contains are pointed to by
|
|
|
|
* frames, that will be freed as well.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
packet_init_protocol(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (frame_proto_data_area)
|
|
|
|
g_mem_chunk_destroy(frame_proto_data_area);
|
|
|
|
|
|
|
|
frame_proto_data_area = g_mem_chunk_new("frame_proto_data_area",
|
|
|
|
sizeof(frame_proto_data),
|
|
|
|
20 * sizeof(frame_proto_data), /* FIXME*/
|
|
|
|
G_ALLOC_ONLY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
packet_init(void)
|
|
|
|
{
|
|
|
|
register_init_routine(&packet_init_protocol);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
packet_cleanup(void)
|
|
|
|
{
|
|
|
|
/* nothing */
|
|
|
|
}
|
|
|
|
|
1999-11-20 05:35:15 +00:00
|
|
|
/* Wrapper for the most common case of asking
|
|
|
|
* for a string using a colon as the hex-digit separator.
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
ether_to_str(const guint8 *ad)
|
|
|
|
{
|
|
|
|
return ether_to_str_punct(ad, ':');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Places char punct in the string as the hex-digit separator.
|
|
|
|
* If punct is '\0', no punctuation is applied (and thus
|
|
|
|
* the resulting string is 5 bytes shorter)
|
|
|
|
*/
|
1998-09-16 02:39:15 +00:00
|
|
|
gchar *
|
1999-11-20 05:35:15 +00:00
|
|
|
ether_to_str_punct(const guint8 *ad, char punct) {
|
1998-09-16 02:39:15 +00:00
|
|
|
static gchar str[3][18];
|
|
|
|
static gchar *cur;
|
1999-08-14 04:23:22 +00:00
|
|
|
gchar *p;
|
|
|
|
int i;
|
|
|
|
guint32 octet;
|
|
|
|
static const gchar hex_digits[16] = "0123456789abcdef";
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
1999-08-14 04:23:22 +00:00
|
|
|
p = &cur[18];
|
|
|
|
*--p = '\0';
|
|
|
|
i = 5;
|
|
|
|
for (;;) {
|
|
|
|
octet = ad[i];
|
|
|
|
*--p = hex_digits[octet&0xF];
|
|
|
|
octet >>= 4;
|
|
|
|
*--p = hex_digits[octet&0xF];
|
|
|
|
if (i == 0)
|
|
|
|
break;
|
1999-11-20 05:35:15 +00:00
|
|
|
if (punct)
|
|
|
|
*--p = punct;
|
1999-08-14 04:23:22 +00:00
|
|
|
i--;
|
|
|
|
}
|
|
|
|
return p;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
1999-01-05 07:33:38 +00:00
|
|
|
ip_to_str(const guint8 *ad) {
|
1998-09-16 02:39:15 +00:00
|
|
|
static gchar str[3][16];
|
|
|
|
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];
|
|
|
|
}
|
2001-01-09 09:57:06 +00:00
|
|
|
ip_to_str_buf(ad, cur);
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ip_to_str_buf(const guint8 *ad, gchar *buf)
|
|
|
|
{
|
|
|
|
gchar *p;
|
|
|
|
int i;
|
|
|
|
guint32 octet;
|
|
|
|
guint32 digit;
|
|
|
|
gboolean saw_nonzero;
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
i = 0;
|
1999-08-14 04:23:22 +00:00
|
|
|
for (;;) {
|
2001-01-09 09:57:06 +00:00
|
|
|
saw_nonzero = FALSE;
|
1999-08-14 04:23:22 +00:00
|
|
|
octet = ad[i];
|
2001-01-09 09:57:06 +00:00
|
|
|
digit = octet/100;
|
|
|
|
if (digit != 0) {
|
|
|
|
*p++ = digit + '0';
|
|
|
|
saw_nonzero = TRUE;
|
|
|
|
}
|
|
|
|
octet %= 100;
|
|
|
|
digit = octet/10;
|
|
|
|
if (saw_nonzero || digit != 0)
|
|
|
|
*p++ = digit + '0';
|
1999-08-14 04:23:22 +00:00
|
|
|
digit = octet%10;
|
2001-01-09 09:57:06 +00:00
|
|
|
*p++ = digit + '0';
|
|
|
|
if (i == 3)
|
1999-08-14 04:23:22 +00:00
|
|
|
break;
|
2001-01-09 09:57:06 +00:00
|
|
|
*p++ = '.';
|
|
|
|
i++;
|
1999-08-14 04:23:22 +00:00
|
|
|
}
|
2001-01-09 09:57:06 +00:00
|
|
|
*p = '\0';
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
1999-10-14 05:41:33 +00:00
|
|
|
gchar *
|
|
|
|
ip6_to_str(struct e_in6_addr *ad) {
|
|
|
|
#ifndef INET6_ADDRSTRLEN
|
|
|
|
#define INET6_ADDRSTRLEN 46
|
|
|
|
#endif
|
|
|
|
static gchar buf[INET6_ADDRSTRLEN];
|
|
|
|
|
|
|
|
inet_ntop(AF_INET6, (u_char*)ad, (gchar*)buf, sizeof(buf));
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-28 21:29:36 +00:00
|
|
|
#define PLURALIZE(n) (((n) > 1) ? "s" : "")
|
|
|
|
#define COMMA(do_it) ((do_it) ? ", " : "")
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
time_secs_to_str(guint32 time)
|
|
|
|
{
|
|
|
|
static gchar str[3][8+1+4+2+2+5+2+2+7+2+2+7+1];
|
|
|
|
static gchar *cur, *p;
|
|
|
|
int hours, mins, secs;
|
|
|
|
int do_comma;
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
1999-12-12 05:11:57 +00:00
|
|
|
if (time == 0) {
|
|
|
|
sprintf(cur, "0 time");
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
1999-01-28 21:29:36 +00:00
|
|
|
secs = time % 60;
|
|
|
|
time /= 60;
|
|
|
|
mins = time % 60;
|
|
|
|
time /= 60;
|
|
|
|
hours = time % 24;
|
|
|
|
time /= 24;
|
|
|
|
|
|
|
|
p = cur;
|
|
|
|
if (time != 0) {
|
|
|
|
sprintf(p, "%u day%s", time, PLURALIZE(time));
|
|
|
|
p += strlen(p);
|
|
|
|
do_comma = 1;
|
|
|
|
} else
|
|
|
|
do_comma = 0;
|
|
|
|
if (hours != 0) {
|
|
|
|
sprintf(p, "%s%u hour%s", COMMA(do_comma), hours, PLURALIZE(hours));
|
|
|
|
p += strlen(p);
|
|
|
|
do_comma = 1;
|
|
|
|
} else
|
|
|
|
do_comma = 0;
|
|
|
|
if (mins != 0) {
|
|
|
|
sprintf(p, "%s%u minute%s", COMMA(do_comma), mins, PLURALIZE(mins));
|
|
|
|
p += strlen(p);
|
|
|
|
do_comma = 1;
|
|
|
|
} else
|
|
|
|
do_comma = 0;
|
|
|
|
if (secs != 0)
|
|
|
|
sprintf(p, "%s%u second%s", COMMA(do_comma), secs, PLURALIZE(secs));
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
static const char *mon_names[12] = {
|
|
|
|
"Jan",
|
|
|
|
"Feb",
|
|
|
|
"Mar",
|
|
|
|
"Apr",
|
|
|
|
"May",
|
|
|
|
"Jun",
|
|
|
|
"Jul",
|
|
|
|
"Aug",
|
|
|
|
"Sep",
|
|
|
|
"Oct",
|
|
|
|
"Nov",
|
|
|
|
"Dec"
|
|
|
|
};
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
abs_time_to_str(struct timeval *abs_time)
|
|
|
|
{
|
|
|
|
struct tm *tmp;
|
|
|
|
static gchar *cur;
|
|
|
|
static char str[3][3+1+2+2+4+1+2+1+2+1+2+1+4+1 + 5 /* extra */];
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = localtime(&abs_time->tv_sec);
|
|
|
|
sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%04ld",
|
|
|
|
mon_names[tmp->tm_mon],
|
|
|
|
tmp->tm_mday,
|
|
|
|
tmp->tm_year + 1900,
|
|
|
|
tmp->tm_hour,
|
|
|
|
tmp->tm_min,
|
|
|
|
tmp->tm_sec,
|
|
|
|
(long)abs_time->tv_usec/100);
|
|
|
|
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2000-09-10 06:44:39 +00:00
|
|
|
#define REL_TIME_LEN (1+10+1+6+1)
|
|
|
|
|
1999-09-12 06:11:51 +00:00
|
|
|
gchar *
|
|
|
|
rel_time_to_str(struct timeval *rel_time)
|
|
|
|
{
|
|
|
|
static gchar *cur;
|
2000-09-10 06:44:39 +00:00
|
|
|
static char str[3][REL_TIME_LEN];
|
1999-09-12 06:11:51 +00:00
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
2000-09-10 06:44:39 +00:00
|
|
|
display_signed_time(cur, REL_TIME_LEN, rel_time->tv_sec,
|
|
|
|
rel_time->tv_usec);
|
1999-09-12 06:11:51 +00:00
|
|
|
return cur;
|
|
|
|
}
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2000-09-10 06:44:39 +00:00
|
|
|
static void
|
|
|
|
display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 usec)
|
|
|
|
{
|
|
|
|
char *sign;
|
|
|
|
|
|
|
|
/* If the microseconds part of the time stamp is negative,
|
|
|
|
print its absolute value and, if the seconds part isn't
|
|
|
|
(the seconds part should be zero in that case), stick
|
|
|
|
a "-" in front of the entire time stamp. */
|
|
|
|
sign = "";
|
|
|
|
if (usec < 0) {
|
|
|
|
usec = -usec;
|
|
|
|
if (sec >= 0)
|
|
|
|
sign = "-";
|
|
|
|
}
|
|
|
|
snprintf(buf, buflen, "%s%d.%06d", sign, sec, usec);
|
|
|
|
}
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1998-10-10 03:32:20 +00:00
|
|
|
/* Tries to match val against each element in the value_string array vs.
|
1998-10-20 05:31:03 +00:00
|
|
|
Returns the associated string ptr on a match.
|
|
|
|
Formats val with fmt, and returns the resulting string, on failure. */
|
|
|
|
gchar*
|
1998-10-28 01:16:49 +00:00
|
|
|
val_to_str(guint32 val, const value_string *vs, const char *fmt) {
|
1998-10-20 05:31:03 +00:00
|
|
|
gchar *ret;
|
|
|
|
static gchar str[3][64];
|
|
|
|
static gchar *cur;
|
|
|
|
|
|
|
|
ret = match_strval(val, vs);
|
|
|
|
if (ret != NULL)
|
|
|
|
return ret;
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
snprintf(cur, 64, fmt, val);
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tries to match val against each element in the value_string array vs.
|
|
|
|
Returns the associated string ptr on a match, or NULL on failure. */
|
1998-10-10 03:32:20 +00:00
|
|
|
gchar*
|
1998-10-28 01:16:49 +00:00
|
|
|
match_strval(guint32 val, const value_string *vs) {
|
1998-10-16 01:18:35 +00:00
|
|
|
gint i = 0;
|
1998-10-10 03:32:20 +00:00
|
|
|
|
1998-10-16 01:18:35 +00:00
|
|
|
while (vs[i].strptr) {
|
1998-10-10 03:32:20 +00:00
|
|
|
if (vs[i].value == val)
|
|
|
|
return(vs[i].strptr);
|
1998-10-16 01:18:35 +00:00
|
|
|
i++;
|
1998-10-10 03:32:20 +00:00
|
|
|
}
|
1999-07-07 22:52:57 +00:00
|
|
|
|
1998-10-10 03:32:20 +00:00
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
1999-03-31 08:20:28 +00:00
|
|
|
/* Generate, into "buf", a string showing the bits of a bitfield.
|
|
|
|
Return a pointer to the character after that string. */
|
1999-10-12 06:21:15 +00:00
|
|
|
char *
|
1999-03-31 08:20:28 +00:00
|
|
|
decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
guint32 bit;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
p = buf;
|
|
|
|
bit = 1 << (width - 1);
|
|
|
|
for (;;) {
|
|
|
|
if (mask & bit) {
|
|
|
|
/* This bit is part of the field. Show its value. */
|
|
|
|
if (val & bit)
|
|
|
|
*p++ = '1';
|
|
|
|
else
|
|
|
|
*p++ = '0';
|
|
|
|
} else {
|
|
|
|
/* This bit is not part of the field. */
|
|
|
|
*p++ = '.';
|
|
|
|
}
|
|
|
|
bit >>= 1;
|
|
|
|
i++;
|
|
|
|
if (i >= width)
|
|
|
|
break;
|
|
|
|
if (i % 4 == 0)
|
|
|
|
*p++ = ' ';
|
|
|
|
}
|
|
|
|
strcpy(p, " = ");
|
|
|
|
p += 3;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a string describing a Boolean bitfield (a one-bit field that
|
|
|
|
says something is either true of false). */
|
|
|
|
const char *
|
|
|
|
decode_boolean_bitfield(guint32 val, guint32 mask, int width,
|
|
|
|
const char *truedesc, const char *falsedesc)
|
|
|
|
{
|
|
|
|
static char buf[1025];
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = decode_bitfield_value(buf, val, mask, width);
|
|
|
|
if (val & mask)
|
|
|
|
strcpy(p, truedesc);
|
|
|
|
else
|
|
|
|
strcpy(p, falsedesc);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a string describing an enumerated bitfield (an N-bit field
|
|
|
|
with various specific values having particular names). */
|
|
|
|
const char *
|
|
|
|
decode_enumerated_bitfield(guint32 val, guint32 mask, int width,
|
|
|
|
const value_string *tab, const char *fmt)
|
|
|
|
{
|
|
|
|
static char buf[1025];
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = decode_bitfield_value(buf, val, mask, width);
|
|
|
|
sprintf(p, fmt, val_to_str(val & mask, tab, "Unknown"));
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a string describing a numeric bitfield (an N-bit field whose
|
|
|
|
value is just a number). */
|
|
|
|
const char *
|
|
|
|
decode_numeric_bitfield(guint32 val, guint32 mask, int width,
|
|
|
|
const char *fmt)
|
|
|
|
{
|
|
|
|
static char buf[1025];
|
|
|
|
char *p;
|
1999-08-04 04:37:46 +00:00
|
|
|
int shift = 0;
|
|
|
|
|
|
|
|
/* Compute the number of bits we have to shift the bitfield right
|
|
|
|
to extract its value. */
|
|
|
|
while ((mask & (1<<shift)) == 0)
|
|
|
|
shift++;
|
1999-03-31 08:20:28 +00:00
|
|
|
|
|
|
|
p = decode_bitfield_value(buf, val, mask, width);
|
1999-08-04 04:37:46 +00:00
|
|
|
sprintf(p, fmt, (val & mask) >> shift);
|
1999-03-31 08:20:28 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2000-12-03 22:12:21 +00:00
|
|
|
/* Allocate all the data structures for constructing column data, given
|
|
|
|
the number of columns. */
|
|
|
|
void
|
|
|
|
col_init(column_info *col_info, gint num_cols)
|
|
|
|
{
|
|
|
|
col_info->num_cols = num_cols;
|
|
|
|
col_info->col_fmt = (gint *) g_malloc(sizeof(gint) * num_cols);
|
|
|
|
col_info->fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * num_cols);
|
|
|
|
col_info->col_width = (gint *) g_malloc(sizeof(gint) * num_cols);
|
|
|
|
col_info->col_title = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
|
|
|
|
col_info->col_data = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
|
|
|
|
col_info->col_buf = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
|
|
|
|
}
|
|
|
|
|
2000-09-12 07:04:30 +00:00
|
|
|
gboolean
|
|
|
|
col_get_writable(frame_data *fd)
|
|
|
|
{
|
|
|
|
if (fd) {
|
|
|
|
|
2000-09-12 08:38:44 +00:00
|
|
|
return (fd->cinfo ? fd->cinfo->writable : FALSE);
|
2000-09-12 07:04:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-12 08:38:44 +00:00
|
|
|
return FALSE;
|
2000-09-12 07:04:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-07-08 10:46:23 +00:00
|
|
|
void
|
|
|
|
col_set_writable(frame_data *fd, gboolean writable)
|
|
|
|
{
|
|
|
|
if (fd->cinfo) {
|
|
|
|
fd->cinfo->writable = writable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
/* Checks to see if a particular packet information element is needed for
|
|
|
|
the packet list */
|
|
|
|
gint
|
|
|
|
check_col(frame_data *fd, gint el) {
|
|
|
|
int i;
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2000-07-08 10:46:23 +00:00
|
|
|
if (fd->cinfo && fd->cinfo->writable) {
|
1998-11-17 04:29:13 +00:00
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
if (fd->cinfo->fmt_matx[i][el])
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Add a "col_clear()" routine, to clear a column; it appears (and it
doesn't just seem to be a profiling artifact) that, at least on FreeBSD
3.4, it's significantly more efficient to clear out a column by stuffing
a '\0' into the first byte of the column data than to do so by copying a
null string (I guess when copying one byte, the fixed overhead of the
procedure call and of "strcpy()" is significant).
Have the TCP dissector set the Protocol column, and clear the Info
column, before doing anything that might cause an exception to be
thrown, so that if we *do* get an exception thrown, the frame at least
shows up as TCP.
Instead of, in the TCP dissector, constructing a string and then
stuffing it into the Info column, just append to the Info column, which
avoids one string copy.
Pass a "frame_data" pointer to dissectors for TCP and IP (and PPP)
options, so they can use it to append to the Info column.
svn path=/trunk/; revision=2744
2000-12-04 06:37:46 +00:00
|
|
|
/* Use this to clear out a column, especially if you're going to be
|
|
|
|
appending to it later; at least on some platforms, it's more
|
|
|
|
efficient than using "col_add_str()" with a null string, and
|
|
|
|
more efficient than "col_set_str()" with a null string if you
|
|
|
|
later append to it, as the later append will cause a string
|
|
|
|
copy to be done. */
|
|
|
|
void
|
|
|
|
col_clear(frame_data *fd, gint el) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
if (fd->cinfo->fmt_matx[i][el]) {
|
|
|
|
fd->cinfo->col_buf[i][0] = 0;
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-19 08:54:37 +00:00
|
|
|
/* Use this if "str" points to something that will stay around (and thus
|
|
|
|
needn't be copied). */
|
|
|
|
void
|
|
|
|
col_set_str(frame_data *fd, gint el, gchar* str) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
if (fd->cinfo->fmt_matx[i][el])
|
|
|
|
fd->cinfo->col_data[i] = str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
/* Adds a vararg list to a packet info string. */
|
|
|
|
void
|
|
|
|
col_add_fstr(frame_data *fd, gint el, gchar *format, ...) {
|
1999-10-29 02:25:54 +00:00
|
|
|
va_list ap;
|
|
|
|
int i;
|
|
|
|
size_t max_len;
|
2000-07-08 10:46:23 +00:00
|
|
|
|
|
|
|
if (el == COL_INFO)
|
|
|
|
max_len = COL_MAX_INFO_LEN;
|
|
|
|
else
|
|
|
|
max_len = COL_MAX_LEN;
|
1998-11-17 04:29:13 +00:00
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
1999-10-29 02:25:54 +00:00
|
|
|
if (fd->cinfo->fmt_matx[i][el]) {
|
2000-11-19 08:54:37 +00:00
|
|
|
vsnprintf(fd->cinfo->col_buf[i], max_len, format, ap);
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
1999-10-29 02:25:54 +00:00
|
|
|
}
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-19 08:54:37 +00:00
|
|
|
/* Use this if "str" points to something that won't stay around (and
|
|
|
|
must thus be copied). */
|
1998-11-17 04:29:13 +00:00
|
|
|
void
|
1999-06-12 04:21:09 +00:00
|
|
|
col_add_str(frame_data *fd, gint el, const gchar* str) {
|
1999-10-29 02:25:54 +00:00
|
|
|
int i;
|
1999-10-15 20:33:06 +00:00
|
|
|
size_t max_len;
|
|
|
|
|
2000-07-08 10:46:23 +00:00
|
|
|
if (el == COL_INFO)
|
1999-10-15 20:33:06 +00:00
|
|
|
max_len = COL_MAX_INFO_LEN;
|
2000-07-08 10:46:23 +00:00
|
|
|
else
|
1999-10-15 20:33:06 +00:00
|
|
|
max_len = COL_MAX_LEN;
|
2000-07-08 10:46:23 +00:00
|
|
|
|
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
if (fd->cinfo->fmt_matx[i][el]) {
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[i], str, max_len);
|
|
|
|
fd->cinfo->col_buf[i][max_len - 1] = 0;
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
1998-11-17 04:29:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-29 02:25:54 +00:00
|
|
|
/* Appends a vararg list to a packet info string. */
|
|
|
|
void
|
|
|
|
col_append_fstr(frame_data *fd, gint el, gchar *format, ...) {
|
|
|
|
va_list ap;
|
|
|
|
int i;
|
|
|
|
size_t len, max_len;
|
|
|
|
|
2000-07-08 10:46:23 +00:00
|
|
|
if (el == COL_INFO)
|
|
|
|
max_len = COL_MAX_INFO_LEN;
|
|
|
|
else
|
|
|
|
max_len = COL_MAX_LEN;
|
|
|
|
|
1999-10-29 02:25:54 +00:00
|
|
|
va_start(ap, format);
|
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
if (fd->cinfo->fmt_matx[i][el]) {
|
2000-11-19 08:54:37 +00:00
|
|
|
if (fd->cinfo->col_data[i] != fd->cinfo->col_buf[i]) {
|
|
|
|
/* This was set with "col_set_str()"; copy the string they
|
|
|
|
set it to into the buffer, so we can append to it. */
|
|
|
|
strncpy(fd->cinfo->col_buf[i], fd->cinfo->col_data[i], max_len);
|
|
|
|
fd->cinfo->col_buf[i][max_len - 1] = '\0';
|
|
|
|
}
|
|
|
|
len = strlen(fd->cinfo->col_buf[i]);
|
|
|
|
vsnprintf(&fd->cinfo->col_buf[i][len], max_len - len, format, ap);
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
1999-10-29 02:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-15 20:33:06 +00:00
|
|
|
void
|
|
|
|
col_append_str(frame_data *fd, gint el, gchar* str) {
|
1999-10-29 02:25:54 +00:00
|
|
|
int i;
|
|
|
|
size_t len, max_len;
|
1999-10-15 20:33:06 +00:00
|
|
|
|
2000-07-08 10:46:23 +00:00
|
|
|
if (el == COL_INFO)
|
|
|
|
max_len = COL_MAX_INFO_LEN;
|
|
|
|
else
|
|
|
|
max_len = COL_MAX_LEN;
|
|
|
|
|
1999-10-29 02:25:54 +00:00
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
if (fd->cinfo->fmt_matx[i][el]) {
|
2000-11-19 08:54:37 +00:00
|
|
|
if (fd->cinfo->col_data[i] != fd->cinfo->col_buf[i]) {
|
|
|
|
/* This was set with "col_set_str()"; copy the string they
|
|
|
|
set it to into the buffer, so we can append to it. */
|
|
|
|
strncpy(fd->cinfo->col_buf[i], fd->cinfo->col_data[i], max_len);
|
|
|
|
fd->cinfo->col_buf[i][max_len - 1] = '\0';
|
|
|
|
}
|
|
|
|
len = strlen(fd->cinfo->col_buf[i]);
|
|
|
|
strncat(fd->cinfo->col_buf[i], str, max_len - len);
|
|
|
|
fd->cinfo->col_buf[i][max_len - 1] = 0;
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
1999-10-15 20:33:06 +00:00
|
|
|
}
|
1999-10-29 02:25:54 +00:00
|
|
|
}
|
1999-10-15 20:33:06 +00:00
|
|
|
}
|
1999-12-29 07:25:48 +00:00
|
|
|
|
|
|
|
/* To do: Add check_col checks to the col_add* routines */
|
|
|
|
|
|
|
|
static void
|
|
|
|
col_set_abs_time(frame_data *fd, int col)
|
|
|
|
{
|
|
|
|
struct tm *tmp;
|
|
|
|
time_t then;
|
|
|
|
|
|
|
|
then = fd->abs_secs;
|
|
|
|
tmp = localtime(&then);
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld",
|
1999-12-29 07:25:48 +00:00
|
|
|
tmp->tm_hour,
|
|
|
|
tmp->tm_min,
|
|
|
|
tmp->tm_sec,
|
|
|
|
(long)fd->abs_usecs/100);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
}
|
|
|
|
|
2000-11-01 08:31:36 +00:00
|
|
|
static void
|
|
|
|
col_set_abs_date_time(frame_data *fd, int col)
|
|
|
|
{
|
|
|
|
struct tm *tmp;
|
|
|
|
time_t then;
|
|
|
|
|
|
|
|
then = fd->abs_secs;
|
|
|
|
tmp = localtime(&then);
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN,
|
2000-11-01 08:31:36 +00:00
|
|
|
"%04d-%02d-%02d %02d:%02d:%02d.%04ld",
|
|
|
|
tmp->tm_year + 1900,
|
|
|
|
tmp->tm_mon + 1,
|
|
|
|
tmp->tm_mday,
|
|
|
|
tmp->tm_hour,
|
|
|
|
tmp->tm_min,
|
|
|
|
tmp->tm_sec,
|
|
|
|
(long)fd->abs_usecs/100);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
2000-11-01 08:31:36 +00:00
|
|
|
}
|
|
|
|
|
1999-12-29 07:25:48 +00:00
|
|
|
static void
|
|
|
|
col_set_rel_time(frame_data *fd, int col)
|
|
|
|
{
|
2000-11-19 08:54:37 +00:00
|
|
|
display_signed_time(fd->cinfo->col_buf[col], COL_MAX_LEN,
|
2000-09-10 06:44:39 +00:00
|
|
|
fd->rel_secs, fd->rel_usecs);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
col_set_delta_time(frame_data *fd, int col)
|
|
|
|
{
|
2000-11-19 08:54:37 +00:00
|
|
|
display_signed_time(fd->cinfo->col_buf[col], COL_MAX_LEN,
|
2000-09-10 06:44:39 +00:00
|
|
|
fd->del_secs, fd->del_usecs);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add "command-line-specified" time.
|
|
|
|
XXX - this is called from "file.c" when the user changes the time
|
|
|
|
format they want for "command-line-specified" time; it's a bit ugly
|
|
|
|
that we have to export it, but if we go to a CList-like widget that
|
|
|
|
invokes callbacks to get the text for the columns rather than
|
|
|
|
requiring us to stuff the text into the widget from outside, we
|
|
|
|
might be able to clean this up. */
|
|
|
|
void
|
|
|
|
col_set_cls_time(frame_data *fd, int col)
|
|
|
|
{
|
|
|
|
switch (timestamp_type) {
|
|
|
|
case ABSOLUTE:
|
|
|
|
col_set_abs_time(fd, col);
|
|
|
|
break;
|
|
|
|
|
2000-11-01 08:31:36 +00:00
|
|
|
case ABSOLUTE_WITH_DATE:
|
|
|
|
col_set_abs_date_time(fd, col);
|
|
|
|
break;
|
|
|
|
|
1999-12-29 07:25:48 +00:00
|
|
|
case RELATIVE:
|
|
|
|
col_set_rel_time(fd, col);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DELTA:
|
|
|
|
col_set_delta_time(fd, col);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
col_set_addr(frame_data *fd, int col, address *addr, gboolean is_res)
|
|
|
|
{
|
|
|
|
u_int ipv4_addr;
|
|
|
|
struct e_in6_addr ipv6_addr;
|
|
|
|
struct atalk_ddp_addr ddp_addr;
|
|
|
|
struct sna_fid_type_4_addr sna_fid_type_4_addr;
|
|
|
|
|
|
|
|
switch (addr->type) {
|
|
|
|
|
|
|
|
case AT_ETHER:
|
|
|
|
if (is_res)
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], get_ether_name(addr->data), COL_MAX_LEN);
|
1999-12-29 07:25:48 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], ether_to_str(addr->data), COL_MAX_LEN);
|
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AT_IPv4:
|
|
|
|
memcpy(&ipv4_addr, addr->data, sizeof ipv4_addr);
|
|
|
|
if (is_res)
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], get_hostname(ipv4_addr), COL_MAX_LEN);
|
1999-12-29 07:25:48 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], ip_to_str(addr->data), COL_MAX_LEN);
|
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AT_IPv6:
|
|
|
|
memcpy(&ipv6_addr.s6_addr, addr->data, sizeof ipv6_addr.s6_addr);
|
|
|
|
if (is_res)
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], get_hostname6(&ipv6_addr), COL_MAX_LEN);
|
1999-12-29 07:25:48 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], ip6_to_str(&ipv6_addr), COL_MAX_LEN);
|
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AT_IPX:
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col],
|
1999-12-29 07:25:48 +00:00
|
|
|
ipx_addr_to_str(pntohl(&addr->data[0]), &addr->data[4]), COL_MAX_LEN);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AT_SNA:
|
|
|
|
switch (addr->len) {
|
|
|
|
|
|
|
|
case 1:
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%04X", addr->data[0]);
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%04X",
|
1999-12-29 07:25:48 +00:00
|
|
|
pntohs(&addr->data[0]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SNA_FID_TYPE_4_ADDR_LEN:
|
|
|
|
memcpy(&sna_fid_type_4_addr, addr->data, SNA_FID_TYPE_4_ADDR_LEN);
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col],
|
1999-12-29 07:25:48 +00:00
|
|
|
sna_fid_type_4_addr_to_str(&sna_fid_type_4_addr), COL_MAX_LEN);
|
|
|
|
break;
|
|
|
|
}
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AT_ATALK:
|
|
|
|
memcpy(&ddp_addr, addr->data, sizeof ddp_addr);
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], atalk_addr_to_str(&ddp_addr),
|
1999-12-29 07:25:48 +00:00
|
|
|
COL_MAX_LEN);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AT_VINES:
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], vines_addr_to_str(&addr->data[0]),
|
1999-12-29 07:25:48 +00:00
|
|
|
COL_MAX_LEN);
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
col_set_port(frame_data *fd, int col, port_type ptype, guint32 port,
|
|
|
|
gboolean is_res)
|
|
|
|
{
|
|
|
|
switch (ptype) {
|
|
|
|
|
2000-08-19 08:26:04 +00:00
|
|
|
case PT_SCTP:
|
|
|
|
if (is_res)
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], get_sctp_port(port), COL_MAX_LEN);
|
2000-08-19 08:26:04 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
|
2000-08-19 08:26:04 +00:00
|
|
|
break;
|
|
|
|
|
1999-12-29 07:25:48 +00:00
|
|
|
case PT_TCP:
|
|
|
|
if (is_res)
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], get_tcp_port(port), COL_MAX_LEN);
|
1999-12-29 07:25:48 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PT_UDP:
|
|
|
|
if (is_res)
|
2000-11-19 08:54:37 +00:00
|
|
|
strncpy(fd->cinfo->col_buf[col], get_udp_port(port), COL_MAX_LEN);
|
1999-12-29 07:25:48 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%u", port);
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-11-19 08:54:37 +00:00
|
|
|
fd->cinfo->col_buf[col][COL_MAX_LEN - 1] = '\0';
|
|
|
|
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
1999-12-29 07:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fill_in_columns(frame_data *fd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fd->cinfo->num_cols; i++) {
|
|
|
|
switch (fd->cinfo->col_fmt[i]) {
|
|
|
|
|
|
|
|
case COL_NUMBER:
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[i], COL_MAX_LEN, "%u", fd->num);
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_CLS_TIME:
|
|
|
|
col_set_cls_time(fd, i);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_ABS_TIME:
|
|
|
|
col_set_abs_time(fd, i);
|
|
|
|
break;
|
|
|
|
|
2000-11-01 08:31:36 +00:00
|
|
|
case COL_ABS_DATE_TIME:
|
|
|
|
col_set_abs_date_time(fd, i);
|
|
|
|
break;
|
|
|
|
|
1999-12-29 07:25:48 +00:00
|
|
|
case COL_REL_TIME:
|
|
|
|
col_set_rel_time(fd, i);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DELTA_TIME:
|
|
|
|
col_set_delta_time(fd, i);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_SRC:
|
|
|
|
case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
|
|
|
|
col_set_addr(fd, i, &pi.src, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_SRC:
|
|
|
|
col_set_addr(fd, i, &pi.src, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_DL_SRC:
|
|
|
|
case COL_RES_DL_SRC:
|
|
|
|
col_set_addr(fd, i, &pi.dl_src, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_DL_SRC:
|
|
|
|
col_set_addr(fd, i, &pi.dl_src, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_NET_SRC:
|
|
|
|
case COL_RES_NET_SRC:
|
|
|
|
col_set_addr(fd, i, &pi.net_src, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_NET_SRC:
|
|
|
|
col_set_addr(fd, i, &pi.net_src, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_DST:
|
|
|
|
case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
|
|
|
|
col_set_addr(fd, i, &pi.dst, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_DST:
|
|
|
|
col_set_addr(fd, i, &pi.dst, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_DL_DST:
|
|
|
|
case COL_RES_DL_DST:
|
|
|
|
col_set_addr(fd, i, &pi.dl_dst, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_DL_DST:
|
|
|
|
col_set_addr(fd, i, &pi.dl_dst, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_NET_DST:
|
|
|
|
case COL_RES_NET_DST:
|
|
|
|
col_set_addr(fd, i, &pi.net_dst, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_NET_DST:
|
|
|
|
col_set_addr(fd, i, &pi.net_dst, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_SRC_PORT:
|
|
|
|
case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
|
|
|
|
col_set_port(fd, i, pi.ptype, pi.srcport, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_SRC_PORT:
|
|
|
|
col_set_port(fd, i, pi.ptype, pi.srcport, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_DEF_DST_PORT:
|
|
|
|
case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
|
|
|
|
col_set_port(fd, i, pi.ptype, pi.destport, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_UNRES_DST_PORT:
|
|
|
|
col_set_port(fd, i, pi.ptype, pi.destport, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_PROTOCOL: /* currently done by dissectors */
|
|
|
|
case COL_INFO: /* currently done by dissectors */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COL_PACKET_LENGTH:
|
2000-11-19 08:54:37 +00:00
|
|
|
snprintf(fd->cinfo->col_buf[i], COL_MAX_LEN, "%d", fd->pkt_len);
|
|
|
|
fd->cinfo->col_data[i] = fd->cinfo->col_buf[i];
|
1999-12-29 07:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NUM_COL_FMTS: /* keep compiler happy - shouldn't get here */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-15 20:33:06 +00:00
|
|
|
|
Generalize the "ip_src" and "ip_dst" members of the "packet_info"
structure to "dl_src"/"dl_dst", "net_src"/"net_dst", and "src"/"dst"
addresses, where an address is an address type, an address length in
bytes, and a pointer to that many bytes.
"dl_{src,dst}" are the link-layer source/destination; "net_{src,dst}"
are the network-layer source/destination; "{src,dst}" are the
source/destination from the highest of those two layers that we have in
the packet.
Add a port type to "packet_info" as well, specifying whether it's a TCP
or UDP port.
Don't set the address and port columns in the dissector functions; just
set the address and port members of the "packet_info" structure. Set
the columns in "fill_in_columns()"; this means that if we're showing
COL_{DEF,RES,UNRES}_SRC" or "COL_{DEF,RES,UNRES}_DST", we only generate
the string from "src" or "dst", we don't generate a string for the
link-layer address and then overwrite it with a string for the
network-layer address (generating those strings costs CPU).
Add support for "conversations", where a "conversation" is (at present)
a source and destination address and a source and destination port. (In
the future, we may support "conversations" above the transport layer,
e.g. a TFTP conversation, where the first packet goes from the client to
the TFTP server port, but the reply comes back from a different port,
and all subsequent packets go between the client address/port and the
server address/new port, or an NFS conversation, which might include
lock manager, status monitor, and mount packets, as well as NFS
packets.)
Currently, all we support is a call that takes the source and
destination address/port pairs, looks them up in a hash table, and:
if nothing is found, creates a new entry in the hash table, and
assigns it a unique 32-bit conversation ID, and returns that
conversation ID;
if an entry is found, returns its conversation ID.
Use that in the SMB and AFS code to keep track of individual SMB or AFS
conversations. We need to match up requests and replies, as, for
certain replies, the operation code for the request to which it's a
reply doesn't show up in the reply - you have to find the request with a
matching transaction ID. Transaction IDs are per-conversation, so the
hash table for requests should include a conversation ID and transaction
ID as the key.
This allows SMB and AFS decoders to handle IPv4 or IPv6 addresses
transparently (and should allow the SMB decoder to handle NetBIOS atop
other protocols as well, if the source and destination address and port
values in the "packet_info" structure are set appropriately).
In the "Follow TCP Connection" code, check to make sure that the
addresses are IPv4 addressses; ultimately, that code should be changed
to use the conversation code instead, which will let it handle IPv6
transparently.
svn path=/trunk/; revision=909
1999-10-22 07:18:23 +00:00
|
|
|
void blank_packetinfo(void)
|
|
|
|
{
|
|
|
|
pi.dl_src.type = AT_NONE;
|
|
|
|
pi.dl_dst.type = AT_NONE;
|
|
|
|
pi.net_src.type = AT_NONE;
|
|
|
|
pi.net_dst.type = AT_NONE;
|
|
|
|
pi.src.type = AT_NONE;
|
|
|
|
pi.dst.type = AT_NONE;
|
|
|
|
pi.ipproto = 0;
|
|
|
|
pi.ptype = PT_NONE;
|
|
|
|
pi.srcport = 0;
|
|
|
|
pi.destport = 0;
|
2000-05-19 23:07:04 +00:00
|
|
|
pi.current_proto = "<Missing Protocol Name>";
|
2000-09-21 04:41:37 +00:00
|
|
|
pi.p2p_dir = P2P_DIR_UNKNOWN;
|
Generalize the "ip_src" and "ip_dst" members of the "packet_info"
structure to "dl_src"/"dl_dst", "net_src"/"net_dst", and "src"/"dst"
addresses, where an address is an address type, an address length in
bytes, and a pointer to that many bytes.
"dl_{src,dst}" are the link-layer source/destination; "net_{src,dst}"
are the network-layer source/destination; "{src,dst}" are the
source/destination from the highest of those two layers that we have in
the packet.
Add a port type to "packet_info" as well, specifying whether it's a TCP
or UDP port.
Don't set the address and port columns in the dissector functions; just
set the address and port members of the "packet_info" structure. Set
the columns in "fill_in_columns()"; this means that if we're showing
COL_{DEF,RES,UNRES}_SRC" or "COL_{DEF,RES,UNRES}_DST", we only generate
the string from "src" or "dst", we don't generate a string for the
link-layer address and then overwrite it with a string for the
network-layer address (generating those strings costs CPU).
Add support for "conversations", where a "conversation" is (at present)
a source and destination address and a source and destination port. (In
the future, we may support "conversations" above the transport layer,
e.g. a TFTP conversation, where the first packet goes from the client to
the TFTP server port, but the reply comes back from a different port,
and all subsequent packets go between the client address/port and the
server address/new port, or an NFS conversation, which might include
lock manager, status monitor, and mount packets, as well as NFS
packets.)
Currently, all we support is a call that takes the source and
destination address/port pairs, looks them up in a hash table, and:
if nothing is found, creates a new entry in the hash table, and
assigns it a unique 32-bit conversation ID, and returns that
conversation ID;
if an entry is found, returns its conversation ID.
Use that in the SMB and AFS code to keep track of individual SMB or AFS
conversations. We need to match up requests and replies, as, for
certain replies, the operation code for the request to which it's a
reply doesn't show up in the reply - you have to find the request with a
matching transaction ID. Transaction IDs are per-conversation, so the
hash table for requests should include a conversation ID and transaction
ID as the key.
This allows SMB and AFS decoders to handle IPv4 or IPv6 addresses
transparently (and should allow the SMB decoder to handle NetBIOS atop
other protocols as well, if the source and destination address and port
values in the "packet_info" structure are set appropriately).
In the "Follow TCP Connection" code, check to make sure that the
addresses are IPv4 addressses; ultimately, that code should be changed
to use the conversation code instead, which will let it handle IPv6
transparently.
svn path=/trunk/; revision=909
1999-10-22 07:18:23 +00:00
|
|
|
}
|
1999-10-15 20:33:06 +00:00
|
|
|
|
2000-04-04 07:03:07 +00:00
|
|
|
|
Provide a general mechanism by which dissectors can register "init"
routines, which are called before a dissection pass is made over all the
packets in a capture - the "init" routine would clear out any state
information that needs to be initialized before such a dissection pass.
Make the NCP, SMB, AFS, and ONC RPC dissectors register their "init"
routines with that mechanism, have the code that reads in a capture file
call the routine that calls all registered "init" routines rather than
calling a wired-in set of "init" routines, and also have the code that
runs a filtering or colorizing pass over all the packets call that
routine, as a filtering or colorizing pass is a dissection pass.
Have the ONC RPC "init" routine zero out the table of RPC calls, so that
it completely erases any state from the previous dissection pass (so
that, for example, if you run a filtering pass, it doesn't mark any
non-duplicate packets as duplicates because it remembers them from the
previous pass).
svn path=/trunk/; revision=1050
1999-11-17 21:58:33 +00:00
|
|
|
/* Allow protocols to register "init" routines, which are called before
|
|
|
|
we make a pass through a capture file and dissect all its packets
|
|
|
|
(e.g., when we read in a new capture file, or run a "filter packets"
|
|
|
|
or "colorize packets" pass over the current capture file). */
|
|
|
|
static GSList *init_routines;
|
|
|
|
|
|
|
|
void
|
|
|
|
register_init_routine(void (*func)(void))
|
|
|
|
{
|
|
|
|
init_routines = g_slist_append(init_routines, func);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call all the registered "init" routines. */
|
|
|
|
static void
|
|
|
|
call_init_routine(gpointer routine, gpointer dummy)
|
|
|
|
{
|
|
|
|
void (*func)(void) = routine;
|
|
|
|
|
|
|
|
(*func)();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
init_all_protocols(void)
|
|
|
|
{
|
|
|
|
g_slist_foreach(init_routines, &call_init_routine, NULL);
|
|
|
|
}
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
/* Creates the top-most tvbuff and calls dissect_frame() */
|
1998-09-16 02:39:15 +00:00
|
|
|
void
|
2000-10-06 10:11:40 +00:00
|
|
|
dissect_packet(tvbuff_t **p_tvb, union wtap_pseudo_header *pseudo_header,
|
|
|
|
const u_char *pd, frame_data *fd, proto_tree *tree)
|
1998-09-27 22:12:47 +00:00
|
|
|
{
|
2000-09-21 04:41:37 +00:00
|
|
|
blank_packetinfo();
|
|
|
|
|
1999-08-18 00:57:54 +00:00
|
|
|
/* Set the initial payload to the packet length, and the initial
|
|
|
|
captured payload to the capture length (other protocols may
|
|
|
|
reduce them if their headers say they're less). */
|
|
|
|
pi.len = fd->pkt_len;
|
|
|
|
pi.captured_len = fd->cap_len;
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
pi.fd = fd;
|
2000-05-19 23:07:04 +00:00
|
|
|
pi.pseudo_header = pseudo_header;
|
2000-05-11 08:18:09 +00:00
|
|
|
|
2000-07-08 10:46:23 +00:00
|
|
|
col_set_writable(fd, TRUE);
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
TRY {
|
2000-10-06 10:11:40 +00:00
|
|
|
*p_tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
|
|
|
|
pi.compat_top_tvb = *p_tvb;
|
2000-05-11 08:18:09 +00:00
|
|
|
}
|
|
|
|
CATCH(BoundsError) {
|
2000-10-06 10:11:40 +00:00
|
|
|
g_assert_not_reached();
|
2000-05-16 04:44:14 +00:00
|
|
|
}
|
|
|
|
CATCH(ReportedBoundsError) {
|
2000-10-06 10:11:40 +00:00
|
|
|
proto_tree_add_protocol_format(tree, proto_malformed, *p_tvb, 0, 0,
|
|
|
|
"[Malformed Frame: Packet Length]" );
|
1998-11-12 00:06:47 +00:00
|
|
|
}
|
2000-05-11 08:18:09 +00:00
|
|
|
ENDTRY;
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
dissect_frame(*p_tvb, &pi, tree);
|
2000-04-13 20:39:38 +00:00
|
|
|
|
|
|
|
fd->flags.visited = 1;
|
1999-07-07 22:52:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
|
|
|
|
|
2000-03-26 06:57:41 +00:00
|
|
|
gint p_compare(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (((frame_proto_data *)a) -> proto > ((frame_proto_data *)b) -> proto)
|
|
|
|
return 1;
|
|
|
|
else if (((frame_proto_data *)a) -> proto == ((frame_proto_data *)b) -> proto)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
p_add_proto_data(frame_data *fd, int proto, void *proto_data)
|
|
|
|
{
|
2000-04-16 04:56:40 +00:00
|
|
|
frame_proto_data *p1 = g_mem_chunk_alloc(frame_proto_data_area);
|
2000-03-26 06:57:41 +00:00
|
|
|
|
|
|
|
g_assert(p1 != NULL);
|
|
|
|
|
|
|
|
p1 -> proto = proto;
|
|
|
|
p1 -> proto_data = proto_data;
|
|
|
|
|
2000-04-16 04:56:40 +00:00
|
|
|
/* Add it to the GSLIST */
|
2000-03-26 06:57:41 +00:00
|
|
|
|
|
|
|
fd -> pfd = g_slist_insert_sorted(fd -> pfd,
|
|
|
|
(gpointer *)p1,
|
|
|
|
p_compare);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
p_get_proto_data(frame_data *fd, int proto)
|
|
|
|
{
|
2000-08-12 00:15:40 +00:00
|
|
|
frame_proto_data temp, *p1;
|
2000-03-26 07:59:47 +00:00
|
|
|
GSList *item;
|
2000-03-26 06:57:41 +00:00
|
|
|
|
2000-03-26 07:59:47 +00:00
|
|
|
temp.proto = proto;
|
|
|
|
temp.proto_data = NULL;
|
|
|
|
|
|
|
|
item = g_slist_find_custom(fd->pfd, (gpointer *)&temp, p_compare);
|
|
|
|
|
2000-08-12 00:15:40 +00:00
|
|
|
if (item) {
|
|
|
|
p1 = (frame_proto_data *)item->data;
|
|
|
|
return p1->proto_data;
|
|
|
|
}
|
2000-03-26 07:59:47 +00:00
|
|
|
|
|
|
|
return NULL;
|
2000-03-26 06:57:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
p_rem_proto_data(frame_data *fd, int proto)
|
|
|
|
{
|
2000-08-21 12:53:10 +00:00
|
|
|
frame_proto_data temp;
|
2000-08-19 23:06:51 +00:00
|
|
|
GSList *item;
|
|
|
|
|
|
|
|
temp.proto = proto;
|
|
|
|
temp.proto_data = NULL;
|
|
|
|
|
|
|
|
item = g_slist_find_custom(fd->pfd, (gpointer *)&temp, p_compare);
|
|
|
|
|
|
|
|
if (item) {
|
2000-03-26 06:57:41 +00:00
|
|
|
|
2000-08-19 23:06:51 +00:00
|
|
|
fd->pfd = g_slist_remove(fd->pfd, item);
|
|
|
|
|
|
|
|
}
|
2000-03-26 06:57:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-04-03 09:24:12 +00:00
|
|
|
|
|
|
|
/*********************** code added for sub-dissector lookup *********************/
|
|
|
|
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
static GHashTable *dissector_tables = NULL;
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
/*
|
|
|
|
* XXX - for now, we support having both "old" dissectors, with packet
|
|
|
|
* data pointer, packet offset, frame_data pointer, and protocol tree
|
|
|
|
* pointer arguments, and "new" dissectors, with tvbuff pointer,
|
|
|
|
* packet_info pointer, and protocol tree pointer arguments.
|
|
|
|
*
|
|
|
|
* Nuke this and go back to storing a pointer to the dissector when
|
|
|
|
* the last old-style dissector is gone.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
gboolean is_old_dissector;
|
|
|
|
union {
|
|
|
|
old_dissector_t old;
|
|
|
|
dissector_t new;
|
|
|
|
} dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
int proto_index;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
} dtbl_entry_t;
|
|
|
|
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
/* Finds a dissector table by field name. */
|
|
|
|
static dissector_table_t
|
|
|
|
find_dissector_table(const char *name)
|
|
|
|
{
|
|
|
|
g_assert(dissector_tables);
|
|
|
|
return g_hash_table_lookup( dissector_tables, name );
|
|
|
|
}
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
/* add an entry, lookup the dissector table for the specified field name, */
|
|
|
|
/* if a valid table found, add the subdissector */
|
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
old_dissector_add(const char *name, guint32 pattern, old_dissector_t dissector,
|
|
|
|
int proto)
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dissector_table_t sub_dissectors = find_dissector_table( name);
|
|
|
|
dtbl_entry_t *dtbl_entry;
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
/* sanity check */
|
|
|
|
g_assert( sub_dissectors);
|
|
|
|
|
|
|
|
dtbl_entry = g_malloc(sizeof (dtbl_entry_t));
|
|
|
|
dtbl_entry->is_old_dissector = TRUE;
|
|
|
|
dtbl_entry->dissector.old = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
dtbl_entry->proto_index = proto;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
|
|
|
|
/* do the table insertion */
|
|
|
|
g_hash_table_insert( sub_dissectors, GUINT_TO_POINTER( pattern),
|
|
|
|
(gpointer)dtbl_entry);
|
|
|
|
}
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
dissector_add(const char *name, guint32 pattern, dissector_t dissector,
|
|
|
|
int proto)
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
{
|
2000-04-03 09:24:12 +00:00
|
|
|
dissector_table_t sub_dissectors = find_dissector_table( name);
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry_t *dtbl_entry;
|
2000-04-03 09:24:12 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert( sub_dissectors);
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry = g_malloc(sizeof (dtbl_entry_t));
|
|
|
|
dtbl_entry->is_old_dissector = FALSE;
|
|
|
|
dtbl_entry->dissector.new = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
dtbl_entry->proto_index = proto;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
|
2000-04-03 09:24:12 +00:00
|
|
|
/* do the table insertion */
|
|
|
|
g_hash_table_insert( sub_dissectors, GUINT_TO_POINTER( pattern),
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
(gpointer)dtbl_entry);
|
2000-04-03 09:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* delete the entry for this dissector at this pattern */
|
|
|
|
|
|
|
|
/* NOTE: this doesn't use the dissector call variable. It is included to */
|
|
|
|
/* be consistant with the dissector_add and more importantly to be used */
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
/* if the technique of adding a temporary dissector is implemented. */
|
|
|
|
/* If temporary dissectors are deleted, then the original dissector must */
|
2000-04-03 09:24:12 +00:00
|
|
|
/* be available. */
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
void
|
|
|
|
old_dissector_delete(const char *name, guint32 pattern, old_dissector_t dissector)
|
|
|
|
{
|
|
|
|
dissector_table_t sub_dissectors = find_dissector_table( name);
|
|
|
|
dtbl_entry_t *dtbl_entry;
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert( sub_dissectors);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the entry.
|
|
|
|
*/
|
|
|
|
dtbl_entry = g_hash_table_lookup(sub_dissectors,
|
|
|
|
GUINT_TO_POINTER(pattern));
|
|
|
|
|
|
|
|
if (dtbl_entry != NULL) {
|
|
|
|
/*
|
|
|
|
* Found - remove it.
|
|
|
|
*/
|
|
|
|
g_hash_table_remove(sub_dissectors, GUINT_TO_POINTER(pattern));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now free up the entry.
|
|
|
|
*/
|
|
|
|
g_free(dtbl_entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
void
|
|
|
|
dissector_delete(const char *name, guint32 pattern, dissector_t dissector)
|
|
|
|
{
|
2000-04-03 09:24:12 +00:00
|
|
|
dissector_table_t sub_dissectors = find_dissector_table( name);
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry_t *dtbl_entry;
|
2000-04-03 09:24:12 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert( sub_dissectors);
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
/*
|
|
|
|
* Find the entry.
|
|
|
|
*/
|
|
|
|
dtbl_entry = g_hash_table_lookup(sub_dissectors,
|
|
|
|
GUINT_TO_POINTER(pattern));
|
|
|
|
|
|
|
|
if (dtbl_entry != NULL) {
|
|
|
|
/*
|
|
|
|
* Found - remove it.
|
|
|
|
*/
|
|
|
|
g_hash_table_remove(sub_dissectors, GUINT_TO_POINTER(pattern));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now free up the entry.
|
|
|
|
*/
|
|
|
|
g_free(dtbl_entry);
|
|
|
|
}
|
2000-04-03 09:24:12 +00:00
|
|
|
}
|
|
|
|
|
Make a routine that takes a dissector table, a port number, and
pd/offset/fd/tree arguments, looks up the port number in the dissector
table, and:
if it finds it, call the corresponding dissector routine with
the pd/offset/fd/tree arguments, and return TRUE;
if it doesn't find it, return FALSE.
Use that in the TCP and UDP dissectors.
Don't add arbitrary UDP ports for which a dissector is found in the
table as ports that should be dissected as TFTP; this should only be
done if we find a packet going from port XXX to the official TFTP port.
Don't register TFTP in UDP's dissector table, as it has to be handled
specially (i.e., we have to add the source port as a TFTP port, although
we really should register the source port *and* IP address); eventually,
we should move that registration to the TFTP dissector itself, at which
point we can register TFTP normally.
svn path=/trunk/; revision=1785
2000-04-04 05:37:36 +00:00
|
|
|
/* Look for a given port in a given dissector table and, if found, call
|
|
|
|
the dissector with the arguments supplied, and return TRUE, otherwise
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
return FALSE.
|
|
|
|
|
|
|
|
If the arguments supplied don't match the arguments to the dissector,
|
|
|
|
do the appropriate translation. */
|
Make a routine that takes a dissector table, a port number, and
pd/offset/fd/tree arguments, looks up the port number in the dissector
table, and:
if it finds it, call the corresponding dissector routine with
the pd/offset/fd/tree arguments, and return TRUE;
if it doesn't find it, return FALSE.
Use that in the TCP and UDP dissectors.
Don't add arbitrary UDP ports for which a dissector is found in the
table as ports that should be dissected as TFTP; this should only be
done if we find a packet going from port XXX to the official TFTP port.
Don't register TFTP in UDP's dissector table, as it has to be handled
specially (i.e., we have to add the source port as a TFTP port, although
we really should register the source port *and* IP address); eventually,
we should move that registration to the TFTP dissector itself, at which
point we can register TFTP normally.
svn path=/trunk/; revision=1785
2000-04-04 05:37:36 +00:00
|
|
|
gboolean
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissector_try_port(dissector_table_t sub_dissectors, guint32 port,
|
Make a routine that takes a dissector table, a port number, and
pd/offset/fd/tree arguments, looks up the port number in the dissector
table, and:
if it finds it, call the corresponding dissector routine with
the pd/offset/fd/tree arguments, and return TRUE;
if it doesn't find it, return FALSE.
Use that in the TCP and UDP dissectors.
Don't add arbitrary UDP ports for which a dissector is found in the
table as ports that should be dissected as TFTP; this should only be
done if we find a packet going from port XXX to the official TFTP port.
Don't register TFTP in UDP's dissector table, as it has to be handled
specially (i.e., we have to add the source port as a TFTP port, although
we really should register the source port *and* IP address); eventually,
we should move that registration to the TFTP dissector itself, at which
point we can register TFTP normally.
svn path=/trunk/; revision=1785
2000-04-04 05:37:36 +00:00
|
|
|
const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry_t *dtbl_entry;
|
|
|
|
tvbuff_t *tvb;
|
2001-01-12 09:25:29 +00:00
|
|
|
const char *saved_proto;
|
2001-01-13 04:28:42 +00:00
|
|
|
guint32 saved_match_port;
|
Make a routine that takes a dissector table, a port number, and
pd/offset/fd/tree arguments, looks up the port number in the dissector
table, and:
if it finds it, call the corresponding dissector routine with
the pd/offset/fd/tree arguments, and return TRUE;
if it doesn't find it, return FALSE.
Use that in the TCP and UDP dissectors.
Don't add arbitrary UDP ports for which a dissector is found in the
table as ports that should be dissected as TFTP; this should only be
done if we find a packet going from port XXX to the official TFTP port.
Don't register TFTP in UDP's dissector table, as it has to be handled
specially (i.e., we have to add the source port as a TFTP port, although
we really should register the source port *and* IP address); eventually,
we should move that registration to the TFTP dissector itself, at which
point we can register TFTP normally.
svn path=/trunk/; revision=1785
2000-04-04 05:37:36 +00:00
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry = g_hash_table_lookup(sub_dissectors,
|
|
|
|
GUINT_TO_POINTER(port));
|
|
|
|
if (dtbl_entry != NULL) {
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
/*
|
|
|
|
* Is this protocol enabled?
|
|
|
|
*/
|
|
|
|
if (dtbl_entry->proto_index != -1 &&
|
|
|
|
!proto_is_protocol_enabled(dtbl_entry->proto_index)) {
|
|
|
|
/*
|
|
|
|
* No - pretend this dissector didn't exist,
|
|
|
|
* so that other dissectors might have a chance
|
|
|
|
* to dissect this packet.
|
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Yes, it's enabled.
|
|
|
|
*/
|
2001-01-12 09:25:29 +00:00
|
|
|
saved_proto = pi.current_proto;
|
2001-01-13 04:28:42 +00:00
|
|
|
saved_match_port = pi.match_port;
|
|
|
|
pi.match_port = port;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (dtbl_entry->is_old_dissector)
|
|
|
|
(*dtbl_entry->dissector.old)(pd, offset, fd, tree);
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Old dissector calling new dissector; use
|
|
|
|
* "tvb_create_from_top()" to remap.
|
|
|
|
*
|
|
|
|
* XXX - what about the "pd" argument? Do
|
|
|
|
* any dissectors not just pass that along and
|
|
|
|
* let the "offset" argument handle stepping
|
|
|
|
* through the packet?
|
|
|
|
*/
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
if (dtbl_entry->proto_index != -1) {
|
|
|
|
pi.current_proto =
|
|
|
|
proto_get_protocol_short_name(dtbl_entry->proto_index);
|
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
tvb = tvb_create_from_top(offset);
|
|
|
|
(*dtbl_entry->dissector.new)(tvb, &pi, tree);
|
|
|
|
}
|
2001-01-12 09:25:29 +00:00
|
|
|
pi.current_proto = saved_proto;
|
2001-01-13 04:28:42 +00:00
|
|
|
pi.match_port = saved_match_port;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
return TRUE;
|
|
|
|
} else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
dissector_try_port(dissector_table_t sub_dissectors, guint32 port,
|
|
|
|
tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
dtbl_entry_t *dtbl_entry;
|
|
|
|
const guint8 *pd;
|
|
|
|
int offset;
|
2001-01-12 09:25:29 +00:00
|
|
|
const char *saved_proto;
|
2001-01-13 04:28:42 +00:00
|
|
|
guint32 saved_match_port;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
|
|
|
|
dtbl_entry = g_hash_table_lookup(sub_dissectors,
|
|
|
|
GUINT_TO_POINTER(port));
|
|
|
|
if (dtbl_entry != NULL) {
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
/*
|
|
|
|
* Is this protocol enabled?
|
|
|
|
*/
|
|
|
|
if (dtbl_entry->proto_index != -1 &&
|
|
|
|
!proto_is_protocol_enabled(dtbl_entry->proto_index)) {
|
|
|
|
/*
|
|
|
|
* No - pretend this dissector didn't exist,
|
|
|
|
* so that other dissectors might have a chance
|
|
|
|
* to dissect this packet.
|
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-01-12 09:25:29 +00:00
|
|
|
/*
|
|
|
|
* Yes, it's enabled.
|
|
|
|
*/
|
|
|
|
saved_proto = pinfo->current_proto;
|
2001-01-13 04:28:42 +00:00
|
|
|
saved_match_port = pinfo->match_port;
|
|
|
|
pinfo->match_port = port;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (dtbl_entry->is_old_dissector) {
|
|
|
|
/*
|
|
|
|
* New dissector calling old dissector; use
|
|
|
|
* "tvb_compat()" to remap.
|
|
|
|
*/
|
|
|
|
tvb_compat(tvb, &pd, &offset);
|
|
|
|
(*dtbl_entry->dissector.old)(pd, offset, pinfo->fd,
|
|
|
|
tree);
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
} else {
|
|
|
|
if (dtbl_entry->proto_index != -1) {
|
|
|
|
pinfo->current_proto =
|
|
|
|
proto_get_protocol_short_name(dtbl_entry->proto_index);
|
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
(*dtbl_entry->dissector.new)(tvb, pinfo, tree);
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
}
|
2001-01-12 09:25:29 +00:00
|
|
|
pinfo->current_proto = saved_proto;
|
2001-01-13 04:28:42 +00:00
|
|
|
pinfo->match_port = saved_match_port;
|
Make a routine that takes a dissector table, a port number, and
pd/offset/fd/tree arguments, looks up the port number in the dissector
table, and:
if it finds it, call the corresponding dissector routine with
the pd/offset/fd/tree arguments, and return TRUE;
if it doesn't find it, return FALSE.
Use that in the TCP and UDP dissectors.
Don't add arbitrary UDP ports for which a dissector is found in the
table as ports that should be dissected as TFTP; this should only be
done if we find a packet going from port XXX to the official TFTP port.
Don't register TFTP in UDP's dissector table, as it has to be handled
specially (i.e., we have to add the source port as a TFTP port, although
we really should register the source port *and* IP address); eventually,
we should move that registration to the TFTP dissector itself, at which
point we can register TFTP normally.
svn path=/trunk/; revision=1785
2000-04-04 05:37:36 +00:00
|
|
|
return TRUE;
|
|
|
|
} else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
dissector_table_t
|
|
|
|
register_dissector_table(const char *name)
|
|
|
|
{
|
|
|
|
dissector_table_t sub_dissectors;
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
/* Create our hash-of-hashes if it doesn't already exist */
|
|
|
|
if (!dissector_tables) {
|
|
|
|
dissector_tables = g_hash_table_new( g_str_hash, g_str_equal );
|
|
|
|
g_assert(dissector_tables);
|
|
|
|
}
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
/* Make sure the registration is unique */
|
|
|
|
g_assert(!g_hash_table_lookup( dissector_tables, name ));
|
2000-04-03 09:24:12 +00:00
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
/* Create and register the dissector table for this name; returns */
|
Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:
udp_dissector_table = register_dissector_table("udp.port");
Because of this different namespace, dissector tables can have names
that are not field names. This is useful for ethertype, since multiple
fields are "ethertypes".
packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)
Although it registers no protocol or field, it registers one dissector table:
ethertype_dissector_table = register_dissector_table("ethertype");
All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.
In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)
Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)
svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
|
|
|
/* a pointer to the dissector table. */
|
|
|
|
sub_dissectors = g_hash_table_new( g_direct_hash, g_direct_equal );
|
|
|
|
g_hash_table_insert( dissector_tables, (gpointer)name, (gpointer) sub_dissectors );
|
|
|
|
return sub_dissectors;
|
2000-04-03 09:24:12 +00:00
|
|
|
}
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
|
|
|
|
static GHashTable *heur_dissector_lists = NULL;
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
/*
|
|
|
|
* XXX - for now, we support having both "old" dissectors, with packet
|
|
|
|
* data pointer, packet offset, frame_data pointer, and protocol tree
|
|
|
|
* pointer arguments, and "new" dissectors, with tvbuff pointer,
|
|
|
|
* packet_info pointer, and protocol tree pointer arguments.
|
|
|
|
*
|
|
|
|
* Nuke this and go back to storing a pointer to the dissector when
|
|
|
|
* the last old-style dissector is gone.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
gboolean is_old_dissector;
|
|
|
|
union {
|
|
|
|
old_heur_dissector_t old;
|
|
|
|
heur_dissector_t new;
|
|
|
|
} dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
int proto_index;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
} heur_dtbl_entry_t;
|
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
/* Finds a heuristic dissector table by field name. */
|
|
|
|
static heur_dissector_list_t *
|
|
|
|
find_heur_dissector_list(const char *name)
|
|
|
|
{
|
|
|
|
g_assert(heur_dissector_lists != NULL);
|
|
|
|
return g_hash_table_lookup(heur_dissector_lists, name);
|
|
|
|
}
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
old_heur_dissector_add(const char *name, old_heur_dissector_t dissector,
|
|
|
|
int proto)
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
{
|
|
|
|
heur_dissector_list_t *sub_dissectors = find_heur_dissector_list(name);
|
|
|
|
heur_dtbl_entry_t *dtbl_entry;
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert(sub_dissectors != NULL);
|
|
|
|
|
|
|
|
dtbl_entry = g_malloc(sizeof (heur_dtbl_entry_t));
|
|
|
|
dtbl_entry->is_old_dissector = TRUE;
|
|
|
|
dtbl_entry->dissector.old = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
dtbl_entry->proto_index = proto;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
|
|
|
|
/* do the table insertion */
|
|
|
|
*sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
|
|
|
|
}
|
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
heur_dissector_add(const char *name, heur_dissector_t dissector, int proto)
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
{
|
|
|
|
heur_dissector_list_t *sub_dissectors = find_heur_dissector_list(name);
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
heur_dtbl_entry_t *dtbl_entry;
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert(sub_dissectors != NULL);
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry = g_malloc(sizeof (heur_dtbl_entry_t));
|
|
|
|
dtbl_entry->is_old_dissector = FALSE;
|
|
|
|
dtbl_entry->dissector.new = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
dtbl_entry->proto_index = proto;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
/* do the table insertion */
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
*sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
}
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
gboolean
|
|
|
|
dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
|
|
|
|
tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2001-01-12 09:25:29 +00:00
|
|
|
gboolean status;
|
|
|
|
const char *saved_proto;
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
GSList *entry;
|
|
|
|
heur_dtbl_entry_t *dtbl_entry;
|
|
|
|
const guint8 *pd = NULL;
|
|
|
|
int offset;
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
|
2001-01-12 09:25:29 +00:00
|
|
|
status = FALSE;
|
|
|
|
saved_proto = pinfo->current_proto;
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
for (entry = sub_dissectors; entry != NULL; entry = g_slist_next(entry)) {
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dtbl_entry = (heur_dtbl_entry_t *)entry->data;
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
if (dtbl_entry->proto_index != -1 &&
|
|
|
|
!proto_is_protocol_enabled(dtbl_entry->proto_index)) {
|
|
|
|
/*
|
|
|
|
* No - don't try this dissector.
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (dtbl_entry->is_old_dissector) {
|
|
|
|
/*
|
|
|
|
* New dissector calling old dissector; use
|
|
|
|
* "tvb_compat()" to remap.
|
|
|
|
*/
|
|
|
|
if (pd == NULL)
|
|
|
|
tvb_compat(tvb, &pd, &offset);
|
|
|
|
if ((*dtbl_entry->dissector.old)(pd, offset, pinfo->fd,
|
2001-01-12 09:25:29 +00:00
|
|
|
tree)) {
|
|
|
|
status = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
} else {
|
2001-01-12 09:25:29 +00:00
|
|
|
if (dtbl_entry->proto_index != -1) {
|
|
|
|
pinfo->current_proto =
|
|
|
|
proto_get_protocol_short_name(dtbl_entry->proto_index);
|
|
|
|
}
|
|
|
|
if ((*dtbl_entry->dissector.new)(tvb, pinfo, tree)) {
|
|
|
|
status = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
}
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
}
|
2001-01-12 09:25:29 +00:00
|
|
|
pinfo->current_proto = saved_proto;
|
|
|
|
return status;
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
register_heur_dissector_list(const char *name, heur_dissector_list_t *sub_dissectors)
|
|
|
|
{
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
/* Create our hash-of-lists if it doesn't already exist */
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
if (heur_dissector_lists == NULL) {
|
|
|
|
heur_dissector_lists = g_hash_table_new(g_str_hash, g_str_equal);
|
|
|
|
g_assert(heur_dissector_lists != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the registration is unique */
|
|
|
|
g_assert(g_hash_table_lookup(heur_dissector_lists, name) == NULL);
|
|
|
|
|
|
|
|
*sub_dissectors = NULL; /* initially empty */
|
|
|
|
g_hash_table_insert(heur_dissector_lists, (gpointer)name,
|
|
|
|
(gpointer) sub_dissectors);
|
Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.
This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow
1) conversations between two ports, both of which have
dissectors associated with them, that have been given to the
wrong dissector to be given to the right dissector;
2) conversations between two ports, neither of which have
dissectors associated with them, to be given to a dissector
(RTP and RTCP, for example, typically run on random ports,
and if you don't have, in a capture, traffic that would say
"OK, traffic between these two hosts and ports will be RTP
traffic", you may have to tell Ethereal explicitly what
protocol the conversation is).
svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GHashTable *conv_dissector_lists = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX - for now, we support having both "old" dissectors, with packet
|
|
|
|
* data pointer, packet offset, frame_data pointer, and protocol tree
|
|
|
|
* pointer arguments, and "new" dissectors, with tvbuff pointer,
|
|
|
|
* packet_info pointer, and protocol tree pointer arguments.
|
|
|
|
*
|
|
|
|
* Nuke this and go back to storing a pointer to the dissector when
|
|
|
|
* the last old-style dissector is gone.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
gboolean is_old_dissector;
|
|
|
|
union {
|
|
|
|
old_dissector_t old;
|
|
|
|
dissector_t new;
|
|
|
|
} dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
int proto_index;
|
Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.
This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow
1) conversations between two ports, both of which have
dissectors associated with them, that have been given to the
wrong dissector to be given to the right dissector;
2) conversations between two ports, neither of which have
dissectors associated with them, to be given to a dissector
(RTP and RTCP, for example, typically run on random ports,
and if you don't have, in a capture, traffic that would say
"OK, traffic between these two hosts and ports will be RTP
traffic", you may have to tell Ethereal explicitly what
protocol the conversation is).
svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +00:00
|
|
|
} conv_dtbl_entry_t;
|
|
|
|
|
|
|
|
/* Finds a conversation dissector table by table name. */
|
|
|
|
static conv_dissector_list_t *
|
|
|
|
find_conv_dissector_list(const char *name)
|
|
|
|
{
|
|
|
|
g_assert(conv_dissector_lists != NULL);
|
|
|
|
return g_hash_table_lookup(conv_dissector_lists, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
old_conv_dissector_add(const char *name, old_dissector_t dissector,
|
|
|
|
int proto)
|
Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.
This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow
1) conversations between two ports, both of which have
dissectors associated with them, that have been given to the
wrong dissector to be given to the right dissector;
2) conversations between two ports, neither of which have
dissectors associated with them, to be given to a dissector
(RTP and RTCP, for example, typically run on random ports,
and if you don't have, in a capture, traffic that would say
"OK, traffic between these two hosts and ports will be RTP
traffic", you may have to tell Ethereal explicitly what
protocol the conversation is).
svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +00:00
|
|
|
{
|
|
|
|
conv_dissector_list_t *sub_dissectors = find_conv_dissector_list(name);
|
|
|
|
conv_dtbl_entry_t *dtbl_entry;
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert(sub_dissectors != NULL);
|
|
|
|
|
|
|
|
dtbl_entry = g_malloc(sizeof (conv_dtbl_entry_t));
|
|
|
|
dtbl_entry->is_old_dissector = TRUE;
|
|
|
|
dtbl_entry->dissector.old = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
dtbl_entry->proto_index = proto;
|
Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.
This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow
1) conversations between two ports, both of which have
dissectors associated with them, that have been given to the
wrong dissector to be given to the right dissector;
2) conversations between two ports, neither of which have
dissectors associated with them, to be given to a dissector
(RTP and RTCP, for example, typically run on random ports,
and if you don't have, in a capture, traffic that would say
"OK, traffic between these two hosts and ports will be RTP
traffic", you may have to tell Ethereal explicitly what
protocol the conversation is).
svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +00:00
|
|
|
|
|
|
|
/* do the table insertion */
|
|
|
|
*sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
conv_dissector_add(const char *name, dissector_t dissector, int proto)
|
Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.
This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow
1) conversations between two ports, both of which have
dissectors associated with them, that have been given to the
wrong dissector to be given to the right dissector;
2) conversations between two ports, neither of which have
dissectors associated with them, to be given to a dissector
(RTP and RTCP, for example, typically run on random ports,
and if you don't have, in a capture, traffic that would say
"OK, traffic between these two hosts and ports will be RTP
traffic", you may have to tell Ethereal explicitly what
protocol the conversation is).
svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +00:00
|
|
|
{
|
|
|
|
conv_dissector_list_t *sub_dissectors = find_conv_dissector_list(name);
|
|
|
|
conv_dtbl_entry_t *dtbl_entry;
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_assert(sub_dissectors != NULL);
|
|
|
|
|
|
|
|
dtbl_entry = g_malloc(sizeof (conv_dtbl_entry_t));
|
|
|
|
dtbl_entry->is_old_dissector = FALSE;
|
|
|
|
dtbl_entry->dissector.new = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
dtbl_entry->proto_index = proto;
|
Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.
This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow
1) conversations between two ports, both of which have
dissectors associated with them, that have been given to the
wrong dissector to be given to the right dissector;
2) conversations between two ports, neither of which have
dissectors associated with them, to be given to a dissector
(RTP and RTCP, for example, typically run on random ports,
and if you don't have, in a capture, traffic that would say
"OK, traffic between these two hosts and ports will be RTP
traffic", you may have to tell Ethereal explicitly what
protocol the conversation is).
svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +00:00
|
|
|
|
|
|
|
/* do the table insertion */
|
|
|
|
*sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
register_conv_dissector_list(const char *name, conv_dissector_list_t *sub_dissectors)
|
|
|
|
{
|
|
|
|
/* Create our hash-of-lists if it doesn't already exist */
|
|
|
|
if (conv_dissector_lists == NULL) {
|
|
|
|
conv_dissector_lists = g_hash_table_new(g_str_hash, g_str_equal);
|
|
|
|
g_assert(conv_dissector_lists != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the registration is unique */
|
|
|
|
g_assert(g_hash_table_lookup(conv_dissector_lists, name) == NULL);
|
|
|
|
|
|
|
|
*sub_dissectors = NULL; /* initially empty */
|
|
|
|
g_hash_table_insert(conv_dissector_lists, (gpointer)name,
|
|
|
|
(gpointer) sub_dissectors);
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
}
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register dissectors by name; used if one dissector always calls a
|
|
|
|
* particular dissector, or if it bases the decision of which dissector
|
|
|
|
* to call on something other than a numerical value or on "try a bunch
|
|
|
|
* of dissectors until one likes the packet".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* List of registered dissectors.
|
|
|
|
*/
|
|
|
|
static GHashTable *registered_dissectors = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An entry in the list of registered dissectors.
|
|
|
|
*/
|
|
|
|
struct dissector_handle {
|
|
|
|
const char *name; /* dissector name */
|
|
|
|
dissector_t dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
int proto_index;
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Find a registered dissector by name. */
|
|
|
|
dissector_handle_t
|
|
|
|
find_dissector(const char *name)
|
|
|
|
{
|
|
|
|
g_assert(registered_dissectors != NULL);
|
|
|
|
return g_hash_table_lookup(registered_dissectors, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register a dissector by name. */
|
|
|
|
void
|
2001-01-09 06:32:10 +00:00
|
|
|
register_dissector(const char *name, dissector_t dissector, int proto)
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
{
|
|
|
|
struct dissector_handle *handle;
|
|
|
|
|
|
|
|
/* Create our hash table if it doesn't already exist */
|
|
|
|
if (registered_dissectors == NULL) {
|
|
|
|
registered_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
|
|
|
|
g_assert(registered_dissectors != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the registration is unique */
|
|
|
|
g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
|
|
|
|
|
|
|
|
handle = g_malloc(sizeof (struct dissector_handle));
|
|
|
|
handle->name = name;
|
|
|
|
handle->dissector = dissector;
|
2001-01-09 06:32:10 +00:00
|
|
|
handle->proto_index = proto;
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
|
|
|
|
g_hash_table_insert(registered_dissectors, (gpointer)name,
|
|
|
|
(gpointer) handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call a dissector through a handle. */
|
|
|
|
void
|
|
|
|
call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
|
|
|
|
packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2001-01-12 09:25:29 +00:00
|
|
|
const char *saved_proto;
|
|
|
|
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
if (handle->proto_index != -1 &&
|
|
|
|
!proto_is_protocol_enabled(handle->proto_index)) {
|
|
|
|
/*
|
|
|
|
* No - just dissect this packet as data.
|
|
|
|
*/
|
|
|
|
dissect_data(tvb, 0, pinfo, tree);
|
|
|
|
}
|
|
|
|
|
2001-01-12 09:25:29 +00:00
|
|
|
saved_proto = pinfo->current_proto;
|
In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table. If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.
In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table. (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet. Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)
In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()". if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.
svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
|
|
|
if (handle->proto_index != -1) {
|
|
|
|
pinfo->current_proto =
|
|
|
|
proto_get_protocol_short_name(handle->proto_index);
|
|
|
|
}
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
(*handle->dissector)(tvb, pinfo, tree);
|
2001-01-12 09:25:29 +00:00
|
|
|
pinfo->current_proto = saved_proto;
|
Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.
This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either
1) a pointer to the dissector is put in the Big Transfer Vector
or
2) some other mechanism for getting a pointer to the dissector
is provided.
This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).
It could also, in the future, perhaps support
disabling of protocols;
setting "pinfo->current_proto";
inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by
having "proto_register_protocol()" take an abbreviation - of the
sort that would be put in, for example, "pinfo->current_proto" -
as an argument;
having the calls to register dissectors take an index returned
by "proto_register_protocol()" as an argument.
The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters. Watch this space.)
Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()". (Next step - see if Ethereal can now compile on
Windows as a result of this.)
svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +00:00
|
|
|
}
|