Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 *_addr;
98  socklen_t _addr_size;
99 
100  mutable char * _modified_name;
101 };
102 
103 } // end namespace fawkes
104 
105 #endif