cli329 network location awareness dr. neil roodyn
TRANSCRIPT
![Page 1: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/1.jpg)
CLI329CLI329
Network Location Network Location AwarenessAwareness
Dr. Neil RoodynDr. Neil Roodyn
![Page 2: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/2.jpg)
MManagementanagementTToolsools
CCommunicationsommunications& & MMessagingessaging
Device Update Agent
Software Update Services
Live Communications Server
Exchange Server
Internet Security and Acceleration Server
Speech Server
Image Update
LLocation ocation SServiceservices
MMultimediaultimedia
MapPoint
DirectX
Windows Media
Visual Studio 2005DDevelopment evelopment TToolsools
MFC 8.0, ATL 8.0
Win32NNativeative
MManagedanaged
SServer erver SSideide
LLightweightightweight
RRelationalelationalSQL Server 2005 Express EditionEDB
DDa
taata
PPro
gra
mm
ing
ro
gra
mm
ing
MM
od
el
od
el
DDevice evice BBuilding uilding TToolsools
HHardware/ardware/DDriversrivers
Windows XP DDK
Windows Embedded Studio
Platform Builder
OEM/IHV SuppliedBSP
(ARM, SH4, MIPS)OEM Hardware and Standard Drivers
Standard PC Hardware and Drivers
SQL Server 2005SQL Server 2005 Mobile Edition
ASP.NET Mobile Controls ASP.NET
.NET Compact Framework .NET Framework
Microsoft Operations Manager
Systems Management Server
![Page 3: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/3.jpg)
Dr. NeilDr. Neil
MissionMissionTo increase the value of your To increase the value of your Software BusinessSoftware Business
Working with software for way too long to Working with software for way too long to be healthybe healthy
Spend summer in Australia Spend summer in Australia
Spend other summer in USA and EuropeSpend other summer in USA and Europe
Regular contributor to: Australian Developer, Regular contributor to: Australian Developer, International Developer, Cutter ITInternational Developer, Cutter IT
![Page 4: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/4.jpg)
BooksBooks
http://eXtreme.NET.Roodyn.comhttp://eXtreme.NET.Roodyn.com
http://smartphone.roodyn.com/http://smartphone.roodyn.com/
http://tablet.roodyn.com/http://tablet.roodyn.com/
![Page 5: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/5.jpg)
Sometimes-Connected PCsSometimes-Connected PCs
How many people here have a How many people here have a laptop/Tablet PC?laptop/Tablet PC?
How many of your clients have How many of your clients have laptops/Tablet PCs?laptops/Tablet PCs?
How many different networks do you How many different networks do you connect to each week/month/year?connect to each week/month/year?
![Page 6: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/6.jpg)
Bob’s StoryBob’s Story
Bob – Tech Support Bob – Tech Support
LaptopLaptop
![Page 7: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/7.jpg)
Jenny’s StoryJenny’s Story
Jenny – Insurance Jenny – Insurance Company RepresentativeCompany Representative
Tablet PCTablet PC
![Page 8: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/8.jpg)
Important ScenariosImportant Scenarios
Identify current connectionsIdentify current connections
Notification of changesNotification of changes
Smooth transition fromSmooth transition fromConnected to not connectedConnected to not connected
Not connected to connectedNot connected to connected
Addition of networkAddition of network
![Page 9: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/9.jpg)
Network Location Network Location AwarenessAwareness
NLANLA
MSDN points us to Windows MSDN points us to Windows Sockets Library APISockets Library API
![Page 10: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/10.jpg)
P/InvokeP/Invoke[DllImport("Ws2_32.dll", CharSet = CharSet.Auto, [DllImport("Ws2_32.dll", CharSet = CharSet.Auto,
SetLastError=true)]SetLastError=true)]
private extern static Int32 private extern static Int32 WSALookupServiceBegin(WSAQUERYSET qsRestrictions,WSALookupServiceBegin(WSAQUERYSET qsRestrictions,
Int32 dwControlFlags, ref Int32 lphLookup);Int32 dwControlFlags, ref Int32 lphLookup);
[DllImport("Ws2_32.dll", CharSet = CharSet.Auto, [DllImport("Ws2_32.dll", CharSet = CharSet.Auto, SetLastError=true)]SetLastError=true)]
private extern static Int32 WSALookupServiceNext(Int32 hLookup,private extern static Int32 WSALookupServiceNext(Int32 hLookup,
Int32 dwControlFlags,Int32 dwControlFlags,
ref Int32 lpdwBufferLength,ref Int32 lpdwBufferLength,
[Out]WSAQUERYSET lpqsResults);[Out]WSAQUERYSET lpqsResults);
[DllImport("Ws2_32.dll", CharSet = CharSet.Auto, [DllImport("Ws2_32.dll", CharSet = CharSet.Auto, SetLastError=true)]SetLastError=true)]
private extern static Int32 WSALookupServiceEnd(Int32 hLookup);private extern static Int32 WSALookupServiceEnd(Int32 hLookup);
![Page 11: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/11.jpg)
WSAxxxWSAxxxInt32 dwControlFlags;Int32 dwControlFlags;Int32 valHandle = 0;Int32 valHandle = 0;IntPtr hLookup = new IntPtr(&valHandle);IntPtr hLookup = new IntPtr(&valHandle);WSAQUERYSET qsRestrictions = new WSAQUERYSET();WSAQUERYSET qsRestrictions = new WSAQUERYSET();qsRestrictions.dwSize = Marshal.SizeOf(typeof(WSAQUERYSET));qsRestrictions.dwSize = Marshal.SizeOf(typeof(WSAQUERYSET));qsRestrictions.dwNameSpace = 0; //NS_ALL;qsRestrictions.dwNameSpace = 0; //NS_ALL;dwControlFlags = 0x0FF0; //LUP_RETURN_ALL;dwControlFlags = 0x0FF0; //LUP_RETURN_ALL;
int nResult = WSALookupServiceBegin(qsRestrictions, int nResult = WSALookupServiceBegin(qsRestrictions, dwControlFlags, ref valHandle);dwControlFlags, ref valHandle);
while (0 == nResult)while (0 == nResult){{
WSAQUERYSET qsResult = new WSAQUERYSET() ;WSAQUERYSET qsResult = new WSAQUERYSET() ;nResult = WSALookupServiceNext(valHandle, dwControlFlags, nResult = WSALookupServiceNext(valHandle, dwControlFlags,
ref dwBuffer, qsResult);ref dwBuffer, qsResult); } } nResult = WSALookupServiceEnd(valHandle);nResult = WSALookupServiceEnd(valHandle);
![Page 12: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/12.jpg)
WSAQUERYSETWSAQUERYSET[ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )][ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )]public class WSAQUERYSETpublic class WSAQUERYSET{{ public Int32 dwSize = 0; public Int32 dwSize = 0; public String szServiceInstanceName = null; public String szServiceInstanceName = null; public IntPtr lpServiceClassId; public IntPtr lpServiceClassId; public IntPtr lpVersion; public IntPtr lpVersion; public String lpszComment; public String lpszComment; public Int32 dwNameSpace; public Int32 dwNameSpace; public IntPtr lpNSProviderId; public IntPtr lpNSProviderId; public String lpszContext; public String lpszContext; public Int32 dwNumberOfProtocols; public Int32 dwNumberOfProtocols; public IntPtr lpafpProtocols; public IntPtr lpafpProtocols; public String lpszQueryString; public String lpszQueryString; public Int32 dwNumberOfCsAddrs; public Int32 dwNumberOfCsAddrs; public IntPtr lpcsaBuffer; public IntPtr lpcsaBuffer; public Int32 dwOutputFlags; public Int32 dwOutputFlags; public IntPtr lpBlob;public IntPtr lpBlob;}}
![Page 13: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/13.jpg)
Getting A List Of Current Getting A List Of Current ConnectionsConnections
![Page 14: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/14.jpg)
Current ConnectionsCurrent Connections
WSALookupServiceBeginWSALookupServiceBegin
WSALookupServiceNextWSALookupServiceNext
WSALookupServiceEndWSALookupServiceEnd
Too easy!Too easy!
![Page 15: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/15.jpg)
NotificationsNotifications
Application needs to know when the Application needs to know when the connected networks changeconnected networks change
![Page 16: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/16.jpg)
P/InvokeP/Invoke
[DllImport("Ws2_32.dll", CharSet = CharSet.Auto, [DllImport("Ws2_32.dll", CharSet = CharSet.Auto, SetLastError=true)]SetLastError=true)]
private extern static Int32 WSANSPIoctl(private extern static Int32 WSANSPIoctl(
Int32 hLookup,Int32 hLookup,
UInt32 dwControlCode,UInt32 dwControlCode,
IntPtr lpvInBuffer,IntPtr lpvInBuffer,
Int32 cbInBuffer,Int32 cbInBuffer,
IntPtr lpvOutBuffer,IntPtr lpvOutBuffer,
Int32 cbOutBuffer,Int32 cbOutBuffer,
ref Int32 lpcbBytesReturned,ref Int32 lpcbBytesReturned,
IntPtr lpCompletion );IntPtr lpCompletion );
![Page 17: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/17.jpg)
Notifications - WSAxxxNotifications - WSAxxxWSAQUERYSET qsRestrictions = new WSAQUERYSET();WSAQUERYSET qsRestrictions = new WSAQUERYSET();Int32 dwControlFlags;Int32 dwControlFlags;Int32 hLookup = 0;Int32 hLookup = 0;qsRestrictions.dwSize = Marshal.SizeOf(typeof(WSAQUERYSET));qsRestrictions.dwSize = Marshal.SizeOf(typeof(WSAQUERYSET));qsRestrictions.dwNameSpace = 0; //NS_ALL;qsRestrictions.dwNameSpace = 0; //NS_ALL;dwControlFlags = 0x0FF0; //LUP_RETURN_ALL;dwControlFlags = 0x0FF0; //LUP_RETURN_ALL;int nResult = WSALookupServiceBegin(qsRestrictions, int nResult = WSALookupServiceBegin(qsRestrictions,
dwControlFlags, ref hLookup);dwControlFlags, ref hLookup);Int32 dwBytesReturned = 0;Int32 dwBytesReturned = 0;UInt32 cCode = 2281701401; //SIO_NSP_NOTIFY_CHANGEUInt32 cCode = 2281701401; //SIO_NSP_NOTIFY_CHANGEnResult = WSANSPIoctl(hLookup, cCode, nResult = WSANSPIoctl(hLookup, cCode,
new IntPtr(), 0, new IntPtr(), 0,new IntPtr(), 0, new IntPtr(), 0,ref dwBytesReturned,ref dwBytesReturned,new IntPtr());new IntPtr());
nResult = WSALookupServiceEnd(hLookup);nResult = WSALookupServiceEnd(hLookup);
![Page 18: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/18.jpg)
NLA NotificationsNLA Notifications
![Page 19: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/19.jpg)
NotificationsNotifications
Again its very easy!Again its very easy!
The hardest part is the threading The hardest part is the threading
![Page 20: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/20.jpg)
Getting More InformationGetting More Information
Network speed?Network speed?
Internet connectivity?Internet connectivity?
Managed network?Managed network?
![Page 21: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/21.jpg)
Meet NLA_BLOBMeet NLA_BLOBtypedef struct _NLA_BLOB {typedef struct _NLA_BLOB { struct {struct { NLA_BLOB_DATA_TYPE type;NLA_BLOB_DATA_TYPE type; DWORD dwSize;DWORD dwSize; DWORD nextOffset; } header;DWORD nextOffset; } header; union {union {
CHAR rawData[1]; // header.type -> NLA_RAW_DATACHAR rawData[1]; // header.type -> NLA_RAW_DATAstruct {struct {
DWORD dwType;DWORD dwType; DWORD dwSpeed;DWORD dwSpeed; CHAR adapterName[1]; } interfaceData; // header.type -> NLA_INTERFACECHAR adapterName[1]; } interfaceData; // header.type -> NLA_INTERFACE
struct {struct { CHAR information[1]; } locationData; // header.type -> NLA_802_1X_LOCATIONCHAR information[1]; } locationData; // header.type -> NLA_802_1X_LOCATION
struct {struct { NLA_CONNECTIVITY_TYPE type;NLA_CONNECTIVITY_TYPE type; NLA_INTERNET internet; } connectivity; // header.type -> NLA_CONNECTIVITYNLA_INTERNET internet; } connectivity; // header.type -> NLA_CONNECTIVITY
struct {struct { struct {struct { DWORD speed;DWORD speed; DWORD type;DWORD type; DWORD state;DWORD state; WCHAR machineName[256];WCHAR machineName[256]; WCHAR sharedAdapterName[256]; } remote;WCHAR sharedAdapterName[256]; } remote; } ICS; // header.type -> NLA_ICS} ICS; // header.type -> NLA_ICS } data;} data;}}
![Page 22: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/22.jpg)
NLA_BLOB’s friendsNLA_BLOB’s friendstypedef enum _NLA_BLOB_DATA_TYPE {typedef enum _NLA_BLOB_DATA_TYPE { NLA_RAW_DATA = 0,NLA_RAW_DATA = 0, NLA_INTERFACE = 1,NLA_INTERFACE = 1, NLA_802_1X_LOCATION = 2,NLA_802_1X_LOCATION = 2, NLA_CONNECTIVITY = 3,NLA_CONNECTIVITY = 3, NLA_ICS = 4,NLA_ICS = 4,}}
typedef enum _NLA_CONNECTIVITY_TYPE {typedef enum _NLA_CONNECTIVITY_TYPE { NLA_NETWORK_AD_HOC = 0,NLA_NETWORK_AD_HOC = 0, NLA_NETWORK_MANAGED = 1,NLA_NETWORK_MANAGED = 1, NLA_NETWORK_UNMANAGED = 2,NLA_NETWORK_UNMANAGED = 2, NLA_NETWORK_UNKNOWN = 3,NLA_NETWORK_UNKNOWN = 3,} }
typedef enum _NLA_INTERNET {typedef enum _NLA_INTERNET { NLA_INTERNET_UNKNOWN = 0,NLA_INTERNET_UNKNOWN = 0, NLA_INTERNET_NO = 1,NLA_INTERNET_NO = 1, NLA_INTERNET_YES = 2,NLA_INTERNET_YES = 2,} }
![Page 23: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/23.jpg)
A Flexible TruthA Flexible Truth
[DllImport("Ws2_32.dll", CharSet = [DllImport("Ws2_32.dll", CharSet = CharSet.Auto, CharSet.Auto,
SetLastError=true)]SetLastError=true)]
private extern static private extern static
Int32 WSALookupServiceNext(Int32 hLookup,Int32 WSALookupServiceNext(Int32 hLookup,
Int32 dwControlFlags,Int32 dwControlFlags,
ref Int32 lpdwBufferLength,ref Int32 lpdwBufferLength,
[Out][Out]IntPtrIntPtr lpqsResults); lpqsResults);
![Page 24: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/24.jpg)
Looking For The NetworksLooking For The Networkswhile (0 == nResult)while (0 == nResult){{
Int32 bufferSize = 0;Int32 bufferSize = 0;WSAQUERYSET qsResult = new WSAQUERYSET() ;WSAQUERYSET qsResult = new WSAQUERYSET() ;IntPtr pqsResult = new IntPtr();IntPtr pqsResult = new IntPtr();
nResult = WSALookupServiceNext(valHandle, dwControlFlags, ref bufferSize, nResult = WSALookupServiceNext(valHandle, dwControlFlags, ref bufferSize, pqsResult);pqsResult);
if (0!=nResult)if (0!=nResult){{
pqsResult = Marshal.AllocHGlobal(bufferSize);pqsResult = Marshal.AllocHGlobal(bufferSize); nResult = WSALookupServiceNext(valHandle, dwControlFlags, ref nResult = WSALookupServiceNext(valHandle, dwControlFlags, ref
bufferSize, pqsResult);bufferSize, pqsResult); if (0==nResult)if (0==nResult) {{ Marshal.PtrToStructure(pqsResult, qsResult);Marshal.PtrToStructure(pqsResult, qsResult);
//get network details//get network details}}
Marshal.FreeHGlobal(pqsResult);Marshal.FreeHGlobal(pqsResult);}}
} }
![Page 25: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/25.jpg)
A Managed NLA_BLOBA Managed NLA_BLOB
[StructLayout(LayoutKind.Sequential, [StructLayout(LayoutKind.Sequential, Pack=4)]Pack=4)]
public class BLOB public class BLOB
{{
public UInt32 cbSize;public UInt32 cbSize;
public IntPtr pInfo;public IntPtr pInfo;
}}
![Page 26: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/26.jpg)
A Managed NLA _BLOB A Managed NLA _BLOB AgainAgain
[ StructLayout( LayoutKind.Explicit, Pack=4 )][ StructLayout( LayoutKind.Explicit, Pack=4 )]
public class NLA_Infopublic class NLA_Info
{{
[ FieldOffset( 0 )][ FieldOffset( 0 )]
public NLA_Header header;public NLA_Header header;
[ FieldOffset( 12 )][ FieldOffset( 12 )]
public NLA_InterfaceData interfaceData;public NLA_InterfaceData interfaceData;
[ FieldOffset( 12 )][ FieldOffset( 12 )]
public NLA_Connectivity connectivity;public NLA_Connectivity connectivity;
} }
![Page 27: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/27.jpg)
Managed Nested StructuresManaged Nested Structures[StructLayout(LayoutKind.Sequential, Pack=4)][StructLayout(LayoutKind.Sequential, Pack=4)]public struct NLA_Headerpublic struct NLA_Header{{ public UInt32 type;public UInt32 type; public UInt32 size;public UInt32 size; public UInt32 nextOffset;public UInt32 nextOffset;} } [StructLayout(LayoutKind.Sequential, Pack=4)][StructLayout(LayoutKind.Sequential, Pack=4)]public struct NLA_InterfaceDatapublic struct NLA_InterfaceData{{ public UInt32 type;public UInt32 type; public UInt32 speed;public UInt32 speed; public public IntPtrIntPtr adapterName;adapterName;} } [StructLayout(LayoutKind.Sequential, Pack=4)][StructLayout(LayoutKind.Sequential, Pack=4)]public struct NLA_Connectivitypublic struct NLA_Connectivity{{ public UInt32 type;public UInt32 type; public UInt32 internet;public UInt32 internet;} }
![Page 28: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/28.jpg)
Getting To The InformationGetting To The Informationunsafe protected Network GetNetworkDetails(WSAQUERYSET qsResult)unsafe protected Network GetNetworkDetails(WSAQUERYSET qsResult){{
Network network = new Network(qsResult.szServiceInstanceName ) ;Network network = new Network(qsResult.szServiceInstanceName ) ;
BLOB blob = GetBlob(qsResult) ;BLOB blob = GetBlob(qsResult) ;byte* pInfo = (byte*)blob.pInfo ;byte* pInfo = (byte*)blob.pInfo ;NLA_Info info ;NLA_Info info ;dodo
{{ info = network.SetNLAInfo(new IntPtr(pInfo)) ;info = network.SetNLAInfo(new IntPtr(pInfo)) ;
pInfo += info.header.nextOffset ;pInfo += info.header.nextOffset ; }while (0 != info.header.nextOffset) ;}while (0 != info.header.nextOffset) ;
return network ;return network ;}}
![Page 29: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/29.jpg)
Getting To The Point(er)Getting To The Point(er)
unsafe public NLA_Info SetNLAInfo(IntPtr pInfo)unsafe public NLA_Info SetNLAInfo(IntPtr pInfo){{
NLA_Info info = new NLA_Info();NLA_Info info = new NLA_Info();Marshal.PtrToStructure(pInfo, info);Marshal.PtrToStructure(pInfo, info);AddInfo(info);AddInfo(info);if (NLA_DATA_TYPE.NLA_INTERFACE == if (NLA_DATA_TYPE.NLA_INTERFACE == (NLA_DATA_TYPE)info.header.type )(NLA_DATA_TYPE)info.header.type )
{{byte* p = (byte*)pInfo;byte* p = (byte*)pInfo;p += 20;p += 20;adaptor = Marshal.PtrToStringAnsi(new IntPtr(p));adaptor = Marshal.PtrToStringAnsi(new IntPtr(p));
}}return info;return info;
}}
![Page 30: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/30.jpg)
Getting The Values We WantGetting The Values We Wantprotected void AddInfo(NLA_Info info)protected void AddInfo(NLA_Info info){{
NLA_DATA_TYPE type = (NLA_DATA_TYPE)info.header.type;NLA_DATA_TYPE type = (NLA_DATA_TYPE)info.header.type;switch (type)switch (type)
{{ case NLA_DATA_TYPE.NLA_INTERFACE:case NLA_DATA_TYPE.NLA_INTERFACE: this.speed = info.interfaceData.speed;this.speed = info.interfaceData.speed;
break;break;case NLA_DATA_TYPE.NLA_CONNECTIVITY:case NLA_DATA_TYPE.NLA_CONNECTIVITY:
this.internet = this.internet = (NLA_INTERNET)info.connectivity.internet;(NLA_INTERNET)info.connectivity.internet;
this.connectionType = this.connectionType =
(NLA_CONNECTIVITY_TYPE)info.connectivity.type;(NLA_CONNECTIVITY_TYPE)info.connectivity.type;break;break;
}}}}
![Page 31: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/31.jpg)
Searching DeepSearching Deep
Previously we search for Previously we search for LUP_RETURN_ALLLUP_RETURN_ALL
We need to search DEEPWe need to search DEEPdwControlFlags = 0x0FF1; // LUP_RETURN_ALL | LUP_DEEP dwControlFlags = 0x0FF1; // LUP_RETURN_ALL | LUP_DEEP
int nResult = WSALookupServiceBegin(qsRestrictions,int nResult = WSALookupServiceBegin(qsRestrictions,
dwControlFlags, ref valHandle);dwControlFlags, ref valHandle);
Only in the WSALookupServiceBegin!Only in the WSALookupServiceBegin!
![Page 32: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/32.jpg)
Putting It All TogetherPutting It All Together
![Page 33: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/33.jpg)
Action!Action!
Add NLA to your application.Add NLA to your application.Wrap the WSAxxx methods in Wrap the WSAxxx methods in a .NET classa .NET class
Reuse that class with all your applicationsReuse that class with all your applications
Do it now!Do it now!It’s not difficultIt’s not difficult
You don’t have to be a doctor!You don’t have to be a doctor!
Make you application Network Make you application Network Location AwareLocation Aware
![Page 34: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/34.jpg)
MEDC Mobile PC TalksMEDC Mobile PC Talks
CLI204 - Tablet PC Development OverviewCLI204 - Tablet PC Development OverviewSpeaker - Dave HaleSpeaker - Dave HaleTime – Tuesday 5/10 11:30 AMTime – Tuesday 5/10 11:30 AM
CLI208 – Anywhere Access to DataCLI208 – Anywhere Access to DataSpeaker – Markus EggerSpeaker – Markus EggerTime – Tuesday 5/10 3:00 PMTime – Tuesday 5/10 3:00 PM
CLI324 - Advanced Tablet PC Development TopicsCLI324 - Advanced Tablet PC Development TopicsSpeaker – Todd LandstadSpeaker – Todd LandstadTime – Wednesday 5/11 8:00 AMTime – Wednesday 5/11 8:00 AM
CLI325 - In Depth - Ink Data ManagementCLI325 - In Depth - Ink Data ManagementSpeaker – Stefan WickSpeaker – Stefan WickTime – Wednesday 5/11 9:30 AMTime – Wednesday 5/11 9:30 AM
CLI205 – Basic Considerations for Mobile PC DevelopmentCLI205 – Basic Considerations for Mobile PC DevelopmentSpeaker – Michelle McKelveySpeaker – Michelle McKelveyTime – Wednesday 5/11 11:30 AMTime – Wednesday 5/11 11:30 AM
CLI329 - Network AwarenessCLI329 - Network AwarenessSpeaker – Dr. Neil RoodynSpeaker – Dr. Neil RoodynTime – Thursday 5/12 8:00 AMTime – Thursday 5/12 8:00 AM
![Page 35: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/35.jpg)
Mobile Hands On Labs At MEDCMobile Hands On Labs At MEDC
Building Network-Aware Mobile PC ApplicationsBuilding Network-Aware Mobile PC ApplicationsBuild a network-aware application using the Build a network-aware application using the Windows Network Location Awareness Windows Network Location Awareness (NLA) API (NLA) API
Building Power-Aware Mobile PC ApplicationsBuilding Power-Aware Mobile PC ApplicationsLearn how to tune your applications to save Learn how to tune your applications to save power, extend battery life, and enhance the power, extend battery life, and enhance the user's mobile PC experience user's mobile PC experience
Building Managed Applications with Microsoft Building Managed Applications with Microsoft Windows XP Tablet PC SDK Windows XP Tablet PC SDK
Create a cool Tablet application using the Create a cool Tablet application using the Windows XP Tablet PC Edition SDK 1.7Windows XP Tablet PC Edition SDK 1.7
![Page 36: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/36.jpg)
The Tablet And Mobile The Tablet And Mobile PC Developer CenterPC Developer Center
http://msdn.microsoft.com/mobilepchttp://msdn.microsoft.com/mobilepc
![Page 37: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/37.jpg)
Mobile PC Developer CenterMobile PC Developer Center
The latest technical articlesThe latest technical articles
DownloadsDownloads
Developer resourcesDeveloper resources
Regular columnsRegular columns
..
NewsgroupsNewsgroups
Featured partnersFeatured partners
and more…and more…
![Page 38: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/38.jpg)
Attend a free chat or web castAttend a free chat or web casthttp://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp http://www.microsoft.com/usa/webcasts/default.asp
List of newsgroupsList of newsgroupshttp://communities2.microsoft.com/communities/newsgroups/en-us/default.aspxhttp://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx
MS Community SitesMS Community Siteshttp://www.microsoft.com/communities/default.mspx http://www.microsoft.com/communities/default.mspx
Locate Local User Groups and Community SitesLocate Local User Groups and Community Siteshttp://www.microsoft.com/communities/usergroups/default.mspx http://www.microsoft.com/communities/usergroups/default.mspx http://www.microsoft.com/communities/related/default.mspxhttp://www.microsoft.com/communities/related/default.mspx
![Page 39: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/39.jpg)
Questions?Questions?
Thank you!Thank you!
![Page 40: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/40.jpg)
While at MEDC 2005…While at MEDC 2005…Fill outFill out an evaluation for this session an evaluation for this session
Randomly selected instant Randomly selected instant WINWIN prizes! prizes!
Use Use real technology in a labreal technology in a lab Instructor led Instructor led Reef E/FReef E/F & & Breakers LBreakers L
Self-paced Self-paced Reef B/CReef B/C
VisitVisit the Microsoft Product Pavilion the Microsoft Product Pavilion
in the Exhibit Hall in the Exhibit Hall Shorelines BShorelines B
![Page 41: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/41.jpg)
After The Conference…After The Conference…
DevelopDevelop
BuildBuild
InstallInstall
BuildBuild
JoinJoin
InstallInstall
EnterEnter
JoinJoin
Full-featured trial versions of Windows CE Full-featured trial versions of Windows CE and/or Windows XP Embeddedand/or Windows XP Embedded
Cool stuff & tell us about it: Cool stuff & tell us about it: msdn.microsoft.com/embedded/community
Windows Embedded Partner Program:Windows Embedded Partner Program:www.mswep.com
Windows Mobile 5.0 Eval Kit including Windows Mobile 5.0 Eval Kit including Visual Studio 2005 Beta 2Visual Studio 2005 Beta 2
Mobile2Market Contest and win up to $25000: Mobile2Market Contest and win up to $25000: mobile2marketcontest.com mobile2marketcontest.com
Microsoft Solutions Partner Program:Microsoft Solutions Partner Program:partner.microsoft.com partner.microsoft.com
![Page 42: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/42.jpg)
Tools & ResourcesTools & Resources
msdn.microsoft.com/msdn.microsoft.com/ embeddedembedded
microsoft.public.microsoft.public. windowsxp.embeddedwindowsxp.embedded windowsce.platbuilderwindowsce.platbuilder windowsce.embedded.vcwindowsce.embedded.vc
blogs.msdn.com/blogs.msdn.com/ mikehallmikehall
Windows CE 5.0 Eval KitWindows CE 5.0 Eval KitWindows XP Embedded Eval KitWindows XP Embedded Eval Kit
msdn.microsoft.com/msdn.microsoft.com/ mobilitymobility
microsoft.public.microsoft.public. pocketpc.developer pocketpc.developer smartphone.developer smartphone.developer dotnet.framework.compactframeworkdotnet.framework.compactframework
blogs.msdn.com/blogs.msdn.com/ windowsmobilewindowsmobile vsdteamvsdteam netcfteamnetcfteam
Windows Mobile 5.0 Eval KitWindows Mobile 5.0 Eval Kit
WebsitesWebsites
NewsgroupsNewsgroups
BlogsBlogs
ToolsTools
BuildBuild DevelopDevelop
![Page 43: CLI329 Network Location Awareness Dr. Neil Roodyn](https://reader030.vdocument.in/reader030/viewer/2022020111/56649cf05503460f949bf3db/html5/thumbnails/43.jpg)
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.