Go to the source code of this file.
Functions | |
int | selectChannelIPW (char *devname, int channel) |
int | shutCardIPW (char *devname) |
int | openCardIPW (char *devname) |
int | getPacketIPW (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketIPW (char *devname) |
void | closePacketIPW (void) |
int selectChannelIPW | ( | char * | devname, | |
int | channel | |||
) |
Definition at line 44 of file ipw.c.
References debug, NO_ERROR, and STR_MAX.
Referenced by selectChannel().
00045 { 00046 #define STR_MAX 80 00047 char str[STR_MAX]; 00048 int result = NO_ERROR; 00049 00050 //result = IwconfigSetMode(devname, IW_MODE_MONITOR); 00051 //result = IwconfigSetChannel(devname, channel); 00052 snprintf(str, STR_MAX, "iwpriv %s monitor 1 %d 2>/dev/null", 00053 devname, channel); 00054 debug(3, "%s\n", str); 00055 result += system(str); 00056 //return NO_ERROR; 00057 return result; 00058 }
int shutCardIPW | ( | char * | devname | ) |
Definition at line 60 of file ipw.c.
References IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by shutCard().
00061 { 00062 int result = NO_ERROR; 00063 00064 result = IwconfigSetMode(devname, IW_MODE_INFRA); 00065 warning_if_error(result); 00066 result = IfconfigSetFlags(devname, IFF_UP); 00067 warning_if_error(result); 00068 return result; 00069 }
int openCardIPW | ( | char * | devname | ) |
Definition at line 71 of file ipw.c.
References IfconfigSetFlags(), IwconfigSetMode(), NO_ERROR, and warning_if_error().
Referenced by openCard().
00072 { 00073 int result = NO_ERROR; 00074 00075 // Turn on monitor mode 00076 result = IwconfigSetMode(devname, IW_MODE_MONITOR); 00077 warning_if_error(result); 00078 result = IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC); 00079 warning_if_error(result); 00080 return result; 00081 }
int getPacketIPW | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 84 of file ipw.c.
References CaptureArg_t::DataLink, debug, DumpHexPaquets(), FillRadioData(), MAX_BUFFER_SIZE, MAX_OF, memcpy_buff(), MIN_OF, CaptureArg_t::offset, CaptureArg_t::pcap, and RealTime_WND.
Referenced by getPacket().
00085 { 00086 struct pcap_pkthdr pktHdr; 00087 u_char *RadioPacket; 00088 fd_set rs; 00089 00090 FD_ZERO(&rs); 00091 FD_SET(0, &rs); 00092 00093 RadioPacket = (u_char *) pcap_next(ca.pcap, &pktHdr); 00094 if (RadioPacket != NULL) { 00095 #if 0 00096 // Function to dump in hexa the message send or sent to the driver 00097 DumpHexPaquets(RealTime_WND, RadioPacket, 0x40); 00098 #endif 00099 if (ca.DataLink == DLT_IEEE802_11_RADIO) { 00100 // calculate the offset = RadioPacket[2]; 00101 ca.offset = (UINT16) RadioPacket[2]; 00102 debug(3, "DLT_IEEE802_11_RADIO >> ca.offset = %x\n", ca.offset); 00103 } 00104 debug(3, "ca.offset = %x - pktHdr.len = %x\n", ca.offset, pktHdr.len); 00105 // If no problem and packet is enought big (with data) 00106 if (pktHdr.len > MAX_BUFFER_SIZE) { 00107 debug(1, "ERROR : Packet is TOOO BIG size=%d\n", pktHdr.len); 00108 // Sometimes return an enormous empty packet ... 00109 //DumpHexPaquets(RealTime_WND, buf, 0x1B0); 00110 return 0; 00111 } else { 00112 memcpy_buff(buf, (RadioPacket + ca.offset), 00113 MIN_OF((pktHdr.len - ca.offset), maxlen)); 00114 FillRadioData(wlan_header, ca.DataLink, RadioPacket, pktHdr.len); 00115 return MAX_OF(0, (pktHdr.len - ca.offset)); 00116 } 00117 } 00118 return (0); /* Noting to read */ 00119 }
int openPacketIPW | ( | char * | devname | ) |
Definition at line 121 of file ipw.c.
References CalculateOffset(), CaptureArg_t::DataLink, errbuf, ERROR_CANT_OPEN_PCAP, MAX_PACKET_LEN, NO_ERROR, CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by openPacket().
00122 { 00123 ca.pcap = pcap_open_live(devname, MAX_PACKET_LEN, 0, 1000, errbuf); 00124 00125 if (ca.pcap) { 00126 pcap_setnonblock(ca.pcap, 1, errbuf); 00127 ca.DataLink = pcap_datalink(ca.pcap); 00128 ca.offset = CalculateOffset(ca.DataLink); 00129 return NO_ERROR; 00130 } 00131 return ERROR_CANT_OPEN_PCAP; 00132 }
void closePacketIPW | ( | void | ) |