1 /*
2  * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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
23  * SUCH DAMAGE.
24  *
25  *---------------------------------------------------------------------------
26  *
27  *	printing cause values
28  *	---------------------
29  *
30  *	$Id: pcause.c,v 1.4 2003/10/06 09:43:27 itojun Exp $
31  *
32  * $FreeBSD$
33  *
34  *	last edit-date: [Mon Dec 13 21:48:07 1999]
35  *
36  *---------------------------------------------------------------------------*/
37 
38 #include "isdnd.h"
39 
40 static char *cause_i4b_tab[CAUSE_I4B_MAX+1] = {
41 	"normal call clearing",
42 	"user busy",
43 	"channel not available",
44 	"incompatible source or destination",
45 	"call rejected",
46 	"destination out of order",
47 	"temporary failure",
48 	"layer 1 error / persistent deactivation",
49 	"dialing impossible on leased line",
50 	"ERROR, invalid I4B cause value!"
51 };
52 
53 static char *cause_q850_tab[CAUSE_Q850_MAX] = {
54 	"Normal D-channel shutdown",
55 	"Unallocated (unassigned) number",
56 	"No route to specified transit network (national use)",
57 	"No route to destination",
58 	"Send special information tone",
59 	"Misdialled trunk prefix (national use)",
60 	"Channel unacceptable",
61 	"Call awarded and being delivered in an established channel",
62 	"Preemption",
63 	"Preemption - circuit reserved for reuse",
64 
65 /*10*/	"cause code 10: error, unassigned in Q.850 (03/93)",
66 	"cause code 11: error, unassigned in Q.850 (03/93)",
67 	"cause code 12: error, unassigned in Q.850 (03/93)",
68 	"cause code 13: error, unassigned in Q.850 (03/93)",
69 	"cause code 14: error, unassigned in Q.850 (03/93)",
70 	"cause code 15: error, unassigned in Q.850 (03/93)",
71 	"Normal call clearing",
72 	"User busy",
73 	"No user responding",
74 	"No answer from user (user alerted)",
75 
76 /*20*/	"Subscriber absent",
77 	"Call rejected",
78 	"Number changed",
79 	"cause code 23: error, unassigned in Q.850 (03/93)",
80 	"cause code 24: error, unassigned in Q.850 (03/93)",
81 	"cause code 25: error, unassigned in Q.850 (03/93)",
82 	"Non-selected user clearing",
83 	"Destination out of order",
84 	"Invalid number format",
85 	"Facility rejected",
86 
87 /*30*/	"Response to STATUS ENQUIRY",
88 	"Normal, unspecified",
89 	"cause code 32: error, unassigned in Q.850 (03/93)",
90 	"cause code 33: error, unassigned in Q.850 (03/93)",
91 	"No circuit / channel available",
92 	"cause code 35: error, unassigned in Q.850 (03/93)",
93 	"cause code 36: error, unassigned in Q.850 (03/93)",
94 	"cause code 37: error, unassigned in Q.850 (03/93)",
95 	"Network out of order",
96 	"Permanent frame mode connection out of service",
97 
98 /*40*/	"Permanent frame mode connection operational",
99 	"Temporary failure",
100 	"Switching equipment congestion",
101 	"Access information discarded",
102 	"Requested circuit/channel not available",
103 	"cause code 45: error, unassigned in Q.850 (03/93)",
104 	"Precedence call blocked",
105 	"Resources unavailable, unspecified",
106 	"cause code 48: error, unassigned in Q.850 (03/93)",
107 	"Quality of service unavailable",
108 
109 /*50*/	"Requested facility not subscribed",
110 	"cause code 51: error, unassigned in Q.850 (03/93)",
111 	"cause code 52: error, unassigned in Q.850 (03/93)",
112 	"Outgoing calls barred within CUG",
113 	"cause code 54: error, unassigned in Q.850 (03/93)",
114 	"Incoming calls barred within CUG",
115 	"cause code 56: error, unassigned in Q.850 (03/93)",
116 	"Bearer capability not authorized",
117 	"Bearer capability not presently available",
118 	"cause code 59: error, unassigned in Q.850 (03/93)",
119 
120 /*60*/	"cause code 60: error, unassigned in Q.850 (03/93)",
121 	"cause code 61: error, unassigned in Q.850 (03/93)",
122 	"Inconsistenciy in designated outg. access info and subscriber class",
123 	"Service or option not available, unspecified",
124 	"cause code 64: error, unassigned in Q.850 (03/93)",
125 	"Bearer capability not implemented",
126 	"Channel type not implemented",
127 	"cause code 67: error, unassigned in Q.850 (03/93)",
128 	"cause code 68: error, unassigned in Q.850 (03/93)",
129 	"Requested facility not implemented",
130 
131 /*70*/	"Only restricted digital information bearer capability is available",
132 	"cause code 71: error, unassigned in Q.850 (03/93)",
133 	"cause code 72: error, unassigned in Q.850 (03/93)",
134 	"cause code 73: error, unassigned in Q.850 (03/93)",
135 	"cause code 74: error, unassigned in Q.850 (03/93)",
136 	"cause code 75: error, unassigned in Q.850 (03/93)",
137 	"cause code 76: error, unassigned in Q.850 (03/93)",
138 	"cause code 77: error, unassigned in Q.850 (03/93)",
139 	"cause code 78: error, unassigned in Q.850 (03/93)",
140 	"Service or option not implemented, unspecified",
141 
142 /*80*/	"cause code 80: error, unassigned in Q.850 (03/93)",
143 	"Invalid call reference value",
144 	"Identified channel does not exist",
145 	"A suspended call exists, but this call identity does not",
146 	"Call identity in use",
147 	"No call suspended",
148 	"Call having the requested call identity has been cleared",
149 	"User not member of CUG",
150 	"Incompatible destination",
151 	"cause code 89: error, unassigned in Q.850 (03/93)",
152 
153 /*90*/	"Non-existent CUG",
154 	"Invalid transit network selection",
155 	"cause code 92: error, unassigned in Q.850 (03/93)",
156 	"cause code 93: error, unassigned in Q.850 (03/93)",
157 	"cause code 94: error, unassigned in Q.850 (03/93)",
158 	"Invalid message, unspecified",
159 	"Mandatory information element is missing",
160 	"Message type non-existent or not implemented",
161 	"Message not compatible with call state or message type non-existent or not implemented",
162 	"Information element/parameter non-existent or not implemented",
163 
164 /*100*/	"Invalid information element contents",
165 	"Message not compatible with call state",
166 	"Recovery on timer expiry",
167 	"Parameter non-existent or not implemented, passed on",
168 	"cause code 104: error, unassigned in Q.850 (03/93)",
169 	"cause code 105: error, unassigned in Q.850 (03/93)",
170 	"cause code 106: error, unassigned in Q.850 (03/93)",
171 	"cause code 107: error, unassigned in Q.850 (03/93)",
172 	"cause code 108: error, unassigned in Q.850 (03/93)",
173 	"cause code 109: error, unassigned in Q.850 (03/93)",
174 
175 /*110*/	"Message with unrecognized parameter, discarded",
176 	"Protocol error, unspecified",
177 	"cause code 112: error, unassigned in Q.850 (03/93)",
178 	"cause code 113: error, unassigned in Q.850 (03/93)",
179 	"cause code 114: error, unassigned in Q.850 (03/93)",
180 	"cause code 115: error, unassigned in Q.850 (03/93)",
181 	"cause code 116: error, unassigned in Q.850 (03/93)",
182 	"cause code 117: error, unassigned in Q.850 (03/93)",
183 	"cause code 118: error, unassigned in Q.850 (03/93)",
184 	"cause code 119: error, unassigned in Q.850 (03/93)",
185 
186 /*120*/	"cause code 120: error, unassigned in Q.850 (03/93)",
187 	"cause code 121: error, unassigned in Q.850 (03/93)",
188 	"cause code 122: error, unassigned in Q.850 (03/93)",
189 	"cause code 123: error, unassigned in Q.850 (03/93)",
190 	"cause code 124: error, unassigned in Q.850 (03/93)",
191 	"cause code 125: error, unassigned in Q.850 (03/93)",
192 	"cause code 126: error, unassigned in Q.850 (03/93)",
193 	"Interworking, unspecified"
194 };
195 
196 char *
print_i4b_cause(cause_t code)197 print_i4b_cause(cause_t code)
198 {
199 	static char error_message[128];
200 
201 	snprintf(error_message, sizeof(error_message), "%d: ", GET_CAUSE_VAL(code));
202 
203 	switch (GET_CAUSE_TYPE(code))
204 	{
205 	case CAUSET_Q850:
206 		strlcat(error_message,
207 		    cause_q850_tab[GET_CAUSE_VAL(code)],
208 		    sizeof(error_message));
209 		strlcat(error_message, " (Q.850)",
210 		    sizeof(error_message));
211 		break;
212 
213 	case CAUSET_I4B:
214 		if ((GET_CAUSE_VAL(code) < CAUSE_I4B_NORMAL) ||
215 		    (GET_CAUSE_VAL(code) >= CAUSE_I4B_MAX))
216 		{
217 			SET_CAUSE_VAL(code, CAUSE_I4B_MAX);
218 		}
219 		strlcat(error_message,
220 		    cause_i4b_tab[GET_CAUSE_VAL(code)],
221 		    sizeof(error_message));
222 		strlcat(error_message, " (I4B)", sizeof(error_message));
223 		break;
224 
225 	default:
226 		strlcat(error_message, "ERROR: unknown cause type!",
227 		    sizeof(error_message));
228 		break;
229 	}
230 	return(error_message);
231 }
232 
233 /* EOF */
234