Skip to content

Commit

Permalink
pv: added $cts - contact header star status
Browse files Browse the repository at this point in the history
- 1 if it is *, 0 otherwise
  • Loading branch information
miconda committed May 17, 2024
1 parent e738bd0 commit 4eb3942
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modules/pv/pv.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ static pv_export_t mod_pvs[] = {
PVT_OTHER, pv_get_cseq_body, 0, 0, 0, 0, 0},
{{"ct", (sizeof("ct") - 1)}, /* */
PVT_OTHER, pv_get_contact, 0, 0, 0, 0, 0},
{{"cts", (sizeof("cts") - 1)}, /* */
PVT_OTHER, pv_get_contact_star, 0, 0, 0, 0, 0},
{{"ctu", (sizeof("ctu") - 1)}, /* */
PVT_OTHER, pv_get_contact_uri, 0, 0, 0, 0, 0},
{{"cT", (sizeof("cT") - 1)}, /* */
Expand Down
23 changes: 23 additions & 0 deletions src/modules/pv/pv_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,29 @@ int pv_get_contact_uri(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
return pv_get_strval(msg, param, res, &cb->contacts->uri);
}

int pv_get_contact_star(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
contact_body_t *cb = NULL;

if(msg == NULL)
return -1;

if(msg->contact == NULL && parse_headers(msg, HDR_CONTACT_F, 0) == -1) {
LM_DBG("no contact header\n");
return pv_get_null(msg, param, res);
}
if(parse_contact_headers(msg) < 0) {
return pv_get_null(msg, param, res);
}

cb = (contact_body_t *)msg->contact->parsed;

if(cb->star == 1) {
return pv_get_uintval(msg, param, res, 1);
}
return pv_get_uintval(msg, param, res, 0);
}

int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res,
struct to_body *xto, int type)
{
Expand Down
3 changes: 3 additions & 0 deletions src/modules/pv/pv_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ int pv_get_contact(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);

int pv_get_contact_uri(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);

int pv_get_contact_star(
struct sip_msg *msg, pv_param_t *param, pv_value_t *res);

int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res,
struct to_body *xto, int type);

Expand Down

0 comments on commit 4eb3942

Please sign in to comment.