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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*
* (C)opyright 1997 Darren Reed. (from tcplog)
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and due credit is given
* to the original author and the contributors.
*/
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
int initdevice(device, sport, tout)
char *device;
int sport, tout;
{
int fd;
if ((fd = socket(AF_DLI, SOCK_RAW, 0)) == -1)
perror("socket");
return fd;
}
/*
* output an IP packet onto a fd opened for /dev/bpf
*/
int sendip(fd, pkt, len)
int fd, len;
char *pkt;
{
if (send(fd, pkt, len, 0) == -1)
{
perror("send");
return -1;
}
return len;
}
char *strdup(str)
char *str;
{
char *s;
if ((s = (char *)malloc(strlen(str) + 1)))
return strcpy(s, str);
return NULL;
}
/*
* (C)opyright 1997 Darren Reed. (from tcplog)
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and due credit is given
* to the original author and the contributors.
*/
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
int initdevice(device, sport, tout)
char *device;
int sport, tout;
{
int fd;
if ((fd = socket(AF_DLI, SOCK_RAW, 0)) == -1)
perror("socket");
return fd;
}
/*
* output an IP packet onto a fd opened for /dev/bpf
*/
int sendip(fd, pkt, len)
int fd, len;
char *pkt;
{
if (send(fd, pkt, len, 0) == -1)
{
perror("send");
return -1;
}
return len;
}
char *strdup(str)
char *str;
{
char *s;
if ((s = (char *)malloc(strlen(str) + 1)))
return strcpy(s, str);
return NULL;
}
|