scclib
Stable Cloud Computing C++ Library
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
scc::net::NetIf Class Reference

A network interface. More...

#include <net_if.h>

Public Types

enum class  SocketType { any , tcp_stream , udp_datagram }
 

Public Member Functions

const std::string & name () const
 Name of the interface.
 
const int index () const
 The interface index.
 
const std::string & hw_addr () const
 Hardware address for the interface.
 
const size_t speed () const
 Link speed in bytes / second, 0 means loopback.
 
const size_t mtu () const
 Maximum transmission unit.
 
int flags () const
 Flags for this interface. More...
 
bool test_flags (int f) const
 
const std::vector< NetIfAddr > & addrs () const
 Zero or more addresses associated with this interface.
 
std::string str () const
 String representation of network interface. More...
 

Static Public Member Functions

static std::vector< NetIfall_interfaces ()
 List network interfaces on the local system.
 
static std::vector< InetAddrhost_addrs (const std::string &name, SocketType=SocketType::any)
 List addresses for the specified host (do a name lookup). More...
 

Friends

class NetIfIterator
 

Detailed Description

A network interface.

Contains zero or more internet addresses.

Examples
examples/net/netmain.cc, and net/unittest/net_if.cc.

Definition at line 89 of file net_if.h.

Member Function Documentation

◆ flags()

int scc::net::NetIf::flags ( ) const
inline

Flags for this interface.

Returns
NetIfFlag bit mask.

Definition at line 149 of file net_if.h.

◆ host_addrs()

std::vector< InetAddr > NetIf::host_addrs ( const std::string &  name,
NetIf::SocketType  type = SocketType::any 
)
static

List addresses for the specified host (do a name lookup).

Returns a list of host addresses to that can used with bind() or connect().

Can specify a filter for a specific capability (tcp or udp).

This will carry out a name resolution and return the list of addresses that map to the host name.

If both ipv4 and ipv6 are specified, ipv6 addresses are preferred.

Definition at line 57 of file net_if.cc.

◆ str()

std::string NetIf::str ( ) const

String representation of network interface.

Lists all associated addresses.

Definition at line 237 of file net_if.cc.


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