Commit 1c070d40 authored by Pekka Pessi's avatar Pekka Pessi

sip_util.c, sip_util.h: Added sip_route_reverse_as() and sip_route_fixdup_as().

darcs-hash:20060524213514-65a35-52683e5f4ad5fb86459984fb92392d673ae40f55.gz
parent e53497ef
...@@ -18,8 +18,6 @@ API/ABI changes and versioning ...@@ -18,8 +18,6 @@ API/ABI changes and versioning
other important information to developers; other important information to developers;
- and should be updated _continuously_! /> - and should be updated _continuously_! />
- nua_glib.h: renamed glib property 'stun' to 'stun-server',
removed property 'bind-address' (same as 'contact').
Contributors to this release Contributors to this release
---------------------------- ----------------------------
...@@ -30,6 +28,7 @@ Contributors to this release ...@@ -30,6 +28,7 @@ Contributors to this release
- name of the contributor should be enough - name of the contributor should be enough
/> />
- Colin Whittaker <colinw@occamnetworks.com>
- Michael Jerris <mike@jerris.com> - Michael Jerris <mike@jerris.com>
- Thomas Rosenblatt <trosenblatt@cirpack.com> - Thomas Rosenblatt <trosenblatt@cirpack.com>
......
...@@ -564,17 +564,18 @@ sip_route_is_loose(sip_route_t const *r) ...@@ -564,17 +564,18 @@ sip_route_is_loose(sip_route_t const *r)
/**@ingroup sip_route /**@ingroup sip_route
* *
* Reverse a route header. * Reverse a route header (Route, Record-Route, Path, Service-Route).
*
* The function sip_route_reverse() reverses a route header like @b
* Record-Route or @b Path.
*/ */
sip_route_t *sip_route_reverse(su_home_t *home, sip_route_t const *route) sip_route_t *sip_route_reverse_as(su_home_t *home,
msg_hclass_t const *hc,
sip_route_t const *route)
{ {
sip_route_t *reverse = NULL; sip_route_t *reverse = NULL;
sip_route_t r[1], *tmp; sip_route_t r[1], *tmp;
sip_route_init(r); sip_route_init(r);
r->r_common->h_class = hc;
for (reverse = NULL; route; route = route->r_next) { for (reverse = NULL; route; route = route->r_next) {
*r->r_url = *route->r_url; *r->r_url = *route->r_url;
/* Fix broken (Record-)Routes without <> */ /* Fix broken (Record-)Routes without <> */
...@@ -588,7 +589,7 @@ sip_route_t *sip_route_reverse(su_home_t *home, sip_route_t const *route) ...@@ -588,7 +589,7 @@ sip_route_t *sip_route_reverse(su_home_t *home, sip_route_t const *route)
r->r_params = route->r_params + 1; r->r_params = route->r_params + 1;
else else
r->r_params = route->r_params; r->r_params = route->r_params;
tmp = sip_route_dup(home, r); tmp = (sip_route_t *)msg_header_dup_as(home, hc, (msg_header_t *)r);
if (!tmp) if (!tmp)
goto error; goto error;
tmp->r_next = reverse; tmp->r_next = reverse;
...@@ -598,25 +599,31 @@ sip_route_t *sip_route_reverse(su_home_t *home, sip_route_t const *route) ...@@ -598,25 +599,31 @@ sip_route_t *sip_route_reverse(su_home_t *home, sip_route_t const *route)
return reverse; return reverse;
error: error:
while (reverse) { msg_header_free_all(home, (msg_header_t *)reverse);
sip_route_t *r_next = reverse->r_next;
su_free(home, reverse);
reverse = r_next;
}
return NULL; return NULL;
} }
/**@ingroup sip_route /**@ingroup sip_route
* *
* Fix and duplicate a route header. * Reverse a @b Route header.
*
* Reverse A route header like @b Record-Route or @b Path.
*/
sip_route_t *sip_route_reverse(su_home_t *home, sip_route_t const *route)
{
return sip_route_reverse_as(home, sip_route_class, route);
}
/**@ingroup sip_route
* *
* The function sip_route_reverse() reverses a route header like @b * Fix and duplicate a route header (Route, Record-Route, Path, Service-Route).
* Record-Route or @b Path.
* *
*/ */
sip_route_t *sip_route_fixdup(su_home_t *home, sip_route_t const *route) sip_route_t *sip_route_fixdup_as(su_home_t *home,
msg_hclass_t const *hc,
sip_route_t const *route)
{ {
sip_route_t *copy = NULL; sip_route_t *copy = NULL;
sip_route_t r[1], **rr; sip_route_t r[1], **rr;
...@@ -636,7 +643,7 @@ sip_route_t *sip_route_fixdup(su_home_t *home, sip_route_t const *route) ...@@ -636,7 +643,7 @@ sip_route_t *sip_route_fixdup(su_home_t *home, sip_route_t const *route)
r->r_params = route->r_params + 1; r->r_params = route->r_params + 1;
else else
r->r_params = route->r_params; r->r_params = route->r_params;
*rr = sip_route_dup(home, r); *rr = (sip_route_t *)msg_header_dup_as(home, hc, (msg_header_t *)r);
if (!*rr) goto error; if (!*rr) goto error;
rr = &(*rr)->r_next; rr = &(*rr)->r_next;
} }
...@@ -644,15 +651,23 @@ sip_route_t *sip_route_fixdup(su_home_t *home, sip_route_t const *route) ...@@ -644,15 +651,23 @@ sip_route_t *sip_route_fixdup(su_home_t *home, sip_route_t const *route)
return copy; return copy;
error: error:
while (copy) { msg_header_free_all(home, (msg_header_t *)copy);
sip_route_t *r_next = copy->r_next;
su_free(home, copy);
copy = r_next;
}
return NULL; return NULL;
} }
/**@ingroup sip_route
*
* Fix and duplicate a @b Route header.
*
* Copy a route header like @b Record-Route or @b Path as @b Route.
*
*/
sip_route_t *sip_route_fixdup(su_home_t *home, sip_route_t const *route)
{
return sip_route_fixdup_as(home, sip_route_class, route);
}
static void sip_fragment_clear_chain(sip_header_t *h) static void sip_fragment_clear_chain(sip_header_t *h)
{ {
void const *next; void const *next;
......
...@@ -107,6 +107,13 @@ SOFIAPUBFUN sip_route_t *sip_route_reverse(su_home_t *, sip_route_t const *); ...@@ -107,6 +107,13 @@ SOFIAPUBFUN sip_route_t *sip_route_reverse(su_home_t *, sip_route_t const *);
SOFIAPUBFUN sip_route_t *sip_route_fixdup(su_home_t *, sip_route_t const *); SOFIAPUBFUN sip_route_t *sip_route_fixdup(su_home_t *, sip_route_t const *);
SOFIAPUBFUN sip_route_t *sip_route_fix(sip_route_t *route); SOFIAPUBFUN sip_route_t *sip_route_fix(sip_route_t *route);
SOFIAPUBFUN sip_route_t *sip_route_fixdup_as(su_home_t *,
msg_hclass_t const *,
sip_route_t const *);
SOFIAPUBFUN sip_route_t *sip_route_reverse_as(su_home_t *,
msg_hclass_t const *,
sip_route_t const *);
SOFIAPUBFUN sip_via_t *sip_via_remove(msg_t *msg, sip_t *sip); SOFIAPUBFUN sip_via_t *sip_via_remove(msg_t *msg, sip_t *sip);
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment