if ( !when.nets )
return true;
- if ( sfvar_ip_in(when.nets, &flow->client_ip) )
- return true;
+ switch ( when.role )
+ {
+ case BindWhen::BR_SERVER:
+ if ( sfvar_ip_in(when.nets, &flow->server_ip) )
+ return true;
+ break;
+ case BindWhen::BR_CLIENT:
+ if ( sfvar_ip_in(when.nets, &flow->client_ip) )
+ return true;
+ break;
+ case BindWhen::BR_EITHER:
+ if ( sfvar_ip_in(when.nets, &flow->client_ip) or
+ sfvar_ip_in(when.nets, &flow->server_ip) )
+ return true;
+ break;
+ default:
+ break;
+ }
- if ( sfvar_ip_in(when.nets, &flow->server_ip) )
- return true;
return false;
}
bool Binding::check_port(const Flow* flow) const
{
- return when.ports.test(flow->server_port);
+ switch ( when.role )
+ {
+ case BindWhen::BR_SERVER:
+ return when.ports.test(flow->server_port);
+ case BindWhen::BR_CLIENT:
+ return when.ports.test(flow->client_port);
+ case BindWhen::BR_EITHER:
+ return (when.ports.test(flow->client_port) or when.ports.test(flow->server_port) );
+ default:
+ break;
+ }
+ return false;
}
bool Binding::check_service(const Flow* flow) const
return SIP_PARSE_SUCCESS;
}
+static inline bool is_valid_ip(const char *start, int length)
+{
+ sfip_t ip;
+ char ipStr[INET6_ADDRSTRLEN];
+
+ /*Get the IP address*/
+ if(length > INET6_ADDRSTRLEN - 1)
+ {
+ length = INET6_ADDRSTRLEN - 1;
+ }
+ memcpy(ipStr, start, length);
+ ipStr[length] = '\0';
+
+ DebugFormat(DEBUG_SIP, "IP data: %s\n", ipStr);
+
+ if( (sfip_pton(ipStr, &ip)) != SFIP_SUCCESS)
+ {
+ DebugMessage(DEBUG_SIP, "Not valid IP! \n");
+ return false;
+ }
+
+ return true;
+}
+
/********************************************************************
* Function: sip_parse_call_id()
*
static int sip_parse_call_id(SIPMsg* msg, const char* start, const char* end, SIP_PROTO_CONF*)
{
- DEBUG_WRAP(int length = end -start; )
+ int length = end -start;
DebugFormat(DEBUG_SIP, "Call-Id value: %.*s\n", length, start);
msg->call_id = (char*)start;
+ /*ignore ip address in call id by adjusting length*/
+ char* at = (char*)memchr(start, '@', length);
+ if(at && (at < end) && is_valid_ip(at+1, (end-at-1)))
+ {
+ length = at - start;
+ }
+
msg->callIdLen = end - start;
- msg->dlgID.callIdHash = strToHash(msg->call_id, msg->callIdLen);
+ msg->dlgID.callIdHash = strToHash(msg->call_id, length);
DebugFormat(DEBUG_SIP, "Call-Id length: %d, Hash: %u\n",
msg->callIdLen, msg->dlgID.callIdHash);
return 0;
}
+// FIXIT-L sfvar_ip_in, _sfvar_ip_in4 and _sfvar_ip_in6 should all return boool
/* Returns SFIP_SUCCESS if ip is contained in 'var', SFIP_FAILURE otherwise
If either argument is NULL, SFIP_ARG_ERR is returned. */
int sfvar_ip_in(sfip_var_t* var, const sfip_t* ip)