modified: chan_lcr.c
[lcr.git] / cause.c
diff --git a/cause.c b/cause.c
index c6ca903..46b870b 100644 (file)
--- a/cause.c
+++ b/cause.c
@@ -9,9 +9,6 @@
 **                                                                           **
 \*****************************************************************************/ 
 
-#include "stdio.h"
-#include "sys/types.h"
-#include "string.h"
 #include "main.h"
 
 struct isdn_cause isdn_cause[128] = {
@@ -373,3 +370,46 @@ char *get_isdn_cause(int cause, int location, int type)
 
        return(result);
 }
+
+/*
+ * collect cause for multipoint
+ * used by Process, Endpoint and Join instance when multiplexing
+ */
+void collect_cause(int *multicause, int *multilocation, int newcause, int newlocation)
+{
+       if (newcause == CAUSE_REJECTED) /* call rejected */
+       {
+               *multicause = newcause;
+               *multilocation = newlocation;
+       } else
+       if (newcause==CAUSE_NORMAL && *multicause!=CAUSE_REJECTED) /* reject via hangup */
+       {
+               *multicause = newcause;
+               *multilocation = newlocation;
+       } else
+       if (newcause==CAUSE_BUSY && *multicause!=CAUSE_REJECTED && *multicause!=CAUSE_NORMAL) /* busy */
+       {
+               *multicause = newcause;
+               *multilocation = newlocation;
+       } else
+       if (newcause==CAUSE_OUTOFORDER && *multicause!=CAUSE_BUSY && *multicause!=CAUSE_REJECTED && *multicause!=CAUSE_NORMAL) /* no L1 */
+       {
+               *multicause = newcause;
+               *multilocation = newlocation;
+       } else
+       if (newcause!=CAUSE_NOUSER && *multicause!=CAUSE_OUTOFORDER && *multicause!=CAUSE_BUSY && *multicause!=CAUSE_REJECTED && *multicause!=CAUSE_NORMAL) /* anything but not 18 */
+       {
+               *multicause = newcause;
+               *multilocation = newlocation;
+       } else
+       if (newcause==CAUSE_NOUSER && *multicause==CAUSE_NOUSER) /* cause 18, use the location */
+       {
+               *multilocation = newlocation;
+       } else
+       if (*multicause==0) /* no cause yet, use newcause (should be 18) */
+       {
+               *multicause = newcause;
+               *multilocation = newlocation;
+       }
+}
+