aboutsummaryrefslogtreecommitdiffstats
path: root/packet-rip.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-03-23 03:14:46 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-03-23 03:14:46 +0000
commitef3dfe2077c3fd49997b7d9f3c31ba9f65ff27e2 (patch)
tree50607383870e1a22da46616611b6af517557c1e3 /packet-rip.c
parente3db269e00f32936d8385aa04df895edcbed1547 (diff)
Removed all references to gtk objects from packet*.[ch] files. They now
reference the protocol tree with struct proto_tree and struct proto_item objects. That way, the packet decoding source code file can be used with non-gtk packet decoders, like a curses-based ethereal, e.g. I also re-arranged some of the information in packet.h to more appropriate places (like other packet-*.[ch] files). svn path=/trunk/; revision=223
Diffstat (limited to 'packet-rip.c')
-rw-r--r--packet-rip.c69
1 files changed, 33 insertions, 36 deletions
diff --git a/packet-rip.c b/packet-rip.c
index 368dbf8e9f..b4d3a992e7 100644
--- a/packet-rip.c
+++ b/packet-rip.c
@@ -2,7 +2,7 @@
* Routines for RIPv1 and RIPv2 packet disassembly
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
- * $Id: packet-rip.c,v 1.7 1999/02/05 00:52:19 guy Exp $
+ * $Id: packet-rip.c,v 1.8 1999/03/23 03:14:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -26,10 +26,6 @@
#include "config.h"
-#include <gtk/gtk.h>
-
-#include <stdio.h>
-
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -38,21 +34,22 @@
#include <netinet/in.h>
#endif
-#include "ethereal.h"
+#include <glib.h>
#include "packet.h"
#include "packet-rip.h"
static void dissect_ip_rip_vektor(guint8 version,
- const e_rip_vektor *rip_vektor, int offset, GtkWidget *tree);
+ const e_rip_vektor *rip_vektor, int offset, proto_tree *tree);
static void dissect_rip_authentication(const e_rip_authentication *rip_authentication,
- int offset, GtkWidget *tree);
+ int offset, proto_tree *tree);
void
-dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
+dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_riphdr rip_header;
e_rip_entry rip_entry;
guint16 family;
- GtkWidget *rip_tree = NULL, *ti;
+ proto_tree *rip_tree = NULL;
+ proto_item *ti;
/* we do the range checking of the index when checking wether or not this is a RIP packet */
static char *packet_type[8] = { "never used", "Request", "Response",
@@ -93,14 +90,14 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, packet_type[rip_header.command]);
if (tree) {
- ti = add_item_to_tree(GTK_WIDGET(tree), offset, (fd->cap_len - offset), "Routing Information Protocol");
- rip_tree = gtk_tree_new();
- add_subtree(ti, rip_tree, ETT_RIP);
+ ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset), "Routing Information Protocol");
+ rip_tree = proto_tree_new();
+ proto_item_add_subtree(ti, rip_tree, ETT_RIP);
- add_item_to_tree(rip_tree, offset, 1, "Command: %d (%s)", rip_header.command, packet_type[rip_header.command]);
- add_item_to_tree(rip_tree, offset + 1, 1, "Version: %d", rip_header.version);
+ proto_tree_add_item(rip_tree, offset, 1, "Command: %d (%s)", rip_header.command, packet_type[rip_header.command]);
+ proto_tree_add_item(rip_tree, offset + 1, 1, "Version: %d", rip_header.version);
if(rip_header.version == RIPv2)
- add_item_to_tree(rip_tree, offset + 2 , 2, "Routing Domain: %d", ntohs(rip_header.domain));
+ proto_tree_add_item(rip_tree, offset + 2 , 2, "Routing Domain: %d", ntohs(rip_header.domain));
/* skip header */
offset += RIP_HEADER_LENGTH;
@@ -112,7 +109,7 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
family = ntohs(rip_entry.vektor.family);
switch (family) {
case 2: /* IP */
- ti = add_item_to_tree(GTK_WIDGET(rip_tree), offset,
+ ti = proto_tree_add_item(rip_tree, offset,
RIP_ENTRY_LENGTH, "IP Address: %s, Metric: %ld",
ip_to_str((guint8 *) &(rip_entry.vektor.ip)),
(long)ntohl(rip_entry.vektor.metric));
@@ -120,13 +117,13 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
offset, ti);
break;
case 0xFFFF:
- add_item_to_tree(GTK_WIDGET(rip_tree), offset,
- RIP_ENTRY_LENGTH, "Authention");
+ proto_tree_add_item(rip_tree, offset,
+ RIP_ENTRY_LENGTH, "Authentication");
dissect_rip_authentication(&rip_entry.authentication,
offset, ti);
break;
default:
- add_item_to_tree(GTK_WIDGET(rip_tree), offset,
+ proto_tree_add_item(rip_tree, offset,
RIP_ENTRY_LENGTH, "Unknown address family %u",
family);
break;
@@ -139,44 +136,44 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
static void
dissect_ip_rip_vektor(guint8 version, const e_rip_vektor *rip_vektor,
- int offset, GtkWidget *tree)
+ int offset, proto_tree *tree)
{
- GtkWidget *rip_vektor_tree;
+ proto_tree *rip_vektor_tree;
- rip_vektor_tree = gtk_tree_new();
- add_subtree(tree, rip_vektor_tree, ETT_RIP_VEC);
+ rip_vektor_tree = proto_tree_new();
+ proto_item_add_subtree(tree, rip_vektor_tree, ETT_RIP_VEC);
- add_item_to_tree(rip_vektor_tree, offset, 2, "Address Family ID: IP");
+ proto_tree_add_item(rip_vektor_tree, offset, 2, "Address Family ID: IP");
if(version == RIPv2)
- add_item_to_tree(rip_vektor_tree, offset + 2 , 2, "Route Tag: %d",
+ proto_tree_add_item(rip_vektor_tree, offset + 2 , 2, "Route Tag: %d",
ntohs(rip_vektor->tag));
- add_item_to_tree(rip_vektor_tree, offset + 4, 4, "IP Address: %s",
+ proto_tree_add_item(rip_vektor_tree, offset + 4, 4, "IP Address: %s",
ip_to_str((guint8 *) &(rip_vektor->ip)));
if(version == RIPv2) {
- add_item_to_tree(rip_vektor_tree, offset + 8 , 4, "Netmask: %s",
+ proto_tree_add_item(rip_vektor_tree, offset + 8 , 4, "Netmask: %s",
ip_to_str((guint8 *) &(rip_vektor->mask)));
- add_item_to_tree(rip_vektor_tree, offset + 12, 4, "Next Hop: %s",
+ proto_tree_add_item(rip_vektor_tree, offset + 12, 4, "Next Hop: %s",
ip_to_str((guint8 *) &(rip_vektor->next_hop)));
}
- add_item_to_tree(rip_vektor_tree, offset + 16, 4, "Metric: %ld",
+ proto_tree_add_item(rip_vektor_tree, offset + 16, 4, "Metric: %ld",
(long)ntohl(rip_vektor->metric));
}
static void
dissect_rip_authentication(const e_rip_authentication *rip_authentication,
- int offset, GtkWidget *tree)
+ int offset, proto_tree *tree)
{
- GtkWidget *rip_authentication_tree;
+ proto_tree *rip_authentication_tree;
guint16 authtype;
- rip_authentication_tree = gtk_tree_new();
- add_subtree(tree, rip_authentication_tree, ETT_RIP_VEC);
+ rip_authentication_tree = proto_tree_new();
+ proto_item_add_subtree(tree, rip_authentication_tree, ETT_RIP_VEC);
authtype = ntohs(rip_authentication->authtype);
- add_item_to_tree(rip_authentication_tree, offset + 2, 2,
+ proto_tree_add_item(rip_authentication_tree, offset + 2, 2,
"Authentication type: %u", authtype);
if (authtype == 2)
- add_item_to_tree(rip_authentication_tree, offset + 4 , 16,
+ proto_tree_add_item(rip_authentication_tree, offset + 4 , 16,
"Password: %.16s",
rip_authentication->authentication);
}