Skip to content

Commit

Permalink
topos: MESSAGE may be without Contact header
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Mar 18, 2016
1 parent 98f9271 commit 1c7f393
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
7 changes: 6 additions & 1 deletion modules/topos/topos_mod.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions modules/topos/tps_msg.c
Expand Up @@ -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;
}

Expand Down
20 changes: 13 additions & 7 deletions modules/topos/tps_storage.c
Expand Up @@ -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;
}
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions modules/topos/tps_storage.h
Expand Up @@ -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);
Expand Down

0 comments on commit 1c7f393

Please sign in to comment.