メイン   モジュール   デー タ構造   ファイルリスト   データフィールド   グローバル   関連ページ   注意事項   English

Packet32.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999, 2000
00003  *  Politecnico di Torino.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that: (1) source code distributions
00007  * retain the above copyright notice and this paragraph in its entirety, (2)
00008  * distributions including binary code include the above copyright notice and
00009  * this paragraph in its entirety in the documentation or other materials
00010  * provided with the distribution, and (3) all advertising materials mentioning
00011  * features or use of this software display the following acknowledgement:
00012  * ``This product includes software developed by the Politecnico
00013  * di Torino, and its contributors.'' Neither the name of
00014  * the University nor the names of its contributors may be used to endorse
00015  * or promote products derived from this software without specific prior
00016  * written permission.
00017  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
00018  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020  */
00021 
00033 #ifndef __PACKET32
00034 #define __PACKET32
00035 
00036 #include <winsock2.h>
00037 #include "devioctl.h"
00038 
00039 // Working modes
00040 #define PACKET_MODE_CAPT 0x0 
00041 #define PACKET_MODE_STAT 0x1 
00042 #define PACKET_MODE_DUMP 0x10 
00043 #define PACKET_MODE_STAT_DUMP MODE_DUMP | MODE_STAT 
00044 
00045 // ioctls
00046 #define FILE_DEVICE_PROTOCOL        0x8000
00047 
00048 #define IOCTL_PROTOCOL_STATISTICS   CTL_CODE(FILE_DEVICE_PROTOCOL, 2 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00049 #define IOCTL_PROTOCOL_RESET        CTL_CODE(FILE_DEVICE_PROTOCOL, 3 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00050 #define IOCTL_PROTOCOL_READ         CTL_CODE(FILE_DEVICE_PROTOCOL, 4 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00051 #define IOCTL_PROTOCOL_WRITE        CTL_CODE(FILE_DEVICE_PROTOCOL, 5 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00052 #define IOCTL_PROTOCOL_MACNAME      CTL_CODE(FILE_DEVICE_PROTOCOL, 6 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00053 #define IOCTL_OPEN                  CTL_CODE(FILE_DEVICE_PROTOCOL, 7 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00054 #define IOCTL_CLOSE                 CTL_CODE(FILE_DEVICE_PROTOCOL, 8 , METHOD_BUFFERED, FILE_ANY_ACCESS)
00055 
00056 #define  pBIOCSETBUFFERSIZE 9592        
00057 #define  pBIOCSETF 9030                 
00058 #define  pBIOCGSTATS 9031               
00059 #define  pBIOCSRTIMEOUT 7416            
00060 #define  pBIOCSMODE 7412                
00061 #define  pBIOCSWRITEREP 7413            
00062 #define  pBIOCSMINTOCOPY 7414           
00063 #define  pBIOCSETOID 2147483648         
00064 #define  pBIOCQUERYOID 2147483652       
00065 #define  pATTACHPROCESS 7117            
00066 #define  pDETACHPROCESS 7118            
00067 #define  pBIOCSETDUMPFILENAME 9029      
00068 #define  pBIOCEVNAME 7415               
00069 #define  pBIOCSENDPACKETSNOSYNC 9032    
00070 #define  pBIOCSENDPACKETSSYNC 9033      
00071 #define  pBIOCSETDUMPLIMITS 9034        
00072 #define  pBIOCISDUMPENDED 7411          
00073 
00074 #define  pBIOCSTIMEZONE 7471            
00075 
00076 
00078 #define Packet_ALIGNMENT sizeof(int)
00079 
00080 #define Packet_WORDALIGN(x) (((x)+(Packet_ALIGNMENT-1))&~(Packet_ALIGNMENT-1))
00081 
00087 typedef struct NetType
00088 {
00089     UINT LinkType;  
00090     UINT LinkSpeed; 
00091 }NetType;
00092 
00093 
00094 //some definitions stolen from libpcap
00095 
00096 #ifndef BPF_MAJOR_VERSION
00097 
00103 struct bpf_program {
00104     UINT bf_len;                
00105     struct bpf_insn *bf_insns;  
00106 };
00107 
00113 struct bpf_insn {
00114     USHORT  code;       
00115     UCHAR   jt;         
00116     UCHAR   jf;         
00117     int k;              
00118 };
00119 
00125 struct bpf_stat {
00126     UINT bs_recv;       
00127 
00128 
00129     UINT bs_drop;       
00130 
00131 
00132     UINT ps_ifdrop;     
00133     UINT bs_capt;       
00134 
00135 };
00136 
00142 struct bpf_hdr {
00143     struct timeval  bh_tstamp;  
00144 
00145     UINT    bh_caplen;          
00146 
00147 
00148     UINT    bh_datalen;         
00149     USHORT      bh_hdrlen;      
00150 
00151 
00152 
00153 };
00154 
00162 struct dump_bpf_hdr{
00163     struct timeval  ts;         
00164     UINT            caplen;     
00165 
00166 
00167     UINT            len;        
00168 };
00169 
00170 
00171 #endif
00172 
00173 #define        DOSNAMEPREFIX   TEXT("Packet_")  
00174 #define        MAX_LINK_NAME_LENGTH 64          //< Maximum length of the devices symbolic links
00175 #define        NMAX_PACKET 65535
00176 
00183 typedef struct _ADAPTER  { 
00184     HANDLE hFile;               
00185     CHAR  SymbolicLink[MAX_LINK_NAME_LENGTH]; 
00186     int NumWrites;              
00187 
00188     HANDLE ReadEvent;           
00189 
00190 
00191 
00192 
00193 
00194 
00195     
00196     UINT ReadTimeOut;           
00197 
00198 }  ADAPTER, *LPADAPTER;
00199 
00205 typedef struct _PACKET {  
00206     HANDLE       hEvent;        
00207     OVERLAPPED   OverLapped;    
00208     PVOID        Buffer;        
00209 
00210     UINT         Length;        
00211     DWORD        ulBytesReceived;   
00212 
00213     BOOLEAN      bIoComplete;   
00214 }  PACKET, *LPPACKET;
00215 
00223 struct _PACKET_OID_DATA {
00224     ULONG Oid;                  
00225 
00226     ULONG Length;               
00227     UCHAR Data[1];              
00228 
00229 }; 
00230 typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA;
00231 
00238 typedef struct npf_if_addr {
00239     struct sockaddr IPAddress;  
00240     struct sockaddr SubnetMask; 
00241     struct sockaddr Broadcast;  
00242 }npf_if_addr;
00243 
00244 #ifdef __cplusplus
00245 extern "C" {
00246 #endif
00247 
00252 //---------------------------------------------------------------------------
00253 // FUNCTIONS
00254 //---------------------------------------------------------------------------
00255 
00256 PCHAR PacketGetVersion();
00257 BOOLEAN PacketSetMinToCopy(LPADAPTER AdapterObject,int nbytes);
00258 BOOLEAN PacketSetNumWrites(LPADAPTER AdapterObject,int nwrites);
00259 BOOLEAN PacketSetMode(LPADAPTER AdapterObject,int mode);
00260 BOOLEAN PacketSetReadTimeout(LPADAPTER AdapterObject,int timeout);
00261 BOOLEAN PacketSetBpf(LPADAPTER AdapterObject,struct bpf_program *fp);
00262 BOOLEAN PacketGetStats(LPADAPTER AdapterObject,struct bpf_stat *s);
00263 BOOLEAN PacketGetStatsEx(LPADAPTER AdapterObject,struct bpf_stat *s);
00264 BOOLEAN PacketSetBuff(LPADAPTER AdapterObject,int dim);
00265 BOOLEAN PacketGetNetType (LPADAPTER AdapterObject,NetType *type);
00266 LPADAPTER PacketOpenAdapter(LPTSTR AdapterName);
00267 BOOLEAN PacketSendPacket(LPADAPTER AdapterObject,LPPACKET pPacket,BOOLEAN Sync);
00268 INT PacketSendPackets(LPADAPTER AdapterObject,PVOID PacketBuff,ULONG Size, BOOLEAN Sync);
00269 LPPACKET PacketAllocatePacket(void);
00270 VOID PacketInitPacket(LPPACKET lpPacket,PVOID  Buffer,UINT  Length);
00271 VOID PacketFreePacket(LPPACKET lpPacket);
00272 BOOLEAN PacketReceivePacket(LPADAPTER AdapterObject,LPPACKET lpPacket,BOOLEAN Sync);
00273 BOOLEAN PacketSetHwFilter(LPADAPTER AdapterObject,ULONG Filter);
00274 BOOLEAN PacketGetAdapterNames(PTSTR pStr,PULONG  BufferSize);
00275 BOOLEAN PacketGetNetInfo(LPTSTR AdapterName, PULONG netp, PULONG maskp);
00276 BOOLEAN PacketGetNetInfoEx(LPTSTR AdapterName, npf_if_addr* buffer, PLONG NEntries);
00277 BOOLEAN PacketRequest(LPADAPTER  AdapterObject,BOOLEAN Set,PPACKET_OID_DATA  OidData);
00278 HANDLE PacketGetReadEvent(LPADAPTER AdapterObject);
00279 BOOLEAN PacketSetDumpName(LPADAPTER AdapterObject, void *name, int len);
00280 BOOLEAN PacketSetDumpLimits(LPADAPTER AdapterObject, UINT maxfilesize, UINT maxnpacks);
00281 BOOLEAN PacketIsDumpEnded(LPADAPTER AdapterObject, BOOLEAN sync);
00282 BOOL PacketStopDriver();
00283 VOID PacketCloseAdapter(LPADAPTER lpAdapter);
00284 
00285 #ifdef __cplusplus
00286 }
00287 #endif 
00288 
00289 #endif //__PACKET32

documentation. Copyright (c)2002-2003 Politecnico di Torino.
2005 translated by Telebusiness,Inc.
 All rights reserved.