同盾sdk獲取局域網內其他設備的Ip和Mac

同盾sdk代碼:

static String gqgggggg9q9qqggqq() {
        String str;
        int i = 0;
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader("/proc/net/arp"));
            String str2 = "";
            String str3 = "";
            String str4 = "";
            String str5 = "";
            String str6 = "";
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    str = str6;
                    break;
                }
                try {
                    String trim = readLine.trim();
                    if (trim.length() >= 63 && !trim.toUpperCase(Locale.US).contains("IP")) {
                        String trim2 = trim.substring(0, 17).trim();
                        trim.substring(29, 32).trim();
                        String trim3 = trim.substring(41, 63).trim();
                        if (!trim3.contains("00:00:00:00:00:00")) {
                            i++;
                            str6 = str6 + trim3.replace(":", "") + trim2 + "_";
                            if (i >= 20) {
                                str = str6;
                                break;
                            }
                        } else {
                            continue;
                        }
                    }
                } catch (Exception e) {
                }
            }
            bufferedReader.close();
            return str.substring(0, str.length() - 1);
        } catch (Exception e2) {
            return "";
        }
    }

 

/proc/net/arp內容:

sagit:/ $ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
192.168.1.22     0x1         0x2         de:47:54:b9:63:33     *        wlan0
192.168.1.82     0x1         0x2         7a:32:d0:e1:f5:13     *        wlan0
192.168.1.1      0x1         0x2         30:2c:15:2b:ae:21     *        wlan0
192.168.1.123    0x1         0x2         64:ab:45:1a:23:e3     *        wlan0

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章