Stuart Stanley's ISIS dissection support.
[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.11 1999/11/16 11:42:50 guy 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 <glib.h>
36 #include "packet.h"
37
38 static gint ett_raw = -1;
39
40 void
41 capture_raw( const u_char *pd, guint32 cap_len, packet_counts *ld ) {
42
43   /* So far, the only time we get raw connection types are with Linux and
44    * Irix PPP connections.  We can't tell what type of data is coming down
45    * the line, so our safest bet is IP. - GCC
46    */
47    
48   /* Currently, the Linux 2.1.xxx PPP driver passes back some of the header
49    * sometimes.  This check should be removed when 2.2 is out.
50    */
51   if (pd[0] == 0xff && pd[1] == 0x03)
52     capture_ip(pd, 4, cap_len, ld);
53   else
54     capture_ip(pd, 0, cap_len, ld);
55 }
56
57 void
58 dissect_raw( const u_char *pd, frame_data *fd, proto_tree *tree ) {
59   proto_tree *fh_tree;
60   proto_item *ti;
61
62   /* load the top pane info. This should be overwritten by
63      the next protocol in the stack */
64   if(check_col(fd, COL_RES_DL_SRC))
65     col_add_str(fd, COL_RES_DL_SRC, "N/A" );
66   if(check_col(fd, COL_RES_DL_DST))
67     col_add_str(fd, COL_RES_DL_DST, "N/A" );
68   if(check_col(fd, COL_PROTOCOL))
69     col_add_str(fd, COL_PROTOCOL, "N/A" );
70   if(check_col(fd, COL_INFO))
71     col_add_str(fd, COL_INFO, "Raw packet data" );
72
73   /* populate a tree in the second pane with the status of the link
74      layer (ie none) */
75   if(tree) {
76     ti = proto_tree_add_text(tree, 0, 0, "Raw packet data" );
77     fh_tree = proto_item_add_subtree(ti, ett_raw);
78     proto_tree_add_text(fh_tree, 0, 0, "No link information available");
79   }
80
81   /* So far, the only time we get raw connection types are with Linux and
82    * Irix PPP connections.  We can't tell what type of data is coming down
83    * the line, so our safest bet is IP. - GCC
84    */
85    
86   /* Currently, the Linux 2.1.xxx PPP driver passes back some of the header
87    * sometimes.  This check should be removed when 2.2 is out.
88    */
89   if (pd[0] == 0xff && pd[1] == 0x03)
90     dissect_ip(pd, 4, fd, tree);
91   else
92     dissect_ip(pd, 0, fd, tree);
93 }
94
95 void
96 proto_register_raw(void)
97 {
98   static gint *ett[] = {
99     &ett_raw,
100   };
101
102   proto_register_subtree_array(ett, array_length(ett));
103 }