modified: chan_lcr.c
[lcr.git] / cause.c
1 /*****************************************************************************\
2 **                                                                           **
3 ** PBX4Linux                                                                 **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** cause database                                                            **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12 #include "main.h"
13
14 struct isdn_cause isdn_cause[128] = {
15                         /********************************* - **/ /*38*/
16         { /*0*/         "<No cause>",
17                         "<Kein Grund>" },
18         { /*1*/         "Unallocated number",
19                         "Nummer nicht vergeben" },
20         { /*2*/         "No route to transit network",
21                         "Keine Verbindung zum Netz" },
22         { /*3*/         "No route to destination",
23                         "Zielnummer nicht erreichbar" },
24         { /*4*/         "<Listen to announcement...>",
25                         "<Ansage hoeren...>" },
26         { /*5*/         "Misdialed trunk prefix.",
27                         "Falscher Carrier-Code" },
28         { /*6*/         "Channel unacceptable",
29                         "Kanal nicht akzeptiert" },
30         { /*7*/         "",
31                         "" },
32         { /*8*/         "Preemption",
33                         "Vorkauf" },
34         { /*9*/         "Preemption - circuit reserved",
35                         "Vorkauf - Gasse reserviert" },
36         { /*10*/        "",
37                         "" },
38         { /*11*/        "",
39                         "" },
40         { /*12*/        "",
41                         "" },
42         { /*13*/        "",
43                         "" },
44         { /*14*/        "",
45                         "" },
46         { /*15*/        "",
47                         "" },
48         { /*16*/        "Normal call clearing",
49                         "Normaler Verbindungsabbau" },
50         { /*17*/        "User busy",
51                         "Teilnehmer besetzt" },
52         { /*18*/        "No user responding",
53                         "Teilnehmer antwortet nicht" },
54         { /*19*/        "No answer from user",
55                         "Teilnehmer nimmt nicht ab" },
56         { /*20*/        "Subscriber absent",
57                         "Teilnehmer nicht anwesend" },
58         { /*21*/        "Call rejected",
59                         "Gespraech abgewiesen" },
60         { /*22*/        "Number changed",
61                         "Rufnummer hat sich geaendert" },
62         { /*23*/        "",
63                         "" },
64         { /*24*/        "",
65                         "" },
66         { /*25*/        "",
67                         "" },
68         { /*26*/        "Non-selected user clearing",
69                         "Gespraech woanders angenommen" },
70         { /*27*/        "Destination out of order",
71                         "Gegenstelle ausser Betrieb" },
72         { /*28*/        "Invalid number (incomplete)",
73                         "Fehlerhafte Nummer (n. komplett)" },
74         { /*29*/        "Facility rejected",
75                         "Funktion nicht verfuegbar" },
76         { /*30*/        "",
77                         "" },
78         { /*31*/        "Normal, unspecified",
79                         "Normal, unspezifisch" },
80         { /*32*/        "",
81                         "" },
82         { /*33*/        "",
83                         "" },
84         { /*34*/        "No circuit/channel available",
85                         "Keine Gasse/Kanal verfuegbar" },
86         { /*35*/        "",
87                         "" },
88         { /*36*/        "",
89                         "" },
90         { /*37*/        "",
91                         "" },
92         { /*38*/        "",
93                         "" },
94         { /*39*/        "",
95                         "" },
96         { /*40*/        "",
97                         "" },
98         { /*41*/        "Temporary failure",
99                         "Vorruebergehende Fehlfunktion" },
100         { /*42*/        "Switchting equipment congestion",
101                         "Vermittlungstelle ueberlastet" },
102         { /*43*/        "Access informationen discarded",
103                         "Zugriffsinformationen geloescht" },
104         { /*44*/        "No requested circuit/channel",
105                         "Keine angeforderte Gasse/Kanal" },
106         { /*45*/        "",
107                         "" },
108         { /*46*/        "Precedence call blocked",
109                         "Vorverkaufanruf gesperrt" },
110         { /*47*/        "Resource unavailable, unspecified",
111                         "" },
112         { /*48*/        "",
113                         "" },
114         { /*49*/        "Quality of service not available",
115                         "Qualitaetsmerkmal nicht verfuegbar" },
116         { /*50*/        "Requested facility not subscribed",
117                         "Funktion nicht freigeschaltet" },
118         { /*51*/        "",
119                         "" },
120         { /*52*/        "",
121                         "" },
122         { /*53*/        "Outgoing calls barred within CUG",
123                         "CUG erlaubt keine gehenden Rufe" },
124         { /*54*/        "",
125                         "" },
126         { /*55*/        "Incoming calls barred within CUG",
127                         "CUG erlaubt keine kommenden Rufe" },
128         { /*56*/        "",
129                         "" },
130         { /*57*/        "Bearer capability not authorized",
131                         "Verbindungseigenschaft verboten" },
132         { /*58*/        "Bearer capability not present",
133                         "Verb.eigenschaft n. verfuegbar" },
134         { /*59*/        "",
135                         "" },
136         { /*60*/        "",
137                         "" },
138         { /*61*/        "",
139                         "" },
140         { /*62*/        "",
141                         "" },
142         { /*63*/        "Service or option not available",
143                         "Dienst oder Merkmal nicht verf." },
144         { /*64*/        "",
145                         "" },
146         { /*65*/        "Bearer capability not implement.",
147                         "Verb.eigenschaft nicht unterstue." },
148         { /*66*/        "Channel type not implemented",
149                         "Kanalart nicht unterstuetzt" },
150         { /*67*/        "",
151                         "" },
152         { /*68*/        "",
153                         "" },
154         { /*69*/        "Requested facility not implement.",
155                         "Funktion nicht unterstuetzt" },
156         { /*70*/        "restricted digital informat. only",
157                         "Nur eingeschraenkte digitale inf." },
158         { /*71*/        "",
159                         "" },
160         { /*72*/        "",
161                         "" },
162         { /*73*/        "",
163                         "" },
164         { /*74*/        "",
165                         "" },
166         { /*75*/        "",
167                         "" },
168         { /*76*/        "",
169                         "" },
170         { /*77*/        "",
171                         "" },
172         { /*78*/        "",
173                         "" },
174         { /*79*/        "Service or option not implemented",
175                         "Dienst oder Merkmal n. unterstue." },
176         { /*80*/        "",
177                         "" },
178         { /*81*/        "Invalid call reference value",
179                         "Falsche call reference" },
180         { /*82*/        "Identified channel does not exist",
181                         "Erkannter Kanal existiert nicht" },
182         { /*83*/        "No suspended call with this id",
183                         "Kein geparktes Gespr. f. diese ID" },
184         { /*84*/        "Call identity in use",
185                         "ID in gebrauch" },
186         { /*85*/        "No call suspended",
187                         "Kein geparktes Gespraech" },
188         { /*86*/        "Suspended call has been cleared",
189                         "Geparktes Gespraech wurde beendet" },
190         { /*87*/        "User not member of CUG",
191                         "Teilnehmer nicht in der CUG" },
192         { /*88*/        "Incompatibel destination",
193                         "Gegenstelle nicht kompatibel" },
194         { /*89*/        "",
195                         "" },
196         { /*90*/        "Non-existent CUG",
197                         "CUG existiert nicht" },
198         { /*91*/        "Invalid transit network selection",
199                         "Falscher Carrier-Code" },
200         { /*92*/        "",
201                         "" },
202         { /*93*/        "",
203                         "" },
204         { /*94*/        "",
205                         "" },
206         { /*95*/        "Invalid message, unspecified",
207                         "Fehlerhafte Daten, unbekannt" },
208         { /*96*/        "Information element missing",
209                         "Information wird vermisst" },
210         { /*97*/        "Message type non-existent",
211                         "Message exisitiert nicht" },
212         { /*98*/        "Message not compatible with state",
213                         "Message nicht komatibel" },
214         { /*99*/        "Information element not impl.",
215                         "Information nicht implementiert" },
216         { /*100*/       "Invalid info element contents",
217                         "Fehlerhafterhafte Information" },
218         { /*101*/       "Message not compatible with state",
219                         "Message not kompatibel" },
220         { /*102*/       "Recovery on timer expiry",
221                         "Fehler durch Zeitueberschreitung" },
222         { /*103*/       "Parameter non-existent",
223                         "Parameter fehlt" },
224         { /*104*/       "",
225                         "" },
226         { /*105*/       "",
227                         "" },
228         { /*106*/       "",
229                         "" },
230         { /*107*/       "",
231                         "" },
232         { /*108*/       "",
233                         "" },
234         { /*109*/       "",
235                         "" },
236         { /*110*/       "",
237                         "" },
238         { /*111*/       "Protocol error, unspecified",
239                         "Protokollfehler, unbekannt" },
240         { /*112*/       "",
241                         "" },
242         { /*113*/       "",
243                         "" },
244         { /*114*/       "",
245                         "" },
246         { /*115*/       "",
247                         "" },
248         { /*116*/       "",
249                         "" },
250         { /*117*/       "",
251                         "" },
252         { /*118*/       "",
253                         "" },
254         { /*119*/       "",
255                         "" },
256         { /*120*/       "",
257                         "" },
258         { /*121*/       "",
259                         "" },
260         { /*122*/       "",
261                         "" },
262         { /*123*/       "",
263                         "" },
264         { /*124*/       "",
265                         "" },
266         { /*125*/       "",
267                         "" },
268         { /*126*/       "",
269                         "" },
270         { /*127*/       "Interworking, unspecified",
271                         "Zusammenspiel, unbekannt" },
272 };
273
274 struct isdn_cause isdn_cause_class[8] = {
275                         /********************************* - **/ /*38*/
276         { /*0*/         "(Normal class)",
277                         "(Normale Fehlerklasse)" },
278         { /*16*/        "(Normal class)",
279                         "(Normale Fehlerklasse)" },
280         { /*32*/        "(Resource unavailable class)",
281                         "(Ressourcen nicht verfuegbar)" },
282         { /*48*/        "(Service or option unavailable)",
283                         "(Dienst oder Merkmal n. verfueg.)" },
284         { /*64*/        "(Service or option n.implemented)",
285                         "(Dienst oder Merkmal n. vorhand.)" },
286         { /*80*/        "(Invalid message class)",
287                         "(Fehlerhafte Message)" },
288         { /*96*/        "(Protocol error class)",
289                         "(Klasse der Protokollfehler)" },
290         { /*112*/       "(Interworking class)",
291                         "(Klasse des Zusammenspiels)" },
292 };
293
294 struct isdn_location isdn_location[16] = {
295         { /*0*/         "User",
296                         "Endgerät" },
297         { /*1*/         "Private (Local)",
298                         "Anlage (Lokal)" },
299         { /*2*/         "Public (Local)",
300                         "Vermittlung (Lokal)" },
301         { /*3*/         "Transit",
302                         "Knotenvermittlung" },
303         { /*4*/         "Public (Remote)",
304                         "Vermittlung (Gegenstelle)" },
305         { /*5*/         "Private (Remote)",
306                         "Anlage (Gegenstelle)" },
307         { /*6*/         "",
308                         "" },
309         { /*7*/         "International",
310                         "Fernvermittlung" },
311         { /*8*/         "",
312                         "" },
313         { /*9*/         "",
314                         "" },
315         { /*10*/        "Beyond Interworking",
316                         "Nicht verfuegbar" },
317         { /*11*/        "",
318                         "" },
319         { /*12*/        "",
320                         "" },
321         { /*13*/        "",
322                         "" },
323         { /*14*/        "",
324                         "" },
325         { /*15*/        "",
326                         "" },
327 };
328
329 char *get_isdn_cause(int cause, int location, int type)
330 {
331         static char result[128];
332
333         /* protect us */
334         if (cause<0 || cause>127)
335                 cause = 0;
336
337         switch(type)
338         {
339                 case DISPLAY_CAUSE_NUMBER:
340                 SPRINT(result, "Cause %d", cause);
341                 break;
342
343                 case DISPLAY_CAUSE_ENGLISH:
344                 if (isdn_cause[cause].english[0])
345                         SPRINT(result, "%d - %s", cause, isdn_cause[cause].english);
346                 else    SPRINT(result, "%d - %s", cause, isdn_cause_class[cause>>4].english);
347                 break;
348
349                 case DISPLAY_CAUSE_GERMAN:
350                 if (isdn_cause[cause].german[0])
351                         SPRINT(result, "%d - %s", cause, isdn_cause[cause].german);
352                 else    SPRINT(result, "%d - %s", cause, isdn_cause_class[cause>>4].german);
353                 break;
354
355                 case DISPLAY_LOCATION_ENGLISH:
356                 if (isdn_location[location].english[0])
357                         SPRINT(result, "%d - %s", cause, isdn_location[location].english);
358                 else    SPRINT(result, "%d - Location code %d", cause, location);
359                 break;
360
361                 case DISPLAY_LOCATION_GERMAN:
362                 if (isdn_location[location].german[0])
363                         SPRINT(result, "%d - %s", cause, isdn_location[location].german);
364                 else    SPRINT(result, "%d - Lokationscode %d", cause, location);
365                 break;
366
367                 default:
368                 result[0] = '\0';
369         }
370
371         return(result);
372 }
373
374 /*
375  * collect cause for multipoint
376  * used by Process, Endpoint and Join instance when multiplexing
377  */
378 void collect_cause(int *multicause, int *multilocation, int newcause, int newlocation)
379 {
380         if (newcause == CAUSE_REJECTED) /* call rejected */
381         {
382                 *multicause = newcause;
383                 *multilocation = newlocation;
384         } else
385         if (newcause==CAUSE_NORMAL && *multicause!=CAUSE_REJECTED) /* reject via hangup */
386         {
387                 *multicause = newcause;
388                 *multilocation = newlocation;
389         } else
390         if (newcause==CAUSE_BUSY && *multicause!=CAUSE_REJECTED && *multicause!=CAUSE_NORMAL) /* busy */
391         {
392                 *multicause = newcause;
393                 *multilocation = newlocation;
394         } else
395         if (newcause==CAUSE_OUTOFORDER && *multicause!=CAUSE_BUSY && *multicause!=CAUSE_REJECTED && *multicause!=CAUSE_NORMAL) /* no L1 */
396         {
397                 *multicause = newcause;
398                 *multilocation = newlocation;
399         } else
400         if (newcause!=CAUSE_NOUSER && *multicause!=CAUSE_OUTOFORDER && *multicause!=CAUSE_BUSY && *multicause!=CAUSE_REJECTED && *multicause!=CAUSE_NORMAL) /* anything but not 18 */
401         {
402                 *multicause = newcause;
403                 *multilocation = newlocation;
404         } else
405         if (newcause==CAUSE_NOUSER && *multicause==CAUSE_NOUSER) /* cause 18, use the location */
406         {
407                 *multilocation = newlocation;
408         } else
409         if (*multicause==0) /* no cause yet, use newcause (should be 18) */
410         {
411                 *multicause = newcause;
412                 *multilocation = newlocation;
413         }
414 }
415