2 * Routines for ISO/OSI network and transport protocol packet disassembly
3 * Main entrance point and common functions
5 * $Id: packet-osi.c,v 1.44 2001/04/16 10:04:30 guy Exp $
6 * Laurent Deniel <deniel@worldnet.fr>
7 * Ralf Schneider <Ralf.Schneider@t-online.de>
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@zing.org>
11 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifdef HAVE_SYS_TYPES_H
35 # include <sys/types.h>
47 #include "packet-osi.h"
48 #include "packet-isis.h"
49 #include "packet-esis.h"
52 gchar *calc_checksum( tvbuff_t *tvb, int offset, u_int len, u_int checksum) {
61 available_len = tvb_length_remaining( tvb, offset );
62 if ( available_len < len )
63 return( "Not checkable - not all of packet was captured" );
65 buffer = tvb_get_ptr( tvb, offset, len );
66 for ( count = 0; count < len; count++ ) {
67 calc_sum += (u_int) buffer[count];
69 calc_sum %= 255; /* modulo 255 divison */
74 return( "Is wrong" ); /* XXX - what should the checksum be? */
78 /* main entry point */
80 const value_string nlpid_vals[] = {
81 { NLPID_NULL, "NULL" },
82 { NLPID_T_70, "T.70" },
83 { NLPID_X_633, "X.633" },
84 { NLPID_Q_931, "Q.931" },
85 { NLPID_Q_2931, "Q.2931" },
86 { NLPID_Q_2119, "Q.2119" },
87 { NLPID_SNAP, "SNAP" },
88 { NLPID_ISO8473_CLNP, "CLNP" },
89 { NLPID_ISO9542_ESIS, "ESIS" },
90 { NLPID_ISO10589_ISIS, "ISIS" },
91 { NLPID_ISO10747_IDRP, "IDRP" },
92 { NLPID_ISO9542X25_ESIS, "ESIS (X.25)" },
93 { NLPID_ISO10030, "ISO 10030" },
94 { NLPID_ISO11577, "ISO 11577" },
95 { NLPID_COMPRESSED, "Data compression protocol" },
97 { NLPID_IP6, "IPv6" },
102 dissector_table_t osinl_subdissector_table;
104 static void dissect_osi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
108 pinfo->current_proto = "OSI";
110 nlpid = tvb_get_guint8(tvb, 0);
112 /* do lookup with the subdissector table */
113 if (dissector_try_port(osinl_subdissector_table, nlpid, tvb, pinfo, tree))
118 /* ESIS (X.25) is not currently decoded */
120 case NLPID_ISO9542X25_ESIS:
121 if (check_col(pinfo->fd, COL_PROTOCOL)) {
122 col_set_str(pinfo->fd, COL_PROTOCOL, "ESIS (X.25)");
124 dissect_data(tvb, 0, pinfo, tree);
126 case NLPID_ISO10747_IDRP:
127 if (check_col(pinfo->fd, COL_PROTOCOL)) {
128 col_set_str(pinfo->fd, COL_PROTOCOL, "IDRP");
130 dissect_data(tvb, 0, pinfo, tree);
133 if (check_col(pinfo->fd, COL_PROTOCOL)) {
134 col_set_str(pinfo->fd, COL_PROTOCOL, "ISO");
136 if (check_col(pinfo->fd, COL_INFO)) {
137 col_add_fstr(pinfo->fd, COL_INFO, "Unknown ISO protocol (%02x)", nlpid);
139 dissect_data(tvb, 0, pinfo, tree);
145 proto_register_osi(void)
147 /* There's no "OSI" protocol *per se*, but we do register a
148 dissector table so various protocols running at the
149 network layer can register themselves. */
150 osinl_subdissector_table = register_dissector_table("osinl");
154 proto_reg_handoff_osi(void)
156 dissector_add("llc.dsap", SAP_OSINL, dissect_osi, -1);
157 dissector_add("ppp.protocol", PPP_OSI, dissect_osi, -1);
158 dissector_add("null.type", BSD_AF_ISO, dissect_osi, -1);