UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
UPnPsdk::INetadapter Class Referenceabstract

Manage information from different platforms about network adapters. More...

#include <netadapter_if.hpp>

+ Inheritance diagram for UPnPsdk::INetadapter:

Public Member Functions

virtual void get_first ()=0
 Load a list of network adapters from the operating system and select its first entry.
 
virtual bool get_next ()=0
 Select next entry from the network adapter list that was initial loaded with get_first().
 
virtual unsigned int index () const =0
 Get index number from current selected list entry.
 
virtual std::string name () const =0
 Get network adapter name from current selected list entry.
 
virtual void sockaddr (SSockaddr &a_saddr) const =0
 Get socket address from current selected list entry.
 
virtual void socknetmask (SSockaddr &a_snetmask) const =0
 Get socket address netmask from current selected list entry.
 
virtual unsigned int bitmask () const =0
 Get prefix length from the ip address of the current selected local network adapter.
 
virtual void reset () noexcept=0
 Reset pointer and point to the first entry of the local network adapter list if available.
 

Detailed Description

Manage information from different platforms about network adapters.

// Usage e.g.:
CNetadapter nadaptObj;
try {
nadaptObj.get_first();
} catch(xcp) { handle_error(); };
SSockaddr saddrObj;
do {
std::cout << "adapter name is " << nadaptObj.name() << '\n';
nadaptObj.sockaddr(saddrObj);
std::cout << "adapter address is " << saddrObj.netaddrp() << '\n';
nadaptObj.socknetmask(saddrObj);
std::cout << "with netmask " << saddrObj.netaddr() << '\n';
} while (nadaptObj.get_next());
Get information from local network adapters.
UPnPsdk_API void get_first()
Load a list of network adapters from the operating system and select its first entry.
UPnPsdk_API void socknetmask(SSockaddr &a_snetmask) const
Get socket address netmask from current selected list entry.
UPnPsdk_API void sockaddr(SSockaddr &a_saddr) const
Get socket address from current selected list entry.
UPnPsdk_API std::string name() const
Get network adapter name from current selected list entry.
UPnPsdk_API bool get_next()
Select next entry from the network adapter list that was initial loaded with get_first().

Used to get information from the local network adapters. Encapsulate it in a class to get a common C++ interface to the program for different platform realisations, for example on Unix like platforms and on Microsoft Windows. They use different system calls.

Definition at line 44 of file netadapter_if.hpp.

Constructor & Destructor Documentation

◆ INetadapter()

UPnPsdk::INetadapter::INetadapter ( )

Definition at line 14 of file netadapter_if.cpp.

◆ ~INetadapter()

UPnPsdk::INetadapter::~INetadapter ( )
virtual

Definition at line 18 of file netadapter_if.cpp.

Member Function Documentation

◆ get_first()

virtual void UPnPsdk::INetadapter::get_first ( )
pure virtual

Load a list of network adapters from the operating system and select its first entry.

Exceptions
std::runtime_errorFailed to get information from the network adapters: (detail information appended)

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ get_next()

virtual bool UPnPsdk::INetadapter::get_next ( )
pure virtual

Select next entry from the network adapter list that was initial loaded with get_first().

Returns
  • true if next adapter in the list exists
  • false otherwise

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ index()

virtual unsigned int UPnPsdk::INetadapter::index ( ) const
pure virtual

Get index number from current selected list entry.

This is the unique number of a network adapter as given by the operating system. It is the best way to identify a network adapter. 0 means the unspecified, unavailable adapter.

Returns
  • 0 if the local network adapter does not exist. This should only be possible if you haven't successful selected an adapter before.
  • otherwise index number of the selected adapter.

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ name()

virtual std::string UPnPsdk::INetadapter::name ( ) const
pure virtual

Get network adapter name from current selected list entry.

Returns
  • "" (empty string) if the local network adapter does not exist. This should only be possible if you haven't successful selected an adapter before.
  • otherwise name of the local network adapter like "lo", "wlan0", "Ethernet". etc.

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ sockaddr()

virtual void UPnPsdk::INetadapter::sockaddr ( SSockaddr a_saddr) const
pure virtual

Get socket address from current selected list entry.

Parameters
[in,out]a_saddrReference to a socket address object that will be filled with the socket address from the current selected network adapter list entry.

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ socknetmask()

virtual void UPnPsdk::INetadapter::socknetmask ( SSockaddr a_snetmask) const
pure virtual

Get socket address netmask from current selected list entry.

This netmask belongs to the adapters network address that is current selected.

Parameters
[in,out]a_snetmaskReference to a socket address object that will be filled with the socket address netmask from the current selected network adapter list entry.

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ bitmask()

virtual unsigned int UPnPsdk::INetadapter::bitmask ( ) const
pure virtual

Get prefix length from the ip address of the current selected local network adapter.

Returns
Prefix length of the ip address from the current selected local network adapter.

Implemented in UPnPsdk::CNetadapter_platform, and UPnPsdk::CNetadapter_platform.

◆ reset()

virtual void UPnPsdk::INetadapter::reset ( )
pure virtualnoexcept

Reset pointer and point to the first entry of the local network adapter list if available.

Implemented in UPnPsdk::CNetadapter_platform.


The documentation for this class was generated from the following files: