forked from osmocom/wireshark
Move the code to handle ISO protocols over TCP/TPKT to packet-osi.c where it belongs.
svn path=/trunk/; revision=19180
This commit is contained in:
parent
bb8ff68e21
commit
d0ee14432c
|
@ -40,7 +40,6 @@
|
|||
#include "packet-osi-options.h"
|
||||
#include "packet-isis.h"
|
||||
#include "packet-esis.h"
|
||||
#include "packet-tpkt.h"
|
||||
#include <epan/nlpid.h>
|
||||
#include <epan/ipproto.h>
|
||||
#include <epan/expert.h>
|
||||
|
@ -139,13 +138,8 @@ static const fragment_items cotp_frag_items = {
|
|||
};
|
||||
|
||||
static dissector_handle_t clnp_handle;
|
||||
static dissector_handle_t clnp_tpkt_handle;
|
||||
static dissector_handle_t data_handle;
|
||||
|
||||
/* desegmentation of OSI over TPKT over TCP */
|
||||
static gboolean tpkt_desegment = FALSE;
|
||||
int global_tcp_port_clnp_over_tpkt = 0;
|
||||
int tcp_port_clnp_over_tpkt = 0;
|
||||
/*
|
||||
* ISO 8473 OSI CLNP definition (see RFC994)
|
||||
*
|
||||
|
@ -168,7 +162,7 @@ int tcp_port_clnp_over_tpkt = 0;
|
|||
|
||||
#define CNF_TYPE 0x1f
|
||||
#define CNF_ERR_OK 0x20
|
||||
#define CNF_MORE_SEGS 0x40
|
||||
#define CNF_MORE_SEGS 0x40
|
||||
#define CNF_SEG_OK 0x80
|
||||
|
||||
#define DT_NPDU 0x1C
|
||||
|
@ -1813,15 +1807,9 @@ static void dissect_ositp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
call_dissector(data_handle,tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
/* Dissect CLNP over TCP over TPKT */
|
||||
static void
|
||||
dissect_clnp_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
dissect_tpkt_encap(tvb, pinfo, tree, tpkt_desegment, clnp_handle);
|
||||
}
|
||||
/*
|
||||
* CLNP part / main entry point
|
||||
*/
|
||||
*/
|
||||
|
||||
static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
|
@ -2131,6 +2119,7 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
/* Continue with COTP if any data.
|
||||
XXX - if this isn't the first Derived PDU of a segmented Initial
|
||||
PDU, skip that? */
|
||||
|
||||
if (nsel == (char)tp_nsap_selector || always_decode_transport) {
|
||||
if (dissect_ositp_internal(next_tvb, pinfo, tree, FALSE)) {
|
||||
pinfo->fragmented = save_fragmented;
|
||||
|
@ -2202,29 +2191,6 @@ cotp_reassemble_init(void)
|
|||
reassembled_table_init(&cotp_reassembled_table);
|
||||
}
|
||||
|
||||
void
|
||||
proto_reg_handoff_clnp(void)
|
||||
{
|
||||
static int clnp_prefs_initialized = FALSE;
|
||||
|
||||
data_handle = find_dissector("data");
|
||||
if (!clnp_prefs_initialized) {
|
||||
clnp_handle = create_dissector_handle(dissect_clnp, proto_clnp);
|
||||
clnp_tpkt_handle = create_dissector_handle(dissect_clnp_tpkt, proto_clnp);
|
||||
clnp_prefs_initialized = TRUE;
|
||||
}else{
|
||||
dissector_delete("tcp.port", tcp_port_clnp_over_tpkt, clnp_tpkt_handle);
|
||||
}
|
||||
|
||||
tcp_port_clnp_over_tpkt = global_tcp_port_clnp_over_tpkt;
|
||||
|
||||
dissector_add("osinl", NLPID_ISO8473_CLNP, clnp_handle);
|
||||
dissector_add("osinl", NLPID_NULL, clnp_handle); /* Inactive subset */
|
||||
dissector_add("x.25.spi", NLPID_ISO8473_CLNP, clnp_handle);
|
||||
dissector_add("tcp.port", global_tcp_port_clnp_over_tpkt, clnp_tpkt_handle);
|
||||
}
|
||||
|
||||
|
||||
void proto_register_clnp(void)
|
||||
{
|
||||
static hf_register_info hf[] = {
|
||||
|
@ -2312,7 +2278,7 @@ void proto_register_clnp(void)
|
|||
register_init_routine(clnp_reassemble_init);
|
||||
register_init_routine(cotp_reassemble_init);
|
||||
|
||||
clnp_module = prefs_register_protocol(proto_clnp, proto_reg_handoff_clnp);
|
||||
clnp_module = prefs_register_protocol(proto_clnp, NULL);
|
||||
prefs_register_uint_preference(clnp_module, "tp_nsap_selector",
|
||||
"NSAP selector for Transport Protocol (last byte in hex)",
|
||||
"NSAP selector for Transport Protocol (last byte in hex)",
|
||||
|
@ -2325,16 +2291,18 @@ void proto_register_clnp(void)
|
|||
"Reassemble segmented CLNP datagrams",
|
||||
"Whether segmented CLNP datagrams should be reassembled",
|
||||
&clnp_reassemble);
|
||||
prefs_register_uint_preference(clnp_module, "tpkt_port",
|
||||
"TCP port for CLNP over TPKT",
|
||||
"TCP port for CLNP over TPKT",
|
||||
10, &global_tcp_port_clnp_over_tpkt);
|
||||
prefs_register_bool_preference(clnp_module, "tpkt_reassemble",
|
||||
"Reassemble segmented TPKT datagrams",
|
||||
"Whether segmented TPKT datagrams should be reassembled",
|
||||
&tpkt_desegment);
|
||||
}
|
||||
|
||||
void
|
||||
proto_reg_handoff_clnp(void)
|
||||
{
|
||||
data_handle = find_dissector("data");
|
||||
|
||||
clnp_handle = create_dissector_handle(dissect_clnp, proto_clnp);
|
||||
dissector_add("osinl", NLPID_ISO8473_CLNP, clnp_handle);
|
||||
dissector_add("osinl", NLPID_NULL, clnp_handle); /* Inactive subset */
|
||||
dissector_add("x.25.spi", NLPID_ISO8473_CLNP, clnp_handle);
|
||||
}
|
||||
|
||||
void proto_register_cotp(void)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <glib.h>
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/llcsaps.h>
|
||||
#include <epan/aftypes.h>
|
||||
|
@ -42,7 +43,16 @@
|
|||
#include "packet-osi.h"
|
||||
#include "packet-isis.h"
|
||||
#include "packet-esis.h"
|
||||
#include "packet-tpkt.h"
|
||||
|
||||
static int proto_osi = -1;
|
||||
static dissector_handle_t osi_handle;
|
||||
static dissector_handle_t osi_tpkt_handle;
|
||||
|
||||
/* Preferences for OSI over TPKT over TCP */
|
||||
static gboolean tpkt_desegment = FALSE;
|
||||
int global_tcp_port_osi_over_tpkt = 8473;
|
||||
int tcp_port_osi_over_tpkt = 8473;
|
||||
|
||||
cksum_status_t
|
||||
calc_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum) {
|
||||
|
@ -227,6 +237,13 @@ static dissector_table_t osinl_subdissector_table;
|
|||
static dissector_table_t osinl_excl_subdissector_table;
|
||||
static dissector_handle_t data_handle, ppp_handle;
|
||||
|
||||
/* Dissect OSI over TCP over TPKT */
|
||||
static void
|
||||
dissect_osi_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
dissect_tpkt_encap(tvb, pinfo, tree, tpkt_desegment, osi_handle);
|
||||
}
|
||||
|
||||
static void dissect_osi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
guint8 nlpid;
|
||||
|
@ -239,7 +256,6 @@ static void dissect_osi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
/* try lookup with the subdissector tables that includes the nlpid */
|
||||
if (dissector_try_port(osinl_subdissector_table, nlpid, tvb, pinfo, tree))
|
||||
return;
|
||||
|
||||
/* try lookup with the subdissector tables that excludes the nlpid */
|
||||
new_tvb = tvb_new_subset(tvb, 1, -1, -1);
|
||||
if (dissector_try_port(osinl_excl_subdissector_table, nlpid, new_tvb, pinfo, tree))
|
||||
|
@ -273,14 +289,44 @@ static void dissect_osi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
}
|
||||
} /* dissect_osi */
|
||||
|
||||
void
|
||||
proto_reg_handoff_osi(void)
|
||||
{
|
||||
static int osi_prefs_initialized = FALSE;
|
||||
if (!osi_prefs_initialized) {
|
||||
osi_handle = create_dissector_handle(dissect_osi, proto_osi);
|
||||
dissector_add("llc.dsap", SAP_OSINL1, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL2, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL3, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL4, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL5, osi_handle);
|
||||
dissector_add("ppp.protocol", PPP_OSI, osi_handle);
|
||||
dissector_add("chdlctype", CHDLCTYPE_OSI, osi_handle);
|
||||
dissector_add("null.type", BSD_AF_ISO, osi_handle);
|
||||
dissector_add("gre.proto", SAP_OSINL5, osi_handle);
|
||||
data_handle = find_dissector("data");
|
||||
ppp_handle = find_dissector("ppp");
|
||||
osi_tpkt_handle = create_dissector_handle(dissect_osi_tpkt, proto_osi);
|
||||
osi_prefs_initialized = TRUE;
|
||||
}else{
|
||||
dissector_delete("tcp.port", tcp_port_osi_over_tpkt, osi_tpkt_handle);
|
||||
}
|
||||
|
||||
tcp_port_osi_over_tpkt = global_tcp_port_osi_over_tpkt;
|
||||
dissector_add("tcp.port", global_tcp_port_osi_over_tpkt, osi_tpkt_handle);
|
||||
}
|
||||
|
||||
void
|
||||
proto_register_osi(void)
|
||||
{
|
||||
module_t *osi_module;
|
||||
|
||||
/* There's no "OSI" protocol *per se*, but we do register a
|
||||
dissector table so various protocols running at the
|
||||
network layer can register themselves.
|
||||
all protocols that require inclusion of the NLPID
|
||||
should register here */
|
||||
all protocols that require inclusion of the NLPID
|
||||
should register here
|
||||
*/
|
||||
osinl_subdissector_table = register_dissector_table("osinl",
|
||||
"OSI incl NLPID", FT_UINT8, BASE_HEX);
|
||||
|
||||
|
@ -289,23 +335,19 @@ proto_register_osi(void)
|
|||
* (typically non OSI protocols like IP,IPv6,PPP */
|
||||
osinl_excl_subdissector_table = register_dissector_table("osinl.excl",
|
||||
"OSI excl NLPID", FT_UINT8, BASE_HEX);
|
||||
|
||||
proto_osi = proto_register_protocol("OSI", "OSI", "osi");
|
||||
/* Preferences how OSI protocols should be dissected */
|
||||
osi_module = prefs_register_protocol(proto_osi, proto_reg_handoff_osi);
|
||||
|
||||
prefs_register_uint_preference(osi_module, "tpkt_port",
|
||||
"TCP port for OSI over TPKT",
|
||||
"TCP port for OSI over TPKT",
|
||||
10, &global_tcp_port_osi_over_tpkt);
|
||||
prefs_register_bool_preference(osi_module, "tpkt_reassemble",
|
||||
"Reassemble segmented TPKT datagrams",
|
||||
"Whether segmented TPKT datagrams should be reassembled",
|
||||
&tpkt_desegment);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
proto_reg_handoff_osi(void)
|
||||
{
|
||||
dissector_handle_t osi_handle;
|
||||
|
||||
osi_handle = create_dissector_handle(dissect_osi, -1);
|
||||
dissector_add("llc.dsap", SAP_OSINL1, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL2, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL3, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL4, osi_handle);
|
||||
dissector_add("llc.dsap", SAP_OSINL5, osi_handle);
|
||||
dissector_add("ppp.protocol", PPP_OSI, osi_handle);
|
||||
dissector_add("chdlctype", CHDLCTYPE_OSI, osi_handle);
|
||||
dissector_add("null.type", BSD_AF_ISO, osi_handle);
|
||||
dissector_add("gre.proto", SAP_OSINL5, osi_handle);
|
||||
data_handle = find_dissector("data");
|
||||
ppp_handle = find_dissector("ppp");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue