1 /* 2 * pfhook.h 3 * 4 * Packet filter API 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #ifndef __PFHOOK_H 24 #define __PFHOOK_H 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #define DD_IPFLTRDRVR_DEVICE_NAME L"\\Device\\IPFILTERDRIVER" 31 32 #define INVALID_PF_IF_INDEX 0xffffffff 33 #define ZERO_PF_IP_ADDR 0 34 35 typedef ULONG IPAddr; 36 37 typedef enum _PF_FORWARD_ACTION { 38 PF_FORWARD = 0, 39 PF_DROP = 1, 40 PF_PASS = 2, 41 PF_ICMP_ON_DROP = 3 42 } PF_FORWARD_ACTION; 43 44 typedef PF_FORWARD_ACTION 45 (NTAPI *PacketFilterExtensionPtr)( 46 IN unsigned char *PacketHeader, 47 IN unsigned char *Packet, 48 IN unsigned int PacketLength, 49 IN unsigned int RecvInterfaceIndex, 50 IN unsigned int SendInterfaceIndex, 51 IN IPAddr RecvLinkNextHop, 52 IN IPAddr SendLinkNextHop); 53 54 typedef struct _PF_SET_EXTENSION_HOOK_INFO { 55 PacketFilterExtensionPtr ExtensionPointer; 56 } PF_SET_EXTENSION_HOOK_INFO, *PPF_SET_EXTENSION_HOOK_INFO; 57 58 #define FSCTL_IPFLTRDRVR_BASE FILE_DEVICE_NETWORK 59 60 #define _IPFLTRDRVR_CTL_CODE(function, method, access) \ 61 CTL_CODE(FSCTL_IPFLTRDRVR_BASE, function, method, access) 62 63 #define IOCTL_PF_SET_EXTENSION_POINTER \ 64 _IPFLTRDRVR_CTL_CODE(22, METHOD_BUFFERED, FILE_WRITE_ACCESS) 65 66 #ifdef __cplusplus 67 } 68 #endif 69 70 #endif /* __PFHOOK_H */ 71