|
@@ -76,6 +76,7 @@ static int w_record_route_advertised_address(struct sip_msg *, char *, char *);
|
|
|
static int w_add_rr_param(struct sip_msg *,char *, char *);
|
|
|
static int w_check_route_param(struct sip_msg *,char *, char *);
|
|
|
static int w_is_direction(struct sip_msg *,char *, char *);
|
|
|
+static int remove_record_route(sip_msg_t*, char*, char*);
|
|
|
/* PV functions */
|
|
|
static int pv_get_route_uri_f(struct sip_msg *, pv_param_t *, pv_value_t *);
|
|
|
/*!
|
|
@@ -100,6 +101,8 @@ static cmd_export_t cmds[] = {
|
|
|
REQUEST_ROUTE},
|
|
|
{"is_direction", (cmd_function)w_is_direction, 1, direction_fixup, 0,
|
|
|
REQUEST_ROUTE},
|
|
|
+ {"remove_record_route", remove_record_route, 0, 0, 0,
|
|
|
+ REQUEST_ROUTE|FAILURE_ROUTE},
|
|
|
{"load_rr", (cmd_function)load_rr, 0, 0, 0, 0},
|
|
|
{0, 0, 0, 0, 0, 0}
|
|
|
};
|
|
@@ -400,3 +403,79 @@ pv_get_route_uri_f(struct sip_msg *msg, pv_param_t *param,
|
|
|
return pv_get_strval(msg, param, res, &uri);
|
|
|
}
|
|
|
|
|
|
+static void free_rr_lump(struct lump **list)
|
|
|
+{
|
|
|
+ struct lump *prev_lump, *lump, *a, *foo, *next;
|
|
|
+ int first_shmem;
|
|
|
+
|
|
|
+ first_shmem=1;
|
|
|
+ next=0;
|
|
|
+ prev_lump=0;
|
|
|
+ for(lump=*list;lump;lump=next) {
|
|
|
+ next=lump->next;
|
|
|
+ if (lump->type==HDR_RECORDROUTE_T) {
|
|
|
+ /* may be called from railure_route */
|
|
|
+ /* if (lump->flags & (LUMPFLAG_DUPED|LUMPFLAG_SHMEM)){
|
|
|
+ LOG(L_CRIT, "BUG: free_rr_lmp: lump %p, flags %x\n",
|
|
|
+ lump, lump->flags);
|
|
|
+ */ /* ty to continue */
|
|
|
+ /*}*/
|
|
|
+ a=lump->before;
|
|
|
+ while(a) {
|
|
|
+ foo=a; a=a->before;
|
|
|
+ if (!(foo->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
|
|
|
+ free_lump(foo);
|
|
|
+ if (!(foo->flags&LUMPFLAG_SHMEM))
|
|
|
+ pkg_free(foo);
|
|
|
+ }
|
|
|
+ a=lump->after;
|
|
|
+ while(a) {
|
|
|
+ foo=a; a=a->after;
|
|
|
+ if (!(foo->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
|
|
|
+ free_lump(foo);
|
|
|
+ if (!(foo->flags&LUMPFLAG_SHMEM))
|
|
|
+ pkg_free(foo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (first_shmem && (lump->flags&LUMPFLAG_SHMEM)) {
|
|
|
+ /* This is the first element of the
|
|
|
+ shmemzied lump list, we can not unlink it!
|
|
|
+ It wound corrupt the list otherwise if we
|
|
|
+ are in failure_route. -- No problem, only the
|
|
|
+ anchor is left in the list */
|
|
|
+
|
|
|
+ LOG(L_DBG, "DEBUG: free_rr_lump: lump %p" \
|
|
|
+ " is left in the list\n",
|
|
|
+ lump);
|
|
|
+
|
|
|
+ if (lump->len)
|
|
|
+ LOG(L_CRIT, "BUG: free_rr_lump: lump %p" \
|
|
|
+ " can not be removed, but len=%d\n",
|
|
|
+ lump, lump->len);
|
|
|
+
|
|
|
+ prev_lump=lump;
|
|
|
+ } else {
|
|
|
+ if (prev_lump) prev_lump->next = lump->next;
|
|
|
+ else *list = lump->next;
|
|
|
+ if (!(lump->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
|
|
|
+ free_lump(lump);
|
|
|
+ if (!(lump->flags&LUMPFLAG_SHMEM))
|
|
|
+ pkg_free(lump);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ /* store previous position */
|
|
|
+ prev_lump=lump;
|
|
|
+ }
|
|
|
+ if (first_shmem && (lump->flags&LUMPFLAG_SHMEM))
|
|
|
+ first_shmem=0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * Remove Record-Route header from message lumps
|
|
|
+ */
|
|
|
+static int remove_record_route(sip_msg_t* _m, char* _s1, char* _s2)
|
|
|
+{
|
|
|
+ free_rr_lump(&(_m->add_rm));
|
|
|
+ return 1;
|
|
|
+}
|