1 /* Copyright (C) 2018 Open Information Security Foundation 2 * 3 * You can copy, redistribute or modify this Program under the terms of 4 * the GNU General Public License version 2 as published by the Free 5 * Software Foundation. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * version 2 along with this program; if not, write to the Free Software 14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 15 * 02110-1301, USA. 16 */ 17 18 /** 19 * 20 * \file 21 * 22 * \author Jacob Masen-Smith <jacob@evengx.com> 23 * 24 */ 25 26 #ifndef __SOURCE_WINDIVERT_H__ 27 #define __SOURCE_WINDIVERT_H__ 28 29 #ifdef WINDIVERT 30 31 #include "windivert.h" 32 33 #define WINDIVERT_FILTER_MAXLEN 128 /* from windivert_device.h */ 34 35 typedef void *WinDivertHandle; 36 37 /** 38 * \brief WinDivertQueueVars is the queue configuration and other miscellaneous 39 * information about the specific queue/filter. 40 * 41 * see https://reqrypt.org/windivert-doc.html#divert_open for more info 42 */ 43 typedef struct WinDivertQueueVars_ 44 { 45 int queue_num; 46 47 /* see https://reqrypt.org/windivert-doc.html#filter_language */ 48 char filter_str[WINDIVERT_FILTER_MAXLEN + 1]; 49 WINDIVERT_LAYER layer; 50 int16_t priority; 51 uint64_t flags; 52 53 WinDivertHandle filter_handle; 54 /* only needed for setup/teardown; Recv/Send are internally synchronized */ 55 SCMutex filter_init_mutex; 56 57 /* counters */ 58 uint32_t pkts; 59 uint64_t bytes; 60 uint32_t errs; 61 uint32_t accepted; 62 uint32_t dropped; 63 uint32_t replaced; 64 SCMutex counters_mutex; 65 } WinDivertQueueVars; 66 67 typedef struct WinDivertPacketVars_ 68 { 69 int thread_num; 70 71 WINDIVERT_ADDRESS addr; 72 bool verdicted; 73 } WinDivertPacketVars; 74 75 int WinDivertRegisterQueue(bool forward, char *filter_str); 76 void *WinDivertGetThread(int thread); 77 void *WinDivertGetQueue(int queue); 78 79 void SourceWinDivertRegisterTests(void); 80 81 #endif /* WINDIVERT */ 82 #endif /* __SOURCE_WINDIVERT_H__ */