00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <include.h>
00025 #include <src/pcap_file.h>
00026 #include <src/wlan-ng.h>
00027 #include <src/functions.h>
00028 #include <src/crt_io.h>
00029
00030 static char *ID = "$Id: pcap.c,v 1.3 2005/11/03 15:28:53 poggij Exp $";
00031
00032
00033
00034
00035
00036 extern ConfigStruct config;
00037 extern p80211_caphdr_t wlan_header;
00038 extern WINDOW *Sum_WND, *RealTime_WND;
00039
00040 static CaptureArg ca;
00041 static char errbuf[PCAP_ERRBUF_SIZE];
00042
00043 #define STR_MAX 80
00044
00045
00046
00047
00048 int getPacketPCAP(p80211_caphdr_t * wlan_header, UINT8 * buf, int maxlen)
00049 {
00050 struct pcap_pkthdr pktHdr;
00051 u_char *ret;
00052 fd_set rs;
00053
00054 FD_ZERO(&rs);
00055 FD_SET(0, &rs);
00056
00057 warning("before\n");
00058 ret = (u_char *) pcap_next(ca.pcap, &pktHdr);
00059 warning("after\n");
00060
00061
00062 if ((ret) && (pktHdr.len >= 1)) {
00063 #if 1
00064
00065 DumpHexPaquets(RealTime_WND, ret, 0x40);
00066 #endif
00067 memcpy_buff(buf, ret + ca.offset, pktHdr.len + 0x00);
00068
00069
00070 wlan_header->version = 0;
00071 wlan_header->length = 0;
00072 wlan_header->mactime = 0;
00073 wlan_header->hosttime = 0;
00074 wlan_header->phytype = 0;
00075 wlan_header->channel = 0;
00076 wlan_header->datarate = 0;
00077 wlan_header->antenna = 0;
00078 wlan_header->priority = 0;
00079 wlan_header->ssi_type = 0;
00080 wlan_header->ssi_signal = 0;
00081 wlan_header->ssi_noise = 0;
00082 wlan_header->preamble = 0;
00083 wlan_header->encoding = 0;
00084 return pktHdr.len;
00085 } else {
00086 return (0);
00087 }
00088 }
00089
00090 int openPacketPCAP(char *pcap_name)
00091 {
00092 ca.pcap = pcap_open_offline(pcap_name, errbuf);
00093 if (ca.pcap) {
00094 ca.DataLink = pcap_datalink(ca.pcap);
00095 ca.offset = CalculateOffset(ca.DataLink);
00096 return NO_ERROR;
00097 }
00098 return ERROR_CANT_OPEN_PCAP;
00099 }
00100
00101 void closePacketPCAP(void)
00102 {
00103 pcap_close(ca.pcap);
00104 }