epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-lnpdqp.c
blobdb17a1c8c496fa8c3c07d18595c7a923ae37ecfb
1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
3 /* packet-lnpdqp.c */
4 /* asn2wrs.py -b -q -L -p lnpdqp -c ./lnpdqp.cnf -s ./packet-lnpdqp-template -D . -O ../.. LNPDQP.asn */
6 /* packet-lnpdqp-template.c
7 * Routines for Local Number Portability Database Query Protocol dissection
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * Ref GR-533 i2 2001
14 #include "config.h"
16 #include <epan/packet.h>
18 #include <epan/asn1.h>
19 #include <wsutil/array.h>
20 #include "packet-ber.h"
22 #define PNAME "Local Number Portability Database Query"
23 #define PSNAME "LNPDQP"
24 #define PFNAME "lnpdqp"
27 * Operation Code is partitioned into:
28 * Operation Family = ConnectionControl, no Reply Required (4)
29 * Operation Specifier = Connect (1)
31 #define LNPDQP_ANSI_TCAP_OPCODE_CC 0x0401
33 * Operation Code is partitioned into:
34 * Operation Family = ProvideInstruction, Reply Required (131) 0x83
35 * Operation Specifier = Start (1)
37 /* Excluding H bit */
38 #define LNPDQP_ANSI_TCAP_OPCODE_PI 0x0301
40 void proto_reg_handoff_lnpdqp(void);
41 void proto_register_lnpdqp(void);
43 /* Initialize the protocol and registered fields */
44 static int proto_lnpdqp;
47 static int hf_lnpdqp_type_of_digits;
48 static int hf_lnpdqp_nature_of_number;
49 static int hf_lnpdqp_digits_enc;
50 static int hf_lnpdqp_np;
51 static int hf_lnpdqp_nr_digits;
52 static int hf_lnpdqp_bcd_digits;
53 static int hf_lnpdqp_ia5_digits;
55 /* asn2wrs/the ber dissector does not handle the same tag used multiple times
56 * in asn1 description, do some magic to handle.
58 static int hf_lnpdqp_networkRoutingNumber; /* Digits */
59 static int hf_lnpdqp_callingPartyANI; /* Digits */
60 static int hf_lnpdqp_originatingLATA; /* Digits */
61 static int hf_lnpdqp_carrierID; /* Digits */
63 static int hf_lnpdqp_ConnectionControlArg_PDU; /* ConnectionControlArg */
64 static int hf_lnpdqp_ProvideInstructionArg_PDU; /* ProvideInstructionArg */
65 static int hf_lnpdqp_digits; /* Digits */
66 static int hf_lnpdqp_billingIndicators; /* BillingIndicators */
67 static int hf_lnpdqp_calledPartyNumber; /* ServiceKey */
68 static int hf_lnpdqp_oli; /* OriginatingStationType */
70 static int ett_lnpdqp;
71 static int ett_lnpdqp_digitstype;
72 static int ett_lnpdqp_digits;
73 static int ett_lnpdqp_ConnectionControlArg_U;
74 static int ett_lnpdqp_ProvideInstructionArg_U;
75 static int ett_lnpdqp_ServiceKey;
78 /* Type of Digits (octet 1, bits A-H) */
79 static const value_string lnpdqp_type_of_digits_vals[] = {
80 { 0, "Not Used" },
81 { 1, "Dialed Number or Called Party Number" },
82 { 2, "Calling Party Number" },
83 { 3, "Caller Interaction" },
84 { 4, "Routing Number" },
85 { 5, "Billing Number" },
86 { 6, "Destination Number" },
87 { 7, "LATA" },
88 { 8, "Carrier" },
89 { 9, "Last Calling Party" },
90 { 10, "Last Party Called" },
91 { 11, "Calling Directory Number" },
92 { 12, "VMSR Identifier" },
93 { 13, "Original Called Number" },
94 { 14, "Redirecting Number" },
95 { 15, "Connected Number" },
96 { 0, NULL }
99 #if 0
100 XXXX Currently unused
101 /* Nature of Number (octet 2, bits A-H )*/
102 static const true_false_string lnpdqp_na_bool_val = {
103 "International",
104 "National"
106 static const true_false_string lnpdqp_pi_bool_val = {
107 "Presentation Restricted",
108 "Presentation Allowed"
110 static const true_false_string lnpdqp_navail_bool_val = {
111 "Number is not available",
112 "Number is available"
114 static const true_false_string lnpdqp_si_bool_val = {
115 "User provided, screening passed",
116 "User provided, not screened"
118 #endif
119 static const value_string lnpdqp_na_vals[] = {
120 { 0, "National, No Presentation Restricted"},
121 { 1, "International, No Presentation Restricted"},
122 { 2, "National, Presentation Restricted"},
123 { 3, "International, Presentation Restricted"},
124 { 0, NULL }
126 /* Encoding (octet 3, bits A-D) */
127 static const value_string lnpdqp_digits_enc_vals[] = {
128 { 0, "Not used"},
129 { 1, "BCD"},
130 { 2, "IA5"},
131 { 3, "Octet string"},
132 { 0, NULL }
134 /* Numbering Plan (octet 3, bits E-H) */
135 static const value_string lnpdqp_np_vals[] = {
136 { 0, "Unknown or not applicable"},
137 { 1, "ISDN Numbering Plan (ITU Rec. E.164)"},
138 { 2, "Telephony Numbering (ITU-T Rec. E.164,E.163)"},
139 { 3, "Data Numbering (ITU-T Rec. X.121)"},
140 { 4, "Telex Numbering (ITU-T Rec. F.69)"},
141 { 5, "Maritime Mobile Numbering"},
142 { 6, "Land Mobile Numbering (ITU-T Rec. E.212)"},
143 { 7, "Private Numbering Plan"},
144 { 0, NULL }
148 * OriginatingStationType ::= OCTET STRING (SIZE(1))
149 * The following codes are used in the originating line information field:
150 * 00000010 } Binary values administered by the North
151 * to } American Numbering Administration
152 * 01100011 }
153 * Ref http://www.nanpa.com/number_resource_info/ani_ii_assignments.html
156 static const value_string lnpdqp_OriginatingStationType_vals[] = {
157 { 0, "Plain Old Telephone Service (POTS) - non-coin service requiring no special treatment"},
158 { 1, "Multiparty line (more than 2) - ANI cannot be provided on 4 or 8 party lines. "},
159 { 2, "ANI Failure "},
160 /* 03-05 Unassigned */
161 { 6, "Station Level Rating "},
162 { 7, "Special Operator Handling Required"},
163 /* 08-09 Unassigned */
164 { 10, "Not assignable - conflict with 10X test code"},
165 /* 11 Unassigned */
166 /* 12-19 Not assignable - conflict with international outpulsing code */
167 { 20, "Automatic Identified Outward Dialing (AIOD)"},
168 /* 21-22 Unassigned */
169 /* To lasy to do these */
170 { 61, "Cellular/Wireless PCS (Type 1) "},
171 { 62, "Cellular/Wireless PCS (Type 2) "},
172 { 63, "Cellular/Wireless PCS (Roaming)"},
173 { 0, NULL }
176 static void
177 dissect_lnpdqp_digits_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, asn1_ctx_t *actx _U_){
179 uint8_t octet , no_of_digits;
180 int offset = 0;
181 char *digit_str;
183 proto_tree *subtree;
186 subtree = proto_item_add_subtree(actx->created_item, ett_lnpdqp_digitstype);
188 /* Octet 1 Type of Digits*/
189 proto_tree_add_item(subtree, hf_lnpdqp_type_of_digits, tvb, offset, 1, ENC_BIG_ENDIAN);
190 offset++;
191 /* Octet 2 Nature of Number*/
192 proto_tree_add_item(subtree, hf_lnpdqp_nature_of_number, tvb, offset, 1, ENC_BIG_ENDIAN);
193 offset++;
194 /* Octet 3 Numbering Plan |Encoding Scheme| */
195 octet = tvb_get_uint8(tvb,offset);
196 proto_tree_add_item(subtree, hf_lnpdqp_np, tvb, offset, 1, ENC_BIG_ENDIAN);
197 proto_tree_add_item(subtree, hf_lnpdqp_digits_enc, tvb, offset, 1, ENC_BIG_ENDIAN);
198 offset++;
199 /* Octet 4 Number of Digits */
200 switch ((octet&0xf)){
201 case 1:
202 /* BCD Coding */
203 no_of_digits = tvb_get_uint8(tvb,offset);
204 proto_tree_add_item(subtree, hf_lnpdqp_nr_digits, tvb, offset, 1, ENC_BIG_ENDIAN);
205 if(no_of_digits == 0)
206 return;
207 offset++;
208 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);
209 proto_item_append_text(actx->created_item, " - %s", digit_str);
210 break;
211 case 2:
212 /* IA5 Coding */
213 no_of_digits = tvb_get_uint8(tvb,offset);
214 proto_tree_add_item(subtree, hf_lnpdqp_nr_digits, tvb, offset, 1, ENC_BIG_ENDIAN);
215 if(no_of_digits == 0)
216 return;
217 offset++;
218 proto_tree_add_item(subtree, hf_lnpdqp_ia5_digits, tvb, offset, -1, ENC_ASCII);
219 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));
220 break;
221 default:
222 break;
230 static int
231 dissect_lnpdqp_Digits(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
232 tvbuff_t *parameter_tvb = NULL;
233 uint8_t type_of_dgt;
234 proto_tree *subtree;
236 type_of_dgt = tvb_get_uint8(tvb,offset);
237 switch(type_of_dgt){
238 case 2:
239 /* Calling Party Number */
240 hf_index = hf_lnpdqp_callingPartyANI;
241 break;
242 case 4:
243 /* Routing Number */
244 hf_index = hf_lnpdqp_networkRoutingNumber;
245 break;
246 case 7:
247 /* Local Access and Transport Area */
248 hf_index = hf_lnpdqp_originatingLATA;
249 break;
250 case 8:
251 /* Carrier */
252 hf_index = hf_lnpdqp_carrierID;
253 break;
254 default:
255 break;
257 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
258 &parameter_tvb);
260 if (parameter_tvb){
261 subtree = proto_item_add_subtree(actx->created_item, ett_lnpdqp_digits);
262 dissect_lnpdqp_digits_type(parameter_tvb,actx->pinfo,subtree, actx);
266 return offset;
271 static int
272 dissect_lnpdqp_BillingIndicators(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
273 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
274 NULL);
276 return offset;
280 static const ber_sequence_t ConnectionControlArg_U_set[] = {
281 { &hf_lnpdqp_digits , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_lnpdqp_Digits },
282 { &hf_lnpdqp_billingIndicators, BER_CLASS_PRI, 65, BER_FLAGS_IMPLTAG, dissect_lnpdqp_BillingIndicators },
283 { NULL, 0, 0, 0, NULL }
286 static int
287 dissect_lnpdqp_ConnectionControlArg_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
288 offset = dissect_ber_set(implicit_tag, actx, tree, tvb, offset,
289 ConnectionControlArg_U_set, hf_index, ett_lnpdqp_ConnectionControlArg_U);
291 return offset;
296 static int
297 dissect_lnpdqp_ConnectionControlArg(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
298 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
299 hf_index, BER_CLASS_PRI, 18, true, dissect_lnpdqp_ConnectionControlArg_U);
301 return offset;
305 static const value_string lnpdqp_ServiceKey_vals[] = {
306 { 4, "digits" },
307 { 0, NULL }
310 static const ber_choice_t ServiceKey_choice[] = {
311 { 4, &hf_lnpdqp_digits , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_lnpdqp_Digits },
312 { 0, NULL, 0, 0, 0, NULL }
315 static int
316 dissect_lnpdqp_ServiceKey(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
317 offset = dissect_ber_choice(actx, tree, tvb, offset,
318 ServiceKey_choice, hf_index, ett_lnpdqp_ServiceKey,
319 NULL);
321 return offset;
326 static int
327 dissect_lnpdqp_OriginatingStationType(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
328 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
329 NULL);
331 return offset;
335 static const ber_sequence_t ProvideInstructionArg_U_set[] = {
336 { &hf_lnpdqp_calledPartyNumber, BER_CLASS_CON, 10, BER_FLAGS_IMPLTAG|BER_FLAGS_NOTCHKTAG, dissect_lnpdqp_ServiceKey },
337 { &hf_lnpdqp_digits , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_lnpdqp_Digits },
338 { &hf_lnpdqp_oli , BER_CLASS_PRI, 69, BER_FLAGS_IMPLTAG, dissect_lnpdqp_OriginatingStationType },
339 { NULL, 0, 0, 0, NULL }
342 static int
343 dissect_lnpdqp_ProvideInstructionArg_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
344 offset = dissect_ber_set(implicit_tag, actx, tree, tvb, offset,
345 ProvideInstructionArg_U_set, hf_index, ett_lnpdqp_ProvideInstructionArg_U);
347 return offset;
352 static int
353 dissect_lnpdqp_ProvideInstructionArg(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
354 offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
355 hf_index, BER_CLASS_PRI, 18, true, dissect_lnpdqp_ProvideInstructionArg_U);
357 return offset;
360 /*--- PDUs ---*/
362 static int dissect_ConnectionControlArg_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
363 int offset = 0;
364 asn1_ctx_t asn1_ctx;
365 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
366 offset = dissect_lnpdqp_ConnectionControlArg(false, tvb, offset, &asn1_ctx, tree, hf_lnpdqp_ConnectionControlArg_PDU);
367 return offset;
369 static int dissect_ProvideInstructionArg_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
370 int offset = 0;
371 asn1_ctx_t asn1_ctx;
372 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
373 offset = dissect_lnpdqp_ProvideInstructionArg(false, tvb, offset, &asn1_ctx, tree, hf_lnpdqp_ProvideInstructionArg_PDU);
374 return offset;
378 static int
379 dissect_lnpdqp_cc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
381 proto_item *item=NULL;
382 proto_tree *tree=NULL;
383 asn1_ctx_t asn1_ctx;
385 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
387 col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
388 col_set_str(pinfo->cinfo, COL_INFO, "ConnectionControl");
391 /* create display subtree for the protocol */
392 item = proto_tree_add_item(parent_tree, proto_lnpdqp, tvb, 0, -1, ENC_NA);
393 tree = proto_item_add_subtree(item, ett_lnpdqp);
395 return dissect_ConnectionControlArg_PDU(tvb, pinfo, tree, NULL);
398 static int
399 dissect_lnpdqp_pi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
401 proto_item *item=NULL;
402 proto_tree *tree=NULL;
403 asn1_ctx_t asn1_ctx;
405 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
407 col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
408 col_set_str(pinfo->cinfo, COL_INFO, "ProvideInstruction");
411 /* create display subtree for the protocol */
412 item = proto_tree_add_item(parent_tree, proto_lnpdqp, tvb, 0, -1, ENC_NA);
413 tree = proto_item_add_subtree(item, ett_lnpdqp);
415 return dissect_ProvideInstructionArg_PDU(tvb, pinfo, tree, NULL);
420 void proto_register_lnpdqp(void) {
422 /* List of fields */
423 static hf_register_info hf[] = {
424 { &hf_lnpdqp_type_of_digits,
425 { "Type of Digits", "lnpdqp.type_of_digits",
426 FT_UINT8, BASE_DEC, VALS(lnpdqp_type_of_digits_vals), 0x0,
427 NULL, HFILL }},
428 { &hf_lnpdqp_nature_of_number,
429 { "Nature of Number", "lnpdqp.na",
430 FT_UINT8, BASE_DEC, VALS(lnpdqp_na_vals), 0x0,
431 NULL, HFILL }},
432 { &hf_lnpdqp_digits_enc,
433 { "Encoding", "lnpdqp.enc",
434 FT_UINT8, BASE_DEC, VALS(lnpdqp_digits_enc_vals), 0x0f,
435 NULL, HFILL }},
436 { &hf_lnpdqp_np,
437 { "Numbering Plan", "lnpdqp.np",
438 FT_UINT8, BASE_DEC, VALS(lnpdqp_np_vals), 0xf0,
439 NULL, HFILL }},
440 { &hf_lnpdqp_nr_digits,
441 { "Number of Digits", "lnpdqp.nr_digits",
442 FT_UINT8, BASE_DEC, NULL, 0x0,
443 NULL, HFILL }},
444 { &hf_lnpdqp_bcd_digits,
445 { "BCD digits", "lnpdqp.bcd_digits",
446 FT_STRING, BASE_NONE, NULL, 0,
447 NULL, HFILL }},
448 { &hf_lnpdqp_ia5_digits,
449 { "IA5 digits", "lnpdqp.ia5_digits",
450 FT_STRING, BASE_NONE, NULL, 0,
451 NULL, HFILL }},
453 /* asn2wrs/the ber dissector does not handle the same tag used multiple times
454 * in asn1 description, do some magic to handle.
456 { &hf_lnpdqp_networkRoutingNumber,
457 { "networkRoutingNumber", "lnpdqp.networkRoutingNumber",
458 FT_BYTES, BASE_NONE, NULL, 0,
459 "Digits", HFILL }},
461 { &hf_lnpdqp_callingPartyANI,
462 { "callingPartyANI", "lnpdqp.callingPartyANI",
463 FT_BYTES, BASE_NONE, NULL, 0,
464 "Digits", HFILL }},
465 { &hf_lnpdqp_originatingLATA,
466 { "originatingLATA", "lnpdqp.originatingLATA",
467 FT_BYTES, BASE_NONE, NULL, 0,
468 "Digits", HFILL }},
469 { &hf_lnpdqp_carrierID,
470 { "carrierID", "lnpdqp.carrierID",
471 FT_BYTES, BASE_NONE, NULL, 0,
472 "Digits", HFILL }},
474 { &hf_lnpdqp_ConnectionControlArg_PDU,
475 { "ConnectionControlArg", "lnpdqp.ConnectionControlArg_element",
476 FT_NONE, BASE_NONE, NULL, 0,
477 NULL, HFILL }},
478 { &hf_lnpdqp_ProvideInstructionArg_PDU,
479 { "ProvideInstructionArg", "lnpdqp.ProvideInstructionArg_element",
480 FT_NONE, BASE_NONE, NULL, 0,
481 NULL, HFILL }},
482 { &hf_lnpdqp_digits,
483 { "digits", "lnpdqp.digits",
484 FT_BYTES, BASE_NONE, NULL, 0,
485 NULL, HFILL }},
486 { &hf_lnpdqp_billingIndicators,
487 { "billingIndicators", "lnpdqp.billingIndicators",
488 FT_BYTES, BASE_NONE, NULL, 0,
489 NULL, HFILL }},
490 { &hf_lnpdqp_calledPartyNumber,
491 { "calledPartyNumber", "lnpdqp.calledPartyNumber",
492 FT_UINT32, BASE_DEC, VALS(lnpdqp_ServiceKey_vals), 0,
493 "ServiceKey", HFILL }},
494 { &hf_lnpdqp_oli,
495 { "oli", "lnpdqp.oli",
496 FT_UINT8, BASE_DEC, VALS(lnpdqp_OriginatingStationType_vals), 0,
497 "OriginatingStationType", HFILL }},
500 /* List of subtrees */
501 static int *ett[] = {
502 &ett_lnpdqp,
503 &ett_lnpdqp_digitstype,
504 &ett_lnpdqp_digits,
506 &ett_lnpdqp_ConnectionControlArg_U,
507 &ett_lnpdqp_ProvideInstructionArg_U,
508 &ett_lnpdqp_ServiceKey,
511 /* Register protocol */
512 proto_lnpdqp = proto_register_protocol(PNAME, PSNAME, PFNAME);
515 register_dissector("lnpdqp_cc", dissect_lnpdqp_cc, proto_lnpdqp);
516 register_dissector("lnpdqp_pi", dissect_lnpdqp_pi, proto_lnpdqp);
518 /* Register fields and subtrees */
519 proto_register_field_array(proto_lnpdqp, hf, array_length(hf));
520 proto_register_subtree_array(ett, array_length(ett));
523 void proto_reg_handoff_lnpdqp(void) {
525 static dissector_handle_t lnpdqp_cc_handle, lnpdqp_pi_handle;
527 lnpdqp_cc_handle = find_dissector("lnpdqp_cc");
528 lnpdqp_pi_handle = find_dissector("lnpdqp_pi");
530 dissector_add_uint("ansi_tcap.nat.opcode", LNPDQP_ANSI_TCAP_OPCODE_CC, lnpdqp_cc_handle);
531 dissector_add_uint("ansi_tcap.nat.opcode", LNPDQP_ANSI_TCAP_OPCODE_PI, lnpdqp_pi_handle);
535 * Editor modelines
537 * Local Variables:
538 * c-basic-offset: 4
539 * tab-width: 8
540 * indent-tabs-mode: nil
541 * End:
543 * ex: set shiftwidth=4 tabstop=8 expandtab:
544 * :indentSize=4:tabSize=8:noTabs=true: