Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 11:43, 24 August 2007.

TSS000462 - Retrieving WLAN MAC address

From Forum Nokia Wiki


Subject:

Retrieving WLAN MAC address TSS000462

 

Platform(s): Device(s), SW version(s):
S60 3rd Edition, S60 3rd Edition FP1  

Category:

Symbian C++

Subcategory:

-

Description:

The following code demonstrates how to list all network interfaces and retrieve the hardware (MAC) address for a WLAN interface, if one is found.
//------------------------------------------------------------------------------
#include <in_sock.h>    // link against insock.lib, esock.lib
    // Connect to the socket server
    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<TSoInetInterfaceInfo> 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); // socket, socketServ

    // macAddr now contains the WLAN MAC address,
    // (empty if no WLAN interface is found)

//------------------------------------------------------------------------------

Creation date:

November 22, 2006

Last modified:

-
Related Discussions
Thread Thread Starter Forum Replies Last Post
Add WLAN AP nmnir General Symbian C++ 3 2007-12-12 07:46
Different between GPRS and WLAN john_c_ye Wired and Wireless interfaces 4 2007-06-09 05:22
Connnecting two N95 in WLAN ad hoc mode npradeep Wired and Wireless interfaces 3 2008-01-22 19:01
About WLAN ab General Symbian C++ 2 2007-12-24 13:06
WLAN without SIM Card mrpunkrock Wired and Wireless interfaces 5 2006-09-18 07:50
 
Powered by MediaWiki