Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Experts Guide regarding MAC Address of a remote machine.

Experts Guide regarding MAC Address of a remote machine.

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmintutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 1149186
    wrote on last edited by
    #1

    I am able to get the MAC address of any machine connected in my LAN network . Now How should I extend this app to obtain the MAC address of a remote machine? Experts Guide Regards Black Tiger 007

    D C S 3 Replies Last reply
    0
    • U User 1149186

      I am able to get the MAC address of any machine connected in my LAN network . Now How should I extend this app to obtain the MAC address of a remote machine? Experts Guide Regards Black Tiger 007

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      blacktiger007 wrote: How should I extend this app to obtain the MAC address of a remote machine? What do you mean by "remote?" Any machine besides the one running the code is remote. Yes?


      "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

      1 Reply Last reply
      0
      • U User 1149186

        I am able to get the MAC address of any machine connected in my LAN network . Now How should I extend this app to obtain the MAC address of a remote machine? Experts Guide Regards Black Tiger 007

        C Offline
        C Offline
        cmk
        wrote on last edited by
        #3

        typedef byte SkNetMAC[6];

        bool FkNetGetMacA( CkStr SA, SkNetMAC &MAC )
        {
        if( SA.IsEmpty() ) return(false);

        #if 1 // get local or remote MAC given an IP using ARP (Win2K+)

        ulong   rc = 0,
                ml = sizeof(MAC);
        IPAddr  ip = inet\_addr( SA.PtrSafe(0) );
        
        rc = ::SendARP(ip, 0, (ulong\*)&MAC, &ml);
        

        #else // get local MAC associated with IP by querying adapter info (Win*)

        ulong             rc = 0,
                          al = 0;
        IP\_ADAPTER\_INFO  \*ai = NULL,
                         \*ac = NULL;
        IP\_ADDR\_STRING   \*ip = NULL;
        
        rc = ::GetAdaptersInfo(ai, &al);
        if( rc != ERROR\_BUFFER\_OVERFLOW )  return(false);
        
        ai = (IP\_ADAPTER\_INFO\*)ckMemTemp.Calloc(al);
        if( !ai )  return(false);
        
        rc = ::GetAdaptersInfo(ai, &al);
        if( rc != ERROR\_SUCCESS )  goto e\_FkNetGetMacA;
        
        // there can be a many to one relationship between
        // ip's and addapters - search adapters for matching IP
        for( ac = ai;  ac;  ac = ac->Next ) {
        	for( ip = &ac->IpAddressList;  ip;  ip = ip->Next ) {
        		if( SA == ip->IpAddress.String ) {
        			FkMemCpy(ac->Address, &MAC, sizeof(MAC));
        			goto e\_FkNetGetMacA;
        		}
        	}
        }
        
        e\_FkNetGetMacA:
        ckMemTemp.Free(ai);
        

        #endif

        return(true);
        

        }

        ...cmk Save the whales - collect the whole set

        1 Reply Last reply
        0
        • U User 1149186

          I am able to get the MAC address of any machine connected in my LAN network . Now How should I extend this app to obtain the MAC address of a remote machine? Experts Guide Regards Black Tiger 007

          S Offline
          S Offline
          simpocoder
          wrote on last edited by
          #4

          Am looking for PHP code to get the Mac address of a machine and I think you got the answer.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups