diff --git a/libsip/src/sip-message.c b/libsip/src/sip-message.c index ab3d910f..2006112a 100644 --- a/libsip/src/sip-message.c +++ b/libsip/src/sip-message.c @@ -235,7 +235,13 @@ int sip_message_init2(struct sip_message_t* msg, const char* method, const struc // initialize remote target memmove(&msg->u.c.method, &msg->cseq.method, sizeof(struct cstring_t)); //memmove(&msg->u.c.uri, &dialog->remote.target, sizeof(struct sip_uri_t)); +#if defined(SIP_KEEP_DIALOG_REQUET_URI) + // same as invite request uri + msg->ptr.ptr = sip_uri_clone(msg->ptr.ptr, msg->ptr.end, &msg->u.c.uri, &dialog->remote.uri); +#else + // replace URI with dialog peer contact msg->ptr.ptr = sip_uri_clone(msg->ptr.ptr, msg->ptr.end, &msg->u.c.uri, &dialog->remote.target); +#endif // TODO: Via @@ -713,7 +719,7 @@ static inline int sip_message_skip_header(const struct cstring_t* name) int sip_message_add_header(struct sip_message_t* msg, const char* name, const char* value) { int r; - struct sip_uri_t uri; + //struct sip_uri_t uri; struct sip_param_t header; if (!name || !*name) diff --git a/libsip/src/uac/sip-uac.c b/libsip/src/uac/sip-uac.c index fa3f20b2..536685d2 100644 --- a/libsip/src/uac/sip-uac.c +++ b/libsip/src/uac/sip-uac.c @@ -296,7 +296,7 @@ int sip_uac_transaction_via(struct sip_uac_transaction_t* t, char *via, int nvia if (0 == sip_uri_username(&t->req->from.uri, &user)) { assert(user.n > 0); - r = snprintf(contact, ncontact, "<%.*s:%.*s@%s>", uri->scheme.n > 0 ? (int)uri->scheme.n : 3, uri->scheme.n > 0 ? uri->scheme.p : "sip", (int)user.n, user.p, local); + r = snprintf(contact, ncontact, "<%.*s:%.*s@%s>", (uri && uri->scheme.n > 0) ? (int)uri->scheme.n : 3, (uri && uri->scheme.n > 0) ? uri->scheme.p : "sip", (int)user.n, user.p, local); if (r < 0 || r >= ncontact) return -1; // ENOMEM }