struct action_defs action_defs[] = {
{ ACTION_EXTERNAL,
"extern", &EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_external, &EndpointAppPBX::action_hangup_call,
- PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_KEYPAD | PARAM_TIMEOUT,
+ PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_KEYPAD | PARAM_CONTEXT | PARAM_TIMEOUT,
"Call is routed to extern number as dialed."},
{ ACTION_INTERNAL,
"intern", &EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_internal, &EndpointAppPBX::action_hangup_call,
"outdial", &EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_external, &EndpointAppPBX::action_hangup_call,
PARAM_CONNECT | PARAM_PREFIX | PARAM_COMPLETE | PARAM_TYPE | PARAM_CAPA | PARAM_BMODE | PARAM_INFO1 | PARAM_HLC | PARAM_EXTHLC | PARAM_PRESENT | PARAM_INTERFACES | PARAM_CALLERID | PARAM_CALLERIDTYPE | PARAM_KEYPAD | PARAM_TIMEOUT,
"Same as 'extern'"},
- { ACTION_REMOTE,
- "remote", &EndpointAppPBX::action_init_remote, &EndpointAppPBX::action_dialing_remote, &EndpointAppPBX::action_hangup_call,
- PARAM_CONNECT | PARAM_APPLICATION | PARAM_CONTEXT | PARAM_EXTEN | PARAM_TIMEOUT,
- "Call is routed to Remote application, like Asterisk."},
{ ACTION_VBOX_RECORD,
"vbox-record",&EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_vbox_record, &EndpointAppPBX::action_hangup_call,
PARAM_CONNECT | PARAM_EXTENSION | PARAM_ANNOUNCEMENT | PARAM_TIMEOUT,
istrue,
couldbetrue,
condition,
- dialing_required,
- avail,
- any;
+ dialing_required;
struct route_rule *rule = ruleset->rule_first;
struct route_cond *cond;
struct route_action *action = NULL;
unsigned long comp_len;
- int j, jj;
+ int j;
char isdn_port[10];
char *argv[11]; /* check also number of args below */
char callerid[64], callerid2[64], redirid[64];
FILE *tfp;
long long timeout, now_ll = 0, match_timeout = 0;
struct timeval current_time;
+#ifdef WITH_MISDN
struct mISDNport *mISDNport;
+ int avail,
+ any;
+ int jj;
+#endif
struct admin_list *admin;
time_t now;
struct tm *now_tm;
- int pid2;
+ int pid, status;
/* reset timeout action */
e_match_to_action = NULL;
break;
case MATCH_PORT:
+#ifdef WITH_MISDN
if (ea_endpoint->ep_portlist)
if ((ea_endpoint->ep_portlist->port_type & PORT_CLASS_MASK) != PORT_CLASS_mISDN)
break;
integer = e_callerinfo.isdn_port;
goto match_integer;
+#endif
+ break;
case MATCH_INTERFACE:
if (!e_callerinfo.interface[0])
argv[j++] = isdn_port;
argv[j++] = e_callerinfo.imsi;
argv[j++] = NULL; /* check also number of args above */
- if (fork() == 0) {
- if ((pid2 = fork()) == 0) {
- execve(cond->string_value, argv, environ);
- }
+ switch ((pid = fork())) {
+ case 0:
+ execve(cond->string_value, argv, environ);
+ perror("execve");
+ exit(1);
+ case -1:
+ break;
+ default:
+ waitpid(pid, &status, 0);
+ if (0 == WEXITSTATUS(status))
+ istrue = 1;
}
break;
case MATCH_FREE:
case MATCH_NOTFREE:
+#ifdef WITH_MISDN
if (!(comp_len = (unsigned long)strchr(cond->string_value, ':')))
break;
comp_len = comp_len-(unsigned long)cond->string_value;
if (avail < atoi(cond->string_value + comp_len + 1))
istrue = 1;
}
+#endif
break;
case MATCH_DOWN:
+#ifdef WITH_MISDN
mISDNport = mISDNport_first;
while(mISDNport) {
if (mISDNport->ifport)
}
if (!mISDNport) /* all down */
istrue = 1;
+#endif
break;
case MATCH_UP:
+#ifdef WITH_MISDN
mISDNport = mISDNport_first;
while(mISDNport) {
if (mISDNport->ifport)
}
if (mISDNport) /* one link at least */
istrue = 1;
+#endif
break;
case MATCH_BUSY:
case MATCH_IDLE:
+#ifdef WITH_MISDN
any = 0;
mISDNport = mISDNport_first;
while(mISDNport) {
istrue = 1;
if (!mISDNport && cond->match==MATCH_IDLE)
istrue = 1;
+#endif
break;
case MATCH_REMOTE:
cond = cond->next;
}
- if (timeout>now_ll && match==1) /* the matching rule with timeout in the future */
- if (match_timeout == 0 || timeout < match_timeout) { /* first timeout or lower */
- /* set timeout in the furture */
- match_timeout = timeout;
- e_match_to_action = rule->action_first;
- e_match_to_extdialing = e_dialinginfo.id + dialing_required;
+ if (timeout>now_ll && match==1) { /* the matching rule with timeout in the future */
+ if (match_timeout == 0 || timeout < match_timeout) { /* first timeout or lower */
+ /* set timeout in the furture */
+ match_timeout = timeout;
+ e_match_to_action = rule->action_first;
+ e_match_to_extdialing = e_dialinginfo.id + dialing_required;
+ }
match = 0; /* matches in the future */
}
if (match == 1) {
if (match_timeout == 0)
unsched_timer(&e_match_timeout); /* no timeout */
else {
- schedule_timer(&e_match_timeout, match_timeout / 1000000, match_timeout % 1000000);
+ schedule_timer(&e_match_timeout, (match_timeout-now_ll) / 1000000, (match_timeout-now_ll) % 1000000);
}
return(action);
}
0,
};
-struct route_action action_remote = {
- NULL,
- NULL,
- ACTION_REMOTE,
- 0,
- 0,
-};
-
struct route_action action_vbox = {
NULL,
NULL,