This commit is contained in:
Thomas Ries 2015-09-19 22:32:55 +00:00
parent 5eab79fb7c
commit cdccee4266
3 changed files with 17 additions and 8 deletions

View File

@ -118,7 +118,7 @@ int PLUGIN_INIT(plugin_def_t *plugin_def) {
/* Execution mask - during what stages of SIP processing shall
* the plugin be called. */
plugin_def->exe_mask=PLUGIN_PRE_PROXY;
plugin_def->exe_mask=PLUGIN_DETERMINE_TARGET; //PLUGIN_PRE_PROXY;
/* read the config file */
if (read_config(configuration.configfile,
@ -204,6 +204,9 @@ static int plugin_siptrunk_process(sip_ticket_t *ticket) {
/* plugin loaded and not configured, return with success */
if (plugin_cfg.trunk_numbers_regex.used==0) return STS_SUCCESS;
if (ticket->direction == DIRTYP_UNKNOWN) {
sip_find_direction(ticket, NULL);
}
DEBUGC(DBCLASS_PLUGIN, "plugin_siptrunk: type=%i", ticket->direction);
DEBUGC(DBCLASS_PLUGIN, "plugin_siptrunk: next hop was %s:%i",
@ -211,10 +214,11 @@ static int plugin_siptrunk_process(sip_ticket_t *ticket) {
ticket->next_hop.sin_port);
/* SIP request? && direction undetermined? */
if (MSG_IS_REQUEST(ticket->sipmsg)) {
// if ((ticket->direction == DIRTYP_UNKNOWN)
// && MSG_IS_REQUEST(ticket->sipmsg)) {
if ((ticket->direction == DIRTYP_UNKNOWN)
&& MSG_IS_REQUEST(ticket->sipmsg)) {
DEBUGC(DBCLASS_PLUGIN, "plugin_siptrunk: processing REQ w/ DIRTYP_UNKNOWN");
DEBUGC(DBCLASS_PLUGIN, "&&&1: req_uri [%s]", ticket->sipmsg->req_uri->username);
DEBUGC(DBCLASS_PLUGIN, "&&&1: to_url [%s]", ticket->sipmsg->to->url->username);
/* get REQ URI & To URI from headers */
req_url=osip_message_get_uri(ticket->sipmsg);
@ -223,7 +227,8 @@ static int plugin_siptrunk_process(sip_ticket_t *ticket) {
}
/* check To: URI */
to_url=osip_to_get_url(ticket->sipmsg);
//&&&broken: to_url=osip_to_get_url(ticket->sipmsg);
to_url=ticket->sipmsg->to->url;
if (to_url && to_url->username) {
DEBUGC(DBCLASS_BABBLE, "To: header: [%s]", to_url->username);
}

View File

@ -114,11 +114,11 @@ int proxy_request (sip_ticket_t *ticket) {
* by doing a lookup in the registration table.
*/
sip_find_direction(ticket, &i);
type = ticket->direction;
/* Call Plugins for stage: PLUGIN_PRE_PROXY */
sts = call_plugins(PLUGIN_PRE_PROXY, ticket);
type = ticket->direction;
/*
* RFC 3261, Section 16.6 step 1
* Proxy Behavior - Request Forwarding - Make a copy
@ -140,7 +140,10 @@ int proxy_request (sip_ticket_t *ticket) {
* (rewrite request URI to point to the real host)
*/
/* 'i' still holds the valid index into the URLMAP table */
proxy_rewrite_request_uri(request, i);
DEBUGC(DBCLASS_PROXY,"index i=%i",i);
if ((i>=0) && (i < URLMAP_SIZE)) {
proxy_rewrite_request_uri(request, i);
}
/* if this is CANCEL/BYE request, stop RTP proxying */
if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) {
@ -495,11 +498,11 @@ int proxy_response (sip_ticket_t *ticket) {
* world to one of our registered clients
*/
sip_find_direction(ticket, NULL);
type = ticket->direction;
/* Call Plugins for stage: PLUGIN_PRE_PROXY */
sts = call_plugins(PLUGIN_PRE_PROXY, ticket);
type = ticket->direction;
/*
* RFC 3261, Section 16.7 step 3
* Proxy Behavior - Response Processing - Remove my Via header field value

View File

@ -1192,6 +1192,7 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
if (type == DIRTYP_UNKNOWN) {
DEBUGC(DBCLASS_SIP, "sip_find_direction: unable to determine "
"direction of SIP packet");
if (urlidx) *urlidx=-1;
return STS_FAILURE;
}