Skip to content

Commit

Permalink
change: sip_uac_ack add content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
ireader committed Apr 27, 2024
1 parent 598f857 commit 1b81ae3
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion libsip/include/sip-uac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions libsip/src/uac/sip-uac-ack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion libsip/src/uac/sip-uac.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "sip-message.h"
#include "sip-transport.h"
#include <stdio.h>
#include <errno.h>

int sip_uac_link_transaction(struct sip_agent_t* sip, struct sip_uac_transaction_t* t)
{
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion libsip/test/sip-agent-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion libsip/test/sip-message-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libsip/test/sip-uac-message-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libsip/test/sip-uac-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libsip/test/sip-uac-test2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1b81ae3

Please sign in to comment.