📄 example1.c
字号:
/** API for wireless cards under Linux** Moustafa A. Youssef - MIND Lab '01** This API works for any driver that supports wireless extensions (provided that the driver works correctly)* For the signal strength measurements from all the access points, only the mwavelan_cs driver works (as far as I know)** */#include "mapi.h"#include <stdio.h>int main(){ char T[255]; int N; float F; wireless_info Info; iwstats Stats; struct iw_quality Qual; if (OpenSocket()< 0){ printf("Error Opening socket to the networking kernel!"); return 0; } /* * Get All network interfaces names */ printf("**** GetNetworkInterfacesNames(T, &N)\n"); GetNetworkInterfacesNames(T, &N); printf("%d Interfaces\n%s", N, T); /* * Get Wireless network interfaces names */ printf("**** GetWirelessInterfacesNames(T, &N)\n"); GetWirelessInterfacesNames(T, &N); printf("%d Wireless Interfaces\n%s", N, T); /* * Get Info on all devices and print it on the screen */ printf("**** PrintDevices()\n"); PrintDevices(); printf("**** PrintInfo(\"eth0\")\n"); PrintInfo("eth0"); /* * Get wireless informations & config from the device driver */ printf("**** GetInterfaceInfo(\"eth0\", &Info)\n"); if (GetInterfaceInfo("eth0", &Info)< 0) printf("Error in GetInterfaceInfo!\n"); else DisplayInfo("eth0", &Info); /* * Get the latest statistics for the current access point */ printf("**** GetCurrentAPStats\n"); if (GetCurrentAPStats("eth0", &Stats)< 0) printf("Error in GetCurrentAPStats!\n"); else DisplayStat("eth0", &Stats); /* * Get Wireless Name */ printf("****** GetWirelessName\n"); if(GetWirelessName("eth0", T)< 0) printf("Error in GetWirelessName!\n"); else printf("%s\n", T); /* * Get Frequency */ printf("**** GetFrequency\n"); if (GetFrequency("eth0", &F)<0) printf("Error in GetFrequency!\n"); else printf("%f\n", F); /* * Get Access Point Address */ printf("******** GetAPAddress\n"); if (GetAPAddress("eth0", T)< 0) printf("Error in GetAPAddress!\n"); else printf("%s\n", T); /* * Get Operation Mode */ printf("******* GetOperationMode\n"); if (GetOperationMode("eth0", &N)< 0) printf("Error in GetOperationMode!\n"); else printf("%d\n", N); printf("Enter a MAC address to spy: "); scanf("%s", T); if (RegisterAddress(T, "eth0")<0) printf("Error registering address (%s)\n", T); if (GetAddressStats("eth0", T, &Qual) >= 0) printf("%d %d %d\n", Qual.qual, Qual.level-0x100, Qual.noise-0x100); else printf("Error getting statistics\n"); CloseSocket(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -