2 * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * q932_fac.c - decode Q.932 facilities
28 * ------------------------------------
30 * $Id: q932_fac.c,v 1.8 2000/02/24 16:32:46 hm Exp $
34 * last edit-date: [Thu Feb 24 17:36:47 2000]
36 *---------------------------------------------------------------------------
38 * - Q.932 (03/93) Generic Procedures for the Control of
39 * ISDN Supplementaty Services
40 * - Q.950 (03/93) Supplementary Services Protocols, Structure and
42 * - ETS 300 179 (10/92) Advice Of Charge: charging information during
43 * the call (AOC-D) supplementary service Service description
44 * - ETS 300 180 (10/92) Advice Of Charge: charging information at the
45 * end of call (AOC-E) supplementary service Service description
46 * - ETS 300 181 (04/93) Advice Of Charge (AOC) supplementary service
47 * Functional capabilities and information flows
48 * - ETS 300 182 (04/93) Advice Of Charge (AOC) supplementary service
49 * Digital Subscriber Signalling System No. one (DSS1) protocol
50 * - X.208 Specification of Abstract Syntax Notation One (ASN.1)
51 * - X.209 Specification of Basic Encoding Rules for
52 * Abstract Syntax Notation One (ASN.1)
53 * - "ASN.1 Abstract Syntax Notation One", Walter Gora, DATACOM-Verlag
54 * 1992, 3rd Edition (ISBN 3-89238-062-7) (german !)
56 *---------------------------------------------------------------------------*/
61 static int do_component(int length, char *pbuf);
62 static char *uni_str(int code);
63 static char *opval_str(int val);
64 static char *bid_str(int val);
65 static void next_state(char *pbuf, int class, int form, int code, int val);
67 static void object_id(int comp_length, unsigned char *pbuf);
70 static unsigned char *byte_buf;
73 /*---------------------------------------------------------------------------*
74 * decode Q.931/Q.932 facility info element
75 *---------------------------------------------------------------------------*/
77 q932_facility(char *pbuf, unsigned char *buf)
81 sprintf((pbuf+strlen(pbuf)), "[facility (Q.932): ");
87 buf++; /* protocol profile */
89 sprintf((pbuf+strlen(pbuf)), "Protocol=");
94 sprintf((pbuf+strlen(pbuf)), "Remote Operations Protocol\n");
98 sprintf((pbuf+strlen(pbuf)), "CMIP Protocol (Q.941), UNSUPPORTED!\n");
103 sprintf((pbuf+strlen(pbuf)), "ACSE Protocol (X.217/X.227), UNSUPPORTED!\n");
108 sprintf((pbuf+strlen(pbuf)), "Unknown Protocol (val = 0x%x), UNSUPPORTED!\n", *buf & 0x1f);
118 /* initialize variables for do_component */
122 state = ST_EXP_COMP_TYP;
124 /* decode facility */
126 do_component(len, pbuf);
128 sprintf((pbuf+(strlen(pbuf)-1)), "]"); /* XXX replace last newline */
133 /*---------------------------------------------------------------------------*
134 * handle a component recursively
135 *---------------------------------------------------------------------------*/
137 do_component(int length, char *pbuf)
139 int comp_tag_class; /* component tag class */
140 int comp_tag_form; /* component form: constructor or primitive */
141 int comp_tag_code; /* component code depending on class */
142 int comp_length = 0; /* component length */
145 sprintf((pbuf+strlen(pbuf)), "ENTER - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
151 sprintf((pbuf+strlen(pbuf)), "AGAIN - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
154 /*----------------------------------------*/
155 /* first component element: component tag */
156 /*----------------------------------------*/
160 sprintf((pbuf+strlen(pbuf)), "\t0x%02x Tag: ", *byte_buf);
162 comp_tag_class = (*byte_buf & 0xc0) >> 6;
164 switch(comp_tag_class)
166 case FAC_TAGCLASS_UNI:
167 sprintf((pbuf+strlen(pbuf)), "Universal");
169 case FAC_TAGCLASS_APW:
170 sprintf((pbuf+strlen(pbuf)), "Applic-wide");
172 case FAC_TAGCLASS_COS:
173 sprintf((pbuf+strlen(pbuf)), "Context-spec");
175 case FAC_TAGCLASS_PRU:
176 sprintf((pbuf+strlen(pbuf)), "Private");
182 comp_tag_form = (*byte_buf & 0x20) > 5;
184 sprintf((pbuf+strlen(pbuf)), ", ");
186 if(comp_tag_form == FAC_TAGFORM_CON)
188 sprintf((pbuf+strlen(pbuf)), "Constructor");
192 sprintf((pbuf+strlen(pbuf)), "Primitive");
197 comp_tag_code = *byte_buf & 0x1f;
199 sprintf((pbuf+strlen(pbuf)), ", ");
201 if(comp_tag_code == 0x1f)
208 while(*byte_buf & 0x80)
210 comp_tag_code += (*byte_buf & 0x7f);
214 comp_tag_code += (*byte_buf & 0x7f);
215 sprintf((pbuf+strlen(pbuf)), "%d (ext)\n", comp_tag_code);
219 comp_tag_code = (*byte_buf & 0x1f);
221 if(comp_tag_class == FAC_TAGCLASS_UNI)
223 sprintf((pbuf+strlen(pbuf)), "%s (%d)\n", uni_str(comp_tag_code), comp_tag_code);
227 sprintf((pbuf+strlen(pbuf)), "code = %d\n", comp_tag_code);
234 /*--------------------------------------------*/
235 /* second component element: component length */
236 /*--------------------------------------------*/
238 sprintf((pbuf+strlen(pbuf)), "\t0x%02x Len: ", *byte_buf);
244 int i = *byte_buf & 0x7f;
251 comp_length += (*byte_buf * (i*256));
253 sprintf((pbuf+strlen(pbuf)), "%d (long form)\n", comp_length);
257 comp_length = *byte_buf & 0x7f;
258 sprintf((pbuf+strlen(pbuf)), "%d (short form)\n", comp_length);
261 next_state(pbuf, comp_tag_class, comp_tag_form, comp_tag_code, -1);
269 /*---------------------------------------------*/
270 /* third component element: component contents */
271 /*---------------------------------------------*/
273 if(comp_tag_form) /* == constructor */
275 do_component(comp_length, pbuf);
280 if(comp_tag_class == FAC_TAGCLASS_UNI)
282 switch(comp_tag_code)
284 case FAC_CODEUNI_INT:
285 case FAC_CODEUNI_ENUM:
286 case FAC_CODEUNI_BOOL:
291 sprintf((pbuf+strlen(pbuf)), "\t");
293 for(i = comp_length-1; i >= 0; i--)
295 sprintf((pbuf+strlen(pbuf)), "0x%02x ", *byte_buf);
296 val += (*byte_buf + (i*255));
300 sprintf((pbuf+strlen(pbuf)), "\n\t");
302 sprintf((pbuf+strlen(pbuf)), "Val: %d\n", val);
306 case FAC_CODEUNI_OBJI: /* object id */
309 object_id(comp_length, pbuf);
317 sprintf((pbuf+strlen(pbuf)), "\t");
319 for(i = comp_length-1; i >= 0; i--)
321 sprintf((pbuf+strlen(pbuf)), "0x%02x = %d", *byte_buf, *byte_buf);
322 if(isprint(*byte_buf))
323 sprintf((pbuf+strlen(pbuf)), " = '%c'", *byte_buf);
327 sprintf((pbuf+strlen(pbuf)), "\n\t");
334 else /* comp_tag_class != FAC_TAGCLASS_UNI */
340 sprintf((pbuf+strlen(pbuf)), "\t");
342 for(i = comp_length-1; i >= 0; i--)
344 sprintf((pbuf+strlen(pbuf)), "0x%02x", *byte_buf);
345 val += (*byte_buf + (i*255));
349 sprintf((pbuf+strlen(pbuf)), "\n\t");
351 sprintf((pbuf+strlen(pbuf)), "\n");
354 next_state(pbuf, comp_tag_class, comp_tag_form, comp_tag_code, val);
359 sprintf((pbuf+strlen(pbuf)), "PREGOTO - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
361 if(byte_len < length)
364 sprintf((pbuf+strlen(pbuf)), "RETURN - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
369 /*---------------------------------------------------------------------------*
370 * print universal id type
371 *---------------------------------------------------------------------------*/
372 static char *uni_str(int code)
374 static char *tbl[] = {
401 if(code >= 1 && code <= FAC_CODEUNI_GNSTR)
404 return("ERROR, Value out of Range!");
407 /*---------------------------------------------------------------------------*
408 * print operation value
409 *---------------------------------------------------------------------------*/
410 static char *opval_str(int val)
412 static char buffer[80];
435 case FAC_OPVAL_DIV_ACT:
436 r = "activationDiversion";
438 case FAC_OPVAL_DIV_DEACT:
439 r = "deactivationDiversion";
441 case FAC_OPVAL_DIV_ACTSN:
442 r = "activationStatusNotificationDiv";
444 case FAC_OPVAL_DIV_DEACTSN:
445 r = "deactivationStatusNotificationDiv";
447 case FAC_OPVAL_DIV_INTER:
448 r = "interrogationDiversion";
450 case FAC_OPVAL_DIV_INFO:
451 r = "diversionInformation";
453 case FAC_OPVAL_DIV_CALLDEF:
454 r = "callDeflection";
456 case FAC_OPVAL_DIV_CALLRER:
459 case FAC_OPVAL_DIV_LINF2:
460 r = "divertingLegInformation2";
462 case FAC_OPVAL_DIV_INVS:
465 case FAC_OPVAL_DIV_INTER1:
466 r = "interrogationDiversion1";
468 case FAC_OPVAL_DIV_LINF1:
469 r = "divertingLegInformation1";
471 case FAC_OPVAL_DIV_LINF3:
472 r = "divertingLegInformation3";
474 case FAC_OPVAL_ER_CRCO:
475 r = "explicitReservationCreationControl";
477 case FAC_OPVAL_ER_MGMT:
478 r = "explicitReservationManagement";
480 case FAC_OPVAL_ER_CANC:
481 r = "explicitReservationCancel";
483 case FAC_OPVAL_MLPP_QUERY:
484 r = "mLPP lfb Query";
486 case FAC_OPVAL_MLPP_CALLR:
487 r = "mLPP Call Request";
489 case FAC_OPVAL_MLPP_CALLP:
490 r = "mLPP Call Preemption";
492 case FAC_OPVAL_AOC_REQ:
493 r = "chargingRequest";
495 case FAC_OPVAL_AOC_S_CUR:
498 case FAC_OPVAL_AOC_S_SPC:
499 r = "aOCSSpecialArrangement";
501 case FAC_OPVAL_AOC_D_CUR:
504 case FAC_OPVAL_AOC_D_UNIT:
505 r = "aOCDChargingUnit";
507 case FAC_OPVAL_AOC_E_CUR:
510 case FAC_OPVAL_AOC_E_UNIT:
511 r = "aOCEChargingUnit";
513 case FAC_OPVAL_AOC_IDOFCRG:
514 r = "identificationOfCharge";
516 case FAC_OPVAL_CONF_BEG:
519 case FAC_OPVAL_CONF_ADD:
522 case FAC_OPVAL_CONF_SPLIT:
525 case FAC_OPVAL_CONF_DROP:
528 case FAC_OPVAL_CONF_ISOLATE:
531 case FAC_OPVAL_CONF_REATT:
534 case FAC_OPVAL_CONF_PDISC:
537 case FAC_OPVAL_CONF_FCONF:
540 case FAC_OPVAL_CONF_END:
543 case FAC_OPVAL_CONF_IDCFE:
544 r = "indentifyConferee";
546 case FAC_OPVAL_REVC_REQ:
550 sprintf(buffer, "unknown operation value %d!", val);
556 /*---------------------------------------------------------------------------*
558 *---------------------------------------------------------------------------*/
559 static char *bid_str(int val)
561 static char buffer[80];
567 r = "normalCharging";
570 r = "reverseCharging";
573 r = "creditCardCharging";
576 r = "callForwardingUnconditional";
579 r = "callForwardingBusy";
582 r = "callForwardingNoReply";
585 r = "callDeflection";
591 sprintf(buffer, "unknown billing-id value %d!", val);
597 /*---------------------------------------------------------------------------*
599 *---------------------------------------------------------------------------*/
601 F_1_1(char *pbuf, int val)
604 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_1, val = %d\n", val);
608 sprintf((pbuf+strlen(pbuf)), "\t invokeComponent\n");
609 state = ST_EXP_INV_ID;
613 /*---------------------------------------------------------------------------*
615 *---------------------------------------------------------------------------*/
617 F_1_2(char *pbuf, int val)
620 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_2, val = %d\n", val);
624 sprintf((pbuf+strlen(pbuf)), "\t returnResult\n");
625 state = ST_EXP_RR_INV_ID;
628 /*---------------------------------------------------------------------------*
630 *---------------------------------------------------------------------------*/
632 F_1_3(char *pbuf, int val)
635 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_3, val = %d\n", val);
639 sprintf((pbuf+strlen(pbuf)), "\t returnError\n");
643 /*---------------------------------------------------------------------------*
645 *---------------------------------------------------------------------------*/
647 F_1_4(char *pbuf, int val)
650 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_4, val = %d\n", val);
654 sprintf((pbuf+strlen(pbuf)), "\t reject\n");
655 state = ST_EXP_REJ_INV_ID;
659 /*---------------------------------------------------------------------------*
660 * return result: invoke id
661 *---------------------------------------------------------------------------*/
663 F_RJ2(char *pbuf, int val)
666 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ2, val = %d\n", val);
670 sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
671 state = ST_EXP_REJ_OP_VAL;
675 /*---------------------------------------------------------------------------*
676 * reject, general problem
677 *---------------------------------------------------------------------------*/
679 F_RJ30(char *pbuf, int val)
682 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ30, val = %d\n", val);
686 sprintf((pbuf+strlen(pbuf)), "\t General problem\n");
693 sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized component\n");
696 sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped component\n");
699 sprintf((pbuf+strlen(pbuf)), "\t problem = badly structured component\n");
702 sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
709 /*---------------------------------------------------------------------------*
710 * reject, invoke problem
711 *---------------------------------------------------------------------------*/
713 F_RJ31(char *pbuf, int val)
716 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ31, val = %d\n", val);
720 sprintf((pbuf+strlen(pbuf)), "\t Invoke problem\n");
727 sprintf((pbuf+strlen(pbuf)), "\t problem = duplicate invocation\n");
730 sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized operation\n");
733 sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped argument\n");
736 sprintf((pbuf+strlen(pbuf)), "\t problem = resource limitation\n");
739 sprintf((pbuf+strlen(pbuf)), "\t problem = initiator releasing\n");
742 sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized linked identifier\n");
745 sprintf((pbuf+strlen(pbuf)), "\t problem = linked resonse unexpected\n");
748 sprintf((pbuf+strlen(pbuf)), "\t problem = unexpected child operation\n");
751 sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
758 /*---------------------------------------------------------------------------*
759 * reject, return result problem
760 *---------------------------------------------------------------------------*/
762 F_RJ32(char *pbuf, int val)
765 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ32, val = %d\n", val);
769 sprintf((pbuf+strlen(pbuf)), "\t Return result problem\n");
776 sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized invocation\n");
779 sprintf((pbuf+strlen(pbuf)), "\t problem = return response unexpected\n");
782 sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped result\n");
785 sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
792 /*---------------------------------------------------------------------------*
793 * reject, return error problem
794 *---------------------------------------------------------------------------*/
796 F_RJ33(char *pbuf, int val)
799 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ33, val = %d\n", val);
803 sprintf((pbuf+strlen(pbuf)), "\t Return error problem\n");
810 sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized invocation\n");
813 sprintf((pbuf+strlen(pbuf)), "\t problem = error response unexpected\n");
816 sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized error\n");
819 sprintf((pbuf+strlen(pbuf)), "\t problem = unexpected error\n");
822 sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped parameter\n");
825 sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
832 /*---------------------------------------------------------------------------*
833 * invoke component: invoke id
834 *---------------------------------------------------------------------------*/
836 F_2(char *pbuf, int val)
839 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_2, val = %d\n", val);
843 sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
844 state = ST_EXP_OP_VAL;
848 /*---------------------------------------------------------------------------*
849 * return result: invoke id
850 *---------------------------------------------------------------------------*/
852 F_RR2(char *pbuf, int val)
855 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RR2, val = %d\n", val);
859 sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
860 state = ST_EXP_RR_OP_VAL;
864 /*---------------------------------------------------------------------------*
865 * invoke component: operation value
866 *---------------------------------------------------------------------------*/
868 F_3(char *pbuf, int val)
871 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_3, val = %d\n", val);
875 sprintf((pbuf+strlen(pbuf)), "\t Operation Value = %s (%d)\n", opval_str(val), val);
880 /*---------------------------------------------------------------------------*
881 * return result: operation value
882 *---------------------------------------------------------------------------*/
884 F_RR3(char *pbuf, int val)
887 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RR3, val = %d\n", val);
891 sprintf((pbuf+strlen(pbuf)), "\t Operation Value = %s (%d)\n", opval_str(val), val);
892 state = ST_EXP_RR_RESULT;
896 /*---------------------------------------------------------------------------*
897 * return result: RESULT
898 *---------------------------------------------------------------------------*/
900 F_RRR(char *pbuf, int val)
903 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RRR, val = %d\n", val);
908 /*---------------------------------------------------------------------------*
910 *---------------------------------------------------------------------------*/
912 F_4(char *pbuf, int val)
915 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4, val = %d\n", val);
919 sprintf((pbuf+strlen(pbuf)), "\t specificChargingUnits\n");
924 /*---------------------------------------------------------------------------*
926 *---------------------------------------------------------------------------*/
928 F_4_1(char *pbuf, int val)
931 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4_1, val = %d\n", val);
935 sprintf((pbuf+strlen(pbuf)), "\t freeOfCharge\n");
940 /*---------------------------------------------------------------------------*
942 *---------------------------------------------------------------------------*/
944 F_4_2(char *pbuf, int val)
947 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4_2, val = %d\n", val);
951 sprintf((pbuf+strlen(pbuf)), "\t chargeNotAvailable\n");
956 /*---------------------------------------------------------------------------*
958 *---------------------------------------------------------------------------*/
960 F_5(char *pbuf, int val)
963 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_5, val = %d\n", val);
967 sprintf((pbuf+strlen(pbuf)), "\t recordedUnitsList [1]\n");
972 /*---------------------------------------------------------------------------*
974 *---------------------------------------------------------------------------*/
976 F_6(char *pbuf, int val)
979 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_6, val = %d\n", val);
983 sprintf((pbuf+strlen(pbuf)), "\t RecordedUnits\n");
988 /*---------------------------------------------------------------------------*
990 *---------------------------------------------------------------------------*/
992 F_7(char *pbuf, int val)
995 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_7, val = %d\n", val);
999 sprintf((pbuf+strlen(pbuf)), "\t NumberOfUnits = %d\n", val);
1000 state = ST_EXP_TOCI;
1004 /*---------------------------------------------------------------------------*
1006 *---------------------------------------------------------------------------*/
1008 F_8(char *pbuf, int val)
1011 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_8, val = %d\n", val);
1015 sprintf((pbuf+strlen(pbuf)), "\t typeOfChargingInfo = %s\n", val == 0 ? "subTotal" : "total");
1016 state = ST_EXP_DBID;
1020 /*---------------------------------------------------------------------------*
1022 *---------------------------------------------------------------------------*/
1024 F_9(char *pbuf, int val)
1027 sprintf((pbuf+strlen(pbuf)), "next_state: exec F_9, val = %d\n", val);
1031 sprintf((pbuf+strlen(pbuf)), "\t AOCDBillingId = %s (%d)\n", bid_str(val), val);
1036 /*---------------------------------------------------------------------------*
1038 *---------------------------------------------------------------------------*/
1039 static struct statetab {
1040 int currstate; /* input: current state we are in */
1041 int form; /* input: current tag form */
1042 int class; /* input: current tag class */
1043 int code; /* input: current tag code */
1044 void (*func)(char *,int); /* output: func to exec */
1047 /* current state tag form tag class tag code function */
1048 /* --------------------- ---------------------- ---------------------- ---------------------- ----------------*/
1052 {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 1, F_1_1 },
1053 {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 2, F_1_2 },
1054 {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 3, F_1_3 },
1055 {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 4, F_1_4 },
1056 {ST_EXP_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_2 },
1057 {ST_EXP_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_3 },
1058 {ST_EXP_INFO, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SEQ, F_4 },
1059 {ST_EXP_INFO, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_NULL, F_4_1 },
1060 {ST_EXP_INFO, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 1, F_4_2 },
1061 {ST_EXP_RUL, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 1, F_5 },
1062 {ST_EXP_RU, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SEQ, F_6 },
1063 {ST_EXP_RNOU, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_7 },
1064 {ST_EXP_TOCI, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 2, F_8 },
1065 {ST_EXP_DBID, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 3, F_9 },
1069 {ST_EXP_RR_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR2 },
1070 {ST_EXP_RR_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR3 },
1071 {ST_EXP_RR_RESULT, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SET, F_RRR },
1073 /* current state tag form tag class tag code function */
1074 /* --------------------- ---------------------- ---------------------- ---------------------- ----------------*/
1077 {ST_EXP_REJ_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RJ2 },
1078 {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 0, F_RJ30 },
1079 {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 1, F_RJ31 },
1080 {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 2, F_RJ32 },
1081 {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 3, F_RJ33 },
1085 {-1, -1, -1, -1, NULL }
1088 /*---------------------------------------------------------------------------*
1089 * state decode for do_component
1090 *---------------------------------------------------------------------------*/
1092 next_state(char *pbuf, int class, int form, int code, int val)
1097 sprintf((pbuf+strlen(pbuf)), "next_state: class=%d, form=%d, code=%d, val=%d\n", class, form, code, val);
1102 if((statetab[i].currstate > state) ||
1103 (statetab[i].currstate == -1))
1108 if((statetab[i].currstate == state) &&
1109 (statetab[i].form == form) &&
1110 (statetab[i].class == class) &&
1111 (statetab[i].code == code))
1113 (*statetab[i].func)(pbuf, val);
1119 /*---------------------------------------------------------------------------*
1120 * decode OBJECT IDENTIFIER
1121 *---------------------------------------------------------------------------*/
1123 object_id(int comp_length, unsigned char *pbuf)
1131 sprintf((pbuf+strlen(pbuf)), "\t");
1133 for(i = comp_length-1; i >= 0; i--, j++)
1135 sprintf((pbuf+strlen(pbuf)), "0x%02x = %d", *byte_buf, *byte_buf);
1141 if(x >= 0 && x <= 39)
1143 sprintf((pbuf+strlen(pbuf)), " ccitt/itu-t (0)");
1147 sprintf((pbuf+strlen(pbuf)), " recommendation (0)");
1150 sprintf((pbuf+strlen(pbuf)), " question (1)");
1153 sprintf((pbuf+strlen(pbuf)), " administration (2)");
1156 sprintf((pbuf+strlen(pbuf)), " network-operator (3)");
1159 sprintf((pbuf+strlen(pbuf)), " identified-organization (4)");
1163 sprintf((pbuf+strlen(pbuf)), " error: undefined-identifier (%d)", x);
1167 else if(x >= 40 && x <= 79)
1169 sprintf((pbuf+strlen(pbuf)), " iso (1)");
1174 sprintf((pbuf+strlen(pbuf)), " standard (0)");
1177 sprintf((pbuf+strlen(pbuf)), " registration-authority (1)");
1180 sprintf((pbuf+strlen(pbuf)), " member-body (2)");
1183 sprintf((pbuf+strlen(pbuf)), " identified-organization (3)");
1187 sprintf((pbuf+strlen(pbuf)), " error: undefined-identifier (%d)", x);
1194 sprintf((pbuf+strlen(pbuf)), " joint-iso-ccitt (3) ??? (%d)", x);
1204 sprintf((pbuf+strlen(pbuf)), " etsi (0)");
1216 sprintf((pbuf+strlen(pbuf)), " mobileDomain (0)");
1220 sprintf((pbuf+strlen(pbuf)), " inDomain (1)");
1229 sprintf((pbuf+strlen(pbuf)), "\n\t");
1231 sprintf((pbuf+strlen(pbuf)), "\n");