Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Retrieve MAC address of host from ip, need help.

$
0
0
hey guys im working with some raw networking in C++ here and i have to retrieve the mac address of a remote target that i have the ip of, i am trying to use the SendARP function but i am only receiving CC:CC:CC:CC:CC:CC mac addr from it :/ i really have no clue at what is wrong with my code, help me out ? :D

now over to the code:

ULONG DestMacAddr[2];
	ULONG PhysicalLength = 6;

	IPAddr destination = inet_addr(target.c_str());
	IPAddr source = inet_addr(host.c_str());

	SendARP(destination, source, DestMacAddr, &PhysicalLength);
	
	unsigned char mac[6];
	BYTE *bMacAddr = (BYTE *) & DestMacAddr;
	for (int p = 0; p < (int) PhysicalLength; p++)
	{
		mac[p] = (char)bMacAddr[p];
	}

	printf("DestMacAddr: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X \n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);




btw i checked and the strings host and target are correct.

i would be very gratefull for advice, help and tips.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>