Skip to content

Commit

Permalink
test/call: accept incoming call for UA_EVENT_SIPSESS_CONN
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Aug 19, 2024
1 parent 8bc6f93 commit 8192d52
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions test/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ static void event_handler(enum ua_event ev, struct bevent *event, void *arg)
const char *prm = bevent_get_text(event);
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
const struct sip_msg *msg = bevent_get_msg(event);
int err = 0;

#if 1
Expand All @@ -627,13 +628,28 @@ static void event_handler(enum ua_event ev, struct bevent *event, void *arg)
ASSERT_TRUE(f != NULL);
ASSERT_EQ(MAGIC, f->magic);

if (!ua)
ua = uag_find_msg(msg);

if (ua && ev == UA_EVENT_SIPSESS_CONN) {
err = ua_accept(ua, msg);
if (err) {
warning("test: could not accept incoming call (%m)\n",
err);
return;
}
}

if (ua == f->a.ua)
ag = &f->a;
else if (ua == f->b.ua)
ag = &f->b;
else if (ua == f->c.ua)
ag = &f->c;
else {
if (ev != UA_EVENT_CREATE)
warning("test: could not find agent/ua\n");

return;
}

Expand Down Expand Up @@ -881,7 +897,7 @@ static void event_handler(enum ua_event ev, struct bevent *event, void *arg)
}


int test_call_answer(void)
static int test_call_answer_priv(void)
{
struct fixture fix, *f = &fix;
int err = 0;
Expand Down Expand Up @@ -910,11 +926,31 @@ int test_call_answer(void)

out:
fixture_close(f);

return err;
}


int test_call_answer(void)
{
int err;
conf_config()->call.accept = true;
err = test_call_answer_priv();
if (err) {
warning("call_accept true failed\n");
return err;
}

conf_config()->call.accept = false;
err = test_call_answer_priv();
if (err) {
warning("call_accept false failed\n");
return err;
}

return 0;
}


int test_call_reject(void)
{
struct fixture fix, *f = &fix;
Expand Down

0 comments on commit 8192d52

Please sign in to comment.