Categories
Networking Wireless Network

How to get MAC of a WLAN / Wifi device , get MAC address of Nokia 5800 Expressmusic phone WLAN

The MAC address of a WLAN device can be retrieved by the code *#MAC0WLAN# on the standby screen (that’s same as dialing *#62209526#)

This is for the programmers :

Header:

#include

Link against:

LIBRARY insock.lib

Capabilities:

CAPABILITY NONE

RSocketServ socketServ;
User::LeaveIfError(socketServ.Connect());
CleanupClosePushL(socketServ);

// Open a socket
RSocket socket;
User::LeaveIfError(socket.Open (socketServ,KAfInet,KSockStream,KProtocolInetTcp));
CleanupClosePushL(socket);

// Start enumerating the interfaces
TPckgBuf info;
socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl);
TBuf<32> macAddr;

while(socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info) == KErrNone)
{
if(info().iName.FindF(_L(“Wlan”)) == KErrNotFound)
continue;

macAddr.Zero();
for(TUint i = sizeof(SSockAddr) ; i < sizeof(SSockAddr) + 6 ; i++) if(i < (TUint)info().iHwAddr.Length()) macAddr.AppendFormat(_L("%02X:"), info().iHwAddr[i] ); if(macAddr.Length()) // remove trailing ':' macAddr.Delete(macAddr.Length()-1, 1); } CleanupStack::PopAndDestroy(2); Click here to know more