Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions libsofia-sip-ua/http/http_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,15 @@ int http_request_complete(msg_t *msg)
http_payload_t const *pl;
su_home_t *home = msg_home(msg);

if (!http)
return -1;
if (!http->http_request)
return -1;
if (!http->http_host)
return -1;
if (!http) return -1;
if (!http->http_request) return -1;
if (!http->http_host) return -1;

for (pl = http->http_payload; pl; pl = pl->pl_next)
len += pl->pl_len;
for (pl = http->http_payload; pl; pl = pl->pl_next) {
len += pl->pl_len;
}

if (len > UINT32_MAX)
return -1;
if (len > UINT32_MAX) return -1;

if (!http->http_content_length) {
http->http_content_length = http_content_length_create(home, (uint32_t)len);
Expand All @@ -89,8 +86,9 @@ int http_request_complete(msg_t *msg)
}
}

if (!http->http_separator)
if (!http->http_separator) {
http->http_separator = http_separator_create(home);
}

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions libsofia-sip-ua/http/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ http_method_t http_method_d(char **ss, char const **nname)
case 'H': if (MATCH(s, "HEAD")) code = http_method_head; break;
case 'O': if (MATCH(s, "OPTIONS")) code = http_method_options; break;
case 'P': if (MATCH(s, "POST")) code = http_method_post;
else
if (MATCH(s, "PUT")) code = http_method_put; break;
else if (MATCH(s, "PUT")) code = http_method_put;
break;
case 'T': if (MATCH(s, "TRACE")) code = http_method_trace; break;
}

Expand Down
9 changes: 6 additions & 3 deletions libsofia-sip-ua/msg/msg_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ int time_d(char const **ss,
return -1;
*sec = 10 * s[0] + s[1] - 11 * '0'; s += 2;
if (*s) {
if (!IS_LWS(*s)) return -1; skip_lws(&s);
if (!IS_LWS(*s)) return -1;
skip_lws(&s);
}
*ss = s;
return 0;
Expand Down Expand Up @@ -247,8 +248,10 @@ issize_t msg_date_d(char const **ss, msg_time_t *date)
else {
/* actime-date =
wkday SP month SP ( 2DIGIT | ( SP 1DIGIT )) SP time SP 4DIGIT */
mon = month_d(s); skip_token(&s);
if (mon < 0 || !IS_LWS(*s)) return -1; s++;
mon = month_d(s);
skip_token(&s);
if (mon < 0 || !IS_LWS(*s)) return -1;
s++;
while (IS_LWS(*s)) s++;
if (!is_digit(*s)) return -1;
day = *s++ - '0'; if (is_digit(*s)) day = 10 * day + *s++ - '0';
Expand Down
2 changes: 1 addition & 1 deletion libsofia-sip-ua/msg/msg_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ msg_header_t **serialize_one(msg_t *msg, msg_header_t *h, msg_header_t **prev)
for (last = h; last->sh_succ; last = last->sh_succ) {
/* Ensure that chain is connected */
assert(last->sh_next == last->sh_succ);
assert(last->sh_succ->sh_prev = &last->sh_succ);
assert(last->sh_succ->sh_prev == &last->sh_succ);
}
prev = &last->sh_succ;
}
Expand Down
17 changes: 14 additions & 3 deletions libsofia-sip-ua/nta/nta.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ static void leg_recv(nta_leg_t *, msg_t *, sip_t *, tport_t *);
static void leg_free(nta_agent_t *sa, nta_leg_t *leg);

#define NTA_HASH(i, cs) ((i)->i_hash + 26839U * (uint32_t)(cs))
#define NTA_HASH_WITH_VIA(i, cs, v) ((i)->i_hash + 26839U * (uint32_t)(cs) + (v ? 39581U * msg_hash_string(v) : 0))

HTABLE_PROTOS_WITH(incoming_htable, iht, nta_incoming_t, size_t, hash_value_t);
static nta_incoming_t *incoming_create(nta_agent_t *agent,
Expand Down Expand Up @@ -5695,7 +5696,8 @@ nta_incoming_t *incoming_create(nta_agent_t *agent,
irq->irq_tport = tport_ref(tport);
}

irq->irq_hash = NTA_HASH(irq->irq_call_id, irq->irq_cseq->cs_seq);
/* DCH: added via branch to hash calculation so when receiving forked invites we can track each as a server txn */
irq->irq_hash = NTA_HASH_WITH_VIA(irq->irq_call_id, irq->irq_cseq->cs_seq, irq->irq_via->v_branch);

incoming_insert(agent, queue, irq);
}
Expand Down Expand Up @@ -6255,7 +6257,8 @@ static nta_incoming_t *incoming_find(nta_agent_t const *agent,

assert(cseq);

hash = NTA_HASH(i, cseq->cs_seq);
/* DCH: changed to include not only call-id and cseq but via branch to find server txn */
hash = NTA_HASH_WITH_VIA(i, cseq->cs_seq, v->v_branch);

if (v->v_branch && su_casenmatch(v->v_branch, "z9hG4bK", 7))
magic_branch = v->v_branch + 7;
Expand Down Expand Up @@ -8275,6 +8278,10 @@ nta_outgoing_t *outgoing_create(nta_agent_t *agent,
/* Now we are committed in sending the transaction */
orq->orq_request = msg;
agent->sa_stats->as_client_tr++;

/* DCH: this is a client txn, currently I have not made changes to include via branch here
* we may want to do so in the future.
*/
orq->orq_hash = NTA_HASH(sip->sip_call_id, sip->sip_cseq->cs_seq);

if (orq->orq_user_tport)
Expand Down Expand Up @@ -9503,6 +9510,7 @@ nta_outgoing_t *outgoing_find(nta_agent_t const *sa,
if (cseq == NULL)
return NULL;

/* DCH: I have not made changes to include via branch in client txns yet */
hash = NTA_HASH(i, cseq->cs_seq);

method = cseq->cs_method;
Expand Down Expand Up @@ -11441,8 +11449,11 @@ nta_reliable_t *reliable_find(nta_agent_t const *agent,
incoming_htable_t const *iht = agent->sa_incoming;
nta_incoming_t *irq, **ii;
sip_call_id_t const *i = sip->sip_call_id;
sip_via_t const *v = sip->sip_via;
sip_rack_t const *rack = sip->sip_rack;
hash_value_t hash = NTA_HASH(i, rack->ra_cseq);

/* DCH: changed incoming hash (server txns) to include via branch */
hash_value_t hash = NTA_HASH_WITH_VIA(i, rack->ra_cseq, v->v_branch);

/* XXX - add own hash table for 100rel */

Expand Down
5 changes: 3 additions & 2 deletions libsofia-sip-ua/nua/nua_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,9 +1591,10 @@ int nua_client_treport(nua_client_request_t *cr,
int nua_client_next_request(nua_client_request_t *cr, int invite)
{
for (; cr; cr = cr->cr_next) {
if (cr->cr_method == sip_method_cancel)
if (cr->cr_method == sip_method_cancel) {
continue;
break;
}
break;
}

if (cr && !nua_client_request_in_progress(cr)) {
Expand Down
8 changes: 4 additions & 4 deletions libsofia-sip-ua/nua/nua_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,23 +690,23 @@ nua_event_data_t const *nua_event_data(nua_saved_event_t const saved[1])
*
* @sa #nua_event_e, nua_event_save(), nua_event_data(), nua_saved_event_request().
*/
void nua_destroy_event(nua_saved_event_t saved[1])
void nua_destroy_event(nua_saved_event_t *saved)
{
if (saved && saved[0]) su_msg_destroy(saved);
}

/** @internal Move signal. */
void nua_move_signal(nua_saved_signal_t a[1], nua_saved_signal_t b[1])
void nua_move_signal(nua_saved_signal_t *a, nua_saved_signal_t *b)
{
su_msg_save(a, b);
}

void nua_destroy_signal(nua_saved_signal_t saved[1])
void nua_destroy_signal(nua_saved_signal_t *saved)
{
if (saved) su_msg_destroy(saved);
}

nua_signal_data_t const *nua_signal_data(nua_saved_signal_t const saved[1])
nua_signal_data_t const *nua_signal_data(nua_saved_signal_t const *saved)
{
return nua_event_data(saved);
}
Expand Down
6 changes: 3 additions & 3 deletions libsofia-sip-ua/nua/nua_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ typedef int nua_stack_signal_handler(nua_t *,
nua_event_t,
tagi_t const *);

void nua_move_signal(nua_saved_signal_t a[1], nua_saved_signal_t b[1]);
nua_signal_data_t const *nua_signal_data(nua_saved_signal_t const saved[1]);
void nua_destroy_signal(nua_saved_signal_t saved[1]);
void nua_move_signal(nua_saved_signal_t *a, nua_saved_signal_t *b);
nua_signal_data_t const *nua_signal_data(nua_saved_signal_t const *saved);
void nua_destroy_signal(nua_saved_signal_t *saved);

nua_stack_signal_handler
nua_stack_set_params, nua_stack_get_params,
Expand Down
6 changes: 4 additions & 2 deletions libsofia-sip-ua/sdp/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,8 @@ int sdp_rtpmap_match(sdp_rtpmap_t const *a, sdp_rtpmap_t const *b)
if (aparam == bparam)
return 1;

if (!aparam) aparam = "1"; if (!bparam) bparam = "1";
if (!aparam) aparam = "1";
if (!bparam) bparam = "1";

if (!su_casematch(aparam, bparam))
return 0;
Expand Down Expand Up @@ -1895,7 +1896,8 @@ sdp_rtpmap_t *sdp_rtpmap_find_matching(sdp_rtpmap_t const *list,
break;
}

if (!lparam) lparam = "1"; if (!rparam) rparam = "1";
if (!lparam) lparam = "1";
if (!rparam) rparam = "1";
if (!su_casematch(lparam, rparam))
continue;

Expand Down
4 changes: 0 additions & 4 deletions libsofia-sip-ua/sip/sip_pref_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ int sip_is_callerpref(char const *param)
if (param[0] == '+')
param++, xor = 1;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstring-plus-int"

switch (param[0]) {
case 'a': case 'A':
base = MATCH("audio") || MATCH("automata") || MATCH("application") ||
Expand Down Expand Up @@ -365,7 +362,6 @@ int sip_is_callerpref(char const *param)
base = 0;
break;
}
#pragma GCC diagnostic pop

#undef MATCH

Expand Down
41 changes: 27 additions & 14 deletions libsofia-sip-ua/stun/stun.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,20 @@ int stun_obtain_shared_secret(stun_handle_t *sh,
s = su_socket(family = AF_INET, SOCK_STREAM, 0);

if (s == INVALID_SOCKET) {
return STUN_ERROR(errno, socket);
STUN_ERROR(errno, socket);
return -1;
}

/* asynchronous connect() */
if (su_setblocking(s, 0) < 0) {
return STUN_ERROR(errno, su_setblocking);
STUN_ERROR(errno, su_setblocking);
return -1;
}

if (setsockopt(s, SOL_TCP, TCP_NODELAY,
(void *)&one, sizeof one) == -1) {
return STUN_ERROR(errno, setsockopt);
STUN_ERROR(errno, setsockopt);
return -1;
}

/* Do an asynchronous connect(). Three error codes are ok,
Expand All @@ -592,7 +595,8 @@ int stun_obtain_shared_secret(stun_handle_t *sh,
ai->ai_addrlen) == SOCKET_ERROR) {
err = su_errno();
if (err != EINPROGRESS && err != EAGAIN && err != EWOULDBLOCK) {
return STUN_ERROR(err, connect);
STUN_ERROR(err, connect);
return -1;
}
}

Expand All @@ -604,15 +608,18 @@ int stun_obtain_shared_secret(stun_handle_t *sh,
/* req = stun_request_create(sd); */

events = SU_WAIT_CONNECT | SU_WAIT_ERR;
if (su_wait_create(wait, s, events) == -1)
return STUN_ERROR(errno, su_wait_create);
if (su_wait_create(wait, s, events) == -1) {
STUN_ERROR(errno, su_wait_create);
return -1;
}

/* su_root_eventmask(sh->sh_root, sh->sh_root_index, s, events); */

if ((sd->sd_index =
su_root_register(sh->sh_root, wait, stun_tls_callback, (su_wakeup_arg_t *) sd, 0)) == -1) {
su_wait_destroy(wait);
return STUN_ERROR(errno, su_root_register);
STUN_ERROR(errno, su_root_register);
return -1;
}

ta_start(ta, tag, value);
Expand Down Expand Up @@ -789,7 +796,8 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int register_socket)

/* set socket asynchronous */
if (su_setblocking(s, 0) < 0) {
return STUN_ERROR(errno, su_setblocking);
STUN_ERROR(errno, su_setblocking);
return -1;
}

/* xxx -- check if socket is already assigned to this root */
Expand All @@ -815,7 +823,8 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int register_socket)
}

if (getsockname(s, &su->su_sa, &sulen) == -1) {
return STUN_ERROR(errno, getsockname);
STUN_ERROR(errno, getsockname);
return -1;
}
}

Expand All @@ -828,15 +837,17 @@ int assign_socket(stun_discovery_t *sd, su_socket_t s, int register_socket)
events = SU_WAIT_IN | SU_WAIT_ERR;

if (su_wait_create(wait, s, events) == -1) {
return STUN_ERROR(su_errno(), su_wait_create);
STUN_ERROR(su_errno(), su_wait_create);
return -1;
}

/* Register receiving function with events specified above */
if ((sd->sd_index = su_root_register(sh->sh_root,
wait, stun_bind_callback,
(su_wakeup_arg_t *) sd, 0)) < 0) {
su_wait_destroy(wait);
return STUN_ERROR(errno, su_root_register);
STUN_ERROR(errno, su_root_register);
return -1;
}

SU_DEBUG_7(("%s: socket registered.\n", __func__));
Expand Down Expand Up @@ -877,13 +888,15 @@ static int get_localinfo(int family, su_sockaddr_t *su, socklen_t *return_len)
su_freelocalinfo(res);

if (!li) { /* Not found */
return STUN_ERROR(error, su_getlocalinfo);
STUN_ERROR(error, su_getlocalinfo);
return -1;
}

return 0;
}
else {
return STUN_ERROR(error, su_getlocalinfo);
STUN_ERROR(error, su_getlocalinfo);
return -1;
}
}
#endif
Expand Down Expand Up @@ -1355,7 +1368,7 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, su_wakeup_arg_t *arg)
/* openssl initiation */
SSLeay_add_ssl_algorithms();
SSL_load_error_strings();
ctx = SSL_CTX_new(TLSv1_client_method());
ctx = SSL_CTX_new(TLS_client_method());
self->sh_ctx = ctx;

if (ctx == NULL) {
Expand Down
3 changes: 1 addition & 2 deletions libsofia-sip-ua/stun/stun_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ extern char const STUN_DEBUG[]; /* dummy declaration for Doxygen */
#endif

#define STUN_ERROR(err, what) \
SU_DEBUG_5(("%s: %s: %s\n", __func__, #what, su_strerror(err))), \
-1 \
SU_DEBUG_5(("%s: %s: %s\n", __func__, #what, su_strerror(err)))

int stun_is_requested(tag_type_t tag, tag_value_t value, ...);

Expand Down
4 changes: 2 additions & 2 deletions libsofia-sip-ua/su/sofia-sip/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ scope type prefix##get(heaptype, size_t)
* bytes in the heap.
*/
#define HEAP_BODIES(scope, heaptype, prefix, type, less, set, alloc, null) \
scope int prefix##resize(void *realloc_arg, heaptype h[1], size_t new_size) \
scope int prefix##resize(void *realloc_arg, heaptype *h, size_t new_size) \
{ \
struct prefix##priv { size_t _size, _used; type _heap[2]; }; \
struct prefix##priv *_priv; \
Expand Down Expand Up @@ -198,7 +198,7 @@ scope int prefix##resize(void *realloc_arg, heaptype h[1], size_t new_size) \
} \
\
/** Free heap. */ \
scope int prefix##free(void *realloc_arg, heaptype h[1]) \
scope int prefix##free(void *realloc_arg, heaptype* h) \
{ \
(void)realloc_arg; \
*(void **)h = alloc(realloc_arg, *(void **)h, 0); \
Expand Down
Loading