|
@@ -112,6 +112,11 @@ int checkcontact(struct sip_msg* _m, pcontact_t * c) {
|
|
|
str received_host = {0, 0};
|
|
|
char srcip[50];
|
|
|
|
|
|
+ LM_DBG("Port %d (search %d), Proto %d (search %d), reg_state %s (search %s)\n",
|
|
|
+ c->received_port, _m->rcv.src_port, c->received_proto, _m->rcv.proto,
|
|
|
+ reg_state_to_string(c->reg_state), reg_state_to_string(PCONTACT_REGISTERED)
|
|
|
+ );
|
|
|
+
|
|
|
if (c->security) {
|
|
|
switch (c->security->type) {
|
|
|
case SECURITY_IPSEC:
|
|
@@ -164,7 +169,6 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
|
|
|
str received_host = {0, 0};
|
|
|
char srcip[50];
|
|
|
|
|
|
-
|
|
|
if (_m->id != current_msg_id) {
|
|
|
current_msg_id = _m->id;
|
|
|
c = NULL;
|
|
@@ -172,10 +176,17 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
|
|
|
if (is_registered_fallback2ip == 2) {
|
|
|
received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
|
|
|
received_host.s = srcip;
|
|
|
- if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1)
|
|
|
+
|
|
|
+ LM_DBG("Searching in usrloc for %.*s:%i (Proto %i)\n",
|
|
|
+ received_host.len, received_host.s,
|
|
|
+ _m->rcv.src_port, _m->rcv.proto);
|
|
|
+
|
|
|
+ if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1) {
|
|
|
LM_DBG("No entry in usrloc for %.*s:%i (Proto %i) found!\n", received_host.len, received_host.s, _m->rcv.src_port, _m->rcv.proto);
|
|
|
- if (checkcontact(_m, c) != 0) {
|
|
|
- c = NULL;
|
|
|
+ } else {
|
|
|
+ if (checkcontact(_m, c) != 0) {
|
|
|
+ c = NULL;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -185,10 +196,10 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
|
|
|
if (b && b->contacts) {
|
|
|
for (ct = b->contacts; ct; ct = ct->next) {
|
|
|
if (ul.get_pcontact(_d, &ct->uri, &c) == 0) {
|
|
|
- if (checkcontact(_m, c) == 0) {
|
|
|
- break;
|
|
|
- } else {
|
|
|
+ if (checkcontact(_m, c) != 0) {
|
|
|
c = NULL;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -201,10 +212,12 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
|
|
|
LM_INFO("Contact not found based on Contact-header, trying IP/Port/Proto\n");
|
|
|
received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
|
|
|
received_host.s = srcip;
|
|
|
- if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1)
|
|
|
+ if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1) {
|
|
|
LM_DBG("No entry in usrloc for %.*s:%i (Proto %i) found!\n", received_host.len, received_host.s, _m->rcv.src_port, _m->rcv.proto);
|
|
|
- if (checkcontact(_m, c) != 0) {
|
|
|
- c = NULL;
|
|
|
+ } else {
|
|
|
+ if (checkcontact(_m, c) != 0) {
|
|
|
+ c = NULL;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -308,7 +321,7 @@ int check_service_routes(struct sip_msg* _m, udomain_t* _d) {
|
|
|
|
|
|
/* No more Route-Headers? Not following service-routes */
|
|
|
if (!r) {
|
|
|
- LM_ERR("No more route headers in message.\n");
|
|
|
+ LM_DBG("No more route headers in message.\n");
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
@@ -330,7 +343,7 @@ int check_service_routes(struct sip_msg* _m, udomain_t* _d) {
|
|
|
|
|
|
/* Check, if it was the last route-header in the message: */
|
|
|
if (r) {
|
|
|
- LM_ERR("Too many route headers in message.\n");
|
|
|
+ LM_DBG("Too many route headers in message.\n");
|
|
|
goto error;
|
|
|
}
|
|
|
} else {
|
|
@@ -338,7 +351,7 @@ int check_service_routes(struct sip_msg* _m, udomain_t* _d) {
|
|
|
if (c->num_service_routes > 0) goto error;
|
|
|
}
|
|
|
} else {
|
|
|
- LM_ERR("No route header in Message.\n");
|
|
|
+ LM_DBG("No route header in Message.\n");
|
|
|
/* No route-header? Check, if service-routes are indicated.
|
|
|
If yes, request is not following service-routes */
|
|
|
if (c->num_service_routes > 0) goto error;
|
|
@@ -352,12 +365,10 @@ error:
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-static str route_start={": <",8};
|
|
|
+static str route_start={"Route: <",8};
|
|
|
static str route_sep={">, <",4};
|
|
|
static str route_end={">\r\n",3};
|
|
|
|
|
|
-extern str route_header;
|
|
|
-
|
|
|
/**
|
|
|
* Force Service routes (upon request)
|
|
|
*/
|
|
@@ -408,7 +419,7 @@ int force_service_routes(struct sip_msg* _m, udomain_t* _d) {
|
|
|
goto error;
|
|
|
}
|
|
|
/* Calculate the length: */
|
|
|
- new_route_header.len = route_header.len + route_start.len +
|
|
|
+ new_route_header.len = route_start.len +
|
|
|
route_end.len + (c->num_service_routes-1) * route_sep.len;
|
|
|
|
|
|
for(i=0; i< c->num_service_routes; i++)
|
|
@@ -422,7 +433,6 @@ int force_service_routes(struct sip_msg* _m, udomain_t* _d) {
|
|
|
|
|
|
/* Construct new header */
|
|
|
new_route_header.len = 0;
|
|
|
- STR_APPEND(new_route_header, route_header);
|
|
|
STR_APPEND(new_route_header, route_start);
|
|
|
for(i=0; i < c->num_service_routes; i++) {
|
|
|
if (i) STR_APPEND(new_route_header, route_sep);
|