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
33namespace fawkes {
34
35class NetworkNameResolver;
36
38{
39public:
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
88private:
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
Network name and address resolver.
Definition: resolver.h:45
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:38
std::string addr_string() const
Get IP address of entry as string.
Definition: service.cpp:420
~NetworkService()
Destructor.
Definition: service.cpp:184
bool operator==(const NetworkService &s) const
Equal operator for NetworkService reference.
Definition: service.cpp:457
void set_modified_name(const char *new_name) const
Set modified name of service.
Definition: service.cpp:360
const char * modified_name() const
Get modified name of service.
Definition: service.cpp:374
const char * type() const
Get type of service.
Definition: service.cpp:383
void set_txt(std::list< std::string > &txtlist)
Set TXT records all at once.
Definition: service.cpp:330
void add_txt(const char *format,...)
Add a TXT record.
Definition: service.cpp:313
unsigned short int port() const
Get port of service.
Definition: service.cpp:410
NetworkService & operator=(const NetworkService &s)
Assignment operator.
Definition: service.cpp:263
void set_name(const char *new_name)
Set name of service.
Definition: service.cpp:339
NetworkService(const char *name, const char *type, const char *domain, const char *host, unsigned short int port)
Constructor.
Definition: service.cpp:57
const char * name() const
Get name of service.
Definition: service.cpp:349
const char * host() const
Get host of service.
Definition: service.cpp:401
bool operator<(const NetworkService &s) const
Less than operator.
Definition: service.cpp:478
const char * domain() const
Get domain of service.
Definition: service.cpp:392
const std::list< std::string > & txt() const
Get TXT record list of service.
Definition: service.cpp:447
Fawkes library namespace.