1
1
/*
2
2
* capture.c
3
- * (C) 2017 , all rights reserved,
3
+ * (C) 2018 , all rights reserved,
4
4
*
5
5
* This program is free software: you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
@@ -52,11 +52,11 @@ void init_capture(void)
52
52
{
53
53
handle = WinDivertOpen (
54
54
"ip and "
55
- "(outbound and (tcp.DstPort == 80 or "
56
- " tcp.DstPort == 443 or "
57
- " udp .DstPort == 53) or"
58
- " inbound and icmp.Type == 11 and icmp.Code == 0) and "
59
- "ip.DstAddr != 127.0.0.1 " ,
55
+ "!loopback and "
56
+ "(outbound? tcp.DstPort == 80 or"
57
+ " tcp .DstPort == 443 or"
58
+ " udp.DstPort == 53 : "
59
+ " icmp.Type == 11 and icmp.Code == 0) " ,
60
60
WINDIVERT_LAYER_NETWORK , -501 , 0 );
61
61
if (handle == INVALID_HANDLE_VALUE )
62
62
{
@@ -94,8 +94,8 @@ size_t get_packet(uint8_t *buff, size_t len)
94
94
peth_header -> pad2 = 0x0 ;
95
95
peth_header -> proto = htons (ETH_P_IP );
96
96
97
- WinDivertHelperCalcChecksums ((PVOID )(buff + offset ), (UINT )( len - offset ) ,
98
- WINDIVERT_HELPER_NO_REPLACE );
97
+ WinDivertHelperCalcChecksums ((PVOID )(buff + offset ), (UINT )read_len ,
98
+ NULL , 0 );
99
99
100
100
return (size_t )(read_len + offset );
101
101
}
@@ -112,9 +112,11 @@ void inject_packet(uint8_t *buff, size_t len)
112
112
}
113
113
struct pethhdr_s * peth_header = (struct pethhdr_s * )buff ;
114
114
WINDIVERT_ADDRESS addr ;
115
+ memset (& addr , 0 , sizeof (addr ));
115
116
addr .Direction = peth_header -> direction ;
116
117
addr .IfIdx = peth_header -> if_idx ;
117
118
addr .SubIfIdx = peth_header -> sub_if_idx ;
119
+ addr .Impostor = 1 ;
118
120
119
121
len -= offset ;
120
122
buff += offset ;
0 commit comments