-
Notifications
You must be signed in to change notification settings - Fork 1
/
OLD_CODE
52 lines (39 loc) · 1.34 KB
/
OLD_CODE
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
/*
if( (read_bytes = read( bpf, bpf_buf, buf_len ) ) > 0 )
{
printf( "- Read %i bytes\n", read_bytes );
// process first packet
// ...
sum = bpf_buf->bh_hdrlen + bpf_buf->bh_caplen;
int i = 1;
printf( "- 1 <--> sum = %i\n", sum );
while( sum < read_bytes )
{
i++;
bpf_packet = (bpf_hdr*)((char*) bpf_buf + BPF_WORDALIGN( bpf_buf->bh_hdrlen + bpf_buf->bh_caplen ));
sum += bpf_buf->bh_hdrlen + bpf_buf->bh_caplen;
printf( "- %i <--> sum = %i\n", i, sum );
}
}
*/
/*
// Read from the BPF device until data arrives
if( read( bpf, bpf_buf, buf_len ) > 0 )
{
frame = (ethernet_frame*) ( (char*) bpf_buf + bpf_buf->bh_hdrlen);
// a packet from the server (client1)
if( memcmp( frame->src_addr, poisoned_mac, 6 ) == 0 )
{
memcpy( frame->dest_addr, original_mac, 6 );
write( bpf, frame, bpf_buf->bh_caplen );
write( log, (char*)bpf_buf + bpf_buf->bh_hdrlen, bpf_buf->bh_caplen );
}
// a packet from the client (client2 )
else if( memcmp( frame->src_addr, original_mac, 6 ) == 0 )
{
memcpy( frame->dest_addr, poisoned_mac, 6 );
write( bpf, frame, bpf_buf->bh_caplen );
write( log, (char*)bpf_buf + bpf_buf->bh_hdrlen, bpf_buf->bh_caplen );
}
}
*/