Fawkes API  Fawkes Development Version
fawkes::NetworkService Class Reference

Representation of a service announced or found via service discovery (i.e. More...

#include <>>

List of all members.

Public Member Functions

 NetworkService (const char *name, const char *type, const char *domain, const char *host, unsigned short int port)
 Constructor.
 NetworkService (const char *name, const char *type, const char *domain, const char *host, unsigned short int port, const struct sockaddr *addr, const socklen_t addr_size, std::list< std::string > &txt)
 Constructor.
 NetworkService (const char *name, const char *type, unsigned short int port)
 Constructor.
 NetworkService (const char *name, const char *type, const char *domain)
 Constructor.
 NetworkService (NetworkNameResolver *nnresolver, const char *name, const char *type, unsigned short int port)
 Constructor.
 NetworkService (const NetworkService *s)
 Copy constructor (pointer).
 NetworkService (const NetworkService &s)
 Copy constructor (reference).
 ~NetworkService ()
 Destructor.
void add_txt (const char *format,...)
 Add a TXT record.
void set_txt (std::list< std::string > &txtlist)
 Set TXT records all at once.
void set_name (const char *new_name)
 Set name of service.
void set_modified_name (const char *new_name) const
 Set modified name of service.
const char * name () const
 Get name of service.
const char * modified_name () const
 Get modified name of service.
const char * type () const
 Get type of service.
const char * domain () const
 Get domain of service.
const char * host () const
 Get host of service.
std::string addr_string () const
 Get IP address of entry as string.
unsigned short int port () const
 Get port of service.
const std::list< std::string > & txt () const
 Get TXT record list of service.
bool operator== (const NetworkService &s) const
 Equal operator for NetworkService reference.
bool operator== (const NetworkService *s) const
 Equal operator for NetworkService pointer.
bool operator< (const NetworkService &s) const
 Less than operator.

Detailed Description

Representation of a service announced or found via service discovery (i.e.

mDNS/DNS-SD via Avahi). This class is used in the C++ wrapper to talk about services.

Author:
Tim Niemueller

Constructor & Destructor Documentation

fawkes::NetworkService::NetworkService ( const char *  name,
const char *  type,
const char *  domain,
const char *  host,
unsigned short int  port 
)

Constructor.

This constructor sets all parameters.

Parameters:
namename of service
typetype of service
domaindomain of service
hosthost of service
portport of service

Definition at line 60 of file service.cpp.

fawkes::NetworkService::NetworkService ( const char *  name,
const char *  type,
const char *  domain,
const char *  host,
unsigned short int  port,
const struct sockaddr *  addr,
const socklen_t  addr_size,
std::list< std::string > &  txt 
)

Constructor.

This constructor sets all parameters.

Parameters:
namename of service
typetype of service
domaindomain of service
hosthost of service
portport of service
addraddress of the service
addr_sizesize in bytes of addr parameter
txtlist of TXT records

Definition at line 90 of file service.cpp.

fawkes::NetworkService::NetworkService ( const char *  name,
const char *  type,
unsigned short int  port 
)

Constructor.

This constructor sets all parameters. Host and domain are the default values, which means local host name in domain .local (if not set otherwise in Avahi system configuration).

Parameters:
namename of service
typetype of service
portport of service

Definition at line 123 of file service.cpp.

fawkes::NetworkService::NetworkService ( const char *  name,
const char *  type,
const char *  domain 
)

Constructor.

This constructor sets all parameters.

Parameters:
namename of service
typetype of service
domaindomain of service

Definition at line 180 of file service.cpp.

fawkes::NetworkService::NetworkService ( NetworkNameResolver nnresolver,
const char *  name,
const char *  type,
unsigned short int  port 
)

Constructor.

This constructor sets all parameters. Host and domain are the default values, which means local host name in domain .local (if not set otherwise in Avahi system configuration). This specific constructor allows the usage of a "%h" token in the name, which is replaced with the short hostname.

Parameters:
nnresolvernetwork name resolver to get the host from for the replacement of a h token.
namename of service
typetype of service
portport of service

Definition at line 152 of file service.cpp.

References fawkes::NetworkNameResolver::short_hostname().

fawkes::NetworkService::NetworkService ( const NetworkService s)

Copy constructor (pointer).

Create a copy of given NetworkService.

Parameters:
snetwork service to copy from

Definition at line 213 of file service.cpp.

fawkes::NetworkService::NetworkService ( const NetworkService s)

Copy constructor (reference).

Create a copy of given NetworkService.

Parameters:
snetwork service to copy from

Definition at line 245 of file service.cpp.

fawkes::NetworkService::~NetworkService ( )

Destructor.

Definition at line 198 of file service.cpp.


Member Function Documentation

void fawkes::NetworkService::add_txt ( const char *  format,
  ... 
)

Add a TXT record.

Parameters:
formatformat for TXT record to add, must be a "key=value" string, takes the same arguments as sprintf.

Definition at line 278 of file service.cpp.

Referenced by WebviewThread::init(), and XmlRpcThread::init().

std::string fawkes::NetworkService::addr_string ( ) const

Get IP address of entry as string.

Returns:
IP address as string
Exceptions:
NullPointerExceptionthrown if the address has not been set

Definition at line 394 of file service.cpp.

const char * fawkes::NetworkService::domain ( ) const

Get domain of service.

Returns:
domain of service

Definition at line 363 of file service.cpp.

const char * fawkes::NetworkService::host ( ) const

Get host of service.

Returns:
host of service

Definition at line 373 of file service.cpp.

const char * fawkes::NetworkService::modified_name ( ) const

Get modified name of service.

The modified name is the original name with a suffix that has been added to resolve a name collision.

Returns:
modified name of service, this may be NULL if the name has not been modified

Definition at line 343 of file service.cpp.

const char * fawkes::NetworkService::name ( ) const

Get name of service.

Returns:
name of service

Definition at line 317 of file service.cpp.

bool fawkes::NetworkService::operator< ( const NetworkService s) const

Less than operator.

Parameters:
sreference of service to compare to
Returns:
true, if either the type is less than (according to strcmp) or if types are equal if the service name is less than the given service's name.

Definition at line 442 of file service.cpp.

bool fawkes::NetworkService::operator== ( const NetworkService s) const

Equal operator for NetworkService reference.

Parameters:
sreference of service to compare to.
Returns:
true, if the services are the same (same name and type), false otherwise

Definition at line 417 of file service.cpp.

bool fawkes::NetworkService::operator== ( const NetworkService s) const

Equal operator for NetworkService pointer.

Parameters:
spointer to service to compare to.
Returns:
true, if the services are the same (same name and type), false otherwise

Definition at line 429 of file service.cpp.

unsigned short int fawkes::NetworkService::port ( ) const

Get port of service.

Returns:
port of service

Definition at line 383 of file service.cpp.

void fawkes::NetworkService::set_modified_name ( const char *  new_name) const

Set modified name of service.

The modified name is the original name with a suffix that has been added to resolve a name collision.

Parameters:
new_namenew name

Definition at line 329 of file service.cpp.

void fawkes::NetworkService::set_name ( const char *  new_name)

Set name of service.

Parameters:
new_namenew name

Definition at line 306 of file service.cpp.

void fawkes::NetworkService::set_txt ( std::list< std::string > &  txtlist)

Set TXT records all at once.

Parameters:
txtlistlist of TXT records

Definition at line 296 of file service.cpp.

const std::list< std::string > & fawkes::NetworkService::txt ( ) const

Get TXT record list of service.

Returns:
TXT record list of service

Definition at line 406 of file service.cpp.

const char * fawkes::NetworkService::type ( ) const

Get type of service.

Returns:
type of service

Definition at line 353 of file service.cpp.


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