[sr-dev] git:master:1c7f3938: topos: MESSAGE may be without Contact header

Daniel-Constantin Mierla miconda at gmail.com
Fri Mar 18 18:25:25 CET 2016


Module: kamailio
Branch: master
Commit: 1c7f39389225ef5c1430bb8540b6fd9c249734bb
URL: https://github.com/kamailio/kamailio/commit/1c7f39389225ef5c1430bb8540b6fd9c249734bb

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-03-18T16:43:14+01:00

topos: MESSAGE may be without Contact header

---

Modified: modules/topos/topos_mod.c
Modified: modules/topos/tps_msg.c
Modified: modules/topos/tps_storage.c
Modified: modules/topos/tps_storage.h

---

Diff:  https://github.com/kamailio/kamailio/commit/1c7f39389225ef5c1430bb8540b6fd9c249734bb.diff
Patch: https://github.com/kamailio/kamailio/commit/1c7f39389225ef5c1430bb8540b6fd9c249734bb.patch

---

diff --git a/modules/topos/topos_mod.c b/modules/topos/topos_mod.c
index 4bdcbcf..6d56f09 100644
--- a/modules/topos/topos_mod.c
+++ b/modules/topos/topos_mod.c
@@ -228,6 +228,11 @@ int tps_prepare_msg(sip_msg_t *msg)
 		LM_DBG("no second via in this message \n");
 	}
 
+	if(parse_headers(msg, HDR_CSEQ_F, 0)!=0 || msg->cseq==NULL) {
+		LM_ERR("cannot parse cseq header\n");
+		return -1;
+	}
+
 	if(parse_from_header(msg)<0) {
 		LM_ERR("cannot parse FROM header\n");
 		return 3;
@@ -292,7 +297,7 @@ int tps_msg_received(void *data)
 		}
 	} else {
 		/* reply */
-		if(msg->first_line.u.reply.statuscode==100) {
+		if(msg.first_line.u.reply.statuscode==100) {
 			/* nothing to do - it should be absorbed */
 			return 0;
 		}
diff --git a/modules/topos/tps_msg.c b/modules/topos/tps_msg.c
index e6d02ce..5bdf20e 100644
--- a/modules/topos/tps_msg.c
+++ b/modules/topos/tps_msg.c
@@ -409,6 +409,7 @@ int tps_pack_request(sip_msg_t *msg, tps_data_t *ptsd)
 			ptsd->as_contact.len, ZSW(ptsd->as_contact.s), ptsd->as_contact.len,
 			ptsd->bs_contact.len, ZSW(ptsd->bs_contact.s), ptsd->bs_contact.len);
 	ptsd->x_rr = ptsd->a_rr;
+	ptsd->s_method_id = get_cseq(msg)->method_id;
 	return 0;
 }
 
diff --git a/modules/topos/tps_storage.c b/modules/topos/tps_storage.c
index c5a767b..a85c71b 100644
--- a/modules/topos/tps_storage.c
+++ b/modules/topos/tps_storage.c
@@ -275,8 +275,20 @@ int tps_storage_link_msg(sip_msg_t *msg, tps_data_t *td, int dir)
 		td->b_tag = td->a_tag;
 	}
 
+	td->x_via = td->x_via2;
+	if(parse_headers(msg, HDR_CSEQ_F, 0)!=0 || msg->cseq==NULL) {
+		LM_ERR("cannot parse cseq header\n");
+		return -1; /* should it be 0 ?!?! */
+	}
+	td->s_method = get_cseq(msg)->method;
+	td->s_cseq = get_cseq(msg)->number;
+
 	/* extract the contact address */
 	if(parse_headers(msg, HDR_CONTACT_F, 0)<0 || msg->contact==NULL) {
+		if(td->s_method_id == METHOD_MESSAGE) {
+			/* no contact required for MESSAGE - done */
+			return 0;
+		}
 		LM_ERR("bad sip message or missing Contact hdr\n");
 		goto error;
 	}
@@ -291,13 +303,7 @@ int tps_storage_link_msg(sip_msg_t *msg, tps_data_t *td, int dir)
 	} else {
 		td->b_contact = ((contact_body_t*)msg->contact->parsed)->contacts->uri;
 	}
-	td->x_via = td->x_via2;
-	if(parse_headers(msg, HDR_CSEQ_F, 0)!=0 || msg->cseq==NULL) {
-		LM_ERR("cannot parse cseq header\n");
-		return -1; /* should it be 0 ?!?! */
-	}
-	td->s_method = get_cseq(msg)->method;
-	td->s_cseq = get_cseq(msg)->number;
+
 	return 0;
 
 error:
diff --git a/modules/topos/tps_storage.h b/modules/topos/tps_storage.h
index cd24fd9..400ee98 100644
--- a/modules/topos/tps_storage.h
+++ b/modules/topos/tps_storage.h
@@ -65,6 +65,7 @@ typedef struct tps_data {
 	str s_cseq;
 	int32_t iflags;
 	int32_t direction;
+	uint32_t s_method_id;
 } tps_data_t;
 
 int tps_storage_dialog_find(sip_msg_t *msg, tps_data_t *td);




More information about the sr-dev mailing list