From 7fef07fc6e070a2f8b7413f47f7bb7d205544be0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Wed, 18 Dec 2024 08:45:49 +0100 Subject: [PATCH] test: remove mock tcp-server (unused) --- test/CMakeLists.txt | 1 - test/mock/tcpsrv.c | 73 --------------------------------------------- test/test.h | 18 ----------- 3 files changed, 92 deletions(-) delete mode 100644 test/mock/tcpsrv.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index af9953d94..6ec5eb466 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -105,7 +105,6 @@ set(SRCS mock/nat.c mock/sipsrv.c mock/stunsrv.c - mock/tcpsrv.c mock/turnsrv.c mqueue.c net.c diff --git a/test/mock/tcpsrv.c b/test/mock/tcpsrv.c deleted file mode 100644 index b41a58623..000000000 --- a/test/mock/tcpsrv.c +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file mock/tcpsrv.c Mock TCP server - * - * Copyright (C) 2010 Creytiv.com - */ -#include -#include "test.h" - - -#define DEBUG_MODULE "mock/tcpsrv" -#define DEBUG_LEVEL 5 -#include - - -static void destructor(void *arg) -{ - struct tcp_server *srv = arg; - - mem_deref(srv->ts); -} - - -static void tcp_conn_handler(const struct sa *peer, void *arg) -{ - struct tcp_server *srv = arg; - (void)peer; - - switch (srv->behavior) { - - case BEHAVIOR_REJECT: - tcp_reject(srv->ts); - break; - - default: - DEBUG_WARNING("behavior not implemented\n"); - break; - } -} - - -int tcp_server_alloc(struct tcp_server **srvp, enum behavior behavior) -{ - struct tcp_server *srv; - struct sa laddr; - int err; - - if (!srvp) - return EINVAL; - - srv = mem_zalloc(sizeof(*srv), destructor); - if (!srv) - return ENOMEM; - - sa_set_str(&laddr, "127.0.0.1", 0); - - srv->behavior = behavior; - - err = tcp_listen(&srv->ts, &laddr, tcp_conn_handler, srv); - if (err) - goto out; - - err = tcp_local_get(srv->ts, &srv->laddr); - if (err) - goto out; - - out: - if (err) - mem_deref(srv); - else - *srvp = srv; - - return err; -} diff --git a/test/test.h b/test/test.h index 8ce0dd4dc..0c85a22ee 100644 --- a/test/test.h +++ b/test/test.h @@ -481,24 +481,6 @@ int nat_alloc(struct nat **natp, enum natbox_type type, struct udp_sock *us, const struct sa *public_addr); -/* - * TCP Server - */ - -enum behavior { - BEHAVIOR_NORMAL, - BEHAVIOR_REJECT -}; - -struct tcp_server { - struct tcp_sock *ts; - enum behavior behavior; - struct sa laddr; -}; - -int tcp_server_alloc(struct tcp_server **srvp, enum behavior behavior); - - /* * SIP Server */