Update for vaps:
o do not force monitor mode; the wlanX ifnet must be an ahdemo mode vap o move channel change work before marking ifnet up to avoid churning the state machine o change default ifnet name to "wlan0" Approved by: re (kensmith)
This commit is contained in:
parent
671d3b45e2
commit
33f3a67bc1
@ -275,8 +275,13 @@ void set_chan(int c) {
|
|||||||
void setup_if(char *dev) {
|
void setup_if(char *dev) {
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
struct ifmediareq ifmr;
|
|
||||||
int *mwords;
|
// set chan
|
||||||
|
memset(&chaninfo.ireq, 0, sizeof(chaninfo.ireq));
|
||||||
|
strcpy(chaninfo.ireq.i_name, dev);
|
||||||
|
chaninfo.ireq.i_type = IEEE80211_IOC_CHANNEL;
|
||||||
|
|
||||||
|
set_chan(1);
|
||||||
|
|
||||||
// set iface up and promisc
|
// set iface up and promisc
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
@ -293,39 +298,6 @@ void setup_if(char *dev) {
|
|||||||
ifr.ifr_flagshigh = flags >> 16;
|
ifr.ifr_flagshigh = flags >> 16;
|
||||||
if (ioctl(ioctl_s, SIOCSIFFLAGS, &ifr) == -1)
|
if (ioctl(ioctl_s, SIOCSIFFLAGS, &ifr) == -1)
|
||||||
die(1, "ioctl(SIOCSIFFLAGS)");
|
die(1, "ioctl(SIOCSIFFLAGS)");
|
||||||
|
|
||||||
// set monitor mode
|
|
||||||
memset(&ifmr, 0, sizeof(ifmr));
|
|
||||||
strcpy(ifmr.ifm_name, dev);
|
|
||||||
if (ioctl(ioctl_s, SIOCGIFMEDIA, &ifmr) == -1)
|
|
||||||
die(1, "ioctl(SIOCGIFMEDIA)");
|
|
||||||
|
|
||||||
if (ifmr.ifm_count == 0)
|
|
||||||
die(0, "0 media thinggies...\n");
|
|
||||||
|
|
||||||
mwords = (int *)malloc(ifmr.ifm_count * sizeof(int));
|
|
||||||
if (!mwords)
|
|
||||||
die(1, "malloc()");
|
|
||||||
|
|
||||||
ifmr.ifm_ulist = mwords;
|
|
||||||
|
|
||||||
if (ioctl(ioctl_s, SIOCGIFMEDIA, &ifmr) == -1)
|
|
||||||
die(1, "ioctl(SIOCGIFMEDIA)");
|
|
||||||
|
|
||||||
free(mwords);
|
|
||||||
|
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
|
||||||
strcpy(ifr.ifr_name, dev);
|
|
||||||
ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR;
|
|
||||||
if (ioctl(ioctl_s, SIOCSIFMEDIA, &ifr) == -1)
|
|
||||||
die(1, "ioctl(SIOCSIFMEDIA)");
|
|
||||||
|
|
||||||
// set chan
|
|
||||||
memset(&chaninfo.ireq, 0, sizeof(chaninfo.ireq));
|
|
||||||
strcpy(chaninfo.ireq.i_name, dev);
|
|
||||||
chaninfo.ireq.i_type = IEEE80211_IOC_CHANNEL;
|
|
||||||
|
|
||||||
set_chan(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_bpf(char *dev, int dlt) {
|
void open_bpf(char *dev, int dlt) {
|
||||||
|
@ -4,7 +4,7 @@ This is a collection of tools that use raw 802.11 packet injection.
|
|||||||
None of the tools configure the interface, so be sure to run something
|
None of the tools configure the interface, so be sure to run something
|
||||||
like:
|
like:
|
||||||
|
|
||||||
ifconfig ath0 channel 7 mediaopt monitor promisc up
|
ifconfig wlan create wlandev ath0 wlanmode ahdemo channel 7 promisc up
|
||||||
|
|
||||||
beforehand. The following tools are found here:
|
beforehand. The following tools are found here:
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ void next_event(struct params *p)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *iface = "ath0";
|
char *iface = "wlan0";
|
||||||
char *tap = "tap0";
|
char *tap = "tap0";
|
||||||
struct params p;
|
struct params p;
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -710,7 +710,7 @@ int main(int argc, char *argv[])
|
|||||||
char mac[] = { 0x00, 0x00, 0xde, 0xfa, 0xce, 0xd };
|
char mac[] = { 0x00, 0x00, 0xde, 0xfa, 0xce, 0xd };
|
||||||
int ch;
|
int ch;
|
||||||
struct params p;
|
struct params p;
|
||||||
char *iface = "ath0";
|
char *iface = "wlan0";
|
||||||
char *tap = "tap0";
|
char *tap = "tap0";
|
||||||
int timeout = 50*1000;
|
int timeout = 50*1000;
|
||||||
struct timeval start;
|
struct timeval start;
|
||||||
|
@ -421,7 +421,7 @@ void usage(char *name)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct params p;
|
struct params p;
|
||||||
char *iface = "ath0";
|
char *iface = "wlan0";
|
||||||
char *tap = "tap0";
|
char *tap = "tap0";
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ void transmit(struct params *p)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct params p;
|
struct params p;
|
||||||
char *iface = "ath0";
|
char *iface = "wlan0";
|
||||||
char *tap = "tap0";
|
char *tap = "tap0";
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ void usage(char *name)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct params p;
|
struct params p;
|
||||||
char *iface = "ath0";
|
char *iface = "wlan0";
|
||||||
char *tap = "tap0";
|
char *tap = "tap0";
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
|
@ -384,6 +384,15 @@ void setup_if(char *dev) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set chan
|
||||||
|
memset(&chaninfo.ireq, 0, sizeof(chaninfo.ireq));
|
||||||
|
strcpy(chaninfo.ireq.i_name, dev);
|
||||||
|
chaninfo.ireq.i_type = IEEE80211_IOC_CHANNEL;
|
||||||
|
|
||||||
|
chaninfo.chan = 0;
|
||||||
|
chaninfo.s = s;
|
||||||
|
set_chan(1);
|
||||||
|
|
||||||
// set iface up and promisc
|
// set iface up and promisc
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
strcpy(ifr.ifr_name, dev);
|
strcpy(ifr.ifr_name, dev);
|
||||||
@ -404,49 +413,6 @@ void setup_if(char *dev) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set monitor mode
|
|
||||||
memset(&ifmr, 0, sizeof(ifmr));
|
|
||||||
strcpy(ifmr.ifm_name, dev);
|
|
||||||
if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) {
|
|
||||||
perror("ioctl(SIOCGIFMEDIA)");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ifmr.ifm_count == 0) {
|
|
||||||
time_print("0 media thinggies...\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
mwords = (int *)malloc(ifmr.ifm_count * sizeof(int));
|
|
||||||
if (!mwords) {
|
|
||||||
perror("malloc()");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
ifmr.ifm_ulist = mwords;
|
|
||||||
|
|
||||||
if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) {
|
|
||||||
perror("ioctl(SIOCGIFMEDIA)");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
free(mwords);
|
|
||||||
|
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
|
||||||
strcpy(ifr.ifr_name, dev);
|
|
||||||
ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR;
|
|
||||||
if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) {
|
|
||||||
perror("ioctl(SIOCSIFMEDIA)");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set chan
|
|
||||||
memset(&chaninfo.ireq, 0, sizeof(chaninfo.ireq));
|
|
||||||
strcpy(chaninfo.ireq.i_name, dev);
|
|
||||||
chaninfo.ireq.i_type = IEEE80211_IOC_CHANNEL;
|
|
||||||
|
|
||||||
chaninfo.chan = 0;
|
|
||||||
chaninfo.s = s;
|
|
||||||
set_chan(1);
|
|
||||||
|
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,14 @@ void setup_if(char *dev, int chan) {
|
|||||||
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
err(1, "socket()");
|
err(1, "socket()");
|
||||||
|
|
||||||
|
/* chan */
|
||||||
|
memset(&ireq, 0, sizeof(ireq));
|
||||||
|
snprintf(ireq.i_name, sizeof(ireq.i_name), "%s", dev);
|
||||||
|
ireq.i_type = IEEE80211_IOC_CHANNEL;
|
||||||
|
ireq.i_val = chan;
|
||||||
|
if (ioctl(s, SIOCS80211, &ireq) == -1)
|
||||||
|
err(1, "ioctl(SIOCS80211)");
|
||||||
|
|
||||||
/* UP & PROMISC */
|
/* UP & PROMISC */
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", dev);
|
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", dev);
|
||||||
@ -70,34 +78,6 @@ void setup_if(char *dev, int chan) {
|
|||||||
if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1)
|
if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1)
|
||||||
err(1, "ioctl(SIOCSIFFLAGS)");
|
err(1, "ioctl(SIOCSIFFLAGS)");
|
||||||
|
|
||||||
/* set monitor mode */
|
|
||||||
memset(&ifmr, 0, sizeof(ifmr));
|
|
||||||
snprintf(ifmr.ifm_name, sizeof(ifmr.ifm_name), "%s", dev);
|
|
||||||
if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1)
|
|
||||||
err(1, "ioctl(SIOCGIFMEDIA)");
|
|
||||||
if (ifmr.ifm_count == 0) {
|
|
||||||
printf("0 media thinggies...\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
mwords = (int *)malloc(ifmr.ifm_count * sizeof(int));
|
|
||||||
if (!mwords)
|
|
||||||
err(1, "malloc()");
|
|
||||||
ifmr.ifm_ulist = mwords;
|
|
||||||
if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1)
|
|
||||||
err(1, "ioctl(SIOCGIFMEDIA)");
|
|
||||||
free(mwords);
|
|
||||||
ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR;
|
|
||||||
if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1)
|
|
||||||
err(1, "ioctl(SIOCSIFMEDIA)");
|
|
||||||
|
|
||||||
/* chan */
|
|
||||||
memset(&ireq, 0, sizeof(ireq));
|
|
||||||
snprintf(ireq.i_name, sizeof(ireq.i_name), "%s", dev);
|
|
||||||
ireq.i_type = IEEE80211_IOC_CHANNEL;
|
|
||||||
ireq.i_val = chan;
|
|
||||||
if (ioctl(s, SIOCS80211, &ireq) == -1)
|
|
||||||
err(1, "ioctl(SIOCS80211)");
|
|
||||||
|
|
||||||
close(s);
|
close(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,7 +526,7 @@ int do_verify(struct ieee80211_frame *sent, int slen, void *got, int glen)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int fd, fd2;
|
int fd, fd2;
|
||||||
char *iface = "ath0";
|
char *iface = "wlan0";
|
||||||
char *verify = NULL;
|
char *verify = NULL;
|
||||||
int chan = 1;
|
int chan = 1;
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user