match_strval > try_val_to_str
[wireshark-wip.git] / plugins / docsis / packet-dpvreq.c
blobcadb81563b566c13e482911e2a6a08eecb165d19
1 /* packet-dpvreq.c
2 * Routines for DOCSIS 3.0 DOCSIS Path Verify Response Message dissection.
3 * Copyright 2010, Guido Reismueller <g.reismueller[AT]avm.de>
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "config.h"
28 #include <epan/packet.h>
30 /* Initialize the protocol and registered fields */
31 static int proto_docsis_dpvreq = -1;
32 static int hf_docsis_dpvreq_tranid = -1;
33 static int hf_docsis_dpvreq_dschan = -1;
34 static int hf_docsis_dpvreq_flags = -1;
35 static int hf_docsis_dpvreq_us_sf = -1;
36 static int hf_docsis_dpvreq_n = -1;
37 static int hf_docsis_dpvreq_start = -1;
38 static int hf_docsis_dpvreq_end = -1;
39 static int hf_docsis_dpvreq_ts_start = -1;
40 static int hf_docsis_dpvreq_ts_end = -1;
42 /* Initialize the subtree pointers */
43 static gint ett_docsis_dpvreq = -1;
45 /* Code to actually dissect the packets */
46 static void
47 dissect_dpvreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
49 proto_item *it;
50 proto_tree *dpvreq_tree = NULL;
51 guint16 transid;
52 guint8 dschan;
54 transid = tvb_get_ntohs (tvb, 0);
55 dschan = tvb_get_guint8 (tvb, 2);
57 col_add_fstr (pinfo->cinfo, COL_INFO,
58 "DOCSIS Path Verify Request: Transaction-Id = %u DS-Ch %d",
59 transid, dschan);
61 if (tree)
63 it =
64 proto_tree_add_protocol_format (tree, proto_docsis_dpvreq, tvb, 0, -1,
65 "DPV Request");
66 dpvreq_tree = proto_item_add_subtree (it, ett_docsis_dpvreq);
67 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_tranid, tvb,
68 0, 2, ENC_BIG_ENDIAN);
69 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_dschan, tvb,
70 2, 1, ENC_BIG_ENDIAN);
71 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_flags, tvb,
72 3, 1, ENC_BIG_ENDIAN);
73 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_us_sf, tvb,
74 4, 4, ENC_BIG_ENDIAN);
75 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_n, tvb,
76 8, 2, ENC_BIG_ENDIAN);
77 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_start, tvb,
78 10, 1, ENC_BIG_ENDIAN);
79 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_end, tvb,
80 11, 1, ENC_BIG_ENDIAN);
81 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_start, tvb,
82 12, 4, ENC_BIG_ENDIAN);
83 proto_tree_add_item (dpvreq_tree, hf_docsis_dpvreq_ts_end, tvb,
84 16, 4, ENC_BIG_ENDIAN);
91 /* Register the protocol with Wireshark */
93 /* this format is require because a script is used to build the C function
94 that calls all the protocol registration.
97 void
98 proto_register_docsis_dpvreq (void)
101 /* Setup list of header fields See Section 1.6.1 for details*/
102 static hf_register_info hf[] = {
103 {&hf_docsis_dpvreq_tranid,
104 {"Transaction Id", "docsis_dpvreq.tranid",
105 FT_UINT16, BASE_DEC, NULL, 0x0,
106 NULL, HFILL}
108 {&hf_docsis_dpvreq_dschan,
109 {"Downstream Channel ID", "docsis_dpvreq.dschan",
110 FT_UINT8, BASE_DEC, NULL, 0x0,
111 NULL, HFILL}
113 {&hf_docsis_dpvreq_flags,
114 {"Flags", "docsis_dpvreq.flags",
115 FT_UINT8, BASE_DEC, NULL, 0x0,
116 NULL, HFILL}
118 {&hf_docsis_dpvreq_us_sf,
119 {"Upstream Service Flow ID", "docsis_dpvreq.us_sf",
120 FT_UINT32, BASE_DEC, NULL, 0x0,
121 NULL, HFILL}
123 {&hf_docsis_dpvreq_n,
124 {"N (Measurement avaraging factor)", "docsis_dpvreq.n",
125 FT_UINT16, BASE_DEC, NULL, 0x0,
126 NULL, HFILL}
128 {&hf_docsis_dpvreq_start,
129 {"Start Reference Point", "docsis_dpvreq.start",
130 FT_UINT8, BASE_DEC, NULL, 0x0,
131 NULL, HFILL}
133 {&hf_docsis_dpvreq_end,
134 {"End Reference Point", "docsis_dpvreq.end",
135 FT_UINT8, BASE_DEC, NULL, 0x0,
136 NULL, HFILL}
138 {&hf_docsis_dpvreq_ts_start,
139 {"Timestamp Start", "docsis_dpvreq.ts_start",
140 FT_UINT32, BASE_DEC, NULL, 0x0,
141 NULL, HFILL}
143 {&hf_docsis_dpvreq_ts_end,
144 {"Timestamp End", "docsis_dpvreq.ts_end",
145 FT_UINT32, BASE_DEC, NULL, 0x0,
146 NULL, HFILL}
150 /* Setup protocol subtree array */
151 static gint *ett[] = {
152 &ett_docsis_dpvreq,
155 /* Register the protocol name and description */
156 proto_docsis_dpvreq =
157 proto_register_protocol ("DOCSIS Path Verify Request",
158 "DOCSIS DPV-REQ", "docsis_dpvreq");
160 /* Required function calls to register the header fields and subtrees used */
161 proto_register_field_array (proto_docsis_dpvreq, hf, array_length (hf));
162 proto_register_subtree_array (ett, array_length (ett));
164 register_dissector ("docsis_dpvreq", dissect_dpvreq, proto_docsis_dpvreq);
168 /* If this dissector uses sub-dissector registration add a registration routine.
169 This format is required because a script is used to find these routines and
170 create the code that calls these routines.
172 void
173 proto_reg_handoff_docsis_dpvreq (void)
175 dissector_handle_t docsis_dpvreq_handle;
177 docsis_dpvreq_handle = find_dissector ("docsis_dpvreq");
178 dissector_add_uint ("docsis_mgmt", 0x27, docsis_dpvreq_handle);