I have my first OpenWRT installation up and running (RC3), but is there any way to see clients associated to OpenWRT box?
Is the WL only one capable to do it or is there some native way?
Topic: Any way to see client associations?
The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.
Well, if your clients answer arp request, you can try something like :
arp -a | grep eth1But of course, wl assoclist is far better for that purpose.
Thanks.
I did use the ARP, but I hoped for something better.
As much I understand the WL util is not regarded as great tool in OpenWRT, so is there something else to install and use?
Thanks.
I did use the ARP, but I hoped for something better.
As much I understand the WL util is not regarded as great tool in OpenWRT, so is there something else to install and use?
It is not very difficult to program a similar tool. Something like this :
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <signal.h>
#include <getopt.h>
#include <netinet/ether.h>
#include <iwlib.h>
#include <wlioctl.h>
/* Stolen from wificonf.c */
int bcom_ioctl(int skfd, char *ifname, int cmd, void *buf, int len)
{
struct ifreq ifr;
wl_ioctl_t ioc;
int ret;
ioc.cmd = cmd;
ioc.buf = buf;
ioc.len = len;
ifr.ifr_data = (caddr_t) &ioc;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
ret = ioctl(skfd, SIOCDEVPRIVATE, &ifr);
return ret;
}
/* Main loop */
void loop(int skfd, char *iface, short int hotspot) {
/* How many MAC address the driver may keep for us ? */
#define MAXMAC ((WLC_IOCTL_MAXLEN-sizeof(unsigned int))/sizeof(struct ether_addr))
/* Used for ioctl communication */
unsigned char buf[WLC_IOCTL_MAXLEN];
int val;
int i;
wlc_rssi_t rssi;
short int count = 0;
struct ether_addr ether;
/* We get the list of associated MAC address */
memset(buf, 0, sizeof(buf));
((struct maclist *)buf)->count = MAXMAC;
if (bcom_ioctl(skfd,iface, WLC_GET_ASSOCLIST, buf, sizeof(buf)) < 0) {
syslog(LOG_ERR, "Unable to get association list");
exit(5);
}
/* Buf is a struct maclist */
for (i = 0; i < ((struct maclist*)buf)->count; i++) {
memcpy(ðer, buf+sizeof(unsigned int)+i*sizeof(struct ether_addr),
sizeof(struct ether_addr));
memcpy(&(rssi.ea), ðer, sizeof(struct ether_addr));
rssi.unknown = 0x0041;
if (bcom_ioctl(skfd, iface, WLC_GET_RSSI, &rssi, sizeof(wlc_rssi_t)) < 0)
rssi.rssi = 0;
fprintf(stdout, "%s %d\n", ether_ntoa(ðer), rssi.rssi);
}
}
void usage() {
printf("Associated clients\n");
printf("Usage: blah -i iface [-h].\n");
printf(" -i : Wireless interface `iface'.\n");
printf(" -h : This help page.\n");
exit(0);
}
int main(int argc, char **argv) {
int c;
int val;
int skfd;
char *interface = NULL;
while (1) {
c = getopt(argc, argv, "i:h");
if (c == -1) break;
switch (c)
{
case '?':
case 'h':
usage();
break;
case 'i':
interface = optarg;
break;
}
}
/* We configure syslog. */
openlog("auth-mac", LOG_PERROR | LOG_PID, LOG_LOCAL4);
if((skfd = iw_sockets_open()) < 0) {
syslog(LOG_CRIT, "iw_sockets_open(): %m");
exit(-1);
}
val = 0;
if (bcom_ioctl(skfd, interface, WLC_GET_MAGIC, &val, sizeof(val)) < 0) {
syslog(LOG_CRIT, "%s is not a wireless interface", interface);
exit(-1);
}
loop(skfd, interface, hotspot);
}Not tested but should work modulo some compilation fixes.
This is a stripped out version of "auth-mac" which is an authenticator which matches MAC addresses from a file. If the above excerpt does not work, look at the original file :
http://arch.crans.org/bernat@luffy.cx-- … auth-mac.c
ipkg install wl; wl assoclist
ipkg install wl; wl assoclist
wl doesn't give you rssi which alchemy or dd-wrt (or maybe even linksys) give. I think this is what folks want, including myself. When I get a chance I'll take a look and see how alchemy is doing it.
- DL
that's simple... take any mac address shown &
wl rssi <mac>
wl sta_info <mac>
tx, keeping on top of wl is tough because it (at least the v I have) doesn't respect | and help screen order seems to assume random order.
- DL
Try
wl 2>&1 |more(Redirects stderr to stdout)
(Last edited by wtzm on 25 Nov 2005, 13:37)
Try
wl 2>&1 |more(Redirects stderr to stdout)
Thanks, works great. Now I just need to imprint that on my failing memory
. But you have to wonder why wl doesn't use stdout?
- DL
The discussion might have continued from here.
