Make "make-reg-dotc" generate a "register_all_protocol_handoffs()"
routine, which calls all routines found in the dissector source files with names that match " proto_reg_handoff_[a-z_0-9A-Z]*". Call "register_all_protocol_handoffs()" after calling "register_all_protocols()" - "register_all_protocols()" needs to be called first, so that all protocols can register their fields, because registering a dissector as being called if field "proto.port" is equal to N requires that "proto.port" be a registered field. Give DNS a handoff registration routine, and register its dissector to be called if "udp.port" is UDP_PORT_DNS; remove the registration of DNS from "packet-udp.c", and make "dissect_dns()" static (as nobody else need know that it exists). svn path=/trunk/; revision=1788
This commit is contained in:
parent
e6d47076b8
commit
1ffa3cfa2b
|
@ -13,6 +13,10 @@ rm -f register.c-tmp
|
|||
echo '/* Do not modify this file. */' >register.c-tmp
|
||||
echo '/* It is created automatically by the Makefile. */'>>register.c-tmp
|
||||
echo '#include "register.h"' >>register.c-tmp
|
||||
|
||||
#
|
||||
# Build code to call all the protocol registration routines.
|
||||
#
|
||||
echo 'void register_all_protocols(void) {' >>register.c-tmp
|
||||
for f in "$@"
|
||||
do
|
||||
|
@ -23,4 +27,18 @@ do
|
|||
grep '^void proto_register_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
|
||||
done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
|
||||
echo '}' >>register.c-tmp
|
||||
|
||||
#
|
||||
# Build code to call all the protocol handoff registration routines.
|
||||
#
|
||||
echo 'void register_all_protocol_handoffs(void) {' >>register.c-tmp
|
||||
for f in "$@"
|
||||
do
|
||||
grep '^proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
|
||||
done | sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
|
||||
for f in "$@"
|
||||
do
|
||||
grep '^void proto_reg_handoff_[a-z_0-9A-Z]* *(' $srcdir/$f 2>/dev/null
|
||||
done | sed -e 's/^.*://' -e 's/^void \([a-z_0-9A-Z]*\).*/ {extern void \1 (void); \1 ();}/' >>register.c-tmp
|
||||
echo '}' >>register.c-tmp
|
||||
mv register.c-tmp register.c
|
||||
|
|
13
packet-dns.c
13
packet-dns.c
|
@ -1,7 +1,7 @@
|
|||
/* packet-dns.c
|
||||
* Routines for DNS packet disassembly
|
||||
*
|
||||
* $Id: packet-dns.c,v 1.40 2000/03/30 01:52:39 guy Exp $
|
||||
* $Id: packet-dns.c,v 1.41 2000/04/04 06:17:28 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -61,6 +61,9 @@ static gint ett_t_key_flags = -1;
|
|||
|
||||
/* DNS structs and definitions */
|
||||
|
||||
/* Port used for DNS. */
|
||||
#define UDP_PORT_DNS 53
|
||||
|
||||
/* Offsets of fields in the DNS header. */
|
||||
#define DNS_ID 0
|
||||
#define DNS_FLAGS 2
|
||||
|
@ -1483,7 +1486,7 @@ dissect_answer_records(const u_char *pd, int cur_off, int dns_data_offset,
|
|||
return cur_off - start_off;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
dissect_dns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
int dns_data_offset;
|
||||
|
@ -1696,3 +1699,9 @@ proto_register_dns(void)
|
|||
proto_register_field_array(proto_dns, hf, array_length(hf));
|
||||
proto_register_subtree_array(ett, array_length(ett));
|
||||
}
|
||||
|
||||
void
|
||||
proto_reg_handoff_dns(void)
|
||||
{
|
||||
dissector_add("udp.port", UDP_PORT_DNS, dissect_dns);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Definitions for packet disassembly structures and routines used both by
|
||||
* DNS and NBNS.
|
||||
*
|
||||
* $Id: packet-dns.h,v 1.7 2000/03/30 01:52:40 guy Exp $
|
||||
* $Id: packet-dns.h,v 1.8 2000/04/04 06:17:28 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -40,6 +40,4 @@ add_rr_to_tree(proto_item *trr, int rr_type, int offset, const char *name,
|
|||
int namelen, const char *type_name, const char *class_name, u_int ttl,
|
||||
u_short data_len);
|
||||
|
||||
void dissect_dns(const u_char *, int, frame_data *, proto_tree *);
|
||||
|
||||
#endif /* packet-dns.h */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-udp.c
|
||||
* Routines for UDP packet disassembly
|
||||
*
|
||||
* $Id: packet-udp.c,v 1.56 2000/04/04 05:54:59 guy Exp $
|
||||
* $Id: packet-udp.c,v 1.57 2000/04/04 06:17:29 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -49,7 +49,6 @@
|
|||
#include "packet-auto_rp.h"
|
||||
#include "packet-bootp.h"
|
||||
#include "packet-dhis.h"
|
||||
#include "packet-dns.h"
|
||||
#include "packet-hsrp.h"
|
||||
#include "packet-icp.h"
|
||||
#include "packet-icq.h"
|
||||
|
@ -96,7 +95,6 @@ typedef struct _e_udphdr {
|
|||
|
||||
#define UDP_PORT_TIME 37
|
||||
#define UDP_PORT_TACACS 49
|
||||
#define UDP_PORT_DNS 53
|
||||
#define UDP_PORT_BOOTPS 67
|
||||
#define UDP_PORT_TFTP 69
|
||||
#define UDP_PORT_NTP 123
|
||||
|
@ -275,7 +273,6 @@ proto_register_udp(void)
|
|||
|
||||
dissector_add("udp.port", UDP_PORT_TIME, dissect_time);
|
||||
dissector_add("udp.port", UDP_PORT_TACACS, dissect_tacacs);
|
||||
dissector_add("udp.port", UDP_PORT_DNS, dissect_dns);
|
||||
dissector_add("udp.port", UDP_PORT_BOOTPS, dissect_bootp);
|
||||
dissector_add("udp.port", UDP_PORT_NTP, dissect_ntp);
|
||||
dissector_add("udp.port", UDP_PORT_NBNS, dissect_nbns);
|
||||
|
|
10
proto.c
10
proto.c
|
@ -1,7 +1,7 @@
|
|||
/* proto.c
|
||||
* Routines for protocol tree
|
||||
*
|
||||
* $Id: proto.c,v 1.58 2000/04/04 02:34:39 gram Exp $
|
||||
* $Id: proto.c,v 1.59 2000/04/04 06:17:29 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -193,9 +193,15 @@ proto_init(void)
|
|||
tree_is_expanded[0] = FALSE;
|
||||
num_tree_types = 1;
|
||||
|
||||
/* Have each dissector register its protocols and fields. */
|
||||
/* Have each dissector register its protocols and fields, and
|
||||
do whatever one-time initialization it needs to do. */
|
||||
register_all_protocols();
|
||||
|
||||
/* Now have the ones that register a "handoff", i.e. that
|
||||
specify that another dissector for a protocol under which
|
||||
this dissector's protocol lives call it. */
|
||||
register_all_protocol_handoffs();
|
||||
|
||||
/* Register one special-case FT_TEXT_ONLY field for use when
|
||||
converting ethereal to new-style proto_tree. These fields
|
||||
are merely strings on the GUI tree; they are not filterable */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* register.h
|
||||
* Definitions for protocol registration
|
||||
*
|
||||
* $Id: register.h,v 1.1 1999/10/20 06:28:29 guy Exp $
|
||||
* $Id: register.h,v 1.2 2000/04/04 06:17:30 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -27,5 +27,6 @@
|
|||
#define __REGISTER_H__
|
||||
|
||||
extern void register_all_protocols(void);
|
||||
extern void register_all_protocol_handoffs(void);
|
||||
|
||||
#endif /* __REGISTER_H__ */
|
||||
|
|
Loading…
Reference in New Issue