how to find out the client connected to router.( chip is MT7620a) the router is openwrt installed, i need to find out the client which are connected to the router using and code.
Topic: openwrt
The content of this topic has been archived on 10 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.
You can see the list of clients connected to your router via DHCP in the file "dhcp.leases" located in "/tmp" folder. But this file is not getting updated if a client gets disconnected from your router.
Another option is viewing arp-table. You can view it by using "arp". But, arp table also has updation issues as Dhco.leases.
Another, and quite stable and handy, tool is "arp-scan" command. It doesn't have any issue of updation. But, this command is not generally available in openwrt, you have to compile it's source according to your board.
PS: you can also use "nmap" and "tcpdump" commands as they are already available in OpenWRT.
I hope it helps.
I need c code to demonstrate this result. so can u help me to give a c code
can any one tell me how to get the signal strength of the device's which are connected to the router. my router is openwrt installed and i need c code to achieve this task
Another, and quite stable and handy, tool is "arp-scan" command. It doesn't have any issue of updation. But, this command is not generally available in openwrt, you have to compile it's source according to your board.
Can you please show some examples on how to use arp-scan to achieve this?
PS: you can also use "nmap" and "tcpdump" commands as they are already available in OpenWRT.
I will also be interested to see some examples with either nmap or tcpdump, if you don't mind.
there is no nmap found on the router.
root@OpenWrt:~# nmap
-ash: nmap: not found
i'm doing my project so it's important me to gather an information like connected devices to router and signal strength of those devices.... can any one please help me to get those information by c code... i need c code to chive this tasks....
Can you explain why you need c-code for things already available from the shell?
that will help me for my project... there is no any software or nothing is there to get me those information.... c code will help me to do this and even i can able to modify the code if i need any changes means... so for that asking the c code
th3gr8 wrote:Another, and quite stable and handy, tool is "arp-scan" command. It doesn't have any issue of updation. But, this command is not generally available in openwrt, you have to compile it's source according to your board.
Can you please show some examples on how to use arp-scan to achieve this?
PS: you can also use "nmap" and "tcpdump" commands as they are already available in OpenWRT.
I will also be interested to see some examples with either nmap or tcpdump, if you don't mind.
For example:
arp-scan --interface=eth0 --localnet
here, interface name may vary depending on the interface being used or required to get scanned.
You can google for the syntax/uses of nmap and tcpdump:
for example:
nmap -v google.com
there is no nmap found on the router.
root@OpenWrt:~# nmap
-ash: nmap: not found
You need to select the nmap command in before running make i.e. select nmap via "make menuconfig" ..
Also, you can download the package using:
"opkg install nmap"
hi i have got the code for this task the code is:
#include <linux/wireless.h>
#include <wireless.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <uci.h>
#include <stdio.h>
#include <stdlib.h>
/* The name of the interface */
#ifndef IW_NAME
#define IW_NAME "eth1"
#endif
int main()
{
int sockfd;
struct iw_statistics stats;
struct iwreq req;
memset(&stats, 0, sizeof(stats));
memset(&req, 0, sizeof(iwreq));
sprintf(req.ifr_name, "rausb0");
req.u.data.pointer = &stats;
req.u.data.length = sizeof(iw_statistics);
#ifdef CLEAR_UPDATED
req.u.data.flags = 1;
#endif
/* Any old socket will do, and a datagram socket is pretty cheap */
if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("Could not create simple datagram socket");
exit(EXIT_FAILURE);
}
/* Perform the ioctl */
if(ioctl(sockfd, SIOCGIWSTATS, &req) == -1) {
perror("Error performing SIOCGIWSTATS");
close(sockfd);
exit(EXIT_FAILURE);
}
close(sockfd);
printf("Signal level%s is %d%s.\n",
1,1 Top
(stats.qual.updated & IW_QUAL_DBM ? " (in dBm)" :""),
stats.qual.level,
(stats.qual.updated & IW_QUAL_LEVEL_UPDATED ? " (updated)" :""));
return 0;
}
but while compiling it's giving the error like:
In file included from /opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:74:0,
from 111.c:1:
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/if.h:181:19: error: field 'ifru_addr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/if.h:182:19: error: field 'ifru_dstaddr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/if.h:183:19: error: field 'ifru_broadaddr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/if.h:184:19: error: field 'ifru_netmask' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/if.h:185:20: error: field 'ifru_hwaddr' has incomplete type
In file included from 111.c:1:0:
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:751:19: error: field 'addr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:777:18: error: field 'bssid' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:835:18: error: field 'addr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:848:18: error: field 'addr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:861:18: error: field 'bssid' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:869:18: error: field 'src_addr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:880:18: error: field 'bssid' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:934:18: error: field 'ap_addr' has incomplete type
/opt/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3/../../../../mipsel-openwrt-linux-uclibc/sys-include/linux/wireless.h:935:18: error: field 'addr' has incomplete type
111.c:2:22: fatal error: wireless.h: No such file or directory
compilation terminated.
can any one help me what changes do i made so that this code will get work.
mazilo wrote:th3gr8 wrote:Another, and quite stable and handy, tool is "arp-scan" command. It doesn't have any issue of updation. But, this command is not generally available in openwrt, you have to compile it's source according to your board.
Can you please show some examples on how to use arp-scan to achieve this?
PS: you can also use "nmap" and "tcpdump" commands as they are already available in OpenWRT.
I will also be interested to see some examples with either nmap or tcpdump, if you don't mind.
For example:
arp-scan --interface=eth0 --localnet
here, interface name may vary depending on the interface being used or required to get scanned.You can google for the syntax/uses of nmap and tcpdump:
for example:
nmap -v google.com
Many thanks.
hi i have got the code for this task the code is:
#include <linux/wireless.h> #include <wireless.h> #include <sys/types.h> #include <sys/socket.h> #include <uci.h> #include <stdio.h> #include <stdlib.h> /* The name of the interface */ #ifndef IW_NAME #define IW_NAME "eth1" #endif int main() { int sockfd; struct iw_statistics stats; struct iwreq req; memset(&stats, 0, sizeof(stats)); memset(&req, 0, sizeof(iwreq)); sprintf(req.ifr_name, "rausb0"); req.u.data.pointer = &stats; req.u.data.length = sizeof(iw_statistics); #ifdef CLEAR_UPDATED req.u.data.flags = 1; #endif /* Any old socket will do, and a datagram socket is pretty cheap */ if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { perror("Could not create simple datagram socket"); exit(EXIT_FAILURE); } /* Perform the ioctl */ if(ioctl(sockfd, SIOCGIWSTATS, &req) == -1) { perror("Error performing SIOCGIWSTATS"); close(sockfd); exit(EXIT_FAILURE); } close(sockfd); printf("Signal level%s is %d%s.\n", 1,1 Top (stats.qual.updated & IW_QUAL_DBM ? " (in dBm)" :""), stats.qual.level, (stats.qual.updated & IW_QUAL_LEVEL_UPDATED ? " (updated)" :"")); return 0; }
can any one help me what changes do i made so that this code will get work.
Out of curiosity and if I may ask, where did you get this code from and what does it suppose to do?
The discussion might have continued from here.