Public Member Functions

fawkes::NetworkService Class Reference
[Fawkes Network Communication]

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.
const char * name () const
 Get 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

Definition at line 37 of file service.h.


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:
name name of service
type type of service
domain domain of service
host host of service
port port 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:
name name of service
type type of service
domain domain of service
host host of service
port port of service
addr address of the service
addr_size size in bytes of addr parameter
txt list of TXT records

Definition at line 88 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:
name name of service
type type of service
port port of service

Definition at line 119 of file service.cpp.

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

Constructor.

This constructor sets all parameters.

Parameters:
name name of service
type type of service
domain domain of service

Definition at line 172 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:
nnresolver network name resolver to get the host from for the replacement of a h token.
name name of service
type type of service
port port of service

Definition at line 146 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:
s network service to copy from

Definition at line 202 of file service.cpp.

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

Copy constructor (reference).

Create a copy of given NetworkService.

Parameters:
s network service to copy from

Definition at line 229 of file service.cpp.

fawkes::NetworkService::~NetworkService (  ) 

Destructor.

Definition at line 188 of file service.cpp.


Member Function Documentation

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

Add a TXT record.

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

Definition at line 257 of file service.cpp.

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

Get IP address of entry as string.

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

Definition at line 347 of file service.cpp.

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

Get domain of service.

Returns:
domain of service

Definition at line 316 of file service.cpp.

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

Get host of service.

Returns:
host of service

Definition at line 326 of file service.cpp.

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

Get name of service.

Returns:
name of service

Definition at line 296 of file service.cpp.

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

Less than operator.

Parameters:
s reference 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 395 of file service.cpp.

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

Equal operator for NetworkService pointer.

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

Definition at line 382 of file service.cpp.

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

Equal operator for NetworkService reference.

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

Definition at line 370 of file service.cpp.

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

Get port of service.

Returns:
port of service

Definition at line 336 of file service.cpp.

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

Set name of service.

Parameters:
new_name new name

Definition at line 285 of file service.cpp.

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

Set TXT records all at once.

Parameters:
txtlist list of TXT records

Definition at line 275 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 359 of file service.cpp.

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

Get type of service.

Returns:
type of service

Definition at line 306 of file service.cpp.


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