diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-06-04 00:09:13 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-06-04 00:09:13 +0000 |
commit | c105f71f505a69e9abba05bb6f547b9d75faaf05 (patch) | |
tree | 07456124e9de0dcd073bf568fff3ec95a87acb1e /channels | |
parent | 6ef8053cb17541a8a8a8557fc0b2eeffd6c9adde (diff) |
add a bit of comment on what build_route does,
plus minor code simplification.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@31895 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0d1c828df..b54ace7e6 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6622,7 +6622,11 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward p->route_persistant = backwards; - /* We build up head, then assign it to p->route when we're done */ + /* Build a tailq, then assign it to p->route when done. + * If backwards, we add entries from the head so they end up + * in reverse order. However, we do need to maintain a correct + * tail pointer because the contact is always at the end. + */ head = NULL; tail = head; /* 1st we pass through all the hops in any Record-Route headers */ @@ -6631,12 +6635,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward rr = __get_header(req, "Record-Route", &start); if (*rr == '\0') break; - for (;;) { - /* Each route entry */ - /* Find < */ - rr = strchr(rr, '<'); - if (!rr) - break; /* No more hops */ + for (; (rr = strchr(rr, '<')) ; rr += len) { /* Each route entry */ ++rr; len = strcspn(rr, ">") + 1; /* Make a struct route */ @@ -6650,7 +6649,8 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward thishop->next = head; head = thishop; /* If this was the first then it'll be the tail */ - if (!tail) tail = thishop; + if (!tail) + tail = thishop; } else { thishop->next = NULL; /* Link in at the end */ @@ -6661,7 +6661,6 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward tail = thishop; } } - rr += len; } } |