-2

for my project i have to fetch all devices name & their ip address which are connected in same network. How to get the names and ips of all devices on my local network? somewhat similar to post but i have to use c code & this post is for ios only.

I know that ARP protocol use to map ip address with the mac address but exactly don't know how to scan all the ip's from there. My aim is to get the output without any command line tool as nmap & arp command are also there which will give the network ip addresses but not in a proper way. Can anybody tell me the way i can get all these details with or without code that would be really helpful.

Thanks,

rmaddy
  • 314,917
  • 42
  • 532
  • 579
im_Aks
  • 1
  • 1

1 Answers1

0

you can socket raw c, Create two threads

  1. Thread 1: ping all machines using ICMP.

  2. Thread 2: Caputre all data comming to your interface (ex: eth0) then filter only ARP response.

phoenixstudio
  • 1,776
  • 1
  • 14
  • 19
  • Creating and coordinating the threads will likely take more resources than simply doing it in a single thread. – David C. Rankin Aug 02 '19 at 23:29
  • you need to bind a thread to an interface, and using two threads is better than bind - send - unbind - send ..., it is also possible to use two separate programs or machines – phoenixstudio Aug 03 '19 at 20:48
  • I have not used these terms before, so this is kind of new to me .As you guys suggested. I have read the use of icmp over sending packets but if you guys give me any code example that would be really helpful. :) Thanks in advance. – im_Aks Aug 09 '19 at 07:10
  • To capture RAW data check this http://plasmixs.github.io/raw-sockets-programming-in-c.html – phoenixstudio Aug 09 '19 at 13:21
  • Thankyou @phoenixstudio for you quick response. I have checked links in detail. The problem i'm getting while compiling the code for second one as some linux libraries are used which is not present in osx. – im_Aks Aug 12 '19 at 13:17
  • For icmp socket it's showing "error: field has incomplete type 'struct icmphdr" .According to me here also structure isn't there. – im_Aks Aug 12 '19 at 13:20
  • Sorry i am not able to help with this, but I can assure you that it work very good on Linux. for other OS you can try libpcap – phoenixstudio Aug 15 '19 at 19:06