Skip to content

Commit

Permalink
rr: debug messages when record-route is inserted
Browse files Browse the repository at this point in the history
- some trailing whitespace removed

(cherry picked from commit 0270827)
(cherry picked from commit c4431b1)
  • Loading branch information
miconda committed Jan 28, 2020
1 parent 126a333 commit 077f33f
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/modules/rr/record.c
Expand Up @@ -13,8 +13,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down Expand Up @@ -71,7 +71,7 @@


/*!
* \brief RR param buffer
* \brief RR param buffer
* \note used for storing RR param which are added before RR insertion
*/
static char rr_param_buf_ptr[RR_PARAM_BUF_SIZE];
Expand Down Expand Up @@ -139,7 +139,7 @@ static inline int get_username(struct sip_msg* _m, str* _user)
/* no username in original uri -- hmm; maybe it is a uri
* with just host address and username is in a preloaded route,
* which is now no rewritten r-uri (assumed rewriteFromRoute
* was called somewhere in script's beginning)
* was called somewhere in script's beginning)
*/
if (!puri.user.len && _m->new_uri.s) {
if (parse_uri(_m->new_uri.s, _m->new_uri.len, &puri) < 0) {
Expand Down Expand Up @@ -237,13 +237,13 @@ static inline int build_rr(struct lump* _l, struct lump* _l2, str* user,
if (r2) pkg_free(r2);
return -3;
}

memcpy(prefix, rr_prefix, rr_prefix_len);
if (user->len) {
memcpy(prefix + rr_prefix_len, user->s, user->len);
#ifdef ENABLE_USER_CHECK
/* don't add the ignored user into a RR */
if(i_user.len && i_user.len == user->len &&
if(i_user.len && i_user.len == user->len &&
!strncmp(i_user.s, user->s, i_user.len))
{
if(prefix[rr_prefix_len]=='x')
Expand Down Expand Up @@ -273,11 +273,11 @@ static inline int build_rr(struct lump* _l, struct lump* _l2, str* user,
memcpy(p, params->s, params->len);
p += params->len;
}

memcpy(term, RR_TERM, RR_TERM_LEN);
memcpy(r2, RR_R2, RR_R2_LEN);

if (!(_l = insert_new_lump_after(_l, prefix, prefix_len, 0)))
if (!(_l = insert_new_lump_after(_l, prefix, prefix_len, 0)))
goto lump_err;
prefix = 0;
_l = insert_subst_lump_after(_l, _inbound?SUBST_RCV_ALL:SUBST_SND_ALL, 0);
Expand Down Expand Up @@ -307,7 +307,7 @@ static inline int build_rr(struct lump* _l, struct lump* _l2, str* user,
goto lump_err;
term = 0;
return 0;

lump_err:
LM_ERR("failed to insert lumps\n");
if (prefix) pkg_free(prefix);
Expand Down Expand Up @@ -468,6 +468,8 @@ int record_route(struct sip_msg* _m, str *params)
goto error;
}

LM_DBG("inserted record route (r2: %d - plen: %d)\n", enable_double_rr,
(params)?params->len:0);
/* reset the rr_param buffer */
rr_param_buf.len = 0;
ret = 0;
Expand Down Expand Up @@ -536,7 +538,7 @@ int record_route_preset(struct sip_msg* _m, str* _data)
}
from = get_from(_m);
}

l = anchor_lump(_m, _m->headers->name.s - _m->buf, 0, HDR_RECORDROUTE_T);
if (!l) {
LM_ERR("failed to create lump anchor\n");
Expand All @@ -552,7 +554,7 @@ int record_route_preset(struct sip_msg* _m, str* _data)
if (append_fromtag && from->tag_value.len) {
hdr_len += RR_FROMTAG_LEN + from->tag_value.len;
}

if (enable_full_lr) {
hdr_len += RR_LR_FULL_LEN;
} else {
Expand Down Expand Up @@ -581,7 +583,7 @@ int record_route_preset(struct sip_msg* _m, str* _data)

memcpy(p, _data->s, _data->len);
p += _data->len;

if (append_fromtag && from->tag_value.len) {
memcpy(p, RR_FROMTAG, RR_FROMTAG_LEN);
p += RR_FROMTAG_LEN;
Expand All @@ -605,6 +607,7 @@ int record_route_preset(struct sip_msg* _m, str* _data)
ret = -5;
goto error;
}
LM_DBG("inserted preset record route\n");
ret = 1;
error:
if ((use_ob == 1) || (use_ob == 2))
Expand Down Expand Up @@ -652,7 +655,7 @@ static inline int build_advertised_rr(struct lump* _l, struct lump* _l2, str *_d
if (tag && tag->len) {
suffix_len += RR_FROMTAG_LEN + tag->len;
}

if (enable_full_lr) {
suffix_len += RR_LR_FULL_LEN;
} else {
Expand Down Expand Up @@ -686,7 +689,7 @@ static inline int build_advertised_rr(struct lump* _l, struct lump* _l2, str *_d
}

memcpy(p, _data->s, _data->len);

p = suffix;
if (tag && tag->len) {
memcpy(p, RR_FROMTAG, RR_FROMTAG_LEN);
Expand Down Expand Up @@ -839,6 +842,7 @@ int record_route_advertised_address(struct sip_msg* _m, str* _data)
ret = -7;
goto error;
}
LM_DBG("inserted advertised address record route\n");
ret = 1;
error:
if ((use_ob == 1) || (use_ob == 2))
Expand All @@ -862,7 +866,7 @@ static struct lump *get_rr_param_lump( struct lump** root)
for( crt=*root ; crt && !last ; crt=crt->next,(*root)=crt ) {
/* check on before list */
for( r=crt->before ; r ; r=r->before ) {
/* we are looking for the lump that adds the
/* we are looking for the lump that adds the
* suffix of the RR header */
if ( r->type==HDR_RECORDROUTE_T && r->op==LUMP_ADD)
last = r;
Expand Down

0 comments on commit 077f33f

Please sign in to comment.