Commit Graph

56 Commits

Author SHA1 Message Date
hgy59
30f33b1b1d mdns_init: avoid null reference access
- when avahi client creation fails with mdns_client=null, use avahi_strerror(error) instead of MDNSERR
  to avoid access to mdns_client->error.
2022-05-22 20:56:49 +02:00
ejurgensen
5f1686695a [-] Name update forked-daapd -> owntone throughout the code 2021-04-24 23:54:20 +02:00
ejurgensen
dd0f0ece78 [mdns] Remove ipv4/ipv6 argument to mdns_browse
Make sure mdns_browse() always works the same, and follows user config.
2021-03-31 23:55:25 +02:00
ejurgensen
6836a0f277 [mdns] Fix incorrect error check for getaddrinfo (can cause segfault)
Non-zero return from getaddrinfo is an error, so since *ai could be a null
pointer when derefenced in the following socket() call.
2019-09-18 21:18:01 +02:00
ejurgensen
df7456dc39 [mdns] Make connection test optional and only do it for Airplay (fixes #602)
Some remotes don't respond as expected to the test. Retune will give connection
refused, because the test is made too quickly, before the service is running.

Even if we delay the test it won't work because Retune crashes.

Since the false mdns advertisements are only seen on Airplay, we only do the
test there.
2018-10-14 22:13:58 +02:00
ejurgensen
2c1f2f1b15 [mdns] connection test: don't wait if connect() succeeds immediately 2018-09-10 20:18:06 +02:00
ejurgensen
475c598d0e [mdns] Check return values of avahi_address_snprint() 2018-09-09 22:17:31 +02:00
ejurgensen
b3fc87170e [mdns] Fix missing check of the value-result from getsockopt(SO_ERROR)
The connection test would not catch "No route to host", as this is returned
through the value-result buffer.

This fix might partially solve issue #498.
2018-09-07 23:19:46 +02:00
chme
ef3ab53562 [mdns] Fix compile warning "directive output may be truncated" (provided
string length might not be big enough for ipv6 addresses)
2018-09-02 07:46:50 +02:00
ejurgensen
970769cab6 [mdns] Fix mdns problems with ATV4 and ipv6
Avahi gives us several ipv6 addresses for an ATV4 that aren't actually
connectable. Here we simply try to make a connection to the address,
and if it is not possible within a timeout we ignore the announcement.

We also now don't start a mdns record browser if the address from the
resolver passes the connection test and isn't link-local.
2018-06-25 21:44:07 +02:00
ejurgensen
b9e069939e [mdns] Also handle devices being switched on/off without Avahi service removal notices 2017-05-02 23:13:53 +02:00
ejurgensen
e2f65debc8 [mdns] Keep Avahi resolvers alive so we get IP changes from e.g. Airplay devices (fix for issue #378) 2017-05-02 19:27:35 +02:00
Scott Shambarger
bb68d59a6e [osx] Added missing timer/clock functions, support Bonjour mDNS on OSX
Added configure checks needed to detect missing functions on OSX
Added compat clock functions using clock_get_time on OSX
Added compat timer functions using clock_gettime and setitimer on OSX
Added byteswap functions on OSX
2017-01-14 00:56:43 -05:00
ejurgensen
785ff21045 Merge pull request #328 from sshambar/fixconfig
Updated configure/makefiles related to Issue #327
2017-01-12 22:41:47 +01:00
Scott Shambarger
8ead7ea3b8 [config] configure.ac checks required features, updated porting
Added a real config.rpath
Fixed build date calc for BSD
Require some needed headers at configure time
Correctly check libav functions using pkg-config flags
Made checks for some Linux features available on other ports
Fixed porting issue with antlr dep files
Added default HOST_NAME_MAX if not defined
Added missing libav header
2016-12-29 16:14:22 -08:00
ejurgensen
80fe738583 [mdns] Fix for missing HOST_NAME_MAX on FreeBSD 2016-12-29 19:30:04 +01:00
ejurgensen
3921cf5732 Merge branch 'spwebapi2' 2016-11-27 22:54:06 +01:00
ejurgensen
bdd6bab982 [-] Lots of housekeeping thanks to scan-build and input from @acmay 2016-11-19 23:08:50 +01:00
ejurgensen
90ecc61ed7 [mdns] CNAME record so we have fixed uri for OAuth redirects
- also refactor mdns_avahi
2016-11-05 13:31:13 +01:00
chme
b75c07625c [mdns] Use %zu for size_t in printf (removes warning about wrong
argument type)
2016-11-04 19:09:59 +01:00
ejurgensen
91c3eb622c [mdns] Put the record browser back
We need to browse through all records so that we can filter out link-local that Avahi sometimes gives us
2016-10-31 22:04:27 +01:00
ejurgensen
be6580d23e [mdns] Also ignore ipv4 link-local announcements 2016-10-30 20:04:08 +01:00
ejurgensen
bc1fb4b385 [mdns] Ignore ipv6 link-local mdns announcements 2016-10-23 23:27:34 +02:00
ejurgensen
03513c56a8 [mdns] Simplify avahi implementation, e.g. drop record browser
- record browser and link level filtering doesn't seem required (I may regret this...)
- fix cast.c so it does not browse for ipv6 when disabled
2016-10-15 19:12:56 +02:00
chme
2195db0800 [mpd] Announce mpd support with avahi/zeroconf 2015-11-06 19:50:18 +01:00
ejurgensen
55104015e0 Full removal of libevent 1 legacy code. Also drop pipe() in FreeBSD, since pipe2 is available now. 2015-10-19 21:15:29 +02:00
ejurgensen
8b97d7fdd8 Forgot to remove some debug messages in mdns_avahi.c 2014-03-16 23:14:30 +01:00
ejurgensen
ae70bf58fc Make mdns_avahi.c fully compliant with libevent 2, so it doesn't
complain in the logs about missing event base for event_del_
2014-03-16 23:11:21 +01:00
Julien BLACHE
8310bc226d Plug leaks, avahi_strdup() not necessary here 2011-07-09 11:54:55 +02:00
Raivo Hool
3a71d7b15d Add netinet/in.h, needed on FreeBSD 2011-03-21 18:46:28 +01:00
Julien BLACHE
bcbda9bc4e Browse records for IPv6 addresses regardless of the underlying protocol 2011-03-15 19:20:38 +01:00
Julien BLACHE
2c1755f025 Don't start record browser if address family not requested 2011-03-15 19:20:38 +01:00
Julien BLACHE
6cd59a1240 Introduce mDNS browser flags for address type selection
Allow each user to specify the address types that should be returned
through the mDNS browse callback.
2011-03-10 21:08:25 +01:00
Julien BLACHE
4f59533ccb Perform manual hostname resolution by browsing mDNS RRs
The service resolver delivers a single IP address that doesn't always suit
our needs. To get all the addresses advertised, we have to look at the RRs
through the record browser; we can then apply our filters and extract the
addresses that fit.
2011-03-10 21:08:25 +01:00
Julien BLACHE
a4c74c2063 Use AF_UNSPEC instead of -1 as error code for family 2010-09-26 14:52:41 +02:00
Julien BLACHE
8411aa48b7 Keep Avahi code inside mdns_avahi.c 2010-09-18 17:25:50 +02:00
Julien BLACHE
7ba3b23f63 Rename mdns_avahi.h to mdns.h 2010-09-18 17:24:34 +02:00
Julien BLACHE
4512a7ce9e Do not add service browser to the list if browser creation fails 2010-07-16 18:36:16 +02:00
Julien BLACHE
4544dc152b Coding-style fix 2010-07-16 18:36:09 +02:00
Julien BLACHE
98ba2fb63d Handle link-local addresses
Discard IPv4 link-local addresses; IPv4LL doesn't work on most systems, so the
address are effectively useless to us.

Turn IPv6 link-local addresses into scoped addresses by appending the interface
name to the address.
2010-07-10 12:36:47 +02:00
Julien BLACHE
691e6a8c93 Fix | vs. |= typo 2010-06-21 19:18:52 +02:00
Julien BLACHE
4bd09cba62 Browse and resolve mDNS services on both IPv4 and IPv6 2010-05-14 17:36:29 +02:00
Julien BLACHE
516909545b Include config.h in all C files 2010-02-02 21:09:55 +01:00
Julien BLACHE
2cb67743fc Add service type to the "ALL FOR NOW" message 2010-01-20 18:17:04 +01:00
Julien BLACHE
04f4622086 Add generic mDNS browsing + resolving facility 2010-01-17 10:52:58 +01:00
Julien BLACHE
b918d14e38 Fix group_entries list traversal 2010-01-17 10:52:58 +01:00
Julien BLACHE
cdf0e2f9a5 Fix incorrect log domain 2010-01-09 11:14:23 +01:00
Julien BLACHE
974a74a833 Update copyright notices for 2010 2010-01-05 19:34:00 +01:00
Julien BLACHE
7b3b538ea6 Rename L_REND to L_MDNS 2009-05-09 17:14:07 +02:00
Julien BLACHE
11fd038d16 Use new logger facility 2009-05-09 17:14:06 +02:00