diff --git a/src/modules/rr/loose.c b/src/modules/rr/loose.c index 4605ba09ade..5efc5097733 100644 --- a/src/modules/rr/loose.c +++ b/src/modules/rr/loose.c @@ -44,13 +44,6 @@ #include "rr_mod.h" -#define RR_ERROR -1 /*!< An error occurred while processing route set */ -#define RR_DRIVEN 1 /*!< The next hop is determined from the route set */ -#define RR_OB_DRIVEN 2 /*!< The next hop is determined from the route set based on flow-token */ -#define NOT_RR_DRIVEN -1 /*!< The next hop is not determined from the route set */ -#define FLOW_TOKEN_BROKEN -2 /*!< Outbound flow-token shows evidence of tampering */ -#define RR_PRELOADED -3 /*!< The next hop is determined from a preloaded route set */ - #define RR_ROUTE_PREFIX ROUTE_PREFIX "<" #define RR_ROUTE_PREFIX_LEN (sizeof(RR_ROUTE_PREFIX)-1) @@ -622,7 +615,7 @@ static inline int after_strict(struct sip_msg* _m) } if (res > 0) { /* No next route found */ LM_DBG("after_strict: No next URI found\n"); - return NOT_RR_DRIVEN; + return RR_NOT_DRIVEN; } rt = (rr_t*)hdr->parsed; } else rt = rt->next; @@ -862,7 +855,7 @@ static inline int after_loose(struct sip_msg* _m, int preloaded) if ((use_ob = process_outbound(_m, puri.user)) < 0) { LM_INFO("failed to process outbound flow-token\n"); - return FLOW_TOKEN_BROKEN; + return RR_FLOW_TOKEN_BROKEN; } if (rr_force_send_socket && !use_ob) { @@ -937,7 +930,7 @@ static inline int after_loose(struct sip_msg* _m, int preloaded) #ifdef ENABLE_USER_CHECK /* check if it the ignored user */ if(uri_is_myself < 0) - return NOT_RR_DRIVEN; + return RR_NOT_DRIVEN; #endif LM_DBG("Topmost URI is NOT myself\n"); routed_params.s = NULL; @@ -997,7 +990,7 @@ static inline int after_loose(struct sip_msg* _m, int preloaded) /*! * \brief Do loose routing as per RFC3261 * \param _m SIP message - * \return -1 on failure, 1 on success + * \return negative on failure or preloaded, 1 on success */ int loose_route(struct sip_msg* _m) { diff --git a/src/modules/rr/loose.h b/src/modules/rr/loose.h index 15863fcb9cc..634df238a40 100644 --- a/src/modules/rr/loose.h +++ b/src/modules/rr/loose.h @@ -36,6 +36,13 @@ #define RR_FLOW_DOWNSTREAM (1<<0) #define RR_FLOW_UPSTREAM (1<<1) +#define RR_ERROR -1 /*!< An error occurred while processing route set */ +#define RR_DRIVEN 1 /*!< The next hop is determined from the route set */ +#define RR_OB_DRIVEN 2 /*!< The next hop is determined from the route set based on flow-token */ +#define RR_NOT_DRIVEN -1 /*!< The next hop is not determined from the route set */ +#define RR_FLOW_TOKEN_BROKEN -2 /*!< Outbound flow-token shows evidence of tampering */ +#define RR_PRELOADED -3 /*!< The next hop is determined from a preloaded route set */ + /*! * \brief Do loose routing as per RFC3261 diff --git a/src/modules/rr/rr_mod.c b/src/modules/rr/rr_mod.c index 6643239fcb9..b7b979f25e8 100644 --- a/src/modules/rr/rr_mod.c +++ b/src/modules/rr/rr_mod.c @@ -74,6 +74,7 @@ static int direction_fixup(void** param, int param_no); static int it_list_fixup(void** param, int param_no); /* wrapper functions */ static int w_loose_route(struct sip_msg *, char *, char *); +static int w_loose_route_preloaded(struct sip_msg *, char *, char *); static int w_record_route(struct sip_msg *, char *, char *); static int w_record_route_preset(struct sip_msg *,char *, char *); 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); static cmd_export_t cmds[] = { {"loose_route", (cmd_function)w_loose_route, 0, 0, 0, REQUEST_ROUTE}, + {"loose_route_preloaded", (cmd_function)w_loose_route_preloaded,0, 0, 0, + REQUEST_ROUTE}, {"record_route", (cmd_function)w_record_route, 0, 0, 0, REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE}, {"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) return loose_route(msg); } +/** + * wrapper for loose_route(msg) + */ +static int w_loose_route_preloaded(sip_msg_t *msg, char *p1, char *p2) +{ + int ret; + ret = loose_route(msg); + if(ret == RR_PRELOADED) { + return 1; + } + return -1; +} + +/** + * wrapper for loose_route_(msg) + */ +static int ki_loose_route_preloaded(sip_msg_t *msg) +{ + int ret; + ret = loose_route(msg); + if(ret == RR_PRELOADED) { + return 1; + } + return -1; +} + /** * common wrapper for record_route(msg, params) */ @@ -801,6 +830,11 @@ static sr_kemi_t sr_kemi_rr_exports[] = { { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init("rr"), str_init("loose_route_preloaded"), + SR_KEMIP_INT, ki_loose_route_preloaded, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, { str_init("rr"), str_init("remove_record_route"), SR_KEMIP_INT, remove_record_route, { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,