source: source/ariba/utility/bootstrap/modules/multicastdns/MulticastDns.h@ 4843

Last change on this file since 4843 was 4836, checked in by Christoph Mayer, 15 years ago

einige avahi fixes und ablauf

File size: 4.1 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef __MULTICAST_DNS_H
40#define __MULTICAST_DNS_H
41
42#include "ariba/config.h"
43
44#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
45 #include <avahi-client/client.h>
46 #include <avahi-client/lookup.h>
47 #include <avahi-client/publish.h>
48 #include <avahi-common/alternative.h>
49 #include <avahi-common/thread-watch.h>
50 #include <avahi-common/malloc.h>
51 #include <avahi-common/error.h>
52 #include <avahi-common/timeval.h>
53#endif // HAVE_AVAHI_CLIENT_CLIENT_H
54
55#include <iostream>
56#include <string>
57#include <map>
58#include <boost/thread/mutex.hpp>
59#include <boost/thread/thread.hpp>
60#include "ariba/utility/bootstrap/modules/BootstrapModule.h"
61#include "ariba/utility/logging/Logging.h"
62
63using std::string;
64using std::map;
65using std::make_pair;
66
67namespace ariba {
68namespace utility {
69
70class MulticastDns : public BootstrapModule {
71 use_logging_h(MulticastDns);
72public:
73 MulticastDns(BootstrapInformationCallback* _callback);
74 virtual ~MulticastDns();
75
76 virtual void start();
77 virtual void stop();
78
79 virtual string getName();
80 virtual string getInformation();
81 virtual bool isFunctional();
82 virtual void publishService(string name, string info1, string info2, string info3);
83 virtual void revokeService(string name);
84
85private:
86 static const string serviceType;
87
88#ifdef HAVE_AVAHI_CLIENT_CLIENT_H
89
90 AvahiClient* avahiclient;
91 AvahiThreadedPoll* avahipoll;
92 AvahiServiceBrowser* avahibrowser;
93
94 typedef map<string, AvahiEntryGroup*> AvahiGroupMap;
95 AvahiGroupMap avahigroups;
96
97 static void client_callback(
98 AvahiClient* client,
99 AvahiClientState state,
100 void* userdata
101 );
102
103 static void entry_group_callback(
104 AvahiEntryGroup* group,
105 AvahiEntryGroupState state,
106 void* userdata);
107
108 static void browse_callback(
109 AvahiServiceBrowser* browser,
110 AvahiIfIndex interface,
111 AvahiProtocol protocol,
112 AvahiBrowserEvent event,
113 const char* name,
114 const char* type,
115 const char* domain,
116 AvahiLookupResultFlags flags,
117 void* userdata);
118
119 static void resolve_callback(
120 AvahiServiceResolver* resolver,
121 AvahiIfIndex interface,
122 AvahiProtocol protocol,
123 AvahiResolverEvent event,
124 const char* name,
125 const char* type,
126 const char* domain,
127 const char* host_name,
128 const AvahiAddress* address,
129 uint16_t port,
130 AvahiStringList* txt,
131 AvahiLookupResultFlags flags,
132 void* userdata
133 );
134
135#endif // HAVE_AVAHI_CLIENT_CLIENT_H
136
137};
138
139}} //namespace ariba, utility
140
141#endif // __MULTICAST_DNS_H
Note: See TracBrowser for help on using the repository browser.