Browse code

rtpengine: really do allow unsigned setid

zxcpoiu authored on 17/02/2017 10:50:57
Showing 3 changed files
... ...
@@ -140,7 +140,7 @@ static int parse_flags(struct ng_flags_parse *, struct sip_msg *, enum rtpe_oper
140 140
 static int rtpengine_offer_answer(struct sip_msg *msg, const char *flags, int op, int more);
141 141
 static int fixup_set_id(void ** param, int param_no);
142 142
 static int set_rtpengine_set_f(struct sip_msg * msg, char * str1, char * str2);
143
-static struct rtpp_set * select_rtpp_set(int id_set);
143
+static struct rtpp_set * select_rtpp_set(unsigned int id_set);
144 144
 static struct rtpp_node *select_rtpp_node_new(str, str, int, struct rtpp_node **, int);
145 145
 static struct rtpp_node *select_rtpp_node_old(str, str, int, enum rtpe_operation);
146 146
 static struct rtpp_node *select_rtpp_node(str, str, int, struct rtpp_node **, int, enum rtpe_operation);
... ...
@@ -175,7 +175,7 @@ static str extra_id_pv_param = {NULL, 0};
175 175
 static char *setid_avp_param = NULL;
176 176
 static int hash_table_tout = 3600;
177 177
 static int hash_table_size = 256;
178
-static int setid_default = DEFAULT_RTPP_SET_ID;
178
+static unsigned int setid_default = DEFAULT_RTPP_SET_ID;
179 179
 
180 180
 static char ** rtpp_strings=0;
181 181
 static int rtpp_sets=0; /*used in rtpengine_set_store()*/
... ...
@@ -598,7 +598,7 @@ struct rtpp_node *get_rtpp_node(struct rtpp_set *rtpp_list, str *url)
598 598
 	return NULL;
599 599
 }
600 600
 
601
-struct rtpp_set *get_rtpp_set(int set_id)
601
+struct rtpp_set *get_rtpp_set(unsigned int set_id)
602 602
 {
603 603
 	struct rtpp_set * rtpp_list;
604 604
 	unsigned int my_current_id = 0;
... ...
@@ -606,7 +606,7 @@ struct rtpp_set *get_rtpp_set(int set_id)
606 606
 
607 607
 	if (set_id < DEFAULT_RTPP_SET_ID )
608 608
 	{
609
-		LM_ERR(" invalid rtpproxy set value [%d]\n", set_id);
609
+		LM_ERR(" invalid rtpproxy set value [%u]\n", set_id);
610 610
 		return NULL;
611 611
 	}
612 612
 
... ...
@@ -623,7 +623,7 @@ struct rtpp_set *get_rtpp_set(int set_id)
623 623
 		if(!rtpp_list)
624 624
 		{
625 625
 			lock_release(rtpp_set_list->rset_head_lock);
626
-			LM_ERR("no shm memory left to create new rtpproxy set %d\n", my_current_id);
626
+			LM_ERR("no shm memory left to create new rtpproxy set %u\n", my_current_id);
627 627
 			return NULL;
628 628
 		}
629 629
 		memset(rtpp_list, 0, sizeof(struct rtpp_set));
... ...
@@ -907,7 +907,8 @@ error:
907 907
 
908 908
 static int fixup_set_id(void ** param, int param_no)
909 909
 {
910
-	int int_val, err;
910
+	int int_val;
911
+	unsigned int set_id;
911 912
 	struct rtpp_set* rtpp_list;
912 913
 	rtpp_set_link_t *rtpl = NULL;
913 914
 	str s;
... ...
@@ -933,11 +934,11 @@ static int fixup_set_id(void ** param, int param_no)
933 934
 			return -1;
934 935
 		}
935 936
 	} else {
936
-		int_val = str2s(*param, strlen(*param), &err);
937
-		if (err == 0) {
937
+		int_val = str2int(&s, &set_id);
938
+		if (int_val == 0) {
938 939
 			pkg_free(*param);
939
-			if((rtpp_list = select_rtpp_set(int_val)) ==0){
940
-				LM_ERR("rtpp_proxy set %i not configured\n", int_val);
940
+			if((rtpp_list = select_rtpp_set(set_id)) ==0){
941
+				LM_ERR("rtpp_proxy set %u not configured\n", set_id);
941 942
 				return E_CFG;
942 943
 			}
943 944
 			rtpl->rset = rtpp_list;
... ...
@@ -1442,9 +1443,9 @@ mod_init(void)
1442 1443
 	/* select the default set */
1443 1444
 	default_rtpp_set = select_rtpp_set(setid_default);
1444 1445
 	if (!default_rtpp_set) {
1445
-		LM_NOTICE("Default rtpp set %d NOT found\n", setid_default);
1446
+		LM_NOTICE("Default rtpp set %u NOT found\n", setid_default);
1446 1447
 	} else {
1447
-		LM_DBG("Default rtpp set %d found\n", setid_default);
1448
+		LM_DBG("Default rtpp set %u found\n", setid_default);
1448 1449
 	}
1449 1450
 
1450 1451
     if(cfg_declare("rtpengine", rtpengine_cfg_def, &default_rtpengine_cfg, cfg_sizeof(rtpengine), &rtpengine_cfg)){
... ...
@@ -2338,7 +2339,7 @@ badproxy:
2338 2339
  * select the set with the id_set id
2339 2340
  */
2340 2341
 
2341
-static struct rtpp_set * select_rtpp_set(int id_set ){
2342
+static struct rtpp_set * select_rtpp_set(unsigned int id_set ){
2342 2343
 
2343 2344
 	struct rtpp_set * rtpp_list;
2344 2345
 	/*is it a valid set_id?*/
... ...
@@ -2594,11 +2595,11 @@ set_rtpengine_set_from_avp(struct sip_msg *msg, int direction)
2594 2595
 
2595 2596
 	active_rtpp_set = select_rtpp_set(setid_val.n);
2596 2597
 	if(active_rtpp_set == NULL) {
2597
-		LM_ERR("could not locate rtpproxy set %d\n", setid_val.n);
2598
+		LM_ERR("could not locate rtpproxy set %u\n", setid_val.n);
2598 2599
 		return -1;
2599 2600
 	}
2600 2601
 
2601
-	LM_DBG("using rtpengine set %d\n", setid_val.n);
2602
+	LM_DBG("using rtpengine set %u\n", setid_val.n);
2602 2603
 
2603 2604
 	current_msg_id = msg->id;
2604 2605
 
... ...
@@ -2680,7 +2681,7 @@ set_rtpengine_set_n(struct sip_msg *msg, rtpp_set_link_t *rtpl, struct rtpp_set
2680 2681
 	}
2681 2682
 	*out = select_rtpp_set(val.ri);
2682 2683
 	if(*out==NULL) {
2683
-		LM_ERR("could not locate rtpengine set %d\n", val.ri);
2684
+		LM_ERR("could not locate rtpengine set %u\n", val.ri);
2684 2685
 		return -1;
2685 2686
 	}
2686 2687
 	current_msg_id = msg->id;
... ...
@@ -75,7 +75,7 @@ struct rtpp_set_head {
75 75
 
76 76
 
77 77
 struct rtpp_node *get_rtpp_node(struct rtpp_set *rtpp_list, str *url);
78
-struct rtpp_set *get_rtpp_set(int set_id);
78
+struct rtpp_set *get_rtpp_set(unsigned int set_id);
79 79
 int add_rtpengine_socks(struct rtpp_set * rtpp_list, char * rtpproxy, unsigned int weight, int disabled, unsigned int ticks, int isDB);
80 80
 
81 81
 int rtpengine_delete_node(struct rtpp_node *rtpp_node);
... ...
@@ -68,8 +68,8 @@ static int rtpp_load_db(void)
68 68
 	db_key_t query_cols[] = {&rtpp_setid_col, &rtpp_url_col, &rtpp_weight_col, &rtpp_disabled_col};
69 69
 
70 70
 	str url;
71
-	int setid, disabled;
72
-	unsigned int weight, ticks;
71
+	int disabled;
72
+	unsigned int setid, weight, ticks;
73 73
 
74 74
 	/* int weight, flags; */
75 75
 	int n_rows = 0;