Skip to content

Commit

Permalink
Add support for SIP URIs without user part in 'avpops' module.
Browse files Browse the repository at this point in the history
This module provides a set of avp_db_xxx functions which take pseudo
var and flag as first argument. Flag can be one of username, domain,
uri or uuid. Previosly avp_db_xxx functions used to return an error if
flag has been set to username, domain or uri and specifed pseudo var
did not contain username and host after parsing as SIP URI. This
behaviour seems to be strange because if flag is being set to
domain/username and sip URI contains domain/username we can still
load/store/delete this variable.

(cherry picked from commit 459f2e9)
  • Loading branch information
andrey-vorobiev authored and razvancrainea committed Jun 16, 2016
1 parent 04945d2 commit 20aea65
Showing 1 changed file with 70 additions and 22 deletions.
92 changes: 70 additions & 22 deletions modules/avpops/avpops_impl.c
Expand Up @@ -325,16 +325,32 @@ int ops_dbload_avps (struct sip_msg* msg, struct fis_param *sp,
goto error;
}

/* check uri */
if(!uri.user.s|| !uri.user.len|| !uri.host.len|| !uri.host.s)
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_USER0))
{
/* check that uri contains user part */
if(!uri.user.s|| !uri.user.len)
{
LM_ERR("incomplet uri <%.*s> missing user\n", uuid.len, uuid.s);
goto error;
}
else
{
s1 = &uri.user;
}
}
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_DOMAIN0))
{
LM_ERR("incomplet uri <%.*s>\n", uuid.len, uuid.s);
goto error;
/* check that uri contains host part */
if(!uri.host.len|| !uri.host.s)
{
LM_ERR("incomplet uri <%.*s> missing host\n", uuid.len, uuid.s);
goto error;
}
else
{
s2 = &uri.host;
}
}
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_USER0))
s1 = &uri.user;
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_DOMAIN0))
s2 = &uri.host;
}

/* is dynamic avp name ? */
Expand Down Expand Up @@ -487,16 +503,32 @@ int ops_dbdelete_avps (struct sip_msg* msg, struct fis_param *sp,
goto error;
}

/* check uri */
if(!uri.user.s|| !uri.user.len|| !uri.host.len|| !uri.host.s)
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_USER0))
{
LM_ERR("incomplet uri <%.*s>\n", uuid.len, uuid.s);
goto error;
/* check that uri contains user part */
if(!uri.user.s|| !uri.user.len)
{
LM_ERR("incomplet uri <%.*s> missing user\n", uuid.len, uuid.s);
goto error;
}
else
{
s1 = &uri.user;
}
}
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_USER0))
s1 = &uri.user;
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_DOMAIN0))
s2 = &uri.host;
{
/* check tah uri contains host part */
if(!uri.host.len|| !uri.host.s)
{
LM_ERR("incomplet uri <%.*s> missing host\n", uuid.len, uuid.s);
goto error;
}
else
{
s2 = &uri.host;
}
}
}

/* is dynamic avp name ? */
Expand Down Expand Up @@ -606,16 +638,32 @@ int ops_dbstore_avps (struct sip_msg* msg, struct fis_param *sp,
goto error;
}

/* check uri */
if(!uri.user.s|| !uri.user.len|| !uri.host.len|| !uri.host.s)
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_USER0))
{
LM_ERR("incomplet uri <%.*s>\n", uuid.len, uuid.s);
goto error;
/* check tha uri contains user part */
if(!uri.user.s|| !uri.user.len)
{
LM_ERR("incomplet uri <%.*s> missing user\n", uuid.len, uuid.s);
goto error;
}
else
{
s1 = &uri.user;
}
}
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_USER0))
s1 = &uri.user;
if((sp->opd&AVPOPS_FLAG_URI0)||(sp->opd&AVPOPS_FLAG_DOMAIN0))
s2 = &uri.host;
{
/* check that uri contains host part */
if(!uri.host.len|| !uri.host.s)
{
LM_ERR("incomplet uri <%.*s> missing host\n", uuid.len, uuid.s);
goto error;
}
else
{
s2 = &uri.host;
}
}
}

/* set values for keys */
Expand Down

0 comments on commit 20aea65

Please sign in to comment.