Fawkes API  Fawkes Development Version
service.h
1 
2 /***************************************************************************
3  * service.h - Network service representation
4  *
5  * Generated: Tue Nov 07 17:58:10 2006
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _NETCOMM_SERVICE_DISCOVERY_SERVICE_H_
25 #define _NETCOMM_SERVICE_DISCOVERY_SERVICE_H_
26 
27 #include <sys/socket.h>
28 #include <sys/types.h>
29 
30 #include <list>
31 #include <string>
32 
33 namespace fawkes {
34 
35 class NetworkNameResolver;
36 
37 class NetworkService
38 {
39 public:
40  NetworkService(const char * name,
41  const char * type,
42  const char * domain,
43  const char * host,
44  unsigned short int port);
45 
46  NetworkService(const char * name,
47  const char * type,
48  const char * domain,
49  const char * host,
50  unsigned short int port,
51  const struct sockaddr * addr,
52  const socklen_t addr_size,
53  std::list<std::string> &txt);
54 
55  NetworkService(const char *name, const char *type, unsigned short int port);
56 
57  NetworkService(const char *name, const char *type, const char *domain);
58 
60  const char * name,
61  const char * type,
62  unsigned short int port);
63 
67 
68  void add_txt(const char *format, ...);
69  void set_txt(std::list<std::string> &txtlist);
70 
71  void set_name(const char *new_name);
72  void set_modified_name(const char *new_name) const;
73 
74  const char * name() const;
75  const char * modified_name() const;
76  const char * type() const;
77  const char * domain() const;
78  const char * host() const;
79  std::string addr_string() const;
80  unsigned short int port() const;
81  const std::list<std::string> &txt() const;
82 
84  bool operator==(const NetworkService &s) const;
85  bool operator==(const NetworkService *s) const;
86  bool operator<(const NetworkService &s) const;
87 
88 private:
89  std::list<std::string> list;
90  char * _name;
91  char * _type;
92  char * _domain;
93  char * _host;
94  unsigned short int _port;
95  struct sockaddr_storage _addr;
96 
97  mutable char *_modified_name;
98 };
99 
100 } // end namespace fawkes
101 
102 #endif
fawkes::NetworkService::NetworkService
NetworkService(const char *name, const char *type, const char *domain, const char *host, unsigned short int port)
Constructor.
Definition: service.cpp:61
fawkes::NetworkService::set_modified_name
void set_modified_name(const char *new_name) const
Set modified name of service.
Definition: service.cpp:364
fawkes::NetworkService::operator<
bool operator<(const NetworkService &s) const
Less than operator.
Definition: service.cpp:482
fawkes::NetworkNameResolver
Definition: resolver.h:48
fawkes::NetworkService::modified_name
const char * modified_name() const
Get modified name of service.
Definition: service.cpp:378
fawkes::NetworkService::set_txt
void set_txt(std::list< std::string > &txtlist)
Set TXT records all at once.
Definition: service.cpp:334
fawkes::NetworkService::domain
const char * domain() const
Get domain of service.
Definition: service.cpp:396
fawkes::NetworkService::txt
const std::list< std::string > & txt() const
Get TXT record list of service.
Definition: service.cpp:451
fawkes::NetworkService::host
const char * host() const
Get host of service.
Definition: service.cpp:405
fawkes::NetworkService
Definition: service.h:41
fawkes
fawkes::NetworkService::port
unsigned short int port() const
Get port of service.
Definition: service.cpp:414
fawkes::NetworkService::operator==
bool operator==(const NetworkService &s) const
Equal operator for NetworkService reference.
Definition: service.cpp:461
fawkes::NetworkService::~NetworkService
~NetworkService()
Destructor.
Definition: service.cpp:188
fawkes::NetworkService::set_name
void set_name(const char *new_name)
Set name of service.
Definition: service.cpp:343
fawkes::NetworkService::type
const char * type() const
Get type of service.
Definition: service.cpp:387
fawkes::NetworkService::operator=
NetworkService & operator=(const NetworkService &s)
Assignment operator.
Definition: service.cpp:267
fawkes::NetworkService::name
const char * name() const
Get name of service.
Definition: service.cpp:353
fawkes::NetworkService::addr_string
std::string addr_string() const
Get IP address of entry as string.
Definition: service.cpp:424
fawkes::NetworkService::add_txt
void add_txt(const char *format,...)
Add a TXT record.
Definition: service.cpp:317