|
@@ -131,80 +131,6 @@ int pvh_real_hdr_append(struct sip_msg *msg, str *hname, str *hvalue)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-int pvh_real_hdr_replace(struct sip_msg *msg, str *hname, str *hvalue)
|
|
|
-{
|
|
|
- struct lump *anchor = NULL;
|
|
|
- hdr_field_t *hf = NULL;
|
|
|
- str new_h = STR_NULL;
|
|
|
- int new = 1;
|
|
|
-
|
|
|
- if(hname->s == NULL || hvalue->s == NULL) {
|
|
|
- LM_ERR("header name/value cannot be empty");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- for(hf = msg->headers; hf; hf = hf->next) {
|
|
|
- if(hf->name.len == hname->len
|
|
|
- && strncasecmp(hf->name.s, hname->s, hname->len) == 0) {
|
|
|
- if(hf->body.len == hvalue->len
|
|
|
- && strncasecmp(hf->body.s, hvalue->s, hvalue->len) == 0) {
|
|
|
- return 1;
|
|
|
- }
|
|
|
- new = 0;
|
|
|
- break;
|
|
|
- }
|
|
|
- if(!hf->next)
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if(hf == NULL) {
|
|
|
- LM_ERR("unable to find header lump\n");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- if(new == 0) {
|
|
|
- if((anchor = del_lump(msg, hf->name.s - msg->buf, hf->len, 0)) == 0) {
|
|
|
- LM_ERR("unable to delete header lump\n");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- anchor = anchor_lump(msg, hf->name.s + hf->len - msg->buf, 0, 0);
|
|
|
- }
|
|
|
-
|
|
|
- if(anchor == 0) {
|
|
|
- LM_ERR("unable to find header lump\n");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- if(pvh_create_hdr_str(hname, hvalue, &new_h) <= 0)
|
|
|
- return -1;
|
|
|
-
|
|
|
- if(insert_new_lump_after(anchor, new_h.s, new_h.len, 0) == 0) {
|
|
|
- LM_ERR("cannot insert header lump\n");
|
|
|
- pkg_free(new_h.s);
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- LM_DBG("%s header: %.*s\n", new ? "append" : "replace", new_h.len, new_h.s);
|
|
|
-
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
-int pvh_real_hdr_del_by_name(struct sip_msg *msg, str *hname)
|
|
|
-{
|
|
|
- hdr_field_t *hf = NULL;
|
|
|
-
|
|
|
- for(hf = msg->headers; hf; hf = hf->next) {
|
|
|
- if(hf->name.len == hname->len
|
|
|
- && strncasecmp(hf->name.s, hname->s, hname->len) == 0) {
|
|
|
- LM_DBG("remove header[%.*s]: %.*s\n", hf->name.len, hf->name.s,
|
|
|
- hf->body.len, hf->body.s);
|
|
|
- del_lump(msg, hf->name.s - msg->buf, hf->len, 0);
|
|
|
- }
|
|
|
- }
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
int pvh_real_hdr_remove_display(struct sip_msg *msg, str *hname)
|
|
|
{
|
|
|
hdr_field_t *hf = NULL;
|