Skip to content

Commit

Permalink
data_lump_rpl: add support for replacing rpl lump
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed May 13, 2022
1 parent 197d881 commit 899c28f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions data_lump_rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ void free_lump_rpl(struct lump_rpl* lump)
}


struct lump_rpl* get_lump_rpl(struct sip_msg *msg, int flags)
{
struct lump_rpl *lump;

for (lump = msg->reply_lump; lump; lump = lump->next) {
if (lump->flags & flags)
return lump;
}
return NULL;
}


int replace_lump_rpl(struct lump_rpl *lump, char *s, int len, int flags)
{
if ((flags & LUMP_RPL_NODUP) == 0) {
LM_ERR("replacing lump should have its own buffer\n");
return -1;
}
if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP)
&& lump->text.s)
pkg_free(lump->text.s);
lump->flags |= flags;
lump->text.s = s;
lump->text.len = len;
return 0;
}


void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump)
{
struct lump_rpl *foo,*prev;
Expand Down
4 changes: 4 additions & 0 deletions data_lump_rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *, char *, int , int );

void free_lump_rpl(struct lump_rpl* );

struct lump_rpl* get_lump_rpl(struct sip_msg *, int);

int replace_lump_rpl(struct lump_rpl *, char *, int , int);

void unlink_lump_rpl(struct sip_msg *, struct lump_rpl* );

void del_nonshm_lump_rpl( struct lump_rpl ** );
Expand Down

0 comments on commit 899c28f

Please sign in to comment.