How to handle the MAC address(physical address) of the roteadot?

Asked

Viewed 113 times

1

I am making an application on INTEL XDK for smartphone and would like to capture the value of MAC Adrees Wifi Router active at the moment, as well as the network name (SSID) and password, to make comparisons. Example: I have 3 routers with the same name and password, but with the VALUES OF MACS 'A', 'B' and 'C' respectively in my work and I want that when I am connected to the Router with MAC Adrees = 'B' the application enable some functions and inform me that I am connected to the Router with SSID = 'work', Password = 'password' and MAC = 'B'.
How to handle the MAC Adrees (physical address) of the router?

  • I’m not sure Html5 does that...

  • does not need to be specifically Html5, I will use this data in an app, home learn in another language serves.

  • 1

    Actually it is not possible to get this information except for IE... Edit your question and add tags java, javascript, php And whatever comes to mind, maybe there’s someone as a solution... This is like seeing the user’s "blood" type, I don’t think it’s so simple... There are some low-level network algorithms that cover these techniques... but it’s very complex... Why besides the application layer, you will have to have a certain domain over the other 6...

  • Although I think I’m confused,...

  • You tried some code for these tasks ?

1 answer

0

Oh, there’s this solution in Java :

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

public class App{

   public static void main(String[] args){

    InetAddress ip;
    try {

        ip = InetAddress.getLocalHost();
        System.out.println("Current IP address : " + ip.getHostAddress());

        NetworkInterface network = NetworkInterface.getByInetAddress(ip);

        byte[] mac = network.getHardwareAddress();

        System.out.print("Current MAC address : ");

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < mac.length; i++) {
            sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));        
        }
        System.out.println(sb.toString());

    } catch (UnknownHostException e) {

        e.printStackTrace();

    } catch (SocketException e){

        e.printStackTrace();

    }

   }

}

See if it helps you.

Source

  • 2

    complemented the answer would have to create a client and server socket dhcp to know the gateway of the network and then yes take the mac from the router

  • 1

    http://www.codeproject.com/Questions/828017/How-do-run-a-DHCP-java-code

  • Good... Pow formulates an answer there, I found none complete here in Sopt,,,

  • I tested all the codes, however, all return me the Mac of the machine and not of the ROUTER, how to create a client and server socket dhcp to return me this information? @Assanges, as Magichat said, I also did not find any complete answer, if I can post I would really appreciate.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.