Retrieve Ip In Addition To Mac Addresses From /Proc/Net/Arp

Posted on

Last postal service “Display WiFi Hotspot clients past times “cat /proc/net/arp”” display arp equally human readable string, merely non machine readable. It’s around other version to retrieve IP together with MAC addresses, shop inwards a ArrayList.

package com.blogspot.android_er.androidlistclient;  import android.os.Bundle; import; import android.view.View; import android.widget.Button; import android.widget.TextView;  import; import; import; import; import java.util.ArrayList;  populace degree MainActivity extends AppCompatActivity {      Button btnRead;     TextView textResult;      ArrayList<Node> listNote;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         btnRead = (Button)findViewById(;         textResult = (TextView)findViewById(;          listNote = novel ArrayList<>();          btnRead.setOnClickListener(new View.OnClickListener() {             @Override             populace void onClick(View v) {                 readAddresses();                 textResult.setText("");                 for(int i=0; i<listNote.size(); i++){                     textResult.append(i + " ");                     textResult.append(listNote.get(i).toString());                     textResult.append("\n");                 }             }         });     }      somebody void readAddresses() {         listNote.clear();         BufferedReader bufferedReader = null;          endeavor {             bufferedReader = novel BufferedReader(new FileReader("/proc/net/arp"));              String line;             spell ((line = bufferedReader.readLine()) != null) {                 String[] splitted = line.split(" +");                 if (splitted != nada && splitted.length >= 4) {                     String ip = splitted[0];                     String mac = splitted[3];                     if (mac.matches("..:..:..:..:..:..")) {                         Node thisNode = novel Node(ip, mac);                         listNote.add(thisNode);                     }                 }             }          } choose handgrip of (FileNotFoundException e) {             e.printStackTrace();         } choose handgrip of (IOException e) {             e.printStackTrace();         } finally{             endeavor {                 bufferedReader.close();             } choose handgrip of (IOException e) {                 e.printStackTrace();             }         }     }      degree Node {         String ip;         String mac;          Node(String ip, String mac){             this.ip = ip;             this.mac = mac;         }          @Override         populace String toString() {             supply ip + " " + mac;         }     } }  


<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=""     xmlns:tools=""     android:layout_width="match_parent"     android:layout_height="match_parent"     android:padding="16dp"     android:orientation="vertical"     tools:context="com.blogspot.android_er.androidlistclient.MainActivity">      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text=""         android:textStyle="bold" />      <Button         android:id="@+id/readclient"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:textAllCaps="false"         android:text="Read Ip/MAC addresses"/>      <TextView         android:id="@+id/result"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:typeface="monospace"         android:textSize="24sp"/> </LinearLayout>  

– Lookup manufacturer information past times MAC address, using API
– Get HostName of WiFi hotspot clients, together with cheque if it is notwithstanding connected