1 /* packet-lnpdqp-template.c
2 * Routines for Local Number Portability Database Query Protocol dissection
4 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <epan/packet.h>
13 #include <epan/asn1.h>
14 #include <wsutil/array.h>
15 #include "packet-ber.h"
17 #define PNAME "Local Number Portability Database Query"
18 #define PSNAME "LNPDQP"
19 #define PFNAME "lnpdqp"
22 * Operation Code is partitioned into:
23 * Operation Family = ConnectionControl, no Reply Required (4)
24 * Operation Specifier = Connect (1)
26 #define LNPDQP_ANSI_TCAP_OPCODE_CC 0x0401
28 * Operation Code is partitioned into:
29 * Operation Family = ProvideInstruction, Reply Required (131) 0x83
30 * Operation Specifier = Start (1)
33 #define LNPDQP_ANSI_TCAP_OPCODE_PI 0x0301
35 void proto_reg_handoff_lnpdqp(void);
36 void proto_register_lnpdqp(void);
38 /* Initialize the protocol and registered fields */
39 static int proto_lnpdqp
;
42 static int hf_lnpdqp_type_of_digits
;
43 static int hf_lnpdqp_nature_of_number
;
44 static int hf_lnpdqp_digits_enc
;
45 static int hf_lnpdqp_np
;
46 static int hf_lnpdqp_nr_digits
;
47 static int hf_lnpdqp_bcd_digits
;
48 static int hf_lnpdqp_ia5_digits
;
50 /* asn2wrs/the ber dissector does not handle the same tag used multiple times
51 * in asn1 description, do some magic to handle.
53 static int hf_lnpdqp_networkRoutingNumber
; /* Digits */
54 static int hf_lnpdqp_callingPartyANI
; /* Digits */
55 static int hf_lnpdqp_originatingLATA
; /* Digits */
56 static int hf_lnpdqp_carrierID
; /* Digits */
58 #include "packet-lnpdqp-hf.c"
60 static int ett_lnpdqp
;
61 static int ett_lnpdqp_digitstype
;
62 static int ett_lnpdqp_digits
;
63 #include "packet-lnpdqp-ett.c"
66 /* Type of Digits (octet 1, bits A-H) */
67 static const value_string lnpdqp_type_of_digits_vals
[] = {
69 { 1, "Dialed Number or Called Party Number" },
70 { 2, "Calling Party Number" },
71 { 3, "Caller Interaction" },
72 { 4, "Routing Number" },
73 { 5, "Billing Number" },
74 { 6, "Destination Number" },
77 { 9, "Last Calling Party" },
78 { 10, "Last Party Called" },
79 { 11, "Calling Directory Number" },
80 { 12, "VMSR Identifier" },
81 { 13, "Original Called Number" },
82 { 14, "Redirecting Number" },
83 { 15, "Connected Number" },
89 /* Nature of Number (octet 2, bits A-H )*/
90 static const true_false_string lnpdqp_na_bool_val
= {
94 static const true_false_string lnpdqp_pi_bool_val
= {
95 "Presentation Restricted",
96 "Presentation Allowed"
98 static const true_false_string lnpdqp_navail_bool_val
= {
99 "Number is not available",
100 "Number is available"
102 static const true_false_string lnpdqp_si_bool_val
= {
103 "User provided, screening passed",
104 "User provided, not screened"
107 static const value_string lnpdqp_na_vals
[] = {
108 { 0, "National, No Presentation Restricted"},
109 { 1, "International, No Presentation Restricted"},
110 { 2, "National, Presentation Restricted"},
111 { 3, "International, Presentation Restricted"},
114 /* Encoding (octet 3, bits A-D) */
115 static const value_string lnpdqp_digits_enc_vals
[] = {
119 { 3, "Octet string"},
122 /* Numbering Plan (octet 3, bits E-H) */
123 static const value_string lnpdqp_np_vals
[] = {
124 { 0, "Unknown or not applicable"},
125 { 1, "ISDN Numbering Plan (ITU Rec. E.164)"},
126 { 2, "Telephony Numbering (ITU-T Rec. E.164,E.163)"},
127 { 3, "Data Numbering (ITU-T Rec. X.121)"},
128 { 4, "Telex Numbering (ITU-T Rec. F.69)"},
129 { 5, "Maritime Mobile Numbering"},
130 { 6, "Land Mobile Numbering (ITU-T Rec. E.212)"},
131 { 7, "Private Numbering Plan"},
136 * OriginatingStationType ::= OCTET STRING (SIZE(1))
137 * The following codes are used in the originating line information field:
138 * 00000010 } Binary values administered by the North
139 * to } American Numbering Administration
141 * Ref http://www.nanpa.com/number_resource_info/ani_ii_assignments.html
144 static const value_string lnpdqp_OriginatingStationType_vals
[] = {
145 { 0, "Plain Old Telephone Service (POTS) - non-coin service requiring no special treatment"},
146 { 1, "Multiparty line (more than 2) - ANI cannot be provided on 4 or 8 party lines. "},
147 { 2, "ANI Failure "},
148 /* 03-05 Unassigned */
149 { 6, "Station Level Rating "},
150 { 7, "Special Operator Handling Required"},
151 /* 08-09 Unassigned */
152 { 10, "Not assignable - conflict with 10X test code"},
154 /* 12-19 Not assignable - conflict with international outpulsing code */
155 { 20, "Automatic Identified Outward Dialing (AIOD)"},
156 /* 21-22 Unassigned */
157 /* To lasy to do these */
158 { 61, "Cellular/Wireless PCS (Type 1) "},
159 { 62, "Cellular/Wireless PCS (Type 2) "},
160 { 63, "Cellular/Wireless PCS (Roaming)"},
165 dissect_lnpdqp_digits_type(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree _U_
, asn1_ctx_t
*actx _U_
){
167 uint8_t octet
, no_of_digits
;
174 subtree
= proto_item_add_subtree(actx
->created_item
, ett_lnpdqp_digitstype
);
176 /* Octet 1 Type of Digits*/
177 proto_tree_add_item(subtree
, hf_lnpdqp_type_of_digits
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
179 /* Octet 2 Nature of Number*/
180 proto_tree_add_item(subtree
, hf_lnpdqp_nature_of_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
182 /* Octet 3 Numbering Plan |Encoding Scheme| */
183 octet
= tvb_get_uint8(tvb
,offset
);
184 proto_tree_add_item(subtree
, hf_lnpdqp_np
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
185 proto_tree_add_item(subtree
, hf_lnpdqp_digits_enc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
187 /* Octet 4 Number of Digits */
188 switch ((octet
&0xf)){
191 no_of_digits
= tvb_get_uint8(tvb
,offset
);
192 proto_tree_add_item(subtree
, hf_lnpdqp_nr_digits
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
193 if(no_of_digits
== 0)
196 proto_tree_add_item_ret_display_string(subtree
, hf_lnpdqp_bcd_digits
, tvb
, offset
, -1, ENC_KEYPAD_BC_TBCD
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &digit_str
);
197 proto_item_append_text(actx
->created_item
, " - %s", digit_str
);
201 no_of_digits
= tvb_get_uint8(tvb
,offset
);
202 proto_tree_add_item(subtree
, hf_lnpdqp_nr_digits
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
203 if(no_of_digits
== 0)
206 proto_tree_add_item(subtree
, hf_lnpdqp_ia5_digits
, tvb
, offset
, -1, ENC_ASCII
);
207 proto_item_append_text(actx
->created_item
, " - %s", tvb_get_string_enc(pinfo
->pool
,tvb
,offset
,tvb_reported_length_remaining(tvb
,offset
), ENC_ASCII
| ENC_NA
));
216 #include "packet-lnpdqp-fn.c"
219 dissect_lnpdqp_cc(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void *data _U_
)
221 proto_item
*item
=NULL
;
222 proto_tree
*tree
=NULL
;
225 asn1_ctx_init(&asn1_ctx
, ASN1_ENC_BER
, true, pinfo
);
227 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, PSNAME
);
228 col_set_str(pinfo
->cinfo
, COL_INFO
, "ConnectionControl");
231 /* create display subtree for the protocol */
232 item
= proto_tree_add_item(parent_tree
, proto_lnpdqp
, tvb
, 0, -1, ENC_NA
);
233 tree
= proto_item_add_subtree(item
, ett_lnpdqp
);
235 return dissect_ConnectionControlArg_PDU(tvb
, pinfo
, tree
, NULL
);
239 dissect_lnpdqp_pi(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void *data _U_
)
241 proto_item
*item
=NULL
;
242 proto_tree
*tree
=NULL
;
245 asn1_ctx_init(&asn1_ctx
, ASN1_ENC_BER
, true, pinfo
);
247 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, PSNAME
);
248 col_set_str(pinfo
->cinfo
, COL_INFO
, "ProvideInstruction");
251 /* create display subtree for the protocol */
252 item
= proto_tree_add_item(parent_tree
, proto_lnpdqp
, tvb
, 0, -1, ENC_NA
);
253 tree
= proto_item_add_subtree(item
, ett_lnpdqp
);
255 return dissect_ProvideInstructionArg_PDU(tvb
, pinfo
, tree
, NULL
);
260 void proto_register_lnpdqp(void) {
263 static hf_register_info hf
[] = {
264 { &hf_lnpdqp_type_of_digits
,
265 { "Type of Digits", "lnpdqp.type_of_digits",
266 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_type_of_digits_vals
), 0x0,
268 { &hf_lnpdqp_nature_of_number
,
269 { "Nature of Number", "lnpdqp.na",
270 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_na_vals
), 0x0,
272 { &hf_lnpdqp_digits_enc
,
273 { "Encoding", "lnpdqp.enc",
274 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_digits_enc_vals
), 0x0f,
277 { "Numbering Plan", "lnpdqp.np",
278 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_np_vals
), 0xf0,
280 { &hf_lnpdqp_nr_digits
,
281 { "Number of Digits", "lnpdqp.nr_digits",
282 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
284 { &hf_lnpdqp_bcd_digits
,
285 { "BCD digits", "lnpdqp.bcd_digits",
286 FT_STRING
, BASE_NONE
, NULL
, 0,
288 { &hf_lnpdqp_ia5_digits
,
289 { "IA5 digits", "lnpdqp.ia5_digits",
290 FT_STRING
, BASE_NONE
, NULL
, 0,
293 /* asn2wrs/the ber dissector does not handle the same tag used multiple times
294 * in asn1 description, do some magic to handle.
296 { &hf_lnpdqp_networkRoutingNumber
,
297 { "networkRoutingNumber", "lnpdqp.networkRoutingNumber",
298 FT_BYTES
, BASE_NONE
, NULL
, 0,
301 { &hf_lnpdqp_callingPartyANI
,
302 { "callingPartyANI", "lnpdqp.callingPartyANI",
303 FT_BYTES
, BASE_NONE
, NULL
, 0,
305 { &hf_lnpdqp_originatingLATA
,
306 { "originatingLATA", "lnpdqp.originatingLATA",
307 FT_BYTES
, BASE_NONE
, NULL
, 0,
309 { &hf_lnpdqp_carrierID
,
310 { "carrierID", "lnpdqp.carrierID",
311 FT_BYTES
, BASE_NONE
, NULL
, 0,
314 #include "packet-lnpdqp-hfarr.c"
317 /* List of subtrees */
318 static int *ett
[] = {
320 &ett_lnpdqp_digitstype
,
323 #include "packet-lnpdqp-ettarr.c"
326 /* Register protocol */
327 proto_lnpdqp
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
330 register_dissector("lnpdqp_cc", dissect_lnpdqp_cc
, proto_lnpdqp
);
331 register_dissector("lnpdqp_pi", dissect_lnpdqp_pi
, proto_lnpdqp
);
333 /* Register fields and subtrees */
334 proto_register_field_array(proto_lnpdqp
, hf
, array_length(hf
));
335 proto_register_subtree_array(ett
, array_length(ett
));
338 void proto_reg_handoff_lnpdqp(void) {
340 static dissector_handle_t lnpdqp_cc_handle
, lnpdqp_pi_handle
;
342 lnpdqp_cc_handle
= find_dissector("lnpdqp_cc");
343 lnpdqp_pi_handle
= find_dissector("lnpdqp_pi");
345 dissector_add_uint("ansi_tcap.nat.opcode", LNPDQP_ANSI_TCAP_OPCODE_CC
, lnpdqp_cc_handle
);
346 dissector_add_uint("ansi_tcap.nat.opcode", LNPDQP_ANSI_TCAP_OPCODE_PI
, lnpdqp_pi_handle
);
355 * indent-tabs-mode: nil
358 * ex: set shiftwidth=4 tabstop=8 expandtab:
359 * :indentSize=4:tabSize=8:noTabs=true: