Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-oipf.c
blob358f168674e57639f439304f566705721e6d9a25
1 /* packet-oipf.c
2 * Dissector for Open IPTV Forum protocols
3 * Copyright 2012, Martin Kaiser <martin@kaiser.cx>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 /* This dissector supports the CI+ Content and Service Protection Gateway
13 (CSPG-CI+) as defined in in Open IPTV Forum Specification Volume 7 V2.1
14 http://www.openiptvforum.org/release_2.html */
16 #include "config.h"
18 #include <epan/packet.h>
20 void proto_register_oipf(void);
21 void proto_reg_handoff_oipf(void);
23 static dissector_handle_t oipf_ciplus_handle;
25 static int proto_oipf_ciplus;
27 static int ett_oipf_ciplus;
29 static int hf_oipf_ciplus_cmd_id;
30 static int hf_oipf_ciplus_ca_sys_id;
31 static int hf_oipf_ciplus_trx_id;
32 static int hf_oipf_ciplus_send_datatype_nbr;
33 static int hf_oipf_ciplus_dat_id;
34 static int hf_oipf_ciplus_dat_len;
35 static int hf_oipf_ciplus_data;
37 /* the application id for this protocol in the CI+ SAS resource
38 this is actually a 64bit hex number, we can't use a 64bit number as a key
39 for the dissector table directly, we have to process it as a string
40 (the string must not be a local variable as glib stores a pointer to
41 it in the hash table) */
42 static const char sas_app_id_str_oipf[] = "0x0108113101190000";
44 static const value_string oipf_ciplus_cmd_id[] = {
45 { 0x01, "send_msg" },
46 { 0x02, "reply_msg" },
47 { 0x03, "parental_control_info" },
48 { 0x04, "rights_info" },
49 { 0x05, "system_info" },
50 { 0, NULL }
53 static const value_string oipf_ciplus_dat_id[] = {
54 { 0x01, "oipf_ca_vendor_specific_information" },
55 { 0x02, "oipf_country_code" },
56 { 0x03, "oipf_parental_control_url" },
57 { 0x04, "oipf_rating_type" },
58 { 0x05, "oipf_rating_value" },
59 { 0x06, "oipf_rights_issuer_url" },
60 { 0x07, "oipf_access_status" },
61 { 0x08, "oipf_status" },
62 { 0, NULL }
66 static int
67 dissect_oipf_ciplus(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
69 int msg_len;
70 proto_tree *oipf_ciplus_tree;
71 unsigned offset = 0;
72 uint8_t i, send_datatype_nbr;
73 uint16_t dat_len;
75 /* an OIPF CI+ message minimally contains command_id (1 byte),
76 ca sys id (2 bytes), transaction id (4 bytes) and
77 number of sent datatypes (1 byte) */
78 msg_len = tvb_reported_length(tvb);
79 if (msg_len < 8)
80 return 0;
82 oipf_ciplus_tree = proto_tree_add_subtree(tree, tvb, 0, msg_len, ett_oipf_ciplus, NULL, "Open IPTV Forum CSPG-CI+");
84 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_cmd_id,
85 tvb, offset, 1, ENC_BIG_ENDIAN);
86 offset++;
87 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_ca_sys_id,
88 tvb, offset, 2, ENC_BIG_ENDIAN);
89 offset += 2;
90 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_trx_id,
91 tvb, offset, 4, ENC_BIG_ENDIAN);
92 offset += 4;
94 send_datatype_nbr = tvb_get_uint8(tvb, offset);
95 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_send_datatype_nbr,
96 tvb, offset, 1, ENC_BIG_ENDIAN);
97 offset++;
99 for (i=0; i<send_datatype_nbr; i++) {
100 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_dat_id,
101 tvb, offset, 1, ENC_BIG_ENDIAN);
102 offset++;
104 dat_len = tvb_get_ntohs(tvb, offset);
105 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_dat_len,
106 tvb, offset, 2, ENC_BIG_ENDIAN);
107 offset += 2;
109 proto_tree_add_item(oipf_ciplus_tree, hf_oipf_ciplus_data,
110 tvb, offset, dat_len, ENC_NA);
111 offset += dat_len;
114 return offset;
117 void
118 proto_register_oipf(void)
120 static int *ett[] = {
121 &ett_oipf_ciplus
124 static hf_register_info hf[] = {
125 { &hf_oipf_ciplus_cmd_id,
126 { "Command ID", "oipf.ciplus.cmd_id", FT_UINT8, BASE_HEX,
127 VALS(oipf_ciplus_cmd_id), 0, NULL, HFILL } },
128 { &hf_oipf_ciplus_ca_sys_id,
129 { "CA system ID", "oipf.ciplus.ca_system_id", FT_UINT16, BASE_HEX,
130 NULL, 0, NULL, HFILL } },
131 { &hf_oipf_ciplus_trx_id,
132 { "Transaction ID", "oipf.ciplus.transaction_id",
133 FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },
134 { &hf_oipf_ciplus_send_datatype_nbr,
135 { "Number of data items", "oipf.ciplus.num_items", FT_UINT8,
136 BASE_DEC, NULL, 0, NULL, HFILL } },
137 { &hf_oipf_ciplus_dat_id,
138 { "Datatype ID", "oipf.ciplus.datatype_id", FT_UINT8, BASE_HEX,
139 VALS(oipf_ciplus_dat_id), 0, NULL, HFILL } },
140 { &hf_oipf_ciplus_dat_len,
141 { "Datatype length", "oipf.ciplus.datatype_len", FT_UINT16,
142 BASE_DEC, NULL, 0, NULL, HFILL } },
143 { &hf_oipf_ciplus_data,
144 { "Data", "oipf.ciplus.data", FT_BYTES, BASE_NONE,
145 NULL, 0, NULL, HFILL } }
148 proto_oipf_ciplus = proto_register_protocol("Open IPTV Forum CSPG-CI+", "OIPF CI+", "oipf.ciplus");
149 proto_register_field_array(proto_oipf_ciplus, hf, array_length(hf));
150 proto_register_subtree_array(ett, array_length(ett));
152 oipf_ciplus_handle = register_dissector("oipf.ciplus", dissect_oipf_ciplus, proto_oipf_ciplus);
155 void
156 proto_reg_handoff_oipf(void)
158 dissector_add_string("dvb-ci.sas.app_id_str",
159 sas_app_id_str_oipf, oipf_ciplus_handle);
163 * Editor modelines - https://www.wireshark.org/tools/modelines.html
165 * Local variables:
166 * c-basic-offset: 4
167 * tab-width: 8
168 * indent-tabs-mode: nil
169 * End:
171 * vi: set shiftwidth=4 tabstop=8 expandtab:
172 * :indentSize=4:tabSize=8:noTabs=true: