Ver código fonte

rr(k): record_route() and loose_route() exported via API

Daniel-Constantin Mierla 15 anos atrás
pai
commit
69c68b70a9
5 arquivos alterados com 36 adições e 17 exclusões
  1. 2 0
      modules_k/rr/api.c
  2. 19 9
      modules_k/rr/api.h
  3. 1 3
      modules_k/rr/loose.c
  4. 1 3
      modules_k/rr/loose.h
  5. 13 2
      modules_k/rr/rr_mod.c

+ 2 - 0
modules_k/rr/api.c

@@ -56,6 +56,8 @@ extern int append_fromtag;
  */
 int load_rr( struct rr_binds *rrb )
 {
+	rrb->record_route      = record_route;
+	rrb->loose_route       = loose_route;
 	rrb->add_rr_param      = add_rr_param;
 	rrb->check_route_param = check_route_param;
 	rrb->is_direction      = is_direction;

+ 19 - 9
modules_k/rr/api.h

@@ -50,17 +50,20 @@ typedef  int (*add_rr_param_t)(struct sip_msg*, str*);
 typedef  int (*check_route_param_t)(struct sip_msg*, regex_t*);
 typedef  int (*is_direction_t)(struct sip_msg*, int);
 typedef  int (*get_route_param_t)(struct sip_msg*, str*, str*);
-
+typedef  int (*record_route_f)(struct sip_msg*, str*);
+typedef  int (*loose_route_f)(struct sip_msg*);
 
 /*! record-route API export binding */
-struct rr_binds {
-	add_rr_param_t		add_rr_param;
-	check_route_param_t	check_route_param;
-	is_direction_t			is_direction;
-	get_route_param_t		get_route_param;
-	register_rrcb_t			register_rrcb;
-	int					append_fromtag;
-};
+typedef struct rr_binds {
+	record_route_f       record_route;
+	loose_route_f        loose_route;
+	add_rr_param_t       add_rr_param;
+	check_route_param_t  check_route_param;
+	is_direction_t       is_direction;
+	get_route_param_t    get_route_param;
+	register_rrcb_t      register_rrcb;
+	int                  append_fromtag;
+} rr_api_t;
 
 typedef  int (*load_rr_f)( struct rr_binds* );
 
@@ -92,5 +95,12 @@ inline static int load_rr_api( struct rr_binds *rrb )
 	return 0;
 }
 
+/**
+ *
+ */
+inline static int rr_load_api( rr_api_t *rrb )
+{
+	return load_rr_api(rrb);
+}
 
 #endif

+ 1 - 3
modules_k/rr/loose.c

@@ -900,11 +900,9 @@ done:
 /*!
  * \brief Do loose routing as per RFC3261
  * \param _m SIP message
- * \param _s1 unused
- * \param _s2 unused
  * \return -1 on failure, 1 on success
  */
-int loose_route(struct sip_msg* _m, char* _s1, char* _s2)
+int loose_route(struct sip_msg* _m)
 {
 	int ret;
 

+ 1 - 3
modules_k/rr/loose.h

@@ -42,11 +42,9 @@
 /*!
  * \brief Do loose routing as per RFC3261
  * \param _m SIP message
- * \param _s1 unused
- * \param _s2 unused
  * \return -1 on failure, 1 on success
  */
-int loose_route(struct sip_msg* _m, char* _s1, char* _s2);
+int loose_route(struct sip_msg* _m);
 
 
 /*!

+ 13 - 2
modules_k/rr/rr_mod.c

@@ -65,7 +65,8 @@ static int  mod_init(void);static void mod_destroy(void);
 static int direction_fixup(void** param, int param_no);
 static int it_list_fixup(void** param, int param_no);
 /* wrapper functions */
-static int w_record_route(struct sip_msg *,char *, char *);
+static int w_loose_route(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_add_rr_param(struct sip_msg *,char *, char *);
 static int w_check_route_param(struct sip_msg *,char *, char *);
@@ -75,7 +76,7 @@ static int w_is_direction(struct sip_msg *,char *, char *);
  * \brief Exported functions
  */
 static cmd_export_t cmds[] = {
-	{"loose_route",          (cmd_function)loose_route,			0, 0, 0,
+	{"loose_route",          (cmd_function)w_loose_route,		0, 0, 0,
 			REQUEST_ROUTE},
 	{"record_route",         (cmd_function)w_record_route,		0, 0, 0,
 			REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
@@ -199,7 +200,17 @@ static int direction_fixup(void** param, int param_no)
 	return 0;
 }
 
+/**
+ * wrapper for loose_route(msg)
+ */
+static int w_loose_route(struct sip_msg *msg, char *p1, char *p2)
+{
+	return loose_route(msg);
+}
 
+/**
+ * wrapper for record_route(msg, params)
+ */
 static int w_record_route(struct sip_msg *msg, char *key, char *bar)
 {
 	str s;