Go to the source code of this file.
Defines | |
#define | SIOC80211IFCREATE (SIOCDEVPRIVATE+7) |
#define | SIOC80211IFDESTROY (SIOCDEVPRIVATE+8) |
#define | IEEE80211_CLONE_BSSID 0x0001 |
#define | IEEE80211_NO_STABEACONS 0x0002 |
#define | IEEE80211_M_STA 1 |
#define | IEEE80211_M_IBSS 0 |
#define | IEEE80211_M_MASTER 6 |
#define | IEEE80211_M_MONITOR 8 |
Functions | |
int | selectChannelMADWIFI_NG (char *devname, int channel) |
int | shutCardMADWIFI_NG (char *devname) |
int | openCardMADWIFI_NG (char *devname) |
int | getPacketMADWIFI_NG (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen) |
int | openPacketMADWIFI_NG (char *devname) |
void | closePacketMADWIFI_NG (void) |
#define SIOC80211IFCREATE (SIOCDEVPRIVATE+7) |
#define SIOC80211IFDESTROY (SIOCDEVPRIVATE+8) |
#define IEEE80211_CLONE_BSSID 0x0001 |
#define IEEE80211_NO_STABEACONS 0x0002 |
Definition at line 35 of file madwifi-ng.h.
#define IEEE80211_M_STA 1 |
Definition at line 37 of file madwifi-ng.h.
#define IEEE80211_M_IBSS 0 |
Definition at line 38 of file madwifi-ng.h.
#define IEEE80211_M_MASTER 6 |
Definition at line 39 of file madwifi-ng.h.
#define IEEE80211_M_MONITOR 8 |
int selectChannelMADWIFI_NG | ( | char * | devname, | |
int | channel | |||
) |
Definition at line 59 of file madwifi-ng.c.
References IwconfigSetChannel().
Referenced by selectChannel().
00060 { 00061 int result = 0; 00062 00063 result = IwconfigSetChannel(devname, channel); 00064 00065 //return NO_ERROR; // XXX no error if channel is forbidden 00066 return result; 00067 }
int shutCardMADWIFI_NG | ( | char * | devname | ) |
Definition at line 69 of file madwifi-ng.c.
References DestroyVAP_MADWIFI_NG().
Referenced by shutCard().
00070 { 00071 // Destroy the created VAP 00072 return (DestroyVAP_MADWIFI_NG(devname)); 00073 }
int openCardMADWIFI_NG | ( | char * | devname | ) |
Definition at line 133 of file madwifi-ng.c.
References debug, DestroyVAP_MADWIFI_NG(), devname1, devname2, findAvailableIF(), IEEE80211_CLONE_BSSID, IEEE80211_M_MONITOR, IfconfigSetFlags(), MADWIFING_ERROR_CANT_CREATE_SOCKET, MADWIFING_ERROR_NO_DEVICE_PRESENT, MADWIFING_ERROR_NO_INTERFACE_AVAILABLE, MADWIFING_ERROR_NO_VAP_CREATED, SIOC80211IFCREATE, STR_MAX, and warning().
Referenced by openCard().
00134 { 00135 char dirpath[STR_MAX]; 00136 DIR *devdir; 00137 struct dirent *devfile; 00138 00139 struct ieee80211_clone_params { 00140 char icp_name[IFNAMSIZ]; 00141 UINT16 icp_opmode; 00142 UINT16 icp_flags; 00143 }; 00144 00145 struct ieee80211_clone_params cp; 00146 struct ifreq ifr; 00147 int sock; 00148 00149 // -- Search if /sys arborescence is available 00150 snprintf(dirpath, STR_MAX, "/sys/class/net/%s/device/", devname); 00151 if ((devdir = opendir(dirpath)) == NULL) { 00152 warning("Device %s is not present !!!\n", devname); 00153 return MADWIFING_ERROR_NO_DEVICE_PRESENT; 00154 } 00155 // -- Determine ath and wifi interface number 00156 // and destroy all VAP if exists 00157 while ((devfile = readdir(devdir)) != NULL) { 00158 if (strncmp("net:ath", devfile->d_name, 7) == 0) { 00159 strncpy(devname1, devfile->d_name + 4, IFNAMSIZ); 00160 #if 0 00161 DestroyVAP_MADWIFI_NG(devname1); 00162 debug(3, "Interface %s is destroyed\n", devname1); 00163 #else 00164 debug(3, "Interface %s is skiped\n", devname1); 00165 #endif 00166 } 00167 00168 if (strncmp("net:wifi", devfile->d_name, 8) == 0) { 00169 strncpy(devname2, devfile->d_name + 4, IFNAMSIZ); 00170 debug(3, "Found a good Interface %s\n", devname2); 00171 } 00172 } 00173 closedir(devdir); 00174 00175 // Now all is clean 00176 // We can create a VAP 00177 00178 // First Step : Find a ath? interface available 00179 if (findAvailableIF(devname1) != 0) { 00180 warning("No available VAP found :-(\n"); 00181 return MADWIFING_ERROR_NO_INTERFACE_AVAILABLE; 00182 } 00183 // Master interface is now devname2 00184 strncpy(devname, devname2, IFNAMSIZ); 00185 debug(3, 00186 "We now use %s as the master insterface for madwifi-ng driver\n", 00187 devname); 00188 00189 // Second Step Create VAP and put it in MONITOR mode 00190 memset(&cp, 0, sizeof(cp)); 00191 strncpy(cp.icp_name, devname1, IFNAMSIZ); 00192 cp.icp_opmode = IEEE80211_M_MONITOR; 00193 cp.icp_flags = IEEE80211_CLONE_BSSID; 00194 00195 memset(&ifr, 0, sizeof(ifr)); 00196 strncpy(ifr.ifr_name, devname2, IFNAMSIZ); 00197 ifr.ifr_data = (caddr_t) & cp; 00198 00199 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 00200 warning("Failed to create socket to madwifi: %s\n", strerror(errno)); 00201 return MADWIFING_ERROR_CANT_CREATE_SOCKET; 00202 } 00203 00204 if (ioctl(sock, SIOC80211IFCREATE, &ifr) < 0) { 00205 warning("Unable to create VAP: %s\n", strerror(errno)); 00206 close(sock); 00207 return MADWIFING_ERROR_NO_VAP_CREATED; 00208 } 00209 00210 strncpy(devname1, ifr.ifr_name, IFNAMSIZ); 00211 debug(3, "I create a VAP in monitor mode in %s\n", ifr.ifr_name); 00212 close(sock); 00213 00214 // Slave interface and working interface is now the same 00215 strncpy(devname, devname1, IFNAMSIZ); 00216 debug(3, "We now use %s as the slave insterface for madwifi-ng driver\n", 00217 devname1); 00218 00219 // last step : UP the interface 00220 return IfconfigSetFlags(devname, IFF_UP); 00221 }
int getPacketMADWIFI_NG | ( | p80211_caphdr_t * | wlan_header, | |
UINT8 * | buf, | |||
int | maxlen | |||
) |
Definition at line 227 of file madwifi-ng.c.
References CaptureArg_t::DataLink, debug, FillRadioData(), MAX_BUFFER_SIZE, MAX_OF, memcpy_buff(), MIN_OF, and CaptureArg_t::pcap.
Referenced by getPacket().
00228 { 00229 struct pcap_pkthdr pktHdr; 00230 u_char *RadioPacket; 00231 fd_set rs; 00232 int real_size_of_headers = 0; 00233 00234 FD_ZERO(&rs); 00235 FD_SET(0, &rs); 00236 00237 RadioPacket = (u_char *) pcap_next(ca.pcap, &pktHdr); 00238 00239 if (RadioPacket != NULL) { 00240 // If no problem and packet is enought big (with data) 00241 if (pktHdr.len >= sizeof(p80211msg_lnxind_wlansniffrm_t)) { 00242 if (pktHdr.len > MAX_BUFFER_SIZE) { 00243 debug(1, "ERROR : Packet is TOOO BIG size=%d\n", pktHdr.len); 00244 //DumpHexPaquets(RealTime_WND, buf, 0x1B0); 00245 return 0; 00246 } else { 00247 real_size_of_headers = FillRadioData(wlan_header, ca.DataLink, RadioPacket, pktHdr.len); 00248 memcpy_buff(buf, (RadioPacket + real_size_of_headers), MIN_OF((pktHdr.len - real_size_of_headers), maxlen)); 00249 return MAX_OF(0, (pktHdr.len - real_size_of_headers)); 00250 } 00251 } 00252 } 00253 return (0); /* Noting to read */ 00254 }
int openPacketMADWIFI_NG | ( | char * | devname | ) |
Definition at line 256 of file madwifi-ng.c.
References CalculateOffset(), CaptureArg_t::DataLink, errbuf, ERROR_CANT_OPEN_PCAP, NO_ERROR, CaptureArg_t::offset, and CaptureArg_t::pcap.
Referenced by openPacket().
00257 { 00258 ca.pcap = pcap_open_live(devname, 3000, 1, 0, errbuf); 00259 if (ca.pcap) { 00260 pcap_setnonblock(ca.pcap, 1, errbuf); 00261 ca.DataLink = pcap_datalink(ca.pcap); 00262 ca.offset = CalculateOffset(ca.DataLink); 00263 return NO_ERROR; 00264 } 00265 return ERROR_CANT_OPEN_PCAP; 00266 }
void closePacketMADWIFI_NG | ( | void | ) |
Definition at line 268 of file madwifi-ng.c.
References CaptureArg_t::pcap.
Referenced by closePacket().