-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
46 lines (34 loc) · 796 Bytes
/
main.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
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include "ethernet.h"
#include "ipv4.h"
#include "raw.h"
int raw_socket;
unsigned char buffer[2048];
struct sockaddr_ll saddr;
int main (int arguments, char *argument[])
{
unsigned long int size;
unsigned long int counter;
fd_set sockets;
struct timeval timeout;
char *lines;
unsigned long int temp;
unsigned long int bytes = 0;
raw_socket = raw_init (ETHNAME);
while (1)
{
FD_ZERO (&sockets);
FD_SET (raw_socket, &sockets);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
select (raw_socket + 1, &sockets, NULL, NULL, &timeout);
if (FD_ISSET (raw_socket, &sockets))
{
raw_parse (raw_socket, buffer);
}
}
}