gloox  1.0.28
linklocalclient.h
1 /*
2  Copyright (c) 2012-2023 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef LINKLOCALCLIENT_H__
15 #define LINKLOCALCLIENT_H__
16 
17 #include "config.h"
18 
19 #ifdef HAVE_MDNS
20 
21 #include "client.h"
22 #include "jid.h"
23 
24 #include <string>
25 
26 #include <dns_sd.h>
27 
28 namespace gloox
29 {
30 
31  class Tag;
32 
33  namespace LinkLocal
34  {
35 
45  class Client : public gloox::Client
46  {
47  public:
52  Client( const JID& jid );
53 
57  virtual ~Client();
58 
63  bool connect();
64 
75  bool connect( const std::string& service, const std::string& type, const std::string& domain, int iface = 0 );
76 
83  virtual ConnectionError recv( int timeout = -1 );
84 
85  // reimplemented from ConnectionDataHandler, overwriting ClientBase::handleConnect()
86  virtual void handleConnect( const ConnectionBase* connection );
87 
88  protected:
89  // reimplemented from ClientBase
90  virtual void handleStartNode( const Tag* start );
91 
92  private:
93  static void handleResolveReply( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
94  DNSServiceErrorType errorCode, const char *fullname, const char *hosttarget,
95  uint16_t port, uint16_t txtLen, const unsigned char *txtRecord, void *context );
96  static void handleQueryReply( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
97  DNSServiceErrorType errorCode, const char *fullname, uint16_t rrtype,
98  uint16_t rrclass, uint16_t rdlen, const void *rdata, uint32_t ttl,
99  void *context );
100 
101  bool resolve( const std::string& serviceName, const std::string& regtype, const std::string& replyDomain );
102  bool query( const std::string& hostname, int port );
103  void handleQuery( const std::string& addr );
104  void sendStart( const std::string& to );
105 
106  DNSServiceRef m_qRef;
107  DNSServiceRef m_rRef;
108  DNSServiceRef m_currentRef;
109 
110  std::string m_to;
111 
112  int m_interface;
113  int m_port;
114 
115  bool m_streamSent;
116 
117  };
118 
119  }
120 
121 }
122 
123 #endif // HAVE_MDNS
124 
125 #endif // LINKLOCALCLIENT_H__
int port() const
Definition: clientbase.h:221
const JID & jid()
Definition: clientbase.h:147
This class implements a basic Jabber/XMPP Client.
Definition: client.h:117
An abstract base class for a connection.
An abstraction of a JID.
Definition: jid.h:31
An implementation of a link-local client.
virtual ConnectionError recv(int timeout=-1)
virtual void handleConnect(const ConnectionBase *connection)
virtual void handleStartNode(const Tag *start)
This is an abstraction of an XML element.
Definition: tag.h:47
The namespace for the gloox library.
Definition: adhoc.cpp:28
ConnectionError
Definition: gloox.h:684