From Michael Tuexen: update for the ASAP dissector which provides
[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.16 2002/06/20 20:17: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 <epan/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_sub  = -1;
203 static gint ett_XSer = -1;
204
205 /*
206  * Value-arrays for certain field-contents
207  */
208 static const value_string vals_hdr_O_R[] = {
209     {  'O', "Operation" },
210     {  'R', "Result" },
211     {  0, NULL }
212 };
213
214 static const value_string vals_hdr_OT[] = {     /* Operation type       */
215     {  0, "Enquiry" },
216     {  1, "Call input" },
217     {  2, "Call input (multiple address)" },
218     {  3, "Call input (supplementary services included)" },
219     {  4, "Address list information" },
220     {  5, "Change address list" },
221     {  6, "Advice of accumulated charges" },
222     {  7, "Password management" },
223     {  8, "Legitimisation code management" },
224     {  9, "Standard text information" },
225     { 10, "Change standard text" },
226     { 11, "Request roaming information" },
227     { 12, "Change roaming information" },
228     { 13, "Roaming reset" },
229     { 14, "Message retrieval" },
230     { 15, "Request call barring" },
231     { 16, "Cancel call barring" },
232     { 17, "Request call diversion" },
233     { 18, "Cancel call diversion" },
234     { 19, "Request deferred delivery" },
235     { 20, "Cancel deferred delivery" },
236     { 21, "All features reset" },
237     { 22, "Call input (with specific character set)" },
238     { 23, "UCP version status request" },
239     { 24, "Mobile subscriber feature status request" },
240     { 30, "SMS message transfer" },
241     { 31, "SMT alert" },
242     { 32, "(proprietary)" },
243     { 34, "(proprietary)" },
244     { 36, "(proprietary)" },
245     { 38, "(proprietary)" },
246     { 40, "(proprietary)" },
247     { 41, "(proprietary)" },
248     { 42, "(proprietary)" },
249     { 43, "(proprietary)" },
250     { 44, "(proprietary)" },
251     { 45, "(proprietary)" },
252     { 51, "Submit short message" },
253     { 52, "Deliver short message" },
254     { 53, "Deliver notification" },
255     { 54, "Modify message" },
256     { 55, "Inquiry message" },
257     { 56, "Delete message" },
258     { 57, "Inquiry response message" },
259     { 58, "Delete response message" },
260     { 60, "Session management" },
261     { 61, "List management" },
262     { 95, "(proprietary)" },
263     { 96, "(proprietary)" },
264     { 97, "(proprietary)" },
265     { 98, "(proprietary)" },
266     { 99, "(proprietary)" },
267     {  0, NULL }
268 };
269
270 static const value_string vals_parm_EC[] = {    /* Error code   */
271     {  1, "Checksum error" },
272     {  2, "Syntax error" },
273     {  3, "Operation not supported by system" },
274     {  4, "Operation not allowed" },
275     {  5, "Call barring active" },
276     {  6, "AdC invalid" },
277     {  7, "Authentication failure" },
278     {  8, "Legitimisation code for all calls, failure" },
279     {  9, "GA not valid" },
280     { 10, "Repetition not allowed" },
281     { 11, "Legitimisation code for repetition, failure" },
282     { 12, "Priority call not allowed" },
283     { 13, "Legitimisation code for priority call, failure" },
284     { 14, "Urgent message not allowed" },
285     { 15, "Legitimisation code for urgent message, failure" },
286     { 16, "Reverse charging not alllowed" },
287     { 17, "Legitimisation code for rev. charging, failure" },
288     { 18, "Deferred delivery not allowed" },
289     { 19, "New AC not valid" },
290     { 20, "New legitimisation code not valid" },
291     { 21, "Standard text not valid" },
292     { 22, "Time period not valid" },
293     { 23, "Message type not supported by system" },
294     { 24, "Message too long" },
295     { 25, "Requested standard text not valid" },
296     { 26, "Message type not valid for the pager type" },
297     { 27, "Message not found in SMSC" },
298     { 28, "Invalid character set" },
299     { 30, "Subscriber hang-up" },
300     { 31, "Fax group not supported" },
301     { 32, "Fax message type not supported" },
302     { 33, "Address already in list (60-series)" },
303     { 34, "Address not in list (60-series)" },
304     { 35, "List full, cannot add address to list (60-series)" },
305     { 36, "RPID already in use" },
306     { 37, "Delivery in progress" },
307     { 38, "Message forwarded" },
308     { 50, "Low network status" },
309     { 51, "Legitimisation code for standard text, failure" },
310     { 53, "Operation partially successfull" },
311     { 54, "Operation not successfull" },
312     { 55, "System error" },
313     { 57, "AdC already a member of GAdC address list" },
314     { 58, "AdC not a member of GAdC address list" },
315     { 59, "Requested standard text list invalid" },
316     { 61, "Not controller of GAdC address list" },
317     { 62, "Standard text too large" },
318     { 63, "Not owner of standard text list" },
319     { 64, "Address list full" },
320     { 65, "GAdC invalid" },
321     { 66, "Operation restricted to mobile subscribers" },
322     { 68, "Invalid AdC type" },
323     { 69, "Cannot add AdC to GAdC address list" },
324     { 90, "(proprietary error code)" },
325     { 91, "(proprietary error code)" },
326     { 92, "(proprietary error code)" },
327     { 93, "(proprietary error code)" },
328     { 94, "(proprietary error code)" },
329     { 95, "(proprietary error code)" },
330     { 96, "(proprietary error code)" },
331     { 97, "(proprietary error code)" },
332     { 98, "(proprietary error code)" },
333     { 99, "(proprietary error code)" },
334     {  0, NULL },
335 };
336
337 static const value_string vals_parm_NRq[] = {
338     {  '0', "NAdC not used" },
339     {  '1', "NAdC used" },
340     {  0, NULL },
341 };
342
343 static const value_string vals_parm_NT[] = {
344     {  '0', "Default value" },
345     {  '1', "Delivery notification" },
346     {  '2', "Non-delivery notification" },
347     {  '3', "Delivery and Non-delivery notification" },
348     {  '4', "Buffered message notification" },
349     {  '5', "Buffered and Delivery notification" },
350     {  '6', "Buffered and Non-delivery notification" },
351     {  '7', "All notifications" },
352     {  0, NULL },
353 };
354
355 static const value_string vals_parm_PID[] = {
356     {  100, "Mobile station" },
357     {  122, "Fax Group 3" },
358     {  131, "X.400" },
359     {  138, "Menu over PSTN" },
360     {  139, "PC appl. over PSTN (E.164)" },
361     {  339, "PC appl. over X.25 (X.121)" },
362     {  439, "PC appl. over ISDN (E.164)" },
363     {  539, "PC appl. over TCP/IP" },
364     {  0, NULL },
365 };
366
367 static const value_string vals_parm_LRq[] = {
368     {  '0', "LRAd not used" },
369     {  '1', "LRAd used" },
370     {  0, NULL },
371 };
372
373 static const value_string vals_parm_DD[] = {
374     {  '0', "DDT not used" },
375     {  '1', "DDT used" },
376     {  0, NULL },
377 };
378
379 static const value_string vals_parm_Dst[] = {
380     {  '0', "delivered" },
381     {  '1', "buffered (see Rsn)" },
382     {  '2', "not delivered (see Rsn)" },
383     {  0, NULL },
384 };
385
386 static const value_string vals_parm_Rsn[] = {
387     {    0, "Unknown subscriber" },
388     {    1, "Service temporary not available" },
389     {    2, "Service temporary not available" },
390     {    3, "Service temporary not available" },
391     {    4, "Service temporary not available" },
392     {    5, "Service temporary not available" },
393     {    6, "Service temporary not available" },
394     {    7, "Service temporary not available" },
395     {    8, "Service temporary not available" },
396     {    9, "Illegal error code" },
397     {   10, "Network time-out" },
398     {  100, "Facility not supported" },
399     {  101, "Unknown subscriber" },
400     {  102, "Facility not provided" },
401     {  103, "Call barred" },
402     {  104, "Operation barred" },
403     {  105, "SC congestion" },
404     {  106, "Facility not supported" },
405     {  107, "Absent subscriber" },
406     {  108, "Delivery fail" },
407     {  109, "Sc congestion" },
408     {  110, "Protocol error" },
409     {  111, "MS not equiped" },
410     {  112, "Unknown SC" },
411     {  113, "SC congestion" },
412     {  114, "Illegal MS" },
413     {  115, "MS nota subscriber" },
414     {  116, "Error in MS" },
415     {  117, "SMS lower layer not provisioned" },
416     {  118, "System fail" },
417     {  119, "PLMN system failure" },
418     {  120, "HLR system failure" },
419     {  121, "VLR system failure" },
420     {  122, "Previous VLR system failure" },
421     {  123, "Controlling MSC system failure" },
422     {  124, "VMSC system failure" },
423     {  125, "EIR system failure" },
424     {  126, "System failure" },
425     {  127, "Unexpected data value" },
426     {  200, "Error in address service centre" },
427     {  201, "Invalid absolute validity period" },
428     {  202, "Short message exceeds maximum" },
429     {  203, "Unable to unpack GSM message" },
430     {  204, "Unable to convert to IRA alphabet" },
431     {  205, "Invalid validity period format" },
432     {  206, "Invalid destination address" },
433     {  207, "Duplicate message submit" },
434     {  208, "Invalid message type indicator" },
435     {  0, NULL },
436 };
437
438 static const value_string vals_parm_MT[] = {
439     {  '2', "Numeric message" },
440     {  '3', "Alphanumeric message" },
441     {  '4', "Transparent data" },
442     {  0, NULL },
443 };
444
445 static const value_string vals_parm_DCs[] = {
446     {  '0', "default alphabet" },
447     {  '1', "User defined data (8 bit)" },
448     {  0, NULL },
449 };
450
451 static const value_string vals_parm_MCLs[] = {
452     {  '0', "message class 0" },
453     {  '1', "message class 1" },
454     {  '2', "message class 2" },
455     {  '3', "message class 3" },
456     {  0, NULL },
457 };
458
459 static const value_string vals_parm_RPI[] = {
460     {  '1', "Request" },
461     {  '2', "Response" },
462     {  0, NULL },
463 };
464
465 static const value_string vals_parm_ACK[] = {
466     {  'A', "Ack" },
467     {  'N', "Nack" },
468     {  0, NULL },
469 };
470
471 static const value_string vals_parm_RP[] = {
472     {  '1', "Repetition requested" },
473     {  0, NULL },
474 };
475
476 static const value_string vals_parm_UM[] = {
477     {  '1', "Urgent message" },
478     {  0, NULL },
479 };
480
481 static const value_string vals_parm_RC[] = {
482     {  '1', "Reverse charging request" },
483     {  0, NULL },
484 };
485
486 static const value_string vals_parm_OTON[] = {
487     {  '1', "International number" },
488     {  '2', "National number" },
489     {  '6', "Abbreviated number (short number alias)" },
490     {  0, NULL },
491 };
492
493 static const value_string vals_parm_ONPI[] = {
494     {  '1', "E.164 address" },
495     {  '3', "X.121 address" },
496     {  '5', "Private -TCP/IP or abbreviated number- address" },
497     {  0, NULL },
498 };
499
500 static const value_string vals_parm_STYP0[] = {
501     {  '1', "open session" },
502     {  '2', "reserved" },
503     {  '3', "change password" },
504     {  '4', "open provisioning session" },
505     {  '5', "reserved" },
506     {  '6', "change provisioning password" },
507     {  0, NULL },
508 };
509
510 static const value_string vals_parm_STYP1[] = {
511     {  '1', "add item to mo-list" },
512     {  '2', "remove item from mo-list" },
513     {  '3', "verify item mo-list" },
514     {  '4', "add item to mt-list" },
515     {  '5', "remove item from mt-list" },
516     {  '6', "verify item mt-list" },
517     {  0, NULL },
518 };
519
520 static const value_string vals_parm_OPID[] = {
521     {  0, "Mobile station" },
522     {  39, "PC application" },
523     {  0, NULL },
524 };
525
526 static const value_string vals_parm_BAS[] = {
527     {  '1', "Barred" },
528     {  0, NULL },
529 };
530
531 static const value_string vals_parm_LAR[] = {
532     {  '1', "Leg. code for all calls requested" },
533     {  0, NULL },
534 };
535
536 static const value_string vals_parm_L1R[] = {
537     {  '1', "Leg. code for priority 1 requested" },
538     {  0, NULL },
539 };
540
541 static const value_string vals_parm_L3R[] = {
542     {  '1', "Leg. code for priority 3 requested" },
543     {  0, NULL },
544 };
545
546 static const value_string vals_parm_LCR[] = {
547     {  '1', "Leg. code for reverse charging requested" },
548     {  0, NULL },
549 };
550
551 static const value_string vals_parm_LUR[] = {
552     {  '1', "Leg. code for urgent message requested" },
553     {  0, NULL },
554 };
555
556 static const value_string vals_parm_LRR[] = {
557     {  '1', "Leg. code for repitition requested" },
558     {  0, NULL },
559 };
560
561 static const value_string vals_parm_RT[] = {
562     {  '1', "Tone only" },
563     {  '2', "Numeric" },
564     {  '3', "Alphanumeric" },
565     {  '4', "Transparent data" },
566     {  0, NULL },
567 };
568
569 static const value_string vals_parm_PNC[] = {
570     {  'H', "Home PNC" },
571     {  'I', "Input PNC" },
572     {  0, NULL },
573 };
574
575 static const value_string vals_parm_A_D[] = {
576     {  'A', "Add" },
577     {  'D', "Delete" },
578     {  0, NULL },
579 };
580
581 static const value_string vals_parm_R_T[] = {
582     {  'R', "Retrieval Ok" },
583     {  'T', "Retransmit on radio channel" },
584     {  0, NULL },
585 };
586
587 static const value_string vals_parm_REQ_OT[] = {
588     {  'S', "Send used operation types" },
589     {  'N', "Don't send used operation types" },
590     {  0, NULL },
591 };
592
593 static const value_string vals_parm_SSTAT[] = {
594     {  '0', "All services" },
595     {  '1', "All in the moment active servics" },
596     {  '2', "Call diversion" },
597     {  '3', "Roaming information status" },
598     {  '4', "Call barring status" },
599     {  '5', "Deferred delivery status" },
600     {  '6', "Number of stored messages" },
601     {  0, NULL },
602 };
603
604 static const value_string vals_xser_service[] = {
605     {  1, "GSM UDH information" },
606     {  2, "GSM DCS information" },
607     {  3, "[Message Type]            TDMA information exchange" },
608     {  4, "[Message Reference]       TDMA information exchange" },
609     {  5, "[Privacy Indicator]       TDMA information exchange" },
610     {  6, "[Urgency Indicator]       TDMA information exchange" },
611     {  7, "[Acknowledgement Request] TDMA information exchange" },
612     {  8, "[Messsage Updating]       TDMA information exchange" },
613     {  9, "[Call Back Number]        TDMA information exchange" },
614     { 10, "[Response Code]           TDMA information exchange" },
615     { 11, "[Teleservice ID]          TDMA information exchange" },
616     { 12, "Billing identifier" },
617     { 13, "Single shot indicator" },
618     {  0, NULL },
619 };
620
621 /*!
622  * Checks whether the PDU looks a bit like UCP and checks the checksum
623  *
624  * \param       tvb     The buffer with PDU-data
625  * \param       endpkt  Returns pointer, indicating the end of the PDU
626  *
627  * \return              The state of this PDU
628  * \retval      0               Definitely UCP
629  * \retval      UCP_SHORTENED   Packet may be there, but not complete
630  * \retval      UCP_MALFORMED   Hmmmm, not UCP after all...
631  * \retval      UCP_INV_CHK     Nice packet, but checksum doesn't add up...
632  */
633 static int
634 check_ucp(tvbuff_t *tvb, int *endpkt)
635 {
636     guint        offset = 1;
637     guint        checksum = 0;
638     int          pkt_check, tmp;
639     int          length;
640
641     length = tvb_find_guint8(tvb, offset, -1, UCP_ETX);
642     if (length == -1) {
643         *endpkt = tvb_reported_length_remaining(tvb, offset);
644         return UCP_SHORTENED;
645     }
646     if (length > (int) tvb_reported_length(tvb)) {
647         *endpkt = 0;
648         return UCP_MALFORMED;
649     }
650     for (; offset < (guint) (length - 2); offset++)
651         checksum += tvb_get_guint8(tvb, offset);
652     checksum &= 0xFF;
653     tmp = tvb_get_guint8(tvb, offset++);
654     pkt_check = AHex2Bin(tmp);
655     tmp = tvb_get_guint8(tvb, offset++);
656     pkt_check = 16 * pkt_check + AHex2Bin(tmp);
657     *endpkt = offset + 1;
658     if (checksum == (guint) pkt_check)
659         return 0;
660     else
661         return UCP_INV_CHK;
662 }
663
664 /*!
665  * UCP equivalent of mktime() (3). Convert date to standard 'time_t' format
666  *
667  * \param       datestr The UCP-formatted date to convert
668  *
669  * \return              The date in standard 'time_t' format.
670  */
671 static time_t
672 ucp_mktime(char *datestr)
673 {
674     struct tm    r_time;
675
676     r_time.tm_mday = 10 * (datestr[0] - '0') + (datestr[1] - '0');
677     r_time.tm_mon  = (10 * (datestr[2] - '0') + (datestr[3] - '0')) - 1;
678     r_time.tm_year = 10 * (datestr[4] - '0') + (datestr[5] - '0');
679     if (r_time.tm_year < 90) 
680         r_time.tm_year += 100;
681     r_time.tm_hour = 10 * (datestr[6] - '0') + (datestr[7] - '0');
682     r_time.tm_min  = 10 * (datestr[8] - '0') + (datestr[9] - '0');
683     if (datestr[10])
684         r_time.tm_sec  = 10 * (datestr[10] - '0') + (datestr[11] - '0');
685     r_time.tm_isdst = -1;
686     return mktime(&r_time);
687 }
688
689 /*!
690  * Scanning routines to add standard types (byte, int, string, data)
691  * to the protocol-tree. Each field is seperated with a slash ('/').
692  *
693  * \param       tree    The protocol tree to add to
694  * \param       tvb     Buffer containing the data
695  * \param       field   The actual field, whose value needs displaying
696  * \param       offset  Location of field within the buffer, returns location
697  *                      of next field.
698  *
699  * \return              For 'int'-types, the value of the field.
700  */
701 static void
702 ucp_handle_string(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
703 {
704     char         strval[BUFSIZ];
705     int          idx = 0;
706     int          tmpoff = *offset;
707
708     idx = 0;
709     while ((strval[idx++] = tvb_get_guint8(tvb, tmpoff++)) != '/')
710         ;
711     if (idx > 1) {
712         strval[--idx] = '\0';
713         proto_tree_add_string(tree, field, tvb, *offset, idx, strval);
714     }
715     *offset = tmpoff;
716 }
717
718 static guint
719 ucp_handle_byte(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
720 {
721     guint        intval = 0;
722
723     if ((intval = tvb_get_guint8(tvb, (*offset)++)) != '/') {
724         proto_tree_add_uint(tree, field, tvb, *offset - 1, 1, intval);
725         (*offset)++;
726     }
727     return intval;
728 }
729
730 static guint
731 ucp_handle_int(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
732 {
733     char         strval[BUFSIZ];
734     guint        intval = 0;
735     int          tmpoff = *offset;
736     int          idx = 0;
737  
738     while ((strval[idx++] = tvb_get_guint8(tvb, tmpoff++)) != '/')
739         ;
740     if (idx > 1) {
741         strval[--idx] = '\0';
742         intval = atoi(strval);
743         proto_tree_add_uint(tree, field, tvb, *offset, idx, intval);
744     }
745     *offset = tmpoff;
746     return intval;
747 }
748
749 static void
750 ucp_handle_time(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
751 {
752     char         strval[BUFSIZ];
753     time_t       tval;
754     nstime_t     tmptime;
755     int          tmpoff = *offset;
756     int          idx = 0;
757
758     while ((strval[idx++] = tvb_get_guint8(tvb, tmpoff++)) != '/')
759         ;
760     if (idx > 1) {
761         strval[--idx] = '\0';
762         tval = ucp_mktime(strval);
763         tmptime.secs  = tval;
764         tmptime.nsecs = 0;
765         proto_tree_add_time(tree, field, tvb, *offset, idx, &tmptime);
766     }
767     *offset = tmpoff;
768 }
769
770 static void
771 ucp_handle_data(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
772 {
773     int          tmpoff = *offset;
774
775     while (tvb_get_guint8(tvb, tmpoff++) != '/')
776         ;
777     if ((tmpoff - *offset) > 1) 
778         proto_tree_add_item(tree, field, tvb, *offset,
779                             tmpoff - *offset - 1, FALSE);
780     *offset = tmpoff;
781 }
782
783 /*!
784  * Handle the data-field within the UCP-message, according the Message Type
785  *      - 1     Tone only
786  *      - 2     Numeric message
787  *      - 3     Alphanumeric message
788  *      - 4     Transparent (binary) data
789  *      - 5     Standard text handling
790  *      - 6     Alphanumeric message in specified character set
791  *
792  * \param       tree    The protocol tree to add to
793  * \param       tvb     Buffer containing the data
794  * \param       field   The actual field, whose value needs displaying
795  * \param       offset  Location of field within the buffer, returns location
796  *                      of next field.
797  */
798 static void
799 ucp_handle_mt(proto_tree *tree, tvbuff_t *tvb, int *offset)
800 {
801     guint                intval;
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     /* This runs atop TCP, so we are guaranteed that there is at least one
1542        byte in the tvbuff. */
1543     if (tvb_get_guint8(tvb, 0) != UCP_STX)
1544         return FALSE;
1545
1546     result = check_ucp(tvb, &endpkt);
1547
1548     if (result == UCP_MALFORMED)
1549         return FALSE;
1550     if (endpkt < UCP_OT_OFFSET + 1)
1551         /*
1552          * Might be shortened packet but don't handle anyway.
1553          */
1554         return FALSE;
1555
1556     /*
1557      * Try getting the operation-type and whether it's a request/response 
1558      */
1559     O_R = tvb_get_guint8(tvb, UCP_O_R_OFFSET);
1560     if (match_strval(O_R, vals_hdr_O_R) == NULL)
1561         return FALSE;
1562     /*
1563      * Ok, looks like a valid packet, go dissect.
1564      */
1565     dissect_ucp(tvb, pinfo, tree);
1566     return TRUE;
1567 }
1568
1569 /*
1570  * The actual dissector
1571  */
1572 static void
1573 dissect_ucp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1574 {
1575     int          offset = 0;    /* Offset in packet within tvbuff       */
1576     int          tmpoff;        /* Local offset value (per field)       */
1577     guint8       O_R;           /* Request or response                  */
1578     guint8       OT;            /* Operation type                       */
1579     guint        intval;
1580     int          i;
1581
1582     /* Set up structures needed to add the protocol subtree and manage it */
1583     proto_item  *ti;
1584     proto_item  *sub_ti;
1585     proto_tree  *ucp_tree;
1586     proto_tree  *sub_tree;
1587     tvbuff_t    *tmp_tvb;
1588
1589     O_R = tvb_get_guint8(tvb, UCP_O_R_OFFSET);
1590     /*
1591      * So do an atoi() on the operation type
1592      */
1593     OT  = tvb_get_guint8(tvb, UCP_OT_OFFSET) - '0';
1594     OT  = 10 * OT + (tvb_get_guint8(tvb, UCP_OT_OFFSET + 1) - '0');
1595
1596     /* Make entries in Protocol column and Info column on summary display */
1597     if (check_col(pinfo->cinfo, COL_PROTOCOL))
1598             col_set_str(pinfo->cinfo, COL_PROTOCOL, "UCP");
1599
1600     if (check_col(pinfo->cinfo, COL_INFO)) {
1601         col_clear(pinfo->cinfo, COL_INFO);
1602         col_append_fstr(pinfo->cinfo, COL_INFO, "%s (%s)",
1603                      val_to_str(OT,  vals_hdr_OT,  "unknown operation"),
1604                      match_strval(O_R, vals_hdr_O_R));
1605         if (result == UCP_SHORTENED)
1606             col_append_str(pinfo->cinfo, COL_INFO, " [short packet]");
1607         else if (result == UCP_INV_CHK)
1608             col_append_str(pinfo->cinfo, COL_INFO, " [checksum invalid]");
1609     }
1610
1611     /* In the interest of speed, if "tree" is NULL, don't do any work not
1612        necessary to generate protocol tree items. */
1613     if (tree) {
1614
1615         /* create display subtree for the protocol */
1616         ti = proto_tree_add_item(tree, proto_ucp, tvb, 0, -1, FALSE);
1617
1618         ucp_tree = proto_item_add_subtree(ti, ett_ucp);
1619         /*
1620          * Process the packet here.
1621          * Transaction number
1622          */
1623         offset++;                               /* Skip <stx>   */
1624         tmpoff = offset;
1625         intval = tvb_get_guint8(tvb, tmpoff++) - '0';
1626         intval = 10 * intval + (tvb_get_guint8(tvb, tmpoff++) - '0');
1627         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_TRN, tvb, offset,
1628                             UCP_TRN_LEN, intval);
1629         offset = tmpoff;
1630
1631         offset++;                               /* Skip '/'     */
1632         intval = 0;
1633         tmpoff = offset;
1634         for (i = 0; i < UCP_LEN_LEN; i++) {     /* Length       */
1635             intval = 10 * intval +
1636                         (tvb_get_guint8(tvb, tmpoff++) - '0');
1637         }
1638         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_LEN, tvb, offset,
1639                             UCP_LEN_LEN, intval);
1640         offset = tmpoff;
1641
1642         offset++;                               /* Operation/Response   */
1643         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_O_R, tvb, offset++,
1644                             UCP_O_R_LEN, O_R);
1645
1646         offset++;                               /* Operation type */
1647         proto_tree_add_uint(ucp_tree, hf_ucp_hdr_OT, tvb, offset,
1648                             UCP_OT_LEN, OT);
1649         offset += UCP_OT_LEN;
1650         /*
1651          * Variable part starts here. Don't dissect if not complete.
1652          */
1653         if (result == UCP_SHORTENED)
1654             return;
1655         tmp_tvb = tvb_new_subset(tvb, offset, -1, -1);
1656         sub_ti = proto_tree_add_item(ucp_tree, hf_ucp_oper_section, tvb,
1657                                      offset, endpkt - offset, FALSE);
1658         sub_tree = proto_item_add_subtree(sub_ti, ett_sub);
1659
1660         switch (OT) {
1661             case  0:
1662                 O_R == 'O' ? add_00O(sub_tree,tmp_tvb) : add_00R(sub_tree,tmp_tvb);
1663                 break;
1664             case  1:
1665                 O_R == 'O' ? add_01O(sub_tree,tmp_tvb) : add_01R(sub_tree,tmp_tvb);
1666                 break;
1667             case  2:
1668                 O_R == 'O' ? add_02O(sub_tree,tmp_tvb) : add_02R(sub_tree,tmp_tvb);
1669                 break;
1670             case  3:
1671                 O_R == 'O' ? add_03O(sub_tree,tmp_tvb) : add_03R(sub_tree,tmp_tvb);
1672                 break;
1673             case  4:
1674                 O_R == 'O' ? add_04O(sub_tree,tmp_tvb) : add_04R(sub_tree,tmp_tvb);
1675                 break;
1676             case  5:
1677                 O_R == 'O' ? add_05O(sub_tree,tmp_tvb) : add_05R(sub_tree,tmp_tvb);
1678                 break;
1679             case  6:
1680                 O_R == 'O' ? add_06O(sub_tree,tmp_tvb) : add_06R(sub_tree,tmp_tvb);
1681                 break;
1682             case  7:
1683                 O_R == 'O' ? add_07O(sub_tree,tmp_tvb) : add_07R(sub_tree,tmp_tvb);
1684                 break;
1685             case  8:
1686                 O_R == 'O' ? add_08O(sub_tree,tmp_tvb) : add_08R(sub_tree,tmp_tvb);
1687                 break;
1688             case  9:
1689                 O_R == 'O' ? add_09O(sub_tree,tmp_tvb) : add_09R(sub_tree,tmp_tvb);
1690                 break;
1691             case 10:
1692                 O_R == 'O' ? add_10O(sub_tree,tmp_tvb) : add_10R(sub_tree,tmp_tvb);
1693                 break;
1694             case 11:
1695                 O_R == 'O' ? add_11O(sub_tree,tmp_tvb) : add_11R(sub_tree,tmp_tvb);
1696                 break;
1697             case 12:
1698                 O_R == 'O' ? add_12O(sub_tree,tmp_tvb) : add_12R(sub_tree,tmp_tvb);
1699                 break;
1700             case 13:
1701                 O_R == 'O' ? add_13O(sub_tree,tmp_tvb) : add_13R(sub_tree,tmp_tvb);
1702                 break;
1703             case 14:
1704                 O_R == 'O' ? add_14O(sub_tree,tmp_tvb) : add_14R(sub_tree,tmp_tvb);
1705                 break;
1706             case 15:
1707                 O_R == 'O' ? add_15O(sub_tree,tmp_tvb) : add_15R(sub_tree,tmp_tvb);
1708                 break;
1709             case 16:
1710                 O_R == 'O' ? add_16O(sub_tree,tmp_tvb) : add_16R(sub_tree,tmp_tvb);
1711                 break;
1712             case 17:
1713                 O_R == 'O' ? add_17O(sub_tree,tmp_tvb) : add_17R(sub_tree,tmp_tvb);
1714                 break;
1715             case 18:
1716                 O_R == 'O' ? add_18O(sub_tree,tmp_tvb) : add_18R(sub_tree,tmp_tvb);
1717                 break;
1718             case 19:
1719                 O_R == 'O' ? add_19O(sub_tree,tmp_tvb) : add_19R(sub_tree,tmp_tvb);
1720                 break;
1721             case 20:
1722                 O_R == 'O' ? add_20O(sub_tree,tmp_tvb) : add_20R(sub_tree,tmp_tvb);
1723                 break;
1724             case 21:
1725                 O_R == 'O' ? add_21O(sub_tree,tmp_tvb) : add_21R(sub_tree,tmp_tvb);
1726                 break;
1727             case 22:
1728                 O_R == 'O' ? add_22O(sub_tree,tmp_tvb) : add_22R(sub_tree,tmp_tvb);
1729                 break;
1730             case 23:
1731                 O_R == 'O' ? add_23O(sub_tree,tmp_tvb) : add_23R(sub_tree,tmp_tvb);
1732                 break;
1733             case 24:
1734                 O_R == 'O' ? add_24O(sub_tree,tmp_tvb) : add_24R(sub_tree,tmp_tvb);
1735                 break;
1736             case 30:
1737                 O_R == 'O' ? add_30O(sub_tree,tmp_tvb) : add_30R(sub_tree,tmp_tvb);
1738                 break;
1739             case 31:
1740                 O_R == 'O' ? add_31O(sub_tree,tmp_tvb) : add_31R(sub_tree,tmp_tvb);
1741                 break;
1742             case 51: case 52: case 53: case 54: case 55: case 56: case 57:
1743             case 58:
1744                 O_R == 'O' ? add_5xO(sub_tree,tmp_tvb) : add_5xR(sub_tree,tmp_tvb);
1745                 break;
1746             case 60: case 61:
1747                 O_R == 'O' ? add_6xO(sub_tree,tmp_tvb,OT) : add_6xR(sub_tree,tmp_tvb);
1748                 break;
1749             default:
1750                 break;
1751         }
1752     }
1753     return;
1754 }
1755
1756 /* Register the protocol with Ethereal */
1757 void
1758 proto_register_ucp(void)
1759 {
1760
1761     /* Setup list of fields     */
1762     static hf_register_info hf[] = {
1763         { &hf_ucp_hdr_TRN,
1764             { "Transaction Reference Number", "ucp.hdr.TRN",
1765               FT_UINT8, BASE_DEC, NULL, 0x00,
1766               "Transaction number for this command, used in windowing.",
1767               HFILL
1768             }
1769         },
1770         { &hf_ucp_hdr_LEN,
1771             { "Length", "ucp.hdr.LEN",
1772               FT_UINT16, BASE_DEC, NULL, 0x00,
1773               "Total number of characters between <stx>...<etx>.",
1774               HFILL
1775             }
1776         },
1777         { &hf_ucp_hdr_O_R,
1778             { "Type", "ucp.hdr.O_R",
1779               FT_UINT8, BASE_DEC, VALS(vals_hdr_O_R), 0x00,
1780               "Your basic 'is a request or response'.",
1781               HFILL
1782             }
1783         },
1784         { &hf_ucp_hdr_OT,
1785             { "Operation", "ucp.hdr.OT",
1786               FT_UINT8, BASE_DEC, VALS(vals_hdr_OT), 0x00,
1787               "The operation that is requested with this message.",
1788               HFILL
1789             }
1790         },
1791         { &hf_ucp_oper_section,
1792             { "Data", "ucp.parm",
1793               FT_NONE, BASE_DEC, NULL, 0x00,
1794               "The actual content of the operation.",
1795               HFILL
1796             }
1797         },
1798         { &hf_ucp_parm_AdC,
1799             { "AdC", "ucp.parm.AdC",
1800               FT_STRING, BASE_NONE, NULL, 0x00,
1801               "Address code recipient.",
1802               HFILL
1803             }
1804         },
1805         { &hf_ucp_parm_OAdC,
1806             { "OAdC", "ucp.parm.OAdC",
1807               FT_STRING, BASE_NONE, NULL, 0x00,
1808               "Address code originator.",
1809               HFILL
1810             }
1811         },
1812         { &hf_ucp_parm_DAdC,
1813             { "DAdC", "ucp.parm.DAdC",
1814               FT_STRING, BASE_NONE, NULL, 0x00,
1815               "Diverted address code.",
1816               HFILL
1817             }
1818         },
1819         { &hf_ucp_parm_AC,
1820             { "AC", "ucp.parm.AC",
1821               FT_STRING, BASE_NONE, NULL, 0x00,
1822               "Authentication code.",
1823               HFILL
1824             }
1825         },
1826         { &hf_ucp_parm_OAC,
1827             { "OAC", "ucp.parm.OAC",
1828               FT_STRING, BASE_NONE, NULL, 0x00,
1829               "Authentication code, originator.",
1830               HFILL
1831             }
1832         },
1833         { &hf_ucp_parm_NAC,
1834             { "NAC", "ucp.parm.NAC",
1835               FT_STRING, BASE_NONE, NULL, 0x00,
1836               "New authentication code.",
1837               HFILL
1838             }
1839         },
1840         { &hf_ucp_parm_BAS,
1841             { "BAS", "ucp.parm.BAS",
1842               FT_UINT8, BASE_DEC, VALS(vals_parm_BAS), 0x00,
1843               "Barring status flag.",
1844               HFILL
1845             }
1846         },
1847         { &hf_ucp_parm_LAR,
1848             { "LAR", "ucp.parm.LAR",
1849               FT_UINT8, BASE_DEC, VALS(vals_parm_LAR), 0x00,
1850               "Leg. code for all calls flag.",
1851               HFILL
1852             }
1853         },
1854         { &hf_ucp_parm_LAC,
1855             { "LAC", "ucp.parm.LAC",
1856               FT_STRING, BASE_NONE, NULL, 0x00,
1857               "New leg. code for all calls.",
1858               HFILL
1859             }
1860         },
1861         { &hf_ucp_parm_L1R,
1862             { "L1R", "ucp.parm.L1R",
1863               FT_UINT8, BASE_DEC, VALS(vals_parm_L1R), 0x00,
1864               "Leg. code for priority 1 flag.",
1865               HFILL
1866             }
1867         },
1868         { &hf_ucp_parm_L1P,
1869             { "L1P", "ucp.parm.L1P",
1870               FT_STRING, BASE_NONE, NULL, 0x00,
1871               "New leg. code for level 1 priority.",
1872               HFILL
1873             }
1874         },
1875         { &hf_ucp_parm_L3R,
1876             { "L3R", "ucp.parm.L3R",
1877               FT_UINT8, BASE_DEC, VALS(vals_parm_L3R), 0x00,
1878               "Leg. code for priority 3 flag.",
1879               HFILL
1880             }
1881         },
1882         { &hf_ucp_parm_L3P,
1883             { "L3P", "ucp.parm.L3P",
1884               FT_STRING, BASE_NONE, NULL, 0x00,
1885               "New leg. code for level 3 priority.",
1886               HFILL
1887             }
1888         },
1889         { &hf_ucp_parm_LCR,
1890             { "LCR", "ucp.parm.LCR",
1891               FT_UINT8, BASE_DEC, VALS(vals_parm_LCR), 0x00,
1892               "Leg. code for reverse charging flag.",
1893               HFILL
1894             }
1895         },
1896         { &hf_ucp_parm_LUR,
1897             { "LUR", "ucp.parm.LUR",
1898               FT_UINT8, BASE_DEC, VALS(vals_parm_LUR), 0x00,
1899               "Leg. code for urgent message flag.",
1900               HFILL
1901             }
1902         },
1903         { &hf_ucp_parm_LRR,
1904             { "LRR", "ucp.parm.LRR",
1905               FT_UINT8, BASE_DEC, VALS(vals_parm_LRR), 0x00,
1906               "Leg. code for repitition flag.",
1907               HFILL
1908             }
1909         },
1910         { &hf_ucp_parm_RT,
1911             { "RT", "ucp.parm.RT",
1912               FT_UINT8, BASE_DEC, VALS(vals_parm_RT), 0x00,
1913               "Receiver type.",
1914               HFILL
1915             }
1916         },
1917         { &hf_ucp_parm_NoN,
1918             { "NoN", "ucp.parm.NoN",
1919               FT_UINT16, BASE_DEC, NULL, 0x00,
1920               "Maximum number of numerical characters accepted.",
1921               HFILL
1922             }
1923         },
1924         { &hf_ucp_parm_NoA,
1925             { "NoA", "ucp.parm.NoA",
1926               FT_UINT16, BASE_DEC, NULL, 0x00,
1927               "Maximum number of alphanumerical characters accepted.",
1928               HFILL
1929             }
1930         },
1931         { &hf_ucp_parm_NoB,
1932             { "NoB", "ucp.parm.NoB",
1933               FT_UINT16, BASE_DEC, NULL, 0x00,
1934               "Maximum number of data bits accepted.",
1935               HFILL
1936             }
1937         },
1938         { &hf_ucp_parm_PNC,
1939             { "PNC", "ucp.parm.PNC",
1940               FT_UINT8, BASE_DEC, VALS(vals_parm_PNC), 0x00,
1941               "Paging network controller.",
1942               HFILL
1943             }
1944         },
1945         { &hf_ucp_parm_LNo,
1946             { "LNo", "ucp.parm.LNo",
1947               FT_STRING, BASE_NONE, NULL, 0x00,
1948               "Standard text list number requested by calling party.",
1949               HFILL
1950             }
1951         },
1952         { &hf_ucp_parm_LST,
1953             { "LST", "ucp.parm.LST",
1954               FT_STRING, BASE_NONE, NULL, 0x00,
1955               "Legitimisation code for standard text.",
1956               HFILL
1957             }
1958         },
1959         { &hf_ucp_parm_TNo,
1960             { "TNo", "ucp.parm.TNo",
1961               FT_STRING, BASE_NONE, NULL, 0x00,
1962               "Standard text number requested by calling party.",
1963               HFILL
1964             }
1965         },
1966         { &hf_ucp_parm_CS,
1967             { "CS", "ucp.parm.CS",
1968               FT_UINT8, BASE_DEC, NULL, 0x00,
1969               "Additional character set number.",
1970               HFILL
1971             }
1972         },
1973         { &hf_ucp_parm_PID,
1974             { "PID", "ucp.parm.PID",
1975               FT_UINT16, BASE_DEC, VALS(vals_parm_PID), 0x00,
1976               "SMT PID value.",
1977               HFILL
1978             }
1979         },
1980         { &hf_ucp_parm_NPL,
1981             { "NPL", "ucp.parm.NPL",
1982               FT_UINT16, BASE_DEC, NULL, 0x00,
1983               "Number of parameters in the following list.",
1984               HFILL
1985             }
1986         },
1987         { &hf_ucp_parm_GA,
1988             { "GA", "ucp.parm.GA",
1989               FT_STRING, BASE_NONE, NULL, 0x00,
1990               "GA?? haven't got a clue.",
1991               HFILL
1992             }
1993         },
1994         { &hf_ucp_parm_RP,
1995             { "RP", "ucp.parm.RP",
1996               FT_UINT8, BASE_DEC, VALS(vals_parm_RP), 0x00,
1997               "Repitition requested.",
1998               HFILL
1999             }
2000         },
2001         { &hf_ucp_parm_LRP,
2002             { "LRP", "ucp.parm.LRP",
2003               FT_STRING, BASE_DEC, NULL, 0x00,
2004               "Legitimisation code for repitition.",
2005               HFILL
2006             }
2007         },
2008         { &hf_ucp_parm_PR,
2009             { "PR", "ucp.parm.PR",
2010               FT_UINT8, BASE_DEC, NULL, 0x00,
2011               "Priority requested.",
2012               HFILL
2013             }
2014         },
2015         { &hf_ucp_parm_LPR,
2016             { "LPR", "ucp.parm.LPR",
2017               FT_STRING, BASE_DEC, NULL, 0x00,
2018               "Legitimisation code for priority requested.",
2019               HFILL
2020             }
2021         },
2022         { &hf_ucp_parm_UM,
2023             { "UM", "ucp.parm.UM",
2024               FT_UINT8, BASE_DEC, VALS(vals_parm_UM), 0x00,
2025               "Urgent message indicator.",
2026               HFILL
2027             }
2028         },
2029         { &hf_ucp_parm_LUM,
2030             { "LUM", "ucp.parm.LUM",
2031               FT_STRING, BASE_DEC, NULL, 0x00,
2032               "Legitimisation code for urgent message.",
2033               HFILL
2034             }
2035         },
2036         { &hf_ucp_parm_RC,
2037             { "RC", "ucp.parm.RC",
2038               FT_UINT8, BASE_DEC, VALS(vals_parm_RC), 0x00,
2039               "Reverse charging request.",
2040               HFILL
2041             }
2042         },
2043         { &hf_ucp_parm_LRC,
2044             { "LRC", "ucp.parm.LRC",
2045               FT_STRING, BASE_DEC, NULL, 0x00,
2046               "Legitimisation code for reverse charging.",
2047               HFILL
2048             }
2049         },
2050         { &hf_ucp_parm_NRq,
2051             { "NRq", "ucp.parm.NRq",
2052               FT_UINT8, BASE_DEC, VALS(vals_parm_NRq), 0x00,
2053               "Notification request.",
2054               HFILL
2055             }
2056         },
2057         { &hf_ucp_parm_GAdC,
2058             { "GAdC", "ucp.parm.GAdC",
2059               FT_STRING, BASE_NONE, NULL, 0x00,
2060               "Group address code.",
2061               HFILL
2062             }
2063         },
2064         { &hf_ucp_parm_A_D,
2065             { "A_D", "ucp.parm.A_D",
2066               FT_UINT8, BASE_DEC, VALS(vals_parm_A_D), 0x00,
2067               "Add to/delete from fixed subscriber address list record.",
2068               HFILL
2069             }
2070         },
2071         { &hf_ucp_parm_CT,
2072             { "CT", "ucp.parm.CT",
2073               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2074               "Accumulated charges timestamp.",
2075               HFILL
2076             }
2077         },
2078         { &hf_ucp_parm_AAC,
2079             { "AAC", "ucp.parm.AAC",
2080               FT_STRING, BASE_NONE, NULL, 0x00,
2081               "Accumulated charges.",
2082               HFILL
2083             }
2084         },
2085         { &hf_ucp_parm_MNo,
2086             { "MNo", "ucp.parm.MNo",
2087               FT_STRING, BASE_NONE, NULL, 0x00,
2088               "Message number.",
2089               HFILL
2090             }
2091         },
2092         { &hf_ucp_parm_R_T,
2093             { "R_T", "ucp.parm.R_T",
2094               FT_STRING, BASE_NONE, NULL, 0x00,
2095               "Message number.",
2096               HFILL
2097             }
2098         },
2099         { &hf_ucp_parm_NAdC,
2100             { "NAdC", "ucp.parm.NAdC",
2101               FT_STRING, BASE_NONE, NULL, 0x00,
2102               "Notification address.",
2103               HFILL
2104             }
2105         },
2106         { &hf_ucp_parm_NT,
2107             { "NT", "ucp.parm.NT",
2108               FT_UINT8, BASE_DEC, VALS(vals_parm_NT), 0x00,
2109               "Notification type.",
2110               HFILL
2111             }
2112         },
2113         { &hf_ucp_parm_IVR5x,
2114             { "IVR5x", "ucp.parm.IVR5x",
2115               FT_STRING, BASE_NONE, NULL, 0x00,
2116               "UCP release number supported/accepted.",
2117               HFILL
2118             }
2119         },
2120         { &hf_ucp_parm_REQ_OT,
2121             { "REQ_OT", "ucp.parm.REQ_OT",
2122               FT_UINT8, BASE_DEC, VALS(vals_parm_REQ_OT), 0x00,
2123               "UCP release number supported/accepted.",
2124               HFILL
2125             }
2126         },
2127         { &hf_ucp_parm_SSTAT,
2128             { "SSTAT", "ucp.parm.SSTAT",
2129               FT_UINT8, BASE_DEC, VALS(vals_parm_SSTAT), 0x00,
2130               "Supplementary services for which status is requested.",
2131               HFILL
2132             }
2133         },
2134         { &hf_ucp_parm_LMN,
2135             { "LMN", "ucp.parm.LMN",
2136               FT_UINT8, BASE_DEC, NULL, 0x00,
2137               "Last message number.",
2138               HFILL
2139             }
2140         },
2141         { &hf_ucp_parm_NMESS,
2142             { "NMESS", "ucp.parm.NMESS",
2143               FT_UINT8, BASE_DEC, NULL, 0x00,
2144               "Number of stored messages.",
2145               HFILL
2146             }
2147         },
2148         { &hf_ucp_parm_NMESS_str,
2149             { "NMESS_str", "ucp.parm.NMESS_str",
2150               FT_STRING, BASE_NONE, NULL, 0x00,
2151               "Number of stored messages.",
2152               HFILL
2153             }
2154         },
2155         { &hf_ucp_parm_NPID,
2156             { "NPID", "ucp.parm.NPID",
2157               FT_UINT16, BASE_DEC, VALS(vals_parm_PID), 0x00,
2158               "Notification PID value.",
2159               HFILL
2160             }
2161         },
2162         { &hf_ucp_parm_LRq,
2163             { "LRq", "ucp.parm.LRq",
2164               FT_UINT8, BASE_DEC, VALS(vals_parm_LRq), 0x00,
2165               "Last resort address request.",
2166               HFILL
2167             }
2168         },
2169         { &hf_ucp_parm_LRAd,
2170             { "LRAd", "ucp.parm.LRAd",
2171               FT_STRING, BASE_NONE, NULL, 0x00,
2172               "Last resort address.",
2173               HFILL
2174             }
2175         },
2176         { &hf_ucp_parm_LPID,
2177             { "LPID", "ucp.parm.LPID",
2178               FT_UINT16, BASE_DEC, VALS(vals_parm_PID), 0x00,
2179               "Last resort PID value.",
2180               HFILL
2181             }
2182         },
2183         { &hf_ucp_parm_DD,
2184             { "DD", "ucp.parm.DD",
2185               FT_UINT8, BASE_DEC, VALS(vals_parm_DD), 0x00,
2186               "Deferred delivery requested.",
2187               HFILL
2188             }
2189         },
2190         { &hf_ucp_parm_DDT,
2191             { "DDT", "ucp.parm.DDT",
2192               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2193               "Deferred delivery time.",
2194               HFILL
2195             }
2196         },
2197         { &hf_ucp_parm_STx,
2198             { "STx", "ucp.parm.STx",
2199               FT_NONE, BASE_NONE, NULL, 0x00,
2200               "Standard text.",
2201               HFILL
2202             }
2203         },
2204         { &hf_ucp_parm_ST,
2205             { "ST", "ucp.parm.ST",
2206               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2207               "Start time.",
2208               HFILL
2209             }
2210         },
2211         { &hf_ucp_parm_SP,
2212             { "SP", "ucp.parm.SP",
2213               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2214               "Stop time.",
2215               HFILL
2216             }
2217         },
2218         { &hf_ucp_parm_VP,
2219             { "VP", "ucp.parm.VP",
2220               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2221               "Validity period.",
2222               HFILL
2223             }
2224         },
2225         { &hf_ucp_parm_RPID,
2226             { "RPID", "ucp.parm.RPID",
2227               FT_STRING, BASE_NONE, NULL, 0x00,
2228               "Replace PID",
2229               HFILL
2230             }
2231         },
2232         { &hf_ucp_parm_SCTS,
2233             { "SCTS", "ucp.parm.SCTS",
2234               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2235               "Service Centre timestamp.",
2236               HFILL
2237             }
2238         },
2239         { &hf_ucp_parm_Dst,
2240             { "Dst", "ucp.parm.Dst",
2241               FT_UINT8, BASE_DEC, VALS(vals_parm_Dst), 0x00,
2242               "Delivery status.",
2243               HFILL
2244             }
2245         },
2246         { &hf_ucp_parm_Rsn,
2247             { "Rsn", "ucp.parm.Rsn",
2248               FT_UINT16, BASE_DEC, VALS(vals_parm_Rsn), 0x00,
2249               "Reason code.",
2250               HFILL
2251             }
2252         },
2253         { &hf_ucp_parm_DSCTS,
2254             { "DSCTS", "ucp.parm.DSCTS",
2255               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2256               "Delivery timestamp.",
2257               HFILL
2258             }
2259         },
2260         { &hf_ucp_parm_MT,
2261             { "MT", "ucp.parm.MT",
2262               FT_UINT8, BASE_DEC, VALS(vals_parm_MT), 0x00,
2263               "Message type.",
2264               HFILL
2265             }
2266         },
2267         { &hf_ucp_parm_NB,
2268             { "  NB", "ucp.parm.NB",
2269               FT_STRING, BASE_NONE, NULL, 0x00,
2270               "No. of bits in Transparent Data (TD) message.",
2271               HFILL
2272             }
2273         },
2274         { &hf_ucp_data_section,
2275             { "  Data", "ucp.message",
2276               FT_NONE, BASE_NONE, NULL, 0x00,
2277               "The actual message or data.",
2278               HFILL
2279             }
2280         },
2281         { &hf_ucp_parm_MMS,
2282             { "MMS", "ucp.parm.MMS",
2283               FT_UINT8, BASE_DEC, NULL, 0x00,
2284               "More messages to send.",
2285               HFILL
2286             }
2287         },
2288         { &hf_ucp_parm_DCs,
2289             { "DCs", "ucp.parm.DCs",
2290               FT_UINT8, BASE_DEC, VALS(vals_parm_DCs), 0x00,
2291               "Data coding scheme (deprecated).",
2292               HFILL
2293             }
2294         },
2295         { &hf_ucp_parm_MCLs,
2296             { "MCLs", "ucp.parm.MCLs",
2297               FT_UINT8, BASE_DEC, VALS(vals_parm_MCLs), 0x00,
2298               "Message class.",
2299               HFILL
2300             }
2301         },
2302         { &hf_ucp_parm_RPI,
2303             { "RPI", "ucp.parm.RPI",
2304               FT_UINT8, BASE_DEC, VALS(vals_parm_RPI), 0x00,
2305               "Reply path.",
2306               HFILL
2307             }
2308         },
2309         { &hf_ucp_parm_CPg,
2310             { "CPg", "ucp.parm.CPg",
2311               FT_STRING, BASE_NONE, NULL, 0x00,
2312               "Reserved for Code Page.",
2313               HFILL
2314             }
2315         },
2316         { &hf_ucp_parm_RPLy,
2317             { "RPLy", "ucp.parm.RPLy",
2318               FT_STRING, BASE_NONE, NULL, 0x00,
2319               "Reserved for Reply type.",
2320               HFILL
2321             }
2322         },
2323         { &hf_ucp_parm_OTOA,
2324             { "OTOA", "ucp.parm.OTOA",
2325               FT_STRING, BASE_NONE, NULL, 0x00,
2326               "Originator Type Of Address.",
2327               HFILL
2328             }
2329         },
2330         { &hf_ucp_parm_HPLMN,
2331             { "HPLMN", "ucp.parm.HPLMN",
2332               FT_STRING, BASE_NONE, NULL, 0x00,
2333               "Home PLMN address.",
2334               HFILL
2335             }
2336         },
2337         { &hf_ucp_parm_XSer,
2338             { "Extra services:", "ucp.parm.XSer",
2339               FT_NONE, BASE_DEC, NULL, 0x00,
2340               "Extra services.",
2341               HFILL
2342             }
2343         },
2344         { &hf_ucp_parm_RES4,
2345             { "RES4", "ucp.parm.RES4",
2346               FT_STRING, BASE_NONE, NULL, 0x00,
2347               "Reserved for future use.",
2348               HFILL
2349             }
2350         },
2351         { &hf_ucp_parm_RES5,
2352             { "RES5", "ucp.parm.RES5",
2353               FT_STRING, BASE_NONE, NULL, 0x00,
2354               "Reserved for future use.",
2355               HFILL
2356             }
2357         },
2358         { &hf_ucp_parm_OTON,
2359             { "OTON", "ucp.parm.OTON",
2360               FT_UINT8, BASE_DEC, VALS(vals_parm_OTON), 0x00,
2361               "Originator type of number.",
2362               HFILL
2363             }
2364         },
2365         { &hf_ucp_parm_ONPI,
2366             { "ONPI", "ucp.parm.ONPI",
2367               FT_UINT8, BASE_DEC, VALS(vals_parm_ONPI), 0x00,
2368               "Originator numbering plan id.",
2369               HFILL
2370             }
2371         },
2372         { &hf_ucp_parm_STYP0,
2373             { "STYP0", "ucp.parm.STYP0",
2374               FT_UINT8, BASE_DEC, VALS(vals_parm_STYP0), 0x00,
2375               "Subtype of operation.",
2376               HFILL
2377             }
2378         },
2379         { &hf_ucp_parm_STYP1,
2380             { "STYP1", "ucp.parm.STYP1",
2381               FT_UINT8, BASE_DEC, VALS(vals_parm_STYP1), 0x00,
2382               "Subtype of operation.",
2383               HFILL
2384             }
2385         },
2386         { &hf_ucp_parm_PWD,
2387             { "PWD", "ucp.parm.PWD",
2388               FT_NONE, BASE_DEC, NULL, 0x00,
2389               "Current password.",
2390               HFILL
2391             }
2392         },
2393         { &hf_ucp_parm_NPWD,
2394             { "NPWD", "ucp.parm.NPWD",
2395               FT_NONE, BASE_DEC, NULL, 0x00,
2396               "New password.",
2397               HFILL
2398             }
2399         },
2400         { &hf_ucp_parm_VERS,
2401             { "VERS", "ucp.parm.VERS",
2402               FT_STRING, BASE_NONE, NULL, 0x00,
2403               "Version number.",
2404               HFILL
2405             }
2406         },
2407         { &hf_ucp_parm_LAdC,
2408             { "LAdC", "ucp.parm.LAdC",
2409               FT_STRING, BASE_NONE, NULL, 0x00,
2410               "Address for VSMSC list operation.",
2411               HFILL
2412             }
2413         },
2414         { &hf_ucp_parm_LTON,
2415             { "LTON", "ucp.parm.LTON",
2416               FT_UINT8, BASE_DEC, NULL, 0x00,
2417               "Type of number list address.",
2418               HFILL
2419             }
2420         },
2421         { &hf_ucp_parm_LNPI,
2422             { "LNPI", "ucp.parm.LNPI",
2423               FT_UINT8, BASE_DEC, NULL, 0x00,
2424               "Numbering plan id. list address.",
2425               HFILL
2426             }
2427         },
2428         { &hf_ucp_parm_OPID,
2429             { "OPID", "ucp.parm.OPID",
2430               FT_UINT8, BASE_DEC, VALS(vals_parm_OPID), 0x00,
2431               "Originator protocol identifier.",
2432               HFILL
2433             }
2434         },
2435         { &hf_ucp_parm_RES1,
2436             { "RES1", "ucp.parm.RES1",
2437               FT_STRING, BASE_NONE, NULL, 0x00,
2438               "Reserved for future use.",
2439               HFILL
2440             }
2441         },
2442         { &hf_ucp_parm_RES2,
2443             { "RES2", "ucp.parm.RES2",
2444               FT_STRING, BASE_NONE, NULL, 0x00,
2445               "Reserved for future use.",
2446               HFILL
2447             }
2448         },
2449         { &hf_ucp_parm_ACK,
2450             { "(N)Ack", "ucp.parm.ACK",
2451               FT_UINT8, BASE_DEC, VALS(vals_parm_ACK), 0x00,
2452               "Positive or negative acknowledge of the operation.",
2453               HFILL
2454             }
2455         },
2456         { &hf_ucp_parm_MVP,
2457             { "MVP", "ucp.parm.MVP",
2458               FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
2459               "Mofified validity period.",
2460               HFILL
2461             }
2462         },
2463         { &hf_ucp_parm_EC,
2464             { "Error code", "ucp.parm.EC",
2465               FT_UINT8, BASE_DEC, VALS(vals_parm_EC), 0x00,
2466               "The result of the requested operation.",
2467               HFILL
2468             }
2469         },
2470         { &hf_ucp_parm_SM,
2471             { "SM", "ucp.parm.SM",
2472               FT_STRING, BASE_NONE, NULL, 0x00,
2473               "System message.",
2474               HFILL
2475             }
2476         },
2477         { &hf_xser_service,
2478             { "Type of service", "ucp.xser.service",
2479               FT_UINT8, BASE_HEX, VALS(vals_xser_service), 0x00,
2480               "The type of service specified.",
2481               HFILL
2482             }
2483         },
2484     };
2485     /* Setup protocol subtree array */
2486     static gint *ett[] = {
2487         &ett_ucp,
2488         &ett_sub,
2489         &ett_XSer
2490     };
2491     /* Register the protocol name and description */
2492     proto_ucp = proto_register_protocol("Universal Computer Protocol",
2493                                         "UCP", "ucp");
2494
2495     /* Required function calls to register header fields and subtrees used */
2496     proto_register_field_array(proto_ucp, hf, array_length(hf));
2497     proto_register_subtree_array(ett, array_length(ett));
2498 }
2499
2500 /*
2501  * If dissector uses sub-dissector registration add a registration routine.
2502  * This format is required because a script is used to find these routines and
2503  * create the code that calls these routines.
2504  */
2505 void
2506 proto_reg_handoff_ucp(void)
2507 {
2508     dissector_handle_t ucp_handle;
2509
2510     /*
2511      * UCP can be spoken on any port so, when not on a specific port, try this
2512      * one whenever TCP is spoken.
2513      */
2514     heur_dissector_add("tcp", dissect_ucp_heur, proto_ucp);
2515
2516     /*
2517      * Also register as one that can be selected by a TCP port number.
2518      */
2519     ucp_handle = create_dissector_handle(dissect_ucp, proto_ucp);
2520     dissector_add_handle("tcp.port", ucp_handle);
2521 }