Commit da8c39d0 authored by Pekka Pessi's avatar Pekka Pessi

check_nta_server: test case for Via with multiple header fields

parent 1cb61e30
......@@ -94,6 +94,51 @@ START_TEST(server_3_0_0)
}
END_TEST
START_TEST(server_3_0_1)
{
struct event *request;
struct message *response;
sip_via_t *vorig = s2_sip_tport_via(s2sip->udp.tport);
sip_via_t via[2];
char *v0_params[8] = {}, *v1_params[8] = {};
char branch0[32], branch1[32];
S2_CASE("server-3.0.1", "Receive MESSAGE",
"Basic non-INVITE transaction with comma-separated Via headers");
s2_sip_msg_flags = MSG_FLG_COMMA_LISTS|MSG_FLG_COMPACT;
fail_if(vorig == NULL);
via[0] = *vorig;
via[0].v_host = "example.net";
via[0].v_params = (void *)v0_params;
snprintf(v0_params[0] = branch0, sizeof branch0,
"branch=z9hG4bK%lx", ++s2sip->tid);
fail_if(vorig == NULL);
via[1] = *vorig;
via[1].v_params = (void *)v1_params;
snprintf(v1_params[0] = branch1, sizeof branch1,
"branch=z9hG4bK%lx", ++s2sip->tid);
fail_if(s2_sip_request_to(dialog, SIP_METHOD_MESSAGE, NULL,
SIPTAG_VIA(via + 1),
SIPTAG_VIA(via + 0),
TAG_END()));
request = s2_nta_wait_for(wait_for_method, (void *)sip_method_message, 0);
fail_unless(request != NULL);
fail_unless(request->irq != NULL);
nta_incoming_treply(request->irq, SIP_200_OK, TAG_END());
nta_incoming_destroy(request->irq);
response = s2_sip_wait_for_response(200, SIP_METHOD_MESSAGE);
fail_unless(response != NULL);
}
END_TEST
/* ---------------------------------------------------------------------- */
......@@ -106,6 +151,7 @@ TCase *check_nta_server_3_0(void)
tcase_set_timeout(tc, 2);
tcase_add_test(tc, server_3_0_0);
tcase_add_test(tc, server_3_0_1);
return tc;
}
......@@ -35,7 +35,7 @@
#undef NDEBUG
#define TP_STACK_T struct s2sip
#define TP_MAGIC_T struct tp_magic_s
#define TP_MAGIC_T struct s2sip_tp_magic_s
#define SU_ROOT_MAGIC_T struct s2sip
#include "s2sip.h"
......@@ -61,7 +61,7 @@
/* -- Module types ------------------------------------------------------ */
struct tp_magic_s
struct s2sip_tp_magic_s
{
sip_via_t *via;
sip_contact_t *contact;
......@@ -88,6 +88,20 @@ s2_sip_generate_tag(su_home_t *home)
return su_sprintf(home, "tag=%s-%s/%u", _s2_suite, _s2_case, ++s2_tag_generator);
}
sip_via_t *s2_sip_tport_via(tport_t const *tport)
{
tp_magic_t *magic = tport_magic(tport);
assert(magic);
return magic->via;
}
sip_contact_t *s2_sip_tport_contact(tport_t const *tport)
{
tp_magic_t *magic = tport_magic(tport);
assert(magic);
return magic->contact;
}
/* ---------------------------------------------------------------------- */
/* SIP messages */
......@@ -390,6 +404,8 @@ s2_complete_response(msg_t *response,
return 0;
}
int s2_sip_msg_flags = 0;
/* Send request (updating dialog).
*
* Return zero upon success, nonzero upon failure.
......@@ -403,7 +419,7 @@ s2_sip_request_to(struct dialog *d,
ta_list ta;
tagi_t const *tags;
msg_t *msg = s2_msg(0);
msg_t *msg = s2_msg(s2_sip_msg_flags);
sip_t *sip = sip_object(msg);
url_t const *target = NULL;
sip_cseq_t cseq[1];
......
......@@ -85,8 +85,13 @@ struct dialog
extern tp_stack_class_t const s2_sip_stack[1];
extern int s2_sip_msg_flags;
char *s2_sip_generate_tag(su_home_t *home);
sip_via_t *s2_sip_tport_via(tport_t const *);
sip_contact_t *s2_sip_tport_contact(tport_t const *);
struct message *s2_sip_remove_message(struct message *m);
void s2_sip_free_message(struct message *m);
void s2_sip_flush_messages(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment