Naveen Neel / shedskin
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pfhook.h Source File

pfhook.h

00001 /*
00002  * pfhook.h
00003  *
00004  * Packet filter API
00005  *
00006  * This file is part of the w32api package.
00007  *
00008  * Contributors:
00009  *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
00010  *
00011  * THIS SOFTWARE IS NOT COPYRIGHTED
00012  *
00013  * This source code is offered for use in the public domain. You may
00014  * use, modify or distribute it freely.
00015  *
00016  * This code is distributed in the hope that it will be useful but
00017  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00018  * DISCLAIMED. This includes but is not limited to warranties of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00020  *
00021  */
00022 
00023 #ifndef __PFHOOK_H
00024 #define __PFHOOK_H
00025 
00026 #if __GNUC__ >=3
00027 #pragma GCC system_header
00028 #endif
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #include "ntddk.h"
00035 
00036 #define DD_IPFLTRDRVR_DEVICE_NAME         L"\\Device\\IPFILTERDRIVER"
00037 
00038 #define INVALID_PF_IF_INDEX               0xffffffff
00039 #define ZERO_PF_IP_ADDR                   0
00040 
00041 typedef ULONG IPAddr;
00042 
00043 typedef enum _PF_FORWARD_ACTION {
00044     PF_FORWARD = 0,
00045     PF_DROP = 1,
00046     PF_PASS = 2,
00047     PF_ICMP_ON_DROP = 3
00048 } PF_FORWARD_ACTION;
00049 
00050 typedef PF_FORWARD_ACTION STDCALL
00051 (*PacketFilterExtensionPtr)(
00052   /*IN*/ unsigned char  *PacketHeader,
00053   /*IN*/ unsigned char  *Packet, 
00054   /*IN*/ unsigned int  PacketLength, 
00055   /*IN*/ unsigned int  RecvInterfaceIndex, 
00056   /*IN*/ unsigned int  SendInterfaceIndex, 
00057   /*IN*/ IPAddr  RecvLinkNextHop, 
00058   /*IN*/ IPAddr  SendLinkNextHop); 
00059 
00060 typedef struct _PF_SET_EXTENSION_HOOK_INFO {
00061   PacketFilterExtensionPtr  ExtensionPointer; 
00062 } PF_SET_EXTENSION_HOOK_INFO, *PPF_SET_EXTENSION_HOOK_INFO;
00063 
00064 #define FSCTL_IPFLTRDRVR_BASE             FILE_DEVICE_NETWORK
00065 
00066 #define _IPFLTRDRVR_CTL_CODE(function, method, access) \
00067   CTL_CODE(FSCTL_IPFLTRDRVR_BASE, function, method, access)
00068 
00069 #define IOCTL_PF_SET_EXTENSION_POINTER \
00070   _IPFLTRDRVR_CTL_CODE(22, METHOD_BUFFERED, FILE_WRITE_ACCESS)
00071 
00072 #ifdef __cplusplus
00073 }
00074 #endif
00075 
00076 #endif /* __PFHOOK_H */