* Fixes for problems with the preference initialization code (Guy)
[obnox/wireshark/wip.git] / packet-raw.c
1 /* packet-raw.c
2  * Routines for raw packet disassembly
3  *
4  * $Id: packet-raw.c,v 1.4 1998/10/10 03:32:15 gerald Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  *
9  * This file created and by Mike Hall <mlh@io.com>
10  * Copyright 1998
11  * 
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  * 
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
33 #endif
34
35 #include <gtk/gtk.h>
36 #include <stdio.h>
37 #include <pcap.h>
38
39 #include "ethereal.h"
40 #include "packet.h"
41
42 void
43 dissect_raw( const u_char *pd, frame_data *fd, GtkTree *tree ) {
44   GtkWidget *ti, *fh_tree;
45
46   /* load the top pane info. This should be overwritten by
47      the next protocol in the stack */
48   if(fd->win_info[COL_NUM]) {
49     strcpy(fd->win_info[COL_SOURCE], "N/A" );
50     strcpy(fd->win_info[COL_DESTINATION], "N/A" );
51     strcpy(fd->win_info[COL_INFO], "Raw packet data" );
52   }
53
54   /* populate a tree in the second pane with the status of the link
55      layer (ie none) */
56   if(tree) {
57     ti = add_item_to_tree( GTK_WIDGET(tree), 0, 0,
58                            "Raw packet data (%d on link, %d captured)",
59                            fd->pkt_len, fd->cap_len );
60     fh_tree = gtk_tree_new();
61     add_subtree(ti, fh_tree, ETT_RAW);
62     add_item_to_tree(fh_tree, 0, 0, "No link information available");
63   }
64
65   /* So far, the only time we get raw connection types are with Linux and
66    * Irix PPP connections.  We can't tell what type of data is coming down
67    * the line, so our safest bet is IP. - GCC
68    */
69    
70   /* Currently, the Linux 2.1.xxx PPP driver passes back some of the header
71    * sometimes.  This check should be removed when 2.2 is out.
72    */
73   if (pd[0] == 0xff && pd[1] == 0x03)
74     dissect_ip(pd, 4, fd, tree);
75   else
76     dissect_ip(pd, 0, fd, tree);
77 }
78