예제 #1
0
static void stun_resp_handler(int err, uint16_t scode, const char *reason,
			      const struct stun_msg *msg, void *arg)
{
	struct test *test = arg;
	struct stun_attr *attr;
	(void)reason;

	if (err)
		goto out;

	++test->n_resp;

	/* verify STUN response */
	TEST_EQUALS(0, scode);
	TEST_EQUALS(0x0101, stun_msg_type(msg));
	TEST_EQUALS(STUN_CLASS_SUCCESS_RESP, stun_msg_class(msg));
	TEST_EQUALS(STUN_METHOD_BINDING, stun_msg_method(msg));
	TEST_EQUALS(0, stun_msg_chk_fingerprint(msg));

	attr = stun_msg_attr(msg, STUN_ATTR_XOR_MAPPED_ADDR);
	TEST_ASSERT(attr != NULL);

	test->mapped_addr = attr->v.sa;

 out:
	if (err)
		test->err = err;

	/* done */
	re_cancel();
}
예제 #2
0
파일: sip_ua.c 프로젝트: chk-jxcn/redemo
/* called when all sip transactions are completed */
static void exit_handler(void *arg)
{
	(void)arg;

	/* stop libre main loop */
	re_cancel();
}
예제 #3
0
파일: main.c 프로젝트: jamella/tlsperf
static void tls_endpoint_estab_handler(const char *cipher, void *arg)
{
	int err;
	(void)arg;

	re_fprintf(stderr, "\r[ %u .. %c ]",
		   tlsperf.count,
		   0x20 + tlsperf.count % 0x60);

	if (tls_endpoint_established(tlsperf.ep_cli) &&
	    tls_endpoint_established(tlsperf.ep_srv)) {

		if (tlsperf.count >= tlsperf.num) {

			tlsperf.ts_estab = tmr_jiffies();

			re_printf("\nDONE!\n");
			re_printf("cipher:        %s\n", cipher);
			print_report();

			re_cancel();
		}
		else {
			stop_test();
			err = start_test();
			if (err)
				abort_test(err);
		}
	}
}
예제 #4
0
static void udp_recv_client(const struct sa *src, struct mbuf *mb, void *arg)
{
	struct udp_test *ut = arg;

	switch (ut->tindex++) {

	case 0:
		if (!mbuf_compare(mb, data0)) {
			ut->err = EBADMSG;
			break;
		}
		if (!sa_cmp(src, &ut->srv, SA_ALL)) {
			ut->err = EPROTO;
			break;
		}
		break;

	default:
		ut->err = ERANGE;
		break;
	}

	if (ut->tindex >= 1)
		re_cancel();
}
예제 #5
0
파일: tcp_server.c 프로젝트: alfredh/redemo
/* called upon reception of  SIGINT, SIGALRM or SIGTERM */
static void signal_handler(int sig)
{
	re_printf("terminating on signal %d...\n", sig);

	/* stop libre main loop */
	re_cancel();
}
예제 #6
0
static void nat_hairpinning_handler(int err, bool supported, void *arg)
{
	struct fixture *fix = arg;

	fix->err = err;
	fix->hairpin_supp = supported;

	re_cancel();
}
예제 #7
0
파일: test.c 프로젝트: bogidan/baresip-lib
static void timeout_handler(void *arg)
{
	int *err = arg;

	warning("selftest: re_main() loop timed out -- test hung..\n");

	*err = ETIMEDOUT;

	re_cancel();
}
예제 #8
0
static void nat_genalg_handler(int err, uint16_t scode, const char *reason,
			       int status, const struct sa *map, void *arg)
{
	struct fixture *fix = arg;
	(void)reason;
	(void)map;

	fix->err = err;
	fix->scode = scode;
	fix->genalg_status = status;

	re_cancel();
}
예제 #9
0
static void sip_resp_handler(int err, const struct sip_msg *msg, void *arg)
{
    struct test *test = arg;

    if (err) {
        test->err = err;
        re_cancel();
        return;
    }

    ++test->n_resp;

    /* verify the SIP response message */
    TEST_ASSERT(msg != NULL);
    TEST_EQUALS(200, msg->scode);
    TEST_STRCMP("REGISTER", 8, msg->cseq.met.p, msg->cseq.met.l);
    TEST_EQUALS(test->tp, msg->tp);

out:
    if (err)
        test->err = err;
    re_cancel();
}
예제 #10
0
파일: agent.c 프로젝트: alfredh/reicec
static void ice_failed_handler(int err, uint16_t scode,
			       struct ice_candpair *pair, void *arg)
{
	struct agent *ag = arg;
	(void)pair;
	(void)ag;

	re_printf("candidate-pair failed (%m %u)\n", err, scode);

	if (trice_checklist_iscompleted(ag->icem)) {

		re_printf("checklist completed! -- stop.\n");

		if (ag->cli->client && !ag->cli->param.wait)
			re_cancel();
	}
}
예제 #11
0
파일: agent.c 프로젝트: alfredh/reicec
static void ice_estab_handler(struct ice_candpair *pair,
			      const struct stun_msg *msg, void *arg)
{
	struct agent *ag = arg;
	(void)ag;
	(void)msg;

	re_printf("established: %H\n", trice_candpair_debug, pair);

	if (trice_checklist_iscompleted(ag->icem)) {

		re_printf("checklist completed! -- stop.\n");

		if (ag->cli->client && !ag->cli->param.wait)
			re_cancel();
	}
}
	static void mediaflow_localcand_handler(
					const struct zapi_candidate *candv,
					size_t candc, void *arg)
	{
		TestMedia *tm = static_cast<TestMedia *>(arg);
		ASSERT_TRUE(tm->candc < ARRAY_SIZE(tm->candv));

		for (size_t i=0; i<candc; i++) {
			struct ice_cand_attr *cand = &tm->candv[tm->candc];
			const struct zapi_candidate *zcand = &candv[i];
			int err;

			if (0 == str_casecmp(zcand->sdp,
					     "a=end-of-candidates")) {
				++tm->n_local_eoc;
				continue;
			}

			tm->candc++;

			err = ice_cand_attr_decode(cand, zcand->sdp);
			ASSERT_EQ(0, err);

			ASSERT_STREQ("audio", zcand->mid);
			ASSERT_EQ(0, zcand->mline_index);

			/* verify that SRFLX and RELAY candidates contain
			   the related address */
			switch (cand->type) {

			case ICE_CAND_TYPE_SRFLX:
			case ICE_CAND_TYPE_RELAY:
				ASSERT_TRUE(sa_isset(&cand->rel_addr, SA_ALL));
				break;
			default:
				break;
			}
		}

		if (tm->candc >= tm->candc_expected)
			re_cancel();
	}
예제 #13
0
static void udp_recv(const struct sa *src, struct mbuf *mb, void *arg)
{
	struct sip_server *srv = arg;
	struct sip_msg *msg;
	int err;

#if 0
	re_printf("sip: %zu bytes from %J\n", mbuf_get_left(mb), src);
	re_printf("%b\n", mb->buf, mb->end);
#endif

	err = sip_msg_decode(&msg, mb);
	if (err) {
		warning("selftest: sip_msg_decode: %m\n", err);
		return;
	}

	if (0 == pl_strcmp(&msg->met, "REGISTER"))
		srv->got_register_req = true;

	msg->sock = mem_ref(srv->us);
	msg->src  = *src;
	msg->dst  = srv->laddr;
	msg->tp   = SIP_TRANSP_UDP;

	if (srv->terminate)
		err = sip_reply(srv->sip, msg, 503, "Server Error");
	else
		err = sip_reply(srv->sip, msg, 200, "OK");
	if (err) {
		warning("selftest: could not reply: %m\n", err);
	}

	mem_deref(msg);

	if (srv->terminate)
		re_cancel();
}
예제 #14
0
static int mock_display(struct vidisp_st *st, const char *title,
			const struct vidframe *frame)
{
	unsigned width, height;
	(void)title;

	if (!st || !frame)
		return EINVAL;

	width = frame->size.w;
	height = frame->size.h;

	if (!vidframe_isvalid(frame)) {
		warning("mock_vidisp: got invalid frame\n");
		return EPROTO;
	}

	/* verify that the video frame is good */
	if (frame->fmt >= VID_FMT_N)
		return EPROTO;
	if (width == 0 || width > MAX_WIDTH)
		return EPROTO;
	if (height == 0 || height > MAX_HEIGHT)
		return EPROTO;
	if (frame->linesize[0] == 0)
		return EPROTO;

	++st->n_frame;

	if (st->n_frame >= 10) {
		info("mock_vidisp: got %u frames -- stopping re_main\n",
		     st->n_frame);
		re_cancel();   /* XXX use a callback handler instead */
	}

	return 0;
}
예제 #15
0
static void stop_test(void)
{
	re_cancel();
}
예제 #16
0
static void signal_handler(int sig)
{
    re_printf("terminating on signal %d...\n", sig);
    re_cancel();
}
예제 #17
0
파일: main.c 프로젝트: Studio-Link/pylibre
static PyObject *py_cancel(PyObject *self)
{
	re_cancel();
	Py_RETURN_NONE;
}
예제 #18
0
파일: main.c 프로젝트: Studio-Link/pylibre
static void re_signal_handler(int sig)
{
	re_cancel();
}
예제 #19
0
파일: main.c 프로젝트: jamella/tlsperf
static void abort_test(int err)
{
	tlsperf.err = err;
	re_cancel();
}
예제 #20
0
static void exit_handler(void *arg)
{
    (void)arg;
    re_cancel();
}
예제 #21
0
파일: main.c 프로젝트: AmesianX/restund
static void signal_handler(int sig)
{
	restund_info("caught signal %d\n", sig);

	re_cancel();
}
예제 #22
0
파일: test.c 프로젝트: bogidan/baresip-lib
static void signal_handler(int sig)
{
	re_fprintf(stderr, "test interrupted by signal %d\n", sig);
	re_cancel();
}
예제 #23
0
static void abort_test(struct test *test, int err)
{
	test->err = err;
	re_cancel();
}
예제 #24
0
static void signal_handler(int sig)
{
	DEBUG_WARNING("%s %d | got signal %d\n", __func__, __LINE__, sig);
    esp_server_stop(server);
    re_cancel();
}