Pārlūkot izejas kodu

topos: use defined values for internal contact mode

Daniel-Constantin Mierla 1 gadu atpakaļ
vecāks
revīzija
2b27aba7f4

+ 2 - 2
src/modules/topos/topos_mod.c

@@ -123,7 +123,7 @@ static int _tps_eventrt_receiving = -1;
 static str _tps_eventrt_receiving_name = str_init("topos:msg-receiving");
 
 str _tps_contact_host = str_init("");
-int _tps_contact_mode = 0;
+int _tps_contact_mode = TPS_CONTACT_MODE_SKEYUSER;
 str _tps_cparam_name = str_init("tps");
 
 str _tps_xavu_cfg = STR_NULL;
@@ -310,7 +310,7 @@ static int mod_init(void)
 	if(sruid_init(&_tps_sruid, '-', "tpsh", SRUID_INC) < 0)
 		return -1;
 
-	if(_tps_contact_mode == 2
+	if(_tps_contact_mode == TPS_CONTACT_MODE_XAVPUSER
 			&& (_tps_xavu_cfg.len <= 0 || _tps_xavu_field_acontact.len <= 0
 					|| _tps_xavu_field_bcontact.len <= 0)) {
 		LM_ERR("contact_mode parameter is 2,"

+ 5 - 2
src/modules/topos/tps_msg.c

@@ -324,7 +324,8 @@ int tps_dlg_message_update(sip_msg_t *msg, tps_data_t *ptsd, int ctmode)
 		return -1;
 	}
 
-	if(ctmode == 1 || ctmode == 2) {
+	if(ctmode == TPS_CONTACT_MODE_RURIUSER
+			|| ctmode == TPS_CONTACT_MODE_XAVPUSER) {
 		if(msg->parsed_uri.sip_params.len < TPS_TUUID_MIN_LEN) {
 			LM_DBG("not an expected param format\n");
 			return 1;
@@ -962,7 +963,9 @@ int tps_request_received(sip_msg_t *msg, int dialog)
 		LM_DBG("use branch for routing information, request from direction "
 			   "%d\n",
 				direction);
-		if(tps_reappend_route(msg, &stsd, &stsd.s_rr, (direction == TPS_DIR_UPSTREAM) ? 0 : 1) < 0) {
+		if(tps_reappend_route(msg, &stsd, &stsd.s_rr,
+				   (direction == TPS_DIR_UPSTREAM) ? 0 : 1)
+				< 0) {
 			LM_ERR("failed to reappend s-route\n");
 			return -1;
 		}

+ 8 - 6
src/modules/topos/tps_storage.c

@@ -244,7 +244,8 @@ int tps_storage_fill_contact(
 	if(_tps_contact_host.len)
 		contact_len = sv.len - puri.host.len + _tps_contact_host.len;
 
-	if(ctmode == 1 || ctmode == 2) {
+	if(ctmode == TPS_CONTACT_MODE_RURIUSER
+			|| ctmode == TPS_CONTACT_MODE_XAVPUSER) {
 		cparam_len = _tps_cparam_name.len;
 	} else {
 		cparam_len = 0;
@@ -285,9 +286,10 @@ int tps_storage_fill_contact(
 		if(sv.s[i] == ':')
 			break;
 	}
-	if(ctmode == 1 || ctmode == 2) {
+	if(ctmode == TPS_CONTACT_MODE_RURIUSER
+			|| ctmode == TPS_CONTACT_MODE_XAVPUSER) {
 		/* create new URI parameter for Contact header */
-		if(ctmode == 1) {
+		if(ctmode == TPS_CONTACT_MODE_RURIUSER) {
 			if(dir == TPS_DIR_DOWNSTREAM) {
 				/* extract the contact address */
 				if(parse_headers(msg, HDR_CONTACT_F, 0) < 0
@@ -332,7 +334,7 @@ int tps_storage_fill_contact(
 						msg->parsed_uri.user.len);
 				td->cp += msg->parsed_uri.user.len;
 			}
-		} else if(ctmode == 2) {
+		} else if(ctmode == TPS_CONTACT_MODE_XAVPUSER) {
 			if(dir == TPS_DIR_DOWNSTREAM) {
 				/* extract the a contact */
 				vavu = xavu_get_child_with_sval(
@@ -356,8 +358,8 @@ int tps_storage_fill_contact(
 			}
 		}
 
-		if(!((ctmode == 1) && (dir == TPS_DIR_DOWNSTREAM)
-				   && (curi.user.len <= 0))) {
+		if(!((ctmode == TPS_CONTACT_MODE_RURIUSER)
+				   && (dir == TPS_DIR_DOWNSTREAM) && (curi.user.len <= 0))) {
 			*td->cp = '@';
 			td->cp++;
 		}

+ 4 - 0
src/modules/topos/tps_storage.h

@@ -37,6 +37,10 @@
 #define TPS_IFLAG_INIT 1
 #define TPS_IFLAG_DLGON 2
 
+#define TPS_CONTACT_MODE_SKEYUSER 0
+#define TPS_CONTACT_MODE_RURIUSER 1
+#define TPS_CONTACT_MODE_XAVPUSER 2
+
 #define TPS_DBU_CONTACT (1 << 0)
 #define TPS_DBU_RPLATTRS (1 << 1)
 #define TPS_DBU_ARR (1 << 2)