2 * Worldvisions Weaver Software:
3 * Copyright (C) 2004 Net Integration Technologies, Inc.
6 * Hubert Figuiere <hub@nit.ca>
8 * This is the Zeroconf browser class
9 * Needs Howl http://www.porchdogsoft.com/products/howl/
15 #ifndef _WVZEROCONF_H_
16 #define _WVZEROCONF_H_
20 #include "wvfdstream.h"
22 #include "wvlinklist.h"
25 class WvZeroconfBrowser
;
28 This data model describe a ZeroConf service
30 class WvZeroconfService
33 WvZeroconfService(WvZeroconfBrowser
&_resolver
,
34 sw_discovery_browse_status _status
,
35 sw_const_string _name
,
36 sw_const_string _type
,
37 sw_const_string _domain
,
38 sw_uint32 _interface_index
)
39 : resolver(_resolver
), status(_status
), name(_name
),
40 type(_type
), domain(_domain
), interface_index(_interface_index
)
44 WvZeroconfService(const WvZeroconfService
&_obj
)
45 : resolver(_obj
.resolver
), status(_obj
.status
), name(_obj
.name
),
46 type(_obj
.type
), domain(_obj
.domain
),
47 interface_index(_obj
.interface_index
)
51 /** will store the ip in cfg["ip"] and the port in cfg["port"] */
52 bool resolve(UniConf
&cfg
);
54 WvZeroconfBrowser
&resolver
;
55 sw_discovery_browse_status status
;
60 sw_uint32 interface_index
;
62 static sw_result
zeroconf_resolver(sw_discovery discovery
,
64 sw_uint32 interface_index
,
67 sw_const_string domain
,
68 sw_ipv4_address address
,
70 sw_octets text_record
,
71 sw_uint32 text_record_len
,
76 Listen for a specific ZeroConf declared service using mDNS
78 class WvZeroconfBrowser
83 sw_discovery zeroconf_session
;
84 WvList
<WvZeroconfService
> services
;
87 WvZeroconfBrowser(WvStringParm service
);
92 Pop a WvZeroconfService from the registered services
93 found on the network. The value is poped out of the
94 list, se next call, it will be different.
96 \retval returns a newly allocated WvZeroconfService
97 that should be deleted by the caller after use.
99 WvZeroconfService
*pop_first_service(void);
101 { return !isok() || services
.isempty(); };
103 /** publish the ZeroConf service name of type on port */
104 bool publish(WvStringParm name
, WvStringParm type
, WvStringParm port
);
106 /** returns the session for zeroconf */
107 sw_discovery
session(void)
109 return zeroconf_session
;
113 virtual ~WvZeroconfBrowser();
115 virtual void execute(void);
118 /* all of these are forbidden to be used */
119 virtual size_t read(void *buf
, size_t count
)
121 virtual size_t read(WvBuf
&outbuf
, size_t count
)
123 virtual void unread(WvBuf
&outbuf
, size_t count
)
125 virtual size_t write(const void *buf
, size_t count
)
127 virtual size_t write(WvBuf
&inbuf
, size_t count
= INT_MAX
)
129 virtual size_t uread(void *buf
, size_t count
)
131 virtual size_t uwrite(const void *buf
, size_t count
)
135 sw_result
_zeroconf_browser(sw_discovery discovery
, sw_discovery_oid oid
,
136 sw_discovery_browse_status status
,
137 sw_uint32 interface_index
,
138 sw_const_string name
, sw_const_string type
,
139 sw_const_string domain
);
141 /* libhowl callbacks */
142 static sw_result
zeroconf_browser(sw_discovery discovery
,
143 sw_discovery_oid oid
,
144 sw_discovery_browse_status status
,
145 sw_uint32 interface_index
,
146 sw_const_string name
,
147 sw_const_string type
,
148 sw_const_string domain
,
150 static sw_result
zeroconf_resolver(sw_discovery discovery
,
151 sw_discovery_oid oid
,
152 sw_uint32 interface_index
,
153 sw_const_string name
,
154 sw_const_string type
,
155 sw_const_string domain
,
156 sw_ipv4_address address
,
158 sw_octets text_record
,
159 sw_uint32 text_record_len
,