diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62ccbb5f5..af9953d94 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -103,7 +103,6 @@ set(SRCS mem.c mock/dnssrv.c mock/nat.c - mock/pf.c mock/sipsrv.c mock/stunsrv.c mock/tcpsrv.c diff --git a/test/mock/pf.c b/test/mock/pf.c deleted file mode 100644 index 8d2ccd500..000000000 --- a/test/mock/pf.c +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file mock/pf.c Mock packet filter - * - * Copyright (C) 2010 Creytiv.com - */ -#include -#include "test.h" - - -#define DEBUG_MODULE "mock/pf" -#define DEBUG_LEVEL 5 -#include - - -static bool stun_attr_handler(const struct stun_attr *attr, void *arg) -{ - (void)arg; - (void)re_printf(" %s", stun_attr_name(attr->type)); - return false; -} - - -static void sniff_stun(struct mbuf *mb) -{ - struct stun_msg *msg; - size_t pos; - int err; - - pos = mb->pos; - err = stun_msg_decode(&msg, mb, NULL); - if (err) { - DEBUG_WARNING("could not decode STUN packet (%m)\n", err); - return; - } - - stun_msg_attr_apply(msg, stun_attr_handler, 0); - (void)re_printf("\n"); - - mem_deref(msg); - - mb->pos = pos; -} - - -/* egress */ -static bool pf_send_handler(int *err, struct sa *dst, - struct mbuf *mb, void *arg) -{ - struct pf *pf = arg; - (void)err; - (void)dst; - - (void)re_printf("[%s] send -- ", pf->name); - sniff_stun(mb); - - return false; -} - - -/* ingress */ -static bool pf_recv_handler(struct sa *src, struct mbuf *mb, void *arg) -{ - struct pf *pf = arg; - (void)src; - - (void)re_printf("[%s] recv --", pf->name); - sniff_stun(mb); - - return false; -} - - -static void pf_destructor(void *arg) -{ - struct pf *pf = arg; - - mem_deref(pf->uh); - mem_deref(pf->us); -} - - -int pf_create(struct pf **pfp, struct udp_sock *us, const char *name) -{ - struct pf *pf; - int err; - - if (!pfp || !us) - return EINVAL; - - pf = mem_zalloc(sizeof(*pf), pf_destructor); - if (!pf) - return ENOMEM; - - pf->us = mem_ref(us); - str_ncpy(pf->name, name, sizeof(pf->name)); - - err = udp_register_helper(&pf->uh, us, - -1000, /* very low layer */ - pf_send_handler, pf_recv_handler, pf); - - if (err) - mem_deref(pf); - else - *pfp = pf; - - return err; -} diff --git a/test/test.h b/test/test.h index eaf278bd4..3b582ecab 100644 --- a/test/test.h +++ b/test/test.h @@ -408,15 +408,6 @@ const char *test_datapath(void); */ -struct pf { - struct udp_helper *uh; - struct udp_sock *us; - char name[16]; -}; - -int pf_create(struct pf **pfp, struct udp_sock *us, const char *name); - - struct stunserver { struct udp_sock *us; struct tcp_sock *ts;