#include <include.h>
#include <src/hostap.h>
#include <src/crt_io.h>
#include <src/functions.h>
Go to the source code of this file.
Functions | |
int | selectChannelHOSTAP (char *devname, int channel) |
int | shutCardHOSTAP (char *devname) |
int | openCardHOSTAP (char *devname) |
int | getPacketHOSTAP (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketHOSTAP (char *devname) |
void | closePacketHOSTAP (void) |
Variables | |
static char * | ID = "$Id: hostap.c 174 2007-07-25 13:20:29Z poggij $" |
UINT8 | SingleChannel |
UINT8 | TypeOfCard |
static CaptureArg | ca |
static char | errbuf [PCAP_ERRBUF_SIZE] |
static UINT8 | wlan_payload [4096] |
int selectChannelHOSTAP | ( | char * | devname, | |
int | channel | |||
) |
Definition at line 47 of file hostap.c.
References IwconfigSetChannel(), and NO_ERROR.
Referenced by selectChannel().
00048 { 00049 int result = NO_ERROR; 00050 00051 result = IwconfigSetChannel(devname, channel); 00052 00053 //return result; 00054 // No error return, because it's possible to change to a forbidden channel 00055 // So we don't wand that the program stop because of this restriction 00056 return NO_ERROR; 00057 }
int shutCardHOSTAP | ( | char * | devname | ) |
Definition at line 59 of file hostap.c.
References IfconfigSetFlags(), IwconfigSetChannel(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by shutCard().
00060 { 00061 int result = NO_ERROR; 00062 00063 // Turn off monitor mode 00064 result = IwconfigSetMode(devname, IW_MODE_INFRA); 00065 warning_if_error(result); 00066 result = IwconfigSetChannel(devname, 11); 00067 warning_if_error(result); 00068 result = IfconfigSetFlags(devname, IFF_UP); 00069 warning_if_error(result); 00070 00071 return result; 00072 }
int openCardHOSTAP | ( | char * | devname | ) |
Definition at line 74 of file hostap.c.
References debug, IfconfigSetFlags(), IwconfigSetChannel(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by openCard().
00075 { 00076 char str[80]; 00077 int result = NO_ERROR; 00078 00079 // Turn on monitor mode 00080 sprintf(str, "prism2_param %s monitor_type 1", devname); 00081 debug(3, "%s\n", str); 00082 result += system(str); 00083 00084 result = IwconfigSetMode(devname, IW_MODE_MONITOR); 00085 warning_if_error(result); 00086 result = IwconfigSetChannel(devname, 1); 00087 warning_if_error(result); 00088 result = IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC); 00089 warning_if_error(result); 00090 00091 return result; 00092 }
int getPacketHOSTAP | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 97 of file hostap.c.
References CaptureArg_t::DataLink, debug, FillRadioData(), MAX_BUFFER_SIZE, MAX_OF, memcpy_buff(), MIN_OF, CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by getPacket().
00098 { 00099 struct pcap_pkthdr pktHdr; 00100 u_char *RadioPacket; 00101 fd_set rs; 00102 00103 FD_ZERO(&rs); 00104 FD_SET(0, &rs); 00105 00106 RadioPacket = (u_char *) pcap_next(ca.pcap, &pktHdr); 00107 00108 if (RadioPacket != NULL) { 00109 // If no problem and packet is enought big (with data) 00110 if (pktHdr.len >= sizeof(p80211msg_lnxind_wlansniffrm_t)) { 00111 if (pktHdr.len > MAX_BUFFER_SIZE) { 00112 debug(1, "ERROR : Packet is TOOO BIG size=%d\n", pktHdr.len); 00113 // Sometimes Wlan-NG return an enormous empty packet ... 00114 //DumpHexPaquets(RealTime_WND, buf, 0x1B0); 00115 return 0; 00116 } else { 00117 FillRadioData(wlan_header, ca.DataLink, RadioPacket, pktHdr.len); 00118 memcpy_buff(buf, (RadioPacket + ca.offset), 00119 MIN_OF((pktHdr.len - ca.offset), maxlen)); 00120 return MAX_OF(0, 00121 (pktHdr.len - 00122 sizeof(p80211msg_lnxind_wlansniffrm_t))); 00123 } 00124 } 00125 } 00126 return (0); /* Noting to read */ 00127 }
int openPacketHOSTAP | ( | char * | devname | ) |
Definition at line 129 of file hostap.c.
References CalculateOffset(), CaptureArg_t::DataLink, errbuf, ERROR_CANT_OPEN_PCAP, NO_ERROR, CaptureArg_t::offset, CaptureArg_t::pcap, TRUE, and warning().
Referenced by openPacket().
00130 { 00131 ca.pcap = pcap_open_live(devname, 3000, TRUE, 1000, errbuf); 00132 if (ca.pcap) { 00133 pcap_setnonblock(ca.pcap, 1, errbuf); 00134 ca.DataLink = pcap_datalink(ca.pcap); 00135 ca.offset = CalculateOffset(ca.DataLink); 00136 return NO_ERROR; 00137 } else { 00138 warning("ERROR when pcap_open_live : %s\n", errbuf); 00139 } 00140 return ERROR_CANT_OPEN_PCAP; 00141 }
void closePacketHOSTAP | ( | void | ) |
Definition at line 143 of file hostap.c.
References CaptureArg_t::pcap.
Referenced by closePacket().
char* ID = "$Id: hostap.c 174 2007-07-25 13:20:29Z poggij $" [static] |
CaptureArg ca [static] |
UINT8 wlan_payload[4096] [static] |