-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathmock_libnet.c
50 lines (45 loc) · 1.03 KB
/
mock_libnet.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#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
*/