MCS  0.3.3-alpha7
mcs::NetInterface Class Reference

Retrieve informations about network interfaces. More...

#include <mcs.hh>

+ Inheritance diagram for mcs::NetInterface:

Public Member Functions

unsigned int count ()
 Return how many network interfaces are present in the system. More...
 
unsigned int index ()
 Return the index of the actual interface. More...
 
string ipaddress (int index=-1)
 Return the IP address of an interface. More...
 
string name (int index=-1)
 Return the name of an interface. More...
 
 NetInterface (string name="lo")
 Constructor. More...
 
 NetInterface (const NetInterface &)
 Declared to avoid using of default copy constructor. More...
 
NetInterfaceoperator= (const NetInterface &)
 Declared to avoid using of default assignment operator. More...
 
 ~NetInterface ()
 Destructor. More...
 

Protected Member Functions

int getflags ()
 
bool isup ()
 
int req (int ioctl_num, struct ifreq *ifr)
 
void str_sockaddr (struct sockaddr *sa)
 
void str_sockaddr_in (struct sockaddr_in *sin)
 

Protected Attributes

unsigned int lindex
 
vector< string > names
 Vector containing the name of all interfaces present in the system. More...
 

Detailed Description

Retrieve informations about network interfaces.

This class can be used to obtain informations such as the name or the IP address of a network interface. It is used by the ServerSocket class to obtain a "struct sockaddr_in" needed to create a server socket.

Definition at line 1487 of file mcs.hh.

Constructor & Destructor Documentation

◆ NetInterface() [1/2]

mcs::NetInterface::NetInterface ( string  name = "lo")

Constructor.

This constructor create a NetInterface objects linked to the interface named in the first parameter, so that any call to methods will return informations about this interface. If you want to know the names of the interfaces present in the system you should create the object without any parameter (deafult value for name is "lo"), then call the name() method with an index going from 0 to count().

Parameters
nameName of the interface, default is "lo" for the localhost interface (127.0.0.1).

Definition at line 38 of file Socket.cc.

◆ ~NetInterface()

mcs::NetInterface::~NetInterface ( )

Destructor.

Definition at line 66 of file Socket.cc.

◆ NetInterface() [2/2]

mcs::NetInterface::NetInterface ( const NetInterface )

Declared to avoid using of default copy constructor.

Warning
This constructor is declared but not implemented. If you try to use it you will get a compilation error.

Member Function Documentation

◆ count()

unsigned int mcs::NetInterface::count ( )

Return how many network interfaces are present in the system.

Definition at line 87 of file Socket.cc.

◆ index()

unsigned int mcs::NetInterface::index ( )

Return the index of the actual interface.

Definition at line 82 of file Socket.cc.

◆ ipaddress()

string mcs::NetInterface::ipaddress ( int  index = -1)

Return the IP address of an interface.

If no argument is given will return the address of the actual interface, otherwise will return the address of the interface with the index equal to the argument. Note that the index must be less then count().

Parameters
indexInterface index, default is -1 for actual interface.

Definition at line 144 of file Socket.cc.

◆ name()

string mcs::NetInterface::name ( int  index = -1)

Return the name of an interface.

If no argument is given will return the name of the actual interface, otherwise will return the name of the interface with the index equal to the argument. Note that the index must be less then count().

Parameters
indexInterface index, default is -1 for actual interface.

Definition at line 70 of file Socket.cc.

◆ operator=()

NetInterface& mcs::NetInterface::operator= ( const NetInterface )

Declared to avoid using of default assignment operator.

Warning
This operator is declared but not implemented. If you try to use

Member Data Documentation

◆ names

vector<string> mcs::NetInterface::names
protected

Vector containing the name of all interfaces present in the system.

Definition at line 1499 of file mcs.hh.


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

mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha7
Documentation generated on Mon May 28 07:39:41 UTC 2018