1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
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
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)
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
[] = {
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" },
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" },
100 XXXX Currently unused
101 /* Nature of Number (octet 2, bits A-H )*/
102 static const true_false_string lnpdqp_na_bool_val
= {
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"
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"},
126 /* Encoding (octet 3, bits A-D) */
127 static const value_string lnpdqp_digits_enc_vals
[] = {
131 { 3, "Octet string"},
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"},
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
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"},
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)"},
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
;
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
);
191 /* Octet 2 Nature of Number*/
192 proto_tree_add_item(subtree
, hf_lnpdqp_nature_of_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
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
);
199 /* Octet 4 Number of Digits */
200 switch ((octet
&0xf)){
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)
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
);
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)
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
));
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
;
236 type_of_dgt
= tvb_get_uint8(tvb
,offset
);
239 /* Calling Party Number */
240 hf_index
= hf_lnpdqp_callingPartyANI
;
244 hf_index
= hf_lnpdqp_networkRoutingNumber
;
247 /* Local Access and Transport Area */
248 hf_index
= hf_lnpdqp_originatingLATA
;
252 hf_index
= hf_lnpdqp_carrierID
;
257 offset
= dissect_ber_octet_string(implicit_tag
, actx
, tree
, tvb
, offset
, hf_index
,
261 subtree
= proto_item_add_subtree(actx
->created_item
, ett_lnpdqp_digits
);
262 dissect_lnpdqp_digits_type(parameter_tvb
,actx
->pinfo
,subtree
, actx
);
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
,
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
}
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
);
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
);
305 static const value_string lnpdqp_ServiceKey_vals
[] = {
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
}
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
,
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
,
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
}
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
);
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
);
362 static int dissect_ConnectionControlArg_PDU(tvbuff_t
*tvb _U_
, packet_info
*pinfo _U_
, proto_tree
*tree _U_
, void *data _U_
) {
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
);
369 static int dissect_ProvideInstructionArg_PDU(tvbuff_t
*tvb _U_
, packet_info
*pinfo _U_
, proto_tree
*tree _U_
, void *data _U_
) {
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
);
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
;
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
);
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
;
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) {
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,
428 { &hf_lnpdqp_nature_of_number
,
429 { "Nature of Number", "lnpdqp.na",
430 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_na_vals
), 0x0,
432 { &hf_lnpdqp_digits_enc
,
433 { "Encoding", "lnpdqp.enc",
434 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_digits_enc_vals
), 0x0f,
437 { "Numbering Plan", "lnpdqp.np",
438 FT_UINT8
, BASE_DEC
, VALS(lnpdqp_np_vals
), 0xf0,
440 { &hf_lnpdqp_nr_digits
,
441 { "Number of Digits", "lnpdqp.nr_digits",
442 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
444 { &hf_lnpdqp_bcd_digits
,
445 { "BCD digits", "lnpdqp.bcd_digits",
446 FT_STRING
, BASE_NONE
, NULL
, 0,
448 { &hf_lnpdqp_ia5_digits
,
449 { "IA5 digits", "lnpdqp.ia5_digits",
450 FT_STRING
, BASE_NONE
, NULL
, 0,
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,
461 { &hf_lnpdqp_callingPartyANI
,
462 { "callingPartyANI", "lnpdqp.callingPartyANI",
463 FT_BYTES
, BASE_NONE
, NULL
, 0,
465 { &hf_lnpdqp_originatingLATA
,
466 { "originatingLATA", "lnpdqp.originatingLATA",
467 FT_BYTES
, BASE_NONE
, NULL
, 0,
469 { &hf_lnpdqp_carrierID
,
470 { "carrierID", "lnpdqp.carrierID",
471 FT_BYTES
, BASE_NONE
, NULL
, 0,
474 { &hf_lnpdqp_ConnectionControlArg_PDU
,
475 { "ConnectionControlArg", "lnpdqp.ConnectionControlArg_element",
476 FT_NONE
, BASE_NONE
, NULL
, 0,
478 { &hf_lnpdqp_ProvideInstructionArg_PDU
,
479 { "ProvideInstructionArg", "lnpdqp.ProvideInstructionArg_element",
480 FT_NONE
, BASE_NONE
, NULL
, 0,
483 { "digits", "lnpdqp.digits",
484 FT_BYTES
, BASE_NONE
, NULL
, 0,
486 { &hf_lnpdqp_billingIndicators
,
487 { "billingIndicators", "lnpdqp.billingIndicators",
488 FT_BYTES
, BASE_NONE
, NULL
, 0,
490 { &hf_lnpdqp_calledPartyNumber
,
491 { "calledPartyNumber", "lnpdqp.calledPartyNumber",
492 FT_UINT32
, BASE_DEC
, VALS(lnpdqp_ServiceKey_vals
), 0,
493 "ServiceKey", HFILL
}},
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
[] = {
503 &ett_lnpdqp_digitstype
,
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
);
540 * indent-tabs-mode: nil
543 * ex: set shiftwidth=4 tabstop=8 expandtab:
544 * :indentSize=4:tabSize=8:noTabs=true: