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 <string>
28 #include <list>
29 
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 
33 namespace fawkes {
34 
35 class NetworkNameResolver;
36 
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,
56  const char *type,
57  unsigned short int port);
58 
59  NetworkService(const char *name,
60  const char *type,
61  const char *domain);
62 
64  const char *name, const char *type,
65  unsigned short int port);
66 
70 
71  void add_txt(const char *format, ...);
72  void set_txt(std::list<std::string> &txtlist);
73 
74  void set_name(const char *new_name);
75  void set_modified_name(const char *new_name) const;
76 
77  const char * name() const;
78  const char * modified_name() const;
79  const char * type() const;
80  const char * domain() const;
81  const char * host() const;
82  std::string addr_string() const;
83  unsigned short int port() const;
84  const std::list<std::string> & txt() const;
85 
86  bool operator==(const NetworkService &s) const;
87  bool operator==(const NetworkService *s) const;
88  bool operator<(const NetworkService &s) const;
89 
90  private:
91  std::list<std::string> list;
92  char * _name;
93  char * _type;
94  char * _domain;
95  char * _host;
96  unsigned short int _port;
97  struct sockaddr_storage _addr;
98 
99  mutable char * _modified_name;
100 };
101 
102 } // end namespace fawkes
103 
104 #endif
Fawkes library namespace.
const char * host() const
Get host of service.
Definition: service.cpp:368
std::string addr_string() const
Get IP address of entry as string.
Definition: service.cpp:389
unsigned short int port() const
Get port of service.
Definition: service.cpp:378
void set_name(const char *new_name)
Set name of service.
Definition: service.cpp:301
void add_txt(const char *format,...)
Add a TXT record.
Definition: service.cpp:273
NetworkService(const char *name, const char *type, const char *domain, const char *host, unsigned short int port)
Constructor.
Definition: service.cpp:60
const char * modified_name() const
Get modified name of service.
Definition: service.cpp:338
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:37
Network name and address resolver.
Definition: resolver.h:48
void set_txt(std::list< std::string > &txtlist)
Set TXT records all at once.
Definition: service.cpp:291
bool operator<(const NetworkService &s) const
Less than operator.
Definition: service.cpp:453
const std::list< std::string > & txt() const
Get TXT record list of service.
Definition: service.cpp:417
bool operator==(const NetworkService &s) const
Equal operator for NetworkService reference.
Definition: service.cpp:428
const char * domain() const
Get domain of service.
Definition: service.cpp:358
~NetworkService()
Destructor.
Definition: service.cpp:196
const char * type() const
Get type of service.
Definition: service.cpp:348
void set_modified_name(const char *new_name) const
Set modified name of service.
Definition: service.cpp:324
const char * name() const
Get name of service.
Definition: service.cpp:312