diff --git a/libsip/include/sip-uac.h b/libsip/include/sip-uac.h index 9b6c251b..2a5f835c 100644 --- a/libsip/include/sip-uac.h +++ b/libsip/include/sip-uac.h @@ -69,8 +69,9 @@ int sip_uac_send(struct sip_uac_transaction_t* t, const void* data, int bytes, s /// @param[in] invite uac transaction, create by sip_uac_invite /// @param[in] data message payload(such as SDP), maybe NULL if don't need send anything /// @param[in] bytes data length in byte, >=0 only +/// @param[in] ctype content-type header /// @return 0-ok, other-error -int sip_uac_ack(struct sip_uac_transaction_t* invite, const void* data, int bytes); +int sip_uac_ack(struct sip_uac_transaction_t* invite, const void* data, int bytes, const char* ctype); int sip_uac_transaction_addref(struct sip_uac_transaction_t* t); int sip_uac_transaction_release(struct sip_uac_transaction_t* t); diff --git a/libsip/src/uac/sip-uac-ack.c b/libsip/src/uac/sip-uac-ack.c index d1e61c71..0ae82cb3 100644 --- a/libsip/src/uac/sip-uac-ack.c +++ b/libsip/src/uac/sip-uac-ack.c @@ -112,13 +112,14 @@ int sip_uac_ack_3456xx(struct sip_uac_transaction_t* t, const struct sip_message } // 17.1.1.3 Construction of the ACK Request(Section 13.) (p129) -int sip_uac_ack(struct sip_uac_transaction_t* invite, const void* data, int bytes) +int sip_uac_ack(struct sip_uac_transaction_t* invite, const void* data, int bytes, const char* content_type) { int r; char ptr[1024]; char contact[1024]; struct sip_message_t* ack; - + const struct cstring_t* h; + if (!invite->dialog || !cstrvalid(&invite->dialog->remote.target.host)) return -1; @@ -133,6 +134,8 @@ int sip_uac_ack(struct sip_uac_transaction_t* invite, const void* data, int byte assert(ack->u.c.uri.scheme.n >= 3 && 0 == strncmp("sip", ack->u.c.uri.scheme.p, 3)); + sip_message_add_header(ack, "Content-Type", content_type); + // 8.1.1.7 Via (p39) // The branch parameter value MUST be unique across space and time for // all requests sent by the UA.The exceptions to this rule are CANCEL diff --git a/libsip/src/uac/sip-uac.c b/libsip/src/uac/sip-uac.c index e634ea86..fa3f20b2 100644 --- a/libsip/src/uac/sip-uac.c +++ b/libsip/src/uac/sip-uac.c @@ -7,6 +7,7 @@ #include "sip-message.h" #include "sip-transport.h" #include +#include int sip_uac_link_transaction(struct sip_agent_t* sip, struct sip_uac_transaction_t* t) { @@ -248,7 +249,7 @@ int sip_uac_send(struct sip_uac_transaction_t* t, const void* sdp, int bytes, st t->req->size = bytes; t->size = sip_message_write(t->req, t->data, sizeof(t->data)); if (t->size < 0 || t->size >= sizeof(t->data)) - return -1; + return -E2BIG; // payload too long return sip_uac_transaction_send(t); } diff --git a/libsip/test/sip-agent-test.cpp b/libsip/test/sip-agent-test.cpp index 6619a13f..9cfe2633 100644 --- a/libsip/test/sip-agent-test.cpp +++ b/libsip/test/sip-agent-test.cpp @@ -242,7 +242,7 @@ static int sip_uac_oninvited(void* param, const struct sip_message_t* reply, str if (200 <= code && code < 300) { *session = NULL; - sip_uac_ack(t, NULL, 0); + sip_uac_ack(t, NULL, 0, NULL); } task->event.Signal(); } diff --git a/libsip/test/sip-message-test.cpp b/libsip/test/sip-message-test.cpp index 9bd394f0..0936cd8d 100644 --- a/libsip/test/sip-message-test.cpp +++ b/libsip/test/sip-message-test.cpp @@ -60,7 +60,7 @@ static int sip_uac_test_oninvite(void* param, const struct sip_message_t* reply, if (200 <= code && code < 300) { *session = test; - sip_uac_ack(t, NULL, 0); + sip_uac_ack(t, NULL, 0, NULL); } return 0; } diff --git a/libsip/test/sip-uac-message-test.cpp b/libsip/test/sip-uac-message-test.cpp index 6c1a3f79..208ce733 100644 --- a/libsip/test/sip-uac-message-test.cpp +++ b/libsip/test/sip-uac-message-test.cpp @@ -96,7 +96,7 @@ static int sip_uac_message_oninvite(void* param, const struct sip_message_t* rep if (200 <= code && code < 300) { *session = NULL; - sip_uac_ack(t, NULL, 0); + sip_uac_ack(t, NULL, 0, NULL); } return 0; } diff --git a/libsip/test/sip-uac-test.cpp b/libsip/test/sip-uac-test.cpp index c95963e7..593881da 100644 --- a/libsip/test/sip-uac-test.cpp +++ b/libsip/test/sip-uac-test.cpp @@ -222,7 +222,7 @@ static int sip_uac_oninvited(void* param, const struct sip_message_t* reply, str if (200 <= code && code < 300) { *session = NULL; - sip_uac_ack(t, NULL, 0); + sip_uac_ack(t, NULL, 0, NULL); } return NULL; } diff --git a/libsip/test/sip-uac-test2.cpp b/libsip/test/sip-uac-test2.cpp index 5984a19d..60f191b4 100644 --- a/libsip/test/sip-uac-test2.cpp +++ b/libsip/test/sip-uac-test2.cpp @@ -900,7 +900,7 @@ static int sip_uac_oninvited(void* param, const struct sip_message_t* reply, str thread_create(&s->th, sip_work_thread, s.get()); *session = s.get(); - sip_uac_ack(t, NULL, 0); + sip_uac_ack(t, NULL, 0, NULL); return 0; } else if (code == 183)