Annotation of embedaddon/arping/src/mock_libnet.c, revision 1.1
1.1 ! misho 1: #include<libnet.h>
! 2: #include"config.h"
! 3:
! 4: #define UNUSED(x) (void)(x)
! 5: int mock_libnet_null_ok = 1;
! 6: int mock_libnet_lo_ok = 1;
! 7:
! 8: void
! 9: libnet_destroy(libnet_t* l)
! 10: {
! 11: free(l);
! 12: }
! 13:
! 14: #if HAVE_LIBNET_INIT_CONST
! 15: #define LIBNET_INIT_CONST const
! 16: #else
! 17: #define LIBNET_INIT_CONST
! 18: #endif
! 19:
! 20: libnet_t*
! 21: libnet_init(int injection_type, LIBNET_INIT_CONST char *device, char *err_buf)
! 22: {
! 23: UNUSED(injection_type);
! 24: UNUSED(err_buf);
! 25: if (device == NULL) {
! 26: if (mock_libnet_null_ok) {
! 27: return malloc(sizeof(libnet_t));
! 28: }
! 29: return NULL;
! 30: }
! 31: if (!strcmp(device, "bad")) {
! 32: return NULL;
! 33: }
! 34: if (!strcmp(device, "good")) {
! 35: return malloc(sizeof(libnet_t));
! 36: }
! 37: if (mock_libnet_lo_ok && !strcmp(device, "lo")) {
! 38: return malloc(sizeof(libnet_t));
! 39: }
! 40: return NULL;
! 41: }
! 42:
! 43: /* ---- Emacs Variables ----
! 44: * Local Variables:
! 45: * c-basic-offset: 8
! 46: * indent-tabs-mode: nil
! 47: * End:
! 48: *
! 49: * vim: ts=8 sw=8
! 50: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>