2 * Routines for Decoding Network_Header for IP-over-FC when we only
3 * capture the frame starting at the Network_Header (as opposed to
4 * when we have the full FC frame).
6 * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
8 * $Id: packet-ipfc.c,v 1.6 2003/01/21 05:21:03 guy Exp $
10 * Ethereal - Network traffic analyzer
11 * By Gerald Combs <gerald@ethereal.com>
12 * 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.
39 #include <epan/packet.h>
41 #include "packet-fc.h"
42 #include "packet-ipfc.h"
43 #include "packet-llc.h"
45 /* Initialize the protocol and registered fields */
46 static int proto_ipfc = -1;
47 static int hf_ipfc_network_da = -1;
48 static int hf_ipfc_network_sa = -1;
50 /* Initialize the subtree pointers */
51 static gint ett_ipfc = -1;
52 static dissector_handle_t llc_handle;
55 capture_ipfc (const guchar *pd, int len, packet_counts *ld)
57 if (!BYTES_ARE_IN_FRAME(0, len, 16)) {
62 capture_llc(pd, 16, len, ld);
66 dissect_ipfc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
69 /* Set up structures needed to add the protocol subtree and manage it */
71 proto_tree *ipfc_tree;
75 /* Make entries in Protocol column and Info column on summary display */
76 if (check_col(pinfo->cinfo, COL_PROTOCOL))
77 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP/FC");
80 ti = proto_tree_add_protocol_format (tree, proto_ipfc, tvb, offset, 16,
81 "IP Over FC Network_Header");
82 ipfc_tree = proto_item_add_subtree (ti, ett_ipfc);
84 proto_tree_add_string (ipfc_tree, hf_ipfc_network_da, tvb, offset, 8,
85 fcwwn_to_str (tvb_get_ptr (tvb, offset, 8)));
86 proto_tree_add_string (ipfc_tree, hf_ipfc_network_sa, tvb, offset+8, 8,
87 fcwwn_to_str (tvb_get_ptr (tvb, offset+8, 8)));
90 next_tvb = tvb_new_subset (tvb, 16, -1, -1);
91 call_dissector(llc_handle, next_tvb, pinfo, tree);
94 /* Register the protocol with Ethereal */
96 /* this format is require because a script is used to build the C function
97 that calls all the protocol registration.
101 proto_register_ipfc (void)
104 /* Setup list of header fields See Section 1.6.1 for details*/
105 static hf_register_info hf[] = {
106 { &hf_ipfc_network_da,
107 {"Network DA", "ipfc.nh.da", FT_STRING, BASE_HEX, NULL,
109 { &hf_ipfc_network_sa,
110 {"Network SA", "ipfc.nh.sa", FT_STRING, BASE_HEX, NULL,
114 /* Setup protocol subtree array */
115 static gint *ett[] = {
119 /* Register the protocol name and description */
120 proto_ipfc = proto_register_protocol("IP Over FC", "IPFC", "ipfc");
122 /* Required function calls to register the header fields and subtrees used */
123 proto_register_field_array(proto_ipfc, hf, array_length(hf));
124 proto_register_subtree_array(ett, array_length(ett));
127 /* If this dissector uses sub-dissector registration add a registration routine.
128 This format is required because a script is used to find these routines and
129 create the code that calls these routines.
132 proto_reg_handoff_ipfc (void)
134 dissector_handle_t ipfc_handle;
136 ipfc_handle = create_dissector_handle (dissect_ipfc, proto_ipfc);
137 dissector_add("wtap_encap", WTAP_ENCAP_IP_OVER_FC, ipfc_handle);
139 llc_handle = find_dissector ("llc");