From Tim Potter: dissect some of the LSA RPCs stub data.
[obnox/wireshark/wip.git] / packet-ucp.c
1 /* packet-ucp.c
2  * Routines for Universal Computer Protocol dissection
3  * Copyright 2001, Tom Uijldert <tom.uijldert@cmg.nl>
4  *
5  * $Id: packet-ucp.c,v 1.8 2001/12/10 00:25:40 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  * ----------
25  *
26  * Dissector of a UCP (Universal Computer Protocol) PDU, as defined for the
27  * ERMES paging system in ETS 300 133-3 (2nd final draft, September 1997,
28  * www.etsi.org).
29  * Includes the extension of EMI-UCP interface (V4.0, May 2001, www.cmgwds.com)
30  *
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <ctype.h>
41 #include <time.h>
42
43 #ifdef HAVE_SYS_TYPES_H
44 # include <sys/types.h>
45 #endif
46
47 #ifdef HAVE_NETINET_IN_H
48 # include <netinet/in.h>
49 #endif
50
51 #include <glib.h>
52
53 #ifdef NEED_SNPRINTF_H
54 # include "snprintf.h"
55 #endif
56
57 #include "packet.h"
58 /* #include "packet-ucp.h" */                   /* We autoregister      */
59
60 /* Prototypes   */
61 static void dissect_ucp(tvbuff_t *, packet_info *, proto_tree *);
62
63 /*
64  * Convert ASCII-hex character to binary equivalent. No checks, assume
65  * is valid hex character.
66  */
67 #define AHex2Bin(n)     (((n) & 0x40) ? ((n) & 0x0F) + 9 : ((n) & 0x0F))
68
69 #define UCP_STX         0x02                    /* Start of UCP PDU     */
70 #define UCP_ETX         0x03                    /* End of UCP PDU       */
71
72 #define UCP_MALFORMED   -1                      /* Not a valid PDU      */
73 #define UCP_SHORTENED   -2                      /* May be valid but short */
74 #define UCP_INV_CHK     -3                      /* Checksum doesn't add up */
75
76 #define UCP_O_R_OFFSET 10                       /* Location of O/R field*/
77 #define UCP_OT_OFFSET  12                       /* Location of OT field */
78
79 #define UCP_TRN_LEN     2                       /* Length of TRN-field  */
80 #define UCP_LEN_LEN     5                       /* Length of LEN-field  */
81 #define UCP_O_R_LEN     1                       /* Length of O/R-field  */
82 #define UCP_OT_LEN      2                       /* Length of OT-field   */
83
84 /*
85  * Initialize the protocol and registered fields
86  *
87  * Header (fixed) section
88  */
89 static int proto_ucp = -1;
90
91 static int hf_ucp_hdr_TRN       = -1;
92 static int hf_ucp_hdr_LEN       = -1;
93 static int hf_ucp_hdr_O_R       = -1;
94 static int hf_ucp_hdr_OT        = -1;
95
96 /*
97  * Data (variable) section
98  */
99 static int hf_ucp_oper_section  = -1;
100 static int hf_ucp_parm_AdC      = -1;
101 static int hf_ucp_parm_OAdC     = -1;
102 static int hf_ucp_parm_DAdC     = -1;
103 static int hf_ucp_parm_AC       = -1;
104 static int hf_ucp_parm_OAC      = -1;
105 static int hf_ucp_parm_BAS      = -1;
106 static int hf_ucp_parm_LAR      = -1;
107 static int hf_ucp_parm_LAC      = -1;
108 static int hf_ucp_parm_L1R      = -1;
109 static int hf_ucp_parm_L1P      = -1;
110 static int hf_ucp_parm_L3R      = -1;
111 static int hf_ucp_parm_L3P      = -1;
112 static int hf_ucp_parm_LCR      = -1;
113 static int hf_ucp_parm_LUR      = -1;
114 static int hf_ucp_parm_LRR      = -1;
115 static int hf_ucp_parm_RT       = -1;
116 static int hf_ucp_parm_NoN      = -1;
117 static int hf_ucp_parm_NoA      = -1;
118 static int hf_ucp_parm_NoB      = -1;
119 static int hf_ucp_parm_NAC      = -1;
120 static int hf_ucp_parm_PNC      = -1;
121 static int hf_ucp_parm_LNo      = -1;
122 static int hf_ucp_parm_LST      = -1;
123 static int hf_ucp_parm_TNo      = -1;
124 static int hf_ucp_parm_CS       = -1;
125 static int hf_ucp_parm_PID      = -1;
126 static int hf_ucp_parm_NPL      = -1;
127 static int hf_ucp_parm_GA       = -1;
128 static int hf_ucp_parm_RP       = -1;
129 static int hf_ucp_parm_LRP      = -1;
130 static int hf_ucp_parm_PR       = -1;
131 static int hf_ucp_parm_LPR      = -1;
132 static int hf_ucp_parm_UM       = -1;
133 static int hf_ucp_parm_LUM      = -1;
134 static int hf_ucp_parm_RC       = -1;
135 static int hf_ucp_parm_LRC      = -1;
136 static int hf_ucp_parm_NRq      = -1;
137 static int hf_ucp_parm_GAdC     = -1;
138 static int hf_ucp_parm_A_D      = -1;
139 static int hf_ucp_parm_CT       = -1;
140 static int hf_ucp_parm_AAC      = -1;
141 static int hf_ucp_parm_MNo      = -1;
142 static int hf_ucp_parm_R_T      = -1;
143 static int hf_ucp_parm_IVR5x    = -1;
144 static int hf_ucp_parm_REQ_OT   = -1;
145 static int hf_ucp_parm_SSTAT    = -1;
146 static int hf_ucp_parm_LMN      = -1;
147 static int hf_ucp_parm_NMESS    = -1;
148 static int hf_ucp_parm_NMESS_str= -1;
149 static int hf_ucp_parm_NAdC     = -1;
150 static int hf_ucp_parm_NT       = -1;
151 static int hf_ucp_parm_NPID     = -1;
152 static int hf_ucp_parm_LRq      = -1;
153 static int hf_ucp_parm_LRAd     = -1;
154 static int hf_ucp_parm_LPID     = -1;
155 static int hf_ucp_parm_DD       = -1;
156 static int hf_ucp_parm_DDT      = -1;
157 static int hf_ucp_parm_STx      = -1;
158 static int hf_ucp_parm_ST       = -1;
159 static int hf_ucp_parm_SP       = -1;
160 static int hf_ucp_parm_VP       = -1;
161 static int hf_ucp_parm_RPID     = -1;
162 static int hf_ucp_parm_SCTS     = -1;
163 static int hf_ucp_parm_Dst      = -1;
164 static int hf_ucp_parm_Rsn      = -1;
165 static int hf_ucp_parm_DSCTS    = -1;
166 static int hf_ucp_parm_MT       = -1;
167 static int hf_ucp_parm_NB       = -1;
168 static int hf_ucp_data_section  = -1;
169 static int hf_ucp_parm_MMS      = -1;
170 static int hf_ucp_parm_DCs      = -1;
171 static int hf_ucp_parm_MCLs     = -1;
172 static int hf_ucp_parm_RPI      = -1;
173 static int hf_ucp_parm_CPg      = -1;
174 static int hf_ucp_parm_RPLy     = -1;
175 static int hf_ucp_parm_OTOA     = -1;
176 static int hf_ucp_parm_HPLMN    = -1;
177 static int hf_ucp_parm_RES4     = -1;
178 static int hf_ucp_parm_RES5     = -1;
179 static int hf_ucp_parm_OTON     = -1;
180 static int hf_ucp_parm_ONPI     = -1;
181 static int hf_ucp_parm_STYP0    = -1;
182 static int hf_ucp_parm_STYP1    = -1;
183 static int hf_ucp_parm_ACK      = -1;
184 static int hf_ucp_parm_PWD      = -1;
185 static int hf_ucp_parm_NPWD     = -1;
186 static int hf_ucp_parm_VERS     = -1;
187 static int hf_ucp_parm_LAdC     = -1;
188 static int hf_ucp_parm_LTON     = -1;
189 static int hf_ucp_parm_LNPI     = -1;
190 static int hf_ucp_parm_OPID     = -1;
191 static int hf_ucp_parm_RES1     = -1;
192 static int hf_ucp_parm_RES2     = -1;
193 static int hf_ucp_parm_MVP      = -1;
194 static int hf_ucp_parm_EC       = -1;
195 static int hf_ucp_parm_SM       = -1;
196
197 static int hf_ucp_parm_XSer     = -1;
198 static int hf_xser_service      = -1;
199
200 /* Initialize the subtree pointers */
201 static gint ett_ucp  = -1;
202 static gint ett_XSer = -1;
203
204 /*
205  * Value-arrays for certain field-contents
206  */
207 static const value_string vals_hdr_O_R[] = {
208     {  'O', "Operation" },
209     {  'R', "Result" },
210     {  0, NULL }
211 };
212
213 static const value_string vals_hdr_OT[] = {     /* Operation type       */
214     {  0, "Enquiry" },
215     {  1, "Call input" },
216     {  2, "Call input (multiple address)" },
217     {  3, "Call input (supplementary services included)" },
218     {  4, "Address list information" },
219     {  5, "Change address list" },
220     {  6, "Advice of accumulated charges" },
221     {  7, "Password management" },
222     {  8, "Legitimisation code management" },
223     {  9, "Standard text information" },
224     { 10, "Change standard text" },
225     { 11, "Request roaming information" },
226     { 12, "Change roaming information" },
227     { 13, "Roaming reset" },
228     { 14, "Message retrieval" },
229     { 15, "Request call barring" },
230     { 16, "Cancel call barring" },
231     { 17, "Request call diversion" },
232     { 18, "Cancel call diversion" },
233     { 19, "Request deferred delivery" },
234     { 20, "Cancel deferred delivery" },
235     { 21, "All features reset" },
236     { 22, "Call input (with specific character set)" },
237     { 23, "UCP version status request" },
238     { 24, "Mobile subscriber feature status request" },
239     { 30, "SMS message transfer" },
240     { 31, "SMT alert" },
241     { 32, "(proprietary)" },
242     { 34, "(proprietary)" },
243     { 36, "(proprietary)" },
244     { 38, "(proprietary)" },
245     { 40, "(proprietary)" },
246     { 41, "(proprietary)" },
247     { 42, "(proprietary)" },
248     { 43, "(proprietary)" },
249     { 44, "(proprietary)" },
250     { 45, "(proprietary)" },
251     { 51, "Submit short message" },
252     { 52, "Deliver short message" },
253     { 53, "Deliver notification" },
254     { 54, "Modify message" },
255     { 55, "Inquiry message" },
256     { 56, "Delete message" },
257     { 57, "Inquiry response message" },
258     { 58, "Delete response message" },
259     { 60, "Session management" },
260     { 61, "List management" },
261     { 95, "(proprietary)" },
262     { 96, "(proprietary)" },
263     { 97, "(proprietary)" },
264     { 98, "(proprietary)" },
265     { 99, "(proprietary)" },
266     {  0, NULL }
267 };
268
269 static const value_string vals_parm_EC[] = {    /* Error code   */
270     {  1, "Checksum error" },
271     {  2, "Syntax error" },
272     {  3, "Operation not supported by system" },
273     {  4, "Operation not allowed" },
274     {  5, "Call barring active" },
275     {  6, "AdC invalid" },
276     {  7, "Authentication failure" },
277     {  8, "Legitimisation code for all calls, failure" },
278     {  9, "GA not valid" },
279     { 10, "Repetition not allowed" },
280     { 11, "Legitimisation code for repetition, failure" },
281     { 12, "Priority call not allowed" },
282     { 13, "Legitimisation code for priority call, failure" },
283     { 14, "Urgent message not allowed" },
284     { 15, "Legitimisation code for urgent message, failure" },
285     { 16, "Reverse charging not alllowed" },
286     { 17, "Legitimisation code for rev. charging, failure" },
287     { 18, "Deferred delivery not allowed" },
288     { 19, "New AC not valid" },
289     { 20, "New legitimisation code not valid" },
290     { 21, "Standard text not valid" },
291     { 22, "Time period not valid" },
292     { 23, "Message type not supported by system" },
293     { 24, "Message too long" },
294     { 25, "Requested standard text not valid" },
295     { 26, "Message type not valid for the pager type" },
296     { 27, "Message not found in SMSC" },
297     { 28, "Invalid character set" },
298     { 30, "Subscriber hang-up" },
299     { 31, "Fax group not supported" },
300     { 32, "Fax message type not supported" },
301     { 33, "Address already in list (60-series)" },
302     { 34, "Address not in list (60-series)" },
303     { 35, "List full, cannot add address to list (60-series)" },
304     { 36, "RPID already in use" },
305     { 37, "Delivery in progress" },
306     { 38, "Message forwarded" },
307     { 50, "Low network status" },
308     { 51, "Legitimisation code for standard text, failure" },
309     { 53, "Operation partially successfull" },
310     { 54, "Operation not successfull" },
311     { 55, "System error" },
312     { 57, "AdC already a member of GAdC address list" },
313     { 58, "AdC not a member of GAdC address list" },
314     { 59, "Requested standard text list invalid" },
315     { 61, "Not controller of GAdC address list" },
316     { 62, "Standard text too large" },
317     { 63, "Not owner of standard text list" },
318     { 64, "Address list full" },
319     { 65, "GAdC invalid" },
320     { 66, "Operation restricted to mobile subscribers" },
321     { 68, "Invalid AdC type" },
322     { 69, "Cannot add AdC to GAdC address list" },
323     { 90, "(proprietary error code)" },
324     { 91, "(proprietary error code)" },
325     { 92, "(proprietary error code)" },
326     { 93, "(proprietary error code)" },
327     { 94, "(proprietary error code)" },
328     { 95, "(proprietary error code)" },
329     { 96, "(proprietary error code)" },
330     { 97, "(proprietary error code)" },
331     { 98, "(proprietary error code)" },
332     { 99, "(proprietary error code)" },
333     {  0, NULL },
334 };
335
336 static const value_string vals_parm_NRq[] = {
337     {  '0', "NAdC not used" },
338     {  '1', "NAdC used" },
339     {  0, NULL },
340 };
341
342 static const value_string vals_parm_NT[] = {
343     {  '0', "Default value" },
344     {  '1', "Delivery notification" },
345     {  '2', "Non-delivery notification" },
346     {  '3', "Delivery and Non-delivery notification" },
347     {  '4', "Buffered message notification" },
348     {  '5', "Buffered and Delivery notification" },
349     {  '6', "Buffered and Non-delivery notification" },
350     {  '7', "All notifications" },
351     {  0, NULL },
352 };
353
354 static const value_string vals_parm_PID[] = {
355     {  100, "Mobile station" },
356     {  122, "Fax Group 3" },
357     {  131, "X.400" },
358     {  138, "Menu over PSTN" },
359     {  139, "PC appl. over PSTN (E.164)" },
360     {  339, "PC appl. over X.25 (X.121)" },
361     {  439, "PC appl. over ISDN (E.164)" },
362     {  539, "PC appl. over TCP/IP" },
363     {  0, NULL },
364 };
365
366 static const value_string vals_parm_LRq[] = {
367     {  '0', "LRAd not used" },
368     {  '1', "LRAd used" },
369     {  0, NULL },
370 };
371
372 static const value_string vals_parm_DD[] = {
373     {  '0', "DDT not used" },
374     {  '1', "DDT used" },
375     {  0, NULL },
376 };
377
378 static const value_string vals_parm_Dst[] = {
379     {  '0', "delivered" },
380     {  '1', "buffered (see Rsn)" },
381     {  '2', "not delivered (see Rsn)" },
382     {  0, NULL },
383 };
384
385 static const value_string vals_parm_Rsn[] = {
386     {    0, "Unknown subscriber" },
387     {    1, "Service temporary not available" },
388     {    2, "Service temporary not available" },
389     {    3, "Service temporary not available" },
390     {    4, "Service temporary not available" },
391     {    5, "Service temporary not available" },
392     {    6, "Service temporary not available" },
393     {    7, "Service temporary not available" },
394     {    8, "Service temporary not available" },
395     {    9, "Illegal error code" },
396     {   10, "Network time-out" },
397     {  100, "Facility not supported" },
398     {  101, "Unknown subscriber" },
399     {  102, "Facility not provided" },
400     {  103, "Call barred" },
401     {  104, "Operation barred" },
402     {  105, "SC congestion" },
403     {  106, "Facility not supported" },
404     {  107, "Absent subscriber" },
405     {  108, "Delivery fail" },
406     {  109, "Sc congestion" },
407     {  110, "Protocol error" },
408     {  111, "MS not equiped" },
409     {  112, "Unknown SC" },
410     {  113, "SC congestion" },
411     {  114, "Illegal MS" },
412     {  115, "MS nota subscriber" },
413     {  116, "Error in MS" },
414     {  117, "SMS lower layer not provisioned" },
415     {  118, "System fail" },
416     {  119, "PLMN system failure" },
417     {  120, "HLR system failure" },
418     {  121, "VLR system failure" },
419     {  122, "Previous VLR system failure" },
420     {  123, "Controlling MSC system failure" },
421     {  124, "VMSC system failure" },
422     {  125, "EIR system failure" },
423     {  126, "System failure" },
424     {  127, "Unexpected data value" },
425     {  200, "Error in address service centre" },
426     {  201, "Invalid absolute validity period" },
427     {  202, "Short message exceeds maximum" },
428     {  203, "Unable to unpack GSM message" },
429     {  204, "Unable to convert to IRA alphabet" },
430     {  205, "Invalid validity period format" },
431     {  206, "Invalid destination address" },
432     {  207, "Duplicate message submit" },
433     {  208, "Invalid message type indicator" },
434     {  0, NULL },
435 };
436
437 static const value_string vals_parm_MT[] = {
438     {  '2', "Numeric message" },
439     {  '3', "Alphanumeric message" },
440     {  '4', "Transparent data" },
441     {  0, NULL },
442 };
443
444 static const value_string vals_parm_DCs[] = {
445     {  '0', "default alphabet" },
446     {  '1', "User defined data (8 bit)" },
447     {  0, NULL },
448 };
449
450 static const value_string vals_parm_MCLs[] = {
451     {  '0', "message class 0" },
452     {  '1', "message class 1" },
453     {  '2', "message class 2" },
454     {  '3', "message class 3" },
455     {  0, NULL },
456 };
457
458 static const value_string vals_parm_RPI[] = {
459     {  '1', "Request" },
460     {  '2', "Response" },
461     {  0, NULL },
462 };
463
464 static const value_string vals_parm_ACK[] = {
465     {  'A', "Ack" },
466     {  'N', "Nack" },
467     {  0, NULL },
468 };
469
470 static const value_string vals_parm_RP[] = {
471     {  '1', "Repetition requested" },
472     {  0, NULL },
473 };
474
475 static const value_string vals_parm_UM[] = {
476     {  '1', "Urgent message" },
477     {  0, NULL },
478 };
479
480 static const value_string vals_parm_RC[] = {
481     {  '1', "Reverse charging request" },
482     {  0, NULL },
483 };
484
485 static const value_string vals_parm_OTON[] = {
486     {  '1', "International number" },
487     {  '2', "National number" },
488     {  '6', "Abbreviated number (short number alias)" },
489     {  0, NULL },
490 };
491
492 static const value_string vals_parm_ONPI[] = {
493     {  '1', "E.164 address" },
494     {  '3', "X.121 address" },
495     {  '5', "Private -TCP/IP or abbreviated number- address" },
496     {  0, NULL },
497 };
498
499 static const value_string vals_parm_STYP0[] = {
500     {  '1', "open session" },
501     {  '2', "reserved" },
502     {  '3', "change password" },
503     {  '4', "open provisioning session" },
504     {  '5', "reserved" },
505     {  '6', "change provisioning password" },
506     {  0, NULL },
507 };
508
509 static const value_string vals_parm_STYP1[] = {
510     {  '1', "add item to mo-list" },
511     {  '2', "remove item from mo-list" },
512     {  '3', "verify item mo-list" },
513     {  '4', "add item to mt-list" },
514     {  '5', "remove item from mt-list" },
515     {  '6', "verify item mt-list" },
516     {  0, NULL },
517 };
518
519 static const value_string vals_parm_OPID[] = {
520     {  0, "Mobile station" },
521     {  39, "PC application" },
522     {  0, NULL },
523 };
524
525 static const value_string vals_parm_BAS[] = {
526     {  '1', "Barred" },
527     {  0, NULL },
528 };
529
530 static const value_string vals_parm_LAR[] = {
531     {  '1', "Leg. code for all calls requested" },
532     {  0, NULL },
533 };
534
535 static const value_string vals_parm_L1R[] = {
536     {  '1', "Leg. code for priority 1 requested" },
537     {  0, NULL },
538 };
539
540 static const value_string vals_parm_L3R[] = {
541     {  '1', "Leg. code for priority 3 requested" },
542     {  0, NULL },
543 };
544
545 static const value_string vals_parm_LCR[] = {
546     {  '1', "Leg. code for reverse charging requested" },
547     {  0, NULL },
548 };
549
550 static const value_string vals_parm_LUR[] = {
551     {  '1', "Leg. code for urgent message requested" },
552     {  0, NULL },
553 };
554
555 static const value_string vals_parm_LRR[] = {
556     {  '1', "Leg. code for repitition requested" },
557     {  0, NULL },
558 };
559
560 static const value_string vals_parm_RT[] = {
561     {  '1', "Tone only" },
562     {  '2', "Numeric" },
563     {  '3', "Alphanumeric" },
564     {  '4', "Transparent data" },
565     {  0, NULL },
566 };
567
568 static const value_string vals_parm_PNC[] = {
569     {  'H', "Home PNC" },
570     {  'I', "Input PNC" },
571     {  0, NULL },
572 };
573
574 static const value_string vals_parm_A_D[] = {
575     {  'A', "Add" },
576     {  'D', "Delete" },
577     {  0, NULL },
578 };
579
580 static const value_string vals_parm_R_T[] = {
581     {  'R', "Retrieval Ok" },
582     {  'T', "Retransmit on radio channel" },
583     {  0, NULL },
584 };
585
586 static const value_string vals_parm_REQ_OT[] = {
587     {  'S', "Send used operation types" },
588     {  'N', "Don't send used operation types" },
589     {  0, NULL },
590 };
591
592 static const value_string vals_parm_SSTAT[] = {
593     {  '0', "All services" },
594     {  '1', "All in the moment active servics" },
595     {  '2', "Call diversion" },
596     {  '3', "Roaming information status" },
597     {  '4', "Call barring status" },
598     {  '5', "Deferred delivery status" },
599     {  '6', "Number of stored messages" },
600     {  0, NULL },
601 };
602
603 static const value_string vals_xser_service[] = {
604     {  1, "GSM UDH information" },
605     {  2, "GSM DCS information" },
606     {  3, "[Message Type]            TDMA information exchange" },
607     {  4, "[Message Reference]       TDMA information exchange" },
608     {  5, "[Privacy Indicator]       TDMA information exchange" },
609     {  6, "[Urgency Indicator]       TDMA information exchange" },
610     {  7, "[Acknowledgement Request] TDMA information exchange" },
611     {  8, "[Messsage Updating]       TDMA information exchange" },
612     {  9, "[Call Back Number]        TDMA information exchange" },
613     { 10, "[Response Code]           TDMA information exchange" },
614     { 11, "[Teleservice ID]          TDMA information exchange" },
615     { 12, "Billing identifier" },
616     { 13, "Single shot indicator" },
617     {  0, NULL },
618 };
619
620 /*!
621  * Checks whether the PDU looks a bit like UCP and checks the checksum
622  *
623  * \param       tvb     The buffer with PDU-data
624  * \param       endpkt  Returns pointer, indicating the end of the PDU
625  *
626  * \return              The state of this PDU
627  * \retval      0               Definitely UCP
628  * \retval      UCP_SHORTENED   Packet may be there, but not complete
629  * \retval      UCP_MALFORMED   Hmmmm, not UCP after all...
630  * \retval      UCP_INV_CHK     Nice packet, but checksum doesn't add up...
631  */
632 static int
633 check_ucp(tvbuff_t *tvb, int *endpkt)
634 {
635     guint        offset = 1;
636     guint        checksum = 0;
637     int          pkt_check, tmp;
638     int          length;
639
640     length = tvb_find_guint8(tvb, offset, -1, UCP_ETX);
641     if (length == -1) {
642         *endpkt = tvb_reported_length_remaining(tvb, offset);
643         return UCP_SHORTENED;
644     }
645     if (length > (int) tvb_reported_length(tvb)) {
646         *endpkt = 0;
647         return UCP_MALFORMED;
648     }
649     for (; offset < (guint) (length - 2); offset++)
650         checksum += tvb_get_guint8(tvb, offset);
651     checksum &= 0xFF;
652     tmp = tvb_get_guint8(tvb, offset++);
653     pkt_check = AHex2Bin(tmp);
654     tmp = tvb_get_guint8(tvb, offset++);
655     pkt_check = 16 * pkt_check + AHex2Bin(tmp);
656     *endpkt = offset + 1;
657     if (checksum == (guint) pkt_check)
658         return 0;
659     else
660         return UCP_INV_CHK;
661 }
662
663 /*!
664  * UCP equivalent of mktime() (3). Convert date to standard 'time_t' format
665  *
666  * \param       datestr The UCP-formatted date to convert
667  *
668  * \return              The date in standard 'time_t' format.
669  */
670 static time_t
671 ucp_mktime(char *datestr)
672 {
673     struct tm    r_time;
674
675     r_time.tm_mday = 10 * (datestr[0] - '0') + (datestr[1] - '0');
676     r_time.tm_mon  = (10 * (datestr[2] - '0') + (datestr[3] - '0')) - 1;
677     r_time.tm_year = 10 * (datestr[4] - '0') + (datestr[5] - '0');
678     if (r_time.tm_year < 90) 
679         r_time.tm_year += 100;
680     r_time.tm_hour = 10 * (datestr[6] - '0') + (datestr[7] - '0');
681     r_time.tm_min  = 10 * (datestr[8] - '0') + (datestr[9] - '0');
682     if (datestr[10])
683         r_time.tm_sec  = 10 * (datestr[10] - '0') + (datestr[11] - '0');
684     return mktime(&r_time);
685 }
686
687 /*!
688  * Scanning routines to add standard types (byte, int, string, data)
689  * to the protocol-tree. Each field is seperated with a slash ('/').
690  *
691  * \param       tree    The protocol tree to add to
692  * \param       tvb     Buffer containing the data
693  * \param       field   The actual field, whose value needs displaying
694  * \param       offset  Location of field within the buffer, returns location
695  *                      of next field.
696  *
697  * \return              For 'int'-types, the value of the field.
698  */
699 static void
700 ucp_handle_string(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
701 {
702     char         strval[BUFSIZ];
703     int          idx = 0;
704     int          tmpoff = *offset;
705
706     idx = 0;
707     while ((strval[idx++] = tvb_get_guint8(tvb, tmpoff++)) != '/')
708         ;
709     if (idx > 1) {
710         strval[--idx] = '\0';
711         proto_tree_add_string(tree, field, tvb, *offset, idx, strval);
712     }
713     *offset = tmpoff;
714 }
715
716 static guint
717 ucp_handle_byte(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
718 {
719     guint        intval = 0;
720
721     if ((intval = tvb_get_guint8(tvb, (*offset)++)) != '/') {
722         proto_tree_add_uint(tree, field, tvb, *offset - 1, 1, intval);
723         (*offset)++;
724     }
725     return intval;
726 }
727
728 static guint
729 ucp_handle_int(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
730 {
731     char         strval[BUFSIZ];
732     guint        intval = 0;
733     int          tmpoff = *offset;
734     int          idx = 0;
735  
736     while ((strval[idx++] = tvb_get_guint8(tvb, tmpoff++)) != '/')
737         ;
738     if (idx > 1) {
739         strval[--idx] = '\0';
740         intval = atoi(strval);
741         proto_tree_add_uint(tree, field, tvb, *offset, idx, intval);
742     }
743     *offset = tmpoff;
744     return intval;
745 }
746
747 static void
748 ucp_handle_time(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
749 {
750     char         strval[BUFSIZ];
751     time_t       tval;
752     nstime_t     tmptime;
753     int          tmpoff = *offset;
754     int          idx = 0;
755
756     while ((strval[idx++] = tvb_get_guint8(tvb, tmpoff++)) != '/')
757         ;
758     if (idx > 1) {
759         strval[--idx] = '\0';
760         tval = ucp_mktime(strval);
761         tmptime.secs  = tval;
762         tmptime.nsecs = 0;
763         proto_tree_add_time(tree, field, tvb, *offset, idx, &tmptime);
764     }
765     *offset = tmpoff;
766 }
767
768 static void
769 ucp_handle_data(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
770 {
771     int          tmpoff = *offset;
772
773     while (tvb_get_guint8(tvb, tmpoff++) != '/')
774         ;
775     if ((tmpoff - *offset) > 1) 
776         proto_tree_add_item(tree, field, tvb, *offset,
777                             tmpoff - *offset - 1, FALSE);
778     *offset = tmpoff;
779 }
780
781 /*!
782  * Handle the data-field within the UCP-message, according the Message Type
783  *      - 1     Tone only
784  *      - 2     Numeric message
785  *      - 3     Alphanumeric message
786  *      - 4     Transparent (binary) data
787  *      - 5     Standard text handling
788  *      - 6     Alphanumeric message in specified character set
789  *
790  * \param       tree    The protocol tree to add to
791  * \param       tvb     Buffer containing the data
792  * \param       field   The actual field, whose value needs displaying
793  * \param       offset  Location of field within the buffer, returns location
794  *                      of next field.
795  */
796 static void
797 ucp_handle_mt(proto_tree *tree, tvbuff_t *tvb, int *offset)
798 {
799     char                 strval[BUFSIZ];
800     guint                intval;
801     int                  idx;
802
803     intval = ucp_handle_byte(tree, tvb, hf_ucp_parm_MT, offset);
804     switch (intval) {
805         case '1':                               /* Tone only, no data   */
806             break;
807         case '4':                               /* TMsg, no of bits     */
808             ucp_handle_string(tree, tvb, hf_ucp_parm_NB, offset);
809             /* fall through here for the data piece     */
810         case '2':
811         case '3':
812             ucp_handle_data(tree, tvb, hf_ucp_data_section, offset);
813             break;
814         case '5':
815             ucp_handle_byte(tree, tvb, hf_ucp_parm_PNC, offset);
816             ucp_handle_string(tree, tvb, hf_ucp_parm_LNo, offset);
817             ucp_handle_string(tree, tvb, hf_ucp_parm_LST, offset);
818             ucp_handle_string(tree, tvb, hf_ucp_parm_TNo, offset);
819             break;
820         case '6':
821             ucp_handle_data(tree, tvb, hf_ucp_data_section, offset);
822             ucp_handle_int(tree, tvb, hf_ucp_parm_CS, offset);
823             break;
824         default:
825             break;              /* No data so ? */
826     }
827 }
828
829 /*!
830  * Handle the data within the 'Extended services' field. Each field having the
831  * format TTLLDD..., TT being the type of service, LL giving the length of the
832  * field, DD... containing the actual data
833  *
834  * \param       tree    The protocol tree to add to
835  * \param       tvb     Buffer containing the extended services data
836  */
837 static void
838 ucp_handle_XSer(proto_tree *tree, tvbuff_t *tvb)
839 {
840     int          offset = 0;
841     guint        intval;
842     int          service;
843     int          len;
844
845     while ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
846         service = AHex2Bin(intval);
847         intval = tvb_get_guint8(tvb, offset++);
848         service = service * 16 + AHex2Bin(intval);
849         intval = tvb_get_guint8(tvb, offset++);
850         len = AHex2Bin(intval);
851         intval = tvb_get_guint8(tvb, offset++);
852         len = len * 16 + AHex2Bin(intval);
853         proto_tree_add_uint(tree, hf_xser_service, tvb, offset,
854                             2 * len, service);
855         offset += (2 * len);
856     }
857 }
858
859 /* Next definitions are just a convenient shorthand to make the coding a
860  * bit more readable instead of summing up all these parameters.
861  */
862 #define UcpHandleString(field)  ucp_handle_string(tree, tvb, (field), &offset)
863
864 #define UcpHandleByte(field)    ucp_handle_byte(tree, tvb, (field), &offset)
865
866 #define UcpHandleInt(field)     ucp_handle_int(tree, tvb, (field), &offset)
867
868 #define UcpHandleTime(field)    ucp_handle_time(tree, tvb, (field), &offset)
869
870 #define UcpHandleData(field)    ucp_handle_data(tree, tvb, (field), &offset)
871
872 /*!
873  * The next set of routines handle the different operation types,
874  * associated with UCP.
875  */
876 static void
877 add_00O(proto_tree *tree, tvbuff_t *tvb)
878 {                                               /* Enquiry      */
879     int          offset = 1;
880
881     UcpHandleString(hf_ucp_parm_AdC);
882     UcpHandleString(hf_ucp_parm_OAdC);
883     UcpHandleString(hf_ucp_parm_OAC);
884 }
885
886 static void
887 add_00R(proto_tree *tree, tvbuff_t *tvb)
888 {
889     int          offset = 1;
890     guint        intval;
891
892     intval = UcpHandleByte(hf_ucp_parm_ACK);
893     if (intval == 'A')
894     {
895         UcpHandleByte(hf_ucp_parm_BAS);
896         UcpHandleByte(hf_ucp_parm_LAR);
897         UcpHandleByte(hf_ucp_parm_L1R);
898         UcpHandleByte(hf_ucp_parm_L3R);
899         UcpHandleByte(hf_ucp_parm_LCR);
900         UcpHandleByte(hf_ucp_parm_LUR);
901         UcpHandleByte(hf_ucp_parm_LRR);
902         UcpHandleByte(hf_ucp_parm_RT);
903         UcpHandleInt(hf_ucp_parm_NoN);
904         UcpHandleInt(hf_ucp_parm_NoA);
905         UcpHandleInt(hf_ucp_parm_NoB);
906     } else {
907         UcpHandleInt(hf_ucp_parm_EC);
908         UcpHandleString(hf_ucp_parm_SM);
909     }
910 }
911
912 static void
913 add_01O(proto_tree *tree, tvbuff_t *tvb)
914 {                                               /* Call input   */
915     int          offset = 1;
916
917     UcpHandleString(hf_ucp_parm_AdC);
918     UcpHandleString(hf_ucp_parm_OAdC);
919     UcpHandleString(hf_ucp_parm_OAC);
920     ucp_handle_mt(tree, tvb, &offset);
921 }
922
923 static void
924 add_01R(proto_tree *tree, tvbuff_t *tvb)
925 {
926     int          offset = 1;
927     guint        intval;
928
929     intval = UcpHandleByte(hf_ucp_parm_ACK);
930     if (intval == 'N')
931         UcpHandleInt(hf_ucp_parm_EC);
932     UcpHandleString(hf_ucp_parm_SM);
933 }
934
935 static void
936 add_02O(proto_tree *tree, tvbuff_t *tvb)
937 {                                               /* Multiple address call input*/
938     int          offset = 1;
939     guint        intval;
940     guint        idx;
941
942     intval = UcpHandleInt(hf_ucp_parm_NPL);
943     for (idx = 0; idx < intval; idx++)
944         UcpHandleString(hf_ucp_parm_AdC);
945
946     UcpHandleString(hf_ucp_parm_OAdC);
947     UcpHandleString(hf_ucp_parm_OAC);
948     ucp_handle_mt(tree, tvb, &offset);
949 }
950
951 #define add_02R(a, b) add_01R(a,b)
952
953 static void
954 add_03O(proto_tree *tree, tvbuff_t *tvb)
955 {                                               /* Call input with SS   */
956     int          offset = 1;
957     guint        intval;
958     guint        idx;
959
960     UcpHandleString(hf_ucp_parm_AdC);
961     UcpHandleString(hf_ucp_parm_OAdC);
962     UcpHandleString(hf_ucp_parm_OAC);
963     intval = UcpHandleInt(hf_ucp_parm_NPL);
964     for (idx = 0; idx < intval; idx++)
965         UcpHandleString(hf_ucp_parm_GA);
966
967     UcpHandleByte(hf_ucp_parm_RP);
968     UcpHandleString(hf_ucp_parm_LRP);
969     UcpHandleByte(hf_ucp_parm_PR);
970     UcpHandleString(hf_ucp_parm_LPR);
971     UcpHandleByte(hf_ucp_parm_UM);
972     UcpHandleString(hf_ucp_parm_LUM);
973     UcpHandleByte(hf_ucp_parm_RC);
974     UcpHandleString(hf_ucp_parm_LRC);
975     UcpHandleByte(hf_ucp_parm_DD);
976     UcpHandleTime(hf_ucp_parm_DDT);
977     ucp_handle_mt(tree, tvb, &offset);
978 }
979
980 #define add_03R(a, b) add_01R(a,b)
981
982 static void
983 add_04O(proto_tree *tree, tvbuff_t *tvb)
984 {                                               /* Address list information */
985     int          offset = 1;
986
987     UcpHandleString(hf_ucp_parm_GAdC);
988     UcpHandleString(hf_ucp_parm_AC);
989     UcpHandleString(hf_ucp_parm_OAdC);
990     UcpHandleString(hf_ucp_parm_OAC);
991 }
992
993 static void
994 add_04R(proto_tree *tree, tvbuff_t *tvb)
995 {
996     int          offset = 1;
997     guint        intval;
998     guint        idx;
999
1000     intval = UcpHandleByte(hf_ucp_parm_ACK);
1001     if (intval == 'A') {
1002         intval = UcpHandleInt(hf_ucp_parm_NPL);
1003         for (idx = 0; idx < intval; idx++)
1004             UcpHandleString(hf_ucp_parm_AdC);
1005         UcpHandleString(hf_ucp_parm_GAdC);
1006     } else
1007         UcpHandleInt(hf_ucp_parm_EC);
1008     UcpHandleString(hf_ucp_parm_SM);
1009 }
1010
1011 static void
1012 add_05O(proto_tree *tree, tvbuff_t *tvb)
1013 {                                               /* Change address list */
1014     int          offset = 1;
1015     guint        intval;
1016     guint        idx;
1017
1018     UcpHandleString(hf_ucp_parm_GAdC);
1019     UcpHandleString(hf_ucp_parm_AC);
1020     UcpHandleString(hf_ucp_parm_OAdC);
1021     UcpHandleString(hf_ucp_parm_OAC);
1022     intval = UcpHandleInt(hf_ucp_parm_NPL);
1023     for (idx = 0; idx < intval; idx++)
1024         UcpHandleString(hf_ucp_parm_AdC);
1025     UcpHandleByte(hf_ucp_parm_A_D);
1026 }
1027
1028 #define add_05R(a, b) add_01R(a, b)
1029
1030 static void
1031 add_06O(proto_tree *tree, tvbuff_t *tvb)
1032 {                                               /* Advice of accum. charges */
1033     int          offset = 1;
1034
1035     UcpHandleString(hf_ucp_parm_AdC);
1036     UcpHandleString(hf_ucp_parm_AC);
1037 }
1038
1039 static void
1040 add_06R(proto_tree *tree, tvbuff_t *tvb)
1041 {
1042     int          offset = 1;
1043     guint        intval;
1044
1045     intval = UcpHandleByte(hf_ucp_parm_ACK);
1046     if (intval == 'A') {
1047         UcpHandleTime(hf_ucp_parm_CT);
1048         UcpHandleString(hf_ucp_parm_AAC);
1049     } else
1050         UcpHandleInt(hf_ucp_parm_EC);
1051     UcpHandleString(hf_ucp_parm_SM);
1052 }
1053
1054 static void
1055 add_07O(proto_tree *tree, tvbuff_t *tvb)
1056 {                                               /* Password management  */
1057     int          offset = 1;
1058
1059     UcpHandleString(hf_ucp_parm_AdC);
1060     UcpHandleString(hf_ucp_parm_AC);
1061     UcpHandleString(hf_ucp_parm_NAC);
1062 }
1063
1064 #define add_07R(a, b) add_01R(a, b)
1065
1066 static void
1067 add_08O(proto_tree *tree, tvbuff_t *tvb)
1068 {                                               /* Leg. code management */
1069     int          offset = 1;
1070
1071     UcpHandleString(hf_ucp_parm_AdC);
1072     UcpHandleString(hf_ucp_parm_AC);
1073     UcpHandleString(hf_ucp_parm_LAC);
1074     UcpHandleString(hf_ucp_parm_L1P);
1075     UcpHandleString(hf_ucp_parm_L3P);
1076     UcpHandleString(hf_ucp_parm_LRC);
1077     UcpHandleString(hf_ucp_parm_LUM);
1078     UcpHandleString(hf_ucp_parm_LRP);
1079     UcpHandleString(hf_ucp_parm_LST);
1080 }
1081
1082 #define add_08R(a, b) add_01R(a, b)
1083
1084 static void
1085 add_09O(proto_tree *tree, tvbuff_t *tvb)
1086 {                                               /* Standard text information */
1087     int          offset = 1;
1088
1089     UcpHandleString(hf_ucp_parm_LNo);
1090     UcpHandleString(hf_ucp_parm_LST);
1091 }
1092
1093 static void
1094 add_09R(proto_tree *tree, tvbuff_t *tvb)
1095 {
1096     int          offset = 1;
1097     guint        intval;
1098     guint        idx;
1099
1100     intval = UcpHandleByte(hf_ucp_parm_ACK);
1101     if (intval == 'A') {
1102         intval = UcpHandleInt(hf_ucp_parm_NPL);
1103         for (idx = 0; idx < intval; idx++)
1104             UcpHandleString(hf_ucp_parm_LST);
1105     } else
1106         UcpHandleInt(hf_ucp_parm_EC);
1107     UcpHandleString(hf_ucp_parm_SM);
1108 }
1109
1110 static void
1111 add_10O(proto_tree *tree, tvbuff_t *tvb)
1112 {                                               /* Change standard text */
1113     int          offset = 1;
1114
1115     UcpHandleString(hf_ucp_parm_AdC);
1116     UcpHandleString(hf_ucp_parm_AC);
1117     UcpHandleString(hf_ucp_parm_LNo);
1118     UcpHandleString(hf_ucp_parm_TNo);
1119     UcpHandleData(hf_ucp_parm_STx);
1120     UcpHandleInt(hf_ucp_parm_CS);
1121 }
1122
1123 #define add_10R(a, b) add_01R(a, b)
1124
1125 #define add_11O(a, b) add_06O(a, b)             /* Request roaming info */
1126
1127 static void
1128 add_11R(proto_tree *tree, tvbuff_t *tvb)
1129 {
1130     int          offset = 1;
1131     guint        intval;
1132     guint        idx;
1133
1134     intval = UcpHandleByte(hf_ucp_parm_ACK);
1135     if (intval == 'A') {
1136         intval = UcpHandleInt(hf_ucp_parm_NPL);
1137         for (idx = 0; idx < intval; idx++)
1138             UcpHandleString(hf_ucp_parm_GA);
1139     } else
1140         UcpHandleInt(hf_ucp_parm_EC);
1141     UcpHandleString(hf_ucp_parm_SM);
1142 }
1143
1144 static void
1145 add_12O(proto_tree *tree, tvbuff_t *tvb)
1146 {                                               /* Change roaming       */
1147     int          offset = 1;
1148     guint        intval;
1149     guint        idx;
1150
1151     UcpHandleString(hf_ucp_parm_AdC);
1152     UcpHandleString(hf_ucp_parm_AC);
1153     intval = UcpHandleInt(hf_ucp_parm_NPL);
1154     for (idx = 0; idx < intval; idx++)
1155         UcpHandleString(hf_ucp_parm_GA);
1156 }
1157
1158 #define add_12R(a, b) add_01R(a, b)
1159
1160 #define add_13O(a, b) add_06O(a, b)             /* Roaming reset        */
1161
1162 #define add_13R(a, b) add_01R(a, b)
1163
1164 static void
1165 add_14O(proto_tree *tree, tvbuff_t *tvb)
1166 {                                               /* Message retrieval    */
1167     int          offset = 1;
1168
1169     UcpHandleString(hf_ucp_parm_AdC);
1170     UcpHandleString(hf_ucp_parm_AC);
1171     UcpHandleString(hf_ucp_parm_MNo);
1172     UcpHandleByte(hf_ucp_parm_R_T);
1173 }
1174
1175 static void
1176 add_14R(proto_tree *tree, tvbuff_t *tvb)
1177 {
1178     int          offset = 1;
1179     guint        intval;
1180     guint        idx;
1181
1182     intval = UcpHandleByte(hf_ucp_parm_ACK);
1183     if (intval == 'A') {
1184         intval = UcpHandleInt(hf_ucp_parm_NPL);
1185         /*
1186          * Spec is unclear here. Is 'SM' part of the Msg:s field or not?
1187          * For now, assume it is part of it...
1188          */
1189         for (idx = 0; idx < intval; idx++)
1190             UcpHandleData(hf_ucp_data_section);
1191     } else {
1192         UcpHandleInt(hf_ucp_parm_EC);
1193         UcpHandleString(hf_ucp_parm_SM);
1194     }
1195 }
1196
1197 static void
1198 add_15O(proto_tree *tree, tvbuff_t *tvb)
1199 {                                               /* Request call barring */
1200     int          offset = 1;
1201
1202     UcpHandleString(hf_ucp_parm_AdC);
1203     UcpHandleString(hf_ucp_parm_AC);
1204     UcpHandleTime(hf_ucp_parm_ST);
1205     UcpHandleTime(hf_ucp_parm_SP);
1206 }
1207
1208 #define add_15R(a, b) add_01R(a, b)
1209
1210 #define add_16O(a, b) add_06O(a, b)             /* Cancel call barring  */
1211
1212 #define add_16R(a, b) add_01R(a, b)
1213
1214 static void
1215 add_17O(proto_tree *tree, tvbuff_t *tvb)
1216 {                                               /* Request call diversion */
1217     int          offset = 1;
1218
1219     UcpHandleString(hf_ucp_parm_AdC);
1220     UcpHandleString(hf_ucp_parm_AC);
1221     UcpHandleString(hf_ucp_parm_DAdC);
1222     UcpHandleTime(hf_ucp_parm_ST);
1223     UcpHandleTime(hf_ucp_parm_SP);
1224 }
1225
1226 #define add_17R(a, b) add_01R(a, b)
1227
1228 #define add_18O(a, b) add_06O(a, b)             /* Cancel call diversion */
1229
1230 #define add_18R(a, b) add_01R(a, b)
1231
1232 static void
1233 add_19O(proto_tree *tree, tvbuff_t *tvb)
1234 {                                               /* Request deferred delivery*/
1235     int          offset = 1;
1236
1237     UcpHandleString(hf_ucp_parm_AdC);
1238     UcpHandleString(hf_ucp_parm_AC);
1239     UcpHandleTime(hf_ucp_parm_ST);
1240     UcpHandleTime(hf_ucp_parm_SP);
1241 }
1242
1243 #define add_19R(a, b) add_01R(a, b)
1244
1245 #define add_20O(a, b) add_06O(a, b)             /* Cancel deferred delivery */
1246
1247 #define add_20R(a, b) add_01R(a, b)
1248
1249 #define add_21O(a, b) add_06O(a, b)             /* All features reset   */
1250
1251 #define add_21R(a, b) add_01R(a, b)
1252
1253 static void
1254 add_22O(proto_tree *tree, tvbuff_t *tvb)
1255 {                                               /* Call input w. add. CS */
1256     int          offset = 1;
1257
1258     UcpHandleString(hf_ucp_parm_AdC);
1259     UcpHandleString(hf_ucp_parm_OAdC);
1260     UcpHandleString(hf_ucp_parm_OAC);
1261     UcpHandleData(hf_ucp_data_section);
1262     UcpHandleInt(hf_ucp_parm_CS);
1263 }
1264
1265 #define add_22R(a, b) add_01R(a, b)
1266
1267 static void
1268 add_23O(proto_tree *tree, tvbuff_t *tvb)
1269 {                                               /* UCP version status   */
1270     int          offset = 1;
1271
1272     UcpHandleString(hf_ucp_parm_IVR5x);
1273     UcpHandleByte(hf_ucp_parm_REQ_OT);
1274 }
1275
1276 static void
1277 add_23R(proto_tree *tree, tvbuff_t *tvb)
1278 {
1279     int          offset = 1;
1280     guint        intval;
1281     guint        idx;
1282
1283     intval = UcpHandleByte(hf_ucp_parm_ACK);
1284     if (intval == 'A') {
1285         UcpHandleByte(hf_ucp_parm_IVR5x);
1286         intval = UcpHandleInt(hf_ucp_parm_NPL);
1287         for (idx = 0; idx < intval; idx++)
1288             UcpHandleInt(hf_ucp_hdr_OT);
1289     } else
1290         UcpHandleInt(hf_ucp_parm_EC);
1291     UcpHandleString(hf_ucp_parm_SM);
1292 }
1293
1294 static void
1295 add_24O(proto_tree *tree, tvbuff_t *tvb)
1296 {                                               /* Mobile subs. feature stat*/
1297     int          offset = 1;
1298
1299     UcpHandleString(hf_ucp_parm_AdC);
1300     UcpHandleString(hf_ucp_parm_AC);
1301     UcpHandleByte(hf_ucp_parm_SSTAT);
1302 }
1303
1304 static void
1305 add_24R(proto_tree *tree, tvbuff_t *tvb)
1306 {
1307     int          offset = 1;
1308     guint        intval;
1309     guint        idx;
1310
1311     intval = UcpHandleByte(hf_ucp_parm_ACK);
1312     if (intval == 'A') {
1313         if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1314             proto_tree_add_text(tree, tvb, offset - 1, 1,
1315                                 "GA roaming definitions");
1316             if (intval == 'N') {
1317                 proto_tree_add_text(tree, tvb, offset -1, 1,
1318                                 "Not subscribed/not allowed");
1319                 offset++;
1320             } else {
1321                 --offset;
1322                 intval = UcpHandleInt(hf_ucp_parm_NPL);
1323                 for (idx = 0; idx < intval; idx++)
1324                     UcpHandleData(hf_ucp_data_section);
1325             }
1326         }
1327         if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1328             proto_tree_add_text(tree, tvb, offset - 1, 1,
1329                                 "Call barring definitions");
1330             if (intval == 'N') {
1331                 proto_tree_add_text(tree, tvb, offset -1, 1,
1332                                 "Not subscribed/not allowed");
1333                 offset++;
1334             } else {
1335                 --offset;
1336                 intval = UcpHandleInt(hf_ucp_parm_NPL);
1337                 for (idx = 0; idx < intval; idx++)
1338                     UcpHandleData(hf_ucp_data_section);
1339             }
1340         }
1341         if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1342             proto_tree_add_text(tree, tvb, offset - 1, 1,
1343                                 "Deferred delivery definitions");
1344             if (intval == 'N') {
1345                 proto_tree_add_text(tree, tvb, offset -1, 1,
1346                                 "Not subscribed/not allowed");
1347                 offset++;
1348             } else {
1349                 --offset;
1350                 intval = UcpHandleInt(hf_ucp_parm_NPL);
1351                 for (idx = 0; idx < intval; idx++)
1352                     UcpHandleData(hf_ucp_data_section);
1353             }
1354         }
1355         if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1356             proto_tree_add_text(tree, tvb, offset - 1, 1,
1357                                 "Diversion definitions");
1358             if (intval == 'N') {
1359                 proto_tree_add_text(tree, tvb, offset -1, 1,
1360                                 "Not subscribed/not allowed");
1361                 offset++;
1362             } else {
1363                 --offset;
1364                 intval = UcpHandleInt(hf_ucp_parm_NPL);
1365                 for (idx = 0; idx < intval; idx++)
1366                     UcpHandleData(hf_ucp_data_section);
1367             }
1368         }
1369         UcpHandleInt(hf_ucp_parm_LMN);
1370         if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1371             if (intval == 'N') {
1372                 proto_tree_add_string(tree, hf_ucp_parm_NMESS_str, tvb,
1373                                 offset -1, 1, "Not subscribed/not allowed");
1374                 offset++;
1375             } else {
1376                 --offset;
1377                 intval = UcpHandleInt(hf_ucp_parm_NMESS);
1378             }
1379         }
1380     } else
1381         UcpHandleInt(hf_ucp_parm_EC);
1382     UcpHandleString(hf_ucp_parm_SM);
1383 }
1384
1385 static void
1386 add_30O(proto_tree *tree, tvbuff_t *tvb)
1387 {                                               /* SMS message transfer */
1388     int          offset = 1;
1389
1390     UcpHandleString(hf_ucp_parm_AdC);
1391     UcpHandleString(hf_ucp_parm_OAdC);
1392     UcpHandleString(hf_ucp_parm_AC);
1393     UcpHandleByte(hf_ucp_parm_NRq);
1394     UcpHandleString(hf_ucp_parm_NAdC);
1395     UcpHandleInt(hf_ucp_parm_NPID);
1396     UcpHandleByte(hf_ucp_parm_DD);
1397     UcpHandleTime(hf_ucp_parm_DDT);
1398     UcpHandleTime(hf_ucp_parm_VP);
1399     UcpHandleData(hf_ucp_data_section);
1400 }
1401
1402 static void
1403 add_30R(proto_tree *tree, tvbuff_t *tvb)
1404 {
1405     int          offset = 1;
1406     guint        intval;
1407
1408     intval = UcpHandleByte(hf_ucp_parm_ACK);
1409     if (intval == 'A')
1410         UcpHandleTime(hf_ucp_parm_MVP);
1411     else
1412         UcpHandleInt(hf_ucp_parm_EC);
1413     UcpHandleString(hf_ucp_parm_SM);
1414 }
1415
1416 static void
1417 add_31O(proto_tree *tree, tvbuff_t *tvb)
1418 {                                               /* SMT alert            */
1419     int          offset = 1;
1420
1421     UcpHandleString(hf_ucp_parm_AdC);
1422     UcpHandleInt(hf_ucp_parm_PID);
1423 }
1424
1425 #define add_31R(a, b) add_01R(a, b)
1426
1427 static void
1428 add_5xO(proto_tree *tree, tvbuff_t *tvb)
1429 {                                               /* 50-series operations */
1430     guint        intval;
1431     int          offset = 1;
1432     int          tmpoff;
1433     proto_item  *ti;
1434     tvbuff_t    *tmptvb;
1435
1436     UcpHandleString(hf_ucp_parm_AdC);
1437     UcpHandleString(hf_ucp_parm_OAdC);
1438     UcpHandleString(hf_ucp_parm_AC);
1439     UcpHandleByte(hf_ucp_parm_NRq);
1440     UcpHandleString(hf_ucp_parm_NAdC);
1441     UcpHandleByte(hf_ucp_parm_NT);
1442     UcpHandleInt(hf_ucp_parm_NPID);
1443     UcpHandleByte(hf_ucp_parm_LRq);
1444     UcpHandleString(hf_ucp_parm_LRAd);
1445     UcpHandleInt(hf_ucp_parm_LPID);
1446     UcpHandleByte(hf_ucp_parm_DD);
1447     UcpHandleTime(hf_ucp_parm_DDT);
1448     UcpHandleTime(hf_ucp_parm_VP);
1449     UcpHandleString(hf_ucp_parm_RPID);
1450     UcpHandleTime(hf_ucp_parm_SCTS);
1451     UcpHandleByte(hf_ucp_parm_Dst);
1452     UcpHandleInt(hf_ucp_parm_Rsn);
1453     UcpHandleTime(hf_ucp_parm_DSCTS);
1454     UcpHandleByte(hf_ucp_parm_MT);
1455     UcpHandleString(hf_ucp_parm_NB);
1456     UcpHandleData(hf_ucp_data_section);
1457     UcpHandleByte(hf_ucp_parm_MMS);
1458     UcpHandleByte(hf_ucp_parm_PR);
1459     UcpHandleByte(hf_ucp_parm_DCs);
1460     UcpHandleByte(hf_ucp_parm_MCLs);
1461     UcpHandleByte(hf_ucp_parm_RPI);
1462     if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1463         proto_tree_add_string(tree, hf_ucp_parm_CPg, tvb, offset - 1,1,
1464                               "(reserved for Code Page)");
1465         offset++;
1466     }
1467     if ((intval = tvb_get_guint8(tvb, offset++)) != '/') {
1468         proto_tree_add_string(tree, hf_ucp_parm_RPLy, tvb, offset - 1,1,
1469                               "(reserved for Reply type)");
1470         offset++;
1471     }
1472     UcpHandleString(hf_ucp_parm_OTOA);
1473     UcpHandleString(hf_ucp_parm_HPLMN);
1474     tmpoff = offset;                            /* Extra services       */
1475     while (tvb_get_guint8(tvb, tmpoff++) != '/')
1476         ;
1477     if ((tmpoff - offset) > 1) {
1478         int      len = tmpoff - offset - 1;
1479
1480         ti = proto_tree_add_item(tree, hf_ucp_parm_XSer,tvb,offset,len,FALSE);
1481         tmptvb = tvb_new_subset(tvb, offset, len + 1, len + 1);
1482         proto_item_add_subtree(ti, ett_XSer);
1483         ucp_handle_XSer(ti, tmptvb);
1484     }
1485     offset = tmpoff;
1486     UcpHandleData(hf_ucp_parm_RES4);
1487     UcpHandleData(hf_ucp_parm_RES5);
1488 }
1489
1490 #define add_5xR(a, b) add_30R(a, b)
1491
1492 static void
1493 add_6xO(proto_tree *tree, tvbuff_t *tvb, guint8 OT)
1494 {                                               /* 60-series operations */
1495     int          offset = 1;
1496
1497     UcpHandleString(hf_ucp_parm_OAdC);
1498     UcpHandleByte(hf_ucp_parm_OTON);
1499     UcpHandleByte(hf_ucp_parm_ONPI);
1500     if (OT == 60) {
1501         UcpHandleByte(hf_ucp_parm_STYP0);
1502     } else {
1503         UcpHandleByte(hf_ucp_parm_STYP1);
1504     }
1505     UcpHandleData(hf_ucp_parm_PWD);
1506     UcpHandleData(hf_ucp_parm_NPWD);
1507     UcpHandleString(hf_ucp_parm_VERS);
1508     UcpHandleString(hf_ucp_parm_LAdC);
1509     UcpHandleByte(hf_ucp_parm_LTON);
1510     UcpHandleByte(hf_ucp_parm_LNPI);
1511     UcpHandleInt(hf_ucp_parm_OPID);
1512     UcpHandleData(hf_ucp_parm_RES1);
1513     UcpHandleData(hf_ucp_parm_RES2);
1514 }
1515
1516 #define add_6xR(a, b) add_01R(a, b)
1517
1518 /*
1519  * End of convenient shorthands
1520  */
1521 #undef UcpHandleString
1522 #undef UcpHandleByte
1523 #undef UcpHandleInt
1524 #undef UcpHandleTime
1525 #undef UcpHandleData
1526
1527 /* Code to actually dissect the packets */
1528 /*
1529  * Overlapping data for these functions
1530  */
1531 static int       result, endpkt;
1532
1533 /*
1534  * The heuristic dissector
1535  */
1536 static gboolean
1537 dissect_ucp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1538 {
1539     guint8       O_R;           /* Request or response                  */
1540
1541     if (!proto_is_protocol_enabled(proto_ucp))
1542         return FALSE;           /* UCP was disabled     */
1543
1544     /* This runs atop TCP, so we are guaranteed that there is at least one
1545        byte in the tvbuff. */
1546     if (tvb_get_guint8(tvb, 0) != UCP_STX)
1547         return FALSE;
1548
1549     result = check_ucp(tvb, &endpkt);
1550
1551     if (result == UCP_MALFORMED)
1552         return FALSE;
1553     if (endpkt < UCP_OT_OFFSET + 1)
1554         /*
1555          * Might be shortened packet but don't handle anyway.
1556          */
1557         return FALSE;
1558
1559     /*
1560      * Try getting the operation-type and whether it's a request/response 
1561      */
1562     O_R = tvb_get_guint8(tvb, UCP_O_R_OFFSET);
1563     if (match_strval(O_R, vals_hdr_O_R) == NULL)
1564         return FALSE;
1565     /*
1566      * Ok, looks like a valid packet, go dissect.
1567      */
1568     dissect_ucp(tvb, pinfo, tree);
1569     return TRUE;
1570 }
1571
1572 /*
1573  * The actual dissector
1574  */
1575 static void
1576 dissect_ucp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1577 {
1578     int          offset = 0;    /* Offset in packet within tvbuff       */
1579     int          tmpoff;        /* Local offset value (per field)       */
1580     guint8       O_R;           /* Request or response                  */
1581     guint8       OT;            /* Operation type                       */
1582     guint        intval;
1583     int          i;
1584
1585     /* Set up structures needed to add the protocol subtree and manage it */
1586     proto_item  *ti;
1587     proto_item  *sub_ti;
1588     proto_tree  *ucp_tree;
1589     tvbuff_t    *tmp_tvb;
1590
1591     O_R = tvb_get_guint8(tvb, UCP_O_R_OFFSET);
1592     /*
1593      * So do an atoi() on the operation type
1594      */
1595     OT  = tvb_get_guint8(tvb, UCP_OT_OFFSET) - '0';
1596     OT  = 10 * OT + (tvb_get_guint8(tvb, UCP_OT_OFFSET + 1) - '0');
1597
1598     /* Make entries in Protocol column and Info column on summary display */
1599     if (check_col(pinfo->cinfo, COL_PROTOCOL))
1600             col_set_str(pinfo->cinfo, COL_PROTOCOL, "UCP");
1601
1602     if (check_col(pinfo->cinfo, COL_INFO)) {
1603         col_clear(pinfo->cinfo, COL_INFO);
1604         col_append_fstr(pinfo->cinfo, COL_INFO, "%s (%s)",
1605                      val_to_str(OT,  vals_hdr_OT,  "unknown operation"),
1606                      match_strval(O_R, vals_hdr_O_R));
1607         if (result == UCP_SHORTENED)
1608             col_append_str(pinfo->cinfo, COL_INFO, " [short packet]");
1609         else if (result == UCP_INV_CHK)
1610             col_append_str(pinfo->cinfo, COL_INFO, " [checksum invalid]");
1611     }
1612
1613     /* In the interest of speed, if "tree" is NULL, don't do any work not
1614        necessary to generate protocol tree items. */
1615     if (tree) {
1616
1617         /* create display subtree for the protocol */
1618         ti = proto_tree_add_item(tree, proto_ucp, tvb, 0,
1619                                  tvb_length(tvb), FALSE);
1620
1621         ucp_tree = proto_item_add_subtree(ti, ett_ucp);
1622         /*
1623          * Process the packet here.
1624          * Transaction number
1625          */
1626         offset++;                               /* Skip <stx>   */
1627         tmpoff = offset;
1628         intval = tvb_get_guint8(tvb, tmpoff++) - '0';
1629         intval = 10 * intval + (tvb_get_guint8(tvb, tmpoff++) - '0');
1630         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_TRN, tvb, offset,
1631                             UCP_TRN_LEN, intval);
1632         offset = tmpoff;
1633
1634         offset++;                               /* Skip '/'     */
1635         intval = 0;
1636         tmpoff = offset;
1637         for (i = 0; i < UCP_LEN_LEN; i++) {     /* Length       */
1638             intval = 10 * intval +
1639                         (tvb_get_guint8(tvb, tmpoff++) - '0');
1640         }
1641         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_LEN, tvb, offset,
1642                             UCP_LEN_LEN, intval);
1643         offset = tmpoff;
1644
1645         offset++;                               /* Operation/Response   */
1646         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_O_R, tvb, offset++,
1647                             UCP_O_R_LEN, O_R);
1648
1649         offset++;                               /* Operation type */
1650         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_OT, tvb, offset,
1651                             UCP_OT_LEN, OT);
1652         offset += UCP_OT_LEN;
1653         /*
1654          * Variable part starts here. Don't dissect if not complete.
1655          */
1656         if (result == UCP_SHORTENED)
1657             return;
1658         tmp_tvb = tvb_new_subset(tvb, offset, -1, -1);
1659         sub_ti = proto_tree_add_item(ucp_tree, hf_ucp_oper_section, tvb,
1660                                      offset, endpkt - offset, FALSE);
1661
1662         switch (OT) {
1663             case  1:
1664                 O_R == 'O' ? add_01O(sub_ti,tmp_tvb) : add_01R(sub_ti,tmp_tvb);
1665                 break;
1666             case  2:
1667                 O_R == 'O' ? add_02O(sub_ti,tmp_tvb) : add_02R(sub_ti,tmp_tvb);
1668                 break;
1669             case  3:
1670                 O_R == 'O' ? add_03O(sub_ti,tmp_tvb) : add_03R(sub_ti,tmp_tvb);
1671                 break;
1672             case  4:
1673                 O_R == 'O' ? add_04O(sub_ti,tmp_tvb) : add_04R(sub_ti,tmp_tvb);
1674                 break;
1675             case  5:
1676                 O_R == 'O' ? add_05O(sub_ti,tmp_tvb) : add_05R(sub_ti,tmp_tvb);
1677                 break;
1678             case  6:
1679                 O_R == 'O' ? add_06O(sub_ti,tmp_tvb) : add_06R(sub_ti,tmp_tvb);
1680                 break;
1681             case  7:
1682                 O_R == 'O' ? add_07O(sub_ti,tmp_tvb) : add_07R(sub_ti,tmp_tvb);
1683                 break;
1684             case  8:
1685                 O_R == 'O' ? add_08O(sub_ti,tmp_tvb) : add_08R(sub_ti,tmp_tvb);
1686                 break;
1687             case  9:
1688                 O_R == 'O' ? add_09O(sub_ti,tmp_tvb) : add_09R(sub_ti,tmp_tvb);
1689                 break;
1690             case 10:
1691                 O_R == 'O' ? add_10O(sub_ti,tmp_tvb) : add_10R(sub_ti,tmp_tvb);
1692                 break;
1693             case 11:
1694                 O_R == 'O' ? add_11O(sub_ti,tmp_tvb) : add_11R(sub_ti,tmp_tvb);
1695                 break;
1696             case 12:
1697                 O_R == 'O' ? add_12O(sub_ti,tmp_tvb) : add_12R(sub_ti,tmp_tvb);
1698                 break;
1699             case 13:
1700                 O_R == 'O' ? add_13O(sub_ti,tmp_tvb) : add_13R(sub_ti,tmp_tvb);
1701                 break;
1702             case 14:
1703                 O_R == 'O' ? add_14O(sub_ti,tmp_tvb) : add_14R(sub_ti,tmp_tvb);
1704                 break;
1705             case 15:
1706                 O_R == 'O' ? add_15O(sub_ti,tmp_tvb) : add_15R(sub_ti,tmp_tvb);
1707                 break;
1708             case 16:
1709                 O_R == 'O' ? add_16O(sub_ti,tmp_tvb) : add_16R(sub_ti,tmp_tvb);
1710                 break;
1711             case 17:
1712                 O_R == 'O' ? add_17O(sub_ti,tmp_tvb) : add_17R(sub_ti,tmp_tvb);
1713                 break;
1714             case 18:
1715                 O_R == 'O' ? add_18O(sub_ti,tmp_tvb) : add_18R(sub_ti,tmp_tvb);
1716                 break;
1717             case 19:
1718                 O_R == 'O' ? add_19O(sub_ti,tmp_tvb) : add_19R(sub_ti,tmp_tvb);
1719                 break;
1720             case 20:
1721                 O_R == 'O' ? add_20O(sub_ti,tmp_tvb) : add_20R(sub_ti,tmp_tvb);
1722                 break;
1723             case 21:
1724                 O_R == 'O' ? add_21O(sub_ti,tmp_tvb) : add_21R(sub_ti,tmp_tvb);
1725                 break;
1726             case 22:
1727                 O_R == 'O' ? add_22O(sub_ti,tmp_tvb) : add_22R(sub_ti,tmp_tvb);
1728                 break;
1729             case 23:
1730                 O_R == 'O' ? add_23O(sub_ti,tmp_tvb) : add_23R(sub_ti,tmp_tvb);
1731                 break;
1732             case 24:
1733                 O_R == 'O' ? add_24O(sub_ti,tmp_tvb) : add_24R(sub_ti,tmp_tvb);
1734                 break;
1735             case 30:
1736                 O_R == 'O' ? add_30O(sub_ti,tmp_tvb) : add_30R(sub_ti,tmp_tvb);
1737                 break;
1738             case 31:
1739                 O_R == 'O' ? add_31O(sub_ti,tmp_tvb) : add_31R(sub_ti,tmp_tvb);
1740                 break;
1741             case 51: case 52: case 53: case 54: case 55: case 56: case 57:
1742             case 58:
1743                 O_R == 'O' ? add_5xO(sub_ti,tmp_tvb) : add_5xR(sub_ti,tmp_tvb);
1744                 break;
1745             case 60: case 61:
1746                 O_R == 'O' ? add_6xO(sub_ti,tmp_tvb,OT) : add_6xR(sub_ti,tmp_tvb);
1747                 break;
1748             default:
1749                 break;
1750         }
1751     }
1752     return;
1753 }
1754
1755 /* Register the protocol with Ethereal */
1756 void
1757 proto_register_ucp(void)
1758 {
1759
1760     /* Setup list of fields     */
1761     static hf_register_info hf[] = {
1762         { &hf_ucp_hdr_TRN,
1763             { "Transaction Reference Number", "ucp.hdr.TRN",
1764               FT_UINT8, BASE_DEC, NULL, 0x00,
1765               "Transaction number for this command, used in windowing.",
1766               HFILL
1767             }
1768         },
1769         { &hf_ucp_hdr_LEN,
1770             { "Length", "ucp.hdr.LEN",
1771               FT_UINT16, BASE_DEC, NULL, 0x00,
1772               "Total number of characters between <stx>...<etx>.",
1773               HFILL
1774             }
1775         },
1776         { &hf_ucp_hdr_O_R,
1777             { "Type", "ucp.hdr.O_R",
1778               FT_UINT8, BASE_DEC, VALS(vals_hdr_O_R), 0x00,
1779               "Your basic 'is a request or response'.",
1780               HFILL
1781             }
1782         },
1783         { &hf_ucp_hdr_OT,
1784             { "Operation", "ucp.hdr.OT",
1785               FT_UINT8, BASE_DEC, VALS(vals_hdr_OT), 0x00,
1786               "The operation that is requested with this message.",
1787               HFILL
1788             }
1789         },
1790         { &hf_ucp_oper_section,
1791             { "Data", "ucp.parm",
1792               FT_NONE, BASE_DEC, NULL, 0x00,
1793               "The actual content of the operation.",
1794               HFILL
1795             }
1796         },
1797         { &hf_ucp_parm_AdC,
1798             { "AdC", "ucp.parm.AdC",
1799               FT_STRING, BASE_NONE, NULL, 0x00,
1800               "Address code recipient.",
1801               HFILL
1802             }
1803         },
1804         { &hf_ucp_parm_OAdC,
1805             { "OAdC", "ucp.parm.OAdC",
1806               FT_STRING, BASE_NONE, NULL, 0x00,
1807               "Address code originator.",
1808               HFILL
1809             }
1810         },
1811         { &hf_ucp_parm_DAdC,
1812             { "DAdC", "ucp.parm.DAdC",
1813               FT_STRING, BASE_NONE, NULL, 0x00,
1814               "Diverted address code.",
1815               HFILL
1816             }
1817         },
1818         { &hf_ucp_parm_AC,
1819             { "AC", "ucp.parm.AC",
1820               FT_STRING, BASE_NONE, NULL, 0x00,
1821               "Authentication code.",
1822               HFILL
1823             }
1824         },
1825         { &hf_ucp_parm_OAC,
1826             { "OAC", "ucp.parm.OAC",
1827               FT_STRING, BASE_NONE, NULL, 0x00,
1828               "Authentication code, originator.",
1829               HFILL
1830             }
1831         },
1832         { &hf_ucp_parm_NAC,
1833             { "NAC", "ucp.parm.NAC",
1834               FT_STRING, BASE_NONE, NULL, 0x00,
1835               "New authentication code.",
1836               HFILL
1837             }
1838         },
1839         { &hf_ucp_parm_BAS,
1840             { "BAS", "ucp.parm.BAS",
1841               FT_UINT8, BASE_DEC, VALS(vals_parm_BAS), 0x00,
1842               "Barring status flag.",
1843               HFILL
1844             }
1845         },
1846         { &hf_ucp_parm_LAR,
1847             { "LAR", "ucp.parm.LAR",
1848               FT_UINT8, BASE_DEC, VALS(vals_parm_LAR), 0x00,
1849               "Leg. code for all calls flag.",
1850               HFILL
1851             }
1852         },
1853         { &hf_ucp_parm_LAC,
1854             { "LAC", "ucp.parm.LAC",
1855               FT_STRING, BASE_NONE, NULL, 0x00,
1856               "New leg. code for all calls.",
1857               HFILL
1858             }
1859         },
1860         { &hf_ucp_parm_L1R,
1861             { "L1R", "ucp.parm.L1R",
1862               FT_UINT8, BASE_DEC, VALS(vals_parm_L1R), 0x00,
1863               "Leg. code for priority 1 flag.",
1864               HFILL
1865             }
1866         },
1867         { &hf_ucp_parm_L1P,
1868             { "L1P", "ucp.parm.L1P",
1869               FT_STRING, BASE_NONE, NULL, 0x00,
1870               "New leg. code for level 1 priority.",
1871               HFILL
1872             }
1873         },
1874         { &hf_ucp_parm_L3R,
1875             { "L3R", "ucp.parm.L3R",
1876               FT_UINT8, BASE_DEC, VALS(vals_parm_L3R), 0x00,
1877               "Leg. code for priority 3 flag.",
1878               HFILL
1879             }
1880         },
1881         { &hf_ucp_parm_L3P,
1882             { "L3P", "ucp.parm.L3P",
1883               FT_STRING, BASE_NONE, NULL, 0x00,
1884               "New leg. code for level 3 priority.",
1885               HFILL
1886             }
1887         },
1888         { &hf_ucp_parm_LCR,
1889             { "LCR", "ucp.parm.LCR",
1890               FT_UINT8, BASE_DEC, VALS(vals_parm_LCR), 0x00,
1891               "Leg. code for reverse charging flag.",
1892               HFILL
1893             }
1894         },
1895         { &hf_ucp_parm_LUR,
1896             { "LUR", "ucp.parm.LUR",
1897               FT_UINT8, BASE_DEC, VALS(vals_parm_LUR), 0x00,
1898               "Leg. code for urgent message flag.",
1899               HFILL
1900             }
1901         },
1902         { &hf_ucp_parm_LRR,
1903             { "LRR", "ucp.parm.LRR",
1904               FT_UINT8, BASE_DEC, VALS(vals_parm_LRR), 0x00,
1905               "Leg. code for repitition flag.",
1906               HFILL
1907             }
1908         },
1909         { &hf_ucp_parm_RT,
1910             { "RT", "ucp.parm.RT",
1911               FT_UINT8, BASE_DEC, VALS(vals_parm_RT), 0x00,
1912               "Receiver type.",
1913               HFILL
1914             }
1915         },
1916         { &hf_ucp_parm_NoN,
1917             { "NoN", "ucp.parm.NoN",
1918               FT_UINT16, BASE_DEC, NULL, 0x00,
1919               "Maximum number of numerical characters accepted.",
1920               HFILL
1921             }
1922         },
1923         { &hf_ucp_parm_NoA,
1924             { "NoA", "ucp.parm.NoA",
1925               FT_UINT16, BASE_DEC, NULL, 0x00,
1926               "Maximum number of alphanumerical characters accepted.",
1927               HFILL
1928             }
1929         },
1930         { &hf_ucp_parm_NoB,
1931             { "NoB", "ucp.parm.NoB",
1932               FT_UINT16, BASE_DEC, NULL, 0x00,
1933               "Maximum number of data bits accepted.",
1934               HFILL
1935             }
1936         },
1937         { &hf_ucp_parm_PNC,
1938             { "PNC", "ucp.parm.PNC",
1939               FT_UINT8, BASE_DEC, VALS(vals_parm_PNC), 0x00,
1940               "Paging network controller.",
1941               HFILL
1942             }
1943         },
1944         { &hf_ucp_parm_LNo,
1945             { "LNo", "ucp.parm.LNo",
1946               FT_STRING, BASE_NONE, NULL, 0x00,
1947               "Standard text list number requested by calling party.",
1948               HFILL
1949             }
1950         },
1951         { &hf_ucp_parm_LST,
1952             { "LST", "ucp.parm.LST",
1953               FT_STRING, BASE_NONE, NULL, 0x00,
1954               "Legitimisation code for standard text.",
1955               HFILL
1956             }
1957         },
1958         { &hf_ucp_parm_TNo,
1959             { "TNo", "ucp.parm.TNo",
1960               FT_STRING, BASE_NONE, NULL, 0x00,
1961               "Standard text number requested by calling party.",
1962               HFILL
1963             }
1964         },
1965         { &hf_ucp_parm_CS,
1966             { "CS", "ucp.parm.CS",
1967               FT_UINT8, BASE_DEC, NULL, 0x00,
1968               "Additional character set number.",
1969               HFILL
1970             }
1971         },
1972         { &hf_ucp_parm_PID,
1973             { "PID", "ucp.parm.PID",
1974               FT_UINT16, BASE_DEC, VALS(vals_parm_PID), 0x00,
1975               "SMT PID value.",
1976               HFILL
1977             }
1978         },
1979         { &hf_ucp_parm_NPL,
1980             { "NPL", "ucp.parm.NPL",
1981               FT_UINT16, BASE_DEC, NULL, 0x00,
1982               "Number of parameters in the following list.",
1983               HFILL
1984             }
1985         },
1986         { &hf_ucp_parm_GA,
1987             { "GA", "ucp.parm.GA",
1988               FT_STRING, BASE_NONE, NULL, 0x00,
1989               "GA?? haven't got a clue.",
1990               HFILL
1991             }
1992         },
1993         { &hf_ucp_parm_RP,
1994             { "RP", "ucp.parm.RP",
1995               FT_UINT8, BASE_DEC, VALS(vals_parm_RP), 0x00,
1996               "Repitition requested.",
1997               HFILL
1998             }
1999         },
2000         { &hf_ucp_parm_LRP,
2001             { "LRP", "ucp.parm.LRP",
2002               FT_STRING, BASE_DEC, NULL, 0x00,
2003               "Legitimisation code for repitition.",
2004               HFILL
2005             }
2006         },
2007         { &hf_ucp_parm_PR,
2008             { "PR", "ucp.parm.PR",
2009               FT_UINT8, BASE_DEC, NULL, 0x00,
2010               "Priority requested.",
2011               HFILL
2012             }
2013         },
2014         { &hf_ucp_parm_LPR,
2015             { "LPR", "ucp.parm.LPR",
2016               FT_STRING, BASE_DEC, NULL, 0x00,
2017               "Legitimisation code for priority requested.",
2018               HFILL
2019             }
2020         },
2021         { &hf_ucp_parm_UM,
2022             { "UM", "ucp.parm.UM",
2023               FT_UINT8, BASE_DEC, VALS(vals_parm_UM), 0x00,
2024               "Urgent message indicator.",
2025               HFILL
2026             }
2027         },
2028         { &hf_ucp_parm_LUM,
2029             { "LUM", "ucp.parm.LUM",
2030               FT_STRING, BASE_DEC, NULL, 0x00,
2031               "Legitimisation code for urgent message.",
2032               HFILL
2033             }
2034         },
2035         { &hf_ucp_parm_RC,
2036             { "RC", "ucp.parm.RC",
2037               FT_UINT8, BASE_DEC, VALS(vals_parm_RC), 0x00,
2038               "Reverse charging request.",
2039               HFILL
2040             }
2041         },
2042         { &hf_ucp_parm_LRC,
2043             { "LRC", "ucp.parm.LRC",
2044               FT_STRING, BASE_DEC, NULL, 0x00,
2045               "Legitimisation code for reverse charging.",
2046               HFILL
2047             }
2048         },
2049         { &hf_ucp_parm_NRq,
2050             { "NRq", "ucp.parm.NRq",
2051               FT_UINT8, BASE_DEC, VALS(vals_parm_NRq), 0x00,
2052               "Notification request.",
2053               HFILL
2054             }
2055         },
2056         { &hf_ucp_parm_GAdC,
2057             { "GAdC", "ucp.parm.GAdC",
2058               FT_STRING, BASE_NONE, NULL, 0x00,
2059               "Group address code.",
2060               HFILL
2061             }
2062         },
2063         { &hf_ucp_parm_A_D,
2064             { "A_D", "ucp.parm.A_D",
2065               FT_UINT8, BASE_DEC, VALS(vals_parm_A_D), 0x00,
2066               "Add to/delete from fixed subscriber address list record.",
2067               HFILL
2068             }
2069         },
2070         { &hf_ucp_parm_CT,
2071             { "CT", "ucp.parm.CT",
2072               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2073               "Accumulated charges timestamp.",
2074               HFILL
2075             }
2076         },
2077         { &hf_ucp_parm_AAC,
2078             { "AAC", "ucp.parm.AAC",
2079               FT_STRING, BASE_NONE, NULL, 0x00,
2080               "Accumulated charges.",
2081               HFILL
2082             }
2083         },
2084         { &hf_ucp_parm_MNo,
2085             { "MNo", "ucp.parm.MNo",
2086               FT_STRING, BASE_NONE, NULL, 0x00,
2087               "Message number.",
2088               HFILL
2089             }
2090         },
2091         { &hf_ucp_parm_R_T,
2092             { "R_T", "ucp.parm.R_T",
2093               FT_STRING, BASE_NONE, NULL, 0x00,
2094               "Message number.",
2095               HFILL
2096             }
2097         },
2098         { &hf_ucp_parm_NAdC,
2099             { "NAdC", "ucp.parm.NAdC",
2100               FT_STRING, BASE_NONE, NULL, 0x00,
2101               "Notification address.",
2102               HFILL
2103             }
2104         },
2105         { &hf_ucp_parm_NT,
2106             { "NT", "ucp.parm.NT",
2107               FT_STRING, BASE_NONE, NULL, 0x00,
2108               "Notification type.",
2109               HFILL
2110             }
2111         },
2112         { &hf_ucp_parm_IVR5x,
2113             { "IVR5x", "ucp.parm.IVR5x",
2114               FT_STRING, BASE_NONE, NULL, 0x00,
2115               "UCP release number supported/accepted.",
2116               HFILL
2117             }
2118         },
2119         { &hf_ucp_parm_REQ_OT,
2120             { "REQ_OT", "ucp.parm.REQ_OT",
2121               FT_UINT8, BASE_DEC, VALS(vals_parm_REQ_OT), 0x00,
2122               "UCP release number supported/accepted.",
2123               HFILL
2124             }
2125         },
2126         { &hf_ucp_parm_SSTAT,
2127             { "SSTAT", "ucp.parm.SSTAT",
2128               FT_UINT8, BASE_DEC, VALS(vals_parm_SSTAT), 0x00,
2129               "Supplementary services for which status is requested.",
2130               HFILL
2131             }
2132         },
2133         { &hf_ucp_parm_LMN,
2134             { "LMN", "ucp.parm.LMN",
2135               FT_UINT8, BASE_DEC, NULL, 0x00,
2136               "Last message number.",
2137               HFILL
2138             }
2139         },
2140         { &hf_ucp_parm_NMESS,
2141             { "NMESS", "ucp.parm.NMESS",
2142               FT_UINT8, BASE_DEC, NULL, 0x00,
2143               "Number of stored messages.",
2144               HFILL
2145             }
2146         },
2147         { &hf_ucp_parm_NMESS_str,
2148             { "NMESS_str", "ucp.parm.NMESS_str",
2149               FT_STRING, BASE_NONE, NULL, 0x00,
2150               "Number of stored messages.",
2151               HFILL
2152             }
2153         },
2154         { &hf_ucp_parm_NPID,
2155             { "NPID", "ucp.parm.NPID",
2156               FT_UINT16, BASE_DEC, VALS(vals_parm_PID), 0x00,
2157               "Notification PID value.",
2158               HFILL
2159             }
2160         },
2161         { &hf_ucp_parm_LRq,
2162             { "LRq", "ucp.parm.LRq",
2163               FT_UINT8, BASE_DEC, VALS(vals_parm_LRq), 0x00,
2164               "Last resort address request.",
2165               HFILL
2166             }
2167         },
2168         { &hf_ucp_parm_LRAd,
2169             { "LRAd", "ucp.parm.LRAd",
2170               FT_STRING, BASE_NONE, NULL, 0x00,
2171               "Last resort address.",
2172               HFILL
2173             }
2174         },
2175         { &hf_ucp_parm_LPID,
2176             { "LPID", "ucp.parm.LPID",
2177               FT_UINT16, BASE_DEC, VALS(vals_parm_PID), 0x00,
2178               "Last resort PID value.",
2179               HFILL
2180             }
2181         },
2182         { &hf_ucp_parm_DD,
2183             { "DD", "ucp.parm.DD",
2184               FT_UINT8, BASE_DEC, VALS(vals_parm_DD), 0x00,
2185               "Deferred delivery requested.",
2186               HFILL
2187             }
2188         },
2189         { &hf_ucp_parm_DDT,
2190             { "DDT", "ucp.parm.DDT",
2191               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2192               "Deferred delivery time.",
2193               HFILL
2194             }
2195         },
2196         { &hf_ucp_parm_STx,
2197             { "STx", "ucp.parm.STx",
2198               FT_NONE, BASE_NONE, NULL, 0x00,
2199               "Standard text.",
2200               HFILL
2201             }
2202         },
2203         { &hf_ucp_parm_ST,
2204             { "ST", "ucp.parm.ST",
2205               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2206               "Start time.",
2207               HFILL
2208             }
2209         },
2210         { &hf_ucp_parm_SP,
2211             { "SP", "ucp.parm.SP",
2212               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2213               "Stop time.",
2214               HFILL
2215             }
2216         },
2217         { &hf_ucp_parm_VP,
2218             { "VP", "ucp.parm.VP",
2219               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2220               "Validity period.",
2221               HFILL
2222             }
2223         },
2224         { &hf_ucp_parm_RPID,
2225             { "RPID", "ucp.parm.RPID",
2226               FT_STRING, BASE_NONE, NULL, 0x00,
2227               "Replace PID",
2228               HFILL
2229             }
2230         },
2231         { &hf_ucp_parm_SCTS,
2232             { "SCTS", "ucp.parm.SCTS",
2233               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2234               "Service Centre timestamp.",
2235               HFILL
2236             }
2237         },
2238         { &hf_ucp_parm_Dst,
2239             { "Dst", "ucp.parm.Dst",
2240               FT_UINT8, BASE_DEC, VALS(vals_parm_Dst), 0x00,
2241               "Delivery status.",
2242               HFILL
2243             }
2244         },
2245         { &hf_ucp_parm_Rsn,
2246             { "Rsn", "ucp.parm.Rsn",
2247               FT_UINT16, BASE_DEC, VALS(vals_parm_Rsn), 0x00,
2248               "Reason code.",
2249               HFILL
2250             }
2251         },
2252         { &hf_ucp_parm_DSCTS,
2253             { "DSCTS", "ucp.parm.DSCTS",
2254               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2255               "Delivery timestamp.",
2256               HFILL
2257             }
2258         },
2259         { &hf_ucp_parm_MT,
2260             { "MT", "ucp.parm.MT",
2261               FT_UINT8, BASE_DEC, VALS(vals_parm_MT), 0x00,
2262               "Message type.",
2263               HFILL
2264             }
2265         },
2266         { &hf_ucp_parm_NB,
2267             { "  NB", "ucp.parm.NB",
2268               FT_STRING, BASE_NONE, NULL, 0x00,
2269               "No. of bits in Transparent Data (TD) message.",
2270               HFILL
2271             }
2272         },
2273         { &hf_ucp_data_section,
2274             { "  Data", "ucp.message",
2275               FT_NONE, BASE_NONE, NULL, 0x00,
2276               "The actual message or data.",
2277               HFILL
2278             }
2279         },
2280         { &hf_ucp_parm_MMS,
2281             { "MMS", "ucp.parm.MMS",
2282               FT_UINT8, BASE_DEC, NULL, 0x00,
2283               "More messages to send.",
2284               HFILL
2285             }
2286         },
2287         { &hf_ucp_parm_DCs,
2288             { "DCs", "ucp.parm.DCs",
2289               FT_UINT8, BASE_DEC, VALS(vals_parm_DCs), 0x00,
2290               "Data coding scheme (deprecated).",
2291               HFILL
2292             }
2293         },
2294         { &hf_ucp_parm_MCLs,
2295             { "MCLs", "ucp.parm.MCLs",
2296               FT_UINT8, BASE_DEC, VALS(vals_parm_MCLs), 0x00,
2297               "Message class.",
2298               HFILL
2299             }
2300         },
2301         { &hf_ucp_parm_RPI,
2302             { "RPI", "ucp.parm.RPI",
2303               FT_UINT8, BASE_DEC, VALS(vals_parm_RPI), 0x00,
2304               "Reply path.",
2305               HFILL
2306             }
2307         },
2308         { &hf_ucp_parm_CPg,
2309             { "CPg", "ucp.parm.CPg",
2310               FT_STRING, BASE_NONE, NULL, 0x00,
2311               "Reserved for Code Page.",
2312               HFILL
2313             }
2314         },
2315         { &hf_ucp_parm_RPLy,
2316             { "RPLy", "ucp.parm.RPLy",
2317               FT_STRING, BASE_NONE, NULL, 0x00,
2318               "Reserved for Reply type.",
2319               HFILL
2320             }
2321         },
2322         { &hf_ucp_parm_OTOA,
2323             { "OTOA", "ucp.parm.OTOA",
2324               FT_STRING, BASE_NONE, NULL, 0x00,
2325               "Originator Type Of Address.",
2326               HFILL
2327             }
2328         },
2329         { &hf_ucp_parm_HPLMN,
2330             { "HPLMN", "ucp.parm.HPLMN",
2331               FT_STRING, BASE_NONE, NULL, 0x00,
2332               "Home PLMN address.",
2333               HFILL
2334             }
2335         },
2336         { &hf_ucp_parm_XSer,
2337             { "Extra services:", "ucp.parm.XSer",
2338               FT_NONE, BASE_DEC, NULL, 0x00,
2339               "Extra services.",
2340               HFILL
2341             }
2342         },
2343         { &hf_ucp_parm_RES4,
2344             { "RES4", "ucp.parm.RES4",
2345               FT_STRING, BASE_NONE, NULL, 0x00,
2346               "Reserved for future use.",
2347               HFILL
2348             }
2349         },
2350         { &hf_ucp_parm_RES5,
2351             { "RES5", "ucp.parm.RES5",
2352               FT_STRING, BASE_NONE, NULL, 0x00,
2353               "Reserved for future use.",
2354               HFILL
2355             }
2356         },
2357         { &hf_ucp_parm_OTON,
2358             { "OTON", "ucp.parm.OTON",
2359               FT_UINT8, BASE_DEC, VALS(vals_parm_OTON), 0x00,
2360               "Originator type of number.",
2361               HFILL
2362             }
2363         },
2364         { &hf_ucp_parm_ONPI,
2365             { "ONPI", "ucp.parm.ONPI",
2366               FT_UINT8, BASE_DEC, VALS(vals_parm_ONPI), 0x00,
2367               "Originator numbering plan id.",
2368               HFILL
2369             }
2370         },
2371         { &hf_ucp_parm_STYP0,
2372             { "STYP0", "ucp.parm.STYP0",
2373               FT_UINT8, BASE_DEC, VALS(vals_parm_STYP0), 0x00,
2374               "Subtype of operation.",
2375               HFILL
2376             }
2377         },
2378         { &hf_ucp_parm_STYP1,
2379             { "STYP1", "ucp.parm.STYP1",
2380               FT_UINT8, BASE_DEC, VALS(vals_parm_STYP1), 0x00,
2381               "Subtype of operation.",
2382               HFILL
2383             }
2384         },
2385         { &hf_ucp_parm_PWD,
2386             { "PWD", "ucp.parm.PWD",
2387               FT_NONE, BASE_DEC, NULL, 0x00,
2388               "Current password.",
2389               HFILL
2390             }
2391         },
2392         { &hf_ucp_parm_NPWD,
2393             { "NPWD", "ucp.parm.NPWD",
2394               FT_NONE, BASE_DEC, NULL, 0x00,
2395               "New password.",
2396               HFILL
2397             }
2398         },
2399         { &hf_ucp_parm_VERS,
2400             { "VERS", "ucp.parm.VERS",
2401               FT_STRING, BASE_NONE, NULL, 0x00,
2402               "Version number.",
2403               HFILL
2404             }
2405         },
2406         { &hf_ucp_parm_LAdC,
2407             { "LAdC", "ucp.parm.LAdC",
2408               FT_STRING, BASE_NONE, NULL, 0x00,
2409               "Address for VSMSC list operation.",
2410               HFILL
2411             }
2412         },
2413         { &hf_ucp_parm_LTON,
2414             { "LTON", "ucp.parm.LTON",
2415               FT_UINT8, BASE_DEC, NULL, 0x00,
2416               "Type of number list address.",
2417               HFILL
2418             }
2419         },
2420         { &hf_ucp_parm_LNPI,
2421             { "LNPI", "ucp.parm.LNPI",
2422               FT_UINT8, BASE_DEC, NULL, 0x00,
2423               "Numbering plan id. list address.",
2424               HFILL
2425             }
2426         },
2427         { &hf_ucp_parm_OPID,
2428             { "OPID", "ucp.parm.OPID",
2429               FT_UINT8, BASE_DEC, VALS(vals_parm_OPID), 0x00,
2430               "Originator protocol identifier.",
2431               HFILL
2432             }
2433         },
2434         { &hf_ucp_parm_RES1,
2435             { "RES1", "ucp.parm.RES1",
2436               FT_STRING, BASE_NONE, NULL, 0x00,
2437               "Reserved for future use.",
2438               HFILL
2439             }
2440         },
2441         { &hf_ucp_parm_RES2,
2442             { "RES2", "ucp.parm.RES2",
2443               FT_STRING, BASE_NONE, NULL, 0x00,
2444               "Reserved for future use.",
2445               HFILL
2446             }
2447         },
2448         { &hf_ucp_parm_ACK,
2449             { "(N)Ack", "ucp.parm.ACK",
2450               FT_UINT8, BASE_DEC, VALS(vals_parm_ACK), 0x00,
2451               "Positive or negative acknowledge of the operation.",
2452               HFILL
2453             }
2454         },
2455         { &hf_ucp_parm_MVP,
2456             { "MVP", "ucp.parm.MVP",
2457               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2458               "Mofified validity period.",
2459               HFILL
2460             }
2461         },
2462         { &hf_ucp_parm_EC,
2463             { "Error code", "ucp.parm.EC",
2464               FT_UINT8, BASE_DEC, VALS(vals_parm_EC), 0x00,
2465               "The result of the requested operation.",
2466               HFILL
2467             }
2468         },
2469         { &hf_ucp_parm_SM,
2470             { "SM", "ucp.parm.SM",
2471               FT_STRING, BASE_NONE, NULL, 0x00,
2472               "System message.",
2473               HFILL
2474             }
2475         },
2476         { &hf_xser_service,
2477             { "Type of service", "ucp.xser.service",
2478               FT_UINT8, BASE_HEX, VALS(vals_xser_service), 0x00,
2479               "The type of service specified.",
2480               HFILL
2481             }
2482         },
2483     };
2484     /* Setup protocol subtree array */
2485     static gint *ett[] = {
2486         &ett_ucp,
2487         &ett_XSer
2488     };
2489     /* Register the protocol name and description */
2490     proto_ucp = proto_register_protocol("Universal Computer Protocol",
2491                                         "UCP", "ucp");
2492
2493     /* Required function calls to register header fields and subtrees used */
2494     proto_register_field_array(proto_ucp, hf, array_length(hf));
2495     proto_register_subtree_array(ett, array_length(ett));
2496 }
2497
2498 /*
2499  * If dissector uses sub-dissector registration add a registration routine.
2500  * This format is required because a script is used to find these routines and
2501  * create the code that calls these routines.
2502  */
2503 void
2504 proto_reg_handoff_ucp(void)
2505 {
2506     dissector_handle_t ucp_handle;
2507
2508     /*
2509      * UCP can be spoken on any port so, when not on a specific port, try this
2510      * one whenever TCP is spoken.
2511      */
2512     heur_dissector_add("tcp", dissect_ucp_heur, proto_ucp);
2513
2514     /*
2515      * Also register as one that can be selected by a TCP port number.
2516      */
2517     ucp_handle = create_dissector_handle(dissect_ucp, proto_ucp);
2518     dissector_add_handle("tcp.port", ucp_handle);
2519 }