X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=route.c;h=743e37de5ce9921f3dbe8644becf17b53c4a2367;hp=f0c7c8a113024b09be575388190bcaf115f761de;hb=89d3a5de4769faafa46efb83e1e35db5b40f1309;hpb=ef3fc1931a2fa82f482d21fb1296735206463d3a diff --git a/route.c b/route.c index f0c7c8a..743e37d 100644 --- a/route.c +++ b/route.c @@ -9,10 +9,6 @@ ** ** \*****************************************************************************/ -#include -#include -#include -#include #include "main.h" @@ -92,10 +88,10 @@ struct cond_defs cond_defs[] = { "busy=[,...]","Matches if any of the given extension is busy."}, { "notbusy", MATCH_IDLE, COND_TYPE_STRING, "notbusy=[,...]","Matches if any of the given extension is not busy."}, - { "asterisk", MATCH_ASTERISK, COND_TYPE_NULL, - "asterisk","Matches if asterisk is not running with LCR channel driver."}, - { "notasterisk",MATCH_NOTASTERISK,COND_TYPE_NULL, - "notasterisk","Matches if asterisk is not running with LCR channel driver."}, + { "remote", MATCH_REMOTE, COND_TYPE_STRING, + "remote=","Matches if remote application is running."}, + { "notremote", MATCH_NOTREMOTE,COND_TYPE_STRING, + "notremote=","Matches if remote application is not running."}, { NULL, 0, 0, NULL} }; @@ -123,7 +119,7 @@ struct param_defs param_defs[] = { "capability=speech|audio|video|digital-restricted|digital-unrestricted|digital-unrestricted-tones", "Alter the service type of the call."}, { PARAM_BMODE, "bmode", PARAM_TYPE_BMODE, - "capability=transparent|hdlc", "Alter the bchannel mode of the call. Use hdlc for data calls."}, + "bmode=transparent|hdlc", "Alter the bchannel mode of the call. Use hdlc for data calls."}, { PARAM_INFO1, "infolayer1", PARAM_TYPE_INTEGER, "infolayer1=", "Alter the layer 1 information of a call. Use 3 for ALAW or 2 for uLAW."}, @@ -220,6 +216,9 @@ struct param_defs param_defs[] = { { PARAM_ROOM, "room", PARAM_TYPE_INTEGER, "room=", "Conference room number, must be greater 0, as in real life."}, + { PARAM_JINGLE, + "jingle", PARAM_TYPE_NULL, + "jingle", "Conference members will hear a jingle if a member joins."}, { PARAM_TIMEOUT, "timeout", PARAM_TYPE_INTEGER, "timeout=", "Timeout before continue with next action."}, @@ -229,6 +228,15 @@ struct param_defs param_defs[] = { { PARAM_STRIP, "strip", PARAM_TYPE_NULL, "strip", "Remove digits that were required to match this rule."}, + { PARAM_APPLICATION, + "application",PARAM_TYPE_STRING, + "application=", "Name of remote application to make call to."}, + { PARAM_CONTEXT, + "context", PARAM_TYPE_STRING, + "context=", "Give context parameter to the remote application."}, + { PARAM_EXTEN, + "exten", PARAM_TYPE_STRING, + "exten=", "Give exten parameter to the remote application. (overrides dialed number)"}, { 0, NULL, 0, NULL, NULL} }; @@ -245,17 +253,17 @@ struct action_defs action_defs[] = { "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_TIMEOUT, "Same as 'extern'"}, - { ACTION_CHAN, - "asterisk", &EndpointAppPBX::action_init_chan, &EndpointAppPBX::action_dialing_chan, &EndpointAppPBX::action_hangup_call, - PARAM_CONNECT | PARAM_TIMEOUT, - "Call is routed to Asterisk via channel driver."}, + { 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, "Caller is routed to the voice box of given extension."}, { ACTION_PARTYLINE, "partyline",&EndpointAppPBX::action_init_partyline, NULL, &EndpointAppPBX::action_hangup_call, - PARAM_ROOM, + PARAM_ROOM | PARAM_JINGLE, "Caller is participating the conference with the given room number."}, { ACTION_LOGIN, "login", NULL, &EndpointAppPBX::action_dialing_login, NULL, @@ -280,7 +288,7 @@ struct action_defs action_defs[] = { { ACTION_REPLY, "reply", &EndpointAppPBX::action_init_redial_reply, &EndpointAppPBX::action_dialing_reply, NULL, PARAM_CONNECT | PARAM_SELECT, - "Caller replies. (last incomming call(s))"}, + "Caller replies. (last incoming call(s))"}, { ACTION_POWERDIAL, "powerdial", NULL, &EndpointAppPBX::action_dialing_powerdial, NULL, PARAM_CONNECT | PARAM_DELAY | PARAM_LIMIT | PARAM_TIMEOUT, @@ -326,11 +334,6 @@ struct action_defs action_defs[] = { "disconnect", NULL, &EndpointAppPBX::action_dialing_disconnect, NULL, PARAM_CONNECT | PARAM_CAUSE | PARAM_LOCATION | PARAM_SAMPLE | PARAM_DISPLAY, "Caller gets disconnected optionally with given cause and given sample and given display text."}, - { ACTION_HELP, - "help", NULL, &EndpointAppPBX::action_dialing_help, NULL, - PARAM_CONNECT | PARAM_TIMEOUT, - NULL}, -// "Caller will be able to select from current rules that would match. (using * and #)"}, { ACTION_DEFLECT, "deflect", NULL, &EndpointAppPBX::action_dialing_deflect, NULL, PARAM_DEST, @@ -845,6 +848,7 @@ struct route_ruleset *ruleset_parse(void) struct route_param *param; struct route_param **param_pointer = NULL; char failure[256]; + unsigned long long allowed_params; /* check the integrity of IDs for ACTION_* and PARAM_* */ i = 0; @@ -970,7 +974,7 @@ struct route_ruleset *ruleset_parse(void) /* reading ruleset name text */ i = 0; - while((*p>='a' && *p<='z') || (*p>='A' && *p<='Z') || (*p>='0' && *p<='9')) + while(*p>' ' && *p<127 && *p!=']') { if (*p>='A' && *p<='Z') *p = *p-'A'+'a'; /* lower case */ key[i++] = *p++; @@ -1458,6 +1462,7 @@ struct route_ruleset *ruleset_parse(void) SPRINT(failure, "Unknown action name '%s'.", key); goto parse_error; } + allowed_params = action_defs[index].params; /* alloc memory for action */ action = (struct route_action *)MALLOC(sizeof(struct route_action)); @@ -1507,6 +1512,13 @@ struct route_ruleset *ruleset_parse(void) goto parse_error; } + /* check if item is allowed for the action */ + if (!(param_defs[index].id & allowed_params)) + { + SPRINT(failure, "Param name '%s' exists, but not for this action.", key); + goto parse_error; + } + /* params without values must not have any parameter */ if (param_defs[index].type == PARAM_TYPE_NULL) { @@ -1942,7 +1954,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) struct route_rule *rule = ruleset->rule_first; struct route_cond *cond; struct route_action *action = NULL; - unsigned long comp_len; + unsigned int comp_len; int j, jj; char callerid[64], redirid[64]; int integer; @@ -1956,8 +1968,8 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) e_match_timeout = 0; /* no timeout */ e_match_to_action = NULL; - SCPY(callerid, numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype)); - SCPY(redirid, numberrize_callerinfo(e_redirinfo.id, e_redirinfo.ntype)); + SCPY(callerid, numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype, options.national, options.international)); + SCPY(redirid, numberrize_callerinfo(e_redirinfo.id, e_redirinfo.ntype, options.national, options.international)); PDEBUG(DEBUG_ROUTE, "parsing ruleset '%s'\n", ruleset->name); while(rule) @@ -2125,9 +2137,9 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) case MATCH_FREE: case MATCH_NOTFREE: - if (!(comp_len = (unsigned long)strchr(cond->string_value, ':'))) + if (!(comp_len = (unsigned int)strchr(cond->string_value, ':'))) break; - comp_len = comp_len-(unsigned long)cond->string_value; + comp_len = comp_len-(unsigned int)cond->string_value; avail = 0; mISDNport = mISDNport_first; while(mISDNport) @@ -2135,7 +2147,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) if (mISDNport->ifport) if (strlen(mISDNport->ifport->interface->name) == comp_len) if (!strncasecmp(mISDNport->ifport->interface->name, cond->string_value, comp_len)) - if (!mISDNport->ptp || mISDNport->l2link) + if (!mISDNport->l2hold || mISDNport->l2link) { j = 0; jj = mISDNport->b_num; @@ -2167,7 +2179,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) { if (mISDNport->ifport) if (!strcasecmp(mISDNport->ifport->interface->name, cond->string_value)) - if (!mISDNport->ptp || mISDNport->l2link) /* break if one is up */ + if (!mISDNport->l2hold || mISDNport->l2link) break; mISDNport = mISDNport->next; } @@ -2181,7 +2193,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) { if (mISDNport->ifport) if (!strcasecmp(mISDNport->ifport->interface->name, cond->string_value)) - if (!mISDNport->ptp || mISDNport->l2link) /* break if one is up */ + if (!mISDNport->l2hold || mISDNport->l2link) break; mISDNport = mISDNport->next; @@ -2208,18 +2220,18 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) istrue = 1; break; - case MATCH_ASTERISK: - case MATCH_NOTASTERISK: - admin = admin_list; + case MATCH_REMOTE: + case MATCH_NOTREMOTE: + admin = admin_first; while(admin) { - if (admin->asterisk) + if (admin->remote_name[0] && !strcmp(cond->string_value, admin->remote_name)) break; admin = admin->next; } - if (admin && cond->match==MATCH_ASTERISK) + if (admin && cond->match==MATCH_REMOTE) istrue = 1; - if (!admin && cond->match==MATCH_NOTASTERISK) + if (!admin && cond->match==MATCH_NOTREMOTE) istrue = 1; break; @@ -2258,7 +2270,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) match_string_prefix: comp_len = strlen(cond->string_value); /* because we must reach value's length */ /* we must have greater or equal length to values */ - if ((unsigned long)strlen(string) < comp_len) + if ((unsigned int)strlen(string) < comp_len) { /* special case for unfinished dialing */ if (cond->match == MATCH_DIALING) @@ -2425,10 +2437,10 @@ struct route_action action_internal = { 0, }; -struct route_action action_chan = { +struct route_action action_remote = { NULL, NULL, - ACTION_CHAN, + ACTION_REMOTE, 0, 0, };