- return 1 when Route header handling is ok for an initial request
(no-totag)
- return -1 in case of error or processing was for a request within
dialog
... | ... |
@@ -44,13 +44,6 @@ |
44 | 44 |
#include "rr_mod.h" |
45 | 45 |
|
46 | 46 |
|
47 |
-#define RR_ERROR -1 /*!< An error occurred while processing route set */ |
|
48 |
-#define RR_DRIVEN 1 /*!< The next hop is determined from the route set */ |
|
49 |
-#define RR_OB_DRIVEN 2 /*!< The next hop is determined from the route set based on flow-token */ |
|
50 |
-#define NOT_RR_DRIVEN -1 /*!< The next hop is not determined from the route set */ |
|
51 |
-#define FLOW_TOKEN_BROKEN -2 /*!< Outbound flow-token shows evidence of tampering */ |
|
52 |
-#define RR_PRELOADED -3 /*!< The next hop is determined from a preloaded route set */ |
|
53 |
- |
|
54 | 47 |
#define RR_ROUTE_PREFIX ROUTE_PREFIX "<" |
55 | 48 |
#define RR_ROUTE_PREFIX_LEN (sizeof(RR_ROUTE_PREFIX)-1) |
56 | 49 |
|
... | ... |
@@ -622,7 +615,7 @@ static inline int after_strict(struct sip_msg* _m) |
622 | 615 |
} |
623 | 616 |
if (res > 0) { /* No next route found */ |
624 | 617 |
LM_DBG("after_strict: No next URI found\n"); |
625 |
- return NOT_RR_DRIVEN; |
|
618 |
+ return RR_NOT_DRIVEN; |
|
626 | 619 |
} |
627 | 620 |
rt = (rr_t*)hdr->parsed; |
628 | 621 |
} else rt = rt->next; |
... | ... |
@@ -862,7 +855,7 @@ static inline int after_loose(struct sip_msg* _m, int preloaded) |
862 | 855 |
|
863 | 856 |
if ((use_ob = process_outbound(_m, puri.user)) < 0) { |
864 | 857 |
LM_INFO("failed to process outbound flow-token\n"); |
865 |
- return FLOW_TOKEN_BROKEN; |
|
858 |
+ return RR_FLOW_TOKEN_BROKEN; |
|
866 | 859 |
} |
867 | 860 |
|
868 | 861 |
if (rr_force_send_socket && !use_ob) { |
... | ... |
@@ -937,7 +930,7 @@ static inline int after_loose(struct sip_msg* _m, int preloaded) |
937 | 930 |
#ifdef ENABLE_USER_CHECK |
938 | 931 |
/* check if it the ignored user */ |
939 | 932 |
if(uri_is_myself < 0) |
940 |
- return NOT_RR_DRIVEN; |
|
933 |
+ return RR_NOT_DRIVEN; |
|
941 | 934 |
#endif |
942 | 935 |
LM_DBG("Topmost URI is NOT myself\n"); |
943 | 936 |
routed_params.s = NULL; |
... | ... |
@@ -997,7 +990,7 @@ done: |
997 | 990 |
/*! |
998 | 991 |
* \brief Do loose routing as per RFC3261 |
999 | 992 |
* \param _m SIP message |
1000 |
- * \return -1 on failure, 1 on success |
|
993 |
+ * \return negative on failure or preloaded, 1 on success |
|
1001 | 994 |
*/ |
1002 | 995 |
int loose_route(struct sip_msg* _m) |
1003 | 996 |
{ |
... | ... |
@@ -36,6 +36,13 @@ |
36 | 36 |
#define RR_FLOW_DOWNSTREAM (1<<0) |
37 | 37 |
#define RR_FLOW_UPSTREAM (1<<1) |
38 | 38 |
|
39 |
+#define RR_ERROR -1 /*!< An error occurred while processing route set */ |
|
40 |
+#define RR_DRIVEN 1 /*!< The next hop is determined from the route set */ |
|
41 |
+#define RR_OB_DRIVEN 2 /*!< The next hop is determined from the route set based on flow-token */ |
|
42 |
+#define RR_NOT_DRIVEN -1 /*!< The next hop is not determined from the route set */ |
|
43 |
+#define RR_FLOW_TOKEN_BROKEN -2 /*!< Outbound flow-token shows evidence of tampering */ |
|
44 |
+#define RR_PRELOADED -3 /*!< The next hop is determined from a preloaded route set */ |
|
45 |
+ |
|
39 | 46 |
|
40 | 47 |
/*! |
41 | 48 |
* \brief Do loose routing as per RFC3261 |
... | ... |
@@ -74,6 +74,7 @@ static int direction_fixup(void** param, int param_no); |
74 | 74 |
static int it_list_fixup(void** param, int param_no); |
75 | 75 |
/* wrapper functions */ |
76 | 76 |
static int w_loose_route(struct sip_msg *, char *, char *); |
77 |
+static int w_loose_route_preloaded(struct sip_msg *, char *, char *); |
|
77 | 78 |
static int w_record_route(struct sip_msg *, char *, char *); |
78 | 79 |
static int w_record_route_preset(struct sip_msg *,char *, char *); |
79 | 80 |
static int w_record_route_advertised_address(struct sip_msg *, char *, char *); |
... | ... |
@@ -97,6 +98,8 @@ static int pv_parse_rdir_name(pv_spec_p sp, str *in); |
97 | 98 |
static cmd_export_t cmds[] = { |
98 | 99 |
{"loose_route", (cmd_function)w_loose_route, 0, 0, 0, |
99 | 100 |
REQUEST_ROUTE}, |
101 |
+ {"loose_route_preloaded", (cmd_function)w_loose_route_preloaded,0, 0, 0, |
|
102 |
+ REQUEST_ROUTE}, |
|
100 | 103 |
{"record_route", (cmd_function)w_record_route, 0, 0, 0, |
101 | 104 |
REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE}, |
102 | 105 |
{"record_route", (cmd_function)w_record_route, 1, it_list_fixup, 0, |
... | ... |
@@ -273,6 +276,32 @@ static int w_loose_route(struct sip_msg *msg, char *p1, char *p2) |
273 | 276 |
return loose_route(msg); |
274 | 277 |
} |
275 | 278 |
|
279 |
+/** |
|
280 |
+ * wrapper for loose_route(msg) |
|
281 |
+ */ |
|
282 |
+static int w_loose_route_preloaded(sip_msg_t *msg, char *p1, char *p2) |
|
283 |
+{ |
|
284 |
+ int ret; |
|
285 |
+ ret = loose_route(msg); |
|
286 |
+ if(ret == RR_PRELOADED) { |
|
287 |
+ return 1; |
|
288 |
+ } |
|
289 |
+ return -1; |
|
290 |
+} |
|
291 |
+ |
|
292 |
+/** |
|
293 |
+ * wrapper for loose_route_(msg) |
|
294 |
+ */ |
|
295 |
+static int ki_loose_route_preloaded(sip_msg_t *msg) |
|
296 |
+{ |
|
297 |
+ int ret; |
|
298 |
+ ret = loose_route(msg); |
|
299 |
+ if(ret == RR_PRELOADED) { |
|
300 |
+ return 1; |
|
301 |
+ } |
|
302 |
+ return -1; |
|
303 |
+} |
|
304 |
+ |
|
276 | 305 |
/** |
277 | 306 |
* common wrapper for record_route(msg, params) |
278 | 307 |
*/ |
... | ... |
@@ -801,6 +830,11 @@ static sr_kemi_t sr_kemi_rr_exports[] = { |
801 | 830 |
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, |
802 | 831 |
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
803 | 832 |
}, |
833 |
+ { str_init("rr"), str_init("loose_route_preloaded"), |
|
834 |
+ SR_KEMIP_INT, ki_loose_route_preloaded, |
|
835 |
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, |
|
836 |
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
|
837 |
+ }, |
|
804 | 838 |
{ str_init("rr"), str_init("remove_record_route"), |
805 | 839 |
SR_KEMIP_INT, remove_record_route, |
806 | 840 |
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, |