11/*
22 * capture.c
3- * (C) 2017 , all rights reserved,
3+ * (C) 2018 , all rights reserved,
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
@@ -52,11 +52,11 @@ void init_capture(void)
5252{
5353 handle = WinDivertOpen (
5454 "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) " ,
6060 WINDIVERT_LAYER_NETWORK , -501 , 0 );
6161 if (handle == INVALID_HANDLE_VALUE )
6262 {
@@ -94,8 +94,8 @@ size_t get_packet(uint8_t *buff, size_t len)
9494 peth_header -> pad2 = 0x0 ;
9595 peth_header -> proto = htons (ETH_P_IP );
9696
97- WinDivertHelperCalcChecksums ((PVOID )(buff + offset ), (UINT )( len - offset ) ,
98- WINDIVERT_HELPER_NO_REPLACE );
97+ WinDivertHelperCalcChecksums ((PVOID )(buff + offset ), (UINT )read_len ,
98+ NULL , 0 );
9999
100100 return (size_t )(read_len + offset );
101101}
@@ -112,9 +112,11 @@ void inject_packet(uint8_t *buff, size_t len)
112112 }
113113 struct pethhdr_s * peth_header = (struct pethhdr_s * )buff ;
114114 WINDIVERT_ADDRESS addr ;
115+ memset (& addr , 0 , sizeof (addr ));
115116 addr .Direction = peth_header -> direction ;
116117 addr .IfIdx = peth_header -> if_idx ;
117118 addr .SubIfIdx = peth_header -> sub_if_idx ;
119+ addr .Impostor = 1 ;
118120
119121 len -= offset ;
120122 buff += offset ;
0 commit comments