File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / arping / src / mock_libnet.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Mar 16 23:40:57 2021 UTC (3 years, 2 months ago) by misho
Branches: arping, MAIN
CVS tags: v2_21, HEAD
arping 2.21

#include<libnet.h>
#include"config.h"

#define UNUSED(x) (void)(x)
int mock_libnet_null_ok = 1;
int mock_libnet_lo_ok = 1;

void
libnet_destroy(libnet_t* l)
{
        free(l);
}

#if HAVE_LIBNET_INIT_CONST
#define LIBNET_INIT_CONST const
#else
#define LIBNET_INIT_CONST
#endif

libnet_t*
libnet_init(int injection_type, LIBNET_INIT_CONST char *device, char *err_buf)
{
        UNUSED(injection_type);
        UNUSED(err_buf);
        if (device == NULL) {
                if (mock_libnet_null_ok) {
                        return malloc(sizeof(libnet_t));
                }
                return NULL;
        }
        if (!strcmp(device, "bad")) {
                return NULL;
        }
        if (!strcmp(device, "good")) {
                return malloc(sizeof(libnet_t));
        }
        if (mock_libnet_lo_ok && !strcmp(device, "lo")) {
                return malloc(sizeof(libnet_t));
        }
        return NULL;
}

/* ---- Emacs Variables ----
 * Local Variables:
 * c-basic-offset: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vim: ts=8 sw=8
 */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>