DrvFltIp.h
上传用户:wlquartz
上传日期:2022-03-04
资源大小:89k
文件大小:3k
开发平台:

Visual C++

  1. /*
  2.   DrvFltIp.H
  3.   Author: Jes鷖 Oliva Garc韆
  4.   Last Updated: 06/04/03 18:54
  5.   
  6. */
  7. //
  8. // Define the various device type values.  Note that values used by Microsoft
  9. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  10. // by customers.
  11. //
  12. // Tipo del dispositivo. De 0-32767 reservado por Microsoft.
  13. #define FILE_DEVICE_DRVFLTIP  0x00654322
  14. // Macro para definir IOCTL
  15. #define DRVFLTIP_IOCTL_INDEX  0x830
  16. // Defino los IOCTLs
  17. #define START_IP_HOOK CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX,METHOD_BUFFERED, FILE_ANY_ACCESS)
  18. #define STOP_IP_HOOK CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  19. #define ADD_FILTER CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  20. #define CLEAR_FILTER CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  21. // Estructura para definir una regla de filtrado
  22. typedef struct filter
  23. {
  24. USHORT protocol; // Protocolo
  25. ULONG sourceIp; // Direcci髇 IP fuente
  26. ULONG destinationIp; // Direcci髇 IP destino
  27. ULONG sourceMask; // Mascara de direcci髇 IP fuente
  28. ULONG destinationMask; // Mascara de direcci髇 IP destino
  29. USHORT sourcePort; // Puerto fuente
  30. USHORT destinationPort; // Puerto destino
  31. BOOLEAN drop; // Si TRUE, el paquete sera tirado en caso de coincidencia
  32. }IPFilter, *PIPFilter;
  33. // Estructura para definir la lista enlazada de reglas.
  34. struct filterList
  35. {
  36. IPFilter ipf;
  37. struct filterList *next;
  38. };
  39. // Cabecera IP
  40. typedef struct IPHeader 
  41. {
  42.     UCHAR     iphVerLen;      // Version y longitud cabecera
  43.     UCHAR     ipTOS;          // Tipo de servicio
  44.     USHORT    ipLength;       // Longitud total del datagrama
  45.     USHORT    ipID;       // Identificacion 
  46.     USHORT    ipFlags;       // Flags
  47.     UCHAR     ipTTL;       // TTL
  48.     UCHAR     ipProtocol;   // Protocolo de nivel superior 
  49.     USHORT    ipChecksum;     // Checksum de la cabecera
  50.     ULONG     ipSource;       // Direccion fuente
  51.     ULONG     ipDestination;  // Direccion destino
  52. } IPPacket, *PIPPacket; 
  53. // Cabecera TCP
  54. typedef struct _TCPHeader
  55. {
  56. USHORT sourcePort; // Puerto fuente
  57. USHORT destinationPort; // Puerto destino
  58. ULONG sequenceNumber; // Numero de secuencia
  59. ULONG acknowledgeNumber; // Numero de reconocimiento
  60. UCHAR dataoffset; // Puntero a los datos
  61. UCHAR flags; // Flags
  62. USHORT windows; // Tama駉 de la ventana TCP
  63. USHORT checksum; // Checksum del paquete
  64. USHORT urgentPointer; // Puntero a los datos "urgentes"
  65. } TCPHeader, *PTCPHeader;
  66. // Cabecera UDP
  67. typedef struct _UDPHeader
  68. {
  69. USHORT sourcePort; // Puerto fuente
  70. USHORT destinationPort; // Puerto destino
  71. USHORT len; // Longitud del datagrama
  72. USHORT checksum; // Checksum del datagrama
  73. } UDPHeader, *PUDPHeader;