-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
avahi-compat-libdns_sd.pc.in \
avahi-compat-howl.pc.in \
avahi-ui.pc.in \
- doxygen_to_devhelp.xsl
+ avahi-ui-gtk3.pc.in \
+ doxygen_to_devhelp.xsl \
+ common/introspection.m4
SUBDIRS = \
common \
endif
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = avahi-core.pc
-avahi-core.pc: avahi-core.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
+%.pc: %.pc.in
+ $(AM_V_GEN)sed -e 's,@prefix\@,$(prefix),g' \
-e 's,@libdir\@,$(libdir),g' \
-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
+pkgconfig_DATA = avahi-core.pc
CLEANFILES = avahi-core.pc
if HAVE_DBUS
-
pkgconfig_DATA += avahi-client.pc
-
-avahi-client.pc: avahi-client.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-client.pc
if ENABLE_COMPAT_HOWL
-
pkgconfig_DATA += avahi-compat-howl.pc
-
-avahi-compat-howl.pc: avahi-compat-howl.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@HOWL_COMPAT_VERSION\@,$(HOWL_COMPAT_VERSION),g' $< > $@
-
CLEANFILES += avahi-compat-howl.pc
-
endif
if ENABLE_COMPAT_LIBDNS_SD
-
pkgconfig_DATA += avahi-compat-libdns_sd.pc
-
-avahi-compat-libdns_sd.pc: avahi-compat-libdns_sd.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-compat-libdns_sd.pc
-
endif
if HAVE_MONO
-
pkgconfig_DATA += avahi-sharp.pc avahi-ui-sharp.pc
-
-avahi-sharp.pc: avahi-sharp.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
- -e 's,@libdir\@,$(libdir),g' $< > $@
-
-avahi-ui-sharp.pc: avahi-ui-sharp.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
- -e 's,@libdir\@,$(libdir),g' $< > $@
-
CLEANFILES += avahi-sharp.pc avahi-ui-sharp.pc
-
endif
endif
if HAVE_GLIB
-
pkgconfig_DATA += avahi-glib.pc
-
-avahi-glib.pc: avahi-glib.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-glib.pc
if HAVE_GOBJECT
-
pkgconfig_DATA += avahi-gobject.pc
-
-avahi-gobject.pc: avahi-gobject.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-gobject.pc
-
endif
endif
if HAVE_GTK
if HAVE_DBUS
-
pkgconfig_DATA += avahi-ui.pc
-
-avahi-ui.pc: avahi-ui.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-ui.pc
+endif
+endif
+if HAVE_GTK3
+if HAVE_DBUS
+pkgconfig_DATA += avahi-ui-gtk3.pc
+CLEANFILES += avahi-ui-gtk3.pc
endif
endif
if HAVE_QT3
-
pkgconfig_DATA += avahi-qt3.pc
-
-avahi-qt3.pc: avahi-qt3.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-qt3.pc
-
endif
if HAVE_QT4
-
pkgconfig_DATA += avahi-qt4.pc
-
-avahi-qt4.pc: avahi-qt4.pc.in
- sed -e 's,@prefix\@,$(prefix),g' \
- -e 's,@libdir\@,$(libdir),g' \
- -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' $< > $@
-
CLEANFILES += avahi-qt4.pc
-
endif
CLEANFILES += avahi.devhelp
MOSTLYCLEANFILES = $(DX_CLEANFILES)
DISTCHECK_CONFIGURE_FLAGS = \
- --disable-monodoc
+ --disable-monodoc \
+ --enable-introspection \
+ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
homepage:
$(MAKE) -C man
ssh tango rm -rf www/avahi.org/tree/download/doxygen
scp -r doxygen/html tango:www/avahi.org/tree/download/doxygen
-dist-hook:
- if test -d .svn ; then \
- svn update ; \
- chmod u+w ${distdir}/ChangeLog || true ; \
- svn2cl -o ${distdir}/ChangeLog ; \
- fi
-
DISTCLEANFILES = \
po/.intltool-merge-cache
-#!/bin/sh
-# $Id$
+#!/bin/bash
# This file is part of avahi.
#
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-VERSION=1.9
+AM_VERSION=1.11
+AC_VERSION=2.63
run_versioned() {
local P
local V
V=$(echo "$2" | sed -e 's,\.,,g')
-
- if [ -e "`which $1$V`" ] ; then
- P="$1$V"
+
+ if [ -e "`which $1$V 2> /dev/null`" ] ; then
+ P="$1$V"
else
- if [ -e "`which $1-$2`" ] ; then
- P="$1-$2"
- else
- P="$1"
- fi
+ if [ -e "`which $1-$2 2> /dev/null`" ] ; then
+ P="$1-$2"
+ else
+ P="$1"
+ fi
fi
shift 2
set -ex
+if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
+ cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
+ chmod +x .git/hooks/pre-commit && \
+ echo "Activated pre-commit hook."
+fi
+
if [ "x$1" = "xam" ] ; then
- run_versioned automake "$VERSION" -a -c --foreign
+ run_versioned automake "$AM_VERSION" -a -c --foreign
./config.status
else
rm -rf autom4te.cache
intltoolize --copy --force --automake
"$LIBTOOLIZE" -c --force
- run_versioned aclocal "$VERSION" -I common
- run_versioned autoconf 2.59 -Wall
- run_versioned autoheader 2.59
- run_versioned automake "$VERSION" -a -c --foreign
+ run_versioned aclocal "$AM_VERSION" -I common
+ run_versioned autoconf "$AC_VERSION" -Wall
+ run_versioned autoheader "$AC_VERSION"
+ run_versioned automake "$AM_VERSION" -a -c --foreign
if test "x$NOCONFIGURE" = "x"; then
./configure "$@"
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
if TARGET_FREEBSD
avahi-autoipd.action: avahi-autoipd.action.bsd
- cp $< $@
+ $(AM_V_GEN)cp $< $@
else
avahi-autoipd.action: avahi-autoipd.action.linux
- cp $< $@
+ $(AM_V_GEN)cp $< $@
endif
if TARGET_DEBIAN
noinst_SCRIPTS = dhclient-enter-hook dhclient-exit-hook
dhclient-enter-hook: dhclient-enter-hook.in
- sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
+ $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ && \
chmod +x $@
dhclient-exit-hook: dhclient-exit-hook.in
- sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
+ $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@ && \
chmod +x $@
BUILD = dhclient-exit-hook dhclient-enter-hook
#!/bin/sh
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/sh
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# $2 interface name
# $3 IP adddress
+PATH="$PATH:/usr/bin:/usr/sbin:/bin:/sbin"
+
+# Use a different metric for each interface, so that we can set
+# identical routes to multiple interfaces.
+
+METRIC=$((1000 + `cat "/sys/class/net/$2/ifindex" 2>/dev/null || echo 0`))
+
if [ -x /bin/ip -o -x /sbin/ip ] ; then
# We have the Linux ip tool from the iproute package
case "$1" in
BIND)
- ip addr add "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2"
+ ip addr add "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2"
+ ip route add default dev "$2" metric "$METRIC" scope link ||:
;;
CONFLICT|UNBIND|STOP)
- ip addr del "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2"
+ ip route del default dev "$2" metric "$METRIC" scope link ||:
+ ip addr del "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2"
;;
*)
case "$1" in
BIND)
- ifconfig "$2:3" inet "$3" netmask 255.255.0.0 broadcast 169.254.255.255 up
+ ifconfig "$2:avahi" inet "$3" netmask 255.255.0.0 broadcast 169.254.255.255 up
+ route add default dev "$2:avahi" metric "$METRIC" ||:
;;
CONFLICT|STOP|UNBIND)
- ifconfig "$2:3" down
+ route del default dev "$2:avahi" metric "$METRIC" ||:
+ ifconfig "$2:avahi" down
;;
*)
#!/bin/sh
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/sh
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
PREINIT|BOUND|RENEW|REBIND|REBOOT|STOP|RELEASE)
# Stopping avahi-autoipd is left for the enter hook
;;
-
+
EXPIRE|FAIL|TIMEOUT)
@sbindir@/avahi-autoipd -wD $interface 2> /dev/null
;;
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int iface_init(int i) {
struct sockaddr_nl addr;
int on = 1;
-
+
if ((fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) {
daemon_log(LOG_ERR, "socket(PF_NETLINK): %s", strerror(errno));
goto fail;
daemon_log(LOG_ERR, "bind(): %s", strerror(errno));
goto fail;
}
-
+
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
daemon_log(LOG_ERR, "SO_PASSCRED: %s", strerror(errno));
goto fail;
}
ifindex = i;
-
+
return fd;
-
+
fail:
if (fd >= 0) {
close(fd);
fd = -1;
}
-
+
return -1;
}
if (ifi->ifi_family != AF_UNSPEC || (int) ifi->ifi_index != ifindex)
return 0;
-
+
if (n->nlmsg_type == RTM_DELLINK) {
daemon_log(LOG_ERR, "Interface vanished.");
return -1;
}
assert(n->nlmsg_type == RTM_NEWLINK);
-
+
if ((ifi->ifi_flags & IFF_LOOPBACK) ||
(ifi->ifi_flags & IFF_NOARP) ||
ifi->ifi_type != ARPHRD_ETHER) {
int l;
uint32_t address = 0;
Address *i;
-
+
ifa = NLMSG_DATA(n);
if (ifa->ifa_family != AF_INET || (int) ifa->ifa_index != ifindex)
memcpy(&address, RTA_DATA(a), sizeof(uint32_t));
break;
}
-
+
a = RTA_NEXT(a, l);
}
static int process_response(int wait_for_done, unsigned seq) {
assert(fd >= 0);
-
+
do {
size_t bytes;
ssize_t r;
struct msghdr msghdr;
struct cmsghdr *cmsghdr;
struct ucred *ucred;
- struct iovec iov;
+ struct iovec iov;
struct nlmsghdr *p = (struct nlmsghdr *) replybuf;
-
+
memset(&iov, 0, sizeof(iov));
- iov.iov_base = replybuf;
+ iov.iov_base = replybuf;
iov.iov_len = sizeof(replybuf);
memset(&msghdr, 0, sizeof(msghdr));
msghdr.msg_name = (void*) NULL;
- msghdr.msg_namelen = 0;
- msghdr.msg_iov = &iov;
- msghdr.msg_iovlen = 1;
- msghdr.msg_control = cred_msg;
- msghdr.msg_controllen = sizeof(cred_msg);
+ msghdr.msg_namelen = 0;
+ msghdr.msg_iov = &iov;
+ msghdr.msg_iovlen = 1;
+ msghdr.msg_control = cred_msg;
+ msghdr.msg_controllen = sizeof(cred_msg);
msghdr.msg_flags = 0;
-
+
if ((r = recvmsg(fd, &msghdr, 0)) < 0) {
daemon_log(LOG_ERR, "recvmsg() failed: %s", strerror(errno));
return -1;
}
if (!(cmsghdr = CMSG_FIRSTHDR(&msghdr)) || cmsghdr->cmsg_type != SCM_CREDENTIALS) {
- daemon_log(LOG_WARNING, "No sender credentials received, ignoring data.");
+ daemon_log(LOG_WARNING, "No sender credentials received, ignoring data.");
return -1;
}
ucred = (struct ucred*) CMSG_DATA(cmsghdr);
-
+
if (ucred->uid != 0)
return -1;
bytes = (size_t) r;
-
+
for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) {
if (!NLMSG_OK(p, bytes) || bytes < sizeof(struct nlmsghdr) || bytes < p->nlmsg_len) {
assert(fd >= 0);
assert(state);
-
+
memset(&req, 0, sizeof(req));
n = (struct nlmsghdr*) req;
n->nlmsg_len = NLMSG_LENGTH(sizeof(*ifi));
if (process_response(1, 0) < 0)
return -1;
-
+
n->nlmsg_type = RTM_GETADDR;
n->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa));
n->nlmsg_seq = ++seq;
ifa = NLMSG_DATA(n);
ifa->ifa_family = AF_INET;
ifa->ifa_index = ifindex;
-
+
if (send(fd, n, n->nlmsg_len, 0) < 0) {
daemon_log(LOG_ERR, "send(): %s", strerror(errno));
return -1;
return -1;
*state = addresses ? STATE_SLEEPING : STATE_START;
-
+
return 0;
}
assert(fd >= 0);
b = !!addresses;
-
+
if (process_response(0, 0) < 0)
return -1;
*event = EVENT_ROUTABLE_ADDR_UNCONFIGURED;
else if (!b && addresses)
*event = EVENT_ROUTABLE_ADDR_CONFIGURED;
-
+
return 0;
}
void iface_done(void) {
Address *a;
-
+
if (fd >= 0) {
close(fd);
fd = -1;
#ifndef fooavahiifacehfoo
#define fooavahiifacehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
return -1;
}
-static void
-close_socket(int fd) {
+static void close_socket(int fd) {
close(fd);
}
#define elementsof(array) (sizeof(array)/sizeof(array[0]))
#endif
-static int
-__get_ether_addr(int ifindex, u_char *lladdr)
-{
- int mib[6];
- char *buf;
- struct if_msghdr *ifm;
- char *lim;
- char *next;
- struct sockaddr_dl *sdl;
- size_t len;
+static int __get_ether_addr(int ifindex, u_char *lladdr) {
+ int mib[6];
+ char *buf;
+ struct if_msghdr *ifm;
+ char *lim;
+ char *next;
+ struct sockaddr_dl *sdl;
+ size_t len;
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
if (sysctl(mib, elementsof(mib), NULL, &len, NULL, 0) != 0) {
daemon_log(LOG_ERR, "sysctl(NET_RT_IFLIST): %s",
strerror(errno));
- return (-1);
- }
-
- buf = malloc(len);
- if (buf == NULL) {
- daemon_log(LOG_ERR, "malloc(%d): %s", len, strerror(errno));
- return (-1);
+ return -1;
}
+ buf = avahi_malloc(len);
if (sysctl(mib, elementsof(mib), buf, &len, NULL, 0) != 0) {
daemon_log(LOG_ERR, "sysctl(NET_RT_IFLIST): %s",
strerror(errno));
free(buf);
- return (-1);
+ return -1;
}
lim = buf + len;
memcpy(lladdr, LLADDR(sdl), ETHER_ADDRLEN);
}
}
- free(buf);
+ avahi_free(buf);
- return (0);
+ return 0;
}
#define PCAP_TIMEOUT 500 /* 0.5s */
-static int
-open_socket(int iface, uint8_t *hw_address)
-{
- struct bpf_program bpf;
- char *filter;
- char ifname[IFNAMSIZ];
- pcap_t *pp;
- int err;
- int fd;
+static int open_socket(int iface, uint8_t *hw_address) {
+ struct bpf_program bpf;
+ char *filter;
+ char ifname[IFNAMSIZ];
+ pcap_t *pp;
+ int err;
+ int fd;
assert(__pp == NULL);
- if (interface_up(iface) < 0) {
- return (-1);
- }
- if (__get_ether_addr(iface, __lladdr) == -1) {
- return (-1);
- }
- if (if_indextoname(iface, ifname) == NULL) {
- return (-1);
- }
+ if (interface_up(iface) < 0)
+ return -1;
+
+ if (__get_ether_addr(iface, __lladdr) == -1)
+ return -1;
+
+ if (if_indextoname(iface, ifname) == NULL)
+ return -1;
/*
* Using a timeout for BPF is fairly portable across BSDs. On most
return (fd);
}
-static void
-close_socket(int fd __unused)
-{
-
+static void close_socket(int fd AVAHI_GCC_UNUSED) {
assert(__pp != NULL);
pcap_close(__pp);
__pp = NULL;
* We trick avahi into allocating sizeof(packet) + sizeof(ether_header),
* and prepend the required ethernet header information before sending.
*/
-static int
-send_packet(int fd __unused, int iface __unused, ArpPacket *packet,
- size_t packet_len)
-{
+static int send_packet(int fd AVAHI_GCC_UNUSED, int iface AVAHI_GCC_UNUSED, ArpPacket *packet, size_t packet_len) {
struct ether_header *eh;
assert(__pp != NULL);
return (pcap_inject(__pp, (void *)eh, packet_len + sizeof(*eh)));
}
-static int
-recv_packet(int fd __unused, ArpPacket **packet, size_t *packet_len)
-{
- struct pcap_pkthdr *ph;
- u_char *pd;
- ArpPacket *ap;
- int err;
- int retval;
+static int recv_packet(int fd AVAHI_GCC_UNUSED, ArpPacket **packet, size_t *packet_len) {
+ struct pcap_pkthdr *ph;
+ u_char *pd;
+ ArpPacket *ap;
+ int err;
+ int retval;
assert(__pp != NULL);
assert(packet != NULL);
* didn't match the filter, in which case we'll get 0 packets.
*/
retval = 0;
- } else {
+ } else
daemon_log(LOG_ERR, "pcap_next_ex(%d): %s",
err, pcap_geterr(__pp));
- }
return (retval);
}
daemon_retval_done();
- setsid();
-
avahi_set_proc_title(argv0, "%s: [%s] callout dispatcher", argv0, interface_name);
close(fds[1]);
char *address_fn = NULL;
const char *p;
- daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP,0);
+ daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0);
if (!(dispatcher = fork_dispatcher()))
goto fail;
int conflict = 0;
if (info.sender_ip_address == addr) {
- /* Normal conflict */
- conflict = 1;
- daemon_log(LOG_INFO, "Received conflicting normal ARP packet.");
+
+ if (memcmp(hw_address, info.sender_hw_address, ETHER_ADDRLEN)) {
+ /* Normal conflict */
+ conflict = 1;
+ daemon_log(LOG_INFO, "Received conflicting normal ARP packet.");
+ } else
+ daemon_log(LOG_DEBUG, "Received ARP packet back on source interface. Ignoring.");
+
} else if (state == STATE_WAITING_PROBE || state == STATE_PROBING || state == STATE_WAITING_ANNOUNCE) {
/* Probe conflict */
conflict = info.target_ip_address == addr && memcmp(hw_address, info.sender_hw_address, ETHER_ADDRLEN);
#ifndef fooavahimainhfoo
#define fooavahimainhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# $Id: Makefile.am 90 2005-05-23 16:15:12Z lennart $
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
endif
-lib_LTLIBRARIES = libavahi-client.la
+lib_LTLIBRARIES = libavahi-client.la
libavahi_client_la_SOURCES = \
client.c client.h \
libavahi_client_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_CLIENT_VERSION_INFO)
client_test_SOURCES = client-test.c
-client_test_CFLAGS = $(AM_CFLAGS)
-client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
+client_test_CFLAGS = $(AM_CFLAGS)
+client_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
srv_test_SOURCES = srv-test.c
-srv_test_CFLAGS = $(AM_CFLAGS)
-srv_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
+srv_test_CFLAGS = $(AM_CFLAGS)
+srv_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
rr_test_SOURCES = rr-test.c
-rr_test_CFLAGS = $(AM_CFLAGS)
-rr_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
+rr_test_CFLAGS = $(AM_CFLAGS)
+rr_test_LDADD = $(AM_LDADD) libavahi-client.la ../avahi-common/libavahi-common.la
xdg_config_test_SOURCES = xdg-config-test.c xdg-config.c xdg-config.h
-xdg_config_test_CFLAGS = $(AM_CFLAGS)
+xdg_config_test_CFLAGS = $(AM_CFLAGS)
xdg_config_test_LDADD = $(AM_LDADD)
check_nss_test_SOURCES = check-nss.c check-nss-test.c client.h
-check_nss_test_CFLAGS = $(AM_CFLAGS)
+check_nss_test_CFLAGS = $(AM_CFLAGS)
check_nss_test_LDADD = $(AM_LDADD)
if HAVE_DLOPEN
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
char buf[AVAHI_DOMAIN_NAME_MAX*3], *e, *t, *p;
assert(b);
-
+
if (!(e = getenv("AVAHI_BROWSE_DOMAINS")))
return;
static void parse_domain_file(AvahiDomainBrowser *b) {
FILE *f;
char buf[AVAHI_DOMAIN_NAME_MAX];
-
+
assert(b);
if (!(f = avahi_xdg_config_open("avahi/browse-domains")))
return;
-
-
+
+
while (fgets(buf, sizeof(buf)-1, f)) {
char domain[AVAHI_DOMAIN_NAME_MAX];
buf[strcspn(buf, "\n\r")] = 0;
-
+
if (avahi_normalize_name(buf, domain, sizeof(domain)))
b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain);
}
AvahiLookupFlags flags,
AvahiDomainBrowserCallback callback,
void *userdata) {
-
+
AvahiDomainBrowser *db = NULL;
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
}
db->static_browse_domains = avahi_string_list_reverse(db->static_browse_domains);
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew"))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
goto fail;
}
}
-
+
dbus_message_unref(message);
dbus_message_unref(reply);
-
+
return db;
fail:
if (db)
avahi_domain_browser_free(db);
-
+
if (message)
dbus_message_unref(message);
int avahi_domain_browser_free (AvahiDomainBrowser *b) {
AvahiClient *client;
int r = AVAHI_OK;
-
+
assert(b);
assert(b->ref >= 1);
if (--(b->ref) >= 1)
return AVAHI_OK;
-
+
client = b->client;
if (b->path && avahi_client_is_connected(b->client))
if (b->defer_timeout)
b->client->poll_api->timeout_free(b->defer_timeout);
-
+
avahi_string_list_free(b->static_browse_domains);
avahi_free(b->path);
avahi_free(b);
assert(client);
assert(message);
-
+
dbus_error_init (&error);
if (!(path = dbus_message_get_path(message)))
switch (event) {
case AVAHI_BROWSER_NEW:
case AVAHI_BROWSER_REMOVE:
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_INT32, &interface,
}
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
case AVAHI_BROWSER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse browser event.\n");
goto fail;
}
-
+
avahi_client_set_errno(db->client, avahi_error_dbus_to_number(etxt));
break;
}
/* We had this entry already in the static entries */
return DBUS_HANDLER_RESULT_HANDLED;
}
-
+
db->callback(db, (AvahiIfIndex) interface, (AvahiProtocol) protocol, event, domain, (AvahiLookupResultFlags) flags, db->userdata);
return DBUS_HANDLER_RESULT_HANDLED;
AvahiIfIndex interface,
AvahiProtocol protocol,
const char *domain,
- AvahiLookupFlags flags,
+ AvahiLookupFlags flags,
AvahiServiceTypeBrowserCallback callback,
void *userdata) {
-
+
AvahiServiceTypeBrowser *b = NULL;
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceTypeBrowserNew"))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
u_flags = (uint32_t) flags;
return b;
fail:
-
+
if (dbus_error_is_set(&error)) {
avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
if (b)
avahi_service_type_browser_free(b);
-
+
if (message)
dbus_message_unref(message);
assert(client);
assert(message);
-
+
dbus_error_init (&error);
if (!(path = dbus_message_get_path(message)))
domain = b->domain;
interface = b->interface;
protocol = b->protocol;
-
+
switch (event) {
case AVAHI_BROWSER_NEW:
case AVAHI_BROWSER_REMOVE:
goto fail;
}
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
case AVAHI_BROWSER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse browser event.\n");
goto fail;
}
-
+
avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
break;
}
AvahiProtocol protocol,
const char *type,
const char *domain,
- AvahiLookupFlags flags,
+ AvahiLookupFlags flags,
AvahiServiceBrowserCallback callback,
void *userdata) {
-
+
AvahiServiceBrowser *b = NULL;
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
b->client = client;
b->callback = callback;
b->userdata = userdata;
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (domain && domain[0])
if (!(b->domain = avahi_strdup(domain))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew"))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
dbus_message_unref(message);
dbus_message_unref(reply);
-
+
return b;
fail:
if (b)
avahi_service_browser_free(b);
-
+
if (message)
dbus_message_unref(message);
switch (event) {
case AVAHI_BROWSER_NEW:
case AVAHI_BROWSER_REMOVE:
-
+
if (!dbus_message_get_args (
message, &error,
DBUS_TYPE_INT32, &interface,
case AVAHI_BROWSER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse browser event.\n");
goto fail;
}
-
+
avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
break;
}
AvahiLookupFlags flags,
AvahiRecordBrowserCallback callback,
void *userdata) {
-
+
AvahiRecordBrowser *b = NULL;
DBusMessage *message = NULL, *reply = NULL;
DBusError error;
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
b->client = client;
b->callback = callback;
b->userdata = userdata;
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew"))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
dbus_message_unref(message);
dbus_message_unref(reply);
-
+
return b;
fail:
if (b)
avahi_record_browser_free(b);
-
+
if (message)
dbus_message_unref(message);
for (j = 0; j < 5; j++)
dbus_message_iter_next(&iter);
-
+
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE)
goto fail;
dbus_message_iter_get_fixed_array(&sub, &rdata, &rdata_size);
dbus_message_iter_next(&iter);
-
+
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32)
goto fail;
dbus_message_iter_get_basic(&iter, &flags);
-
+
break;
}
case AVAHI_BROWSER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse browser event.\n");
goto fail;
}
-
+
avahi_client_set_errno(b->client, avahi_error_dbus_to_number(etxt));
break;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int avahi_nss_support(void) {
int b = 0;
-
+
#ifdef HAVE_DLOPEN
static const char * const libs[] = {
"libnss_mdns.so.2",
"libnss_mdns4.so.2",
"libnss_mdns6.so.2",
NULL };
-
+
const char * const *l;
-
+
for (l = libs; *l; l++) {
void *dl;
-
+
if ((dl = dlopen(*l, RTLD_LAZY))) {
b = 1;
dlclose(dl);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void *userdata) {
-
+
printf ("DOMAIN-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, domain ? domain : "NULL", (char*)userdata);
}
AvahiStringList *txt,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void *userdata) {
-
+
char addr[64];
char *txtr;
if (event == AVAHI_RESOLVER_FAILURE) {
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void *userdata) {
-
+
AvahiServiceResolver *sr;
printf ("SERVICE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), name (%s), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, name ? name : "NULL", type, domain ? domain : "NULL", (char*)userdata);
if (b && name)
{
- sr = avahi_service_resolver_new (avahi_service_browser_get_client (b), interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, avahi_service_resolver_callback, "xxXXxx");
+ sr = avahi_service_resolver_new (avahi_service_browser_get_client (b), interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, avahi_service_resolver_callback, (char*) "xxXXxx");
printf("New service resolver %p\n", (void*) sr);
}
}
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void *userdata) {
-
+
printf ("SERVICE-TYPE-BROWSER: Callback on %p, interface (%d), protocol (%d), event (%d), type (%s), domain (%s), data (%s)\n", (void*) b, interface, protocol, event, type ? type : "NULL", domain ? domain : "NULL", (char*)userdata);
}
const char *name,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void *userdata) {
-
+
char addr[64];
if (event == AVAHI_RESOLVER_FAILURE) {
printf ("ADDRESS-RESOLVER: Callback on AddressResolver, timed out.\n");
const AvahiAddress *a,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void *userdata) {
-
+
AvahiClient *client;
AvahiAddressResolver *ar;
char addr[64];
-
+
if (event == AVAHI_RESOLVER_FAILURE) {
printf ("HOST-NAME-RESOLVER: Callback on HostNameResolver, timed out.\n");
return;
}
client = avahi_host_name_resolver_get_client (r);
- ar = avahi_address_resolver_new(client, interface, protocol, a, 0, avahi_address_resolver_callback, "omghai6u");
+ar = avahi_address_resolver_new(client, interface, protocol, a, 0, avahi_address_resolver_callback, (char*) "omghai6u");
if (ar)
{
printf ("Succesfully created address resolver object\n");
simple_poll = avahi_simple_poll_new();
poll_api = avahi_simple_poll_get(simple_poll);
-
- if (!(avahi = avahi_client_new(poll_api, 0, avahi_client_callback, "omghai2u", &error))) {
+
+ if (!(avahi = avahi_client_new(poll_api, 0, avahi_client_callback, (char*) "omghai2u", &error))) {
fprintf(stderr, "Client failed: %s\n", avahi_strerror(error));
goto fail;
}
ret = avahi_client_get_host_name_fqdn (avahi);
printf("FQDN: %s (Error Return: %s)\n", ret, ret ? "OK" : avahi_strerror(avahi_client_errno(avahi)));
-
+
cookie = avahi_client_get_local_service_cookie(avahi);
printf("Local service cookie: %u (Error Return: %s)\n", cookie, cookie != AVAHI_SERVICE_COOKIE_INVALID ? "OK" : avahi_strerror(avahi_client_errno(avahi)));
- group = avahi_entry_group_new(avahi, avahi_entry_group_callback, "omghai");
+ group = avahi_entry_group_new(avahi, avahi_entry_group_callback, (char*) "omghai");
printf("Creating entry group: %s\n", group ? "OK" : avahi_strerror(avahi_client_errno (avahi)));
assert(group);
-
+
printf("Sucessfully created entry group %p\n", (void*) group);
printf("%s\n", avahi_strerror(avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "Lathiat's Site", "_http._tcp", NULL, NULL, 80, "foo=bar", NULL)));
avahi_entry_group_commit (group);
- domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, "omghai3u");
-
+ domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, (char*) "omghai3u");
+
if (domain == NULL)
printf ("Failed to create domain browser object\n");
else
printf ("Sucessfully created domain browser %p\n", (void*) domain);
- st = avahi_service_type_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, 0, avahi_service_type_browser_callback, "omghai3u");
+ st = avahi_service_type_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, 0, avahi_service_type_browser_callback, (char*) "omghai3u");
if (st == NULL)
printf ("Failed to create service type browser object\n");
else
printf ("Sucessfully created service type browser %p\n", (void*) st);
- sb = avahi_service_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, avahi_service_browser_callback, "omghai3u");
+ sb = avahi_service_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, avahi_service_browser_callback, (char*) "omghai3u");
if (sb == NULL)
printf ("Failed to create service browser object\n");
else
printf ("Sucessfully created service browser %p\n", (void*) sb);
- hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_PROTO_UNSPEC, 0, avahi_host_name_resolver_callback, "omghai4u");
+ hnr = avahi_host_name_resolver_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "ecstasy.local", AVAHI_PROTO_UNSPEC, 0, avahi_host_name_resolver_callback, (char*) "omghai4u");
if (hnr == NULL)
printf ("Failed to create hostname resolver object\n");
else
if (aar == NULL) {
printf ("failed to create address object\n");
} else {
- group2 = avahi_entry_group_new (avahi, avahi_entry_group2_callback, "omghai222");
+ group2 = avahi_entry_group_new (avahi, avahi_entry_group2_callback, (char*) "omghai222");
if ((error = avahi_entry_group_add_address (group2, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "test-mdns.local.", aar)) < 0)
{
printf ("*** failed to add address to entry group: %s\n", avahi_strerror (error));
avahi_simple_poll_loop(simple_poll);
printf("terminating...\n");
-
+
fail:
if (avahi)
-/* $Id$ */
-
/***
This file is part of avahi.
#include <avahi-common/dbus.h>
#include <avahi-common/malloc.h>
#include <avahi-common/dbus-watch-glue.h>
+#include <avahi-common/i18n.h>
#include "client.h"
#include "internal.h"
#ifndef fooclienthfoo
#define fooclienthfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */
AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */
AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */
- AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */
+ AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */
} AvahiClientState;
typedef enum {
const char* avahi_client_get_host_name_fqdn (AvahiClient*);
/** Get state */
-AvahiClientState avahi_client_get_state(AvahiClient *client);
+AvahiClientState avahi_client_get_state(AvahiClient *client);
/** @{ \name Error Handling */
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int r = AVAHI_OK;
int32_t state;
AvahiClient *client;
-
+
dbus_error_init(&error);
assert(group);
client = group->client;
-
+
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
dbus_message_unref(reply);
return state;
-
+
fail:
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
group->client = client;
group->callback = callback;
group->userdata = userdata;
group->state_valid = 0;
group->path = NULL;
AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, group);
-
+
if (!(message = dbus_message_new_method_call(
AVAHI_DBUS_NAME,
AVAHI_DBUS_PATH_SERVER,
avahi_client_set_errno (client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!(group->path = avahi_strdup (path))) {
/* FIXME: We don't remove the object on the server side */
avahi_client_set_errno(client, state);
goto fail;
}
-
+
avahi_entry_group_set_state(group, (AvahiEntryGroupState) state);
dbus_message_unref(message);
if (group)
avahi_entry_group_free(group);
-
+
if (message)
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
return NULL;
}
DBusError error;
int r = AVAHI_OK;
AvahiClient *client;
-
+
dbus_error_init(&error);
assert(group);
client = group->client;
-
+
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, method))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
dbus_message_unref(reply);
return AVAHI_OK;
-
+
fail:
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
int avahi_entry_group_free(AvahiEntryGroup *group) {
AvahiClient *client = group->client;
int r = AVAHI_OK;
-
+
assert(group);
-
+
if (group->path && avahi_client_is_connected(client))
r = entry_group_simple_method_call(group, "Free");
-
+
AVAHI_LLIST_REMOVE(AvahiEntryGroup, groups, client->groups, group);
avahi_free(group->path);
int avahi_entry_group_commit(AvahiEntryGroup *group) {
int ret;
assert(group);
-
+
if (!group->path || !avahi_client_is_connected(group->client))
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
int avahi_entry_group_reset(AvahiEntryGroup *group) {
int ret;
assert(group);
-
+
if (!group->path || !avahi_client_is_connected(group->client))
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
if ((ret = entry_group_simple_method_call(group, "Reset")) < 0)
return ret;
-
+
group->state_valid = 0;
return ret;
}
if (group->state_valid)
return group->state;
-
+
return retrieve_state(group);
}
AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup *group) {
assert(group);
-
+
return group->client;
}
int r = AVAHI_OK;
int b;
AvahiClient *client;
-
+
assert(group);
client = group->client;
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
dbus_error_init(&error);
-
+
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
dbus_message_unref(reply);
return !!b;
-
+
fail:
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
static int append_rdata(DBusMessage *message, const void *rdata, size_t size) {
DBusMessageIter iter, sub;
-
+
assert(message);
-
+
dbus_message_iter_init_append(message, &iter);
-
+
if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) ||
!(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) ||
!(dbus_message_iter_close_container(&iter, &sub)))
return -1;
-
+
return 0;
}
/* Reverse the string list, so that we can pass it in-order to the server */
txt = avahi_string_list_reverse(txt);
-
+
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub))
goto fail;
for (p = txt; p != NULL; p = p->next) {
DBusMessageIter sub2;
const uint8_t *data = p->text;
-
+
if (!(dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2)) ||
!(dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size)) ||
!(dbus_message_iter_close_container(&sub, &sub2)))
const char *host,
uint16_t port,
AvahiStringList *txt) {
-
+
DBusMessage *message = NULL, *reply = NULL;
int r = AVAHI_OK;
DBusError error;
if (!host)
host = "";
-
+
dbus_error_init(&error);
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
return AVAHI_OK;
fail:
-
+
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
const char *host,
uint16_t port,
...) {
-
+
va_list va;
int r;
AvahiStringList *txt;
domain = "";
dbus_error_init(&error);
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
return AVAHI_OK;
fail:
-
+
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
...) {
va_list va;
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
AvahiStringList *txt) {
DBusMessage *message = NULL, *reply = NULL;
if (!domain)
domain = "";
-
+
dbus_error_init(&error);
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
return AVAHI_OK;
fail:
-
+
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
dbus_error_init(&error);
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
u_flags = (uint32_t) flags;
-
+
if (!avahi_address_snprint (s_address, sizeof (s_address), a))
{
r = avahi_client_set_errno(client, AVAHI_ERR_INVALID_ADDRESS);
r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
return AVAHI_OK;
fail:
-
+
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
dbus_error_init(&error);
-
+
if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord"))) {
r = avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
u_flags = (uint32_t) flags;
-
+
if (!dbus_message_append_args(
message,
DBUS_TYPE_INT32, &i_interface,
r = avahi_client_set_errno(group->client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(reply = dbus_connection_send_with_reply_and_block(client->bus, message, -1, &error)) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
r = avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
return AVAHI_OK;
fail:
-
+
if (dbus_error_is_set(&error)) {
r = avahi_client_set_dbus_error(client, &error);
dbus_error_free(&error);
#ifndef foointernalhfoo
#define foointernalhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
char *version_string, *host_name, *host_name_fqdn, *domain_name;
uint32_t local_service_cookie;
int local_service_cookie_valid;
-
+
AvahiClientCallback callback;
void *userdata;
-
+
AVAHI_LLIST_HEAD(AvahiEntryGroup, groups);
AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers);
AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers);
struct AvahiDomainBrowser {
int ref;
-
+
char *path;
AvahiClient *client;
AvahiDomainBrowserCallback callback;
#ifndef fooclientlookuphfoo
#define fooclientlookuphfoo
-/* $Id$ */
-
/***
This file is part of avahi.
* resp. AAAA resource record. */
AvahiServiceResolver * avahi_service_resolver_new(
AvahiClient *client,
- AvahiIfIndex interface, /**< Pass the interface argument you recieved in AvahiServiceBrowserCallback here. */
- AvahiProtocol protocol, /**< Pass the protocol argument you recieved in AvahiServiceBrowserCallback here. */
- const char *name, /**< Pass the name argument you recieved in AvahiServiceBrowserCallback here. */
- const char *type, /**< Pass the type argument you recieved in AvahiServiceBrowserCallback here. */
- const char *domain, /**< Pass the domain argument you recieved in AvahiServiceBrowserCallback here. */
+ AvahiIfIndex interface, /**< Pass the interface argument you received in AvahiServiceBrowserCallback here. */
+ AvahiProtocol protocol, /**< Pass the protocol argument you received in AvahiServiceBrowserCallback here. */
+ const char *name, /**< Pass the name argument you received in AvahiServiceBrowserCallback here. */
+ const char *type, /**< Pass the type argument you received in AvahiServiceBrowserCallback here. */
+ const char *domain, /**< Pass the domain argument you received in AvahiServiceBrowserCallback here. */
AvahiProtocol aprotocol, /**< The desired address family of the service address to resolve. AVAHI_PROTO_UNSPEC if your application can deal with both IPv4 and IPv6 */
AvahiLookupFlags flags,
AvahiServiceResolverCallback callback,
#ifndef fooclientpublishhfoo
#define fooclientpublishhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiPublishFlags flags /**< Usually 0, unless you know what you do */,
const char *name /**< The name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL. */,
const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */,
- const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */,
+ const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */,
const char *host /**< The host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case */,
uint16_t port /**< The IP port number of this service */,
...) AVAHI_GCC_SENTINEL;
AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */,
AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */,
AvahiPublishFlags flags /**< Only != 0 if you really know what you do */,
- const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
- const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
- const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */,
+ const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
+ const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
+ const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */,
...) AVAHI_GCC_SENTINEL;
/** Update a TXT record for an existing service. Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments. */
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
AvahiStringList *strlst);
/** \cond fulldocs */
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
assert(client);
assert(message);
-
+
dbus_error_init (&error);
if (!(path = dbus_message_get_path(message)))
uint16_t port;
DBusMessageIter iter, sub;
AvahiAddress a;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_INT32, &interface,
DBUS_TYPE_UINT16, &port,
DBUS_TYPE_INVALID) ||
dbus_error_is_set (&error)) {
-
+
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
-
+
dbus_message_iter_init(message, &iter);
-
+
for (j = 0; j < 9; j++)
dbus_message_iter_next(&iter);
-
+
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY) {
fprintf(stderr, "Error parsing service resolving message\n");
goto fail;
}
-
+
strlst = NULL;
dbus_message_iter_recurse(&iter, &sub);
-
+
for (;;) {
DBusMessageIter sub2;
int at;
const uint8_t *k;
int n;
-
+
if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID)
break;
-
+
assert(at == DBUS_TYPE_ARRAY);
-
+
if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE) {
fprintf(stderr, "Error parsing service resolving message\n");
goto fail;
}
-
+
dbus_message_iter_recurse(&sub, &sub2);
k = NULL; n = 0;
dbus_message_iter_get_fixed_array(&sub2, &k, &n);
if (k && n > 0)
strlst = avahi_string_list_add_arbitrary(strlst, k, n);
-
+
dbus_message_iter_next(&sub);
}
}
dbus_message_iter_get_basic(&iter, &flags);
-
+
assert(address);
if (address[0] == 0)
address = NULL;
else
avahi_address_parse(address, (AvahiProtocol) aprotocol, &a);
-
+
r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, type, domain, host, address ? &a : NULL, port, strlst, (AvahiLookupResultFlags) flags, r->userdata);
-
+
avahi_string_list_free(strlst);
break;
}
-
+
case AVAHI_RESOLVER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
-
+
avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
r->callback(r, r->interface, r->protocol, event, r->name, r->type, r->domain, NULL, NULL, 0, NULL, 0, r->userdata);
break;
return DBUS_HANDLER_RESULT_HANDLED;
-
+
fail:
dbus_error_free (&error);
avahi_string_list_free(strlst);
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
char *path;
-
+
assert(client);
assert(type);
if (!name)
name = "";
-
+
dbus_error_init (&error);
if (!avahi_client_is_connected(client)) {
r->name = r->type = r->domain = NULL;
r->interface = interface;
r->protocol = protocol;
-
+
AVAHI_LLIST_PREPEND(AvahiServiceResolver, service_resolvers, client->service_resolvers, r);
if (name && name[0])
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
-
+
+
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew"))) {
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
avahi_client_set_errno(client, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
dbus_message_unref(message);
dbus_message_unref(reply);
return r;
-
+
fail:
if (dbus_error_is_set(&error)) {
if (r)
avahi_service_resolver_free(r);
-
+
if (message)
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
-
+
return NULL;
}
assert(client);
assert(message);
-
+
dbus_error_init (&error);
if (!(path = dbus_message_get_path(message)))
uint32_t flags;
char *name, *address;
AvahiAddress a;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_INT32, &interface,
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
-
+
assert(address);
if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
fprintf(stderr, "Failed to parse address\n");
goto fail;
}
-
+
r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, name, &a, (AvahiLookupResultFlags) flags, r->userdata);
break;
}
-
+
case AVAHI_RESOLVER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
-
+
avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, 0, r->userdata);
break;
}
return DBUS_HANDLER_RESULT_HANDLED;
-
+
fail:
dbus_error_free (&error);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
char *path;
-
+
assert(client);
assert(name);
r->interface = interface;
r->protocol = protocol;
r->host_name = NULL;
-
+
AVAHI_LLIST_PREPEND(AvahiHostNameResolver, host_name_resolvers, client->host_name_resolvers, r);
if (!(r->host_name = avahi_strdup(name))) {
dbus_message_unref(reply);
return r;
-
+
fail:
if (dbus_error_is_set(&error)) {
if (r)
avahi_host_name_resolver_free(r);
-
+
if (message)
dbus_message_unref(message);
assert(client);
assert(message);
-
+
dbus_error_init (&error);
if (!(path = dbus_message_get_path(message)))
uint32_t flags;
char *name, *address;
AvahiAddress a;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_INT32, &interface,
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
-
+
assert(address);
if (!avahi_address_parse(address, (AvahiProtocol) aprotocol, &a)) {
fprintf(stderr, "Failed to parse address\n");
goto fail;
}
-
+
r->callback(r, (AvahiIfIndex) interface, (AvahiProtocol) protocol, AVAHI_RESOLVER_FOUND, &a, name, (AvahiLookupResultFlags) flags, r->userdata);
break;
}
case AVAHI_RESOLVER_FAILURE: {
char *etxt;
-
+
if (!dbus_message_get_args(
message, &error,
DBUS_TYPE_STRING, &etxt,
fprintf(stderr, "Failed to parse resolver event.\n");
goto fail;
}
-
+
avahi_client_set_errno(r->client, avahi_error_dbus_to_number(etxt));
r->callback(r, r->interface, r->protocol, event, &r->address, NULL, 0, r->userdata);
break;
}
return DBUS_HANDLER_RESULT_HANDLED;
-
+
fail:
dbus_error_free (&error);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
AvahiIfIndex interface,
AvahiProtocol protocol,
const AvahiAddress *a,
- AvahiLookupFlags flags,
+ AvahiLookupFlags flags,
AvahiAddressResolverCallback callback,
void *userdata) {
r->interface = interface;
r->protocol = protocol;
r->address = *a;
-
+
AVAHI_LLIST_PREPEND(AvahiAddressResolver, address_resolvers, client->address_resolvers, r);
if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "AddressResolverNew"))) {
avahi_client_set_errno(client, AVAHI_ERR_DBUS_ERROR);
goto fail;
}
-
+
if (!(r->path = avahi_strdup(path))) {
/* FIXME: We don't remove the object on the server side */
dbus_message_unref(reply);
return r;
-
+
fail:
if (dbus_error_is_set(&error)) {
if (r)
avahi_address_resolver_free(r);
-
+
if (message)
dbus_message_unref(message);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
assert(p);
printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p);
-
+
while (size > 0) {
unsigned i;
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
if (i < size)
printf("%02x ", c[i]);
else
else
printf(" ");
}
-
+
printf("\n");
c += 16;
if (size <= 16)
break;
-
+
size -= 16;
}
}
const AvahiPoll *poll_api;
AvahiClient *client;
AvahiRecordBrowser *r;
-
+
simple_poll = avahi_simple_poll_new();
assert(simple_poll);
-
+
poll_api = avahi_simple_poll_get(simple_poll);
assert(poll_api);
-
+
client = avahi_client_new(poll_api, 0, NULL, NULL, NULL);
assert(client);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
const AvahiPoll *poll_api;
AvahiClient *client;
AvahiServiceResolver *r;
-
+
simple_poll = avahi_simple_poll_new();
assert(simple_poll);
-
+
poll_api = avahi_simple_poll_get(simple_poll);
assert(poll_api);
-
+
client = avahi_client_new(poll_api, 0, NULL, NULL, NULL);
assert(client);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
FILE *f;
f = avahi_xdg_config_open("foo");
-
+
if (f)
fclose(f);
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef fooxdgconfighfoo
#define fooxdgconfighfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# $Id: Makefile.am 90 2005-05-23 16:15:12Z lennart $
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
i18n.c i18n.h
libavahi_common_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -DAVAHI_LOCALEDIR=\"$(avahilocaledir)\"
-libavahi_common_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(LIBINTL)
+libavahi_common_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(INTLLIBS)
libavahi_common_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_COMMON_VERSION_INFO)
strlst_test_SOURCES = \
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef fooaddresshfoo
#define fooaddresshfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
"gurke ###",
NULL
};
-
+
char *r = NULL;
int i, j, k;
for (k = 0; test_strings[k]; k++) {
printf(">>>>>%s<<<<\n", test_strings[k]);
-
+
for (j = 0; j < 2; j++) {
-
+
for (i = 0; i <= 100; i++) {
char *n;
-
+
n = i == 0 ? avahi_strdup(test_strings[k]) : (j ? avahi_alternative_service_name(r) : avahi_alternative_host_name(r));
avahi_free(r);
r = n;
assert(avahi_is_valid_service_name(n));
else
assert(avahi_is_valid_host_name(n));
-
+
printf("%s\n", r);
}
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
char *e;
e = strchr(c, 0) - 1;
-
+
while (e >= c) {
if (avahi_utf8_valid(c))
break;
-
+
assert(*e & 128);
*e = 0;
if (!avahi_is_valid_host_name(s))
return NULL;
-
+
if ((e = strrchr(s, '-'))) {
const char *p;
e++;
-
+
for (p = e; *p; p++)
if (!isdigit(*p)) {
e = NULL;
}
drop_incomplete_utf8(c);
-
+
r = avahi_strdup_printf("%s-%s", c, m);
avahi_free(c);
avahi_free(m);
-
+
} else {
char *c;
return NULL;
drop_incomplete_utf8(c);
-
+
r = avahi_strdup_printf("%s-2", c);
avahi_free(c);
}
if (!avahi_is_valid_service_name(s))
return NULL;
-
+
if ((e = strstr(s, " #"))) {
const char *n, *p;
e += 2;
-
+
while ((n = strstr(e, " #")))
e = n + 2;
if (e && (*e == '0' || *e == 0))
e = NULL;
}
-
+
if (e) {
char *c, *m;
size_t l;
}
drop_incomplete_utf8(c);
-
+
r = avahi_strdup_printf("%s #%s", c, m);
avahi_free(c);
avahi_free(m);
if (!(c = avahi_strndup(s, AVAHI_LABEL_MAX-1-3)))
return NULL;
-
+
drop_incomplete_utf8(c);
-
+
r = avahi_strdup_printf("%s #2", c);
avahi_free(c);
}
assert(avahi_is_valid_service_name(r));
-
+
return r;
}
#ifndef fooalternativehfoo
#define fooalternativehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foocdeclhfoo
#define foocdeclhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static void watch_callback(AvahiWatch *avahi_watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) {
DBusWatch *dbus_watch = userdata;
-
+
assert(avahi_watch);
assert(dbus_watch);
static dbus_bool_t update_watch(const AvahiPoll *poll_api, DBusWatch *dbus_watch) {
AvahiWatch *avahi_watch;
dbus_bool_t b;
-
+
assert(dbus_watch);
avahi_watch = dbus_watch_get_data(dbus_watch);
b = dbus_watch_get_enabled(dbus_watch);
-
+
if (b && !avahi_watch) {
if (!(avahi_watch = poll_api->watch_new(
return FALSE;
dbus_watch_set_data(dbus_watch, avahi_watch, NULL);
-
+
} else if (!b && avahi_watch) {
-
+
poll_api->watch_free(avahi_watch);
dbus_watch_set_data(dbus_watch, NULL, NULL);
} else if (avahi_watch) {
-
+
/* Update flags */
poll_api->watch_update(avahi_watch, dbus_watch_get_flags(dbus_watch));
}
static dbus_bool_t add_watch(DBusWatch *dbus_watch, void *userdata) {
ConnectionData *d = userdata;
-
+
assert(dbus_watch);
assert(d);
static void remove_watch(DBusWatch *dbus_watch, void *userdata) {
ConnectionData *d = userdata;
AvahiWatch *avahi_watch;
-
+
assert(dbus_watch);
assert(d);
static void watch_toggled(DBusWatch *dbus_watch, void *userdata) {
ConnectionData *d = userdata;
-
+
assert(dbus_watch);
assert(d);
if (--t->ref <= 0) {
if (t->avahi_timeout)
t->poll_api->timeout_free(t->avahi_timeout);
-
+
avahi_free(t);
}
}
static void update_timeout(TimeoutData *timeout) {
assert(timeout);
assert(timeout->ref >= 1);
-
+
if (dbus_timeout_get_enabled(timeout->dbus_timeout)) {
struct timeval tv;
avahi_elapse_time(&tv, dbus_timeout_get_interval(timeout->dbus_timeout), 0);
static void timeout_callback(AvahiTimeout *avahi_timeout, void *userdata) {
TimeoutData *timeout = userdata;
-
+
assert(avahi_timeout);
assert(timeout);
if (timeout->avahi_timeout)
update_timeout(timeout);
-
+
timeout_data_unref(timeout);
}
if ((b = dbus_timeout_get_enabled(dbus_timeout)))
avahi_elapse_time(&tv, dbus_timeout_get_interval(dbus_timeout), 0);
-
+
if (!(timeout->avahi_timeout = d->poll_api->timeout_new(
d->poll_api,
b ? &tv : NULL,
static void dispatch_status(AVAHI_GCC_UNUSED DBusConnection *connection, DBusDispatchStatus new_status, void *userdata) {
ConnectionData *d = userdata;
-
+
if (new_status == DBUS_DISPATCH_DATA_REMAINS)
request_dispatch(d, 1);
}
int avahi_dbus_connection_glue(DBusConnection *c, const AvahiPoll *poll_api) {
ConnectionData *d = NULL;
-
+
assert(c);
assert(poll_api);
d->poll_api = poll_api;
d->connection = c;
d->ref = 1;
-
+
if (!(d->dispatch_timeout = poll_api->timeout_new(poll_api, NULL, dispatch_timeout_callback, d)))
goto fail;
-
+
if (!(dbus_connection_set_watch_functions(c, add_watch, remove_watch, watch_toggled, connection_data_ref(d), (DBusFreeFunction)connection_data_unref)))
goto fail;
request_dispatch(d, 1);
connection_data_unref(d);
-
+
return 0;
fail:
#ifndef foodbuswatchgluehfoo
#define foodbuswatchgluehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_DBUS_ERR_IS_PATTERN,
AVAHI_DBUS_ERR_COLLISION,
AVAHI_DBUS_ERR_INVALID_RECORD,
-
+
AVAHI_DBUS_ERR_INVALID_SERVICE_NAME,
AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE,
AVAHI_DBUS_ERR_INVALID_PORT,
AVAHI_DBUS_ERR_TOO_MANY_OBJECTS,
AVAHI_DBUS_ERR_TOO_MANY_ENTRIES,
AVAHI_DBUS_ERR_OS,
-
+
AVAHI_DBUS_ERR_ACCESS_DENIED,
AVAHI_DBUS_ERR_INVALID_OPERATION,
AVAHI_DBUS_ERR_DBUS_ERROR,
AVAHI_DBUS_ERR_INVALID_INTERFACE,
AVAHI_DBUS_ERR_INVALID_PROTOCOL,
AVAHI_DBUS_ERR_INVALID_FLAGS,
-
+
AVAHI_DBUS_ERR_NOT_FOUND,
AVAHI_DBUS_ERR_INVALID_CONFIG,
AVAHI_DBUS_ERR_VERSION_MISMATCH,
AVAHI_DBUS_ERR_DNS_SERVFAIL,
AVAHI_DBUS_ERR_DNS_NXDOMAIN,
AVAHI_DBUS_ERR_DNS_NOTIMP,
-
+
AVAHI_DBUS_ERR_DNS_REFUSED,
AVAHI_DBUS_ERR_DNS_YXDOMAIN,
AVAHI_DBUS_ERR_DNS_YXRRSET,
for (m = error_map; m->dbus_error; m++)
if (strcmp(m->dbus_error, s) == 0)
return m->avahi_error;
-
+
return AVAHI_ERR_DBUS_ERROR;
}
#ifndef foodbushfoo
#define foodbushfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foodefshfoo
#define foodefshfoo
-/* $Id$ */
-
/***
This file is part of avahi.
* avahi_client_new(). If the client is forced to disconnect from the
* server it will enter AVAHI_CLIENT_FAILURE state with
* avahi_client_errno() == AVAHI_ERR_DISCONNECTED. Free the
- * AvahiClient object in that case and reconnect to the server anew -
- * again with passing AVAHI_CLIENT_NO_FAIL to avahi_client_new().
+ * AvahiClient object in that case (and all its associated objects
+ * such as entry groups and browser objects prior to that) and
+ * reconnect to the server anew - again with passing
+ * AVAHI_CLIENT_NO_FAIL to avahi_client_new().
*
* We encourage implementing this in all software where service
* discovery is not an integral part of application. e.g. use it in
- * all kinds of background daemons, but not in software like iChat
- * compatible IM software.
+ * all kinds of background daemons, but not necessarily in software
+ * like iChat compatible IM software.
*
* For now AVAHI_CLIENT_NO_FAIL cannot deal with D-Bus daemon restarts.
*
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
const char *p;
size_t size;
char name[64], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
-
+
printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046."));
avahi_free(s);
printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\.foo."));
avahi_free(s);
-
+
printf("%s\n", s = avahi_normalize_name_strdup("fo\\\\o\\..f oo."));
avahi_free(s);
avahi_service_name_split(t, name, sizeof(name), type, sizeof(type), domain, sizeof(domain));
printf("name: <%s>; type: <%s>; domain <%s>\n", name, type, domain);
-
+
avahi_service_name_join(t, sizeof(t), NULL, "_http._tcp", "one.two\\. .local");
printf("<%s>\n", t);
size = sizeof(r);
s = r;
-
+
printf("escaped: <%s>\n", avahi_escape_label(t, strlen(t), &s, &size));
p = r;
assert(!avahi_is_valid_service_type_generic("_foo._bar.waldo"));
assert(!avahi_is_valid_service_type_strict("_foo._bar.waldo"));
assert(!avahi_is_valid_service_subtype("_foo._bar.waldo"));
-
+
assert(!avahi_is_valid_service_type_generic(""));
assert(!avahi_is_valid_service_type_strict(""));
assert(!avahi_is_valid_service_subtype(""));
assert(!avahi_is_valid_fqdn("192.168.50.1"));
assert(!avahi_is_valid_fqdn("::1"));
assert(!avahi_is_valid_fqdn(".192.168.50.1."));
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
char *avahi_unescape_label(const char **name, char *dest, size_t size) {
unsigned i = 0;
char *d;
-
+
assert(dest);
assert(size > 0);
assert(name);
d = dest;
-
+
for (;;) {
if (i >= size)
return NULL;
(*name)++;
break;
}
-
+
if (**name == 0)
break;
-
+
if (**name == '\\') {
/* Escaped character */
if (**name == 0)
/* Ending NUL */
return NULL;
-
+
else if (**name == '\\' || **name == '.') {
/* Escaped backslash or dot */
*(d++) = *((*name) ++);
int n;
/* Escaped literal ASCII character */
-
+
if (!isdigit(*(*name+1)) || !isdigit(*(*name+2)))
return NULL;
if (n > 255 || n == 0)
return NULL;
-
+
*(d++) = (char) n;
i++;
(*name) += 3;
} else
return NULL;
-
+
} else {
/* Normal character */
-
+
*(d++) = *((*name) ++);
i++;
}
if (*src == '.' || *src == '\\') {
/* Dot or backslash */
-
+
if (*ret_size < 3)
return NULL;
-
+
*((*ret_name) ++) = '\\';
*((*ret_name) ++) = *src;
(*ret_size) -= 2;
-
+
} else if (
*src == '_' ||
*src == '-' ||
(*src >= 'A' && *src <= 'Z')) {
/* Proper character */
-
+
if (*ret_size < 2)
return NULL;
-
+
*((*ret_name)++) = *src;
(*ret_size) --;
-
+
} else {
/* Everything else */
*((*ret_name) ++) = '0' + (char) ((uint8_t) *src / 100);
*((*ret_name) ++) = '0' + (char) (((uint8_t) *src / 10) % 10);
*((*ret_name) ++) = '0' + (char) ((uint8_t) *src % 10);
-
+
(*ret_size) -= 4;
}
char *avahi_normalize_name(const char *s, char *ret_s, size_t size) {
int empty = 1;
char *r;
-
+
assert(s);
assert(ret_s);
assert(size > 0);
return NULL;
}
-
+
if (!empty) {
if (size < 1)
return NULL;
-
+
*(r++) = '.';
size--;
-
+
} else
empty = 0;
-
+
avahi_escape_label(label, strlen(label), &r, &size);
}
if (a == b)
return 1;
-
+
for (;;) {
char ca[AVAHI_LABEL_MAX], cb[AVAHI_LABEL_MAX], *r;
if (strcasecmp(ca, cb))
return 0;
-
+
if (!*a && !*b)
return 1;
}
if (strlen(label) <= 2 || label[0] != '_')
return 0;
-
+
} while (*t);
return 1;
return 0;
/* Application name */
-
+
if (!(avahi_unescape_label(&t, label, sizeof(label))))
return 0;
return 0;
/* _tcp or _udp boilerplate */
-
+
if (!(avahi_unescape_label(&t, label, sizeof(label))))
return 0;
if (*t)
return 0;
-
+
return 1;
}
return NULL;
/* Subtype name */
-
+
if (!(avahi_unescape_label(&t, label, sizeof(label))))
return NULL;
return NULL;
/* String "_sub" */
-
+
if (!(avahi_unescape_label(&t, label, sizeof(label))))
return NULL;
return NULL;
ret = t;
-
+
/* Application name */
if (!(avahi_unescape_label(&t, label, sizeof(label))))
if (!*t)
return NULL;
-
+
/* _tcp or _udp boilerplate */
-
+
if (!(avahi_unescape_label(&t, label, sizeof(label))))
return NULL;
/* Explicitly allow the root domain name */
if (is_first && label[0] == 0 && *t == 0)
return 1;
-
+
is_first = 0;
-
+
if (label[0] == 0)
return 0;
-
+
} while (*t);
return 1;
if (strlen(t) >= AVAHI_LABEL_MAX || !*t)
return 0;
-
+
return 1;
}
unsigned avahi_domain_hash(const char *s) {
unsigned hash = 0;
-
+
while (*s) {
char c[AVAHI_LABEL_MAX], *p, *r;
char escaped_name[AVAHI_LABEL_MAX*4];
char normalized_type[AVAHI_DOMAIN_NAME_MAX];
char normalized_domain[AVAHI_DOMAIN_NAME_MAX];
-
+
assert(p);
/* Validity checks */
-
+
if ((name && !avahi_is_valid_service_name(name)))
return AVAHI_ERR_INVALID_SERVICE_NAME;
if (!avahi_is_valid_service_type_generic(type))
return AVAHI_ERR_INVALID_SERVICE_TYPE;
-
+
if (!avahi_is_valid_domain_name(domain))
return AVAHI_ERR_INVALID_DOMAIN_NAME;
/* Preparation */
-
+
if (name) {
size_t l = sizeof(escaped_name);
char *e = escaped_name, *r;
return AVAHI_ERR_INVALID_DOMAIN_NAME;
/* Concatenation */
-
+
snprintf(p, size, "%s%s%s.%s", name ? escaped_name : "", name ? "." : "", normalized_type, normalized_domain);
return AVAHI_OK;
static size_t strlcpy(char *dest, const char *src, size_t n) {
assert(dest);
assert(src);
-
+
if (n > 0) {
strncpy(dest, src, n-1);
dest[n-1] = 0;
}
-
+
return strlen(src);
}
DOMAIN
} state;
int type_empty = 1, domain_empty = 1;
-
+
assert(p);
assert(type);
assert(type_size > 0);
state = NAME;
} else
state = TYPE;
-
+
*type = *domain = 0;
-
+
while (*p) {
char buf[64];
-
+
if (!(avahi_unescape_label(&p, buf, sizeof(buf))))
return -1;
if (!type_empty) {
if (!type_size)
return AVAHI_ERR_NO_MEMORY;
-
+
*(type++) = '.';
type_size --;
} else
type_empty = 0;
-
+
if (!(avahi_escape_label(buf, strlen(buf), &type, &type_size)))
return AVAHI_ERR_NO_MEMORY;
break;
- }
+ }
state = DOMAIN;
/* fall through */
if (!domain_empty) {
if (!domain_size)
return AVAHI_ERR_NO_MEMORY;
-
+
*(domain++) = '.';
domain_size --;
} else
/* Make sure that the name is not an IP address */
if (!(avahi_normalize_name(t, normalized, sizeof(normalized))))
return 0;
-
+
if (avahi_address_parse(normalized, AVAHI_PROTO_UNSPEC, &a))
return 0;
#ifndef foodomainhfoo
#define foodomainhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef fooerrorhfoo
#define fooerrorhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_C_DECL_BEGIN
/** Error codes used by avahi */
-enum {
+enum {
AVAHI_OK = 0, /**< OK */
AVAHI_ERR_FAILURE = -1, /**< Generic error code */
AVAHI_ERR_BAD_STATE = -2, /**< Object was in a bad state */
AVAHI_ERR_DNS_YXRRSET = -42,
AVAHI_ERR_DNS_NXRRSET = -43,
AVAHI_ERR_DNS_NOTAUTH = -44, /**< DNS Error: Not authorized */
- AVAHI_ERR_DNS_NOTZONE = -45,
+ AVAHI_ERR_DNS_NOTZONE = -45,
AVAHI_ERR_INVALID_RDATA = -46, /**< Invalid RDATA */
AVAHI_ERR_INVALID_DNS_CLASS = -47, /**< Invalid DNS class */
AVAHI_ERR_INVALID_DNS_TYPE = -48, /**< Invalid DNS type */
AVAHI_ERR_NOT_SUPPORTED = -49, /**< Not supported */
-
+
AVAHI_ERR_NOT_PERMITTED = -50, /**< Operation not permitted */
AVAHI_ERR_INVALID_ARGUMENT = -51, /**< Invalid argument */
AVAHI_ERR_IS_EMPTY = -52, /**< Is empty */
AVAHI_ERR_NO_CHANGE = -53, /**< The requested operation is invalid because it is redundant */
-
+
/****
**** IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD
**** IT TO THE STRING ARRAY IN avahi_strerror() IN error.c AND
****
**** Also remember to update the MAX value below.
****/
-
+
AVAHI_ERR_MAX = -54
};
#ifndef foogccmacrohfoo
#define foogccmacrohfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef fooi18nhfoo
#define fooi18nhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef foollistfoo
#define foollistfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static void oom(void) AVAHI_GCC_NORETURN;
static void oom(void) {
-
+
static const char msg[] = "Out of memory, aborting ...\n";
const char *n = msg;
while (strlen(n) > 0) {
ssize_t r;
-
+
if ((r = write(2, n, strlen(n))) < 0)
break;
/* Default implementation for avahi_calloc() */
static void *xcalloc(size_t nmemb, size_t size) {
void *p;
-
+
if (size == 0 || nmemb == 0)
return NULL;
if (size <= 0)
return NULL;
-
+
if (!allocator)
return xmalloc(size);
if (!p)
return;
-
+
if (!allocator) {
free(p);
return;
char *avahi_strdup(const char *s) {
char *r;
size_t size;
-
+
if (!s)
return NULL;
char *r;
size_t size;
const char *p;
-
+
if (!s)
return NULL;
for (p = s, size = 0;
size < max && *p;
p++, size++);
-
+
if (!(r = avahi_new(char, size+1)))
return NULL;
char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
size_t len = 80;
char *buf;
-
+
assert(fmt);
if (!(buf = avahi_malloc(len)))
va_list ap;
assert(fmt);
-
+
va_start(ap, fmt);
s = avahi_strdup_vprintf(fmt, ap);
va_end(ap);
#ifndef foomallochfoo
#define foomallochfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
return NULL;
n->data = data;
-
+
AVAHI_LLIST_PREPEND(AvahiRList, rlist, r, n);
return r;
}
AvahiRList* avahi_rlist_remove_by_link(AvahiRList *r, AvahiRList *n) {
assert(n);
-
+
AVAHI_LLIST_REMOVE(AvahiRList, rlist, r, n);
avahi_free(n);
#ifndef foorlistfoo
#define foorlistfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int idx;
struct pollfd pollfd;
-
+
AvahiWatchCallback callback;
void *userdata;
int enabled;
struct timeval expiry;
-
+
AvahiTimeoutCallback callback;
void *userdata;
-
+
AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts);
};
return;
s->wakeup_issued = 0;
-
+
for(;;)
if (read(s->wakeup_pipe[0], &c, sizeof(c)) != sizeof(c))
break;
static int set_nonblock(int fd) {
int n;
-
+
assert(fd >= 0);
if ((n = fcntl(fd, F_GETFL)) < 0)
static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) {
AvahiWatch *w;
AvahiSimplePoll *s;
-
+
assert(api);
assert(fd >= 0);
assert(callback);
/* If there is a background thread running the poll() for us, tell it to exit the poll() */
avahi_simple_poll_wakeup(s);
-
+
w->simple_poll = s;
w->dead = 0;
if (w->idx == -1)
return;
-
+
w->simple_poll->rebuild_pollfds = 1;
}
/* If there is a background thread running the poll() for us, tell it to exit the poll() */
avahi_simple_poll_wakeup(w->simple_poll);
-
+
remove_pollfd(w);
-
+
w->dead = 1;
w->simple_poll->n_watches --;
w->simple_poll->watch_req_cleanup = 1;
if (!w->dead)
w->simple_poll->n_watches --;
-
+
avahi_free(w);
}
static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) {
AvahiTimeout *t;
AvahiSimplePoll *s;
-
+
assert(api);
assert(callback);
/* If there is a background thread running the poll() for us, tell it to exit the poll() */
avahi_simple_poll_wakeup(s);
-
+
t->simple_poll = s;
t->dead = 0;
if ((t->enabled = !!tv))
t->expiry = *tv;
-
+
t->callback = callback;
t->userdata = userdata;
/* If there is a background thread running the poll() for us, tell it to exit the poll() */
avahi_simple_poll_wakeup(t->simple_poll);
-
+
if ((t->enabled = !!tv))
t->expiry = *tv;
}
set_nonblock(s->wakeup_pipe[0]);
set_nonblock(s->wakeup_pipe[1]);
-
+
s->api.userdata = s;
s->api.watch_new = watch_new;
s->api.timeout_new = timeout_new;
s->api.timeout_free = timeout_free;
s->api.timeout_update = timeout_update;
-
+
s->pollfds = NULL;
s->max_pollfds = s->n_pollfds = 0;
s->rebuild_pollfds = 1;
s->quit = 0;
s->n_watches = 0;
s->events_valid = 0;
-
+
s->watch_req_cleanup = 0;
s->timeout_req_cleanup = 0;
s->state = STATE_INIT;
s->wakeup_issued = 0;
-
+
avahi_simple_poll_set_func(s, NULL, NULL);
AVAHI_LLIST_HEAD_INIT(AvahiWatch, s->watches);
cleanup_timeouts(s, 1);
cleanup_watches(s, 1);
assert(s->n_watches == 0);
-
+
avahi_free(s->pollfds);
if (s->wakeup_pipe[0] >= 0)
if (s->wakeup_pipe[1] >= 0)
close(s->wakeup_pipe[1]);
-
+
avahi_free(s);
}
static int rebuild(AvahiSimplePoll *s) {
AvahiWatch *w;
int idx;
-
+
assert(s);
if (s->n_watches+1 > s->max_pollfds) {
struct pollfd *n;
s->max_pollfds = s->n_watches + 10;
-
+
if (!(n = avahi_realloc(s->pollfds, sizeof(struct pollfd) * s->max_pollfds)))
return -1;
s->pollfds = n;
}
-
+
s->pollfds[0].fd = s->wakeup_pipe[0];
s->pollfds[0].events = POLLIN;
s->pollfds[0].revents = 0;
idx = 1;
-
+
for (w = s->watches; w; w = w->watches_next) {
if(w->dead)
assert(s);
for (t = s->timeouts; t; t = t->timeouts_next) {
-
+
if (t->dead || !t->enabled)
continue;
-
+
if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0)
n = t;
}
int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout) {
AvahiTimeout *next_timeout;
-
+
assert(s);
assert(s->state == STATE_INIT || s->state == STATE_DISPATCHED || s->state == STATE_FAILURE);
s->state = STATE_PREPARING;
-
+
/* Clear pending wakeup requests */
clear_wakeup(s);
timeout = 0;
goto finish;
}
-
+
gettimeofday(&now, NULL);
usec = avahi_timeval_diff(&next_timeout->expiry, &now);
int avahi_simple_poll_run(AvahiSimplePoll *s) {
assert(s);
assert(s->state == STATE_PREPARED || s->state == STATE_FAILURE);
-
+
s->state = STATE_RUNNING;
- if (s->poll_func(s->pollfds, s->n_pollfds, s->prepared_timeout, s->poll_func_userdata) < 0) {
- s->state = STATE_FAILURE;
- return -1;
+ for (;;) {
+ errno = 0;
+
+ if (s->poll_func(s->pollfds, s->n_pollfds, s->prepared_timeout, s->poll_func_userdata) < 0) {
+
+ if (errno == EINTR)
+ continue;
+
+ s->state = STATE_FAILURE;
+ return -1;
+ }
+
+ break;
}
-
+
/* The poll events are now valid again */
s->events_valid = 1;
-
+
/* Update state */
s->state = STATE_RAN;
return 0;
s->state = STATE_DISPATCHING;
/* We execute only on callback in every iteration */
-
+
/* Check whether the wakeup time has been reached now */
if ((next_timeout = find_next_timeout(s))) {
-
+
if (next_timeout->expiry.tv_sec == 0 && next_timeout->expiry.tv_usec == 0) {
/* Just a shortcut so that we don't need to call gettimeofday() */
timeout_callback(next_timeout);
goto finish;
}
-
+
if (avahi_age(&next_timeout->expiry) >= 0) {
/* Timeout elapsed */
/* Look for some kind of I/O event */
for (w = s->watches; w; w = w->watches_next) {
-
+
if (w->dead)
continue;
-
+
assert(w->idx >= 0);
assert(w->idx < s->n_pollfds);
-
+
if (s->pollfds[w->idx].revents != 0) {
w->callback(w, w->pollfd.fd, s->pollfds[w->idx].revents, w->userdata);
goto finish;
if ((r = avahi_simple_poll_dispatch(s)) != 0)
return r;
-
+
return 0;
}
const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) {
assert(s);
-
+
return &s->api;
}
int r;
assert(s);
-
+
for (;;)
if ((r = avahi_simple_poll_iterate(s, -1)) != 0)
if (r >= 0 || errno != EINTR)
#ifndef foosimplewatchhfoo
#define foosimplewatchhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int r;
a = avahi_string_list_new("prefix", "a", "b", NULL);
-
+
a = avahi_string_list_add(a, "start");
a = avahi_string_list_add(a, "foo=99");
a = avahi_string_list_add(a, "bar");
a = avahi_string_list_add_pair(a, "blubb", "blaa");
a = avahi_string_list_add_pair(a, "uxknurz", NULL);
a = avahi_string_list_add_pair_arbitrary(a, "uxknurz2", (const uint8_t*) "blafasel\0oerks", 14);
-
+
a = avahi_string_list_add(a, "end");
t = avahi_string_list_to_string(a);
printf("--%s--\n", t);
avahi_free(t);
-
+
n = avahi_string_list_serialize(a, NULL, 0);
size = avahi_string_list_serialize(a, data, sizeof(data));
assert(size == n);
- printf("%u\n", size);
+ printf("%zu\n", size);
for (t = (char*) data, n = 0; n < size; n++, t++) {
if (*t <= 32)
}
printf("\n");
-
+
assert(avahi_string_list_parse(data, size, &b) == 0);
printf("equal: %i\n", avahi_string_list_equal(a, b));
-
+
t = avahi_string_list_to_string(b);
printf("--%s--\n", t);
avahi_free(t);
p = avahi_string_list_find(a, "seven");
assert(p);
-
- r = avahi_string_list_get_pair(p, &t, &v, NULL);
+
+ r = avahi_string_list_get_pair(p, &t, &v, NULL);
assert(r >= 0);
assert(t);
assert(v);
-
+
printf("<%s>=<%s>\n", t, v);
avahi_free(t);
avahi_free(v);
printf("<%s>=<%s>\n", t, v);
avahi_free(t);
avahi_free(v);
-
+
avahi_string_list_free(a);
avahi_string_list_free(b);
assert(avahi_string_list_parse(data, size, &a) == 0);
assert(!a);
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (!(n = avahi_malloc(sizeof(AvahiStringList) + size)))
return NULL;
-
+
n->next = l;
n->size = size;
int avahi_string_list_parse(const void* data, size_t size, AvahiStringList **ret) {
const uint8_t *c;
AvahiStringList *r = NULL;
-
+
assert(data);
assert(ret);
c = data;
while (size > 0) {
size_t k;
-
+
k = *(c++);
size--;
if (k > 0) { /* Ignore empty strings */
AvahiStringList *n;
- if (!(n = avahi_string_list_add_arbitrary(r, c, k)))
+ if (!(n = avahi_string_list_add_arbitrary(r, c, k)))
goto fail; /* OOM */
r = n;
}
-
+
c += k;
size -= k;
}
*ret = r;
-
+
return 0;
fail:
return NULL;
l = avahi_string_list_reverse(l);
-
+
for (n = l; n; n = n->next) {
if (n != l)
*(e++) = ' ';
}
l = avahi_string_list_reverse(l);
-
+
*e = 0;
return t;
l = avahi_string_list_reverse(l);
c = data;
-
+
for (n = l; size > 1 && n; n = n->next) {
size_t k;
if ((k = n->size) == 0)
/* Skip empty strings */
continue;
-
+
if (k > 255)
/* Truncate strings at 255 characters */
k = 255;
-
+
if (k > size-1)
/* Make sure this string fits in */
k = size-1;
*(c++) = (uint8_t) k;
memcpy(c, n->text, k);
c += k;
-
+
used += 1 + k;
size -= 1 + k;
}
-
+
l = avahi_string_list_reverse(l);
if (used == 0 && size > 0) {
-
+
/* Empty lists are treated specially. To comply with
* section 6.1 of the DNS-SD spec, we return a single
* empty string (i.e. a NUL byte)*/
*(uint8_t*) data = 0;
used = 1;
}
-
+
} else {
AvahiStringList *n;
for (n = l; n; n = n->next) {
size_t k;
-
+
if ((k = n->size) == 0)
continue;
-
+
if (k > 255)
k = 255;
-
+
used += 1+k;
}
va_start(va, r);
r = avahi_string_list_add_many_va(r, va);
va_end(va);
-
+
return r;
}
AvahiStringList *avahi_string_list_add_vprintf(AvahiStringList *l, const char *format, va_list va) {
size_t len = 80;
AvahiStringList *r;
-
+
assert(format);
if (!(r = avahi_malloc(sizeof(AvahiStringList) + len)))
int n;
AvahiStringList *nr;
va_list va2;
-
+
va_copy(va2, va);
n = vsnprintf((char*) r->text, len, format, va2);
va_end(va2);
r = nr;
}
-
+
r->next = l;
- r->size = strlen((char*) r->text);
+ r->size = strlen((char*) r->text);
return r;
}
AvahiStringList *avahi_string_list_add_printf(AvahiStringList *l, const char *format, ...) {
va_list va;
-
+
assert(format);
va_start(va, format);
l = avahi_string_list_add_vprintf(l, format, va);
va_end(va);
- return l;
+ return l;
}
AvahiStringList *avahi_string_list_find(AvahiStringList *l, const char *key) {
size_t n;
-
+
assert(key);
n = strlen(key);
return avahi_string_list_add(l, key);
n = strlen(key);
-
+
if (!(l = avahi_string_list_add_anonymous(l, n + 1 + size)))
return NULL;
int avahi_string_list_get_pair(AvahiStringList *l, char **key, char **value, size_t *size) {
char *e;
-
+
assert(l);
if (!(e = memchr(l->text, '=', l->size))) {
- if (key)
+ if (key)
if (!(*key = avahi_strdup((char*) l->text)))
return -1;
return -1;
e++; /* Advance after '=' */
-
+
n = l->size - (e - (char*) l->text);
-
+
if (value) {
if (!(*value = avahi_memdup(e, n+1))) {
AvahiStringList *f;
char *value = NULL, *end = NULL;
uint32_t ret;
-
+
if (!(f = avahi_string_list_find(l, AVAHI_SERVICE_COOKIE)))
return AVAHI_SERVICE_COOKIE_INVALID;
}
avahi_free(value);
-
+
return ret;
}
#ifndef footxtlisthfoo
#define footxtlisthfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef foothreadedwatchhfoo
#define foothreadedwatchhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
printf("%li.%li\n", a.tv_sec, a.tv_usec);
- printf("%lli\n", avahi_timeval_diff(&a, &b));
+ printf("%lli\n", (long long) avahi_timeval_diff(&a, &b));
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiUsec avahi_age(const struct timeval *a) {
struct timeval now;
-
+
assert(a);
gettimeofday(&now, NULL);
time_t now;
int r;
-
+
now = time(NULL);
pthread_mutex_lock(&mutex);
timestamp = now;
last_rand = rand();
}
-
+
r = last_rand;
-
+
pthread_mutex_unlock(&mutex);
/* We use the same jitter for 10 seconds. That way our
* time events elapse in bursts which has the advantage that
* packet data can be aggregated better */
-
+
avahi_timeval_add(tv, (AvahiUsec) (jitter*1000.0*r/(RAND_MAX+1.0)));
}
-
+
return tv;
}
#ifndef footimevalhfoo
#define footimevalhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
assert(avahi_utf8_valid("hallo"));
assert(!avahi_utf8_valid("üxknürz"));
assert(avahi_utf8_valid("üxknürz"));
-
+
return 0;
}
-/* $Id */
-
/* This file is based on the GLIB utf8 validation functions. The
* original license text follows. */
(((Char) & 0xFFFFF800) != 0xD800) && \
((Char) < 0xFDD0 || (Char) > 0xFDEF) && \
((Char) & 0xFFFE) != 0xFFFE)
-
-
+
+
#define CONTINUATION_CHAR \
do { \
if ((*(const unsigned char *)p & 0xc0) != 0x80) /* 10xxxxxx */ \
{
if (*(const unsigned char *)p < 128)
/* done */;
- else
+ else
{
const char *last;
-
+
last = p;
if ((*(const unsigned char *)p & 0xe0) == 0xc0) /* 110xxxxx */
{
}
else
goto error;
-
+
p++;
CONTINUATION_CHAR;
TWO_REMAINING:
CONTINUATION_CHAR;
p++;
CONTINUATION_CHAR;
-
+
if ( (val < min))
goto error;
if ( (!UNICODE_VALID(val)))
goto error;
- }
-
+ }
+
continue;
-
+
error:
return NULL;
}
#ifndef fooutf8hfoo
#define fooutf8hfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (event & AVAHI_WATCH_IN) {
ssize_t r;
char c;
-
+
if ((r = read(fd, &c, 1)) <= 0) {
fprintf(stderr, "read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
api->watch_free(w);
api = avahi_threaded_poll_get(threaded_poll);
assert(api);
#endif
-
+
api->watch_new(api, 0, AVAHI_WATCH_IN, callback, NULL);
avahi_elapse_time(&tv, 1000, 0);
fprintf(stderr, "... stupid stuff is done.\n");
avahi_threaded_poll_free(threaded_poll);
-
+
#endif
-
+
return 0;
}
#ifndef foowatchhfoo
#define foowatchhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiPoll {
/** Some abstract user data usable by the provider of the API */
- void* userdata;
+ void* userdata;
/** Create a new watch for the specified file descriptor and for
* the specified events. The API will call the callback function
/** Update the absolute expiration time for a timeout, If tv is
* NULL, the timeout is disabled. It is safe to call this function from an AvahiTimeoutCallback */
void (*timeout_update)(AvahiTimeout *, const struct timeval *tv);
-
+
/** Free a timeout. It is safe to call this function from an AvahiTimeoutCallback */
void (*timeout_free)(AvahiTimeout *t);
};
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
$(HOWLHEADERS) \
address.c \
address-test.c \
- warn.c warn.h
+ warn.c warn.h
address_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include
address_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la
$(HOWLHEADERS) \
text.c \
text-test.c \
- warn.c warn.h
+ warn.c warn.h
text_test_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I $(srcdir)/include
text_test_LDADD = $(AM_LDADD) $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) ../avahi-common/libavahi-common.la
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
ASSERT_SW_OKAY(sw_ipv4_address_init_from_name(&a, "heise.de"));
ASSERT_NOT_NULL(sw_ipv4_address_name(a, t, sizeof(t)));
printf("%s\n", t);
-
+
ASSERT_SW_OKAY(sw_ipv4_address_init_from_this_host(&a));
ASSERT_NOT_NULL(sw_ipv4_address_name(a, t, sizeof(t)));
printf("%s\n", t);
ASSERT_SW_OKAY(sw_ipv4_address_decompose(a, &a1, &a2, &a3, &a4));
printf("%i.%i.%i.%i\n", a1, a2, a3, a4);
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
assert(name);
AVAHI_WARN_LINKAGE;
-
+
if (!(he = gethostbyname(name)))
return SW_E_UNKNOWN;
-
+
self->m_addr = *(uint32_t*) he->h_addr;
return SW_OKAY;
}
assert(self);
AVAHI_WARN_LINKAGE;
-
+
/* This is so fucked up ... */
memset(&sa, 0, sizeof(sa));
close(fd);
self->m_addr = sa.sin_addr.s_addr;
-
+
return SW_OKAY;
}
AVAHI_WARN_LINKAGE;
/* This is ridiculous ... */
-
+
return SW_OKAY;
}
if (len < INET_ADDRSTRLEN)
return NULL;
-
+
if (!(inet_ntop(AF_INET, &self.m_addr, name, len)))
return NULL;
-
+
return name;
}
uint32_t a;
AVAHI_WARN_LINKAGE;
-
+
a = ntohl(self.m_addr);
-
+
assert(a1);
assert(a2);
assert(a3);
*a2 = (uint8_t) (a >> 16);
*a3 = (uint8_t) (a >> 8);
*a4 = (uint8_t) (a);
-
+
return SW_OKAY;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
case SW_DISCOVERY_BROWSE_INVALID:
fprintf(stderr, "some kind of failure happened: %s\n", domain);
break;
-
+
default:
abort();
}
int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
sw_discovery discovery;
sw_discovery_oid oid;
-
+
ASSERT_SW_OKAY(sw_discovery_init(&discovery));
ASSERT_SW_OKAY(sw_discovery_browse_domains(discovery, 0, reply, NULL, &oid));
-
+
ASSERT_SW_OKAY(sw_discovery_run(discovery));
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
sw_discovery_oid oid_index;
int thread_fd, main_fd;
-
+
pthread_t thread;
int thread_running;
switch (error) {
case AVAHI_OK:
return SW_OKAY;
-
+
case AVAHI_ERR_NO_MEMORY:
return SW_E_MEM;
}
char command;
assert(fd >= 0);
-
+
if ((r = read(fd, &command, 1)) != 1) {
fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
return -1;
static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) {
sw_discovery self = userdata;
int ret;
-
+
assert(self);
-
+
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
ret = poll(ufds, nfds, timeout);
ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
sigfillset(&mask);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
-
+
self->thread = pthread_self();
self->thread_running = 1;
break;
/* fprintf(stderr, "Command: %c\n", command); */
-
+
switch (command) {
case COMMAND_POLL: {
for (;;) {
errno = 0;
-
+
if ((ret = avahi_simple_poll_run(self->simple_poll)) < 0) {
-
+
if (errno == EINTR)
continue;
-
+
fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno));
}
break;
}
-
+
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
-
+
if (write_command(self->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0)
break;
-
+
break;
}
case COMMAND_QUIT:
return NULL;
}
-
+
}
return NULL;
while (self->oid_index >= OID_MAX)
self->oid_index -= OID_MAX;
-
+
if (self->oid_table[self->oid_index].type == OID_UNUSED) {
self->oid_table[self->oid_index].type = type;
self->oid_table[self->oid_index].discovery = self;
assert(OID_GET_INDEX(&self->oid_table[self->oid_index]) == self->oid_index);
-
+
return self->oid_index ++;
}
}
/* No free entry found */
-
+
return (sw_discovery_oid) -1;
}
if (self->oid_table[oid].type == OID_UNUSED)
return NULL;
-
+
return &self->oid_table[oid];
}
static service_data* service_data_new(sw_discovery self) {
service_data *sdata;
-
+
assert(self);
if (!(sdata = avahi_new0(service_data, 1)))
return NULL;
AVAHI_LLIST_PREPEND(service_data, services, self->services, sdata);
-
+
return sdata;
-
+
}
static void service_data_free(sw_discovery self, service_data* sdata) {
assert(sdata);
AVAHI_LLIST_REMOVE(service_data, services, self->services, sdata);
-
+
avahi_free(sdata->name);
avahi_free(sdata->regtype);
avahi_free(sdata->domain);
static void client_callback(AvahiClient *s, AvahiClientState state, void* userdata) {
sw_discovery self = userdata;
sw_discovery_oid oid;
-
+
assert(s);
assert(self);
discovery_ref(self);
-
+
for (oid = 0; oid < OID_MAX; oid++) {
switch (self->oid_table[oid].type) {
sw_result result = SW_E_UNKNOWN;
pthread_mutexattr_t mutex_attr;
int error;
-
+
assert(self);
-
+
AVAHI_WARN_LINKAGE;
*self = NULL;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0)
goto fail;
-
+
if (!(*self = avahi_new(struct _sw_discovery, 1))) {
result = SW_E_MEM;
goto fail;
memset((*self)->oid_table, 0, sizeof((*self)->oid_table));
(*self)->oid_index = 0;
-
+
(*self)->thread_running = 0;
AVAHI_LLIST_HEAD_INIT(service_info, (*self)->services);
result = map_error(error);
goto fail;
}
-
+
/* Start simple poll */
if (avahi_simple_poll_prepare((*self)->simple_poll, -1) < 0)
goto fail;
/* Queue an initial POLL command for the thread */
if (write_command((*self)->main_fd, COMMAND_POLL) < 0)
goto fail;
-
+
if (pthread_create(&(*self)->thread, NULL, thread_func, *self) != 0)
goto fail;
(*self)->thread_running = 1;
-
+
return SW_OKAY;
fail:
if (write_command(self->main_fd, COMMAND_QUIT) < 0)
return -1;
-
+
avahi_simple_poll_wakeup(self->simple_poll);
-
+
ASSERT_SUCCESS(pthread_join(self->thread, NULL));
self->thread_running = 0;
return 0;
while (self->services)
service_data_free(self, self->services);
-
+
avahi_free(self);
}
sw_result sw_discovery_fina(sw_discovery self) {
assert(self);
-
+
AVAHI_WARN_LINKAGE;
stop_thread(self);
discovery_unref(self);
-
+
return SW_OKAY;
}
sw_result sw_discovery_run(sw_discovery self) {
assert(self);
-
+
AVAHI_WARN_LINKAGE;
return sw_salt_run((sw_salt) self);
sw_result sw_discovery_stop_run(sw_discovery self) {
assert(self);
-
+
AVAHI_WARN_LINKAGE;
return sw_salt_stop_run((sw_salt) self);
int sw_discovery_socket(sw_discovery self) {
assert(self);
-
+
AVAHI_WARN_LINKAGE;
return self->main_fd;
sw_result sw_discovery_read_socket(sw_discovery self) {
sw_result result = SW_E_UNKNOWN;
-
+
assert(self);
discovery_ref(self);
ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
-
+
/* Cleanup notification socket */
if (read_command(self->main_fd) != COMMAND_POLL_DONE)
goto finish;
-
+
if (avahi_simple_poll_dispatch(self->simple_poll) < 0)
goto finish;
/* Request the poll */
if (write_command(self->main_fd, COMMAND_POLL) < 0)
goto finish;
-
+
result = SW_OKAY;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
discovery_unref(self);
-
+
return result;
}
sw_result sw_discovery_salt(sw_discovery self, sw_salt *salt) {
assert(self);
assert(salt);
-
+
AVAHI_WARN_LINKAGE;
*salt = (sw_salt) self;
-
+
return SW_OKAY;
}
if (!((sw_discovery) self)->thread_running)
return SW_E_UNKNOWN;
-
+
memset(&p, 0, sizeof(p));
p.fd = ((sw_discovery) self)->main_fd;
p.events = POLLIN;
if ((r = poll(&p, 1, msec ? (int) *msec : -1)) < 0) {
-
+
/* Don't treat EINTR as error */
if (errno == EINTR)
return SW_OKAY;
-
+
return SW_E_UNKNOWN;
-
+
} else if (r == 0) {
-
+
/* Timeoout */
return SW_OKAY;
} else {
/* Success */
-
+
if (p.revents != POLLIN)
return SW_E_UNKNOWN;
if ((result = sw_discovery_read_socket((sw_discovery) self)) != SW_OKAY)
return result;
}
-
+
return SW_OKAY;
}
AVAHI_WARN_LINKAGE;
assert(self);
-
+
for (;;)
if ((ret = sw_salt_step(self, NULL)) != SW_OKAY)
return ret;
sw_result sw_salt_unlock(sw_salt self) {
assert(self);
-
+
AVAHI_WARN_LINKAGE;
ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->salt_mutex));
sw_discovery_publish_reply reply;
assert(data);
-
+
reply = (sw_discovery_publish_reply) data->reply;
-
+
reply(data->discovery,
OID_GET_INDEX(data),
status,
static int reg_create_service(oid_data *data) {
int ret;
const char *real_type;
-
+
assert(data);
real_type = avahi_get_type_from_subtype(data->service_data->regtype);
-
+
if ((ret = avahi_entry_group_add_service_strlst(
data->object,
data->service_data->interface,
data->service_data->port,
data->service_data->txt)) < 0)
return ret;
-
+
if (real_type) {
/* Create a subtype entry */
/* We've not been setup completely */
if (!data->object)
return;
-
+
switch (state) {
case AVAHI_CLIENT_FAILURE:
reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
break;
-
+
case AVAHI_CLIENT_S_RUNNING: {
int ret;
reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
return;
}
-
+
break;
}
-
+
case AVAHI_CLIENT_S_COLLISION:
case AVAHI_CLIENT_S_REGISTERING:
case AVAHI_ENTRY_GROUP_FAILURE:
reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
break;
-
+
}
}
sw_result result = SW_E_UNKNOWN;
service_data *sdata;
AvahiStringList *txt = NULL;
-
+
assert(self);
assert(name);
assert(type);
assert(reply);
assert(oid);
-
+
AVAHI_WARN_LINKAGE;
if (text_record && text_record_len > 0)
if (avahi_client_get_state(self->client) == AVAHI_CLIENT_S_RUNNING) {
int error;
-
+
if ((error = reg_create_service(data)) < 0) {
result = map_error(error);
goto finish;
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
-
- if (result != SW_OKAY)
+
+ if (result != SW_OKAY)
if (*oid != (sw_discovery_oid) -1)
sw_discovery_cancel(self, *oid);
case AVAHI_BROWSER_FAILURE:
reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, NULL, NULL, domain, data->extra);
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
sw_discovery_browse_reply reply,
sw_opaque extra,
sw_discovery_oid * oid) {
-
+
oid_data *data;
AvahiIfIndex ifindex;
sw_result result = SW_E_UNKNOWN;
-
+
assert(self);
assert(reply);
assert(oid);
-
+
AVAHI_WARN_LINKAGE;
if ((*oid = oid_alloc(self, OID_DOMAIN_BROWSER)) == (sw_discovery_oid) -1)
assert(data);
data->reply = (sw_result (*)(void)) reply;
data->extra = extra;
-
+
ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index;
ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
-
+
if (!(data->object = avahi_domain_browser_new(self->client, ifindex, AVAHI_PROTO_INET, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, domain_browser_callback, data))) {
result = map_error(avahi_client_errno(self->client));
goto finish;
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
-
+
if (result != SW_OKAY)
if (*oid != (sw_discovery_oid) -1)
sw_discovery_cancel(self, *oid);
oid_data* data = userdata;
sw_discovery_resolve_reply reply;
-
+
assert(r);
assert(data);
sw_ipv4_address_init_from_saddr(&addr, a->data.ipv4.address);
host_name = add_trailing_dot(host_name, host_name_fixed, sizeof(host_name_fixed));
-
+
if ((p = avahi_new0(uint8_t, (l = avahi_string_list_serialize(txt, NULL, 0))+1)))
avahi_string_list_serialize(txt, p, l);
case AVAHI_RESOLVER_FAILURE:
/* Apparently there is no way in HOWL to inform about failed resolvings ... */
-
+
avahi_warn("A service failed to resolve in the HOWL compatiblity layer of Avahi which is used by '%s'. "
"Since the HOWL API doesn't offer any means to inform the application about this, we have to ignore the failure. "
"Please fix your application to use the native API of Avahi!",
oid_data *data;
AvahiIfIndex ifindex;
sw_result result = SW_E_UNKNOWN;
-
+
assert(self);
assert(name);
assert(type);
assert(reply);
assert(oid);
-
+
AVAHI_WARN_LINKAGE;
if ((*oid = oid_alloc(self, OID_SERVICE_RESOLVER)) == (sw_discovery_oid) -1)
assert(data);
data->reply = (sw_result (*)(void)) reply;
data->extra = extra;
-
+
ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index;
ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
-
+
if (!(data->object = avahi_service_resolver_new(self->client, ifindex, AVAHI_PROTO_INET, name, type, domain, AVAHI_PROTO_INET, 0, service_resolver_callback, data))) {
result = map_error(avahi_client_errno(self->client));
goto finish;
}
result = SW_OKAY;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
-
+
if (result != SW_OKAY)
if (*oid != (sw_discovery_oid) -1)
sw_discovery_cancel(self, *oid);
oid_data* data = userdata;
char type_fixed[AVAHI_DOMAIN_NAME_MAX], domain_fixed[AVAHI_DOMAIN_NAME_MAX];
sw_discovery_browse_reply reply;
-
+
assert(b);
assert(data);
case AVAHI_BROWSER_FAILURE:
reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, name, type, domain, data->extra);
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
oid_data *data;
AvahiIfIndex ifindex;
sw_result result = SW_E_UNKNOWN;
-
+
assert(self);
assert(type);
assert(reply);
assert(oid);
-
+
AVAHI_WARN_LINKAGE;
if ((*oid = oid_alloc(self, OID_SERVICE_BROWSER)) == (sw_discovery_oid) -1)
assert(data);
data->reply = (sw_result (*)(void)) reply;
data->extra = extra;
-
+
ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index;
ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
-
+
if (!(data->object = avahi_service_browser_new(self->client, ifindex, AVAHI_PROTO_INET, type, domain, 0, service_browser_callback, data))) {
result = map_error(avahi_client_errno(self->client));
goto finish;
}
result = SW_OKAY;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
-
+
if (result != SW_OKAY)
if (*oid != (sw_discovery_oid) -1)
sw_discovery_cancel(self, *oid);
sw_result sw_discovery_cancel(sw_discovery self, sw_discovery_oid oid) {
oid_data *data;
- assert(self);
+ assert(self);
AVAHI_WARN_LINKAGE;
case OID_SERVICE_BROWSER:
avahi_service_browser_free(data->object);
break;
-
+
case OID_SERVICE_RESOLVER:
avahi_service_resolver_free(data->object);
break;
-
+
case OID_DOMAIN_BROWSER:
avahi_domain_browser_free(data->object);
break;
-
+
case OID_ENTRY_GROUP:
avahi_entry_group_free(data->object);
break;
-
+
case OID_UNUSED:
;
}
}
oid_release(self, oid);
-
+
return SW_OKAY;
}
sw_text_record_string_iterator_init
sw_text_record_string_iterator_fina
sw_text_record_string_iterator_next
-
-$Id$
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
struct _sw_corby_buffer;
void HOWL_API
sw_corby_buffer_reset(
sw_corby_buffer self);
-
+
sw_result HOWL_API
sw_corby_buffer_set_octets(
sw_octets octets,
sw_size_t size);
-
+
sw_octets HOWL_API
sw_corby_buffer_octets(
sw_corby_buffer self);
-
-
+
+
sw_size_t HOWL_API
sw_corby_buffer_bytes_used(
sw_corby_buffer self);
-
+
sw_size_t HOWL_API
sw_corby_buffer_size(
sw_corby_buffer self);
-
+
sw_result HOWL_API
sw_corby_buffer_put_int8(
sw_corby_buffer self,
sw_const_octets val,
sw_size_t size);
-
+
sw_result HOWL_API
sw_corby_buffer_put_sized_octets(
sw_corby_buffer self,
sw_const_octets val,
sw_uint32 len);
-
+
sw_result HOWL_API
sw_corby_buffer_put_cstring(
sw_corby_buffer_put_pad(
sw_corby_buffer self,
sw_corby_buffer_pad pad);
-
+
sw_result HOWL_API
sw_corby_buffer_get_int8(
sw_octets * val,
sw_uint32 * size,
sw_uint8 endian);
-
+
sw_result HOWL_API
sw_corby_buffer_get_zerocopy_sized_octets(
sw_octets * val,
sw_uint32 * size,
sw_uint8 endian);
-
+
sw_result HOWL_API
sw_corby_buffer_get_sized_octets(
sw_string * val,
sw_uint32 * len,
sw_uint8 endian);
-
-
+
+
sw_result HOWL_API
sw_corby_buffer_get_zerocopy_cstring(
sw_corby_buffer self,
sw_string * val,
sw_uint32 * len,
sw_uint8 endian);
-
+
sw_result HOWL_API
sw_corby_buffer_get_cstring(
sw_string val,
sw_uint32 * len,
sw_uint8 endian);
-
-
+
+
sw_result HOWL_API
sw_corby_buffer_get_object(
sw_corby_buffer self,
struct _sw_corby_object ** object,
sw_uint8 endian);
-
+
#ifdef __cplusplus
}
-#endif
+#endif
#endif
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
struct _sw_corby_channel;
typedef struct _sw_corby_channel * sw_corby_channel;
#ifdef __cplusplus
}
-#endif
+#endif
#endif
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
/*
- * protocol tags. the only standard one is TAG_INTERNET_IIOP.
+ * protocol tags. the only standard one is TAG_INTERNET_IIOP.
* the others are proprietary pandora corby protocols.
- */
+ */
#define SW_TAG_INTERNET_IOP 0
#define SW_TAG_UIOP 250
#define SW_TAG_MIOP 251
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
}
-#endif
+#endif
#endif
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
sw_result HOWL_API
sw_corby_object_fina(
sw_corby_object self);
-
+
sw_result HOWL_API
sw_corby_object_start_request(
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
struct _sw_corby_orb;
sw_const_string tag,
sw_string addr,
sw_port * port);
-
+
sw_result HOWL_API
sw_corby_orb_protocol_to_url(
#ifdef __cplusplus
}
-#endif
+#endif
#endif
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
/*
* For backwards compatibility
*/
-#define sw_discovery_publish_host_id sw_discovery_oid
+#define sw_discovery_publish_host_id sw_discovery_oid
#define sw_discovery_publish_id sw_discovery_oid
#define sw_discovery_browse_id sw_discovery_oid
#define sw_discovery_resolve_id sw_discovery_oid
sw_discovery_publish_status status,
sw_opaque extra);
-typedef sw_result
+typedef sw_result
(HOWL_API *sw_discovery_browse_reply)(
sw_discovery session,
sw_discovery_oid oid,
sw_const_string fullname,
sw_uint16 rrtype,
sw_uint16 rrclass,
- sw_uint16 rrdatalen,
+ sw_uint16 rrdatalen,
sw_const_octets rrdata,
sw_uint32 ttl,
- sw_opaque extra);
+ sw_opaque extra);
/*
sw_const_string fullname,
sw_uint16 rrtype,
sw_uint16 rrclass,
- sw_discovery_query_record_reply reply,
+ sw_discovery_query_record_reply reply,
sw_opaque extra,
sw_discovery_oid * oid);
sw_discovery_cancel(
sw_discovery self,
sw_discovery_oid oid);
-
+
/* ----------------------------------------------------------
*
* ----------------------------------------------------------
*/
-
+
sw_result HOWL_API
sw_discovery_run(
sw_result HOWL_API
sw_discovery_stop_run(
sw_discovery self);
-
+
int HOWL_API
sw_discovery_socket(
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
sw_bool HOWL_API
sw_ipv4_address_is_any(
sw_ipv4_address self);
-
+
sw_saddr HOWL_API
sw_ipv4_address_saddr(
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
#define SW_LOG_WARNING 1 << 0
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
#if defined(__VXWORKS__)
* for little endian platforms.
*
* The macro WORDS_BIGENDIAN will be defined
- * by autoconf. If you are using Howl on
+ * by autoconf. If you are using Howl on
* a platform that doesn't have autoconf, define
* SW_ENDIAN directly
* --------------------------------------------------------
sw_strcasecmp(
sw_const_string arg1,
sw_const_string arg2);
-
+
extern sw_int32
sw_strncasecmp(
sw_const_string arg1,
sw_const_string arg2,
sw_len n);
-
+
extern sw_string
sw_strtok_r(
sw_string arg1,
sw_const_string arg2,
sw_string * lasts);
-
+
# define sw_memset(ARG1, ARG2, ARG3) memset((char*) ARG1, ARG2, ARG3)
# define sw_memcpy(ARG1, ARG2, ARG3) memcpy((char*) ARG1, (char*) ARG2, ARG3)
# define sw_memcmp(ARG1, ARG2, ARG3) memcmp((char*) ARG1, ARG2, ARG3)
/*
* Obsolete types and macros.
- *
+ *
* These are here for backwards compatibility, but will
* be removed in the future
*/
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
typedef enum _sw_socket_event
{
SW_SOCKET_READ = (1 << 0),
SW_SOCKET_WRITE = (1 << 1),
- SW_SOCKET_OOB = (1 << 2)
+ SW_SOCKET_OOB = (1 << 2)
} sw_socket_event;
sw_salt salt,
struct _sw_network_interface * netif,
sw_opaque extra);
-
+
typedef sw_opaque sw_signal_handler;
typedef sw_result
(HOWL_API *sw_signal_handler_func)(
sw_salt * self,
int argc,
char ** argv);
-
-
+
+
sw_result HOWL_API
sw_salt_fina(
sw_salt self);
-
+
sw_result HOWL_API
sw_salt_register_socket(
sw_salt self,
sw_salt_unregister_socket(
sw_salt self,
struct _sw_socket * socket);
-
-
+
+
sw_result HOWL_API
sw_salt_register_timer(
sw_salt self,
sw_timer_handler handler,
sw_timer_handler_func func,
sw_opaque extra);
-
-
+
+
sw_result HOWL_API
sw_salt_unregister_timer(
sw_salt self,
sw_result HOWL_API
sw_salt_stop_run(
sw_salt self);
-
+
#define SW_FALSE 0
#define SW_TRUE 1
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
struct _sw_signal;
#ifdef __cplusplus
}
-#endif
+#endif
#endif
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
struct _sw_socket;
sw_result HOWL_API
sw_multicast_socket_init(
sw_socket * self);
-
-
+
+
sw_result HOWL_API
sw_socket_fina(
sw_socket self);
sw_socket_listen(
sw_socket self,
int qsize);
-
-
+
+
sw_result HOWL_API
sw_socket_connect(
sw_socket self,
sw_ipv4_address address,
sw_port port);
-
-
+
+
sw_result HOWL_API
sw_socket_accept(
sw_socket self,
sw_socket * socket);
-
-
+
+
sw_result HOWL_API
sw_socket_send(
sw_socket self,
sw_ipv4_address to,
sw_port port);
-
+
sw_result HOWL_API
sw_socket_recv(
sw_socket self,
sw_socket_set_blocking_mode(
sw_socket self,
sw_bool blocking_mode);
-
-
+
+
sw_result HOWL_API
sw_socket_set_options(
sw_socket self,
sw_socket_options options);
-
+
sw_ipv4_address HOWL_API
sw_socket_ipv4_address(
sw_result HOWL_API
sw_socket_options_init(
sw_socket_options * self);
-
+
sw_result HOWL_API
sw_socket_options_fina(
sw_socket_options self);
-
+
sw_result HOWL_API
sw_socket_options_set_debug(
sw_socket_options self,
sw_bool val);
-
+
sw_result HOWL_API
sw_socket_options_set_nodelay(
sw_socket_options self,
sw_bool val);
-
-
+
+
sw_result HOWL_API
sw_socket_options_set_dontroute(
sw_socket_options self,
sw_bool val);
-
-
+
+
sw_result HOWL_API
sw_socket_options_set_keepalive(
sw_socket_options self,
sw_socket_options self,
sw_bool onoff,
sw_uint32 linger);
-
-
+
+
sw_result HOWL_API
sw_socket_options_set_reuseaddr(
sw_socket_options self,
sw_socket_options_set_rcvbuf(
sw_socket_options self,
sw_uint32 val);
-
-
+
+
sw_result HOWL_API
sw_socket_options_set_sndbuf(
sw_socket_options self,
int
-sw_socket_error_code(void);
+sw_socket_error_code(void);
#define SW_E_SOCKET_BASE 0x80000200
#ifdef __cplusplus
}
-#endif
+#endif
#endif
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifdef __cplusplus
extern "C"
{
-#endif
+#endif
struct _sw_timer;
#ifdef __cplusplus
}
-#endif
+#endif
#endif
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
sw_result err = SW_OKAY;
sw_discovery_cancel(discovery, oid);
-
+
fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port);
if ((text_record_len > 0) && (text_record) && (*text_record != '\0'))
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
sw_const_string fullname,
sw_uint16 rrtype,
sw_uint16 rrclass,
- sw_uint16 rrdatalen,
+ sw_uint16 rrdatalen,
sw_const_octets rrdata,
sw_uint32 ttl,
sw_opaque extra)
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
sw_result err = SW_OKAY;
sw_discovery_cancel(discovery, oid);
-
+
fprintf(stderr, "resolve reply: 0x%x %s %s %s %s %d\n", interface_index, name, type, domain, sw_ipv4_address_name(address, name_buf, 16), port);
if ((text_record_len > 0) && (text_record) && (*text_record != '\0'))
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
const uint8_t *c = p;
assert(p);
- printf("Dumping %u bytes from %p:\n", size, p);
+ printf("Dumping %zu bytes from %p:\n", size, p);
while (size > 0) {
unsigned i;
char key[255];
uint8_t val[255];
sw_ulong val_len;
-
+
ASSERT_SW_OKAY(sw_text_record_init(&r));
ASSERT_SW_OKAY(sw_text_record_add_string(r, "foo=bar"));
ASSERT_SW_OKAY(sw_text_record_add_string(r, "waldo=baz"));
ASSERT_SW_OKAY(sw_text_record_add_key_and_string_value(r, "quux", "nimpf"));
- ASSERT_SW_OKAY(sw_text_record_add_key_and_binary_value(r, "quux", "\0\0\0\0", 4));
+ ASSERT_SW_OKAY(sw_text_record_add_key_and_binary_value(r, "quux", (void*) "\0\0\0\0", 4));
hexdump(sw_text_record_bytes(r), sw_text_record_len(r));
-
+
ASSERT_SW_OKAY(sw_text_record_fina(r));
return 0;
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static size_t strlcpy(char *dest, const char *src, size_t n) {
assert(dest);
assert(src);
-
+
if (n > 0) {
strncpy(dest, src, n-1);
dest[n-1] = 0;
}
-
+
return strlen(src);
}
assert(self);
AVAHI_WARN_LINKAGE;
-
+
if (!(*self = avahi_new(struct _sw_text_record, 1))) {
*self = NULL;
return SW_E_UNKNOWN;
}
-
+
(*self)->strlst = NULL;
(*self)->buffer = NULL;
(*self)->buffer_size = 0;
(*self)->buffer_valid = 0;
-
+
return SW_OKAY;
}
sw_const_string string) {
AvahiStringList *n;
-
+
assert(self);
assert(string);
AVAHI_WARN_LINKAGE;
-
+
if (!(n = avahi_string_list_add(self->strlst, string)))
return SW_E_UNKNOWN;
assert(self);
assert(key);
-
+
AVAHI_WARN_LINKAGE;
if (!(n = avahi_string_list_add_pair(self->strlst, key, val)))
assert(self);
assert(key);
assert(len || !val);
-
+
AVAHI_WARN_LINKAGE;
if (!(n = avahi_string_list_add_pair_arbitrary(self->strlst, key, val, len)))
return 0;
self->buffer_size = avahi_string_list_serialize(self->strlst, NULL, 0);
-
+
if (!(self->buffer = avahi_realloc(self->buffer, self->buffer_size + 1)))
return -1;
-
+
avahi_string_list_serialize(self->strlst, self->buffer, self->buffer_size);
self->buffer_valid = 1;
assert(self);
AVAHI_WARN_LINKAGE;
-
+
if (rebuild(self) < 0)
return (uint32_t) -1;
struct _sw_text_record_iterator {
AvahiStringList *strlst, *index;
-
+
};
sw_result sw_text_record_iterator_init(
assert(self);
AVAHI_WARN_LINKAGE;
-
+
if (!(*self = avahi_new(struct _sw_text_record_iterator, 1))) {
*self = NULL;
return SW_E_UNKNOWN;
}
(*self)->index = (*self)->strlst = avahi_string_list_reverse(txt);
-
+
return SW_OKAY;
}
avahi_string_list_free(self->strlst);
avahi_free(self);
-
+
return SW_OKAY;
}
char *mkey = NULL, *mvalue = NULL;
size_t msize = 0;
-
+
assert(self);
assert(key);
-
+
AVAHI_WARN_LINKAGE;
if (!self->index)
memset(val, 0, SW_TEXT_RECORD_MAX_LEN);
memcpy(val, mvalue, msize);
*val_len = msize;
-
+
avahi_free(mkey);
avahi_free(mvalue);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_WARN_UNSUPPORTED_ABORT;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_time sw_time_sub(
AVAHI_GCC_UNUSED sw_time self,
AVAHI_GCC_UNUSED sw_time y) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_int32 sw_time_cmp(
AVAHI_GCC_UNUSED sw_time self,
AVAHI_GCC_UNUSED sw_time y) {
return SW_E_NO_IMPL;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_ipv4_address sw_socket_ipv4_address(AVAHI_GCC_UNUSED sw_socket self) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_port sw_socket_port(AVAHI_GCC_UNUSED sw_socket self) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_sockdesc_t sw_socket_desc(AVAHI_GCC_UNUSED sw_socket self) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
return SW_E_NO_IMPL;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
int sw_socket_error_code(void) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
return SW_E_NO_IMPL;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_corby_orb_delegate sw_corby_orb_get_delegate(AVAHI_GCC_UNUSED sw_corby_orb self) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
sw_result sw_corby_buffer_fina(AVAHI_GCC_UNUSED sw_corby_buffer self) {
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
-}
+}
void sw_corby_buffer_reset(AVAHI_GCC_UNUSED sw_corby_buffer self) {
AVAHI_WARN_UNSUPPORTED;
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
}
-
+
sw_result sw_corby_buffer_put_cstring(
AVAHI_GCC_UNUSED sw_corby_buffer self,
AVAHI_GCC_UNUSED sw_const_string val) {
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
}
-
+
sw_result sw_corby_buffer_get_uint16(
AVAHI_GCC_UNUSED sw_corby_buffer self,
AVAHI_GCC_UNUSED sw_uint16 * val,
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
}
-
+
sw_result sw_corby_buffer_get_int32(
AVAHI_GCC_UNUSED sw_corby_buffer self,
AVAHI_GCC_UNUSED sw_int32 * val,
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
}
-
+
sw_result sw_corby_channel_start_reply(
AVAHI_GCC_UNUSED sw_corby_channel self,
AVAHI_GCC_UNUSED struct _sw_corby_buffer ** buffer,
AVAHI_GCC_UNUSED sw_corby_channel_delegate delegate) {
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
-}
+}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_corby_channel_delegate sw_corby_channel_get_delegate(
AVAHI_GCC_UNUSED sw_corby_channel self) {
AVAHI_WARN_UNSUPPORTED_ABORT;
AVAHI_WARN_UNSUPPORTED;
}
-AVAHI_GCC_NORETURN
+AVAHI_GCC_NORETURN
sw_opaque sw_corby_channel_get_app_data(AVAHI_GCC_UNUSED sw_corby_channel self) {
AVAHI_WARN_UNSUPPORTED_ABORT;
}
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
}
-
+
sw_result sw_corby_object_recv(
AVAHI_GCC_UNUSED sw_corby_object self,
AVAHI_GCC_UNUSED sw_corby_message * message,
AVAHI_GCC_UNUSED sw_text_record_string_iterator self) {
AVAHI_WARN_UNSUPPORTED;
return SW_E_NO_IMPL;
-}
+}
sw_result sw_text_record_string_iterator_next(
AVAHI_GCC_UNUSED sw_text_record_string_iterator self,
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foowarnhhowlfoo
#define foowarnhhowlfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# licensing restrictions.
libdns_sd-test: libdns_sd-test.c libdns_sd.la
- $(LIBTOOL) --mode=compile $(CC) $(AM_CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test.o -c libdns_sd-test.c
- $(LIBTOOL) --mode=link $(CC) $(AM_CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test libdns_sd-test.o $(PTHREAD_LIBS) ../avahi-common/libavahi-common.la libdns_sd.la
+ $(LIBTOOL) --mode=compile $(CC) $(AM_CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test.o -c libdns_sd-test.c
+ $(LIBTOOL) --mode=link $(CC) $(AM_CFLAGS) $(PTHREAD_CFLAGS) -o libdns_sd-test libdns_sd-test.o $(PTHREAD_LIBS) ../avahi-common/libavahi-common.la libdns_sd.la
CLEANFILES = libdns_sd-test.o libdns_sd-test
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct _DNSServiceRef_t {
int n_ref;
-
+
AvahiSimplePoll *simple_poll;
int thread_fd, main_fd;
int thread_running;
pthread_mutex_t mutex;
-
+
void *context;
DNSServiceBrowseReply service_browser_callback;
DNSServiceResolveReply service_resolver_callback;
switch (error) {
case AVAHI_OK :
return kDNSServiceErr_NoError;
-
+
case AVAHI_ERR_BAD_STATE :
return kDNSServiceErr_BadState;
-
+
case AVAHI_ERR_INVALID_HOST_NAME:
case AVAHI_ERR_INVALID_DOMAIN_NAME:
case AVAHI_ERR_INVALID_TTL:
case AVAHI_ERR_INVALID_INTERFACE:
case AVAHI_ERR_INVALID_PROTOCOL:
return kDNSServiceErr_BadInterfaceIndex;
-
+
case AVAHI_ERR_INVALID_FLAGS:
return kDNSServiceErr_BadFlags;
-
+
case AVAHI_ERR_NOT_FOUND:
return kDNSServiceErr_NoSuchName;
-
+
case AVAHI_ERR_VERSION_MISMATCH:
return kDNSServiceErr_Incompatible;
static int type_info_parse(struct type_info *i, const char *t) {
char *token = NULL;
-
+
assert(i);
assert(t);
if (*t == 0)
break;
-
+
l = strcspn(t, ",");
if (l <= 0)
goto fail;
-
+
token = avahi_strndup(t, l);
if (!token)
token = NULL;
} else {
char *fst;
-
+
/* This is not the first token, hence a subtype */
if (!(fst = avahi_strdup_printf("%s._sub.%s", token, i->type)))
if (i->type)
return 0;
-
+
fail:
type_info_free(i);
avahi_free(token);
char command;
assert(fd >= 0);
-
+
if ((r = read(fd, &command, 1)) != 1) {
fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
return -1;
static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) {
DNSServiceRef sdref = userdata;
int ret;
-
+
assert(sdref);
-
+
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
/* fprintf(stderr, "pre-syscall\n"); */
ret = poll(ufds, nfds, timeout);
/* fprintf(stderr, "post-syscall\n"); */
-
+
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
return ret;
sigfillset(&mask);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
-
+
sdref->thread = pthread_self();
sdref->thread_running = 1;
break;
/* fprintf(stderr, "Command: %c\n", command); */
-
+
switch (command) {
case COMMAND_POLL: {
for (;;) {
errno = 0;
-
+
if ((ret = avahi_simple_poll_run(sdref->simple_poll)) < 0) {
if (errno == EINTR)
continue;
-
+
fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno));
}
if (write_command(sdref->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0)
break;
-
+
break;
}
case COMMAND_QUIT:
return NULL;
}
-
+
}
return NULL;
/* Queue an initial POLL command for the thread */
if (write_command(sdref->main_fd, COMMAND_POLL) < 0)
goto fail;
-
+
if (pthread_create(&sdref->thread, NULL, thread_func, sdref) != 0)
goto fail;
sdref->thread_running = 1;
-
+
return sdref;
fail:
static void sdref_free(DNSServiceRef sdref) {
assert(sdref);
-
+
if (sdref->thread_running) {
ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT));
avahi_simple_poll_wakeup(sdref->simple_poll);
avahi_free(sdref->service_host);
type_info_free(&sdref->type_info);
-
+
avahi_string_list_free(sdref->service_txt);
-
+
avahi_free(sdref);
}
int DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdref) {
AVAHI_WARN_LINKAGE;
-
+
if (!sdref || sdref->n_ref <= 0)
return -1;
if (!sdref || sdref->n_ref <= 0)
return kDNSServiceErr_BadParam;
-
+
sdref_ref(sdref);
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
/* Cleanup notification socket */
if (read_command(sdref->main_fd) != COMMAND_POLL_DONE)
goto finish;
-
+
if (avahi_simple_poll_dispatch(sdref->simple_poll) < 0)
goto finish;
/* Request the poll */
if (write_command(sdref->main_fd, COMMAND_POLL) < 0)
goto finish;
-
+
ret = kDNSServiceErr_NoError;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
sdref_unref(sdref);
return ret;
type = add_trailing_dot(type, type_fixed, sizeof(type_fixed));
domain = add_trailing_dot(domain, domain_fixed, sizeof(domain_fixed));
-
+
switch (event) {
case AVAHI_BROWSER_NEW:
sdref->service_browser_callback(sdref, kDNSServiceFlagsAdd, interface, kDNSServiceErr_NoError, name, type, domain, sdref->context);
case AVAHI_BROWSER_FAILURE:
sdref->service_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), NULL, NULL, NULL, sdref->context);
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
static void generic_client_callback(AvahiClient *s, AvahiClientState state, void* userdata) {
DNSServiceRef sdref = userdata;
int error = kDNSServiceErr_Unknown;
-
+
assert(s);
assert(sdref);
assert(sdref->n_ref >= 1);
DNSServiceRef sdref = NULL;
AvahiIfIndex ifindex;
struct type_info type_info;
-
+
AVAHI_WARN_LINKAGE;
if (!ret_sdref || !regtype)
}
type_info_init(&type_info);
-
+
if (type_info_parse(&type_info, regtype) < 0 || type_info.n_subtypes > 1) {
type_info_free(&type_info);
return kDNSServiceErr_Unsupported;
} else
regtype = type_info.subtypes ? (char*) type_info.subtypes->text : type_info.type;
-
+
if (!(sdref = sdref_new())) {
type_info_free(&type_info);
return kDNSServiceErr_Unknown;
sdref->service_browser_callback = callback;
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
}
ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface;
-
+
if (!(sdref->service_browser = avahi_service_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, regtype, domain, 0, service_browser_callback, sdref))) {
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
assert(ret == AVAHI_OK);
strcat(full_name, ".");
-
+
sdref->service_resolver_callback(sdref, 0, interface, kDNSServiceErr_NoError, full_name, host_name, htons(port), l, (unsigned char*) p, sdref->context);
avahi_free(p);
sdref->service_resolver_callback = callback;
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
}
ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface;
-
+
if (!(sdref->service_resolver = avahi_service_resolver_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, name, regtype, domain, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, sdref))) {
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
int DNSSD_API DNSServiceConstructFullName (
char *fullName,
- const char *service,
+ const char *service,
const char *regtype,
const char *domain) {
if (avahi_service_name_join(fullName, kDNSServiceMaxDomainName, service, regtype, domain) < 0)
return -1;
-
+
return 0;
}
case AVAHI_BROWSER_FAILURE:
sdref->domain_browser_callback(sdref, 0, interface, map_error(avahi_client_errno(sdref->client)), domain, sdref->context);
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
sdref->domain_browser_callback = callback;
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, generic_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
}
ifindex = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface;
-
+
if (!(sdref->domain_browser = avahi_domain_browser_new(sdref->client, ifindex, AVAHI_PROTO_UNSPEC, "local",
flags == kDNSServiceFlagsRegistrationDomains ? AVAHI_DOMAIN_BROWSER_REGISTER : AVAHI_DOMAIN_BROWSER_BROWSE,
0, domain_browser_callback, sdref))) {
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
regtype = add_trailing_dot(sdref->type_info.type, regtype_fixed, sizeof(regtype_fixed));
domain = add_trailing_dot(sdref->service_domain, domain_fixed, sizeof(domain_fixed));
-
+
sdref->service_register_callback(
sdref, 0, error,
sdref->service_name_chosen ? sdref->service_name_chosen : sdref->service_name,
static int reg_create_service(DNSServiceRef sdref) {
int ret;
AvahiStringList *l;
-
+
assert(sdref);
assert(sdref->n_ref >= 1);
/* We've not been setup completely */
if (!sdref->entry_group)
return;
-
+
switch (state) {
case AVAHI_CLIENT_FAILURE:
reg_report_error(sdref, kDNSServiceErr_Unknown);
if (!sdref->service_name_chosen) {
assert(sdref->service_name);
-
+
if (!(sdref->service_name_chosen = avahi_strdup(sdref->service_name))) {
reg_report_error(sdref, kDNSServiceErr_NoMemory);
return;
}
}
-
+
/* Register the service */
if ((ret = reg_create_service(sdref)) < 0) {
reg_report_error(sdref, map_error(ret));
return;
}
-
+
break;
}
-
+
case AVAHI_CLIENT_S_COLLISION:
case AVAHI_CLIENT_S_REGISTERING:
/* Remove our entry */
avahi_entry_group_reset(sdref->entry_group);
-
+
break;
case AVAHI_CLIENT_CONNECTING:
case AVAHI_ENTRY_GROUP_COLLISION: {
char *n;
int ret;
-
+
/* Remove our entry */
avahi_entry_group_reset(sdref->entry_group);
reg_report_error(sdref, map_error(ret));
return;
}
-
+
break;
}
/* Inform the user */
reg_report_error(sdref, map_error(avahi_client_errno(sdref->client)));
break;
-
+
}
}
DNSServiceRef *ret_sdref,
DNSServiceFlags flags,
uint32_t interface,
- const char *name,
+ const char *name,
const char *regtype,
- const char *domain,
- const char *host,
+ const char *domain,
+ const char *host,
uint16_t port,
uint16_t txtLen,
- const void *txtRecord,
- DNSServiceRegisterReply callback,
+ const void *txtRecord,
+ DNSServiceRegisterReply callback,
void *context) {
DNSServiceErrorType ret = kDNSServiceErr_Unknown;
if (!ret_sdref || !regtype)
return kDNSServiceErr_BadParam;
*ret_sdref = NULL;
-
+
if (!txtRecord) {
txtLen = 1;
txtRecord = "";
return kDNSServiceErr_Unsupported;
}
- if (txtLen > 0)
+ if (txtLen > 0)
if (avahi_string_list_parse(txtRecord, txtLen, &txt) < 0)
return kDNSServiceErr_Invalid;
avahi_string_list_free(txt);
return kDNSServiceErr_Invalid;
}
-
+
if (!(sdref = sdref_new())) {
avahi_string_list_free(txt);
type_info_free(&type_info);
sdref->service_txt = txt;
/* Some OOM checking would be cool here */
-
+
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
-
+
if (!(sdref->client = avahi_client_new(avahi_simple_poll_get(sdref->simple_poll), 0, reg_client_callback, sdref, &error))) {
ret = map_error(error);
goto finish;
goto finish;
}
-
+
if ((error = reg_create_service(sdref)) < 0) {
ret = map_error(error);
goto finish;
}
}
-
+
ret = kDNSServiceErr_NoError;
*ret_sdref = sdref;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
if (ret != kDNSServiceErr_NoError)
DNSServiceRefDeallocate(sdref);
DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
DNSServiceRef sdref,
- DNSRecordRef rref,
+ DNSRecordRef rref,
DNSServiceFlags flags,
uint16_t rdlen,
const void *rdata,
return kDNSServiceErr_Unsupported;
}
- if (rdlen > 0)
+ if (rdlen > 0)
if (avahi_string_list_parse(rdata, rdlen, &txt) < 0)
return kDNSServiceErr_Invalid;
sdref->type_info.type,
sdref->service_domain,
sdref->service_txt) < 0) {
-
+
ret = map_error(avahi_client_errno(sdref->client));
goto finish;
}
avahi_string_list_free(txt);
ret = kDNSServiceErr_NoError;
-
+
finish:
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
-
+
return ret;
}
*
* Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
+ * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Flag for signifying that a query or registration should be performed exclusively via multicast DNS,
* even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
*/
-
+
kDNSServiceFlagsReturnCNAME = 0x800
/* Flag for returning CNAME records in the DNSServiceQueryRecord call. CNAME records are
* normally followed without indicating to the client that there was a CNAME record.
*/
-/*
+/*
* Constants for specifying an interface index
*
* Specific interface indexes are identified via a 32-bit unsigned integer returned
* by the if_nametoindex() family of calls.
- *
+ *
* If the client passes 0 for interface index, that means "do the right thing",
* which (at present) means, "if the name is in an mDNS local multicast domain
* (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast
* on all applicable interfaces, otherwise send via unicast to the appropriate
* DNS server." Normally, most clients will use 0 for interface index to
* automatically get the default sensible behaviour.
- *
+ *
* If the client passes a positive interface index, then for multicast names that
* indicates to do the operation only on that one interface. For unicast names the
* interface index is ignored unless kDNSServiceFlagsForceMulticast is also set.
- *
+ *
* If the client passes kDNSServiceInterfaceIndexLocalOnly when registering
* a service, then that service will be found *only* by other local clients
* on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly
* running on the same machine, this allows the client to advertise that service
* in a way such that it does not inadvertently appear in service lists on
* all the other machines on the network.
- *
+ *
* If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing
* then it will find *all* records registered on that same local machine.
* Clients explicitly wishing to discover *only* LocalOnly services can
/* DNSServiceEnumerateDomains() Parameters:
*
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the enumeration operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
/* DNSServiceRegister() Parameters:
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the registration will remain active indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
/* DNSServiceBrowse() Parameters:
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the browse operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
/* DNSServiceResolve() Parameters
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the resolve operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
/* DNSServiceQueryRecord() Parameters:
*
- * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
+ * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
* then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
* and the query operation will run indefinitely until the client
* terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
* calls by this user that do not specify an explicit domain will browse and
* register in this wide-area domain in addition to .local. In addition, this
* domain will be returned as a Browse domain via domain enumeration calls.
- *
+ *
*
* Parameters:
*
(
DNSServiceFlags flags,
const char *domain
- );
-
+ );
+
#endif //__APPLE_API_PRIVATE
// Some C compiler cleverness. We can make the compiler check certain things for us,
-- Unsupported and Irrelevant --
DNSServiceSetDefaultDomainForUser
-
-$Id$
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
const uint8_t *c = p;
assert(p);
- printf("Dumping %u bytes from %p:\n", size, p);
+ printf("Dumping %zu bytes from %p:\n", size, p);
while (size > 0) {
unsigned i;
TXTRecordSetValue(&ref, "yeah", 0, NULL);
hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
-
+
TXTRecordSetValue(&ref, "waldo", 6, "rocked");
hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
-
+
TXTRecordRemoveValue(&ref, "foo");
hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
TXTRecordSetValue(&ref, "kawumm", 6, "bloerb");
hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
-
+
TXTRecordSetValue(&ref, "one", 1, "1");
hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
TXTRecordSetValue(&ref, "three", 1, "3");
hexdump(TXTRecordGetBytesPtr(&ref), TXTRecordGetLength(&ref));
-
+
assert(TXTRecordContainsKey(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "two"));
assert(!TXTRecordContainsKey(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), "four"));
hexdump(p, l);
assert(TXTRecordGetItemAtIndex(TXTRecordGetLength(&ref), TXTRecordGetBytesPtr(&ref), 20, sizeof(k), k, &l, &p) == kDNSServiceErr_Invalid);
-
+
TXTRecordDeallocate(&ref);
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_WARN_LINKAGE;
assert(txtref);
-
+
/* Apple's API design is flawed in so many ways, including the
* fact that it isn't compatible with 64 bit processors. To work
* around this we need some magic here which involves allocating
TXTRecordInternal *t;
AVAHI_WARN_LINKAGE;
-
+
assert(txtref);
t = INTERNAL_PTR(txtref);
if (!t)
static int make_sure_fits_in(TXTRecordInternal *t, size_t size) {
uint8_t *n;
size_t nsize;
-
+
assert(t);
if (t->size + size <= t->max_size)
if (nsize > 0xFFFF)
return -1;
-
+
if (!(n = avahi_realloc(t->malloc_buffer, nsize)))
return -1;
if (!t->malloc_buffer && t->size)
memcpy(n, t->buffer, t->size);
-
+
t->buffer = t->malloc_buffer = n;
t->max_size = nsize;
/* Key longer than buffer */
if (key_len > t->size - i - 1)
break;
-
+
if (key_len <= *p &&
strncmp(key, (char*) p+1, key_len) == 0 &&
(key_len == *p || p[1+key_len] == '=')) {
found = 1;
} else {
/* Skip to next */
-
+
i += *p +1;
p += *p +1;
}
DNSServiceErrorType DNSSD_API TXTRecordSetValue(
TXTRecordRef *txtref,
const char *key,
- uint8_t length,
+ uint8_t length,
const void *value) {
TXTRecordInternal *t;
if (n > 0xFF)
return kDNSServiceErr_Invalid;
-
+
if (make_sure_fits_in(t, 1 + n) < 0)
return kDNSServiceErr_NoMemory;
*(p++) = (uint8_t) n;
t->size ++;
-
+
memcpy(p, key, l);
p += l;
t->size += l;
key_len = strlen(key);
assert(key_len <= 0xFF);
-
+
p = buffer;
i = 0;
/* Key longer than buffer */
if (key_len > size - i - 1)
return NULL;
-
+
if (key_len <= *p &&
strncmp(key, (const char*) p+1, key_len) == 0 &&
(key_len == *p || p[1+key_len] == '=')) {
/* Key matches, so let's return it */
return p;
- }
+ }
/* Skip to next */
i += *p +1;
const uint8_t *p;
size_t n, l;
-
+
AVAHI_WARN_LINKAGE;
assert(key);
if (*key == 0 || strchr(key, '=') || strlen(key) > 0xFF) /* Empty or invalid key */
return NULL;
-
+
assert(buffer);
if (!(p = find_key(buffer, size, key)))
if (n <= 0)
goto fail;
-
+
assert(*p == '=');
p++;
n--;
if (value_len)
*value_len = n;
-
+
return p;
fail:
if (value_len)
*value_len = 0;
-
+
return NULL;
}
if (!size)
return 0;
-
+
assert(buffer);
-
+
p = buffer;
i = 0;
-
+
while (i < size) {
/* Does the item fit in? */
size_t i;
unsigned n = 0;
DNSServiceErrorType ret = kDNSServiceErr_Invalid;
-
+
AVAHI_WARN_LINKAGE;
if (!size)
p = buffer;
i = 0;
-
+
while (i < size) {
/* Does the item fit in? */
strncpy(key, (const char*) p + 1, l);
key[l] = 0;
-
+
if (d) {
if (value_len)
*value_len = *p - l - 1;
if (value_len)
*value_len = 0;
- return ret;
+ return ret;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_GCC_UNUSED void *context) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
AVAHI_GCC_UNUSED void *context) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
AVAHI_GCC_UNUSED const void *rdata) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(AVAHI_GCC_UNUSED DNSServiceRef *sdRef) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
AVAHI_GCC_UNUSED uint32_t ttl) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
AVAHI_GCC_UNUSED DNSServiceFlags flags) {
AVAHI_WARN_UNSUPPORTED;
-
+
return kDNSServiceErr_Unsupported;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
/* Yes, I know, this is not portable. But who cares? It's for
* cosmetics only, anyway. */
-
+
pthread_mutex_lock(&mutex);
if (exe_name[0] == 0) {
int k;
-
+
if ((k = readlink("/proc/self/exe", exe_name, sizeof(exe_name)-1)) < 0)
snprintf(exe_name, sizeof(exe_name), "(unknown)");
else {
char *slash;
-
+
assert((size_t) k <= sizeof(exe_name)-1);
exe_name[k] = 0;
-
+
if ((slash = strrchr(exe_name, '/')))
memmove(exe_name, slash+1, strlen(slash)+1);
}
}
-
+
pthread_mutex_unlock(&mutex);
return exe_name;
char msg[512] = "*** WARNING *** ";
va_list ap;
size_t n;
-
+
assert(fmt);
-
+
va_start(ap, fmt);
n = strlen(msg);
vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
va_end(ap);
-
+
fprintf(stderr, "%s\n", msg);
openlog(avahi_exe_name(), LOG_PID, LOG_USER);
void avahi_warn_linkage(void) {
int w;
-
+
pthread_mutex_lock(&linkage_mutex);
w = linkage_warning;
linkage_warning = 1;
#ifndef foowarnhfoo
#define foowarnhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
util.c util.h \
rr.c rr.h \
hashmap.c hashmap.h \
- domain-util.c domain-util.h
+ domain-util.c domain-util.h \
+ addr-util.c addr-util.h
dns_test_CFLAGS = $(AM_CFLAGS)
dns_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF
};
-
+
assert(a);
if (a->proto != AVAHI_PROTO_INET6)
return memcmp(a->data.ipv6.address, ipv4_in_ipv6, sizeof(ipv4_in_ipv6)) == 0;
}
+#define IPV4LL_NETWORK 0xA9FE0000L
+#define IPV4LL_NETMASK 0xFFFF0000L
+#define IPV6LL_NETWORK 0xFE80
+#define IPV6LL_NETMASK 0xFFC0
+
+int avahi_address_is_link_local(const AvahiAddress *a) {
+ assert(a);
+ if (a->proto == AVAHI_PROTO_INET) {
+ uint32_t n = ntohl(a->data.ipv4.address);
+ return (n & IPV4LL_NETMASK) == IPV4LL_NETWORK;
+ }
+ else if (a->proto == AVAHI_PROTO_INET6) {
+ unsigned n = (a->data.ipv6.address[0] << 8) | (a->data.ipv6.address[1] << 0);
+ return (n & IPV6LL_NETMASK) == IPV6LL_NETWORK;
+ }
+ return 0;
+}
#ifndef fooaddrutilhfoo
#define fooaddrutilhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* encapsulated IPv4 address, returns 1 if yes, 0 otherwise */
int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a);
+/** Check whether the specified address is a link-local IPv4 or IPv6 address;
+ * returns 1 if yes, 0 otherwise */
+int avahi_address_is_link_local(const AvahiAddress *a);
+
AVAHI_C_DECL_END
#endif
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_interface, a->interface->announcers, a);
AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_entry, a->entry->announcers, a);
-
+
avahi_free(a);
}
}
} else {
- if (a->time_event)
+ if (a->time_event)
avahi_time_event_update(a->time_event, tv);
else
a->time_event = avahi_time_event_new(a->server->time_event_queue, tv, elapse_announce, a);
assert(!g->dead);
/* Check whether all group members have been probed */
-
- if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
+
+ if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
return;
avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED);
if (g->dead)
return;
-
+
for (e = g->entries; e; e = e->by_group_next) {
AvahiAnnouncer *a;
-
+
for (a = e->announcers; a; a = a->by_entry_next) {
-
+
if (a->state != AVAHI_WAITING)
continue;
-
+
a->state = AVAHI_ANNOUNCING;
if (immediately) {
/* Shortcut */
-
+
a->n_iteration = 1;
next_state(a);
} else {
assert(a->entry->group);
avahi_s_entry_group_check_probed(a->entry->group, 1);
-
+
} else if (a->state == AVAHI_PROBING) {
if (a->n_iteration >= 4) {
/* Probing done */
-
+
if (a->entry->group) {
assert(a->entry->group->n_probing);
a->entry->group->n_probing--;
}
-
+
if (a->entry->group && a->entry->group->state == AVAHI_ENTRY_GROUP_REGISTERING)
a->state = AVAHI_WAITING;
else {
struct timeval tv;
avahi_interface_post_probe(a->interface, a->entry->record, 0);
-
+
avahi_elapse_time(&tv, AVAHI_PROBE_INTERVAL_MSEC, 0);
set_timeout(a, &tv);
-
+
a->n_iteration++;
}
} else {
struct timeval tv;
avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
-
+
if (a->n_iteration < 10)
a->sec_delay *= 2;
-
+
set_timeout(a, &tv);
}
}
static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
AvahiAnnouncer *a;
-
+
assert(s);
assert(e);
assert(i);
static void go_to_initial_state(AvahiAnnouncer *a) {
AvahiEntry *e;
struct timeval tv;
-
+
assert(a);
e = a->entry;
a->state = AVAHI_ANNOUNCING;
else
a->state = AVAHI_WAITING;
-
+
} else
a->state = AVAHI_ESTABLISHED;
if (a->state == AVAHI_PROBING && e->group)
e->group->n_probing++;
- if (a->state == AVAHI_PROBING)
+ if (a->state == AVAHI_PROBING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC));
- else if (a->state == AVAHI_ANNOUNCING)
+ else if (a->state == AVAHI_ANNOUNCING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC));
else
set_timeout(a, NULL);
/* We don't want duplicate announcers */
if (get_announcer(s, e, i))
- return;
+ return;
if ((!(a = avahi_new(AvahiAnnouncer, 1)))) {
avahi_log_error(__FILE__": Out of memory.");
return;
}
-
+
a->server = s;
a->interface = i;
a->entry = e;
void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) {
AvahiEntry *e;
-
+
assert(s);
assert(i);
static void announce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
AvahiEntry *e = userdata;
-
+
assert(m);
assert(i);
assert(e);
void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g) {
AvahiEntry *e;
-
+
assert(s);
assert(g);
if (!(a = get_announcer(s, e, i)))
return 0;
-
+
return
a->state == AVAHI_ANNOUNCING ||
a->state == AVAHI_ESTABLISHED ||
if (!(a = get_announcer(s, e, i)))
return 0;
-
+
return
a->state == AVAHI_PROBING ||
(a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE));
void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
AvahiAnnouncer *a;
-
+
assert(s);
assert(e);
assert(i);
static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
AvahiRecord *g;
-
+
assert(r);
if (!(g = avahi_record_copy(r)))
return NULL; /* OOM */
-
+
assert(g->ref == 1);
g->ttl = 0;
static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
AvahiEntry *i;
-
+
assert(s);
assert(e);
for (i = avahi_hashmap_lookup(s->entries_by_key, e->record->key); i; i = i->by_key_next) {
- if (i == e)
+ if ((i == e) || (i->dead))
continue;
if (!avahi_record_equal_no_ttl(i->record, e->record))
continue;
-
+
return 1;
}
static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
AvahiEntry *e = userdata;
AvahiRecord *g;
-
+
assert(m);
assert(i);
assert(e);
if (is_duplicate_entry(m->server, e))
return;
-
+
if (!(g = make_goodbye_record(e->record)))
return; /* OOM */
-
+
avahi_interface_post_response(i, g, e->flags & AVAHI_PUBLISH_UNIQUE, NULL, 1);
avahi_record_unref(g);
}
static void reannounce(AvahiAnnouncer *a) {
AvahiEntry *e;
struct timeval tv;
-
+
assert(a);
e = a->entry;
/* Because we might change state we decrease the probing counter first */
if (a->state == AVAHI_PROBING && a->entry->group)
a->entry->group->n_probing--;
-
+
if (a->state == AVAHI_PROBING ||
(a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_NO_PROBE)))
/* We were probing or waiting after probe, so we restart probing from the beginning here */
-
+
a->state = AVAHI_PROBING;
else if (a->state == AVAHI_WAITING)
a->state = AVAHI_WAITING;
else if (e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)
-
+
/* No announcer needed */
a->state = AVAHI_ESTABLISHED;
else {
-
+
/* Ok, let's restart announcing */
a->state = AVAHI_ANNOUNCING;
- }
-
+ }
+
/* Now let's increase the probing counter again */
if (a->state == AVAHI_PROBING && e->group)
e->group->n_probing++;
-
+
a->n_iteration = 1;
a->sec_delay = 1;
if (a->state == AVAHI_PROBING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC));
- else if (a->state == AVAHI_ANNOUNCING)
+ else if (a->state == AVAHI_ANNOUNCING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC));
else
set_timeout(a, NULL);
static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
AvahiEntry *e = userdata;
AvahiAnnouncer *a;
-
+
assert(m);
assert(i);
assert(e);
avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, reannounce_walk_callback, e);
}
-
+
void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye, int remove) {
assert(s);
assert(i);
if (send_goodbye)
if (i->announcing) {
AvahiEntry *e;
-
+
for (e = s->entries; e; e = e->entries_next)
if (!e->dead)
send_goodbye_callback(s->monitor, i, e);
void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int remove) {
assert(s);
assert(e);
-
+
if (send_goodbye)
if (!e->dead)
avahi_interface_monitor_walk(s->monitor, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, send_goodbye_callback, e);
#ifndef fooannouncehfoo
#define fooannouncehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiSimplePoll *simple_poll;
simple_poll = avahi_simple_poll_new();
-
+
avahi_server_config_init(&config);
config.publish_hinfo = 0;
config.publish_addresses = 0;
config.publish_domain = 0;
config.use_ipv6 = 0;
config.enable_reflector = 1;
-
+
server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, NULL, NULL, &error);
avahi_server_config_free(&config);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static void dump_timeout_callback(AvahiTimeout *timeout, void* userdata) {
struct timeval tv;
-
+
AvahiServer *avahi = userdata;
avahi_server_dump(avahi, dump_line, NULL);
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata) {
char *t;
-
+
assert(r);
if (record) {
static void create_entries(int new_name);
static void entry_group_callback(AVAHI_GCC_UNUSED AvahiServer *s, AVAHI_GCC_UNUSED AvahiSEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata) {
- avahi_log_debug("entry group state: %i", state);
+ avahi_log_debug("entry group state: %i", state);
if (state == AVAHI_ENTRY_GROUP_COLLISION) {
remove_entries();
static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) {
server = s;
- avahi_log_debug("server state: %i", state);
-
+ avahi_log_debug("server state: %i", state);
+
if (state == AVAHI_SERVER_RUNNING) {
avahi_log_debug("Server startup complete. Host name is <%s>. Service cookie is %u", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s));
create_entries(0);
remove_entries();
- if (!group)
+ if (!group)
group = avahi_s_entry_group_new(server, entry_group_callback, NULL);
assert(avahi_s_entry_group_is_empty(group));
-
+
if (!service_name)
service_name = avahi_strdup("Test Service");
else if (new_name) {
avahi_free(service_name);
service_name = n;
}
-
+
if (avahi_server_add_service(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, service_name, "_http._tcp", NULL, NULL, 80, "foo", NULL) < 0) {
avahi_log_error("Failed to add HTTP service");
goto fail;
r = avahi_record_new_full("cname.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_CNAME, AVAHI_DEFAULT_TTL);
r->data.cname.name = avahi_strdup("cocaine.local");
-
+
if (avahi_server_add(server, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, r) < 0) {
avahi_record_unref(r);
avahi_log_error("Failed to add CNAME record");
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
+ AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata) {
if (event != AVAHI_RESOLVER_FOUND)
avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain_name, resolver_event_to_string(event));
else {
char t[AVAHI_ADDRESS_STR_MAX], *s;
-
+
avahi_address_snprint(t, sizeof(t), a);
s = avahi_string_list_to_string(txt);
uint16_t port,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata) {
-
+
char t[AVAHI_ADDRESS_STR_MAX] = "n/a";
-
+
if (a)
avahi_address_snprint(t, sizeof(t), a);
simple_poll = avahi_simple_poll_new();
poll_api = avahi_simple_poll_get(simple_poll);
-
+
avahi_server_config_init(&config);
avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]);
server = avahi_server_new(poll_api, &config, server_callback, NULL, &error);
avahi_server_config_free(&config);
-
+
k = avahi_key_new("_http._tcp.0pointer.de", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
r = avahi_s_record_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, k, 0, record_browser_callback, NULL);
avahi_key_unref(k);
avahi_s_dns_server_browser_free(dsb);
if (group)
- avahi_s_entry_group_free(group);
+ avahi_s_entry_group_free(group);
if (server)
avahi_server_free(server);
avahi_simple_poll_free(simple_poll);
avahi_free(service_name);
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiSHostNameResolver *host_name_resolver;
AvahiAddress address;
AvahiLookupResultFlags flags;
-
+
AVAHI_LLIST_FIELDS(AvahiDNSServerInfo, info);
};
struct AvahiSDNSServerBrowser {
AvahiServer *server;
-
+
AvahiSRecordBrowser *record_browser;
AvahiSDNSServerBrowserCallback callback;
void* userdata;
AvahiLookupFlags user_flags;
unsigned n_info;
-
+
AVAHI_LLIST_FIELDS(AvahiSDNSServerBrowser, browser);
AVAHI_LLIST_HEAD(AvahiDNSServerInfo, info);
};
static AvahiDNSServerInfo* get_server_info(AvahiSDNSServerBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r) {
AvahiDNSServerInfo *i;
-
+
assert(b);
assert(r);
avahi_record_unref(i->srv_record);
if (i->host_name_resolver)
avahi_s_host_name_resolver_free(i->host_name_resolver);
-
+
AVAHI_LLIST_REMOVE(AvahiDNSServerInfo, info, b->info, i);
assert(b->n_info >= 1);
b->n_info--;
-
+
avahi_free(i);
}
const AvahiAddress *a,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiDNSServerInfo *i = userdata;
-
+
assert(r);
assert(host_name);
assert(i);
switch (event) {
case AVAHI_RESOLVER_FOUND: {
i->address = *a;
-
+
i->browser->callback(
i->browser,
i->interface,
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSDNSServerBrowser *b = userdata;
assert(rr);
switch (event) {
case AVAHI_BROWSER_NEW: {
AvahiDNSServerInfo *i;
-
+
assert(record);
assert(record->key->type == AVAHI_DNS_TYPE_SRV);
if (get_server_info(b, interface, protocol, record))
return;
-
+
if (b->n_info >= 10)
return;
-
+
if (!(i = avahi_new(AvahiDNSServerInfo, 1)))
return; /* OOM */
-
+
i->browser = b;
i->interface = interface;
i->protocol = protocol;
b->user_flags,
host_name_resolver_callback, i);
i->flags = flags;
-
+
AVAHI_LLIST_PREPEND(AvahiDNSServerInfo, info, b->info, i);
-
+
b->n_info++;
break;
}
case AVAHI_BROWSER_REMOVE: {
AvahiDNSServerInfo *i;
-
+
assert(record);
assert(record->key->type == AVAHI_DNS_TYPE_SRV);
if (!(i = get_server_info(b, interface, protocol, record)))
return;
-
+
if (!i->host_name_resolver)
b->callback(
b,
i->srv_record->data.srv.port,
i->flags | flags,
b->userdata);
-
+
server_info_free(b, i);
break;
}
0,
flags,
b->userdata);
-
+
break;
}
}
"_domain._udp",
"_dns-update._udp"
};
-
+
AvahiSDNSServerBrowser *b;
AvahiKey *k = NULL;
char n[AVAHI_DOMAIN_NAME_MAX];
int r;
-
+
assert(server);
assert(callback);
avahi_server_set_errno(server, r);
return NULL;
}
-
+
if (!(b = avahi_new(AvahiSDNSServerBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
b->server = server;
b->callback = callback;
b->userdata = userdata;
AVAHI_LLIST_HEAD_INIT(AvahiDNSServerInfo, b->info);
AVAHI_LLIST_PREPEND(AvahiSDNSServerBrowser, browser, server->dns_server_browsers, b);
-
+
if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
goto fail;
-
+
avahi_key_unref(k);
return b;
if (k)
avahi_key_unref(k);
-
+
avahi_s_dns_server_browser_free(b);
return NULL;
}
while (b->info)
server_info_free(b, b->info);
-
+
AVAHI_LLIST_REMOVE(AvahiSDNSServerBrowser, browser, b->server->dns_server_browsers, b);
if (b->record_browser)
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiSDomainBrowser {
int ref;
-
+
AvahiServer *server;
-
+
AvahiSRecordBrowser *record_browser;
AvahiDomainBrowserType type;
AvahiTimeEvent *defer_event;
int all_for_now_scheduled;
-
+
AVAHI_LLIST_FIELDS(AvahiSDomainBrowser, browser);
};
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSDomainBrowser *b = userdata;
char *n = NULL;
b->all_for_now_scheduled = 1;
return;
}
-
+
/* Filter flags */
flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
AvahiStringList *l;
/* Filter out entries defined statically */
-
+
for (l = b->server->config.browse_domains; l; l = l->next)
if (avahi_domain_equal((char*) l->text, n))
return;
}
-
+
}
-
+
b->callback(b, interface, protocol, event, n, flags, b->userdata);
}
static void defer_callback(AvahiTimeEvent *e, void *userdata) {
AvahiSDomainBrowser *b = userdata;
AvahiStringList *l;
-
+
assert(e);
assert(b);
inc_ref(b);
for (l = b->server->config.browse_domains; l; l = l->next) {
-
+
/* Check whether this object still exists outside our own
* stack frame */
if (b->ref <= 1)
break;
-
+
b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_NEW, (char*) l->text, AVAHI_LOOKUP_RESULT_STATIC, b->userdata);
}
if (b->ref > 1) {
/* If the ALL_FOR_NOW event has already been scheduled, execute it now */
-
- if (b->all_for_now_scheduled)
+
+ if (b->all_for_now_scheduled)
b->callback(b, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_BROWSER_ALL_FOR_NOW, NULL, 0, b->userdata);
}
-
+
/* Decrease ref counter */
avahi_s_domain_browser_free(b);
}
"dr",
"lb"
};
-
+
AvahiSDomainBrowser *b;
AvahiKey *k = NULL;
char n[AVAHI_DOMAIN_NAME_MAX];
int r;
-
+
assert(server);
assert(callback);
avahi_server_set_errno(server, r);
return NULL;
}
-
+
if (!(b = avahi_new(AvahiSDomainBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
goto fail;
-
+
avahi_key_unref(k);
if (type == AVAHI_DOMAIN_BROWSER_BROWSE && b->server->config.browse_domains)
b->defer_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
-
+
return b;
-
+
fail:
-
+
if (k)
avahi_key_unref(k);
-
+
avahi_s_domain_browser_free(b);
-
+
return NULL;
}
assert(b->ref >= 1);
if (--b->ref > 0)
return;
-
+
AVAHI_LLIST_REMOVE(AvahiSDomainBrowser, browser, b->server->domain_browsers, b);
if (b->record_browser)
if (b->defer_event)
avahi_time_event_free(b->defer_event);
-
+
avahi_free(b);
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSServiceTypeBrowser *b = userdata;
assert(rr);
if (record) {
char type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
-
+
assert(record->key->type == AVAHI_DNS_TYPE_PTR);
if (avahi_service_name_split(record->data.ptr.name, NULL, 0, type, sizeof(type), domain, sizeof(domain)) < 0) {
AvahiLookupFlags flags,
AvahiSServiceTypeBrowserCallback callback,
void* userdata) {
-
+
AvahiSServiceTypeBrowser *b;
AvahiKey *k = NULL;
char n[AVAHI_DOMAIN_NAME_MAX];
int r;
-
+
assert(server);
assert(callback);
avahi_server_set_errno(server, r);
return NULL;
}
-
+
if (!(b = avahi_new(AvahiSServiceTypeBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
b->server = server;
b->callback = callback;
b->userdata = userdata;
b->record_browser = NULL;
-
+
AVAHI_LLIST_PREPEND(AvahiSServiceTypeBrowser, browser, server->service_type_browsers, b);
if (!(b->domain_name = avahi_normalize_name_strdup(domain))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
goto fail;
-
+
avahi_key_unref(k);
return b;
avahi_key_unref(k);
avahi_s_service_type_browser_free(b);
-
+
return NULL;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiServer *server;
char *domain_name;
char *service_type;
-
+
AvahiSRecordBrowser *record_browser;
AvahiSServiceBrowserCallback callback;
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSServiceBrowser *b = userdata;
assert(rr);
/* Filter flags */
flags &= AVAHI_LOOKUP_RESULT_CACHED | AVAHI_LOOKUP_RESULT_MULTICAST | AVAHI_LOOKUP_RESULT_WIDE_AREA;
-
+
if (record) {
char service[AVAHI_LABEL_MAX], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
}
b->callback(b, interface, protocol, event, service, type, domain, flags, b->userdata);
-
+
} else
b->callback(b, interface, protocol, event, NULL, b->service_type, b->domain_name, flags, b->userdata);
AvahiKey *k = NULL;
char n[AVAHI_DOMAIN_NAME_MAX];
int r;
-
+
assert(server);
assert(callback);
assert(service_type);
avahi_server_set_errno(server, r);
return NULL;
}
-
+
if (!(b = avahi_new(AvahiSServiceBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
b->server = server;
b->domain_name = b->service_type = NULL;
b->callback = callback;
b->userdata = userdata;
b->record_browser = NULL;
-
+
AVAHI_LLIST_PREPEND(AvahiSServiceBrowser, browser, server->service_browsers, b);
if (!(b->domain_name = avahi_normalize_name_strdup(domain)) ||
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
goto fail;
if (k)
avahi_key_unref(k);
-
+
avahi_s_service_browser_free(b);
return NULL;
}
if (b->record_browser)
avahi_s_record_browser_free(b->record_browser);
-
+
avahi_free(b->domain_name);
avahi_free(b->service_type);
avahi_free(b);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiSRBLookup {
AvahiSRecordBrowser *record_browser;
-
+
unsigned ref;
AvahiIfIndex interface;
AvahiProtocol protocol;
AvahiLookupFlags flags;
-
+
AvahiKey *key;
AvahiWideAreaLookup *wide_area;
AvahiMulticastLookup *multicast;
AvahiRList *cname_lookups;
-
+
AVAHI_LLIST_FIELDS(AvahiSRBLookup, lookups);
};
AvahiKey *key) {
AvahiSRBLookup *l;
-
+
assert(b);
assert(AVAHI_IF_VALID(interface));
assert(AVAHI_PROTO_VALID(protocol));
if (b->n_lookups >= AVAHI_LOOKUPS_PER_BROWSER_MAX)
/* We don't like cyclic CNAMEs */
return NULL;
-
+
if (!(l = avahi_new(AvahiSRBLookup, 1)))
return NULL;
-
+
l->ref = 1;
l->record_browser = b;
l->interface = interface;
l->flags = flags;
transport_flags_from_domain(b->server, &l->flags, key->name);
-
+
AVAHI_LLIST_PREPEND(AvahiSRBLookup, lookups, b->lookups, l);
b->n_lookups ++;
-
+
return l;
}
avahi_wide_area_lookup_free(l->wide_area);
l->wide_area = NULL;
}
-
+
if (l->multicast) {
avahi_multicast_lookup_free(l->multicast);
l->multicast = NULL;
lookup_unref(l->cname_lookups->data);
l->cname_lookups = avahi_rlist_remove_by_link(l->cname_lookups, l->cname_lookups);
}
-
+
avahi_key_unref(l->key);
avahi_free(l);
}
AvahiProtocol protocol,
AvahiLookupFlags flags,
AvahiKey *key) {
-
+
AvahiSRBLookup *l;
-
+
assert(b);
for (l = b->lookups; l; l = l->lookups_next) {
AvahiLookupResultFlags flags,
AvahiRecord *r,
void *userdata) {
-
+
AvahiSRBLookup *l = userdata;
AvahiSRecordBrowser *b;
return;
lookup_ref(l);
-
+
switch (event) {
case AVAHI_BROWSER_NEW:
assert(r);
-
+
if (r->key->clazz == AVAHI_DNS_CLASS_IN &&
r->key->type == AVAHI_DNS_TYPE_CNAME)
/* It's a CNAME record, so let's follow it. We only follow it on wide area DNS! */
AvahiSRBLookup *l = userdata;
AvahiSRecordBrowser *b;
-
+
assert(e);
assert(l);
return;
lookup_ref(l);
-
+
switch (event) {
case AVAHI_BROWSER_NEW:
assert(r);
-
+
if (r->key->clazz == AVAHI_DNS_CLASS_IN &&
r->key->type == AVAHI_DNS_TYPE_CNAME)
/* It's a CNAME record, so let's follow it. We allow browsing on both multicast and wide area. */
if (avahi_server_is_record_local(b->server, interface, protocol, r))
flags |= AVAHI_LOOKUP_RESULT_LOCAL;
-
+
b->callback(b, interface, protocol, event, r, flags, b->userdata);
}
break;
assert(!(l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) != !(l->flags & AVAHI_LOOKUP_USE_MULTICAST));
assert(!l->wide_area && !l->multicast);
-
+
if (l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) {
if (!(l->wide_area = avahi_wide_area_lookup_new(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l)))
return -1;
-
+
} else {
assert(l->flags & AVAHI_LOOKUP_USE_MULTICAST);
static int lookup_scan_cache(AvahiSRBLookup *l) {
int n = 0;
-
+
assert(l);
assert(!(l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) != !(l->flags & AVAHI_LOOKUP_USE_MULTICAST));
-
+
if (l->flags & AVAHI_LOOKUP_USE_WIDE_AREA) {
n = (int) avahi_wide_area_scan_cache(l->record_browser->server->wide_area_lookup_engine, l->key, lookup_wide_area_callback, l);
-
+
} else {
assert(l->flags & AVAHI_LOOKUP_USE_MULTICAST);
n = (int) avahi_multicast_lookup_engine_scan_cache(l->record_browser->server->multicast_lookup_engine, l->interface, l->protocol, l->key, lookup_multicast_callback, l);
static AvahiSRBLookup* lookup_add(AvahiSRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiKey *key) {
AvahiSRBLookup *l;
-
+
assert(b);
assert(!b->dead);
if (l->record_browser->dead)
return 0;
-
+
lookup_ref(l);
-
+
/* Browse the cache for the root request */
n = lookup_scan_cache(l);
if ((l->flags & AVAHI_LOOKUP_USE_MULTICAST) || n == 0)
/* We do no start a query if the cache contained entries and we're on wide area */
-
+
if (lookup_start(l) < 0)
n = -1;
}
static void lookup_handle_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r) {
AvahiKey *k;
AvahiSRBLookup *n;
-
+
assert(l);
assert(r);
assert(r->key->type == AVAHI_DNS_TYPE_CNAME);
k = avahi_key_new(r->data.ptr.name, l->record_browser->key->clazz, l->record_browser->key->type);
- n = lookup_add(l->record_browser, interface, protocol, flags, k);
+ n = lookup_add(l->record_browser, interface, protocol, flags, k);
avahi_key_unref(k);
if (!n) {
avahi_key_equal(n->key, k))
break;
}
-
+
avahi_key_unref(k);
if (rl) {
b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL,
b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
b->userdata);
-
+
browser_cancel(b);
return;
}
-
+
/* Tell the client that we're done with the cache */
b->callback(
b, b->interface, b->protocol, AVAHI_BROWSER_CACHE_EXHAUSTED, NULL,
/* If we do wide area lookups and the the cache contained
* entries, we assume that it is complete, and tell the user
* so by firing ALL_FOR_NOW. */
-
+
b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_ALL_FOR_NOW, NULL, AVAHI_LOOKUP_RESULT_WIDE_AREA, b->userdata);
}
}
AvahiLookupFlags flags,
AvahiSRecordBrowserCallback callback,
void* userdata) {
-
+
AvahiSRecordBrowser *b;
assert(server);
AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !avahi_key_is_pattern(key), AVAHI_ERR_IS_PATTERN);
AVAHI_CHECK_VALIDITY_RETURN_NULL(server, avahi_key_is_valid(key), AVAHI_ERR_INVALID_KEY);
AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
- AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !(flags & AVAHI_LOOKUP_USE_WIDE_AREA) || !(flags & AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !(flags & AVAHI_LOOKUP_USE_WIDE_AREA) || !(flags & AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+
if (!(b = avahi_new(AvahiSRecordBrowser, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
b->dead = 0;
b->server = server;
b->interface = interface;
b->n_lookups = 0;
AVAHI_LLIST_HEAD_INIT(AvahiSRBLookup, b->lookups);
b->root_lookup = NULL;
-
+
AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, browser, server->record_browsers, b);
/* The currently cached entries are scanned a bit later, and than we will start querying, too */
b->defer_time_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
assert(b->defer_time_event);
-
+
return b;
}
assert(b);
browser_cancel(b);
-
+
AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b);
avahi_key_unref(b->key);
-
+
avahi_free(b);
}
void avahi_browser_cleanup(AvahiServer *server) {
AvahiSRecordBrowser *b;
AvahiSRecordBrowser *n;
-
+
assert(server);
while (server->need_browser_cleanup) {
server->need_browser_cleanup = 0;
-
+
for (b = server->record_browsers; b; b = n) {
n = b->browser_next;
-
+
if (b->dead)
avahi_s_record_browser_destroy(b);
}
- }
+ }
if (server->wide_area_lookup_engine)
avahi_wide_area_cleanup(server->wide_area_lookup_engine);
#ifndef foobrowsehfoo
#define foobrowsehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiIfIndex interface;
AvahiProtocol protocol;
AvahiLookupFlags flags;
-
+
AvahiTimeEvent *defer_time_event;
AvahiSRecordBrowserCallback callback;
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include "log.h"
#include "rr-util.h"
-#define AVAHI_CACHE_ENTRIES_MAX 500
-
static void remove_entry(AvahiCache *c, AvahiCacheEntry *e) {
AvahiCacheEntry *t;
/* Remove from linked list */
AVAHI_LLIST_REMOVE(AvahiCacheEntry, entry, c->entries, e);
-
+
if (e->time_event)
avahi_time_event_free(e->time_event);
avahi_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, AVAHI_BROWSER_REMOVE);
-
+
avahi_record_unref(e->record);
-
+
avahi_free(e);
- assert(c->n_entries-- >= 1);
+ assert(c->n_entries >= 1);
+ --c->n_entries;
}
AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *iface) {
avahi_log_error(__FILE__": Out of memory.");
return NULL; /* OOM */
}
-
+
c->server = server;
c->interface = iface;
c->n_entries = 0;
c->last_rand_timestamp = 0;
-
+
return c;
}
while (c->entries)
remove_entry(c, c->entries);
assert(c->n_entries == 0);
-
+
avahi_hashmap_free(c->hashmap);
-
+
avahi_free(c);
}
assert(k);
assert(!avahi_key_is_pattern(k));
-
+
return avahi_hashmap_lookup(c->hashmap, k);
}
void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, void* userdata) {
void* ret;
-
+
assert(c);
assert(pattern);
assert(cb);
-
+
if (avahi_key_is_pattern(pattern)) {
AvahiCacheEntry *e, *n;
-
+
for (e = c->entries; e; e = n) {
n = e->entry_next;
-
+
if (avahi_key_pattern_match(pattern, e->record->key))
if ((ret = cb(c, pattern, e, userdata)))
return ret;
}
-
+
} else {
AvahiCacheEntry *e, *n;
for (e = lookup_key(c, pattern); e; e = n) {
n = e->by_key_next;
-
+
if ((ret = cb(c, pattern, e, userdata)))
return ret;
}
AvahiCacheEntry *e = userdata;
/* char *txt; */
unsigned percent = 0;
-
+
assert(t);
assert(e);
case AVAHI_CACHE_REPLACE_FINAL:
remove_entry(e->cache, e);
-
+
e = NULL;
/* avahi_log_debug("Removing entry from cache due to expiration (%s)", txt); */
break;
-
+
case AVAHI_CACHE_VALID:
case AVAHI_CACHE_POOF:
e->state = AVAHI_CACHE_EXPIRY1;
percent = 85;
break;
-
+
case AVAHI_CACHE_EXPIRY1:
e->state = AVAHI_CACHE_EXPIRY2;
percent = 90;
e->state = AVAHI_CACHE_EXPIRY3;
percent = 95;
break;
-
+
case AVAHI_CACHE_EXPIRY3:
e->state = AVAHI_CACHE_EXPIRY_FINAL;
percent = 100;
/* Request a cache update if we are subscribed to this entry */
if (avahi_querier_shall_refresh_cache(e->cache->interface, e->record->key))
avahi_interface_post_query(e->cache->interface, e->record->key, 0, NULL);
-
+
/* Check again later */
next_expiry(e->cache, e, percent);
-
+
}
/* avahi_free(txt); */
static void update_time_event(AvahiCache *c, AvahiCacheEntry *e) {
assert(c);
assert(e);
-
+
if (e->time_event)
avahi_time_event_update(e->time_event, &e->expiry);
else
static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, unsigned percent) {
AvahiUsec usec, left, right;
time_t now;
-
+
assert(c);
assert(e);
assert(percent > 0 && percent <= 100);
-
+
usec = (AvahiUsec) e->record->ttl * 10000;
left = usec * percent;
}
usec = left + (AvahiUsec) ((double) (right-left) * c->last_rand / (RAND_MAX+1.0));
-
+
e->expiry = e->timestamp;
avahi_timeval_add(&e->expiry, usec);
-
+
/* g_message("wake up in +%lu seconds", e->expiry.tv_sec - e->timestamp.tv_sec); */
-
+
update_time_event(c, e);
}
static void expire_in_one_second(AvahiCache *c, AvahiCacheEntry *e, AvahiCacheEntryState state) {
assert(c);
assert(e);
-
+
e->state = state;
gettimeofday(&e->expiry, NULL);
avahi_timeval_add(&e->expiry, 1000000); /* 1s */
void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const AvahiAddress *a) {
/* char *txt; */
-
+
assert(c);
assert(r && r->ref >= 1);
/* This is an update request */
if ((first = lookup_key(c, r->key))) {
-
+
if (cache_flush) {
/* For unique entries drop all entries older than one second */
expire_in_one_second(c, e, AVAHI_CACHE_REPLACE_FINAL);
}
}
-
+
/* Look for exactly the same entry */
for (e = first; e; e = e->by_key_next)
if (avahi_record_equal_no_ttl(e->record, r))
break;
}
-
+
if (e) {
-
+
/* avahi_log_debug("found matching cache entry"); */
/* We need to update the hash table key if we replace the
* record */
if (e->by_key_prev == NULL)
avahi_hashmap_replace(c->hashmap, r->key, e);
-
+
/* Update the record */
avahi_record_unref(e->record);
e->record = avahi_record_ref(r);
/* avahi_log_debug("cache: updating %s", txt); */
-
+
} else {
/* No entry found, therefore we create a new one */
-
+
/* avahi_log_debug("cache: couldn't find matching cache entry for %s", txt); */
- if (c->n_entries >= AVAHI_CACHE_ENTRIES_MAX)
+ if (c->n_entries >= c->server->config.n_cache_entries_max)
return;
if (!(e = avahi_new(AvahiCacheEntry, 1))) {
/* Notify subscribers */
avahi_multicast_lookup_engine_notify(c->server->multicast_lookup_engine, c->interface, e->record, AVAHI_BROWSER_NEW);
- }
-
+ }
+
e->origin = *a;
e->timestamp = now;
next_expiry(c, e, 80);
if (!(t = avahi_record_to_string(e->record)))
continue; /* OOM */
-
+
dump_data->callback(t, dump_data->userdata);
avahi_free(t);
}
int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) {
struct timeval now;
unsigned age;
-
+
assert(c);
assert(e);
age = (unsigned) (avahi_timeval_diff(&now, &e->timestamp)/1000000);
/* avahi_log_debug("age: %lli, ttl/2: %u", age, e->record->ttl); */
-
+
return age >= e->record->ttl/2;
}
default:
;
}
-
+
return NULL;
}
next_expiry(c, e, 80);
}
}
-
-
-
#ifndef foocachehfoo
#define foocachehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct timeval expiry;
int cache_flush;
int poof_num;
-
+
AvahiAddress origin;
AvahiCacheEntryState state;
struct AvahiCache {
AvahiServer *server;
-
+
AvahiInterface *interface;
-
+
AvahiHashmap *hashmap;
AVAHI_LLIST_HEAD(AvahiCacheEntry, entries);
* records of the specified key. The specified address is */
void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a);
-/* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */
+/* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */
void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a);
void avahi_cache_flush(AvahiCache *c);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static void dump_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void* userdata) {
struct timeval tv;
-
+
avahi_server_dump(avahi, dump_line, NULL);
avahi_elapse_time(&tv, 5000, 0);
avahi_s_entry_group_reset(group);
else
group = avahi_s_entry_group_new(avahi, entry_group_callback, NULL);
-
- avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
+
+ avahi_server_add_service(avahi, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, 80, "foo", NULL);
avahi_s_entry_group_commit(group);
try++;
static void rename_timeout_callback(AvahiTimeout *timeout, AVAHI_GCC_UNUSED void *userdata) {
struct timeval tv;
-
- if (access("flag", F_OK) == 0) {
+
+ if (access("flag", F_OK) == 0) {
create_service("New - Bonjour Service Name");
return;
}
avahi_server_dump(avahi, dump_line, NULL);
} else if (state == AVAHI_SERVER_COLLISION) {
char *n;
-
+
n = avahi_alternative_host_name(avahi_server_get_host_name(s));
avahi_log_warn("Host name conflict, retrying with <%s>", n);
avahi_server_set_host_name(s, n);
/* Evil, but the conformace test requires that*/
create_service("gurke");
-
+
avahi_simple_poll_loop(simple_poll);
-
+
if (group)
- avahi_s_entry_group_free(group);
+ avahi_s_entry_group_free(group);
avahi_server_free(avahi);
avahi_simple_poll_free(simple_poll);
-
+
return 0;
}
#ifndef foocorehfoo
#define foocorehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int allow_point_to_point; /**< Enable publishing on POINTOPOINT interfaces */
int publish_a_on_ipv6; /**< Publish an IPv4 A RR on IPv6 sockets */
int publish_aaaa_on_ipv4; /**< Publish an IPv4 A RR on IPv6 sockets */
+ unsigned n_cache_entries_max; /**< Maximum number of cache entries per interface */
} AvahiServerConfig;
/** Allocate a new mDNS responder object. */
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foodnssrvhfoo
#define foodnssrvhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiProtocol protocol,
const char *domain,
AvahiDNSServerType type,
- AvahiProtocol aprotocol, /**< Address protocol for the DNS server */
+ AvahiProtocol aprotocol, /**< Address protocol for the DNS server */
AvahiLookupFlags flags, /**< Lookup flags. */
AvahiSDNSServerBrowserCallback callback,
void* userdata);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
avahi_log_debug(">%s<", t);
assert(avahi_domain_equal(a, t));
-
+
assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
avahi_log_debug(">%s<", t);
assert(avahi_domain_equal(b, t));
assert(avahi_dns_packet_consume_name(p, t, sizeof(t)) == 0);
avahi_log_debug(">%s<", t);
assert(avahi_domain_equal(d, t));
-
+
avahi_dns_packet_free(p);
/* RDATA PARSING AND SERIALIZATION */
-
+
/* Create an AvahiRecord with some usful data */
r = avahi_record_new_full("foobar.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, AVAHI_DEFAULT_TTL);
assert(r);
avahi_free(m);
avahi_record_unref(r);
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (max_size < AVAHI_DNS_PACKET_HEADER_SIZE)
max_size = AVAHI_DNS_PACKET_HEADER_SIZE;
-
+
if (!(p = avahi_malloc(sizeof(AvahiDnsPacket) + max_size)))
return p;
-
+
p->size = p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE;
p->max_size = max_size;
p->name_table = NULL;
if (!(p = avahi_dns_packet_new(mtu)))
return NULL;
-
+
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
return p;
}
if (!(p = avahi_dns_packet_new(mtu)))
return NULL;
-
+
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(1, 0, aa, 0, 0, 0, 0, 0, 0, 0));
return p;
}
saved_rindex = p->rindex;
p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE;
-
+
for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); n > 0; n--) {
AvahiKey *k;
int unicast_response;
(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_OPCODE));
return r;
-}
+}
void avahi_dns_packet_free(AvahiDnsPacket *p) {
if (p->name_table)
avahi_hashmap_free(p->name_table);
-
+
avahi_free(p);
}
void avahi_dns_packet_set_field(AvahiDnsPacket *p, unsigned idx, uint16_t v) {
assert(p);
assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE);
-
+
((uint16_t*) AVAHI_DNS_PACKET_DATA(p))[idx] = htons(v);
}
assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE);
avahi_dns_packet_set_field(p, idx, avahi_dns_packet_get_field(p, idx) + 1);
-}
+}
static void name_table_cleanup(void *key, void *value, void *user_data) {
AvahiDnsPacket *p = user_data;
-
+
if ((uint8_t*) value >= AVAHI_DNS_PACKET_DATA(p) + p->size)
avahi_hashmap_remove(p->name_table, key);
}
uint8_t* avahi_dns_packet_append_name(AvahiDnsPacket *p, const char *name) {
uint8_t *d, *saved_ptr = NULL;
size_t saved_size;
-
+
assert(p);
assert(name);
saved_size = p->size;
saved_ptr = avahi_dns_packet_extend(p, 0);
-
+
while (*name) {
uint8_t* prev;
const char *pname;
char label[64], *u;
-
+
/* Check whether we can compress this name. */
if (p->name_table && (prev = avahi_hashmap_lookup(p->name_table, name))) {
unsigned idx;
-
+
assert(prev >= AVAHI_DNS_PACKET_DATA(p));
idx = (unsigned) (prev - AVAHI_DNS_PACKET_DATA(p));
}
pname = name;
-
+
if (!(avahi_unescape_label(&name, label, sizeof(label))))
goto fail;
if (!(d = avahi_dns_packet_extend(p, 1)))
goto fail;
-
+
*d = 0;
return saved_ptr;
uint8_t* avahi_dns_packet_append_uint16(AvahiDnsPacket *p, uint16_t v) {
uint8_t *d;
assert(p);
-
+
if (!(d = avahi_dns_packet_extend(p, sizeof(uint16_t))))
return NULL;
-
+
d[0] = (uint8_t) (v >> 8);
d[1] = (uint8_t) v;
return d;
if (!(d = avahi_dns_packet_extend(p, sizeof(uint32_t))))
return NULL;
-
+
d[0] = (uint8_t) (v >> 24);
d[1] = (uint8_t) (v >> 16);
d[2] = (uint8_t) (v >> 8);
uint8_t* avahi_dns_packet_append_string(AvahiDnsPacket *p, const char *s) {
uint8_t* d;
size_t k;
-
+
assert(p);
assert(s);
if ((k = strlen(s)) >= 255)
k = 255;
-
+
if (!(d = avahi_dns_packet_extend(p, k+1)))
return NULL;
uint8_t *avahi_dns_packet_extend(AvahiDnsPacket *p, size_t l) {
uint8_t *d;
-
+
assert(p);
if (p->size+l > p->max_size)
return NULL;
-
+
d = AVAHI_DNS_PACKET_DATA(p) + p->size;
p->size += l;
-
+
return d;
}
return -1;
flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS);
-
+
if (flags & AVAHI_DNS_FLAG_OPCODE)
return -1;
if (avahi_dns_packet_check_valid(p) < 0)
return -1;
-
+
flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS);
-
+
if (flags & AVAHI_DNS_FLAG_RCODE)
return -1;
int avahi_dns_packet_is_query(AvahiDnsPacket *p) {
assert(p);
-
+
return !(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_QR);
}
unsigned label_ptr;
int i;
assert(p && ret_name && l);
-
+
for (i = 0; i < AVAHI_DNS_LABELS_MAX; i++) {
uint8_t n;
if (l < 1)
return -1;
*ret_name = 0;
-
+
return ret;
-
+
} else if (n <= 63) {
/* Uncompressed label */
idx++;
if (!compressed)
ret++;
-
+
if (idx + n > p->size)
return -1;
return -1;
idx += n;
-
+
if (!compressed)
ret += n;
} else if ((n & 0xC0) == 0xC0) {
if (!compressed)
ret += 2;
-
+
compressed = 1;
} else
return -1;
int avahi_dns_packet_consume_name(AvahiDnsPacket *p, char *ret_name, size_t l) {
int r;
-
+
if ((r = consume_labels(p, p->rindex, ret_name, l)) < 0)
return -1;
d = (uint8_t*) (AVAHI_DNS_PACKET_DATA(p) + p->rindex);
*ret_v = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
p->rindex += sizeof(uint32_t);
-
+
return 0;
}
assert(p);
assert(ret_data);
assert(l > 0);
-
+
if (p->rindex + l > p->size)
return -1;
int avahi_dns_packet_consume_string(AvahiDnsPacket *p, char *ret_string, size_t l) {
size_t k;
-
+
assert(p);
assert(ret_string);
assert(l > 0);
memcpy(ret_string, AVAHI_DNS_PACKET_DATA(p)+p->rindex+1, l-1);
ret_string[l-1] = 0;
-
+
p->rindex += 1+k;
return 0;
const void* avahi_dns_packet_get_rptr(AvahiDnsPacket *p) {
assert(p);
-
+
if (p->rindex > p->size)
return NULL;
static int parse_rdata(AvahiDnsPacket *p, AvahiRecord *r, uint16_t rdlength) {
char buf[AVAHI_DOMAIN_NAME_MAX];
const void* start;
-
+
assert(p);
assert(r);
start = avahi_dns_packet_get_rptr(p);
-
+
switch (r->key->type) {
case AVAHI_DNS_TYPE_PTR:
case AVAHI_DNS_TYPE_CNAME:
case AVAHI_DNS_TYPE_NS:
-
+
if (avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
return -1;
r->data.ptr.name = avahi_strdup(buf);
break;
-
+
case AVAHI_DNS_TYPE_SRV:
-
+
if (avahi_dns_packet_consume_uint16(p, &r->data.srv.priority) < 0 ||
avahi_dns_packet_consume_uint16(p, &r->data.srv.weight) < 0 ||
avahi_dns_packet_consume_uint16(p, &r->data.srv.port) < 0 ||
avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
return -1;
-
+
r->data.srv.name = avahi_strdup(buf);
break;
if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
return -1;
-
+
r->data.hinfo.cpu = avahi_strdup(buf);
-
+
if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
return -1;
-
+
r->data.hinfo.os = avahi_strdup(buf);
break;
if (rdlength > 0) {
if (avahi_string_list_parse(avahi_dns_packet_get_rptr(p), rdlength, &r->data.txt.string_list) < 0)
return -1;
-
+
if (avahi_dns_packet_skip(p, rdlength) < 0)
return -1;
} else
r->data.txt.string_list = NULL;
-
+
break;
case AVAHI_DNS_TYPE_A:
if (avahi_dns_packet_consume_bytes(p, &r->data.a.address, sizeof(AvahiIPv4Address)) < 0)
return -1;
-
+
break;
case AVAHI_DNS_TYPE_AAAA:
/* avahi_log_debug("aaaa"); */
-
+
if (avahi_dns_packet_consume_bytes(p, &r->data.aaaa.address, sizeof(AvahiIPv6Address)) < 0)
return -1;
-
+
break;
-
+
default:
/* avahi_log_debug("generic"); */
-
+
if (rdlength > 0) {
r->data.generic.data = avahi_memdup(avahi_dns_packet_get_rptr(p), rdlength);
- r->data.generic.size = rdlength;
-
+ r->data.generic.size = rdlength;
+
if (avahi_dns_packet_skip(p, rdlength) < 0)
return -1;
}
/* Check if we read enough data */
if ((const uint8_t*) avahi_dns_packet_get_rptr(p) - (const uint8_t*) start != rdlength)
return -1;
-
+
return 0;
}
if (ret_cache_flush)
*ret_cache_flush = !!(class & AVAHI_DNS_CACHE_FLUSH);
class &= ~AVAHI_DNS_CACHE_FLUSH;
-
+
if (!(r = avahi_record_new_full(name, class, type, ttl)))
goto fail;
-
+
if (parse_rdata(p, r, rdlength) < 0)
goto fail;
if (!avahi_record_is_valid(r))
goto fail;
-
+
return r;
fail:
*ret_unicast_response = !!(class & AVAHI_DNS_UNICAST_RESPONSE);
class &= ~AVAHI_DNS_UNICAST_RESPONSE;
-
+
if (!(k = avahi_key_new(name, class, type)))
return NULL;
uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast_response) {
uint8_t *t;
size_t size;
-
+
assert(p);
assert(k);
size = p->size;
-
+
if (!(t = avahi_dns_packet_append_name(p, k->name)) ||
!avahi_dns_packet_append_uint16(p, k->type) ||
!avahi_dns_packet_append_uint16(p, k->clazz | (unicast_response ? AVAHI_DNS_UNICAST_RESPONSE : 0))) {
static int append_rdata(AvahiDnsPacket *p, AvahiRecord *r) {
assert(p);
assert(r);
-
+
switch (r->key->type) {
-
+
case AVAHI_DNS_TYPE_PTR:
case AVAHI_DNS_TYPE_CNAME:
case AVAHI_DNS_TYPE_NS:
-
+
if (!(avahi_dns_packet_append_name(p, r->data.ptr.name)))
return -1;
-
+
break;
case AVAHI_DNS_TYPE_SRV:
if (!avahi_dns_packet_append_bytes(p, &r->data.a.address, sizeof(r->data.a.address)))
return -1;
-
+
break;
case AVAHI_DNS_TYPE_AAAA:
-
+
if (!avahi_dns_packet_append_bytes(p, &r->data.aaaa.address, sizeof(r->data.aaaa.address)))
return -1;
-
+
break;
-
+
default:
if (r->data.generic.size)
if (append_rdata(p, r) < 0)
goto fail;
-
+
size = avahi_dns_packet_extend(p, 0) - start;
assert(size <= AVAHI_DNS_RDATA_MAX);
l[0] = (uint8_t) ((uint16_t) size >> 8);
l[1] = (uint8_t) ((uint16_t) size);
-
+
return t;
assert(p);
assert(p->size <= p->max_size);
-
+
return p->max_size - p->size;
}
int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) {
int ret;
AvahiDnsPacket p;
-
+
assert(record);
assert(rdata);
-
+
p.data = (void*) rdata;
p.max_size = p.size = size;
p.rindex = 0;
ret = parse_rdata(&p, record, size);
assert(!p.name_table);
-
+
return ret;
}
size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size) {
int ret;
AvahiDnsPacket p;
-
+
assert(record);
assert(rdata);
assert(max_size > 0);
if (ret < 0)
return (size_t) -1;
-
+
return p.size;
}
#ifndef foodnshfoo
#define foodnshfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
char *p, *d;
s[strcspn(s, ".")] = 0;
-
- for (p = s, d = s; *p; p++)
+
+ for (p = s, d = s; *p; p++)
if ((*p >= 'a' && *p <= 'z') ||
(*p >= 'A' && *p <= 'Z') ||
(*p >= '0' && *p <= '9') ||
#ifdef __linux__
static int load_lsb_distrib_id(char *ret_s, size_t size) {
FILE *f;
-
+
assert(ret_s);
assert(size > 0);
*ret_s = 0;
avahi_log_warn("System host name is set to 'localhost'. This is not a suitable mDNS host name, looking for alternatives.");
}
-
+
if (*ret_s == 0) {
/* No hostname was set, so let's take the OS name */
{
/* Try uname() second */
struct utsname utsname;
-
+
if (uname(&utsname) >= 0) {
snprintf(ret_s, size, "%s", utsname.sysname);
strip_bad_chars(ret_s);
}
if (size >= AVAHI_LABEL_MAX)
- ret_s[AVAHI_LABEL_MAX-1] = 0;
-
+ ret_s[AVAHI_LABEL_MAX-1] = 0;
+
return ret_s;
}
if ((r = strcmp(ca, cb)))
return r;
-
+
if (!*a && !*b)
return 0;
}
if (*domain == 0)
return 0;
-
+
if (avahi_domain_equal(domain, suffix))
return 1;
r = avahi_unescape_label(&domain, dummy, sizeof(dummy));
assert(r);
- }
+ }
}
#ifndef foodomainutilhfoo
#define foodomainutilhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_C_DECL_BEGIN
/** Return the local host name. */
-char *avahi_get_host_name(char *ret_s, size_t size);
+char *avahi_get_host_name(char *ret_s, size_t size);
/** Return the local host name. avahi_free() the result! */
char *avahi_get_host_name_strdup(void);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (g->register_time_event)
avahi_time_event_free(g->register_time_event);
-
+
AVAHI_LLIST_REMOVE(AvahiSEntryGroup, groups, s->groups, g);
avahi_free(g);
}
if (s->need_group_cleanup) {
AvahiSEntryGroup *g, *next;
-
+
for (g = s->groups; g; g = next) {
next = g->groups_next;
-
+
if (g->dead)
avahi_entry_group_free(s, g);
}
if (s->need_entry_cleanup) {
AvahiEntry *e, *next;
-
+
for (e = s->entries; e; e = next) {
next = e->entries_next;
-
+
if (e->dead)
avahi_entry_free(s, e);
}
static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r, AvahiPublishFlags flags) {
AvahiEntry *e;
-
+
assert(s);
assert(r);
if (!(flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_UNIQUE))
continue;
-
+
if ((flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) && (e->flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) )
continue;
AvahiRecord *r) {
AvahiEntry *e;
-
+
assert(s);
assert(r);
!g ||
(g->state != AVAHI_ENTRY_GROUP_ESTABLISHED && g->state != AVAHI_ENTRY_GROUP_REGISTERING) ||
(flags & AVAHI_PUBLISH_UPDATE), AVAHI_ERR_BAD_STATE);
-
+
if (flags & AVAHI_PUBLISH_UPDATE) {
AvahiRecord *old_record;
int is_first = 1;
-
+
/* Update and existing record */
/* Find the first matching entry */
/* If we were the first entry in the list, we need to update the key */
if (is_first)
avahi_hashmap_replace(s->entries_by_key, e->record->key, e);
-
+
avahi_record_unref(old_record);
} else {
AvahiEntry *t;
/* Add a new record */
-
+
if (check_record_conflict(s, interface, protocol, r, flags) < 0) {
avahi_server_set_errno(s, AVAHI_ERR_COLLISION);
return NULL;
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
e->server = s;
e->record = avahi_record_ref(r);
e->group = g;
e->protocol = protocol;
e->flags = flags;
e->dead = 0;
-
+
AVAHI_LLIST_HEAD_INIT(AvahiAnnouncer, e->announcers);
-
+
AVAHI_LLIST_PREPEND(AvahiEntry, entries, s->entries, e);
-
+
/* Insert into hash table indexed by name */
t = avahi_hashmap_lookup(s->entries_by_key, e->record->key);
AVAHI_LLIST_PREPEND(AvahiEntry, by_key, t, e);
avahi_hashmap_replace(s->entries_by_key, e->record->key, t);
-
+
/* Insert into group list */
if (g)
- AVAHI_LLIST_PREPEND(AvahiEntry, by_group, g->entries, e);
-
+ AVAHI_LLIST_PREPEND(AvahiEntry, by_group, g->entries, e);
+
avahi_announce_entry(s, e);
}
if (!*e)
*e = g ? g->entries : s->entries;
-
+
while (*e && (*e)->dead)
*e = g ? (*e)->by_group_next : (*e)->entries_next;
-
+
if (!*e)
return NULL;
int avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, void* userdata) {
AvahiEntry *e;
-
+
assert(s);
assert(callback);
if (e->dead)
continue;
-
+
if (!(t = avahi_record_to_string(e->record)))
return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
-
+
snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol);
avahi_free(t);
AvahiRecord *r;
AvahiEntry *e;
-
+
assert(s);
assert(dest);
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
r->data.ptr.name = avahi_normalize_name_strdup(dest);
e = server_add_internal(s, g, interface, protocol, flags, r);
avahi_record_unref(r);
return e;
}
-
+
int avahi_server_add_ptr(
AvahiServer *s,
AvahiSEntryGroup *g,
int ret = AVAHI_OK;
AvahiEntry *entry = NULL, *reverse = NULL;
AvahiRecord *r;
-
+
assert(s);
assert(a);
AVAHI_CHECK_VALIDITY(s, !name || avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME);
/* Prepare the host naem */
-
+
if (!name)
name = s->host_name_fqdn;
else {
transport_flags_from_domain(s, &flags, name);
AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
-
+
/* Create the A/AAAA record */
-
+
if (a->proto == AVAHI_PROTO_INET) {
if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, AVAHI_DEFAULT_TTL_HOST_NAME))) {
ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
goto finish;
}
-
+
r->data.a.address = a->data.ipv4;
-
+
} else {
assert(a->proto == AVAHI_PROTO_INET6);
-
+
if (!(r = avahi_record_new_full(name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA, AVAHI_DEFAULT_TTL_HOST_NAME))) {
ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
goto finish;
}
-
+
r->data.aaaa.address = a->data.ipv6;
}
-
+
entry = server_add_internal(s, g, interface, protocol, (flags & ~ AVAHI_PUBLISH_NO_REVERSE) | AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
avahi_record_unref(r);
}
/* Create the reverse lookup entry */
-
+
if (!(flags & AVAHI_PUBLISH_NO_REVERSE)) {
char reverse_n[AVAHI_DOMAIN_NAME_MAX];
avahi_reverse_lookup_name(a, reverse_n, sizeof(reverse_n));
-
+
if (!(reverse = server_add_ptr_internal(s, g, interface, protocol, flags | AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL_HOST_NAME, reverse_n, name))) {
ret = avahi_server_errno(s);
goto finish;
}
}
-
+
finish:
if (ret != AVAHI_OK && !(flags & AVAHI_PUBLISH_UPDATE)) {
AvahiRecord *r;
AvahiEntry *e;
-
+
assert(s);
if (!(r = avahi_record_new_full(name ? name : s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT, ttl))) {
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
r->data.txt.string_list = strlst;
e = server_add_internal(s, g, interface, protocol, flags, r);
avahi_record_unref(r);
AvahiRecord *r = NULL;
int ret = AVAHI_OK;
AvahiEntry *srv_entry = NULL, *txt_entry = NULL, *ptr_entry = NULL, *enum_entry = NULL;
-
+
assert(s);
assert(type);
assert(name);
transport_flags_from_domain(s, &flags, domain);
AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
-
+
if (!(h = avahi_normalize_name_strdup(host))) {
ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
goto fail;
}
/* Add service enumeration PTR record */
-
+
if (!(ptr_entry = server_add_ptr_internal(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name))) {
ret = avahi_server_errno(s);
goto fail;
}
/* Add SRV record */
-
+
if (!(r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) {
ret = avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
goto fail;
}
-
+
r->data.srv.priority = 0;
r->data.srv.weight = 0;
r->data.srv.port = port;
if (!(flags & AVAHI_PUBLISH_NO_COOKIE))
strlst = add_magic_cookie(s, strlst);
-
+
txt_entry = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst);
strlst = NULL;
}
/* Add service type enumeration record */
-
+
if (!(enum_entry = server_add_ptr_internal(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name))) {
ret = avahi_server_errno(s);
goto fail;
if (enum_entry)
avahi_entry_free(s, enum_entry);
}
-
+
avahi_string_list_free(strlst);
avahi_free(h);
-
+
return ret;
}
va_list va;
int ret;
-
+
va_start(va, port);
ret = server_add_service_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, host, port, avahi_string_list_new_va(va));
va_end(va);
-
+
return ret;
}
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
AvahiStringList *strlst) {
char svc_name[AVAHI_DOMAIN_NAME_MAX];
int ret = AVAHI_OK;
AvahiEntry *e;
-
+
assert(s);
assert(type);
assert(name);
/* Add TXT record */
if (!(flags & AVAHI_PUBLISH_NO_COOKIE))
strlst = add_magic_cookie(s, strlst);
-
+
e = server_add_txt_strlst_nocopy(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_UPDATE, AVAHI_DEFAULT_TTL, svc_name, strlst);
strlst = NULL;
if (!e)
ret = avahi_server_errno(s);
-
+
fail:
-
+
avahi_string_list_free(strlst);
-
+
return ret;
}
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
AvahiStringList *strlst) {
return server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_copy(strlst));
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
...) {
va_list va;
int ret;
-
+
va_start(va, domain);
ret = server_update_service_txt_strlst_nocopy(s, g, interface, protocol, flags, name, type, domain, avahi_string_list_new_va(va));
va_end(va);
-
+
return ret;
}
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
const char *subtype) {
int ret = AVAHI_OK;
char svc_name[AVAHI_DOMAIN_NAME_MAX], ptr_name[AVAHI_DOMAIN_NAME_MAX];
-
+
assert(name);
assert(type);
assert(subtype);
goto fail;
fail:
-
+
return ret;
}
k++;
pl--;
}
-
+
b = !b;
sl--;
AvahiEntry *e;
char t[AVAHI_DOMAIN_NAME_MAX], normalized_d[AVAHI_DOMAIN_NAME_MAX], *n;
-
+
AvahiRecord *r;
-
+
assert(s);
assert(name);
AVAHI_CHECK_VALIDITY_RETURN_NULL(s, port != 0, AVAHI_ERR_INVALID_PORT);
AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME);
AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
-
+
if (!domain)
domain = s->domain_name;
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
AVAHI_ASSERT_TRUE(avahi_normalize_name(domain, normalized_d, sizeof(normalized_d)));
snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", normalized_d);
-
+
if (!(r = avahi_record_new_full(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME))) {
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
avahi_free(n);
return NULL;
}
-
+
r->data.srv.priority = 0;
r->data.srv.weight = 0;
r->data.srv.port = port;
transport_flags_from_domain(s, &flags, domain);
AVAHI_CHECK_VALIDITY(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);
-
+
if (address->proto == AVAHI_PROTO_INET) {
hexstring(h, sizeof(h), &address->data, sizeof(AvahiIPv4Address));
snprintf(n, sizeof(n), "ip-%s.%s", h, domain);
if (!r)
return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
-
+
a_entry = server_add_internal(s, g, interface, protocol, AVAHI_PUBLISH_UNIQUE | AVAHI_PUBLISH_ALLOW_MULTIPLE, r);
avahi_record_unref(r);
if (!a_entry)
return avahi_server_errno(s);
-
+
if (!(s_entry = server_add_dns_server_name(s, g, interface, protocol, flags, domain, type, n, port))) {
if (!(flags & AVAHI_PUBLISH_UPDATE))
avahi_entry_free(s, a_entry);
/* If the entry group was established for a time longer then
* 5s, reset the establishment trial counter */
-
+
if (avahi_age(&g->established_at) > 5000000)
g->n_register_try = 0;
} else if (g->state == AVAHI_ENTRY_GROUP_REGISTERING) {
g->register_time_event = NULL;
}
}
-
+
if (state == AVAHI_ENTRY_GROUP_ESTABLISHED)
/* If the entry group is now established, remember the time
* this happened */
-
+
gettimeofday(&g->established_at, NULL);
-
+
g->state = state;
-
+
if (g->callback)
g->callback(g->server, g, state, g->userdata);
}
AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata) {
AvahiSEntryGroup *g;
-
+
assert(s);
if (!(g = avahi_new(AvahiSEntryGroup, 1))) {
avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
g->server = s;
g->callback = callback;
g->userdata = userdata;
void avahi_s_entry_group_free(AvahiSEntryGroup *g) {
AvahiEntry *e;
-
+
assert(g);
assert(g->server);
}
g->dead = 1;
-
+
g->server->need_group_cleanup = 1;
g->server->need_entry_cleanup = 1;
+
+ avahi_cleanup_dead_entries(g->server);
}
static void entry_group_commit_real(AvahiSEntryGroup *g) {
avahi_time_event_free(g->register_time_event);
g->register_time_event = NULL;
-
+
/* Holdoff time passed, so let's start probing */
entry_group_commit_real(g);
}
int avahi_s_entry_group_commit(AvahiSEntryGroup *g) {
struct timeval now;
-
+
assert(g);
assert(!g->dead);
/* Holdoff time has not yet passed, so let's wait */
assert(!g->register_time_event);
g->register_time_event = avahi_time_event_new(g->server->time_event_queue, &g->register_time, entry_group_register_time_event_callback, g);
-
+
avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
}
void avahi_s_entry_group_reset(AvahiSEntryGroup *g) {
AvahiEntry *e;
assert(g);
-
+
for (e = g->entries; e; e = e->by_group_next) {
if (!e->dead) {
avahi_goodbye_entry(g->server, e, 1, 1);
g->n_probing = 0;
avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED);
+
+ avahi_cleanup_dead_entries(g->server);
}
int avahi_entry_is_commited(AvahiEntry *e) {
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int n;
assert(fd >= 0);
-
+
if ((n = fcntl(fd, F_GETFD)) < 0)
return -1;
int avahi_set_nonblock(int fd) {
int n;
-
+
assert(fd >= 0);
if ((n = fcntl(fd, F_GETFL)) < 0)
int avahi_wait_for_write(int fd) {
fd_set fds;
int r;
-
+
FD_ZERO(&fds);
FD_SET(fd, &fds);
-
+
if ((r = select(fd+1, NULL, &fds, NULL, NULL)) < 0)
return -1;
-
+
assert(r > 0);
return 0;
#ifndef foofdutilhfoo
#define foofdutilhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
for (n = 0; n < 1000; n ++)
avahi_hashmap_insert(m, avahi_strdup_printf("key %u", n), avahi_strdup_printf("value %u", n));
-
+
printf("%s\n", (const char*) avahi_hashmap_lookup(m, "bla"));
avahi_hashmap_replace(m, avahi_strdup("bla"), avahi_strdup("#3"));
t = (const char*) avahi_hashmap_lookup(m, "bla");
printf("%s\n", t ? t : "(null)");
-
+
avahi_hashmap_free(m);
return 0;
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiHashFunc hash_func;
AvahiEqualFunc equal_func;
AvahiFreeFunc key_free_func, value_free_func;
-
+
Entry *entries[HASH_MAP_SIZE];
AVAHI_LLIST_HEAD(Entry, entries_list);
};
Entry *e;
idx = m->hash_func(key) % HASH_MAP_SIZE;
-
+
for (e = m->entries[idx]; e; e = e->bucket_next)
if (m->equal_func(key, e->key))
return e;
AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_func, AvahiFreeFunc key_free_func, AvahiFreeFunc value_free_func) {
AvahiHashmap *m;
-
+
assert(hash_func);
assert(equal_func);
m->value_free_func = value_free_func;
AVAHI_LLIST_HEAD_INIT(Entry, m->entries_list);
-
+
return m;
}
while (m->entries_list)
entry_free(m, m->entries_list, 0);
-
+
avahi_free(m);
}
void* avahi_hashmap_lookup(AvahiHashmap *m, const void *key) {
Entry *e;
-
+
assert(m);
if (!(e = entry_get(m, key)))
m->key_free_func(key);
if (m->value_free_func)
m->value_free_func(value);
-
+
return 1;
}
idx = m->hash_func(key) % HASH_MAP_SIZE;
AVAHI_LLIST_PREPEND(Entry, bucket, m->entries[idx], e);
-
+
return 0;
}
e->key = key;
e->value = value;
-
+
return 1;
}
idx = m->hash_func(key) % HASH_MAP_SIZE;
AVAHI_LLIST_PREPEND(Entry, bucket, m->entries[idx], e);
-
+
return 0;
}
void avahi_hashmap_remove(AvahiHashmap *m, const void *key) {
Entry *e;
-
+
assert(m);
if (!(e = entry_get(m, key)))
unsigned hash = 0;
assert(p);
-
+
for (; *p; p++)
hash = 31 * hash + *p;
assert(p);
assert(q);
-
+
return strcmp(p, q) == 0;
}
const int *i = data;
assert(i);
-
+
return (unsigned) *i;
}
assert(_a);
assert(_b);
-
+
return *_a == *_b;
}
#ifndef foohashmaphfoo
#define foohashmaphfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
uint8_t req[1024];
/* Issue a wild dump NETLINK request */
-
+
memset(&req, 0, sizeof(req));
n = (struct nlmsghdr*) req;
n->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg));
AvahiInterfaceMonitor *m = userdata;
/* This routine is called for every RTNETLINK response packet */
-
+
assert(m);
assert(n);
assert(m->osdep.netlink == nl);
if (n->nlmsg_type == RTM_NEWLINK) {
/* A new interface appeared or an existing one has been modified */
-
+
struct ifinfomsg *ifinfomsg = NLMSG_DATA(n);
AvahiHwInterface *hw;
struct rtattr *a = NULL;
* interface appears, but when it changes, too */
if (!(hw = avahi_interface_monitor_get_hw_interface(m, ifinfomsg->ifi_index)))
-
+
/* No object found, so let's create a new
* one. avahi_hw_interface_new() will call
* avahi_interface_new() internally twice for IPv4 and
hw->mac_address_size = RTA_PAYLOAD(a);
if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX)
hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX;
-
+
memcpy(hw->mac_address, RTA_DATA(a), hw->mac_address_size);
break;
-
+
default:
;
}
/* Update any associated RRs of this interface. (i.e. the
* _workstation._tcp record containing the MAC address) */
avahi_hw_interface_update_rrs(hw, 0);
-
+
} else if (n->nlmsg_type == RTM_DELLINK) {
/* An interface has been removed */
/* Free our object */
avahi_hw_interface_free(hw, 0);
-
+
} else if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) {
/* An address has been added, modified or removed */
-
+
struct ifaddrmsg *ifaddrmsg = NLMSG_DATA(n);
AvahiInterface *i;
struct rtattr *a = NULL;
switch(a->rta_type) {
case IFA_ADDRESS:
/* Fill in address data */
-
+
if ((raddr.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||
(raddr.proto == AVAHI_PROTO_INET && RTA_PAYLOAD(a) != 4))
return;
default:
;
}
-
+
a = RTA_NEXT(a, l);
}
/* Update any associated RRs, like A or AAAA for our new/removed address */
avahi_interface_update_rrs(i, 0);
-
+
} else if (n->nlmsg_type == NLMSG_DONE) {
/* This wild dump request ended, so let's see what we do next */
-
+
if (m->osdep.list == LIST_IFACE) {
/* Mmmm, interfaces have been wild dumped already, so
* let's go on with wild dumping the addresses */
-
+
if (netlink_list_items(m->osdep.netlink, RTM_GETADDR, &m->osdep.query_addr_seq) < 0) {
avahi_log_warn("NETLINK: Failed to list addrs: %s", strerror(errno));
m->osdep.list = LIST_DONE;
/* Tell the user that the wild dump is complete */
avahi_log_info("Network interface enumeration completed.");
}
-
+
} else if (n->nlmsg_type == NLMSG_ERROR &&
(n->nlmsg_seq == m->osdep.query_link_seq || n->nlmsg_seq == m->osdep.query_addr_seq)) {
struct nlmsgerr *e = NLMSG_DATA (n);
/* Some kind of error happened. Let's just tell the user and
* ignore it otherwise */
-
+
if (e->error)
avahi_log_warn("NETLINK: Failed to browse: %s", strerror(-e->error));
}
assert(m);
/* Initialize our own data */
-
+
m->osdep.netlink = NULL;
m->osdep.query_addr_seq = m->osdep.query_link_seq = 0;
/* Let's handle netlink events until we are done with wild
* dumping */
-
+
while (!m->list_complete)
if (!avahi_netlink_work(m->osdep.netlink, 1) == 0)
break;
#ifndef fooifacelinuxhfoo
#define fooifacelinuxhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiInterfaceMonitorOSDep {
AvahiNetlink *netlink;
-
+
unsigned query_addr_seq, query_link_seq;
-
+
enum {
LIST_IFACE,
LIST_ADDR,
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include "iface-pfroute.h"
#include "util.h"
-static int bitcount (unsigned int n)
-{
+static int bitcount (unsigned int n)
+{
int count=0 ;
while (n)
{
AvahiHwInterface *hw;
struct if_msghdr *ifm = (struct if_msghdr *)rtm;
struct sockaddr_dl *sdl = (struct sockaddr_dl *)(ifm + 1);
-
+
if (sdl->sdl_family != AF_LINK)
return;
-
+
if (ifm->ifm_addrs == 0 && ifm->ifm_index > 0) {
if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) ifm->ifm_index)))
return;
avahi_hw_interface_free(hw, 0);
return;
}
-
+
if (!(hw = avahi_interface_monitor_get_hw_interface(m, ifm->ifm_index)))
if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) ifm->ifm_index)))
return; /* OOM */
-
+
hw->flags_ok =
(ifm->ifm_flags & IFF_UP) &&
(!m->server->config.use_iff_running || (ifm->ifm_flags & IFF_RUNNING)) &&
!(ifm->ifm_flags & IFF_LOOPBACK) &&
(ifm->ifm_flags & IFF_MULTICAST) &&
(m->server->config.allow_point_to_point || !(ifm->ifm_flags & IFF_POINTOPOINT));
-
+
avahi_free(hw->name);
hw->name = avahi_strndup(sdl->sdl_data, sdl->sdl_nlen);
-
+
hw->mtu = ifm->ifm_data.ifi_mtu;
-
+
hw->mac_address_size = sdl->sdl_alen;
if (hw->mac_address_size > AVAHI_MAC_ADDRESS_MAX)
hw->mac_address_size = AVAHI_MAC_ADDRESS_MAX;
-
+
memcpy(hw->mac_address, sdl->sdl_data + sdl->sdl_nlen, hw->mac_address_size);
-
+
/* { */
/* char mac[256]; */
/* avahi_log_debug("======\n name: %s\n index:%d\n mtu:%d\n mac:%s\n flags_ok:%d\n======", */
/* avahi_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size), */
/* hw->flags_ok); */
/* } */
-
+
avahi_hw_interface_check_relevant(hw);
avahi_hw_interface_update_rrs(hw, 0);
}
return;
raddr.proto = avahi_af_to_proto(sa->sa_family);
-
+
for(cp = cp0, i = 0; i < RTAX_MAX; i++)
{
if (!(ifam->ifam_addrs & (1<<i)))
continue;
sa = (struct sockaddr *)cp;
#ifdef HAVE_SYS_SYSCTL_H
- if (sa->sa_len == 0)
+ if (sa->sa_len == 0)
continue;
#endif
switch(sa->sa_family) {
return;
avahi_interface_address_free(addriface);
}
-
+
avahi_interface_check_relevant(iface);
avahi_interface_update_rrs(iface, 0);
}
{
assert(m);
assert(rtm);
-
+
if (rtm->rtm_version != RTM_VERSION) {
avahi_log_warn("routing message version %d not understood",
rtm->rtm_version);
}
m->osdep.pfroute->fd = fd;
- if (!(m->osdep.pfroute->watch = m->server->poll_api->watch_new(m->server->poll_api,
- m->osdep.pfroute->fd,
- AVAHI_WATCH_IN,
- socket_event,
+ if (!(m->osdep.pfroute->watch = m->server->poll_api->watch_new(m->server->poll_api,
+ m->osdep.pfroute->fd,
+ AVAHI_WATCH_IN,
+ socket_event,
m))) {
avahi_log_error(__FILE__": Failed to create watch.");
goto fail;
}
-
+
return 0;
fail:
if (m->osdep.pfroute) {
if (m->osdep.pfroute->watch)
m->server->poll_api->watch_free(m->osdep.pfroute->watch);
-
+
if (fd >= 0)
close(fd);
-
+
m->osdep.pfroute = NULL;
}
if (m->osdep.pfroute) {
if (m->osdep.pfroute->watch)
m->server->poll_api->watch_free(m->osdep.pfroute->watch);
-
+
if (m->osdep.pfroute->fd >= 0)
close(m->osdep.pfroute->fd);
index = if_nametoindex(lifreq->lifr_name);
if (!(hw = avahi_interface_monitor_get_hw_interface(m, (AvahiIfIndex) index))) {
- if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) index)))
+ if (!(hw = avahi_hw_interface_new(m, (AvahiIfIndex) index)))
return; /* OOM */
hw->flags_ok =
return; /* OOM */
addriface->global_scope = 1;
-
+
avahi_hw_interface_check_relevant(hw);
avahi_hw_interface_update_rrs(hw, 0);
}
struct rt_msghdr *rtm;
assert(m);
-
+
retry2:
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
rtm = (struct rt_msghdr *)next;
parse_rtmsg(rtm, m);
}
-
+
m->list_complete = 1;
avahi_interface_monitor_check_relevant(m);
avahi_interface_monitor_update_rrs(m, 0);
#ifndef fooifacepfroutehfoo
#define fooifacepfroutehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef fooifacehfoo
#define fooifacehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#else
typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
struct AvahiInterfaceMonitorOSDep {
-
+
unsigned query_addr_seq, query_link_seq;
-
+
enum {
LIST_IFACE,
LIST_ADDR,
char *name;
AvahiIfIndex index;
int flags_ok;
-
+
unsigned mtu;
uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX];
AVAHI_LLIST_FIELDS(AvahiInterface, interface);
AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
-
+
AvahiProtocol protocol;
int announcing;
AvahiAddress local_mcast_address;
unsigned prefix_len;
int global_scope;
-
+
AvahiSEntryGroup *entry_group;
};
#ifndef foointernalhfoo
#define foointernalhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiLegacyUnicastReflectSlot {
AvahiServer *server;
-
+
uint16_t id, original_id;
AvahiAddress address;
uint16_t port;
AvahiSEntryGroup *group;
int dead;
-
+
AvahiPublishFlags flags;
AvahiRecord *record;
AvahiIfIndex interface;
AVAHI_LLIST_FIELDS(AvahiEntry, entries);
AVAHI_LLIST_FIELDS(AvahiEntry, by_key);
AVAHI_LLIST_FIELDS(AvahiEntry, by_group);
-
+
AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
};
AvahiSEntryGroupCallback callback;
unsigned n_probing;
-
+
unsigned n_register_try;
struct timeval register_time;
AvahiTimeEvent *register_time_event;
struct timeval established_at;
-
+
AVAHI_LLIST_FIELDS(AvahiSEntryGroup, groups);
AVAHI_LLIST_HEAD(AvahiEntry, entries);
};
struct AvahiServer {
const AvahiPoll *poll_api;
-
+
AvahiInterfaceMonitor *monitor;
AvahiServerConfig config;
AvahiHashmap *entries_by_key;
AVAHI_LLIST_HEAD(AvahiSEntryGroup, groups);
-
+
AVAHI_LLIST_HEAD(AvahiSRecordBrowser, record_browsers);
AvahiHashmap *record_browser_hashmap;
AVAHI_LLIST_HEAD(AvahiSHostNameResolver, host_name_resolvers);
AVAHI_LLIST_HEAD(AvahiSDNSServerBrowser, dns_server_browsers);
int need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
-
+
AvahiTimeEventQueue *time_event_queue;
-
+
char *host_name, *host_name_fqdn, *domain_name;
int fd_ipv4, fd_ipv6,
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- uint32_t ttl,
- const char *name,
+ uint32_t ttl,
+ const char *name,
const char *dest);
#define AVAHI_CHECK_VALIDITY(server, expression, error) { \
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
void avahi_log_ap(AvahiLogLevel level, const char*format, va_list ap) {
char txt[256];
-
+
vsnprintf(txt, sizeof(txt), format, ap);
-
+
if (log_function)
log_function(level, txt);
else
#ifndef foologhfoo
#define foologhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foolookuphfoo
#define foolookuphfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
/** Callback prototype for AvahiSHostNameResolver events */
typedef void (*AvahiSHostNameResolverCallback)(
AvahiSHostNameResolver *r,
- AvahiIfIndex interface,
+ AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event, /**< Resolving event */
const char *host_name, /**< Host name which should be resolved. May differ in case from the query */
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiResolverEvent event,
- const AvahiAddress *a,
+ const AvahiAddress *a,
const char *host_name, /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */
AvahiLookupResultFlags flags, /**< Lookup flags */
void* userdata);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int dead;
AvahiKey *key, *cname_key;
-
+
AvahiMulticastLookupCallback callback;
void *userdata;
AvahiIfIndex interface;
AvahiProtocol protocol;
-
+
int queriers_added;
AvahiTimeEvent *all_for_now_event;
-
+
AVAHI_LLIST_FIELDS(AvahiMulticastLookup, lookups);
AVAHI_LLIST_FIELDS(AvahiMulticastLookup, by_key);
};
AvahiKey *key,
AvahiMulticastLookupCallback callback,
void *userdata) {
-
+
AvahiMulticastLookup *l, *t;
struct timeval tv;
-
+
assert(e);
assert(AVAHI_IF_VALID(interface));
assert(AVAHI_PROTO_VALID(protocol));
/* Issue the ALL_FOR_NOW event one second after the querier was initially created */
l->all_for_now_event = avahi_time_event_new(e->server->time_event_queue, &tv, all_for_now_callback, l);
-
+
return l;
}
assert(l);
lookup_stop(l);
-
+
t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key);
AVAHI_LLIST_REMOVE(AvahiMulticastLookup, by_key, t, l);
if (t)
if (l->cname_key)
avahi_key_unref(l->cname_key);
-
+
avahi_free(l);
}
void avahi_multicast_lookup_engine_cleanup(AvahiMulticastLookupEngine *e) {
AvahiMulticastLookup *l, *n;
assert(e);
-
+
while (e->cleanup_dead) {
e->cleanup_dead = 0;
-
+
for (l = e->lookups; l; l = n) {
n = l->lookups_next;
-
+
if (l->dead)
lookup_destroy(l);
}
cbdata->userdata);
cbdata->n_found ++;
-
+
return NULL;
}
assert(cbdata);
cbdata->interface = i;
-
+
avahi_cache_walk(i->cache, cbdata->key, scan_cache_callback, cbdata);
if (cbdata->cname_key)
avahi_cache_walk(i->cache, cbdata->cname_key, scan_cache_callback, cbdata);
-
+
cbdata->interface = NULL;
}
AvahiKey *key,
AvahiMulticastLookupCallback callback,
void *userdata) {
-
+
struct cbdata cbdata;
-
+
assert(e);
assert(key);
assert(callback);
cbdata.userdata = userdata;
cbdata.interface = NULL;
cbdata.n_found = 0;
-
+
avahi_interface_monitor_walk(e->server->monitor, interface, protocol, scan_interface_callback, &cbdata);
-
+
if (cbdata.cname_key)
avahi_key_unref(cbdata.cname_key);
void avahi_multicast_lookup_engine_new_interface(AvahiMulticastLookupEngine *e, AvahiInterface *i) {
AvahiMulticastLookup *l;
-
+
assert(e);
assert(i);
for (l = e->lookups; l; l = l->lookups_next) {
-
+
if (l->dead || !l->callback)
continue;
void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiInterface *i, AvahiRecord *record, AvahiBrowserEvent event) {
AvahiMulticastLookup *l;
-
+
assert(e);
assert(record);
assert(i);
if (l->dead || !l->callback)
continue;
-
+
if ((key = avahi_key_new_cname(l->key))) {
if (avahi_key_equal(record->key, key))
l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_RESULT_MULTICAST, record, l->userdata);
AvahiMulticastLookupEngine *avahi_multicast_lookup_engine_new(AvahiServer *s) {
AvahiMulticastLookupEngine *e;
-
+
assert(s);
-
+
e = avahi_new(AvahiMulticastLookupEngine, 1);
e->server = s;
e->cleanup_dead = 0;
#ifndef foomulticastlookuphfoo
#define foomulticastlookuphfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct iovec iov;
struct nlmsghdr *p;
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
-
+
assert(nl);
iov.iov_base = nl->buffer;
if ((bytes = recvmsg(nl->fd, &smsg, 0)) < 0) {
if (errno == EAGAIN || errno == EINTR)
return 0;
-
+
avahi_log_error(__FILE__": recvmsg() failed: %s", strerror(errno));
return -1;
}
return -1;
p = (struct nlmsghdr *) nl->buffer;
-
+
assert(nl->callback);
-
+
for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) {
if (!NLMSG_OK(p, (size_t) bytes)) {
avahi_log_warn(__FILE__": packet truncated");
return -1;
}
-
+
nl->callback(nl, p, nl->userdata);
}
-
+
return 0;
}
avahi_log_error(__FILE__": socket(PF_NETLINK): %s", strerror(errno));
return NULL;
}
-
+
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
addr.nl_groups = groups;
avahi_log_error(__FILE__": Failed to create watch.");
goto fail;
}
-
+
return nl;
fail:
if (nl->fd >= 0)
close(nl->fd);
-
+
avahi_free(nl->buffer);
avahi_free(nl);
}
int avahi_netlink_send(AvahiNetlink *nl, struct nlmsghdr *m, unsigned *ret_seq) {
assert(nl);
assert(m);
-
+
m->nlmsg_seq = nl->seq++;
m->nlmsg_flags |= NLM_F_ACK;
#ifndef foonetlinkhfoo
#define foonetlinkhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include "prioq.h"
-#define POINTER_TO_INT(p) ((int) (p))
-#define INT_TO_POINTER(i) ((void*) (i))
+#define POINTER_TO_INT(p) ((int) (long) (p))
+#define INT_TO_POINTER(i) ((void*) (long) (i))
static int compare_int(const void* a, const void* b) {
int i = POINTER_TO_INT(a), j = POINTER_TO_INT(b);
assert(n->parent->right == NULL);
}
-
+
if (n->parent) {
int a = POINTER_TO_INT(n->parent->data), b = POINTER_TO_INT(n->data);
if (a > b) {
assert(q->n_nodes == q2->n_nodes);
printf("%i\n", POINTER_TO_INT(((AvahiPrioQueueNode*)q2->root->data)->data));
-
+
avahi_prio_queue_remove(q, q2->root->data);
avahi_prio_queue_remove(q2, q2->root);
}
-
+
/* prev = 0; */
/* while (q->root) { */
/* int v = GPOINTER_TO_INT(q->root->data); */
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (!(q = avahi_new(AvahiPrioQueue, 1)))
return NULL; /* OOM */
-
+
q->root = q->last = NULL;
q->n_nodes = 0;
q->compare = compare;
-
+
return q;
}
for (r = 0; r < y; r++) {
assert(n);
-
+
if ((x >> (y-r-1)) & 1)
n = n->right;
else
if (a->parent == b) {
/* B is parent of A */
-
+
p = b->parent;
b->parent = a;
a->right->parent = a;
if ((b->right = r))
b->right->parent = b;
-
+
} else {
if ((b->right = a->right))
b->right->parent = b;
}
} else if (b->parent == a) {
/* A ist parent of B */
-
+
p = a->parent;
a->parent = b;
}
} else {
AvahiPrioQueueNode *apl = NULL, *bpl = NULL;
-
+
/* Swap parents */
ap = a->parent;
bp = b->parent;
apl = ap->left;
if (bp)
bpl = bp->left;
-
+
if ((a->parent = bp)) {
if (bpl == b)
bp->left = a;
- else
+ else
bp->right = a;
} else
q->root = a;
-
+
if ((b->parent = ap)) {
if (apl == a)
ap->left = b;
q->root = b;
/* Swap children */
- l = a->left;
- r = a->right;
+ l = a->left;
+ r = a->right;
if ((a->left = b->left))
a->left->parent = a;
if ((b->right = r))
b->right->parent = b;
}
-
+
/* Swap siblings */
ap = a->prev; an = a->next;
bp = b->prev; bn = b->next;
if ((b->prev = ap))
b->prev->next = b;
-
+
} else if (b->next == a) {
/* B is predecessor of A */
a->next = b;
if ((a->prev = bp))
a->prev->next = a;
-
+
if ((a->next = bn))
a->next->prev = a;
else
q->last = a;
-
+
if ((b->prev = ap))
b->prev->next = b;
-
+
if ((b->next = an))
b->next->prev = b;
else
if (!(n = avahi_new(AvahiPrioQueueNode, 1)))
return NULL; /* OOM */
-
+
n->queue = q;
n->data = data;
if (q->last) {
assert(q->root);
assert(q->n_nodes);
-
+
n->y = q->last->y;
n->x = q->last->x+1;
q->last->next = n;
n->prev = q->last;
-
+
assert(n->y > 0);
n->parent = get_node_at_xy(q, n->x/2, n->y-1);
} else {
assert(!q->root);
assert(!q->n_nodes);
-
+
n->y = n->x = 0;
q->root = n;
n->prev = n->parent = NULL;
assert(!n->right);
q->last = n->prev;
-
+
if (n->prev) {
n->prev->next = NULL;
assert(n->parent);
#ifndef fooprioqhfoo
#define fooprioqhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiProbeJob {
AvahiProbeScheduler *scheduler;
AvahiTimeEvent *time_event;
-
+
int chosen; /* Use for packet assembling */
int done;
struct timeval delivery;
AvahiRecord *record;
-
+
AVAHI_LLIST_FIELDS(AvahiProbeJob, jobs);
};
static AvahiProbeJob* job_new(AvahiProbeScheduler *s, AvahiRecord *record, int done) {
AvahiProbeJob *pj;
-
+
assert(s);
assert(record);
avahi_log_error(__FILE__": Out of memory");
return NULL; /* OOM */
}
-
+
pj->scheduler = s;
pj->record = avahi_record_ref(record);
pj->time_event = NULL;
avahi_log_error(__FILE__": Out of memory");
return NULL;
}
-
+
s->interface = i;
s->time_event_queue = i->monitor->server->time_event_queue;
AVAHI_LLIST_HEAD_INIT(AvahiProbeJob, s->jobs);
AVAHI_LLIST_HEAD_INIT(AvahiProbeJob, s->history);
-
+
return s;
}
void avahi_probe_scheduler_clear(AvahiProbeScheduler *s) {
assert(s);
-
+
while (s->jobs)
job_free(s, s->jobs);
while (s->history)
job_free(s, s->history);
}
-
+
static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, AvahiProbeJob *pj) {
size_t size;
AvahiKey *k;
assert(pj);
assert(!pj->chosen);
-
+
/* Estimate the size for this record */
size =
avahi_key_get_estimate_size(pj->record->key) +
/* Create the probe query */
if (!(k = avahi_key_new(pj->record->key->name, pj->record->key->clazz, AVAHI_DNS_TYPE_ANY)))
return 0; /* OOM */
-
+
b = !!avahi_dns_packet_append_key(p, k, 0);
assert(b);
/* Does the record match the probe? */
if (k->clazz != pj->record->key->clazz || !avahi_domain_equal(k->name, pj->record->key->name))
continue;
-
+
/* This job wouldn't fit in */
if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_space(p))
break;
}
avahi_key_unref(k);
-
+
return 1;
}
if (!(p = avahi_dns_packet_new_query(s->interface->hardware->mtu)))
return; /* OOM */
n = 1;
-
+
/* Add the import probe */
if (!packet_add_probe_query(s, p, pj)) {
size_t size;
avahi_key_get_estimate_size(pj->record->key) +
avahi_record_get_estimate_size(pj->record) +
AVAHI_DNS_PACKET_HEADER_SIZE;
-
+
if (!(p = avahi_dns_packet_new_query(size + AVAHI_DNS_PACKET_EXTRA_SIZE)))
return; /* OOM */
avahi_dns_packet_free(p);
return; /* OOM */
}
-
+
b = avahi_dns_packet_append_key(p, k, 0) && avahi_dns_packet_append_record(p, pj->record, 0, 0);
avahi_key_unref(k);
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_QDCOUNT, 1);
avahi_interface_send_packet(s->interface, p);
} else
- avahi_log_warn("Probe record too large, cannot send");
-
+ avahi_log_warn("Probe record too large, cannot send");
+
avahi_dns_packet_free(p);
job_mark_done(s, pj);
if (pj->chosen)
continue;
-
+
if (!packet_add_probe_query(s, p, pj))
break;
-
+
n++;
}
/* Unmark all following jobs */
for (; pj; pj = pj->jobs_next)
pj->chosen = 0;
-
+
break;
}
job_mark_done(s, pj);
-
+
n ++;
}
-
+
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_NSCOUNT, n);
/* Send it now */
for (pj = s->jobs; pj; pj = pj->jobs_next) {
assert(!pj->done);
-
+
if (avahi_record_equal_no_ttl(pj->record, record))
return pj;
}
static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *record) {
AvahiProbeJob *pj;
-
+
assert(s);
assert(record);
job_free(s, pj);
return NULL;
}
-
+
return pj;
}
}
int avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, int immediately) {
AvahiProbeJob *pj;
struct timeval tv;
-
+
assert(s);
assert(record);
assert(!avahi_key_is_pattern(record->key));
/* Create a new job and schedule it */
if (!(pj = job_new(s, record, 0)))
return 0; /* OOM */
-
+
pj->delivery = tv;
pj->time_event = avahi_time_event_new(s->time_event_queue, &pj->delivery, elapse_callback, pj);
-
+
/* avahi_log_debug("Accepted new probe job."); */
return 1;
#ifndef fooprobeschedhfoo
#define fooprobeschedhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foopublishhfoo
#define foopublishhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiProtocol protocol, /**< A protocol family to attach this record to. One of the AVAHI_PROTO_xxx constants. Use AVAHI_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
AvahiPublishFlags flags, /**< Special flags for this record */
AvahiRecord *r /**< The record to add. This function increases the reference counter of this object. */);
-
+
/** Add an IP address mapping to the server. This will add both the
* host-name-to-address and the reverse mapping to the server. See
* avahi_server_add() for more information. If adding one of the RRs
AvahiPublishFlags flags,
const char *name, /**< Service name, e.g. "Lennart's Files" */
const char *type, /**< DNS-SD type, e.g. "_http._tcp" */
- const char *domain,
+ const char *domain,
const char *host, /**< Host name where this servcie resides, or NULL if on the local host */
uint16_t port, /**< Port number of the service */
... /**< Text records, terminated by NULL */) AVAHI_GCC_SENTINEL;
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
AvahiStringList *strlst);
/** Update the TXT record for a service with the NULL termonate list of strings */
AvahiIfIndex interface,
AvahiProtocol protocol,
AvahiPublishFlags flags,
- const char *name,
- const char *type,
- const char *domain,
+ const char *name,
+ const char *type,
+ const char *domain,
...) AVAHI_GCC_SENTINEL;
/** Check if there is a service locally defined and return the entry group it is attached to. Returns NULL if the service isn't local*/
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
service_browser2 = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL);
assert(service_browser2);
-
+
poll_api->timeout_free(timeout);
}
int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
struct timeval tv;
AvahiServerConfig config;
-
+
simple_poll = avahi_simple_poll_new();
assert(simple_poll);
-
+
poll_api = avahi_simple_poll_get(simple_poll);
assert(poll_api);
avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]);
config.n_wide_area_servers = 1;
config.enable_wide_area = 1;
-
+
server = avahi_server_new(poll_api, &config, NULL, NULL, NULL);
assert(server);
avahi_server_config_free(&config);
service_browser1 = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SERVICE_TYPE, DOMAIN, 0, sb_callback, NULL);
assert(service_browser1);
-
+
poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 10000, 0), create_second_service_browser, NULL);
poll_api->timeout_new(poll_api, avahi_elapse_time(&tv, 60000, 0), quit, NULL);
-
+
for (;;)
if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
break;
avahi_server_free(server);
avahi_simple_poll_free(simple_poll);
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
unsigned post_id;
int post_id_valid;
-
+
AVAHI_LLIST_FIELDS(AvahiQuerier, queriers);
};
avahi_key_unref(q->key);
avahi_time_event_free(q->time_event);
-
+
avahi_free(q);
}
static void querier_elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void *userdata) {
AvahiQuerier *q = userdata;
struct timeval tv;
-
+
assert(q);
if (q->n_used <= 0) {
/* The queue accepted our query. We store the query id here,
* that allows us to drop the query at a later point if the
* query is very short-lived. */
-
+
q->post_id_valid = 1;
}
q->sec_delay *= 2;
-
+
if (q->sec_delay >= 60*60) /* 1h */
q->sec_delay = 60*60;
-
+
avahi_elapse_time(&tv, q->sec_delay*1000, 0);
avahi_time_event_update(q->time_event, &tv);
}
void avahi_querier_add(AvahiInterface *i, AvahiKey *key, struct timeval *ret_ctime) {
AvahiQuerier *q;
struct timeval tv;
-
+
assert(i);
assert(key);
-
+
if ((q = avahi_hashmap_lookup(i->queriers_by_key, key))) {
-
+
/* Someone is already browsing for records of this RR key */
q->n_used++;
/* No one is browsing for this RR key, so we add a new querier */
if (!(q = avahi_new(AvahiQuerier, 1)))
return; /* OOM */
-
+
q->key = avahi_key_ref(key);
q->interface = i;
q->n_used = 1;
void avahi_querier_remove_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key) {
assert(s);
assert(key);
-
+
avahi_interface_monitor_walk(s->monitor, idx, protocol, remove_querier_callback, key);
}
static void add_querier_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
struct cbdata *cbdata = userdata;
-
+
assert(m);
assert(i);
assert(cbdata);
void avahi_querier_add_for_all(AvahiServer *s, AvahiIfIndex idx, AvahiProtocol protocol, AvahiKey *key, struct timeval *ret_ctime) {
struct cbdata cbdata;
-
+
assert(s);
assert(key);
if (ret_ctime)
ret_ctime->tv_sec = ret_ctime->tv_usec = 0;
-
+
avahi_interface_monitor_walk(s->monitor, idx, protocol, add_querier_callback, &cbdata);
}
int avahi_querier_shall_refresh_cache(AvahiInterface *i, AvahiKey *key) {
AvahiQuerier *q;
-
+
assert(i);
assert(key);
/* This key is currently not subscribed at all, so no cache
* refresh is needed */
return 0;
-
+
if (q->n_used <= 0) {
/* If this is an entry nobody references right now, don't
* consider it "existing". */
-
+
/* Remove this querier since it is referenced by nobody
* and the cached data will soon be out of date */
avahi_querier_free(q);
/* Tell the cache that no refresh is needed */
return 0;
-
+
} else {
struct timeval tv;
void avahi_querier_free_all(AvahiInterface *i) {
assert(i);
- while (i->queriers)
+ while (i->queriers)
avahi_querier_free(i->queriers);
}
#ifndef fooquerierhfoo
#define fooquerierhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiQueryJob {
unsigned id;
int n_posted;
-
+
AvahiQueryScheduler *scheduler;
AvahiTimeEvent *time_event;
-
+
int done;
struct timeval delivery;
* entries) most of the time, but this might be a wrong
* assumption, especially on setups where traffic reflection is
* involved. */
-
+
AVAHI_LLIST_FIELDS(AvahiQueryJob, jobs);
};
static AvahiQueryJob* job_new(AvahiQueryScheduler *s, AvahiKey *key, int done) {
AvahiQueryJob *qj;
-
+
assert(s);
assert(key);
avahi_log_error(__FILE__": Out of memory");
return NULL;
}
-
+
qj->scheduler = s;
qj->key = avahi_key_ref(key);
qj->time_event = NULL;
qj->n_posted = 1;
qj->id = s->next_id++;
-
- if ((qj->done = done))
+
+ if ((qj->done = done))
AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->history, qj);
else
AVAHI_LLIST_PREPEND(AvahiQueryJob, jobs, s->jobs, qj);
avahi_log_error(__FILE__": Out of memory");
return NULL; /* OOM */
}
-
+
s->interface = i;
s->time_event_queue = i->monitor->server->time_event_queue;
s->next_id = 0;
-
+
AVAHI_LLIST_HEAD_INIT(AvahiQueryJob, s->jobs);
AVAHI_LLIST_HEAD_INIT(AvahiQueryJob, s->history);
AVAHI_LLIST_HEAD_INIT(AvahiKnownAnswer, s->known_answers);
void avahi_query_scheduler_clear(AvahiQueryScheduler *s) {
assert(s);
-
+
while (s->jobs)
job_free(s, s->jobs);
while (s->history)
static void* known_answer_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) {
AvahiQueryScheduler *s = userdata;
AvahiKnownAnswer *ka;
-
+
assert(c);
assert(pattern);
assert(e);
if (avahi_cache_entry_half_ttl(c, e))
return NULL;
-
+
if (!(ka = avahi_new0(AvahiKnownAnswer, 1))) {
avahi_log_error(__FILE__": Out of memory");
return NULL;
}
-
+
ka->scheduler = s;
ka->record = avahi_record_ref(e->record);
/* Add all matching known answers to the list */
avahi_cache_walk(s->interface->cache, qj->key, known_answer_walk_callback, s);
-
+
job_mark_done(s, qj);
return 1;
assert(p);
n = 0;
-
+
while ((ka = s->known_answers)) {
int too_large = 0;
if (!too_large)
n++;
}
-
+
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ANCOUNT, n);
avahi_interface_send_packet(s->interface, p);
avahi_dns_packet_free(p);
}
assert(!s->known_answers);
-
+
if (!(p = avahi_dns_packet_new_query(s->interface->hardware->mtu)))
return; /* OOM */
-
+
b = packet_add_query_job(s, p, qj);
assert(b); /* An query must always fit in */
n = 1;
for (qj = s->jobs; qj; qj = qj->jobs_next) {
assert(!qj->done);
-
+
if (avahi_key_equal(qj->key, key))
return qj;
}
static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) {
AvahiQueryJob *qj;
-
+
assert(s);
assert(key);
job_free(s, qj);
return NULL;
}
-
+
return qj;
}
}
int avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, int immediately, unsigned *ret_id) {
struct timeval tv;
AvahiQueryJob *qj;
-
+
assert(s);
assert(key);
if ((qj = find_history_job(s, key)))
return 0;
-
+
avahi_elapse_time(&tv, immediately ? 0 : AVAHI_QUERY_DEFER_MSEC, 0);
if ((qj = find_scheduled_job(s, key))) {
}
qj->n_posted++;
-
+
} else {
if (!(qj = job_new(s, key, 0)))
return 0; /* OOM */
-
+
qj->delivery = tv;
qj->time_event = avahi_time_event_new(s->time_event_queue, &qj->delivery, elapse_callback, qj);
}
if (ret_id)
*ret_id = qj->id;
-
+
return 1;
}
void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) {
AvahiQueryJob *qj;
-
+
assert(s);
assert(key);
if (!(qj = find_history_job(s, key)))
if (!(qj = job_new(s, key, 1)))
return; /* OOM */
-
+
gettimeofday(&qj->delivery, NULL);
job_set_elapse_time(s, qj, AVAHI_QUERY_HISTORY_MSEC, 0);
}
int avahi_query_scheduler_withdraw_by_id(AvahiQueryScheduler *s, unsigned id) {
AvahiQueryJob *qj;
-
+
assert(s);
/* Very short lived queries can withdraw an already scheduled item
for (qj = s->jobs; qj; qj = qj->jobs_next) {
assert(!qj->done);
-
+
if (qj->id == id) {
/* Entry found */
* case since there should exist only one querier per
* key, but there are exceptions, notably reflected
* traffic.) */
-
+
job_free(s, qj);
return 1;
}
#ifndef fooqueryschedhfoo
#define fooqueryschedhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiSAddressResolver {
AvahiServer *server;
AvahiAddress address;
-
+
AvahiSRecordBrowser *record_browser;
AvahiSAddressResolverCallback callback;
static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) {
assert(r);
-
+
if (r->time_event) {
avahi_time_event_free(r->time_event);
r->time_event = NULL;
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
AvahiSAddressResolver *r = userdata;
-
+
assert(e);
assert(r);
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSAddressResolver *r = userdata;
assert(rr);
assert(r);
switch (event) {
- case AVAHI_BROWSER_NEW:
+ case AVAHI_BROWSER_NEW:
assert(record);
assert(record->key->type == AVAHI_DNS_TYPE_PTR);
-
+
if (r->interface > 0 && interface != r->interface)
return;
-
+
if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
return;
-
+
if (r->interface <= 0)
r->interface = interface;
-
+
if (r->protocol == AVAHI_PROTO_UNSPEC)
r->protocol = protocol;
-
+
if (!r->ptr_record) {
r->ptr_record = avahi_record_ref(record);
r->flags = flags;
-
+
finish(r, AVAHI_RESOLVER_FOUND);
}
break;
-
+
case AVAHI_BROWSER_REMOVE:
assert(record);
assert(record->key->type == AVAHI_DNS_TYPE_PTR);
-
+
if (r->ptr_record && avahi_record_equal_no_ttl(record, r->ptr_record)) {
avahi_record_unref(r->ptr_record);
r->ptr_record = NULL;
r->flags = flags;
-
+
/** Look for a replacement */
avahi_s_record_browser_restart(r->record_browser);
start_timeout(r);
}
break;
-
+
case AVAHI_BROWSER_CACHE_EXHAUSTED:
case AVAHI_BROWSER_ALL_FOR_NOW:
break;
AvahiLookupFlags flags,
AvahiSAddressResolverCallback callback,
void* userdata) {
-
+
AvahiSAddressResolver *r;
AvahiKey *k;
char n[AVAHI_DOMAIN_NAME_MAX];
AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
AVAHI_CHECK_VALIDITY_RETURN_NULL(server, address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6, AVAHI_ERR_INVALID_PROTOCOL);
AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
-
+
avahi_reverse_lookup_name(address, n, sizeof(n));
if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
avahi_key_unref(k);
return NULL;
}
-
+
r->server = server;
r->address = *address;
r->callback = callback;
r->retry_with_multicast = 1;
}
}
-
+
r->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
if (!r->record_browser) {
}
start_timeout(r);
-
+
return r;
}
if (r->key)
avahi_key_unref(r->key);
-
+
avahi_free(r);
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiSHostNameResolver {
AvahiServer *server;
char *host_name;
-
+
AvahiSRecordBrowser *record_browser_a;
AvahiSRecordBrowser *record_browser_aaaa;
switch (event) {
case AVAHI_RESOLVER_FOUND: {
AvahiAddress a;
-
+
assert(r->address_record);
-
+
switch (r->address_record->key->type) {
case AVAHI_DNS_TYPE_A:
a.proto = AVAHI_PROTO_INET;
a.data.ipv4 = r->address_record->data.a.address;
break;
-
+
case AVAHI_DNS_TYPE_AAAA:
a.proto = AVAHI_PROTO_INET6;
a.data.ipv6 = r->address_record->data.aaaa.address;
break;
-
+
default:
abort();
}
break;
}
-
+
case AVAHI_RESOLVER_FAILURE:
-
+
r->callback(r, r->interface, r->protocol, event, r->host_name, NULL, r->flags, r->userdata);
break;
}
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
AvahiSHostNameResolver *r = userdata;
-
+
assert(e);
assert(r);
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSHostNameResolver *r = userdata;
-
+
assert(rr);
assert(r);
if (r->interface > 0 && interface != r->interface)
return;
-
+
if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
return;
-
+
if (r->interface <= 0)
r->interface = interface;
-
+
if (r->protocol == AVAHI_PROTO_UNSPEC)
r->protocol = protocol;
-
+
if (!r->address_record) {
r->address_record = avahi_record_ref(record);
r->flags = flags;
-
+
finish(r, AVAHI_RESOLVER_FOUND);
}
r->flags = flags;
-
+
/** Look for a replacement */
if (r->record_browser_aaaa)
avahi_s_record_browser_restart(r->record_browser_aaaa);
if (r->record_browser_a)
avahi_s_record_browser_restart(r->record_browser_a);
-
+
start_timeout(r);
}
case AVAHI_BROWSER_FAILURE:
/* Stop browsers */
-
+
if (r->record_browser_aaaa)
avahi_s_record_browser_free(r->record_browser_aaaa);
if (r->record_browser_a)
r->record_browser_a = r->record_browser_aaaa = NULL;
r->flags = flags;
-
+
finish(r, AVAHI_RESOLVER_FAILURE);
break;
}
AvahiLookupFlags flags,
AvahiSHostNameResolverCallback callback,
void* userdata) {
-
+
AvahiSHostNameResolver *r;
AvahiKey *k;
-
+
assert(server);
assert(host_name);
assert(callback);
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
r->server = server;
r->host_name = avahi_normalize_name_strdup(host_name);
r->callback = callback;
if (!r->record_browser_a)
goto fail;
- }
+ }
if (aprotocol == AVAHI_PROTO_INET6 || aprotocol == AVAHI_PROTO_UNSPEC) {
k = avahi_key_new(host_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA);
assert(r->record_browser_aaaa || r->record_browser_a);
start_timeout(r);
-
+
return r;
fail:
if (r->address_record)
avahi_record_unref(r->address_record);
-
+
avahi_free(r->host_name);
avahi_free(r);
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiRecord *srv_record, *txt_record, *address_record;
AvahiLookupResultFlags srv_flags, txt_flags, address_flags;
-
+
AvahiSServiceResolverCallback callback;
void* userdata;
AvahiLookupFlags user_flags;
static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) {
AvahiLookupResultFlags flags;
-
+
assert(r);
if (r->time_event) {
r->txt_flags |
r->srv_flags |
r->address_flags;
-
+
switch (event) {
case AVAHI_RESOLVER_FAILURE:
-
+
r->callback(
r,
r->interface,
case AVAHI_RESOLVER_FOUND: {
AvahiAddress a;
-
+
assert(event == AVAHI_RESOLVER_FOUND);
-
+
assert(r->srv_record);
if (r->address_record) {
a.proto = AVAHI_PROTO_INET;
a.data.ipv4 = r->address_record->data.a.address;
break;
-
+
case AVAHI_DNS_TYPE_AAAA:
a.proto = AVAHI_PROTO_INET6;
a.data.ipv6 = r->address_record->data.aaaa.address;
break;
-
+
default:
assert(0);
}
}
-
+
r->callback(
r,
r->interface,
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
AvahiSServiceResolver *r = userdata;
-
+
assert(e);
assert(r);
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiSServiceResolver *r = userdata;
assert(rr);
case AVAHI_BROWSER_NEW: {
int changed = 0;
assert(record);
-
+
if (r->interface > 0 && interface > 0 && interface != r->interface)
return;
-
+
if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
return;
-
+
if (r->interface <= 0)
r->interface = interface;
-
+
if (r->protocol == AVAHI_PROTO_UNSPEC)
r->protocol = protocol;
-
+
switch (record->key->type) {
case AVAHI_DNS_TYPE_SRV:
if (!r->srv_record) {
r->srv_record = avahi_record_ref(record);
changed = 1;
-
+
if (r->record_browser_a) {
avahi_s_record_browser_free(r->record_browser_a);
r->record_browser_a = NULL;
}
-
+
if (r->record_browser_aaaa) {
avahi_s_record_browser_free(r->record_browser_aaaa);
r->record_browser_aaaa = NULL;
AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A);
r->record_browser_a = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r);
avahi_key_unref(k);
- }
-
+ }
+
if (r->address_protocol == AVAHI_PROTO_INET6 || r->address_protocol == AVAHI_PROTO_UNSPEC) {
AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA);
r->record_browser_aaaa = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r);
}
}
break;
-
+
case AVAHI_DNS_TYPE_TXT:
assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT));
changed = 1;
}
break;
-
+
case AVAHI_DNS_TYPE_A:
case AVAHI_DNS_TYPE_AAAA:
changed = 1;
}
break;
-
+
default:
abort();
}
break;
}
-
+
case AVAHI_BROWSER_REMOVE:
assert(record);
switch (record->key->type) {
case AVAHI_DNS_TYPE_SRV:
-
+
if (r->srv_record && avahi_record_equal_no_ttl(record, r->srv_record)) {
avahi_record_unref(r->srv_record);
r->srv_record = NULL;
avahi_s_record_browser_free(r->record_browser_a);
r->record_browser_a = NULL;
}
-
+
if (r->record_browser_aaaa) {
avahi_s_record_browser_free(r->record_browser_aaaa);
r->record_browser_aaaa = NULL;
}
-
+
/** Look for a replacement */
avahi_s_record_browser_restart(r->record_browser_srv);
start_timeout(r);
}
-
+
break;
-
+
case AVAHI_DNS_TYPE_TXT:
-
+
assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT));
-
+
if (r->txt_record && avahi_record_equal_no_ttl(record, r->txt_record)) {
avahi_record_unref(r->txt_record);
r->txt_record = NULL;
-
+
/** Look for a replacement */
avahi_s_record_browser_restart(r->record_browser_txt);
start_timeout(r);
}
break;
-
+
case AVAHI_DNS_TYPE_A:
case AVAHI_DNS_TYPE_AAAA:
-
+
assert(!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS));
-
+
if (r->address_record && avahi_record_equal_no_ttl(record, r->address_record)) {
avahi_record_unref(r->address_record);
r->address_record = NULL;
-
+
/** Look for a replacement */
if (r->record_browser_aaaa)
avahi_s_record_browser_restart(r->record_browser_aaaa);
start_timeout(r);
}
break;
-
+
default:
abort();
}
break;
case AVAHI_BROWSER_FAILURE:
-
+
if (rr == r->record_browser_a && r->record_browser_aaaa) {
/* We were looking for both AAAA and A, and the other query is still living, so we'll not die */
avahi_s_record_browser_free(r->record_browser_a);
}
/* Hmm, everything's lost, tell the user */
-
+
if (r->record_browser_srv)
avahi_s_record_browser_free(r->record_browser_srv);
if (r->record_browser_txt)
AvahiLookupFlags flags,
AvahiSServiceResolverCallback callback,
void* userdata) {
-
+
AvahiSServiceResolver *r;
AvahiKey *k;
char n[AVAHI_DOMAIN_NAME_MAX];
int ret;
-
+
assert(server);
assert(type);
assert(callback);
avahi_server_set_errno(server, ret);
return NULL;
}
-
+
if (!(r = avahi_new(AvahiSServiceResolver, 1))) {
avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
return NULL;
}
-
+
r->server = server;
r->service_name = avahi_strdup(name);
r->service_type = avahi_normalize_name_strdup(type);
k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT);
r->record_browser_txt = avahi_s_record_browser_new(server, interface, protocol, k, flags & ~(AVAHI_LOOKUP_NO_TXT|AVAHI_LOOKUP_NO_ADDRESS), record_browser_callback, r);
avahi_key_unref(k);
-
+
if (!r->record_browser_txt) {
avahi_s_service_resolver_free(r);
return NULL;
}
start_timeout(r);
-
+
return r;
}
if (r->time_event)
avahi_time_event_free(r->time_event);
-
+
if (r->record_browser_srv)
avahi_s_record_browser_free(r->record_browser_srv);
if (r->record_browser_txt)
avahi_record_unref(r->txt_record);
if (r->address_record)
avahi_record_unref(r->address_record);
-
+
avahi_free(r->service_name);
avahi_free(r->service_type);
avahi_free(r->domain_name);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiResponseJob {
AvahiResponseScheduler *scheduler;
AvahiTimeEvent *time_event;
-
+
AvahiResponseJobState state;
struct timeval delivery;
int flush_cache;
AvahiAddress querier;
int querier_valid;
-
+
AVAHI_LLIST_FIELDS(AvahiResponseJob, jobs);
};
static AvahiResponseJob* job_new(AvahiResponseScheduler *s, AvahiRecord *record, AvahiResponseJobState state) {
AvahiResponseJob *rj;
-
+
assert(s);
assert(record);
avahi_log_error(__FILE__": Out of memory");
return NULL;
}
-
+
rj->scheduler = s;
rj->record = avahi_record_ref(record);
rj->time_event = NULL;
rj->flush_cache = 0;
rj->querier_valid = 0;
-
- if ((rj->state = state) == AVAHI_SCHEDULED)
+
+ if ((rj->state = state) == AVAHI_SCHEDULED)
AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->jobs, rj);
else if (rj->state == AVAHI_DONE)
AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->history, rj);
avahi_log_error(__FILE__": Out of memory");
return NULL;
}
-
+
s->interface = i;
s->time_event_queue = i->monitor->server->time_event_queue;
-
+
AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->jobs);
AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->history);
AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->suppressed);
void avahi_response_scheduler_clear(AvahiResponseScheduler *s) {
assert(s);
-
+
while (s->jobs)
job_free(s, s->jobs);
while (s->history)
static void enumerate_aux_records_callback(AVAHI_GCC_UNUSED AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata) {
AvahiResponseJob *rj = userdata;
-
+
assert(r);
assert(rj);
* auxilliary packets, too */
avahi_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj);
job_mark_done(s, rj);
-
+
return 1;
}
/* Try to fill up packet with more responses, if available */
while (s->jobs) {
-
+
if (!packet_add_response_job(s, p, s->jobs))
break;
-
+
n++;
}
-
+
} else {
size_t size;
-
+
avahi_dns_packet_free(p);
/* OK, the packet was too small, so create one that fits */
assert(rj);
- if (rj->state == AVAHI_DONE || rj->state == AVAHI_SUPPRESSED)
+ if (rj->state == AVAHI_DONE || rj->state == AVAHI_SUPPRESSED)
job_free(rj->scheduler, rj); /* Lets drop this entry */
else
send_response_packet(rj->scheduler, rj);
for (rj = s->jobs; rj; rj = rj->jobs_next) {
assert(rj->state == AVAHI_SCHEDULED);
-
+
if (avahi_record_equal_no_ttl(rj->record, record))
return rj;
}
static AvahiResponseJob* find_history_job(AvahiResponseScheduler *s, AvahiRecord *record) {
AvahiResponseJob *rj;
-
+
assert(s);
assert(record);
/* Check whether this entry is outdated */
/* avahi_log_debug("history age: %u", (unsigned) (avahi_age(&rj->delivery)/1000)); */
-
+
if (avahi_age(&rj->delivery)/1000 > AVAHI_RESPONSE_HISTORY_MSEC) {
/* it is outdated, so let's remove it */
job_free(s, rj);
return NULL;
}
-
+
return rj;
}
}
static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) {
AvahiResponseJob *rj;
-
+
assert(s);
assert(record);
assert(querier);
for (rj = s->suppressed; rj; rj = rj->jobs_next) {
assert(rj->state == AVAHI_SUPPRESSED);
assert(rj->querier_valid);
-
+
if (avahi_record_equal_no_ttl(rj->record, record) &&
avahi_address_cmp(&rj->querier, querier) == 0) {
/* Check whether this entry is outdated */
AvahiResponseJob *rj;
struct timeval tv;
/* char *t; */
-
+
assert(s);
assert(record);
}
avahi_elapse_time(&tv, immediately ? 0 : AVAHI_RESPONSE_DEFER_MSEC, immediately ? 0 : AVAHI_RESPONSE_JITTER_MSEC);
-
+
if ((rj = find_scheduled_job(s, record))) {
/* avahi_log_debug("Response suppressed by local duplicate suppression (scheduled)"); */
/* Create a new job and schedule it */
if (!(rj = job_new(s, record, AVAHI_SCHEDULED)))
return 0; /* OOM */
-
+
rj->delivery = tv;
rj->time_event = avahi_time_event_new(s->time_event_queue, &rj->delivery, elapse_callback, rj);
rj->flush_cache = flush_cache;
/* This function is called whenever an incoming response was
* receieved. We drop scheduled responses which match here. The
* keyword is "DUPLICATE ANSWER SUPPRESION". */
-
+
if ((rj = find_scheduled_job(s, record))) {
if ((!rj->flush_cache || flush_cache) && /* flush cache bit was set correctly */
rj->flush_cache = flush_cache;
rj->querier_valid = 0;
-
+
gettimeofday(&rj->delivery, NULL);
job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
}
void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) {
AvahiResponseJob *rj;
-
+
assert(s);
assert(record);
assert(querier);
if ((rj = find_scheduled_job(s, record))) {
-
+
if (rj->querier_valid && avahi_address_cmp(querier, &rj->querier) == 0 && /* same originator */
avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) && /* both goodbye packets, or both not */
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* Let's update the old entry */
avahi_record_unref(rj->record);
rj->record = avahi_record_ref(record);
-
+
} else {
/* Create a new entry */
#ifndef fooresponseschedhfoo
#define fooresponseschedhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef foorrutilhfoo
#define foorrutilhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include "hashmap.h"
#include "domain-util.h"
#include "rr-util.h"
+#include "addr-util.h"
AvahiKey *avahi_key_new(const char *name, uint16_t class, uint16_t type) {
AvahiKey *k;
avahi_log_error("avahi_new() failed.");
return NULL;
}
-
+
if (!(k->name = avahi_normalize_name_strdup(name))) {
avahi_log_error("avahi_normalize_name() failed.");
avahi_free(k);
return NULL;
}
-
+
k->ref = 1;
k->clazz = class;
k->type = type;
void avahi_key_unref(AvahiKey *k) {
assert(k);
assert(k->ref >= 1);
-
+
if ((--k->ref) <= 0) {
avahi_free(k->name);
avahi_free(k);
AvahiRecord *avahi_record_new(AvahiKey *k, uint32_t ttl) {
AvahiRecord *r;
-
+
assert(k);
-
+
if (!(r = avahi_new(AvahiRecord, 1))) {
avahi_log_error("avahi_new() failed.");
return NULL;
}
-
+
r->ref = 1;
r->key = avahi_key_ref(k);
AvahiKey *k;
assert(name);
-
+
if (!(k = avahi_key_new(name, class, type))) {
avahi_log_error("avahi_key_new() failed.");
return NULL;
case AVAHI_DNS_TYPE_A:
case AVAHI_DNS_TYPE_AAAA:
break;
-
+
default:
avahi_free(r->data.generic.data);
}
-
+
avahi_key_unref(r->key);
avahi_free(r);
}
}
const char *avahi_dns_class_to_string(uint16_t class) {
- if (class & AVAHI_DNS_CACHE_FLUSH)
+ if (class & AVAHI_DNS_CACHE_FLUSH)
return "FLUSH";
switch (class) {
char *avahi_key_to_string(const AvahiKey *k) {
char class[16], type[16];
const char *c, *t;
-
+
assert(k);
assert(k->ref >= 1);
/* According to RFC3597 */
-
+
if (!(c = avahi_dns_class_to_string(k->clazz))) {
snprintf(class, sizeof(class), "CLASS%u", k->clazz);
c = class;
snprintf(type, sizeof(type), "TYPE%u", k->type);
t = type;
}
-
+
return avahi_strdup_printf("%s\t%s\t%s", k->name, c, t);
}
assert(r);
assert(r->ref >= 1);
-
+
switch (r->key->type) {
case AVAHI_DNS_TYPE_A:
inet_ntop(AF_INET, &r->data.a.address.address, t = buf, sizeof(buf));
break;
-
+
case AVAHI_DNS_TYPE_AAAA:
inet_ntop(AF_INET6, &r->data.aaaa.address.address, t = buf, sizeof(buf));
break;
-
+
case AVAHI_DNS_TYPE_PTR:
case AVAHI_DNS_TYPE_CNAME:
case AVAHI_DNS_TYPE_NS:
char *e;
/* According to RFC3597 */
-
+
snprintf(t = buf, sizeof(buf), "\\# %u", r->data.generic.size);
e = strchr(t, 0);
-
+
for (c = r->data.generic.data, n = r->data.generic.size, i = 0;
n > 0 && i < 20;
c ++, n --, i++) {
s = avahi_strdup_printf("%s %s ; ttl=%u", p, t, r->ttl);
avahi_free(p);
avahi_free(d);
-
+
return s;
}
if (a == b)
return 1;
-
+
return avahi_domain_equal(a->name, b->name) &&
a->type == b->type &&
a->clazz == b->clazz;
if (pattern == k)
return 1;
-
+
return avahi_domain_equal(pattern->name, k->name) &&
(pattern->type == k->type || pattern->type == AVAHI_DNS_TYPE_ANY) &&
(pattern->clazz == k->clazz || pattern->clazz == AVAHI_DNS_CLASS_ANY);
assert(k);
return
- avahi_domain_hash(k->name) +
+ avahi_domain_hash(k->name) +
k->type +
k->clazz;
}
return a->data.generic.size == b->data.generic.size &&
(a->data.generic.size == 0 || memcmp(a->data.generic.data, b->data.generic.data, a->data.generic.size) == 0);
}
-
+
}
int avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b) {
avahi_log_error("avahi_new() failed.");
return NULL;
}
-
+
copy->ref = 1;
copy->key = avahi_key_ref(r->key);
copy->ttl = r->ttl;
goto fail;
copy->data.generic.size = r->data.generic.size;
break;
-
+
}
return copy;
avahi_key_unref(copy->key);
avahi_free(copy);
-
+
return NULL;
}
static int lexicographical_memcmp(const void* a, size_t al, const void* b, size_t bl) {
size_t c;
int ret;
-
+
assert(a);
assert(b);
(r = uint16_cmp(a->data.srv.weight, b->data.srv.weight)) == 0 &&
(r = uint16_cmp(a->data.srv.port, b->data.srv.port)) == 0)
r = avahi_binary_domain_cmp(a->data.srv.name, b->data.srv.name);
-
+
return r;
}
asize = avahi_string_list_serialize(a->data.txt.string_list, NULL, 0);
bsize = avahi_string_list_serialize(b->data.txt.string_list, NULL, 0);
-
+
if (asize > 0 && !(ma = avahi_new(uint8_t, asize)))
goto fail;
-
+
if (bsize > 0 && !(mb = avahi_new(uint8_t, bsize))) {
avahi_free(ma);
goto fail;
}
-
+
avahi_string_list_serialize(a->data.txt.string_list, ma, asize);
avahi_string_list_serialize(b->data.txt.string_list, mb, bsize);
r = -1;
else
r = 0;
-
+
avahi_free(ma);
avahi_free(mb);
return r;
}
-
+
case AVAHI_DNS_TYPE_A:
return memcmp(&a->data.a.address, &b->data.a.address, sizeof(AvahiIPv4Address));
b->data.generic.data, b->data.generic.size);
}
-
+
fail:
avahi_log_error(__FILE__": Out of memory");
return -1; /* or whatever ... */
if (!avahi_is_valid_domain_name(k->name))
return 0;
-
+
return 1;
}
return
strlen(r->data.hinfo.os) <= 255 &&
strlen(r->data.hinfo.cpu) <= 255;
-
+
case AVAHI_DNS_TYPE_TXT: {
AvahiStringList *strlst;
return 1;
}
}
-
return 1;
}
+
+static AvahiAddress *get_address(const AvahiRecord *r, AvahiAddress *a) {
+ assert(r);
+
+ switch (r->key->type) {
+ case AVAHI_DNS_TYPE_A:
+ a->proto = AVAHI_PROTO_INET;
+ a->data.ipv4 = r->data.a.address;
+ break;
+
+ case AVAHI_DNS_TYPE_AAAA:
+ a->proto = AVAHI_PROTO_INET6;
+ a->data.ipv6 = r->data.aaaa.address;
+ break;
+
+ default:
+ return NULL;
+ }
+
+ return a;
+}
+
+int avahi_record_is_link_local_address(const AvahiRecord *r) {
+ AvahiAddress a;
+
+ assert(r);
+
+ if (!get_address(r, &a))
+ return 0;
+
+ return avahi_address_is_link_local(&a);
+}
#ifndef foorrhfoo
#define foorrhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
enum {
AVAHI_DNS_TYPE_ANY = 0xFF, /**< Special query type for requesting all records */
AVAHI_DNS_TYPE_OPT = 41, /**< EDNS0 option */
- AVAHI_DNS_TYPE_TKEY = 249,
- AVAHI_DNS_TYPE_TSIG = 250,
+ AVAHI_DNS_TYPE_TKEY = 249,
+ AVAHI_DNS_TYPE_TSIG = 250,
AVAHI_DNS_TYPE_IXFR = 251,
AVAHI_DNS_TYPE_AXFR = 252
};
typedef struct AvahiRecord {
int ref; /**< Reference counter */
AvahiKey *key; /**< Reference to the query key of this record */
-
+
uint32_t ttl; /**< DNS TTL of this record */
union {
-
+
struct {
void* data;
uint16_t size;
} generic; /**< Generic record data for unknown types */
-
+
struct {
uint16_t priority;
uint16_t weight;
} aaaa; /**< Data for AAAA records */
} data; /**< Record data */
-
+
} AvahiRecord;
/** Create a new AvahiKey object. The reference counter will be set to 1. */
/** Check whether two AvahiKey object contain the same
* data. AVAHI_DNS_CLASS_ANY/AVAHI_DNS_TYPE_ANY are treated like any
* other class/type. */
-int avahi_key_equal(const AvahiKey *a, const AvahiKey *b);
+int avahi_key_equal(const AvahiKey *a, const AvahiKey *b);
/** Return a numeric hash value for a key for usage in hash tables. */
unsigned avahi_key_hash(const AvahiKey *k);
/** Create a textual representation of the specified record, similar
* in style to BIND zone file data. avahi_free() the result! */
-char *avahi_record_to_string(const AvahiRecord *r);
+char *avahi_record_to_string(const AvahiRecord *r);
/** Check whether two records are equal (regardless of the TTL */
int avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b);
/** Serialize an AvahiRecord object into binary rdata. This function is actually implemented in dns.c */
size_t avahi_rdata_serialize(AvahiRecord *record, void *rdata, size_t max_size);
+/** Return TRUE if the AvahiRecord object is a link-local A or AAAA address */
+int avahi_record_is_link_local_address(const AvahiRecord *r);
+
AVAHI_C_DECL_END
#endif
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
avahi_log_error("avahi_new() failed.");
return NULL;
}
-
+
AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->read);
AVAHI_LLIST_HEAD_INIT(AvahiRecordListItem, l->unread);
assert(l);
assert(i);
- if (i->read)
+ if (i->read)
AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->read, i);
else
AVAHI_LLIST_REMOVE(AvahiRecordListItem, items, l->unread, i);
-
+
avahi_record_unref(i->record);
avahi_free(i);
}
void avahi_record_list_flush(AvahiRecordList *l) {
assert(l);
-
+
while (l->read)
item_free(l, l->read);
while (l->unread)
return NULL;
assert(!i->read);
-
+
r = avahi_record_ref(i->record);
if (ret_unicast_response)
*ret_unicast_response = i->unicast_response;
AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->read, i);
i->read = 1;
-
+
return r;
}
assert(l);
assert(r);
-
+
for (i = l->read; i; i = i->items_next)
if (avahi_record_equal_no_ttl(i->record, r))
return i;
void avahi_record_list_push(AvahiRecordList *l, AvahiRecord *r, int flush_cache, int unicast_response, int auxiliary) {
AvahiRecordListItem *i;
-
+
assert(l);
assert(r);
avahi_log_error("avahi_new() failed.");
return;
}
-
+
i->unicast_response = unicast_response;
i->flush_cache = flush_cache;
i->auxiliary = auxiliary;
i->read = 0;
l->all_flush_cache = l->all_flush_cache && flush_cache;
-
+
AVAHI_LLIST_PREPEND(AvahiRecordListItem, items, l->unread, i);
}
int avahi_record_list_is_empty(AvahiRecordList *l) {
assert(l);
-
+
return !l->unread && !l->read;
}
assert(l);
/* Return TRUE if all entries in this list have flush_cache set */
-
+
return l->all_flush_cache;
}
#ifndef foorrlisthfoo
#define foorrlisthfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
#include "domain-util.h"
#include "rr-util.h"
+#define AVAHI_DEFAULT_CACHE_ENTRIES_MAX 4096
+
static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name, uint16_t type, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata) {
assert(s);
assert(i);
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT); n > 0; n--) {
AvahiRecord *record;
int cache_flush = 0;
-/* char *txt; */
if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) {
avahi_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)");
if (!avahi_key_is_pattern(record->key)) {
if (handle_conflict(s, i, record, cache_flush)) {
- if (!from_local_iface)
+ if (!from_local_iface && !avahi_record_is_link_local_address(record))
reflect_response(s, i, record, cache_flush);
avahi_cache_update(i->cache, record, cache_flush, a);
avahi_response_scheduler_incoming(i->response_scheduler, record, cache_flush);
}
/* If the incoming response contained a conflicting record, some
- records have been scheduling for sending. We need to flush them
+ records have been scheduled for sending. We need to flush them
here. */
if (!avahi_record_list_is_empty(s->record_list))
avahi_server_generate_response(s, i, NULL, NULL, 0, 0, 1);
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id);
}
-static void cleanup_dead(AvahiServer *s) {
- assert(s);
-
- avahi_cleanup_dead_entries(s);
- avahi_browser_cleanup(s);
-}
-
static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, void *userdata) {
AvahiServer *s = userdata;
AvahiAddress dest, src;
if (iface != AVAHI_IF_UNSPEC)
dispatch_packet(s, p, &src, port, &dest, iface, ttl);
else
- avahi_log_error("Incoming packet recieved on address that isn't local.");
+ avahi_log_error("Incoming packet received on address that isn't local.");
avahi_dns_packet_free(p);
- cleanup_dead(s);
+ avahi_cleanup_dead_entries(s);
}
}
dispatch_legacy_unicast_packet(s, p);
avahi_dns_packet_free(p);
- cleanup_dead(s);
+ avahi_cleanup_dead_entries(s);
}
}
c->allow_point_to_point = 0;
c->publish_aaaa_on_ipv4 = 1;
c->publish_a_on_ipv6 = 0;
+ c->n_cache_entries_max = AVAHI_DEFAULT_CACHE_ENTRIES_MAX;
return c;
}
-/* $Id$ */
-
/***
This file is part of avahi.
if (sendmsg(fd, msg, flags) >= 0)
break;
+ if (errno == EINTR)
+ continue;
+
if (errno != EAGAIN) {
char where[64];
struct sockaddr_in *sin = msg->msg_name;
goto fail;
}
+ /* For corrupt packets FIONREAD returns zero size (See rhbz #607297) */
+ if (!ms)
+ goto fail;
+
p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE);
io.iov_base = AVAHI_DNS_PACKET_DATA(p);
goto fail;
}
+ /* For corrupt packets FIONREAD returns zero size (See rhbz #607297) */
+ if (!ms)
+ goto fail;
+
p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE);
io.iov_base = AVAHI_DNS_PACKET_DATA(p);
#ifndef foosockethfoo
#define foosockethfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include "timeeventq.h"
#include "log.h"
-#define POINTER_TO_INT(p) ((int) (p))
-#define INT_TO_POINTER(i) ((void*) (i))
+#define POINTER_TO_INT(p) ((int) (long) (p))
+#define INT_TO_POINTER(i) ((void*) (long) (i))
static AvahiTimeEventQueue *q = NULL;
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct timeval now;
gettimeofday(&now, NULL);
-
+
/* Check if expired */
if (avahi_timeval_compare(&now, &e->expiry) >= 0) {
update_timeout(q);
return;
- }
+ }
}
avahi_log_debug(__FILE__": Strange, expiration_event() called, but nothing really happened.");
if (!(q->prioq = avahi_prio_queue_new(compare)))
goto oom;
- if (!(q->timeout = poll_api->timeout_new(poll_api, NULL, expiration_event, q)))
+ if (!(q->timeout = poll_api->timeout_new(poll_api, NULL, expiration_event, q)))
goto oom;
-
+
return q;
oom:
if (q->prioq)
avahi_prio_queue_free(q->prioq);
}
-
+
return NULL;
}
void avahi_time_event_queue_free(AvahiTimeEventQueue *q) {
AvahiTimeEvent *e;
-
+
assert(q);
while ((e = time_event_queue_root(q)))
avahi_prio_queue_free(q->prioq);
q->poll_api->timeout_free(q->timeout);
-
+
avahi_free(q);
}
const struct timeval *timeval,
AvahiTimeEventCallback callback,
void* userdata) {
-
+
AvahiTimeEvent *e;
-
+
assert(q);
assert(callback);
assert(userdata);
avahi_log_error(__FILE__": Out of memory");
return NULL; /* OOM */
}
-
+
e->queue = q;
e->callback = callback;
e->userdata = userdata;
e->expiry.tv_sec = 0;
e->expiry.tv_usec = 0;
}
-
+
fix_expiry_time(e);
-
+
e->last_run.tv_sec = 0;
e->last_run.tv_usec = 0;
e->expiry = *timeval;
fix_expiry_time(e);
avahi_prio_queue_shuffle(e->queue->prioq, e->node);
-
+
update_timeout(e->queue);
}
#ifndef footimeeventqhfoo
#define footimeeventqhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static void server_callback(AvahiServer *s, AvahiServerState state, AVAHI_GCC_UNUSED void* userdata) {
- avahi_log_debug("server state: %i", state);
-
+ avahi_log_debug("server state: %i", state);
+
if (state == AVAHI_SERVER_RUNNING) {
int ret;
-
+
group = avahi_s_entry_group_new(s, NULL, NULL);
assert(group);
AvahiServer *s = userdata;
avahi_log_debug("modifying");
-
+
ret = avahi_server_update_service_txt(s, group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, "test2", NULL);
assert(ret == AVAHI_OK);
}
simple_poll = avahi_simple_poll_new();
assert(simple_poll);
-
+
poll_api = avahi_simple_poll_get(simple_poll);
assert(poll_api);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
assert(p);
printf("Dumping %lu bytes from %p:\n", (unsigned long) size, p);
-
+
while (size > 0) {
unsigned i;
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
if (i < size)
printf("%02x ", c[i]);
else
else
printf(" ");
}
-
+
printf("\n");
c += 16;
if (size <= 16)
break;
-
+
size -= 16;
}
}
assert(r);
assert(l > 0);
assert(mac);
-
+
if (size <= 0) {
*r = 0;
return r;
}
-
+
for (i = 0; i < size; i++) {
if (l < 3)
break;
-
+
*(t++) = hex[*mac >> 4];
*(t++) = hex[*mac & 0xF];
*(t++) = ':';
l -= 3;
-
+
mac++;
}
*(t-1) = 0;
else
*r = 0;
-
+
return r;
}
#ifndef fooutilhfoo
#define fooutilhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiWideAreaCacheEntry {
AvahiWideAreaLookupEngine *engine;
-
+
AvahiRecord *record;
struct timeval timestamp;
struct timeval expiry;
AvahiTimeEvent *time_event;
-
+
AVAHI_LLIST_FIELDS(AvahiWideAreaCacheEntry, by_key);
AVAHI_LLIST_FIELDS(AvahiWideAreaCacheEntry, cache);
};
struct AvahiWideAreaLookup {
AvahiWideAreaLookupEngine *engine;
int dead;
-
+
uint32_t id; /* effectively just an uint16_t, but we need it as an index for a hash table */
AvahiTimeEvent *time_event;
AvahiKey *key, *cname_key;
-
+
int n_send;
AvahiDnsPacket *packet;
AvahiWatch *watch_ipv4, *watch_ipv6;
uint16_t next_id;
-
+
/* Cache */
AVAHI_LLIST_HEAD(AvahiWideAreaCacheEntry, cache);
AvahiHashmap *cache_by_key;
static AvahiWideAreaLookup* find_lookup(AvahiWideAreaLookupEngine *e, uint16_t id) {
AvahiWideAreaLookup *l;
int i = (int) id;
-
+
assert(e);
if (!(l = avahi_hashmap_lookup(e->lookups_by_id, &i)))
return NULL;
-
+
assert(l->id == id);
if (l->dead)
return NULL;
-
+
return l;
}
static int send_to_dns_server(AvahiWideAreaLookup *l, AvahiDnsPacket *p) {
AvahiAddress *a;
-
+
assert(l);
assert(p);
a = &l->engine->dns_servers[l->engine->current_dns_server];
l->dns_server_used = *a;
-
+
if (a->proto == AVAHI_PROTO_INET) {
if (l->engine->fd_ipv4 < 0)
return -1;
-
+
return avahi_send_dns_packet_ipv4(l->engine->fd_ipv4, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv4, AVAHI_DNS_PORT);
-
+
} else {
assert(a->proto == AVAHI_PROTO_INET6);
if (l->engine->fd_ipv6 < 0)
return -1;
-
+
return avahi_send_dns_packet_ipv6(l->engine->fd_ipv6, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv6, AVAHI_DNS_PORT);
}
}
static void lookup_stop(AvahiWideAreaLookup *l) {
assert(l);
-
+
l->callback = NULL;
if (l->time_event) {
/* There is no other DNS server, fail */
l->n_send = 1000;
}
-
+
if (l->n_send >= 6) {
avahi_log_warn(__FILE__": Query timed out.");
avahi_server_set_errno(l->engine->server, AVAHI_ERR_TIMEOUT);
AvahiKey *key,
AvahiWideAreaLookupCallback callback,
void *userdata) {
-
+
struct timeval tv;
AvahiWideAreaLookup *l, *t;
uint8_t *p;
break; /* This ID is not yet used. */
l->id = e->next_id++;
-
+
/* We keep the packet around in case we need to repeat our query */
l->packet = avahi_dns_packet_new(0);
p = avahi_dns_packet_append_key(l->packet, key, 0);
assert(p);
-
+
avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_QDCOUNT, 1);
if (send_to_dns_server(l, l->packet) < 0) {
}
l->n_send = 1;
-
+
l->time_event = avahi_time_event_new(e->server->time_event_queue, avahi_elapse_time(&tv, 500, 0), sender_timeout_callback, l);
avahi_hashmap_insert(e->lookups_by_id, &l->id, l);
avahi_hashmap_replace(e->lookups_by_key, avahi_key_ref(l->key), t);
AVAHI_LLIST_PREPEND(AvahiWideAreaLookup, lookups, e->lookups, l);
-
+
return l;
}
static void lookup_destroy(AvahiWideAreaLookup *l) {
AvahiWideAreaLookup *t;
assert(l);
-
+
lookup_stop(l);
t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key);
avahi_hashmap_remove(l->engine->lookups_by_key, l->key);
AVAHI_LLIST_REMOVE(AvahiWideAreaLookup, lookups, l->engine->lookups, l);
-
+
avahi_hashmap_remove(l->engine->lookups_by_id, &l->id);
avahi_dns_packet_free(l->packet);
if (l->cname_key)
avahi_key_unref(l->cname_key);
-
+
avahi_free(l);
}
while (e->cleanup_dead) {
e->cleanup_dead = 0;
-
+
for (l = e->lookups; l; l = n) {
n = l->lookups_next;
-
+
if (l->dead)
lookup_destroy(l);
}
static void expiry_event(AvahiTimeEvent *te, void *userdata) {
AvahiWideAreaCacheEntry *e = userdata;
-
+
assert(te);
assert(e);
static AvahiWideAreaCacheEntry* find_record_in_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
AvahiWideAreaCacheEntry *c;
-
+
assert(e);
assert(r);
static void run_callbacks(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
AvahiWideAreaLookup *l;
-
+
assert(e);
assert(r);
for (l = avahi_hashmap_lookup(e->lookups_by_key, r->key); l; l = l->by_key_next) {
if (l->dead || !l->callback)
continue;
-
+
l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata);
}
-
+
if (r->key->clazz == AVAHI_DNS_CLASS_IN && r->key->type == AVAHI_DNS_TYPE_CNAME) {
/* It's a CNAME record, so we have to scan the all lookups to see if one matches */
if (l->dead || !l->callback)
continue;
-
+
if ((key = avahi_key_new_cname(l->key))) {
if (avahi_key_equal(r->key, key))
l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata);
static void add_to_cache(AvahiWideAreaLookupEngine *e, AvahiRecord *r) {
AvahiWideAreaCacheEntry *c;
int is_new;
-
+
assert(e);
assert(r);
if (e->cache_n_entries >= CACHE_ENTRIES_MAX)
/* Eventually we should improve the caching algorithm here */
goto finish;
-
+
c = avahi_new(AvahiWideAreaCacheEntry, 1);
c->engine = e;
c->time_event = NULL;
}
c->record = avahi_record_ref(r);
-
+
gettimeofday(&c->timestamp, NULL);
c->expiry = c->timestamp;
avahi_timeval_add(&c->expiry, r->ttl * 1000000);
c->time_event = avahi_time_event_new(e->server->time_event_queue, &c->expiry, expiry_event, c);
finish:
-
+
if (is_new)
run_callbacks(e, r);
}
int i, r;
AvahiBrowserEvent final_event = AVAHI_BROWSER_ALL_FOR_NOW;
-
+
assert(e);
assert(p);
/* Skip over the question */
for (i = (int) avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT); i > 0; i--) {
AvahiKey *k;
-
+
if (!(k = avahi_dns_packet_consume_key(p, NULL))) {
avahi_log_warn(__FILE__": Wide area response packet too short or invalid while reading question key. (Maybe a UTF-8 problem?)");
avahi_server_set_errno(e->server, AVAHI_ERR_INVALID_PACKET);
}
finish:
-
+
if (l && !l->dead) {
if (l->callback)
l->callback(e, final_event, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata);
static void socket_event(AVAHI_GCC_UNUSED AvahiWatch *w, int fd, AVAHI_GCC_UNUSED AvahiWatchEvent events, void *userdata) {
AvahiWideAreaLookupEngine *e = userdata;
AvahiDnsPacket *p = NULL;
-
+
if (fd == e->fd_ipv4)
p = avahi_recv_dns_packet_ipv4(e->fd_ipv4, NULL, NULL, NULL, NULL, NULL);
else {
AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) {
AvahiWideAreaLookupEngine *e;
-
+
assert(s);
e = avahi_new(AvahiWideAreaLookupEngine, 1);
if (e->fd_ipv4 >= 0)
close(e->fd_ipv4);
-
+
avahi_free(e);
return NULL;
}
/* Create watches */
e->watch_ipv4 = e->watch_ipv6 = NULL;
-
+
if (e->fd_ipv4 >= 0)
e->watch_ipv4 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv4, AVAHI_WATCH_IN, socket_event, e);
if (e->fd_ipv6 >= 0)
void avahi_wide_area_engine_free(AvahiWideAreaLookupEngine *e) {
assert(e);
-
+
avahi_wide_area_clear_cache(e);
while (e->lookups)
lookup_destroy(e->lookups);
-
+
avahi_hashmap_free(e->cache_by_key);
avahi_hashmap_free(e->lookups_by_id);
avahi_hashmap_free(e->lookups_by_key);
if (e->fd_ipv6 >= 0)
close(e->fd_ipv6);
-
+
if (e->fd_ipv4 >= 0)
close(e->fd_ipv4);
assert(e);
if (a) {
- for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--)
+ for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--)
if ((a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == AVAHI_PROTO_INET6 && e->fd_ipv6 >= 0))
e->dns_servers[e->n_dns_servers++] = *a;
} else {
assert(n == 0);
e->n_dns_servers = 0;
}
-
+
e->current_dns_server = 0;
avahi_wide_area_clear_cache(e);
void avahi_wide_area_cache_dump(AvahiWideAreaLookupEngine *e, AvahiDumpCallback callback, void* userdata) {
AvahiWideAreaCacheEntry *c;
-
+
assert(e);
assert(callback);
callback(";; WIDE AREA CACHE ;;; ", userdata);
-
+
for (c = e->cache; c; c = c->cache_next) {
char *t = avahi_record_to_string(c->record);
callback(t, userdata);
AvahiWideAreaCacheEntry *c;
AvahiKey *cname_key;
unsigned n = 0;
-
+
assert(e);
assert(key);
assert(callback);
callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA|AVAHI_LOOKUP_RESULT_CACHED, c->record, userdata);
n++;
}
-
+
avahi_key_unref(cname_key);
}
}
-
+
#ifndef foowideareahfoo
#define foowideareahfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+avahi-daemon.service
+avahi-daemon.socket
avahi-daemon
avahi-dbus.conf
ini-file-parser-test
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.AddressResolver">
-
- <method name="Free"/>
-
- <signal name="Found">
- <arg name="interface" type="i" direction="out"/>
- <arg name="protocol" type="i" direction="out"/>
- <arg name="aprotocol" type="i" direction="out"/>
- <arg name="address" type="s" direction="out"/>
- <arg name="name" type="s" direction="out"/>
- <arg name="flags" type="u" direction="out"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- </interface>
-</node>
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.DomainBrowser">
-
- <method name="Free"/>
-
- <signal name="ItemNew">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="domain" type="s"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="ItemRemove">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="domain" type="s"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- <signal name="AllForNow"/>
-
- <signal name="CacheExhausted"/>
-
- </interface>
-</node>
-
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out"/>
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.EntryGroup">
- <method name="Free"/>
- <method name="Commit"/>
- <method name="Reset"/>
-
- <method name="GetState">
- <arg name="state" type="i" direction="out"/>
- </method>
-
- <signal name="StateChanged">
- <arg name="state" type="i"/>
- <arg name="error" type="s"/>
- </signal>
-
- <method name="IsEmpty">
- <arg name="empty" type="b" direction="out"/>
- </method>
-
- <method name="AddService">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="host" type="s" direction="in"/>
- <arg name="port" type="q" direction="in"/>
- <arg name="txt" type="aay" direction="in"/>
- </method>
-
- <method name="AddServiceSubtype">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="subtype" type="s" direction="in"/>
- </method>
-
- <method name="UpdateServiceTxt">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="txt" type="aay" direction="in"/>
- </method>
-
- <method name="AddAddress">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="address" type="s" direction="in"/>
- </method>
-
- <method name="AddRecord">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="clazz" type="q" direction="in"/>
- <arg name="type" type="q" direction="in"/>
- <arg name="ttl" type="u" direction="in"/>
- <arg name="rdata" type="ay" direction="in"/>
- </method>
- </interface>
-</node>
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.HostNameResolver">
-
- <method name="Free"/>
-
- <signal name="Found">
- <arg name="interface" type="i" direction="out"/>
- <arg name="protocol" type="i" direction="out"/>
- <arg name="name" type="s" direction="out"/>
- <arg name="aprotocol" type="i" direction="out"/>
- <arg name="address" type="s" direction="out"/>
- <arg name="flags" type="u" direction="out"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- </interface>
-</node>
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
pkgsysconfdir=$(sysconfdir)/avahi
servicedir=$(pkgsysconfdir)/services
-introspectiondir=$(pkgdatadir)/introspection
+introspectiondir=$(datadir)/dbus-1/interfaces
+dbussystemservicesdir=$(datadir)/dbus-1/system-services
AM_CFLAGS+= \
-DAVAHI_DAEMON_RUNTIME_DIR=\"$(avahi_runtime_dir)/avahi-daemon/\" \
static-hosts.c static-hosts.h \
ini-file-parser.c ini-file-parser.h \
setproctitle.c setproctitle.h \
+ sd-daemon.h sd-daemon.c \
../avahi-client/check-nss.c
avahi_daemon_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS) $(XML_CFLAGS)
ini-file-parser-test.c
ini_file_parser_test_CFLAGS = $(AM_CFLAGS)
-ini_file_parser_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-core/libavahi-core.la
+ini_file_parser_test_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-core/libavahi-core.la
pkgsysconf_DATA = \
avahi-daemon.conf \
hosts
-service_DATA = \
+dist_service_DATA = \
ssh.service \
sftp-ssh.service
-pkgdata_DATA = \
+dist_pkgdata_DATA = \
avahi-service.dtd
+%.service: %.service.in
+ $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
+
+%.socket: %.socket.in
+ $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@avahi_runtime_dir\@,$(avahi_runtime_dir),g' $< > $@
+
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = \
+ avahi-daemon.service \
+ avahi-daemon.socket
+
+dist_dbussystemservices_DATA = \
+ org.freedesktop.Avahi.service
+endif
+
+CLEANFILES = $(systemdsystemunit_DATA)
+
if ENABLE_CHROOT
avahi_daemon_SOURCES += \
avahi_daemon_CFLAGS += $(DBUS_CFLAGS) -DDBUS_SYSTEM_BUS_DEFAULT_ADDRESS=\"$(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)\"
-dbusservice_DATA = avahi-dbus.conf
+dist_dbusservice_DATA = avahi-dbus.conf
-introspection_DATA = \
- Server.introspect \
- EntryGroup.introspect \
- DomainBrowser.introspect \
- ServiceTypeBrowser.introspect \
- ServiceBrowser.introspect \
- ServiceResolver.introspect \
- AddressResolver.introspect \
- HostNameResolver.introspect \
- RecordBrowser.introspect
+dist_introspection_DATA = \
+ org.freedesktop.Avahi.Server.xml \
+ org.freedesktop.Avahi.EntryGroup.xml \
+ org.freedesktop.Avahi.DomainBrowser.xml \
+ org.freedesktop.Avahi.ServiceTypeBrowser.xml \
+ org.freedesktop.Avahi.ServiceBrowser.xml \
+ org.freedesktop.Avahi.ServiceResolver.xml \
+ org.freedesktop.Avahi.AddressResolver.xml \
+ org.freedesktop.Avahi.HostNameResolver.xml \
+ org.freedesktop.Avahi.RecordBrowser.xml
endif
endif
endif
EXTRA_DIST = \
- avahi-service.dtd \
avahi-daemon.conf \
example.service \
- avahi-dbus.conf \
- Server.introspect \
- EntryGroup.introspect \
- DomainBrowser.introspect \
- ServiceTypeBrowser.introspect \
- ServiceBrowser.introspect \
- ServiceResolver.introspect \
- AddressResolver.introspect \
- HostNameResolver.introspect \
- RecordBrowser.introspect \
- ssh.service \
- sftp-ssh.service \
hosts \
example.service \
introspect.dtd \
- introspect.xsl
+ introspect.xsl \
+ avahi-daemon.service.in \
+ avahi-daemon.socket.in
xmllint:
xmllint --noout --valid example.service
install-data-local:
test -z "$(localstatedir)/run" || $(mkdir_p) "$(DESTDIR)$(localstatedir)/run"
+
+update-systemd:
+ curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c > sd-daemon.c
+ curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h > sd-daemon.h
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.RecordBrowser">
-
- <method name="Free"/>
-
- <signal name="ItemNew">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="name" type="s"/>
- <arg name="clazz" type="q"/>
- <arg name="type" type="q"/>
- <arg name="rdata" type="ay"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="ItemRemove">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="name" type="s"/>
- <arg name="clazz" type="q"/>
- <arg name="type" type="q"/>
- <arg name="rdata" type="ay"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- <signal name="AllForNow"/>
-
- <signal name="CacheExhausted"/>
-
- </interface>
-</node>
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out"/>
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.Server">
-
- <method name="GetVersionString">
- <arg name="version" type="s" direction="out"/>
- </method>
-
- <method name="GetAPIVersion">
- <arg name="version" type="u" direction="out"/>
- </method>
-
- <method name="GetHostName">
- <arg name="name" type="s" direction="out"/>
- </method>
- <method name="SetHostName">
- <arg name="name" type="s" direction="in"/>
- </method>
- <method name="GetHostNameFqdn">
- <arg name="name" type="s" direction="out"/>
- </method>
- <method name="GetDomainName">
- <arg name="name" type="s" direction="out"/>
- </method>
-
- <method name="IsNSSSupportAvailable">
- <arg name="yes" type="b" direction="out"/>
- </method>
-
- <method name="GetState">
- <arg name="state" type="i" direction="out"/>
- </method>
-
- <signal name="StateChanged">
- <arg name="state" type="i"/>
- <arg name="error" type="s"/>
- </signal>
-
- <method name="GetLocalServiceCookie">
- <arg name="cookie" type="u" direction="out"/>
- </method>
-
- <method name="GetAlternativeHostName">
- <arg name="name" type="s" direction="in"/>
- <arg name="name" type="s" direction="out"/>
- </method>
-
- <method name="GetAlternativeServiceName">
- <arg name="name" type="s" direction="in"/>
- <arg name="name" type="s" direction="out"/>
- </method>
-
- <method name="GetNetworkInterfaceNameByIndex">
- <arg name="index" type="i" direction="in"/>
- <arg name="name" type="s" direction="out"/>
- </method>
- <method name="GetNetworkInterfaceIndexByName">
- <arg name="name" type="s" direction="in"/>
- <arg name="index" type="i" direction="out"/>
- </method>
-
- <method name="ResolveHostName">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="aprotocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="interface" type="i" direction="out"/>
- <arg name="protocol" type="i" direction="out"/>
- <arg name="name" type="s" direction="out"/>
- <arg name="aprotocol" type="i" direction="out"/>
- <arg name="address" type="s" direction="out"/>
- <arg name="flags" type="u" direction="out"/>
- </method>
-
- <method name="ResolveAddress">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="address" type="s" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="interface" type="i" direction="out"/>
- <arg name="protocol" type="i" direction="out"/>
- <arg name="aprotocol" type="i" direction="out"/>
- <arg name="address" type="s" direction="out"/>
- <arg name="name" type="s" direction="out"/>
- <arg name="flags" type="u" direction="out"/>
- </method>
-
- <method name="ResolveService">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="aprotocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="interface" type="i" direction="out"/>
- <arg name="protocol" type="i" direction="out"/>
- <arg name="name" type="s" direction="out"/>
- <arg name="type" type="s" direction="out"/>
- <arg name="domain" type="s" direction="out"/>
- <arg name="host" type="s" direction="out"/>
- <arg name="aprotocol" type="i" direction="out"/>
- <arg name="address" type="s" direction="out"/>
- <arg name="port" type="q" direction="out"/>
- <arg name="txt" type="aay" direction="out"/>
- <arg name="flags" type="u" direction="out"/>
- </method>
-
- <method name="EntryGroupNew">
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="DomainBrowserNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="btype" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="ServiceTypeBrowserNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="ServiceBrowserNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="ServiceResolverNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="type" type="s" direction="in"/>
- <arg name="domain" type="s" direction="in"/>
- <arg name="aprotocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="HostNameResolverNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="aprotocol" type="i" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="AddressResolverNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="address" type="s" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
- <method name="RecordBrowserNew">
- <arg name="interface" type="i" direction="in"/>
- <arg name="protocol" type="i" direction="in"/>
- <arg name="name" type="s" direction="in"/>
- <arg name="clazz" type="q" direction="in"/>
- <arg name="type" type="q" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
-
- <arg name="path" type="o" direction="out"/>
- </method>
-
-
- </interface>
-</node>
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.ServiceBrowser">
-
- <method name="Free"/>
-
- <signal name="ItemNew">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="name" type="s"/>
- <arg name="type" type="s"/>
- <arg name="domain" type="s"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="ItemRemove">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="name" type="s"/>
- <arg name="type" type="s"/>
- <arg name="domain" type="s"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- <signal name="AllForNow"/>
-
- <signal name="CacheExhausted"/>
-
- </interface>
-</node>
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.ServiceResolver">
-
- <method name="Free"/>
-
- <signal name="Found">
- <arg name="interface" type="i" direction="out"/>
- <arg name="protocol" type="i" direction="out"/>
- <arg name="name" type="s" direction="out"/>
- <arg name="type" type="s" direction="out"/>
- <arg name="domain" type="s" direction="out"/>
- <arg name="host" type="s" direction="out"/>
- <arg name="aprotocol" type="i" direction="out"/>
- <arg name="address" type="s" direction="out"/>
- <arg name="port" type="q" direction="out"/>
- <arg name="txt" type="aay" direction="out"/>
- <arg name="flags" type="u" direction="out"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- </interface>
-</node>
+++ /dev/null
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
-<!DOCTYPE node SYSTEM "introspect.dtd">
-
-<!-- $Id$ -->
-
-<!--
- This file is part of avahi.
-
- avahi is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- avahi is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with avahi; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
--->
-
-<node>
-
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out" />
- </method>
- </interface>
-
- <interface name="org.freedesktop.Avahi.ServiceTypeBrowser">
-
- <method name="Free"/>
-
- <signal name="ItemNew">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="type" type="s"/>
- <arg name="domain" type="s"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="ItemRemove">
- <arg name="interface" type="i"/>
- <arg name="protocol" type="i"/>
- <arg name="type" type="s"/>
- <arg name="domain" type="s"/>
- <arg name="flags" type="u"/>
- </signal>
-
- <signal name="Failure">
- <arg name="error" type="s"/>
- </signal>
-
- <signal name="AllForNow"/>
-
- <signal name="CacheExhausted"/>
-
- </interface>
-</node>
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
#enable-dbus=yes
#disallow-other-stacks=no
#allow-point-to-point=no
+#cache-entries-max=4096
+#clients-max=4096
+#objects-per-client-max=1024
+#entries-per-entry-group-max=32
[wide-area]
enable-wide-area=yes
--- /dev/null
+# This file is part of avahi.
+#
+# avahi is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# avahi is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with avahi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+[Unit]
+Requires=basic.target avahi-daemon.socket
+After=basic.target syslog.target avahi-daemon.socket
+Conflicts=shutdown.target
+
+[Service]
+Type=dbus
+BusName=org.freedesktop.Avahi
+ExecStart=@sbindir@/avahi-daemon -s
+ExecReload=@sbindir@/avahi-daemon -r
+
+[Install]
+WantedBy=multi-user.target
+Also=avahi-daemon.socket
--- /dev/null
+# This file is part of avahi.
+#
+# avahi is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# avahi is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with avahi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+[Unit]
+After=sysinit.target
+Before=sockets.target
+Conflicts=shutdown.target
+
+[Socket]
+ListenStream=@avahi_runtime_dir@/avahi-daemon/socket
+
+[Install]
+WantedBy=sockets.target
-<!-- $Id$ -->
-
<!ELEMENT service-group (name,service+)>
<!ATTLIST service-group>
<!ELEMENT name (#PCDATA)>
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
int ret = 0;
cap_t caps;
static cap_value_t cap_values[] = { CAP_SYS_CHROOT, CAP_SETUID, CAP_SETGID };
-
+
/* Let's reduce our caps to the minimum set and tell Linux to keep
* them across setuid(). This is called before we drop
* privileges. */
-
+
caps = cap_init();
assert(caps);
cap_clear(caps);
cap_set_flag(caps, CAP_EFFECTIVE, 3, cap_values, CAP_SET);
cap_set_flag(caps, CAP_PERMITTED, 3, cap_values, CAP_SET);
-
+
if (cap_set_proc(caps) < 0) {
avahi_log_error("cap_set_proc() failed: %s", strerror(errno));
ret = -1;
/* Reduce our caps to the bare minimum and tell Linux not to keep
* them across setuid(). This is called after we drop
* privileges. */
-
+
/* No longer retain caps across setuid() */
if (prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) < 0) {
avahi_log_error("prctl(PR_SET_KEEPCAPS) failed: %s", strerror(errno));
caps = cap_init();
assert(caps);
cap_clear(caps);
-
+
if (cap_set_proc(caps) < 0) {
avahi_log_error("cap_set_proc() failed: %s", strerror(errno));
ret = -1;
}
cap_free(caps);
-
+
return ret;
}
#ifndef foocapshfoo
#define foocapshfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
NULL,
"/etc/resolv.conf",
#ifdef HAVE_DBUS
- AVAHI_DBUS_INTROSPECTION_DIR"/Server.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/EntryGroup.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/AddressResolver.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/DomainBrowser.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/HostNameResolver.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/ServiceBrowser.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/ServiceResolver.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/ServiceTypeBrowser.introspect",
- AVAHI_DBUS_INTROSPECTION_DIR"/RecordBrowser.introspect",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.Server.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.EntryGroup.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.AddressResolver.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.DomainBrowser.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.HostNameResolver.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.ServiceBrowser.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.ServiceResolver.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.ServiceTypeBrowser.xml",
+ AVAHI_DBUS_INTROSPECTION_DIR"/org.freedesktop.Avahi.RecordBrowser.xml",
#endif
NULL,
NULL
struct iovec iov;
struct msghdr msg;
union {
- struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(int))];
+ struct cmsghdr hdr;
+ char buf[CMSG_SPACE(sizeof(int))];
} cmsg;
/* Send a file descriptor over the socket */
-
+
memset(&iov, 0, sizeof(iov));
memset(&msg, 0, sizeof(msg));
memset(&cmsg, 0, sizeof(cmsg));
-
- iov.iov_base = &dummy;
+
+ iov.iov_base = &dummy;
iov.iov_len = sizeof(dummy);
-
+
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_name = NULL;
msg.msg_control = &cmsg;
msg.msg_controllen = sizeof(cmsg);
msg.msg_flags = 0;
-
+
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_RIGHTS;
struct iovec iov;
struct msghdr msg;
union {
- struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(int))];
+ struct cmsghdr hdr;
+ char buf[CMSG_SPACE(sizeof(int))];
} cmsg;
/* Receive a file descriptor from a socket */
memset(&iov, 0, sizeof(iov));
memset(&msg, 0, sizeof(msg));
memset(&cmsg, 0, sizeof(cmsg));
-
+
iov.iov_base = &dummy;
iov.iov_len = sizeof(dummy);
-
+
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_name = NULL;
msg.msg_control = cmsg.buf;
msg.msg_controllen = sizeof(cmsg);
msg.msg_flags = 0;
-
+
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_RIGHTS;
*((int*) CMSG_DATA(&cmsg.hdr)) = -1;
-
+
if (recvmsg(fd, &msg, 0) <= 0) {
avahi_log_error("recvmsg() failed: %s", strerror(errno));
return -1;
errno = EINVAL;
return -1;
}
-
+
if (!(h = CMSG_FIRSTHDR(&msg))) {
avahi_log_error("recvmsg() sent no fd.");
errno = EINVAL;
return *((int*)CMSG_DATA(h));
}
}
-
+
static int helper_main(int fd) {
int ret = 1;
assert(fd >= 0);
* mind that this code is security sensitive! */
avahi_log_debug(__FILE__": chroot() helper started");
-
+
for (;;) {
uint8_t command;
ssize_t r;
/* EOF? */
if (r == 0)
break;
-
+
avahi_log_error(__FILE__": read() failed: %s", strerror(errno));
goto fail;
}
avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno));
goto fail;
}
-
+
break;
}
goto fail;
close(payload);
-
+
break;
}
case AVAHI_CHROOT_UNLINK_SOCKET:
case AVAHI_CHROOT_UNLINK_PID: {
uint8_t c = AVAHI_CHROOT_SUCCESS;
-
+
unlink(unlink_file_name_table[(int) command]);
if (write(fd, &c, sizeof(c)) != sizeof(c)) {
avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno));
goto fail;
}
-
+
break;
}
-
+
default:
avahi_log_error(__FILE__": Unknown command %02x.", command);
break;
}
ret = 0;
-
+
fail:
avahi_log_debug(__FILE__": chroot() helper exiting with return value %i", ret);
-
+
return ret;
}
pid_t pid;
assert(helper_fd < 0);
-
+
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) < 0) {
avahi_log_error("socketpair() failed: %s", strerror(errno));
return -1;
}
-
+
if ((pid = fork()) < 0) {
close(sock[0]);
close(sock[1]);
return -1;
} else if (pid == 0) {
- setsid();
-
/* Drop all remaining capabilities */
avahi_caps_drop_all();
avahi_set_proc_title(argv0, "%s: chroot helper", argv0);
daemon_retval_done();
-
+
close(sock[0]);
helper_main(sock[1]);
_exit(0);
if (helper_fd >= 0) {
uint8_t command;
-
+
for (command = 2; command < AVAHI_CHROOT_MAX; command++)
if (get_file_name_table[(int) command] &&
strcmp(fname, get_file_name_table[(int) command]) == 0)
}
assert(get_file_name_table[(int) command]);
-
+
if (write(helper_fd, &command, sizeof(command)) < 0) {
avahi_log_error("write() failed: %s\n", strerror(errno));
return -1;
if (helper_fd >= 0) {
uint8_t c, command;
ssize_t r;
-
+
for (command = 2; command < AVAHI_CHROOT_MAX; command++)
if (unlink_file_name_table[(int) command] &&
strcmp(fname, unlink_file_name_table[(int) command]) == 0)
avahi_log_error("read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
return -1;
}
-
+
return 0;
-
+
} else
-
+
return unlink(fname);
-
+
}
#ifndef foochroothelperhfoo
#define foochroothelperhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_connection_unregister_object_path(server->bus, i->path);
avahi_free(i->path);
}
-
+
AVAHI_LLIST_REMOVE(AsyncAddressResolverInfo, async_address_resolvers, i->client->async_address_resolvers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
void avahi_dbus_async_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata) {
AsyncAddressResolverInfo *i = userdata;
DBusMessage *reply;
-
+
assert(r);
assert(i);
reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, avahi_dbus_map_resolve_signal_name(event));
-
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_RESOLVER_FOUND) {
char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
i_protocol = (int32_t) protocol;
i_aprotocol = (int32_t) address->proto;
u_flags = (uint32_t) flags;
-
+
dbus_message_append_args(
reply,
DBUS_TYPE_INT32, &i_interface,
avahi_dbus_append_server_error(reply);
}
- dbus_message_set_destination(reply, i->client->name);
+ dbus_message_set_destination(reply, i->client->name);
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "AddressResolver.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.AddressResolver.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ADDRESS_RESOLVER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_async_address_resolver_free(i);
return avahi_dbus_respond_ok(c, m);
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
}
AVAHI_LLIST_REMOVE(AsyncHostNameResolverInfo, async_host_name_resolvers, i->client->async_host_name_resolvers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
void avahi_dbus_async_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) {
AsyncHostNameResolverInfo *i = userdata;
DBusMessage *reply;
-
+
assert(r);
assert(i);
reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, avahi_dbus_map_resolve_signal_name(event));
-
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_RESOLVER_FOUND) {
char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
i_protocol = (int32_t) protocol;
i_aprotocol = (int32_t) a->proto;
u_flags = (uint32_t) flags;
-
+
dbus_message_append_args(
reply,
DBUS_TYPE_INT32, &i_interface,
avahi_dbus_append_server_error(reply);
}
- dbus_message_set_destination(reply, i->client->name);
+ dbus_message_set_destination(reply, i->client->name);
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "HostNameResolver.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.HostNameResolver.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_HOST_NAME_RESOLVER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_async_host_name_resolver_free(i);
return avahi_dbus_respond_ok(c, m);
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_connection_unregister_object_path(server->bus, i->path);
avahi_free(i->path);
}
-
+
AVAHI_LLIST_REMOVE(AsyncServiceResolverInfo, async_service_resolvers, i->client->async_service_resolvers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
void* userdata) {
AsyncServiceResolverInfo *i = userdata;
DBusMessage *reply;
-
+
assert(r);
assert(i);
reply = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, avahi_dbus_map_resolve_signal_name(event));
-
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_RESOLVER_FOUND) {
char t[AVAHI_ADDRESS_STR_MAX], *pt = t;
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
-
+
assert(host_name);
/* avahi_log_debug(__FILE__": [%s] Successfully resolved service <%s.%s.%s>", i->path, name, type, domain); */
-
+
if (a)
avahi_address_snprint(t, sizeof(t), a);
else
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
- if (a)
+ if (a)
i_aprotocol = (int32_t) a->proto;
- else
+ else
i_aprotocol = AVAHI_PROTO_UNSPEC;
u_flags = (uint32_t) flags;
avahi_dbus_append_server_error(reply);
}
- dbus_message_set_destination(reply, i->client->name);
+ dbus_message_set_destination(reply, i->client->name);
dbus_connection_send(server->bus, reply, NULL);
dbus_message_unref(reply);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "ServiceResolver.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.ServiceResolver.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_RESOLVER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_async_service_resolver_free(i);
return avahi_dbus_respond_ok(c, m);
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_connection_unregister_object_path(server->bus, i->path);
avahi_free(i->path);
}
-
+
AVAHI_LLIST_REMOVE(DomainBrowserInfo, domain_browsers, i->client->domain_browsers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "DomainBrowser.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.DomainBrowser.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_domain_browser_free(i);
return avahi_dbus_respond_ok(c, m);
-
+
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
DBusMessage *m;
int32_t i_interface, i_protocol;
uint32_t u_flags;
-
+
assert(b);
assert(i);
m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_DOMAIN_BROWSER, avahi_dbus_map_browse_signal_name(event));
+ if (!m) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
assert(domain);
dbus_message_append_args(
DBUS_TYPE_INVALID);
} else if (event == AVAHI_BROWSER_FAILURE)
avahi_dbus_append_server_error(m);
-
- dbus_message_set_destination(m, i->client->name);
+
+ dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
dbus_message_unref(m);
}
-
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
}
AVAHI_LLIST_REMOVE(EntryGroupInfo, entry_groups, i->client->entry_groups, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
-
+
avahi_free(i);
}
DBusMessage *m;
int32_t t;
const char *e;
-
+
assert(s);
assert(g);
assert(i);
m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "StateChanged");
-
+
+ if (!m) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
t = (int32_t) state;
if (state == AVAHI_ENTRY_GROUP_FAILURE)
e = avahi_error_number_to_dbus(avahi_server_errno(s));
e = AVAHI_DBUS_ERR_COLLISION;
else
e = AVAHI_DBUS_ERR_OK;
-
+
dbus_message_append_args(
m,
DBUS_TYPE_INT32, &t,
DBUS_TYPE_STRING, &e,
DBUS_TYPE_INVALID);
- dbus_message_set_destination(m, i->client->name);
+ dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
dbus_message_unref(m);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "EntryGroup.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.EntryGroup.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_entry_group_free(i);
return avahi_dbus_respond_ok(c, m);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Commit")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
if (avahi_s_entry_group_commit(i->entry_group) < 0)
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
-
+
return avahi_dbus_respond_ok(c, m);
-
-
+
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Reset")) {
-
+
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_log_warn("Error parsing EntryGroup::Reset message");
goto fail;
}
avahi_s_entry_group_reset(i->entry_group);
- i->n_entries = 0;
+ i->n_entries = 0;
return avahi_dbus_respond_ok(c, m);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
}
return avahi_dbus_respond_boolean(c, m, !!avahi_s_entry_group_is_empty(i->entry_group));
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState")) {
AvahiEntryGroupState state;
-
+
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_log_warn("Error parsing EntryGroup::GetState message");
goto fail;
state = avahi_s_entry_group_get_state(i->entry_group);
return avahi_dbus_respond_int32(c, m, (int32_t) state);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) {
int32_t interface, protocol;
uint32_t flags;
char *type, *name, *domain, *host;
uint16_t port;
AvahiStringList *strlst = NULL;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
DBUS_TYPE_STRING, &type,
DBUS_TYPE_STRING, &domain,
DBUS_TYPE_STRING, &host,
- DBUS_TYPE_UINT16, &port,
+ DBUS_TYPE_UINT16, &port,
DBUS_TYPE_INVALID) ||
!type || !name ||
avahi_dbus_read_strlst(m, 8, &strlst) < 0) {
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX) {
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max) {
avahi_string_list_free(strlst);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
}
if (!(flags & AVAHI_PUBLISH_UPDATE))
i->n_entries ++;
-
+
avahi_string_list_free(strlst);
-
+
return avahi_dbus_respond_ok(c, m);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype")) {
int32_t interface, protocol;
uint32_t flags;
char *type, *name, *domain, *subtype;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX)
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max)
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
if (domain && !*domain)
domain = NULL;
- if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0)
+ if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0)
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
if (!(flags & AVAHI_PUBLISH_UPDATE))
i->n_entries ++;
-
+
return avahi_dbus_respond_ok(c, m);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "UpdateServiceTxt")) {
uint32_t flags;
char *type, *name, *domain;
AvahiStringList *strlst;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
}
avahi_string_list_free(strlst);
-
+
return avahi_dbus_respond_ok(c, m);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) {
int32_t interface, protocol;
uint32_t flags;
char *name, *address;
AvahiAddress a;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX)
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max)
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
-
+
if (!(avahi_address_parse(address, AVAHI_PROTO_UNSPEC, &a)))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_ADDRESS, NULL);
if (!(flags & AVAHI_PUBLISH_UPDATE))
i->n_entries ++;
-
+
return avahi_dbus_respond_ok(c, m);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddRecord")) {
int32_t interface, protocol;
char *name;
void *rdata;
AvahiRecord *r;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
goto fail;
}
- if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= ENTRIES_PER_ENTRY_GROUP_MAX)
+ if (!(flags & AVAHI_PUBLISH_UPDATE) && i->n_entries >= server->n_entries_per_entry_group_max)
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
if (!avahi_is_valid_domain_name (name))
avahi_record_unref (r);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_RDATA, NULL);
}
-
+
if (avahi_server_add(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, r) < 0) {
avahi_record_unref (r);
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
if (!(flags & AVAHI_PUBLISH_UPDATE))
i->n_entries ++;
-
- avahi_record_unref (r);
+
+ avahi_record_unref (r);
return avahi_dbus_respond_ok(c, m);
- }
-
-
+ }
+
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
#ifndef foodbusinternalhfoo
#define foodbusinternalhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
typedef struct AsyncServiceResolverInfo AsyncServiceResolverInfo;
typedef struct RecordBrowserInfo RecordBrowserInfo;
-#define CLIENTS_MAX 256
-#define OBJECTS_PER_CLIENT_MAX 250
-#define ENTRIES_PER_ENTRY_GROUP_MAX 20
+#define DEFAULT_CLIENTS_MAX 4096
+#define DEFAULT_OBJECTS_PER_CLIENT_MAX 1024
+#define DEFAULT_ENTRIES_PER_ENTRY_GROUP_MAX 32
struct EntryGroupInfo {
unsigned id;
AvahiSEntryGroup *entry_group;
char *path;
- int n_entries;
-
+ unsigned n_entries;
+
AVAHI_LLIST_FIELDS(EntryGroupInfo, entry_groups);
};
unsigned id;
char *name;
unsigned current_id;
- int n_objects;
-
+ unsigned n_objects;
+
AVAHI_LLIST_FIELDS(Client, clients);
AVAHI_LLIST_HEAD(EntryGroupInfo, entry_groups);
AVAHI_LLIST_HEAD(SyncHostNameResolverInfo, sync_host_name_resolvers);
const AvahiPoll *poll_api;
DBusConnection *bus;
AVAHI_LLIST_HEAD(Client, clients);
- int n_clients;
+ unsigned n_clients;
unsigned current_id;
AvahiTimeout *reconnect_timeout;
int reconnect;
+
+ unsigned n_clients_max;
+ unsigned n_objects_per_client_max;
+ unsigned n_entries_per_entry_group_max;
+
+ int disable_user_service_publishing;
};
extern Server *server;
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
void* userdata);
void avahi_dbus_async_service_resolver_free(AsyncServiceResolverInfo *i);
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
void* userdata);
DBusHandlerResult avahi_dbus_msg_async_service_resolver_impl(DBusConnection *c, DBusMessage *m, void *userdata);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
Server *server = NULL;
-static int disable_user_service_publishing = 0;
-
static int dbus_connect(void);
static void dbus_disconnect(void);
static void client_free(Client *c) {
-
+
assert(server);
assert(c);
while (c->async_host_name_resolvers)
avahi_dbus_async_host_name_resolver_free(c->async_host_name_resolvers);
-
+
while (c->sync_address_resolvers)
avahi_dbus_sync_address_resolver_free(c->sync_address_resolvers);
avahi_dbus_record_browser_free(c->record_browsers);
assert(c->n_objects == 0);
-
+
avahi_free(c->name);
AVAHI_LLIST_REMOVE(Client, clients, server->clients, c);
avahi_free(c);
+ assert(server->n_clients >= 1);
server->n_clients --;
- assert(server->n_clients >= 0);
}
static Client *client_get(const char *name, int create) {
if (!create)
return NULL;
- if (server->n_clients >= CLIENTS_MAX)
+ if (server->n_clients >= server->n_clients_max)
return NULL;
-
+
/* If not existent yet, create a new entry */
client = avahi_new(Client, 1);
client->id = server->current_id++;
client->name = avahi_strdup(name);
client->current_id = 0;
client->n_objects = 0;
-
+
AVAHI_LLIST_HEAD_INIT(EntryGroupInfo, client->entry_groups);
AVAHI_LLIST_HEAD_INIT(SyncHostNameResolverInfo, client->sync_host_name_resolvers);
AVAHI_LLIST_HEAD_INIT(AsyncHostNameResolverInfo, client->async_host_name_resolvers);
server->n_clients++;
assert(server->n_clients > 0);
-
+
return client;
}
if (server->reconnect) {
avahi_log_warn("Disconnected from D-Bus, trying to reconnect in %ims...", RECONNECT_MSEC);
-
+
dbus_disconnect();
-
+
avahi_elapse_time(&tv, RECONNECT_MSEC, 0);
-
+
if (server->reconnect_timeout)
server->poll_api->timeout_update(server->reconnect_timeout, &tv);
else
avahi_log_warn("Disconnected from D-Bus, exiting.");
raise(SIGQUIT);
}
-
+
return DBUS_HANDLER_RESULT_HANDLED;
-
+
} else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameAcquired")) {
char *name;
/* avahi_log_info(__FILE__": name acquired (%s)", name); */
return DBUS_HANDLER_RESULT_HANDLED;
-
+
} else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
char *name, *old, *new;
Client *client;
if ((client = client_get(name, FALSE))) {
- avahi_log_debug(__FILE__": client %s vanished.", name);
+ avahi_log_debug(__FILE__": client %s vanished.", name);
client_free(client);
}
}
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
dbus_message_get_member(m));
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "Server.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.Server.xml");
+
else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
}
return avahi_dbus_respond_string(c, m, avahi_server_get_host_name(avahi_server));
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "SetHostName")) {
char *name;
-
+
if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) {
avahi_log_warn("Error parsing Server::SetHostName message");
goto fail;
}
-
- if (avahi_server_set_host_name(avahi_server, name) < 0)
+
+ if (avahi_server_set_host_name(avahi_server, name) < 0)
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
avahi_log_info("Changing host name to '%s'.", name);
-
+
return avahi_dbus_respond_ok(c, m);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetDomainName")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_log_warn("Error parsing Server::GetHostNameFqdn message");
goto fail;
}
-
+
return avahi_dbus_respond_string(c, m, avahi_server_get_host_name_fqdn(avahi_server));
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "IsNSSSupportAvailable")) {
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) {
avahi_log_warn("Error parsing Server::IsNSSSupportAvailable message");
}
return avahi_dbus_respond_boolean(c, m, nss_support);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetVersionString")) {
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) {
avahi_log_warn("Error parsing Server::GetVersionString message");
goto fail;
}
-
+
return avahi_dbus_respond_string(c, m, PACKAGE_STRING);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAPIVersion")) {
avahi_log_warn("Error parsing Server::GetAPIVersion message");
goto fail;
}
-
+
return avahi_dbus_respond_uint32(c, m, AVAHI_DBUS_API_VERSION);
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetState")) {
AvahiServerState state;
-
+
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INVALID))) {
avahi_log_warn("Error parsing Server::GetState message");
goto fail;
}
-
+
state = avahi_server_get_state(avahi_server);
return avahi_dbus_respond_int32(c, m, (int32_t) state);
avahi_log_warn("Error parsing Server::GetLocalServiceCookie message");
goto fail;
}
-
+
return avahi_dbus_respond_uint32(c, m, avahi_server_get_local_service_cookie(avahi_server));
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceNameByIndex")) {
int32_t idx;
- char name[IF_NAMESIZE];
-
+ char name[IF_NAMESIZE];
+
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_INT32, &idx, DBUS_TYPE_INVALID))) {
avahi_log_warn("Error parsing Server::GetNetworkInterfaceNameByIndex message");
goto fail;
snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno));
return avahi_dbus_respond_error(c, m, AVAHI_ERR_OS, txt);
}
-
+
return avahi_dbus_respond_string(c, m, name);
#endif
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetNetworkInterfaceIndexByName")) {
char *n;
int32_t idx;
-
+
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) {
avahi_log_warn("Error parsing Server::GetNetworkInterfaceIndexByName message");
goto fail;
snprintf(txt, sizeof(txt), "OS Error: %s", strerror(errno));
return avahi_dbus_respond_error(c, m, AVAHI_ERR_OS, txt);
}
-
+
return avahi_dbus_respond_int32(c, m, idx);
#endif
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeHostName")) {
char *n, * t;
-
+
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) {
avahi_log_warn("Error parsing Server::GetAlternativeHostName message");
goto fail;
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeServiceName")) {
char *n, *t;
-
+
if (!(dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID)) || !n) {
avahi_log_warn("Error parsing Server::GetAlternativeServiceName message");
goto fail;
avahi_free(t);
return DBUS_HANDLER_RESULT_HANDLED;
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "EntryGroupNew")) {
Client *client;
EntryGroupInfo *i;
goto fail;
}
- if (disable_user_service_publishing)
+ if (server->disable_user_service_publishing)
return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_PERMITTED, NULL);
-
+
if (!(client = client_get(dbus_message_get_sender(m), TRUE))) {
avahi_log_warn("Too many clients, client request failed.");
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
i->n_entries = 0;
AVAHI_LLIST_PREPEND(EntryGroupInfo, entry_groups, client->entry_groups, i);
client->n_objects++;
-
+
if (!(i->entry_group = avahi_s_entry_group_new(avahi_server, avahi_dbus_entry_group_callback, i))) {
avahi_dbus_entry_group_free(i);
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
i->path = avahi_strdup_printf("/Client%u/EntryGroup%u", client->id, i->id);
dbus_connection_register_object_path(c, i->path, &vtable, i);
return avahi_dbus_respond_path(c, m, i->path);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveHostName")) {
Client *client;
int32_t interface, protocol, aprotocol;
uint32_t flags;
char *name;
SyncHostNameResolverInfo *i;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
avahi_dbus_sync_host_name_resolver_free(i);
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
-
+
return DBUS_HANDLER_RESULT_HANDLED;
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveAddress")) {
Client *client;
int32_t interface, protocol;
char *address;
SyncAddressResolverInfo *i;
AvahiAddress a;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
DBUS_TYPE_INT32, &protocol,
DBUS_TYPE_STRING, &address,
- DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_UINT32, &flags,
DBUS_TYPE_INVALID) || !address) {
avahi_log_warn("Error parsing Server::ResolveAddress message");
goto fail;
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
avahi_dbus_sync_address_resolver_free(i);
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
-
+
return DBUS_HANDLER_RESULT_HANDLED;
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "DomainBrowserNew")) {
Client *client;
DomainBrowserInfo *i;
int32_t interface, protocol, type;
uint32_t flags;
char *domain;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
int32_t interface, protocol;
uint32_t flags;
char *domain;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
avahi_dbus_service_type_browser_free(i);
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
-
+
i->path = avahi_strdup_printf("/Client%u/ServiceTypeBrowser%u", client->id, i->id);
dbus_connection_register_object_path(c, i->path, &vtable, i);
return avahi_dbus_respond_path(c, m, i->path);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceBrowserNew")) {
Client *client;
ServiceBrowserInfo *i;
int32_t interface, protocol;
uint32_t flags;
char *domain, *type;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
i->path = avahi_strdup_printf("/Client%u/ServiceBrowser%u", client->id, i->id);
dbus_connection_register_object_path(c, i->path, &vtable, i);
return avahi_dbus_respond_path(c, m, i->path);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ResolveService")) {
Client *client;
int32_t interface, protocol, aprotocol;
uint32_t flags;
char *name, *type, *domain;
SyncServiceResolverInfo *i;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
avahi_log_warn("Too many clients, client request failed.");
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
-
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
if (!*name)
name = NULL;
-
+
i = avahi_new(SyncServiceResolverInfo, 1);
i->client = client;
i->message = dbus_message_ref(m);
avahi_dbus_sync_service_resolver_free(i);
return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
}
-
+
return DBUS_HANDLER_RESULT_HANDLED;
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "ServiceResolverNew")) {
Client *client;
int32_t interface, protocol, aprotocol;
avahi_log_warn("Error parsing Server::ServiceResolverNew message");
goto fail;
}
-
+
if (!(client = client_get(dbus_message_get_sender(m), TRUE))) {
avahi_log_warn(__FILE__": Too many clients, client request failed.");
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
if (!*name)
name = NULL;
-
+
i = avahi_new(AsyncServiceResolverInfo, 1);
i->id = ++client->current_id;
i->client = client;
}
/* avahi_log_debug(__FILE__": [%s], new service resolver for <%s.%s.%s>", i->path, name, type, domain); */
-
+
i->path = avahi_strdup_printf("/Client%u/ServiceResolver%u", client->id, i->id);
dbus_connection_register_object_path(c, i->path, &vtable, i);
return avahi_dbus_respond_path(c, m, i->path);
NULL,
NULL
};
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
avahi_log_warn("Error parsing Server::HostNameResolverNew message");
goto fail;
}
-
+
if (!(client = client_get(dbus_message_get_sender(m), TRUE))) {
avahi_log_warn(__FILE__": Too many clients, client request failed.");
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
NULL,
NULL
};
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn(__FILE__": Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
i->path = avahi_strdup_printf("/Client%u/AddressResolver%u", client->id, i->id);
dbus_connection_register_object_path(c, i->path, &vtable, i);
return avahi_dbus_respond_path(c, m, i->path);
-
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "RecordBrowserNew")) {
Client *client;
RecordBrowserInfo *i;
char *name;
uint16_t type, clazz;
AvahiKey *key;
-
+
if (!dbus_message_get_args(
m, &error,
DBUS_TYPE_INT32, &interface,
goto fail;
}
- if (!avahi_is_valid_domain_name(name))
+ if (!avahi_is_valid_domain_name(name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_INVALID_DOMAIN_NAME, NULL);
if (!(client = client_get(dbus_message_get_sender(m), TRUE))) {
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_CLIENTS, NULL);
}
- if (client->n_objects >= OBJECTS_PER_CLIENT_MAX) {
+ if (client->n_objects >= server->n_objects_per_client_max) {
avahi_log_warn("Too many objects for client '%s', client request failed.", client->name);
return avahi_dbus_respond_error(c, m, AVAHI_ERR_TOO_MANY_OBJECTS, NULL);
}
}
avahi_key_unref(key);
-
+
i->path = avahi_strdup_printf("/Client%u/RecordBrowser%u", client->id, i->id);
dbus_connection_register_object_path(c, i->path, &vtable, i);
return avahi_dbus_respond_path(c, m, i->path);
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
DBusMessage *m;
int32_t t;
const char *e;
-
+
if (!server || !server->bus)
return;
m = dbus_message_new_signal(AVAHI_DBUS_PATH_SERVER, AVAHI_DBUS_INTERFACE_SERVER, "StateChanged");
+
+ if (!m) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
t = (int32_t) state;
if (state == AVAHI_SERVER_COLLISION)
e = avahi_error_number_to_dbus(avahi_server_errno(avahi_server));
else
e = AVAHI_DBUS_ERR_OK;
-
+
dbus_message_append_args(m, DBUS_TYPE_INT32, &t, DBUS_TYPE_STRING, &e, DBUS_TYPE_INVALID);
dbus_connection_send(server->bus, m, NULL);
dbus_message_unref(m);
dbus_error_init(&error);
-#ifdef HAVE_DBUS_BUS_GET_PRIVATE
+#ifdef HAVE_DBUS_BUS_GET_PRIVATE
if (!(server->bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) {
assert(dbus_error_is_set(&error));
avahi_log_error("dbus_bus_get_private(): %s", error.message);
if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a)
a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS;
-
+
if (!(server->bus = dbus_connection_open_private(a, &error))) {
assert(dbus_error_is_set(&error));
avahi_log_error("dbus_bus_open_private(): %s", error.message);
}
}
#endif
-
+
if (avahi_dbus_connection_glue(server->bus, server->poll_api) < 0) {
avahi_log_error("avahi_dbus_connection_glue() failed");
goto fail;
}
dbus_connection_set_exit_on_disconnect(server->bus, FALSE);
-
+
if (dbus_bus_request_name(
server->bus,
AVAHI_DBUS_NAME,
avahi_log_error("dbus_connection_add_filter() failed");
goto fail;
}
-
+
dbus_bus_add_match(server->bus, "type='signal',""interface='" DBUS_INTERFACE_DBUS "'", &error);
if (dbus_error_is_set(&error)) {
avahi_log_error("dbus_bus_add_match(): %s", error.message);
goto fail;
}
-
+
if (!(dbus_connection_register_object_path(server->bus, AVAHI_DBUS_PATH_SERVER, &server_vtable, NULL))) {
avahi_log_error("dbus_connection_register_object_path() failed");
goto fail;
while (server->clients)
client_free(server->clients);
-
+
assert(server->n_clients == 0);
if (server->bus) {
}
}
-int dbus_protocol_setup(const AvahiPoll *poll_api, int _disable_user_service_publishing, int force) {
+int dbus_protocol_setup(const AvahiPoll *poll_api,
+ int _disable_user_service_publishing,
+ int _n_clients_max,
+ int _n_objects_per_client_max,
+ int _n_entries_per_entry_group_max,
+ int force) {
- disable_user_service_publishing = _disable_user_service_publishing;
server = avahi_new(Server, 1);
AVAHI_LLIST_HEAD_INIT(Clients, server->clients);
server->poll_api = poll_api;
server->reconnect_timeout = NULL;
server->reconnect = force;
+ server->disable_user_service_publishing = _disable_user_service_publishing;
+ server->n_clients_max = _n_clients_max > 0 ? _n_clients_max : DEFAULT_CLIENTS_MAX;
+ server->n_objects_per_client_max = _n_objects_per_client_max > 0 ? _n_objects_per_client_max : DEFAULT_OBJECTS_PER_CLIENT_MAX;
+ server->n_entries_per_entry_group_max = _n_entries_per_entry_group_max > 0 ? _n_entries_per_entry_group_max : DEFAULT_ENTRIES_PER_ENTRY_GROUP_MAX;
if (dbus_connect() < 0) {
struct timeval tv;
goto fail;
avahi_log_warn("WARNING: Failed to contact D-Bus daemon, retrying in %ims.", RECONNECT_MSEC);
-
+
avahi_elapse_time(&tv, RECONNECT_MSEC, 0);
server->reconnect_timeout = server->poll_api->timeout_new(server->poll_api, &tv, reconnect_callback, NULL);
}
-
+
return 0;
fail:
if (server->reconnect_timeout)
server->poll_api->timeout_free(server->reconnect_timeout);
-
+
avahi_free(server);
server = NULL;
}
#ifndef foodbusprotocolhfoo
#define foodbusprotocolhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
-int dbus_protocol_setup(const AvahiPoll *poll_api, int disable_user_service_publishing, int force);
+int dbus_protocol_setup(const AvahiPoll *poll_api,
+ int _disable_user_service_publishing,
+ int _n_clients_max,
+ int _n_objects_per_client_max,
+ int _n_entries_per_entry_group_max,
+ int force);
void dbus_protocol_shutdown(void);
void dbus_protocol_server_state_changed(AvahiServerState state);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
}
AVAHI_LLIST_REMOVE(RecordBrowserInfo, record_browsers, i->client->record_browsers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "RecordBrowser.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.RecordBrowser.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_record_browser_free(i);
return avahi_dbus_respond_ok(c, m);
-
+
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
AvahiRecord *record,
AvahiLookupResultFlags flags,
void* userdata) {
-
+
RecordBrowserInfo *i = userdata;
DBusMessage *m = NULL;
int32_t i_interface, i_protocol;
uint32_t u_flags;
-
+
assert(b);
assert(i);
m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_RECORD_BROWSER, avahi_dbus_map_browse_signal_name(event));
+ if (!m) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
uint8_t rdata[0xFFFF];
size_t size;
assert(record);
-
+
if (!(dbus_message_append_args(
m,
DBUS_TYPE_INT32, &i_interface,
DBUS_TYPE_UINT16, &record->key->type,
DBUS_TYPE_INVALID)))
goto fail;
-
+
if ((size = avahi_rdata_serialize(record, rdata, sizeof(rdata))) == (size_t) -1 ||
avahi_dbus_append_rdata(m, rdata, size) < 0) {
avahi_log_debug(__FILE__": Failed to append rdata");
dbus_message_unref(m);
return;
}
-
+
dbus_message_append_args(
m,
DBUS_TYPE_UINT32, &u_flags,
DBUS_TYPE_INVALID);
-
+
} else if (event == AVAHI_BROWSER_FAILURE)
avahi_dbus_append_server_error(m);
-
- dbus_message_set_destination(m, i->client->name);
+
+ dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
dbus_message_unref(m);
return;
-
+
fail:
if (m)
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_connection_unregister_object_path(server->bus, i->path);
avahi_free(i->path);
}
-
+
AVAHI_LLIST_REMOVE(ServiceBrowserInfo, service_browsers, i->client->service_browsers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "ServiceBrowser.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.ServiceBrowser.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_service_browser_free(i);
return avahi_dbus_respond_ok(c, m);
-
+
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
DBusMessage *m;
int32_t i_interface, i_protocol;
uint32_t u_flags;
-
+
assert(b);
assert(i);
m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_BROWSER, avahi_dbus_map_browse_signal_name(event));
+ if (!m) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_BROWSER_NEW) {
/* Patch in AVAHI_LOOKUP_RESULT_OUR_OWN */
if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0)
flags |= AVAHI_LOOKUP_RESULT_OUR_OWN;
}
-
+
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
u_flags = (uint32_t) flags;
-
+
if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
assert(name);
assert(type);
assert(domain);
-
+
dbus_message_append_args(
m,
DBUS_TYPE_INT32, &i_interface,
DBUS_TYPE_INVALID);
} else if (event == AVAHI_BROWSER_FAILURE)
avahi_dbus_append_server_error(m);
-
- dbus_message_set_destination(m, i->client->name);
+
+ dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
dbus_message_unref(m);
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_connection_unregister_object_path(server->bus, i->path);
avahi_free(i->path);
}
-
+
AVAHI_LLIST_REMOVE(ServiceTypeBrowserInfo, service_type_browsers, i->client->service_type_browsers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
assert(c);
assert(m);
assert(i);
-
+
dbus_error_init(&error);
avahi_log_debug(__FILE__": interface=%s, path=%s, member=%s",
/* Introspection */
if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- return avahi_dbus_handle_introspect(c, m, "ServiceTypeBrowser.introspect");
-
+ return avahi_dbus_handle_introspect(c, m, "org.freedesktop.Avahi.ServiceTypeBrowser.xml");
+
/* Access control */
- if (strcmp(dbus_message_get_sender(m), i->client->name))
+ if (strcmp(dbus_message_get_sender(m), i->client->name))
return avahi_dbus_respond_error(c, m, AVAHI_ERR_ACCESS_DENIED, NULL);
-
+
if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, "Free")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_dbus_service_type_browser_free(i);
return avahi_dbus_respond_ok(c, m);
-
+
}
-
+
avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
DBusMessage *m;
int32_t i_interface, i_protocol;
uint32_t u_flags;
-
+
assert(b);
assert(i);
m = dbus_message_new_signal(i->path, AVAHI_DBUS_INTERFACE_SERVICE_TYPE_BROWSER, avahi_dbus_map_browse_signal_name(event));
+ if (!m) {
+ avahi_log_error("Failed allocate message");
+ return;
+ }
+
if (event == AVAHI_BROWSER_NEW || event == AVAHI_BROWSER_REMOVE) {
assert(type);
assert(domain);
DBUS_TYPE_INVALID);
} else if (event == AVAHI_BROWSER_FAILURE)
avahi_dbus_append_server_error(m);
-
- dbus_message_set_destination(m, i->client->name);
+
+ dbus_message_set_destination(m, i->client->name);
dbus_connection_send(server->bus, m, NULL);
dbus_message_unref(m);
}
-
-
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_message_unref(i->message);
AVAHI_LLIST_REMOVE(SyncAddressResolverInfo, sync_address_resolvers, i->client->sync_address_resolvers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
void avahi_dbus_sync_address_resolver_callback(AvahiSAddressResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const AvahiAddress *address, const char *host_name, AvahiLookupResultFlags flags, void* userdata) {
SyncAddressResolverInfo *i = userdata;
-
+
assert(r);
assert(address);
assert(i);
i_protocol = (int32_t) protocol;
i_aprotocol = (int32_t) address->proto;
u_flags = (uint32_t) flags;
-
+
reply = dbus_message_new_method_return(i->message);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ goto finish;
+ }
+
dbus_message_append_args(
reply,
DBUS_TYPE_INT32, &i_interface,
avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
}
+finish:
avahi_dbus_sync_address_resolver_free(i);
}
-
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_message_unref(i->message);
AVAHI_LLIST_REMOVE(SyncHostNameResolverInfo, sync_host_name_resolvers, i->client->sync_host_name_resolvers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
void avahi_dbus_sync_host_name_resolver_callback(AvahiSHostNameResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *host_name, const AvahiAddress *a, AvahiLookupResultFlags flags, void* userdata) {
SyncHostNameResolverInfo *i = userdata;
-
+
assert(r);
assert(host_name);
assert(i);
i_protocol = (int32_t) protocol;
i_aprotocol = (int32_t) a->proto;
u_flags = (uint32_t) flags;
-
+
reply = dbus_message_new_method_return(i->message);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ goto finish;
+ }
+
dbus_message_append_args(
reply,
DBUS_TYPE_INT32, &i_interface,
avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
}
+finish:
avahi_dbus_sync_host_name_resolver_free(i);
}
-
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbus_message_unref(i->message);
AVAHI_LLIST_REMOVE(SyncServiceResolverInfo, sync_service_resolvers, i->client->sync_service_resolvers, i);
+ assert(i->client->n_objects >= 1);
i->client->n_objects--;
- assert(i->client->n_objects >= 0);
avahi_free(i);
}
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
void* userdata) {
-
+
SyncServiceResolverInfo *i = userdata;
-
+
assert(r);
assert(i);
int32_t i_interface, i_protocol, i_aprotocol;
uint32_t u_flags;
DBusMessage *reply;
-
+
assert(host_name);
if (!name)
name = "";
- if (a)
+ if (a)
avahi_address_snprint(t, sizeof(t), a);
else
t[0] = 0;
if (avahi_dbus_is_our_own_service(i->client, interface, protocol, name, type, domain) > 0)
flags |= AVAHI_LOOKUP_RESULT_OUR_OWN;
-
+
i_interface = (int32_t) interface;
i_protocol = (int32_t) protocol;
- if (a)
- i_aprotocol = (int32_t) a->proto;
- else
- i_aprotocol = AVAHI_PROTO_UNSPEC;
+ if (a)
+ i_aprotocol = (int32_t) a->proto;
+ else
+ i_aprotocol = AVAHI_PROTO_UNSPEC;
u_flags = (uint32_t) flags;
reply = dbus_message_new_method_return(i->message);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ goto finish;
+ }
+
dbus_message_append_args(
reply,
DBUS_TYPE_INT32, &i_interface,
DBUS_TYPE_INVALID);
avahi_dbus_append_string_list(reply, txt);
-
+
dbus_message_append_args(
reply,
DBUS_TYPE_UINT32, &u_flags,
dbus_message_unref(reply);
} else {
assert(event == AVAHI_RESOLVER_FAILURE);
-
+
avahi_dbus_respond_error(server->bus, i->message, avahi_server_errno(avahi_server), NULL);
}
+finish:
avahi_dbus_sync_service_resolver_free(i);
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (!text)
text = avahi_strerror(error);
-
+
reply = dbus_message_new_error(m, avahi_error_number_to_dbus(error), text);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
avahi_log_debug(__FILE__": Responding error '%s' (%i)", text, error);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
DBusMessage *reply;
reply = dbus_message_new_method_return(m);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_message_append_args(reply, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
DBusMessage *reply;
reply = dbus_message_new_method_return(m);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_message_append_args(reply, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
DBusMessage *reply;
reply = dbus_message_new_method_return(m);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_message_append_args(reply, DBUS_TYPE_UINT32, &u, DBUS_TYPE_INVALID);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
DBusMessage *reply;
reply = dbus_message_new_method_return(m);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &b, DBUS_TYPE_INVALID);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
DBusMessage *reply;
reply = dbus_message_new_method_return(m);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
DBusMessage *reply;
reply = dbus_message_new_method_return(m);
+
+ if (!reply) {
+ avahi_log_error("Failed allocate message");
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+
dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
dbus_connection_send(c, reply, NULL);
dbus_message_unref(reply);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
}
const char *t;
t = avahi_error_number_to_dbus(avahi_server_errno(avahi_server));
-
+
dbus_message_append_args(
reply,
DBUS_TYPE_STRING, &t,
char *buf = NULL;
assert(fname);
-
+
#ifdef ENABLE_CHROOT
fd = avahi_chroot_helper_get_fd(fname);
#else
close(fd);
return buf;
-
+
fail:
if (fd >= 0)
close(fd);
-
+
if (buf)
avahi_free(buf);
return NULL;
-
+
}
DBusHandlerResult avahi_dbus_handle_introspect(DBusConnection *c, DBusMessage *m, const char *fname) {
char *contents, *path;
DBusError error;
-
+
assert(c);
assert(m);
assert(fname);
path = avahi_strdup_printf("%s/%s", AVAHI_DBUS_INTROSPECTION_DIR, fname);
contents = file_get_contents(path);
avahi_free(path);
-
+
if (!contents) {
avahi_log_error("Failed to load introspection data.");
goto fail;
}
-
+
avahi_dbus_respond_string(c, m, contents);
avahi_free(contents);
-
+
return DBUS_HANDLER_RESULT_HANDLED;
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
-
+
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
void avahi_dbus_append_string_list(DBusMessage *reply, AvahiStringList *txt) {
AvahiStringList *p;
DBusMessageIter iter, sub;
-
+
assert(reply);
dbus_message_iter_init_append(reply, &iter);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "ay", &sub);
-
+
for (p = txt; p; p = p->next) {
DBusMessageIter sub2;
const uint8_t *data = p->text;
-
+
dbus_message_iter_open_container(&sub, DBUS_TYPE_ARRAY, "y", &sub2);
- dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size);
+ dbus_message_iter_append_fixed_array(&sub2, DBUS_TYPE_BYTE, &data, p->size);
dbus_message_iter_close_container(&sub, &sub2);
-
+
}
dbus_message_iter_close_container(&iter, &sub);
}
uint8_t *k;
assert(m);
-
+
dbus_message_iter_init(m, &iter);
for (j = 0; j < idx; j++)
dbus_message_iter_next(&iter);
-
+
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_BYTE)
goto fail;
*rdata = k;
*size = n;
-
+
return 0;
-
+
fail:
avahi_log_warn("Error parsing data");
assert(m);
assert(l);
-
+
dbus_message_iter_init(m, &iter);
for (j = 0; j < idx; j++)
dbus_message_iter_next(&iter);
-
+
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY)
goto fail;
dbus_message_iter_recurse(&iter, &sub);
-
+
for (;;) {
int at, n;
const uint8_t *k;
DBusMessageIter sub2;
-
+
if ((at = dbus_message_iter_get_arg_type(&sub)) == DBUS_TYPE_INVALID)
break;
-
+
assert(at == DBUS_TYPE_ARRAY);
-
+
if (dbus_message_iter_get_element_type(&sub) != DBUS_TYPE_BYTE)
goto fail;
dbus_message_iter_recurse(&sub, &sub2);
-
+
k = (const uint8_t*) "";
n = 0;
dbus_message_iter_get_fixed_array(&sub2, &k, &n);
if (!k)
k = (const uint8_t*) "";
-
+
strlst = avahi_string_list_add_arbitrary(strlst, k, n);
-
+
dbus_message_iter_next(&sub);
}
*l = strlst;
-
+
return 0;
-
+
fail:
avahi_log_warn("Error parsing TXT data");
int avahi_dbus_append_rdata(DBusMessage *message, const void *rdata, size_t size) {
DBusMessageIter iter, sub;
-
+
assert(message);
-
+
dbus_message_iter_init_append(message, &iter);
-
+
if (!(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &sub)) ||
!(dbus_message_iter_append_fixed_array(&sub, DBUS_TYPE_BYTE, &rdata, size)) ||
!(dbus_message_iter_close_container(&iter, &sub)))
return -1;
-
+
return 0;
}
#ifndef foodbusutilhfoo
#define foodbusutilhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
-<!-- $Id$ -->
-
<!--
This file is part of avahi.
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
for (i = split; *i; i++)
printf("<%s> ", *i);
-
+
avahi_strfreev(split);
printf("\n");
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
FILE *fo;
AvahiIniFileGroup *group = NULL;
unsigned line;
-
+
assert(fname);
if (!(fo = fopen(fname, "r"))) {
avahi_log_error("Failed to open file '%s': %s", fname, strerror(errno));
return NULL;
}
-
+
f = avahi_new(AvahiIniFile, 1);
AVAHI_LLIST_HEAD_INIT(AvahiIniFileGroup, f->groups);
f->n_groups = 0;
while (!feof(fo)) {
char ln[256], *s, *e;
AvahiIniFilePair *pair;
-
+
if (!(fgets(ln, sizeof(ln), fo)))
break;
line++;
-
+
s = ln + strspn(ln, " \t");
s[strcspn(s, "\r\n")] = 0;
if (*s == '[') {
/* new group */
-
+
if (!(e = strchr(s, ']'))) {
avahi_log_error("Unclosed group header in %s:%u: <%s>", fname, line, s);
goto fail;
}
*e = 0;
-
+
group = avahi_new(AvahiIniFileGroup, 1);
group->name = avahi_strdup(s+1);
group->n_pairs = 0;
AVAHI_LLIST_HEAD_INIT(AvahiIniFilePair, group->pairs);
-
+
AVAHI_LLIST_PREPEND(AvahiIniFileGroup, groups, f->groups, group);
f->n_groups++;
} else {
avahi_log_error("Missing assignment in %s:%u: <%s>", fname, line, s);
goto fail;
}
-
+
if (!group) {
avahi_log_error("Assignment outside group in %s:%u <%s>", fname, line, s);
goto fail;
}
-
+
/* Split the key and the value */
*(e++) = 0;
-
+
pair = avahi_new(AvahiIniFilePair, 1);
pair->key = avahi_strdup(s);
pair->value = avahi_strdup(e);
-
+
AVAHI_LLIST_PREPEND(AvahiIniFilePair, pairs, group->pairs, pair);
group->n_pairs++;
}
}
-
+
fclose(fo);
-
+
return f;
fail:
while ((g = f->groups)) {
AvahiIniFilePair *p;
-
+
while ((p = g->pairs)) {
avahi_free(p->key);
avahi_free(p->value);
if (!p)
return;
-
+
for (i = p; *i; i++)
avahi_free(*i);
#ifndef fooinifileparserhfoo
#define fooinifileparserhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-->
-<!-- $Id$ -->
-
<xsl:output method="xml" version="1.0" encoding="iso-8859-15" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes"/>
<xsl:template match="/">
-/* $Id$ */
-
/***
This file is part of avahi.
#include "static-services.h"
#include "static-hosts.h"
#include "ini-file-parser.h"
+#include "sd-daemon.h"
#ifdef HAVE_DBUS
#include "dbus-protocol.h"
#ifdef HAVE_DBUS
int enable_dbus;
int fail_on_missing_dbus;
+ unsigned n_clients_max;
+ unsigned n_objects_per_client_max;
+ unsigned n_entries_per_entry_group_max;
#endif
int drop_root;
int set_rlimits;
return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T';
}
+static int parse_unsigned(const char *s, unsigned *u) {
+ char *e = NULL;
+ unsigned long ul;
+ unsigned k;
+
+ errno = 0;
+ ul = strtoul(s, &e, 0);
+
+ if (!e || *e || errno != 0)
+ return -1;
+
+ k = (unsigned) ul;
+
+ if ((unsigned long) k != ul)
+ return -1;
+
+ *u = k;
+ return 0;
+}
+
static int load_config_file(DaemonConfig *c) {
int r = -1;
AvahiIniFile *f;
c->server_config.deny_interfaces = avahi_string_list_add(c->server_config.deny_interfaces, *t);
avahi_strfreev(e);
+ } else if (strcasecmp(p->key, "cache-entries-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid cache-entries-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->server_config.n_cache_entries_max = k;
+#ifdef HAVE_DBUS
+ } else if (strcasecmp(p->key, "clients-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid clients-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->n_clients_max = k;
+ } else if (strcasecmp(p->key, "objects-per-client-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid objects-per-client-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->n_objects_per_client_max = k;
+ } else if (strcasecmp(p->key, "entries-per-entry-group-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid entries-per-entry-group-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->n_entries_per_entry_group_max = k;
+#endif
} else {
avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name);
goto finish;
#ifdef HAVE_DBUS
if (c->enable_dbus) {
- if (dbus_protocol_setup(poll_api, config.disable_user_service_publishing, !c->fail_on_missing_dbus
+ if (dbus_protocol_setup(poll_api,
+ config.disable_user_service_publishing,
+ config.n_clients_max,
+ config.n_objects_per_client_max,
+ config.n_entries_per_entry_group_max,
+ !c->fail_on_missing_dbus
#ifdef ENABLE_CHROOT
&& !config.use_chroot
#endif
#endif
/* the sysctl() call from iface-pfroute.c needs locked memory on FreeBSD */
-#if defined(RLIMIT_MEMLOCK) && !defined(__FreeBSD__)
+#if defined(RLIMIT_MEMLOCK) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
/* We don't need locked memory */
set_one_rlimit(RLIMIT_MEMLOCK, 0, "RLIMIT_MEMLOCK");
#endif
#ifdef HAVE_DBUS
config.enable_dbus = 1;
config.fail_on_missing_dbus = 1;
+ config.n_clients_max = 0;
+ config.n_objects_per_client_max = 0;
+ config.n_entries_per_entry_group_max = 0;
#endif
config.drop_root = 1;
if (config.use_syslog || config.daemonize)
daemon_log_use = DAEMON_LOG_SYSLOG;
- if (daemon_close_all(-1) < 0) {
- avahi_log_error("Failed to close remaining file descriptors: %s", strerror(errno));
- goto finish;
- }
+ if (sd_listen_fds(0) <= 0)
+ if (daemon_close_all(-1) < 0) {
+ avahi_log_error("Failed to close remaining file descriptors: %s", strerror(errno));
+ goto finish;
+ }
if (make_runtime_dir() < 0)
goto finish;
#ifndef foomainhfoo
#define foomainhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.AddressResolver">
+
+ <method name="Free"/>
+
+ <signal name="Found">
+ <arg name="interface" type="i" direction="out"/>
+ <arg name="protocol" type="i" direction="out"/>
+ <arg name="aprotocol" type="i" direction="out"/>
+ <arg name="address" type="s" direction="out"/>
+ <arg name="name" type="s" direction="out"/>
+ <arg name="flags" type="u" direction="out"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.DomainBrowser">
+
+ <method name="Free"/>
+
+ <signal name="ItemNew">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="domain" type="s"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="ItemRemove">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="domain" type="s"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ <signal name="AllForNow"/>
+
+ <signal name="CacheExhausted"/>
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out"/>
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.EntryGroup">
+ <method name="Free"/>
+ <method name="Commit"/>
+ <method name="Reset"/>
+
+ <method name="GetState">
+ <arg name="state" type="i" direction="out"/>
+ </method>
+
+ <signal name="StateChanged">
+ <arg name="state" type="i"/>
+ <arg name="error" type="s"/>
+ </signal>
+
+ <method name="IsEmpty">
+ <arg name="empty" type="b" direction="out"/>
+ </method>
+
+ <method name="AddService">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="host" type="s" direction="in"/>
+ <arg name="port" type="q" direction="in"/>
+ <arg name="txt" type="aay" direction="in"/>
+ </method>
+
+ <method name="AddServiceSubtype">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="subtype" type="s" direction="in"/>
+ </method>
+
+ <method name="UpdateServiceTxt">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="txt" type="aay" direction="in"/>
+ </method>
+
+ <method name="AddAddress">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="address" type="s" direction="in"/>
+ </method>
+
+ <method name="AddRecord">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="clazz" type="q" direction="in"/>
+ <arg name="type" type="q" direction="in"/>
+ <arg name="ttl" type="u" direction="in"/>
+ <arg name="rdata" type="ay" direction="in"/>
+ </method>
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.HostNameResolver">
+
+ <method name="Free"/>
+
+ <signal name="Found">
+ <arg name="interface" type="i" direction="out"/>
+ <arg name="protocol" type="i" direction="out"/>
+ <arg name="name" type="s" direction="out"/>
+ <arg name="aprotocol" type="i" direction="out"/>
+ <arg name="address" type="s" direction="out"/>
+ <arg name="flags" type="u" direction="out"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.RecordBrowser">
+
+ <method name="Free"/>
+
+ <signal name="ItemNew">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="name" type="s"/>
+ <arg name="clazz" type="q"/>
+ <arg name="type" type="q"/>
+ <arg name="rdata" type="ay"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="ItemRemove">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="name" type="s"/>
+ <arg name="clazz" type="q"/>
+ <arg name="type" type="q"/>
+ <arg name="rdata" type="ay"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ <signal name="AllForNow"/>
+
+ <signal name="CacheExhausted"/>
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out"/>
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.Server">
+
+ <method name="GetVersionString">
+ <arg name="version" type="s" direction="out"/>
+ </method>
+
+ <method name="GetAPIVersion">
+ <arg name="version" type="u" direction="out"/>
+ </method>
+
+ <method name="GetHostName">
+ <arg name="name" type="s" direction="out"/>
+ </method>
+ <method name="SetHostName">
+ <arg name="name" type="s" direction="in"/>
+ </method>
+ <method name="GetHostNameFqdn">
+ <arg name="name" type="s" direction="out"/>
+ </method>
+ <method name="GetDomainName">
+ <arg name="name" type="s" direction="out"/>
+ </method>
+
+ <method name="IsNSSSupportAvailable">
+ <arg name="yes" type="b" direction="out"/>
+ </method>
+
+ <method name="GetState">
+ <arg name="state" type="i" direction="out"/>
+ </method>
+
+ <signal name="StateChanged">
+ <arg name="state" type="i"/>
+ <arg name="error" type="s"/>
+ </signal>
+
+ <method name="GetLocalServiceCookie">
+ <arg name="cookie" type="u" direction="out"/>
+ </method>
+
+ <method name="GetAlternativeHostName">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="name" type="s" direction="out"/>
+ </method>
+
+ <method name="GetAlternativeServiceName">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="name" type="s" direction="out"/>
+ </method>
+
+ <method name="GetNetworkInterfaceNameByIndex">
+ <arg name="index" type="i" direction="in"/>
+ <arg name="name" type="s" direction="out"/>
+ </method>
+ <method name="GetNetworkInterfaceIndexByName">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="index" type="i" direction="out"/>
+ </method>
+
+ <method name="ResolveHostName">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="aprotocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="interface" type="i" direction="out"/>
+ <arg name="protocol" type="i" direction="out"/>
+ <arg name="name" type="s" direction="out"/>
+ <arg name="aprotocol" type="i" direction="out"/>
+ <arg name="address" type="s" direction="out"/>
+ <arg name="flags" type="u" direction="out"/>
+ </method>
+
+ <method name="ResolveAddress">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="address" type="s" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="interface" type="i" direction="out"/>
+ <arg name="protocol" type="i" direction="out"/>
+ <arg name="aprotocol" type="i" direction="out"/>
+ <arg name="address" type="s" direction="out"/>
+ <arg name="name" type="s" direction="out"/>
+ <arg name="flags" type="u" direction="out"/>
+ </method>
+
+ <method name="ResolveService">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="aprotocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="interface" type="i" direction="out"/>
+ <arg name="protocol" type="i" direction="out"/>
+ <arg name="name" type="s" direction="out"/>
+ <arg name="type" type="s" direction="out"/>
+ <arg name="domain" type="s" direction="out"/>
+ <arg name="host" type="s" direction="out"/>
+ <arg name="aprotocol" type="i" direction="out"/>
+ <arg name="address" type="s" direction="out"/>
+ <arg name="port" type="q" direction="out"/>
+ <arg name="txt" type="aay" direction="out"/>
+ <arg name="flags" type="u" direction="out"/>
+ </method>
+
+ <method name="EntryGroupNew">
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="DomainBrowserNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="btype" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="ServiceTypeBrowserNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="ServiceBrowserNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="ServiceResolverNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ <arg name="domain" type="s" direction="in"/>
+ <arg name="aprotocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="HostNameResolverNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="aprotocol" type="i" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="AddressResolverNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="address" type="s" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+ <method name="RecordBrowserNew">
+ <arg name="interface" type="i" direction="in"/>
+ <arg name="protocol" type="i" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="clazz" type="q" direction="in"/>
+ <arg name="type" type="q" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+
+ <arg name="path" type="o" direction="out"/>
+ </method>
+
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.ServiceBrowser">
+
+ <method name="Free"/>
+
+ <signal name="ItemNew">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="name" type="s"/>
+ <arg name="type" type="s"/>
+ <arg name="domain" type="s"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="ItemRemove">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="name" type="s"/>
+ <arg name="type" type="s"/>
+ <arg name="domain" type="s"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ <signal name="AllForNow"/>
+
+ <signal name="CacheExhausted"/>
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.ServiceResolver">
+
+ <method name="Free"/>
+
+ <signal name="Found">
+ <arg name="interface" type="i" direction="out"/>
+ <arg name="protocol" type="i" direction="out"/>
+ <arg name="name" type="s" direction="out"/>
+ <arg name="type" type="s" direction="out"/>
+ <arg name="domain" type="s" direction="out"/>
+ <arg name="host" type="s" direction="out"/>
+ <arg name="aprotocol" type="i" direction="out"/>
+ <arg name="address" type="s" direction="out"/>
+ <arg name="port" type="q" direction="out"/>
+ <arg name="txt" type="aay" direction="out"/>
+ <arg name="flags" type="u" direction="out"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ </interface>
+</node>
--- /dev/null
+<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
+<?xml-stylesheet type="text/xsl" href="introspect.xsl"?>
+<!DOCTYPE node SYSTEM "introspect.dtd">
+
+<!--
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+-->
+
+<node>
+
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" type="s" direction="out" />
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.Avahi.ServiceTypeBrowser">
+
+ <method name="Free"/>
+
+ <signal name="ItemNew">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="type" type="s"/>
+ <arg name="domain" type="s"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="ItemRemove">
+ <arg name="interface" type="i"/>
+ <arg name="protocol" type="i"/>
+ <arg name="type" type="s"/>
+ <arg name="domain" type="s"/>
+ <arg name="flags" type="u"/>
+ </signal>
+
+ <signal name="Failure">
+ <arg name="error" type="s"/>
+ </signal>
+
+ <signal name="AllForNow"/>
+
+ <signal name="CacheExhausted"/>
+
+ </interface>
+</node>
--- /dev/null
+# This file is part of avahi.
+#
+# avahi is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# avahi is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with avahi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+[D-BUS Service]
+Name=org.freedesktop.Avahi
+SystemdService=avahi-daemon.service
+
+# This service should not be bus activated if systemd isn't running,
+# so that activation won't conflict with the init script startup.
+Exec=/bin/false
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ Copyright 2010 Lennart Poettering
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+***/
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/fcntl.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "sd-daemon.h"
+
+int sd_listen_fds(int unset_environment) {
+
+#if defined(DISABLE_SYSTEMD) || !defined(__linux__)
+ return 0;
+#else
+ int r, fd;
+ const char *e;
+ char *p = NULL;
+ unsigned long l;
+
+ if (!(e = getenv("LISTEN_PID"))) {
+ r = 0;
+ goto finish;
+ }
+
+ errno = 0;
+ l = strtoul(e, &p, 10);
+
+ if (errno != 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ if (!p || *p || l <= 0) {
+ r = -EINVAL;
+ goto finish;
+ }
+
+ /* Is this for us? */
+ if (getpid() != (pid_t) l) {
+ r = 0;
+ goto finish;
+ }
+
+ if (!(e = getenv("LISTEN_FDS"))) {
+ r = 0;
+ goto finish;
+ }
+
+ errno = 0;
+ l = strtoul(e, &p, 10);
+
+ if (errno != 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ if (!p || *p) {
+ r = -EINVAL;
+ goto finish;
+ }
+
+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
+ int flags;
+
+ if ((flags = fcntl(fd, F_GETFD)) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ if (flags & FD_CLOEXEC)
+ continue;
+
+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
+ r = -errno;
+ goto finish;
+ }
+ }
+
+ r = (int) l;
+
+finish:
+ if (unset_environment) {
+ unsetenv("LISTEN_PID");
+ unsetenv("LISTEN_FDS");
+ }
+
+ return r;
+#endif
+}
+
+int sd_is_fifo(int fd, const char *path) {
+ struct stat st_fd;
+
+ if (fd < 0)
+ return -EINVAL;
+
+ memset(&st_fd, 0, sizeof(st_fd));
+ if (fstat(fd, &st_fd) < 0)
+ return -errno;
+
+ if (!S_ISFIFO(st_fd.st_mode))
+ return 0;
+
+ if (path) {
+ struct stat st_path;
+
+ memset(&st_path, 0, sizeof(st_path));
+ if (fstat(fd, &st_path) < 0) {
+
+ if (errno == ENOENT || errno == ENOTDIR)
+ return 0;
+
+ return -errno;
+ }
+
+ return
+ st_path.st_dev == st_fd.st_dev &&
+ st_path.st_ino == st_fd.st_ino;
+ }
+
+ return 1;
+}
+
+static int sd_is_socket_internal(int fd, int type, int listening) {
+ struct stat st_fd;
+
+ if (fd < 0 || type < 0)
+ return -EINVAL;
+
+ if (fstat(fd, &st_fd) < 0)
+ return -errno;
+
+ if (!S_ISSOCK(st_fd.st_mode))
+ return 0;
+
+ if (type != 0) {
+ int other_type = 0;
+ socklen_t l = sizeof(other_type);
+
+ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0)
+ return -errno;
+
+ if (l != sizeof(other_type))
+ return -EINVAL;
+
+ if (other_type != type)
+ return 0;
+ }
+
+ if (listening >= 0) {
+ int accepting = 0;
+ socklen_t l = sizeof(accepting);
+
+ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0)
+ return -errno;
+
+ if (l != sizeof(accepting))
+ return -EINVAL;
+
+ if (!accepting != !listening)
+ return 0;
+ }
+
+ return 1;
+}
+
+union sockaddr_union {
+ struct sockaddr sa;
+ struct sockaddr_in in4;
+ struct sockaddr_in6 in6;
+ struct sockaddr_un un;
+ struct sockaddr_storage storage;
+};
+
+int sd_is_socket(int fd, int family, int type, int listening) {
+ int r;
+
+ if (family < 0)
+ return -EINVAL;
+
+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
+ return r;
+
+ if (family > 0) {
+ union sockaddr_union sockaddr;
+ socklen_t l;
+
+ memset(&sockaddr, 0, sizeof(sockaddr));
+ l = sizeof(sockaddr);
+
+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
+ return -errno;
+
+ if (l < sizeof(sa_family_t))
+ return -EINVAL;
+
+ return sockaddr.sa.sa_family == family;
+ }
+
+ return 1;
+}
+
+int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
+ union sockaddr_union sockaddr;
+ socklen_t l;
+ int r;
+
+ if (family != 0 && family != AF_INET && family != AF_INET6)
+ return -EINVAL;
+
+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
+ return r;
+
+ memset(&sockaddr, 0, sizeof(sockaddr));
+ l = sizeof(sockaddr);
+
+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
+ return -errno;
+
+ if (l < sizeof(sa_family_t))
+ return -EINVAL;
+
+ if (sockaddr.sa.sa_family != AF_INET &&
+ sockaddr.sa.sa_family != AF_INET6)
+ return 0;
+
+ if (family > 0)
+ if (sockaddr.sa.sa_family != family)
+ return 0;
+
+ if (port > 0) {
+ if (sockaddr.sa.sa_family == AF_INET) {
+ if (l < sizeof(struct sockaddr_in))
+ return -EINVAL;
+
+ return htons(port) == sockaddr.in4.sin_port;
+ } else {
+ if (l < sizeof(struct sockaddr_in6))
+ return -EINVAL;
+
+ return htons(port) == sockaddr.in6.sin6_port;
+ }
+ }
+
+ return 1;
+}
+
+int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
+ union sockaddr_union sockaddr;
+ socklen_t l;
+ int r;
+
+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
+ return r;
+
+ memset(&sockaddr, 0, sizeof(sockaddr));
+ l = sizeof(sockaddr);
+
+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
+ return -errno;
+
+ if (l < sizeof(sa_family_t))
+ return -EINVAL;
+
+ if (sockaddr.sa.sa_family != AF_UNIX)
+ return 0;
+
+ if (path) {
+ if (length <= 0)
+ length = strlen(path);
+
+ if (length <= 0)
+ /* Unnamed socket */
+ return l == sizeof(sa_family_t);
+
+ if (path[0])
+ /* Normal path socket */
+ return
+ (l >= sizeof(sa_family_t) + length + 1) &&
+ memcmp(path, sockaddr.un.sun_path, length+1) == 0;
+ else
+ /* Abstract namespace socket */
+ return
+ (l == sizeof(sa_family_t) + length) &&
+ memcmp(path, sockaddr.un.sun_path, length) == 0;
+ }
+
+ return 1;
+}
+
+int sd_notify(int unset_environment, const char *state) {
+#if defined(DISABLE_SYSTEMD) || !defined(__linux__)
+ return 0;
+#else
+ int fd = -1, r;
+ struct msghdr msghdr;
+ struct iovec iovec;
+ union sockaddr_union sockaddr;
+ struct ucred *ucred;
+ union {
+ struct cmsghdr cmsghdr;
+ uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
+ } control;
+ const char *e;
+
+ if (!state) {
+ r = -EINVAL;
+ goto finish;
+ }
+
+ if (!(e = getenv("NOTIFY_SOCKET")))
+ return 0;
+
+ /* Must be an abstract socket, or an absolute path */
+ if ((e[0] != '@' && e[0] != '/') || e[1] == 0) {
+ r = -EINVAL;
+ goto finish;
+ }
+
+ if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ memset(&sockaddr, 0, sizeof(sockaddr));
+ sockaddr.sa.sa_family = AF_UNIX;
+ strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
+
+ if (sockaddr.un.sun_path[0] == '@')
+ sockaddr.un.sun_path[0] = 0;
+
+ memset(&iovec, 0, sizeof(iovec));
+ iovec.iov_base = (char*) state;
+ iovec.iov_len = strlen(state);
+
+ memset(&control, 0, sizeof(control));
+ control.cmsghdr.cmsg_level = SOL_SOCKET;
+ control.cmsghdr.cmsg_type = SCM_CREDENTIALS;
+ control.cmsghdr.cmsg_len = CMSG_LEN(sizeof(struct ucred));
+
+ ucred = (struct ucred*) CMSG_DATA(&control.cmsghdr);
+ ucred->pid = getpid();
+ ucred->uid = getuid();
+ ucred->gid = getgid();
+
+ memset(&msghdr, 0, sizeof(msghdr));
+ msghdr.msg_name = &sockaddr;
+ msghdr.msg_namelen = sizeof(struct sockaddr_un);
+ msghdr.msg_iov = &iovec;
+ msghdr.msg_iovlen = 1;
+ msghdr.msg_control = &control;
+ msghdr.msg_controllen = control.cmsghdr.cmsg_len;
+
+ if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ r = 1;
+
+finish:
+ if (unset_environment)
+ unsetenv("NOTIFY_SOCKET");
+
+ if (fd >= 0)
+ close(fd);
+
+ return r;
+#endif
+}
+
+int sd_notifyf(int unset_environment, const char *format, ...) {
+#if defined(DISABLE_SYSTEMD) || !defined(__linux__)
+ return 0;
+#else
+ va_list ap;
+ char *p = NULL;
+ int r;
+
+ va_start(ap, format);
+ r = vasprintf(&p, format, ap);
+ va_end(ap);
+
+ if (r < 0 || !p)
+ return -ENOMEM;
+
+ r = sd_notify(unset_environment, p);
+ free(p);
+
+ return r;
+#endif
+}
+
+int sd_booted(void) {
+#if defined(DISABLE_SYSTEMD) || !defined(__linux__)
+ return 0;
+#else
+
+ struct stat a, b;
+
+ /* We simply test whether the systemd cgroup hierarchy is
+ * mounted */
+
+ if (lstat("/cgroup", &a) < 0)
+ return 0;
+
+ if (lstat("/cgroup/systemd", &b) < 0)
+ return 0;
+
+ return a.st_dev != b.st_dev;
+#endif
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foosddaemonhfoo
+#define foosddaemonhfoo
+
+/***
+ Copyright 2010 Lennart Poettering
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+***/
+
+#include <sys/types.h>
+#include <inttypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ Reference implementation of a few systemd related interfaces for
+ writing daemons. These interfaces are trivial to implement. To
+ simplify porting we provide this reference implementation.
+ Applications are welcome to reimplement the algorithms described
+ here if they do not want to include these two source files.
+
+ The following functionality is provided:
+
+ - Support for logging with log levels on stderr
+ - File descriptor passing for socket-based activation
+ - Daemon startup and status notification
+ - Detection of systemd boots
+
+ You may compile this with -DDISABLE_SYSTEMD to disable systemd
+ support. This makes all those calls NOPs that are directly related to
+ systemd (i.e. only sd_is_xxx() will stay useful).
+
+ Since this is drop-in code we don't want any of our symbols to be
+ exported in any case. Hence we declare hidden visibility for all of
+ them.
+
+ You may find an up-to-date version of these source files online:
+
+ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h
+ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c
+
+ This should compile on non-Linux systems, too, but with the
+ exception of the sd_is_xxx() calls all functions will become NOPs.
+
+ See sd-daemon(7) for more information.
+*/
+
+#if __GNUC__ >= 4
+#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
+#define _sd_hidden_ __attribute__ ((visibility("hidden")))
+#else
+#define _sd_printf_attr_(a,b)
+#define _sd_hidden_
+#endif
+
+/*
+ Log levels for usage on stderr:
+
+ fprintf(stderr, SD_NOTICE "Hello World!\n");
+
+ This is similar to printk() usage in the kernel.
+*/
+#define SD_EMERG "<0>" /* system is unusable */
+#define SD_ALERT "<1>" /* action must be taken immediately */
+#define SD_CRIT "<2>" /* critical conditions */
+#define SD_ERR "<3>" /* error conditions */
+#define SD_WARNING "<4>" /* warning conditions */
+#define SD_NOTICE "<5>" /* normal but significant condition */
+#define SD_INFO "<6>" /* informational */
+#define SD_DEBUG "<7>" /* debug-level messages */
+
+/* The first passed file descriptor is fd 3 */
+#define SD_LISTEN_FDS_START 3
+
+/*
+ Returns how many file descriptors have been passed, or a negative
+ errno code on failure. Optionally, removes the $LISTEN_FDS and
+ $LISTEN_PID file descriptors from the environment (recommended, but
+ problematic in threaded environments). If r is the return value of
+ this function you'll find the file descriptors passed as fds
+ SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative
+ errno style error code on failure. This function call ensures that
+ the FD_CLOEXEC flag is set for the passed file descriptors, to make
+ sure they are not passed on to child processes. If FD_CLOEXEC shall
+ not be set, the caller needs to unset it after this call for all file
+ descriptors that are used.
+
+ See sd_listen_fds(3) for more information.
+*/
+int sd_listen_fds(int unset_environment) _sd_hidden_;
+
+/*
+ Helper call for identifying a passed file descriptor. Returns 1 if
+ the file descriptor is a FIFO in the file system stored under the
+ specified path, 0 otherwise. If path is NULL a path name check will
+ not be done and the call only verifies if the file descriptor
+ refers to a FIFO. Returns a negative errno style error code on
+ failure.
+
+ See sd_is_fifo(3) for more information.
+*/
+int sd_is_fifo(int fd, const char *path) _sd_hidden_;
+
+/*
+ Helper call for identifying a passed file descriptor. Returns 1 if
+ the file descriptor is a socket of the specified family (AF_INET,
+ ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If
+ family is 0 a socket family check will not be done. If type is 0 a
+ socket type check will not be done and the call only verifies if
+ the file descriptor refers to a socket. If listening is > 0 it is
+ verified that the socket is in listening mode. (i.e. listen() has
+ been called) If listening is == 0 it is verified that the socket is
+ not in listening mode. If listening is < 0 no listening mode check
+ is done. Returns a negative errno style error code on failure.
+
+ See sd_is_socket(3) for more information.
+*/
+int sd_is_socket(int fd, int family, int type, int listening) _sd_hidden_;
+
+/*
+ Helper call for identifying a passed file descriptor. Returns 1 if
+ the file descriptor is an Internet socket, of the specified family
+ (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM,
+ SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version
+ check is not done. If type is 0 a socket type check will not be
+ done. If port is 0 a socket port check will not be done. The
+ listening flag is used the same way as in sd_is_socket(). Returns a
+ negative errno style error code on failure.
+
+ See sd_is_socket_inet(3) for more information.
+*/
+int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) _sd_hidden_;
+
+/*
+ Helper call for identifying a passed file descriptor. Returns 1 if
+ the file descriptor is an AF_UNIX socket of the specified type
+ (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0
+ a socket type check will not be done. If path is NULL a socket path
+ check will not be done. For normal AF_UNIX sockets set length to
+ 0. For abstract namespace sockets set length to the length of the
+ socket name (including the initial 0 byte), and pass the full
+ socket path in path (including the initial 0 byte). The listening
+ flag is used the same way as in sd_is_socket(). Returns a negative
+ errno style error code on failure.
+
+ See sd_is_socket_unix(3) for more information.
+*/
+int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) _sd_hidden_;
+
+/*
+ Informs systemd about changed daemon state. This takes a number of
+ newline seperated environment-style variable assignments in a
+ string. The following variables are known:
+
+ READY=1 Tells systemd that daemon startup is finished (only
+ relevant for services of Type=notify). The passed
+ argument is a boolean "1" or "0". Since there is
+ little value in signalling non-readiness the only
+ value daemons should send is "READY=1".
+
+ STATUS=... Passes a single-line status string back to systemd
+ that describes the daemon state. This is free-from
+ and can be used for various purposes: general state
+ feedback, fsck-like programs could pass completion
+ percentages and failing programs could pass a human
+ readable error message. Example: "STATUS=Completed
+ 66% of file system check..."
+
+ ERRNO=... If a daemon fails, the errno-style error code,
+ formatted as string. Example: "ERRNO=2" for ENOENT.
+
+ BUSERROR=... If a daemon fails, the D-Bus error-style error
+ code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut"
+
+ MAINPID=... The main pid of a daemon, in case systemd did not
+ fork off the process itself. Example: "MAINPID=4711"
+
+ Daemons can choose to send additional variables. However, it is
+ recommened to prefix variable names not listed above with X_.
+
+ Returns a negative errno-style error code on failure. Returns > 0
+ if systemd could be notified, 0 if it couldn't possibly because
+ systemd is not running.
+
+ Example: When a daemon finished starting up, it could issue this
+ call to notify systemd about it:
+
+ sd_notify(0, "READY=1");
+
+ See sd_notifyf() for more complete examples.
+
+ See sd_notify(3) for more information.
+*/
+int sd_notify(int unset_environment, const char *state) _sd_hidden_;
+
+/*
+ Similar to sd_notify() but takes a format string.
+
+ Example 1: A daemon could send the following after initialization:
+
+ sd_notifyf(0, "READY=1\n"
+ "STATUS=Processing requests...\n"
+ "MAINPID=%lu",
+ (unsigned long) getpid());
+
+ Example 2: A daemon could send the following shortly before
+ exiting, on failure:
+
+ sd_notifyf(0, "STATUS=Failed to start up: %s\n"
+ "ERRNO=%i",
+ strerror(errno),
+ errno);
+
+ See sd_notifyf(3) for more information.
+*/
+int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3) _sd_hidden_;
+
+/*
+ Returns > 0 if the system was booted with systemd. Returns < 0 on
+ error. Returns 0 if the system was not booted with systemd. Note
+ that all of the functions above handle non-systemd boots just
+ fine. You should NOT protect them with a call to this function. Also
+ note that this function checks whether the system, not the user
+ session is controlled by systemd. However the functions above work
+ for both session and system services.
+
+ See sd_booted(3) for more information.
+*/
+int sd_booted(void) _sd_hidden_;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
argv_size = endptr - argv_buffer[0];
/* Make a copy of environ */
-
+
new_environ = avahi_malloc(sizeof(char*) * (i + 1));
for (i = 0; environ[i]; i++)
new_environ[i] = avahi_strdup(environ[i]);
environ = new_environ;
#endif
-}
+}
void avahi_set_proc_title(const char *name, const char *fmt,...) {
#ifdef HAVE_SETPROCTITLE
#elif __linux__
size_t l;
va_list ap;
-
+
if (!argv_buffer)
return;
-
+
va_start(ap, fmt);
vsnprintf(argv_buffer[0], argv_size, fmt, ap);
va_end(ap);
l = strlen(argv_buffer[0]);
-
+
memset(argv_buffer[0] + l, 0, argv_size - l);
argv_buffer[1] = NULL;
#endif
if (name)
prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0);
-
+
#endif
}
#ifndef foosetproctitlehfoo
#define foosetproctitlehfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
-<!-- $Id$ -->
-
<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
<service-group>
- <name replace-wildcards="yes">SFTP File Transfer on %h</name>
+ <name replace-wildcards="yes">%h</name>
<service>
<type>_sftp-ssh._tcp</type>
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include "simple-protocol.h"
#include "main.h"
+#include "sd-daemon.h"
#ifdef ENABLE_CHROOT
#include "chroot.h"
Server *server;
ClientState state;
-
+
int fd;
AvahiWatch *watch;
AvahiSDNSServerBrowser *dns_server_browser;
AvahiProtocol afquery;
-
+
AVAHI_LLIST_FIELDS(Client, clients);
};
AVAHI_LLIST_HEAD(Client, clients);
unsigned n_clients;
- int bind_successful;
+ int remove_socket;
};
static Server *server = NULL;
c->server->poll_api->watch_free(c->watch);
close(c->fd);
-
+
AVAHI_LLIST_REMOVE(Client, clients, c->server->clients, c);
avahi_free(c);
}
static void client_output(Client *c, const uint8_t*data, size_t size) {
size_t k, m;
-
+
assert(c);
assert(data);
static void client_output_printf(Client *c, const char *format, ...) {
char *t;
va_list ap;
-
+
va_start(ap, format);
t = avahi_strdup_vprintf(format, ap);
va_end(ap);
AvahiResolverEvent event,
const char *hostname,
const AvahiAddress *a,
- AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
+ AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
Client *c = userdata;
-
+
assert(c);
if (event == AVAHI_RESOLVER_FAILURE)
const char *hostname,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
-
+
Client *c = userdata;
-
+
assert(c);
if (event == AVAHI_RESOLVER_FAILURE)
uint16_t port,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
-
+
Client *c = userdata;
char t[AVAHI_ADDRESS_STR_MAX];
-
+
assert(c);
if (!a)
case AVAHI_BROWSER_NEW:
case AVAHI_BROWSER_REMOVE:
-
+
avahi_address_snprint(t, sizeof(t), a);
client_output_printf(c, "%c %i %u %s %u\n", event == AVAHI_BROWSER_NEW ? '>' : '<', interface, protocol, t, port);
break;
avahi_log_debug(__FILE__": Got %s request for '%s'.", cmd, arg);
} else if (strcmp(cmd, "RESOLVE-ADDRESS") == 0 && n_args == 2) {
AvahiAddress addr;
-
+
if (!(avahi_address_parse(arg, AVAHI_PROTO_UNSPEC, &addr))) {
client_output_printf(c, "%+i Failed to parse address \"%s\".\n", AVAHI_ERR_INVALID_ADDRESS, arg);
c->state = CLIENT_DEAD;
k = e - (char*) c->inbuf;
*e = 0;
-
+
handle_line(c, c->inbuf);
c->inbuf_length -= k + 1;
memmove(c->inbuf, e+1, c->inbuf_length);
if ((events & AVAHI_WATCH_IN) && c->inbuf_length < sizeof(c->inbuf)) {
ssize_t r;
-
+
if ((r = read(c->fd, c->inbuf + c->inbuf_length, sizeof(c->inbuf) - c->inbuf_length)) <= 0) {
if (r < 0)
avahi_log_warn("read(): %s", strerror(errno));
assert((size_t) r <= c->outbuf_length);
c->outbuf_length -= r;
-
+
if (c->outbuf_length)
memmove(c->outbuf, c->outbuf + r, c->outbuf_length - r);
}
c->server->poll_api->watch_update(
- watch,
+ watch,
(c->outbuf_length > 0 ? AVAHI_WATCH_OUT : 0) |
(c->inbuf_length < sizeof(c->inbuf) ? AVAHI_WATCH_IN : 0));
}
client_new(s, cfd);
}
}
-
+
int simple_protocol_setup(const AvahiPoll *poll_api) {
struct sockaddr_un sa;
mode_t u;
+ int n;
assert(!server);
server = avahi_new(Server, 1);
server->poll_api = poll_api;
- server->bind_successful = 0;
+ server->remove_socket = 0;
server->fd = -1;
server->n_clients = 0;
AVAHI_LLIST_HEAD_INIT(Client, server->clients);
server->watch = NULL;
-
+
u = umask(0000);
- if ((server->fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
- avahi_log_warn("socket(PF_LOCAL, SOCK_STREAM, 0): %s", strerror(errno));
+ if ((n = sd_listen_fds(1)) < 0) {
+ avahi_log_warn("Failed to acquire systemd file descriptors: %s", strerror(-n));
goto fail;
}
- memset(&sa, 0, sizeof(sa));
- sa.sun_family = AF_LOCAL;
- strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1);
-
- /* We simply remove existing UNIX sockets under this name. The
- Avahi daemon makes sure that it runs only once on a host,
- therefore sockets that already exist are stale and may be
- removed without any ill effects */
-
- unlink(AVAHI_SOCKET);
-
- if (bind(server->fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) {
- avahi_log_warn("bind(): %s", strerror(errno));
+ if (n > 1) {
+ avahi_log_warn("Too many systemd file descriptors passed.");
goto fail;
}
- server->bind_successful = 1;
-
- if (listen(server->fd, 2) < 0) {
- avahi_log_warn("listen(): %s", strerror(errno));
- goto fail;
+ if (n == 1) {
+ int r;
+
+ if ((r = sd_is_socket(AF_LOCAL, SOCK_STREAM, 1, 0)) < 0) {
+ avahi_log_warn("Passed systemd file descriptor is of wrong type: %s", strerror(-r));
+ goto fail;
+ }
+
+ server->fd = SD_LISTEN_FDS_START;
+
+ } else {
+
+ if ((server->fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
+ avahi_log_warn("socket(AF_LOCAL, SOCK_STREAM, 0): %s", strerror(errno));
+ goto fail;
+ }
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sun_family = AF_LOCAL;
+ strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1);
+
+ /* We simply remove existing UNIX sockets under this name. The
+ Avahi daemon makes sure that it runs only once on a host,
+ therefore sockets that already exist are stale and may be
+ removed without any ill effects */
+
+ unlink(AVAHI_SOCKET);
+
+ if (bind(server->fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) {
+ avahi_log_warn("bind(): %s", strerror(errno));
+ goto fail;
+ }
+
+ server->remove_socket = 1;
+
+ if (listen(server->fd, SOMAXCONN) < 0) {
+ avahi_log_warn("listen(): %s", strerror(errno));
+ goto fail;
+ }
}
umask(u);
server->watch = poll_api->watch_new(poll_api, server->fd, AVAHI_WATCH_IN, server_work, server);
-
+
return 0;
fail:
-
+
umask(u);
simple_protocol_shutdown();
if (server) {
- if (server->bind_successful)
+ if (server->remove_socket)
#ifdef ENABLE_CHROOT
avahi_chroot_helper_unlink(AVAHI_SOCKET);
#else
if (server->watch)
server->poll_api->watch_free(server->watch);
-
+
if (server->fd >= 0)
close(server->fd);
avahi_free(server);
-
+
server = NULL;
}
}
Client *c;
/* Restart queries in case of local domain name changes */
-
+
assert(server);
for (c = server->clients; c; c = c->clients_next)
c->dns_server_browser = avahi_s_dns_server_browser_new(avahi_server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DNS_SERVER_RESOLVE, c->afquery, AVAHI_LOOKUP_USE_MULTICAST, dns_server_browser_callback, c);
}
}
-
-
#ifndef foosimpleprotocolhfoo
#define foosimpleprotocolhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
-<!-- $Id$ -->
-
<!--
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
case AVAHI_ENTRY_GROUP_FAILURE:
avahi_log_notice ("Failed to establish static host name \"%s\": %s.", h->host, avahi_strerror (avahi_server_errno (s)));
break;
-
+
case AVAHI_ENTRY_GROUP_UNCOMMITED:
case AVAHI_ENTRY_GROUP_REGISTERING:
;
static StaticHost *static_host_new(void) {
StaticHost *s;
-
+
s = avahi_new(StaticHost, 1);
s->group = NULL;
avahi_s_entry_group_free (s->group);
avahi_free(s->host);
-
+
avahi_free(s);
}
assert(host);
assert(a);
-
+
for (h = hosts; h; h = h->hosts_next)
if (!strcmp(h->host, host) && !avahi_address_cmp(a, &h->address))
return h;
int err;
const AvahiServerConfig *config;
config = avahi_server_get_config(avahi_server);
-
+
p = (h->address.proto == AVAHI_PROTO_INET && config->publish_a_on_ipv6) ||
(h->address.proto == AVAHI_PROTO_INET6 && config->publish_aaaa_on_ipv4) ? AVAHI_PROTO_UNSPEC : h->address.proto;
-
+
if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, p, 0, h->host, &h->address)) < 0) {
avahi_log_error ("Static host name %s: avahi_server_add_address failure: %s", h->host, avahi_strerror(err));
return;
if (h->group)
avahi_s_entry_group_reset (h->group);
}
-
+
void static_hosts_add_to_server(void) {
StaticHost *h;
}
current_iteration++;
-
+
while (!feof(f)) {
unsigned int len;
char ln[256], *s;
/* Skip past any more spaces */
s += strspn(s, " \t");
-
+
/* Anything left? */
if (*s != 0) {
avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line);
for (h = hosts; h; h = next) {
next = h->hosts_next;
-
+
if (h->iteration != current_iteration) {
avahi_log_info("Static hostname %s vanished, removing.", h->host);
static_host_free(h);
}
fail:
-
+
fclose(f);
}
#ifndef foostatichostshfoo
#define foostatichostshfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef foostaticserviceshfoo
#define foostaticserviceshfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
AM_CFLAGS=-I$(top_srcdir)
interfaces = \
- avahi-discover.glade
+ avahi-discover.ui
# This cool debug trap works on i386/gcc only
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
-if HAVE_GTK
-if HAVE_GLIB
+if HAVE_GTK2OR3
+if HAVE_GLIB
bin_PROGRAMS = \
avahi-discover-standalone
avahi_discover_standalone_CFLAGS = \
$(AM_CFLAGS) \
- $(GLIB20_CFLAGS) $(GTK20_CFLAGS) $(GLADE20_CFLAGS)\
-DAVAHI_INTERFACES_DIR=\"$(interfacesdir)\"
avahi_discover_standalone_LDADD = \
$(AM_LDADD) \
../avahi-common/libavahi-common.la \
../avahi-glib/libavahi-glib.la \
- ../avahi-core/libavahi-core.la \
- $(GLIB20_LIBS) $(GTK20_LIBS) $(GLADE20_LIBS)
+ ../avahi-core/libavahi-core.la
+
+if HAVE_GTK3
+avahi_discover_standalone_CFLAGS += \
+ $(GLIB30_CFLAGS) $(GTK30_CFLAGS)
+avahi_discover_standalone_LDADD += \
+ $(GLIB30_LIBS) $(GTK30_LIBS)
+else
+avahi_discover_standalone_CFLAGS += \
+ $(GLIB20_CFLAGS) $(GTK20_CFLAGS)
+avahi_discover_standalone_LDADD += \
+ $(GLIB20_LIBS) $(GTK20_LIBS)
+endif
interfaces_DATA = $(interfaces)
endif # HAVE_GLIB
-else
+else
if HAVE_PYTHON_DBUS
endif
EXTRA_DIST = \
- $(interfaces) \
- avahi-discover.gladep
+ $(interfaces)
+++ /dev/null
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
-<glade-interface>
-
-<widget class="GtkWindow" id="main_window">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Avahi Discovery</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">500</property>
- <property name="default_height">400</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <signal handler="gtk_main_quit" name="destroy" after="False"/>
-
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="tree_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- <signal name="cursor_changed" handler="on_tree_view_cursor_changed" last_modification_time="Sat, 30 Jul 2005 21:39:13 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="info_label">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes"><i>No service currently selected.</i></property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
+++ /dev/null
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
-
-<glade-project>
- <name>Avahi-discover</name>
- <program_name>avahi-discover</program_name>
- <gnome_support>FALSE</gnome_support>
-</glade-project>
--- /dev/null
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+ <object class="GtkWindow" id="main_window">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Avahi Discovery</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="default_width">500</property>
+ <property name="default_height">400</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <signal after="False" handler="gtk_main_quit" name="destroy"/>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+ <child>
+ <object class="GtkTreeView" id="tree_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
+ <property name="hover_selection">False</property>
+ <property name="hover_expand">False</property>
+ <signal handler="on_tree_view_cursor_changed" last_modification_time="Sat, 30 Jul 2005 21:39:13 GMT" name="cursor_changed"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="info_label">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"><i>No service currently selected.</i></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#include <unistd.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include <avahi-core/core.h>
#include <avahi-core/lookup.h>
for (l = st->services; l; l = l->next) {
struct Service *s = l->data;
-
+
if (s->interface == interface &&
s->protocol == protocol &&
avahi_domain_equal(s->service_name, service_name) &&
avahi_s_service_resolver_free(service_resolver);
service_resolver = NULL;
}
-
+
gtk_label_set_text(info_label, "<i>Service removed</i>");
}
-
+
s->service_type->services = g_list_remove(s->service_type->services, s);
if ((path = gtk_tree_row_reference_get_path(s->tree_ref))) {
gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &iter, path);
gtk_tree_path_free(path);
}
-
+
gtk_tree_store_remove(tree_store, &iter);
gtk_tree_row_reference_free(s->tree_ref);
GtkTreePath *path, *ppath;
gchar iface[256];
char name[IF_NAMESIZE];
-
+
s = g_new(struct Service, 1);
s->service_name = g_strdup(service_name);
s->domain_name = g_strdup(domain_name);
s->protocol = protocol;
s->service_type = g_hash_table_lookup(service_type_hash_table, service_type);
g_assert(s->service_type);
-
+
s->service_type->services = g_list_prepend(s->service_type->services, s);
ppath = gtk_tree_row_reference_get_path(s->service_type->tree_ref);
gtk_tree_view_expand_row(tree_view, ppath, FALSE);
gtk_tree_path_free(ppath);
-
+
} else if (event == AVAHI_BROWSER_REMOVE) {
struct Service* s;
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void * userdata) {
-
+
struct ServiceType *st;
GtkTreePath *path;
GtkTreeIter iter;
st = g_new(struct ServiceType, 1);
st->service_type = g_strdup(service_type);
st->services = NULL;
-
+
gtk_tree_store_append(tree_store, &iter, NULL);
gtk_tree_store_set(tree_store, &iter, 0, st->service_type, 1, "", 2, NULL, -1);
snprintf(address, sizeof(address), "<i>n/a</i>");
txt_s = g_strdup("<i>n/a</i>");
}
-
+
snprintf(t, sizeof(t),
"<b>Service Type:</b> %s\n"
"<b>Service Name:</b> %s\n"
GtkTreePath *path;
struct Service *s;
GtkTreeIter iter;
-
+
gtk_tree_view_get_cursor(tree_view, &path, NULL);
if (!path)
return NULL;
-
+
gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_store), &iter, path);
gtk_tree_model_get(GTK_TREE_MODEL(tree_store), &iter, 2, &s, -1);
gtk_tree_path_free(path);
const AvahiAddress *a,
uint16_t port,
AvahiStringList *txt,
- AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
+ AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
-
+
struct Service *s;
g_assert(r);
static void tree_view_on_cursor_changed(AVAHI_GCC_UNUSED GtkTreeView *tv, AVAHI_GCC_UNUSED gpointer userdata) {
struct Service *s;
-
+
if (!(s = get_service_on_cursor()))
return;
}
int main(int argc, char *argv[]) {
- GladeXML *xml;
+ GtkBuilder *ui;
AvahiServerConfig config;
GtkTreeViewColumn *c;
gint error;
AvahiGLibPoll *poll_api;
gtk_init(&argc, &argv);
- glade_init();
avahi_set_allocator(avahi_glib_allocator());
poll_api = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT);
- xml = glade_xml_new(AVAHI_INTERFACES_DIR"avahi-discover.glade", NULL, NULL);
- main_window = glade_xml_get_widget(xml, "main_window");
+ ui = gtk_builder_new();
+ gtk_builder_add_from_file(ui, AVAHI_INTERFACES_DIR"avahi-discover.ui", NULL);
+ main_window = GTK_WIDGET(gtk_builder_get_object(ui, "main_window"));
g_signal_connect(main_window, "delete-event", (GCallback) main_window_on_delete_event, NULL);
-
- tree_view = GTK_TREE_VIEW(glade_xml_get_widget(xml, "tree_view"));
+
+ tree_view = GTK_TREE_VIEW(gtk_builder_get_object(ui, "tree_view"));
g_signal_connect(GTK_WIDGET(tree_view), "cursor-changed", (GCallback) tree_view_on_cursor_changed, NULL);
- info_label = GTK_LABEL(glade_xml_get_widget(xml, "info_label"));
+ info_label = GTK_LABEL(gtk_builder_get_object(ui, "info_label"));
tree_store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
gtk_tree_view_set_model(tree_view, GTK_TREE_MODEL(tree_store));
gtk_tree_view_column_set_resizable(c = gtk_tree_view_get_column(tree_view, 0), TRUE);
gtk_tree_view_column_set_sizing(c, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
gtk_tree_view_column_set_expand(c, TRUE);
-
+
service_type_hash_table = g_hash_table_new((GHashFunc) avahi_domain_hash, (GEqualFunc) avahi_domain_equal);
-
+
avahi_server_config_init(&config);
config.publish_hinfo = config.publish_addresses = config.publish_domain = config.publish_workstation = FALSE;
server = avahi_server_new(avahi_glib_poll_get(poll_api), &config, NULL, NULL, &error);
+avahi-dnsconfd.service
avahi-dnsconfd
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
+EXTRA_DIST=avahi-dnsconfd.action avahi-dnsconfd.service.in
+
if HAVE_XML
if HAVE_LIBDAEMON
sbin_PROGRAMS = avahi-dnsconfd
-avahi_dnsconfd_SOURCES = main.c
+avahi_dnsconfd_SOURCES = main.c
avahi_dnsconfd_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS)
avahi_dnsconfd_LDADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(LIBDAEMON_LIBS)
pkgsysconf_SCRIPTS=avahi-dnsconfd.action
+%.service: %.service.in
+ $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
+
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = \
+ avahi-dnsconfd.service
endif
-endif
-EXTRA_DIST=avahi-dnsconfd.action
+CLEANFILES = $(systemdsystemunit_DATA)
+
+endif
+endif
#!/bin/sh
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
--- /dev/null
+# This file is part of avahi.
+#
+# avahi is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# avahi is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with avahi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+[Unit]
+Requires=basic.target avahi-daemon.socket avahi-daemon.service
+After=basic.target syslog.target avahi-daemon.socket
+Conflicts=shutdown.target
+
+[Service]
+Type=simple
+ExecStart=@sbindir@/avahi-dnsconfd -s
+ExecReload=@sbindir@/avahi-dnsconfd -r
+
+[Install]
+WantedBy=multi-user.target
+Also=avahi-daemon.socket
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static int quit = 0;
static int daemonize = 0;
+static int use_syslog = 0;
#if !HAVE_DECL_ENVIRON
extern char **environ;
assert(i);
avahi_free(i->address);
-
+
AVAHI_LLIST_REMOVE(DNSServerInfo, servers, servers, i);
avahi_free(i);
}
static DNSServerInfo* new_server_info(AvahiIfIndex interface, AvahiProtocol protocol, const char *address) {
DNSServerInfo *i;
-
+
assert(address);
i = avahi_new(DNSServerInfo, 1);
i->address = avahi_strdup(address);
AVAHI_LLIST_PREPEND(DNSServerInfo, servers, servers, i);
-
+
return i;
}
int n;
assert(fd >= 0);
-
+
if ((n = fcntl(fd, F_GETFD)) < 0)
return -1;
daemon_log(LOG_ERR, "fcntl(): %s", strerror(errno));
goto fail;
}
-
+
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1);
if (connect(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) {
daemon_log(LOG_ERR, "connect(): %s", strerror(errno));
- daemon_log(LOG_INFO, "Failed to connect to the daemon. This probably means that you");
- daemon_log(LOG_INFO, "didn't start avahi-daemon before avahi-dnsconfd.");
+ daemon_log(LOG_INFO, "Failed to connect to the daemon. This probably means that you");
+ daemon_log(LOG_INFO, "didn't start avahi-daemon before avahi-dnsconfd.");
goto fail;
}
return fd;
-
+
fail:
if (fd >= 0)
close(fd);
static char *concat_dns_servers(AvahiIfIndex interface) {
DNSServerInfo *i;
char *r = NULL;
-
+
for (i = servers; i; i = i->servers_next)
if (i->interface == interface || interface <= 0) {
DNSServerInfo *j;
if (j != i)
continue;
-
+
if (!r)
t = avahi_strdup(i->address);
else
static void set_env(const char *name, const char *value) {
char **e;
size_t l;
-
+
assert(name);
assert(value);
/* Search for the variable */
if (strlen(*e) < l+1)
continue;
-
+
if (strncmp(*e, name, l) != 0 || (*e)[l] != '=')
continue;
assert(interface > 0);
- if (!if_indextoname(interface, name))
+ if (!if_indextoname(interface, name))
return;
-
+
p = concat_dns_servers(interface);
set_env(ENV_INTERFACE_DNS_SERVERS, p ? p : "");
- avahi_free(p);
+ avahi_free(p);
p = concat_dns_servers(-1);
set_env(ENV_DNS_SERVERS, p ? p : "");
- avahi_free(p);
+ avahi_free(p);
set_env(ENV_INTERFACE, name);
-
+
snprintf(ia, sizeof(ia), "%i", (int) interface);
snprintf(pa, sizeof(pa), "%i", (int) protocol);
AvahiProtocol protocol;
int i_interface, i_protocol, port;
char a[AVAHI_ADDRESS_STR_MAX];
-
- assert(state == BROWSING);
+
+ assert(state == BROWSING);
if (*l != '<' && *l != '>') {
daemon_log(LOG_ERR, "Avahi sent us an invalid browsing line: %s", l);
} else {
DNSServerInfo *i;
- if (port == 53)
+ if (port == 53)
if ((i = get_server_info(interface, protocol, a))) {
daemon_log(LOG_INFO, "DNS Server %s removed (interface: %i.%s)", a, interface, avahi_proto_to_string(protocol));
server_info_free(i);
}
}
-
+
return 0;
}
static int do_connect(void) {
int fd = -1;
-
+
if ((fd = open_socket()) < 0)
goto fail;
fail:
if (fd >= 0)
close(fd);
-
+
return -1;
}
AvahiProtocol protocol = servers->protocol;
char *address = avahi_strdup(servers->address);
server_info_free(servers);
-
+
run_script(0, interface, protocol, address);
avahi_free(address);
}
"%s [options]\n"
" -h --help Show this help\n"
" -D --daemonize Daemonize after startup\n"
+ " -s --syslog Write log messages to syslog(3) instead of STDERR\n"
" -k --kill Kill a running daemon\n"
" -r --refresh Request a running daemon to refresh DNS server data\n"
" -c --check Return 0 if a daemon is already running\n"
static int parse_command_line(int argc, char *argv[]) {
int c;
-
+
static const struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "daemonize", no_argument, NULL, 'D' },
+ { "syslog", no_argument, NULL, 's' },
{ "kill", no_argument, NULL, 'k' },
{ "version", no_argument, NULL, 'V' },
{ "refresh", no_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 }
};
- while ((c = getopt_long(argc, argv, "hDkVrc", long_options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) {
switch(c) {
case 'h':
case 'D':
daemonize = 1;
break;
+ case 's':
+ use_syslog = 1;
+ break;
case 'k':
command = DAEMON_KILL;
break;
fprintf(stderr, "Too many arguments\n");
return -1;
}
-
+
return 0;
}
size_t buflen = 0;
AVAHI_LLIST_HEAD_INIT(DNSServerInfo, servers);
-
+
daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0);
/* Allocate some memory for our environment variables */
putenv(avahi_strdup(ENV_INTERFACE"="));
putenv(avahi_strdup(ENV_DNS_SERVERS"="));
putenv(avahi_strdup(ENV_INTERFACE_DNS_SERVERS"="));
-
+
if ((fd = do_connect()) < 0)
goto finish;
case SIGCHLD:
waitpid(-1, NULL, WNOHANG);
break;
-
+
case SIGHUP:
daemon_log(LOG_INFO, "Refreshing DNS Server list");
-
+
close(fd);
free_dns_server_info_list();
-
+
if ((fd = do_connect()) < 0)
goto finish;
-
+
break;
}
-
+
} else if (FD_ISSET(fd, &rfds)) {
ssize_t r;
char *n;
if (buflen >= sizeof(buf)-1) {
/* The incoming line is horribly long */
buf[sizeof(buf)-1] = 0;
-
+
if (new_line(buf) < 0)
goto finish;
-
+
buflen = 0;
}
}
}
-
+
finish:
free_dns_server_info_list();
if (fd >= 0)
close(fd);
-
+
daemon_signal_done();
if (ret != 0 && daemonize)
daemon_retval_send(1);
-
+
return ret;
}
daemon_pid_file_ident = daemon_log_ident = argv0;
daemon_pid_file_proc = pid_file_proc;
-
+
if (parse_command_line(argc, argv) < 0)
goto finish;
if (daemonize) {
daemon_retval_init();
-
+
if ((pid = daemon_fork()) < 0)
goto finish;
else if (pid != 0) {
/* Child */
}
+ if (use_syslog || daemonize)
+ daemon_log_use = DAEMON_LOG_SYSLOG;
+
chdir("/");
if (daemon_pid_file_create() < 0) {
r = 0;
} else if (command == DAEMON_HELP) {
help(stdout, argv0);
-
+
r = 0;
} else if (command == DAEMON_VERSION) {
printf("%s "PACKAGE_VERSION"\n", argv0);
-
+
r = 0;
} else if (command == DAEMON_KILL) {
if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) {
daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno));
goto finish;
}
-
+
r = 0;
} else if (command == DAEMON_REFRESH) {
if (daemon_pid_file_kill(SIGHUP) < 0) {
if (daemonize)
daemon_retval_done();
-
+
if (wrote_pid_file)
daemon_pid_file_remove();
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#ifndef fooglibmallochfoo
#define fooglibmallochfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
if (event & AVAHI_WATCH_IN) {
ssize_t r;
char c;
-
+
if ((r = read(fd, &c, 1)) <= 0) {
fprintf(stderr, "read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
api->watch_free(w);
int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
AvahiGLibPoll *g;
struct timeval tv;
-
+
g = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT);
assert(g);
g_main_loop_unref(loop);
avahi_glib_poll_free(g);
-
+
return 0;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
struct AvahiWatch {
AvahiGLibPoll *glib_poll;
int dead;
-
+
GPollFD pollfd;
int pollfd_added;
-
+
AvahiWatchCallback callback;
void *userdata;
AvahiTimeoutCallback callback;
void *userdata;
-
+
AVAHI_LLIST_FIELDS(AvahiTimeout, timeouts);
};
gboolean timeout_req_cleanup;
gboolean watch_req_cleanup;
-
+
AVAHI_LLIST_HEAD(AvahiWatch, watches);
AVAHI_LLIST_HEAD(AvahiTimeout, timeouts);
};
static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent events, AvahiWatchCallback callback, void *userdata) {
AvahiWatch *w;
AvahiGLibPoll *g;
-
+
assert(api);
assert(fd >= 0);
assert(callback);
if (!(w = avahi_new(AvahiWatch, 1)))
return NULL;
-
+
w->glib_poll = g;
w->pollfd.fd = fd;
w->pollfd.events = map_events_to_glib(events);
g_source_remove_poll(&w->glib_poll->source, &w->pollfd);
w->pollfd_added = FALSE;
}
-
+
w->dead = TRUE;
w->glib_poll->timeout_req_cleanup = TRUE;
}
static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) {
AvahiTimeout *t;
AvahiGLibPoll *g;
-
+
assert(api);
assert(callback);
if (!(t = avahi_new(AvahiTimeout, 1)))
return NULL;
-
+
t->glib_poll = g;
t->dead = FALSE;
if ((t->enabled = !!tv))
t->expiry = *tv;
-
+
t->callback = callback;
t->userdata = userdata;
static void timeout_update(AvahiTimeout *t, const struct timeval *tv) {
assert(t);
assert(!t->dead);
-
+
if ((t->enabled = !!tv))
t->expiry = *tv;
}
assert(g);
for (t = g->timeouts; t; t = t->timeouts_next) {
-
+
if (t->dead || !t->enabled)
continue;
-
+
if (!n || avahi_timeval_compare(&t->expiry, &n->expiry) < 0)
n = t;
}
if (g->timeout_req_cleanup)
cleanup_timeouts(g, 0);
-
+
if ((next_timeout = find_next_timeout(g))) {
GTimeVal now;
struct timeval tvnow;
g_source_get_current_time(source, &now);
tvnow.tv_sec = now.tv_sec;
tvnow.tv_usec = now.tv_usec;
-
+
usec = avahi_timeval_diff(&next_timeout->expiry, &tvnow);
if (usec <= 0) {
*timeout = (gint) (usec / 1000);
} else
*timeout = -1;
-
+
return FALSE;
}
g_source_get_current_time(source, &now);
tvnow.tv_sec = now.tv_sec;
tvnow.tv_usec = now.tv_usec;
-
+
if (avahi_timeval_compare(&next_timeout->expiry, &tvnow) <= 0)
return TRUE;
}
for (w = g->watches; w; w = w->watches_next)
if (w->pollfd.revents > 0)
return TRUE;
-
+
return FALSE;
}
AvahiGLibPoll* g = (AvahiGLibPoll*) source;
AvahiWatch *w;
AvahiTimeout *next_timeout;
-
+
g_assert(g);
if ((next_timeout = find_next_timeout(g))) {
g_source_get_current_time(source, &now);
tvnow.tv_sec = now.tv_sec;
tvnow.tv_usec = now.tv_usec;
-
+
if (avahi_timeval_compare(&next_timeout->expiry, &tvnow) < 0) {
start_timeout_callback(next_timeout);
return TRUE;
}
}
-
+
for (w = g->watches; w; w = w->watches_next)
if (w->pollfd.revents > 0) {
assert(w->callback);
AvahiGLibPoll *avahi_glib_poll_new(GMainContext *context, gint priority) {
AvahiGLibPoll *g;
-
+
static GSourceFuncs source_funcs = {
prepare_func,
check_func,
g_main_context_ref(g->context = context ? context : g_main_context_default());
g->api.userdata = g;
-
+
g->api.watch_new = watch_new;
g->api.watch_free = watch_free;
g->api.watch_update = watch_update;
g->api.watch_get_events = watch_get_events;
-
+
g->api.timeout_new = timeout_new;
g->api.timeout_free = timeout_free;
g->api.timeout_update = timeout_update;
g->watch_req_cleanup = FALSE;
g->timeout_req_cleanup = FALSE;
-
+
AVAHI_LLIST_HEAD_INIT(AvahiWatch, g->watches);
AVAHI_LLIST_HEAD_INIT(AvahiTimeout, g->timeouts);
-
+
g_source_attach(&g->source, g->context);
g_source_set_priority(&g->source, priority);
g_source_set_can_recurse(&g->source, FALSE);
#ifndef fooglibwatchhfoo
#define fooglibwatchhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+*.typelib
+Avahi-0.6.gir
ga-*-enumtypes.c
ga-*-enumtypes.h
*.o
--- /dev/null
+<?xml version="1.0"?>
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+ <namespace name="AvahiCore" version="0.6" shared-library="avahi-core">
+ <alias name="IfIndex" target="int" c:type="AvahiIfIndex"/>
+ <enumeration name="Protocol" c:type="AvahiProtocol">
+ <member name="inet"
+ value="0"
+ c:identifier="AVAHI_PROTO_INET"/>
+ <member name="inet6"
+ value="1"
+ c:identifier="AVAHI_PROTO_INET6"/>
+ <member name="unspec"
+ value="-1"
+ c:identifier="AVAHI_PROTO_UNSPEC"/>
+ </enumeration>
+ <bitfield name="PublishFlags" c:type="AvahiPublishFlags">
+ <member name="unique"
+ value="1"
+ c:identifier="AVAHI_PUBLISH_UNIQUE"/>
+ <member name="no_probe"
+ value="2"
+ c:identifier="AVAHI_PUBLISH_NO_PROBE"/>
+ <member name="no_announce"
+ value="4"
+ c:identifier="AVAHI_PUBLISH_NO_ANNOUNCE"/>
+ <member name="allow_multiple"
+ value="8"
+ c:identifier="AVAHI_PUBLISH_ALLOW_MULTIPLE"/>
+ <member name="no_reverse"
+ value="16"
+ c:identifier="AVAHI_PUBLISH_NO_reverse"/>
+ <member name="no_cookie"
+ value="32"
+ c:identifier="AVAHI_PUBLISH_NO_cookie"/>
+ <member name="update"
+ value="64"
+ c:identifier="AVAHI_PUBLISH_UPDATE"/>
+ <member name="use_wide_area"
+ value="128"
+ c:identifier="AVAHI_PUBLISH_USE_WIDE_AREA"/>
+ <member name="use_multicast"
+ value="256"
+ c:identifier="AVAHI_PUBLISH_USE_MULTICAST"/>
+ </bitfield>
+ <record name="StringList" c:type="AvahiStringList"/>
+ <record name="Address" c:type="AvahiAddress"/>
+ <record name="Client" c:type="AvahiClient"/>
+ <function name="server_get_host_name" c:identifier="avahi_server_get_host_name">
+ <return-value transfer-ownership="none">
+ <type name="utf8" c:type="char8"/>
+ </return-value>
+ <parameters>
+ </parameters>
+ </function>
+ </namespace>
+</repository>
-# $Id$
-#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# This cool debug trap works on i386/gcc only
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
+EXTRA_DIST = \
+ AvahiCore-0.6.gir
+
if HAVE_GOBJECT
if HAVE_DBUS
$(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done)
signals-marshal.list: $(CORE_SOURCES) Makefile.am
- ( cd $(srcdir) && \
+ $(AM_V_GEN)( cd $(srcdir) && \
sed -n -e 's/.*_ga_signals_marshal_\([A-Z]*__[A-Z_]*\).*/\1/p' \
$(CORE_SOURCES) ) \
- | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp
+ | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp && \
if cmp -s $@.tmp $@; then \
rm $@.tmp; \
else \
fi
signals-marshal.h: signals-marshal.list
- glib-genmarshal --header --prefix=_ga_signals_marshal $< > $@
+ $(AM_V_GEN)glib-genmarshal --header --prefix=_ga_signals_marshal $< > $@
signals-marshal.c: signals-marshal.list
- glib-genmarshal --body --prefix=_ga_signals_marshal $< > $@
-
+ $(AM_V_GEN)(echo "#include \"signals-marshal.h\"" ; glib-genmarshal --body --prefix=_ga_signals_marshal $< ) > $@
# rules for making the glib enum objects
%-enumtypes.h: %.h Makefile.in
- glib-mkenums \
+ $(AM_V_GEN)glib-mkenums \
--fhead "#ifndef __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n#define __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
--fprod "/* enumerations from \"@filename@\" */\n" \
--vhead "GType @enum_name@_get_type (void);\n#define $(shell echo $* | tr [:lower:]- [:upper:]_ | sed 's/_.*//')_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
$< > $@
%-enumtypes.c: %.h Makefile.in
- glib-mkenums \
- --fhead "#include <$*.h>" \
+ $(AM_V_GEN)glib-mkenums \
+ --fhead "#include <$*.h>\n#include<$*-enumtypes.h>" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@VALUENAME@\" }," \
--vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
$< > $@
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+if HAVE_INTROSPECTION
+introspection_sources = $(libavahi_gobject_la_SOURCES)
+
+Avahi-0.6.gir: $(lib_LTLIBRARIES)
+Avahi_0_6_gir_INCLUDES = GObject-2.0 AvahiCore-0.6
+Avahi_0_6_gir_CFLAGS = $(libavahi_gobject_la_CFLAGS)
+Avahi_0_6_gir_LIBS = $(lib_LTLIBRARIES)
+Avahi_0_6_gir_FILES = $(addprefix $(srcdir)/, $(CORE_SOURCES)) $(BUILT_SOURCES)
+Avahi_0_6_gir_SCANNERFLAGS = --strip-prefix=Ga
+INTROSPECTION_GIRS += Avahi-0.6.gir
+INTROSPECTION_INSTALL_GIRS = AvahiCore-0.6.gir $(INTROSPECTION_GIRS)
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_INSTALL_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_INSTALL_GIRS:.gir=.typelib)
+
+CLEANFILES += $(INTROSPECTION_GIRS) $(typelib_DATA)
+endif
+
endif
endif
GaEntryGroupServicePrivate *priv = (GaEntryGroupServicePrivate *) service;
GaEntryGroupServiceEntry entry;
- entry.value = key;
+ entry.value = (void*) key;
entry.size = strlen(key);
g_hash_table_remove(priv->entries, &entry);
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
avahi-bookmarks
avahi-bookmarks: avahi-bookmarks.in
- sed -e 's,@PYTHON\@,$(PYTHON),g' $< > $@
+ $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' $< > $@ && \
chmod +x $@
bin_SCRIPTS = $(pythonscripts)
#!@PYTHON@
# -*-python-*-
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
EXTRA_DIST = \
__init__.py \
- SimpleGladeApp.py \
avahi-discover.in \
avahi-discover.desktop.in.in
pythonscripts =
desktopdir = $(datadir)/applications
-desktop_DATA =
+desktop_DATA =
avahi_discoverdir = $(pythondir)/avahi_discover
avahi_discover_PYTHON =
avahi-discover
desktop_DATA += avahi-discover.desktop
@INTLTOOL_DESKTOP_RULE@
-avahi_discover_PYTHON += __init__.py SimpleGladeApp.py
+avahi_discover_PYTHON += __init__.py
endif
if HAVE_DBM
avahi-discover
desktop_DATA += avahi-discover.desktop
@INTLTOOL_DESKTOP_RULE@
-avahi_discover_PYTHON += __init__.py SimpleGladeApp.py
+avahi_discover_PYTHON += __init__.py
endif
avahi-discover.desktop.in: avahi-discover.desktop.in.in
- sed -e 's,@bindir\@,$(bindir),g' $< > $@
+ $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@
avahi-discover: avahi-discover.in
- sed -e 's,@PYTHON\@,$(PYTHON),g' \
+ $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
-e 's,@GETTEXT_PACKAGE\@,"$(GETTEXT_PACKAGE)",g' \
-e 's,@LOCALEDIR\@,"$(datadir)/locale",g' \
- -e 's,@interfacesdir\@,$(interfacesdir),g' $< > $@
+ -e 's,@interfacesdir\@,$(interfacesdir),g' $< > $@ && \
chmod +x $@
bin_SCRIPTS = $(pythonscripts)
+++ /dev/null
-"""
- SimpleGladeApp.py
- Module that provides an object oriented abstraction to pygtk and libglade.
- Copyright (C) 2004 Sandino Flores Moreno
-"""
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-
-import os
-import sys
-import re
-
-import tokenize
-import gtk
-import gtk.glade
-import weakref
-import inspect
-
-__version__ = "1.0"
-__author__ = 'Sandino "tigrux" Flores-Moreno'
-
-def bindtextdomain(app_name, locale_dir=None):
- """
- Bind the domain represented by app_name to the locale directory locale_dir.
- It has the effect of loading translations, enabling applications for different
- languages.
-
- app_name:
- a domain to look for translations, tipically the name of an application.
-
- locale_dir:
- a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo
- If omitted or None, then the current binding for app_name is used.
- """
- try:
- import locale
- import gettext
- locale.setlocale(locale.LC_ALL, "")
- gtk.glade.bindtextdomain(app_name, locale_dir)
- gettext.install(app_name, locale_dir, unicode=1)
- except (IOError,locale.Error), e:
- print "Warning", app_name, e
- __builtins__.__dict__["_"] = lambda x : x
-
-
-class SimpleGladeApp:
-
- def __init__(self, path, root=None, domain=None, **kwargs):
- """
- Load a glade file specified by glade_filename, using root as
- root widget and domain as the domain for translations.
-
- If it receives extra named arguments (argname=value), then they are used
- as attributes of the instance.
-
- path:
- path to a glade filename.
- If glade_filename cannot be found, then it will be searched in the
- same directory of the program (sys.argv[0])
-
- root:
- the name of the widget that is the root of the user interface,
- usually a window or dialog (a top level widget).
- If None or ommited, the full user interface is loaded.
-
- domain:
- A domain to use for loading translations.
- If None or ommited, no translation is loaded.
-
- **kwargs:
- a dictionary representing the named extra arguments.
- It is useful to set attributes of new instances, for example:
- glade_app = SimpleGladeApp("ui.glade", foo="some value", bar="another value")
- sets two attributes (foo and bar) to glade_app.
- """
- if os.path.isfile(path):
- self.glade_path = path
- else:
- glade_dir = os.path.dirname( sys.argv[0] )
- self.glade_path = os.path.join(glade_dir, path)
- for key, value in kwargs.items():
- try:
- setattr(self, key, weakref.proxy(value) )
- except TypeError:
- setattr(self, key, value)
- self.glade = None
- self.install_custom_handler(self.custom_handler)
- self.glade = self.create_glade(self.glade_path, root, domain)
- if root:
- self.main_widget = self.get_widget(root)
- else:
- self.main_widget = None
- self.normalize_names()
- self.add_callbacks(self)
- self.new()
-
- def __repr__(self):
- class_name = self.__class__.__name__
- if self.main_widget:
- root = gtk.Widget.get_name(self.main_widget)
- repr = '%s(path="%s", root="%s")' % (class_name, self.glade_path, root)
- else:
- repr = '%s(path="%s")' % (class_name, self.glade_path)
- return repr
-
- def new(self):
- """
- Method called when the user interface is loaded and ready to be used.
- At this moment, the widgets are loaded and can be refered as self.widget_name
- """
- pass
-
- def add_callbacks(self, callbacks_proxy):
- """
- It uses the methods of callbacks_proxy as callbacks.
- The callbacks are specified by using:
- Properties window -> Signals tab
- in glade-2 (or any other gui designer like gazpacho).
-
- Methods of classes inheriting from SimpleGladeApp are used as
- callbacks automatically.
-
- callbacks_proxy:
- an instance with methods as code of callbacks.
- It means it has methods like on_button1_clicked, on_entry1_activate, etc.
- """
- self.glade.signal_autoconnect(callbacks_proxy)
-
- def normalize_names(self):
- """
- It is internally used to normalize the name of the widgets.
- It means a widget named foo:vbox-dialog in glade
- is refered self.vbox_dialog in the code.
-
- It also sets a data "prefixes" with the list of
- prefixes a widget has for each widget.
- """
- for widget in self.get_widgets():
- widget_name = gtk.Widget.get_name(widget)
- prefixes_name_l = widget_name.split(":")
- prefixes = prefixes_name_l[ : -1]
- widget_api_name = prefixes_name_l[-1]
- widget_api_name = "_".join( re.findall(tokenize.Name, widget_api_name) )
- gtk.Widget.set_name(widget, widget_api_name)
- if hasattr(self, widget_api_name):
- raise AttributeError("instance %s already has an attribute %s" % (self,widget_api_name))
- else:
- setattr(self, widget_api_name, widget)
- if prefixes:
- gtk.Widget.set_data(widget, "prefixes", prefixes)
-
- def add_prefix_actions(self, prefix_actions_proxy):
- """
- By using a gui designer (glade-2, gazpacho, etc)
- widgets can have a prefix in theirs names
- like foo:entry1 or foo:label3
- It means entry1 and label3 has a prefix action named foo.
-
- Then, prefix_actions_proxy must have a method named prefix_foo which
- is called everytime a widget with prefix foo is found, using the found widget
- as argument.
-
- prefix_actions_proxy:
- An instance with methods as prefix actions.
- It means it has methods like prefix_foo, prefix_bar, etc.
- """
- prefix_s = "prefix_"
- prefix_pos = len(prefix_s)
-
- is_method = lambda t : callable( t[1] )
- is_prefix_action = lambda t : t[0].startswith(prefix_s)
- drop_prefix = lambda (k,w): (k[prefix_pos:],w)
-
- members_t = inspect.getmembers(prefix_actions_proxy)
- methods_t = filter(is_method, members_t)
- prefix_actions_t = filter(is_prefix_action, methods_t)
- prefix_actions_d = dict( map(drop_prefix, prefix_actions_t) )
-
- for widget in self.get_widgets():
- prefixes = gtk.Widget.get_data(widget, "prefixes")
- if prefixes:
- for prefix in prefixes:
- if prefix in prefix_actions_d:
- prefix_action = prefix_actions_d[prefix]
- prefix_action(widget)
-
- def custom_handler(self,
- glade, function_name, widget_name,
- str1, str2, int1, int2):
- """
- Generic handler for creating custom widgets, internally used to
- enable custom widgets (custom widgets of glade).
-
- The custom widgets have a creation function specified in design time.
- Those creation functions are always called with str1,str2,int1,int2 as
- arguments, that are values specified in design time.
-
- Methods of classes inheriting from SimpleGladeApp are used as
- creation functions automatically.
-
- If a custom widget has create_foo as creation function, then the
- method named create_foo is called with str1,str2,int1,int2 as arguments.
- """
- try:
- handler = getattr(self, function_name)
- return handler(str1, str2, int1, int2)
- except AttributeError:
- return None
-
- def gtk_widget_show(self, widget, *args):
- """
- Predefined callback.
- The widget is showed.
- Equivalent to widget.show()
- """
- widget.show()
-
- def gtk_widget_hide(self, widget, *args):
- """
- Predefined callback.
- The widget is hidden.
- Equivalent to widget.hide()
- """
- widget.hide()
-
- def gtk_widget_grab_focus(self, widget, *args):
- """
- Predefined callback.
- The widget grabs the focus.
- Equivalent to widget.grab_focus()
- """
- widget.grab_focus()
-
- def gtk_widget_destroy(self, widget, *args):
- """
- Predefined callback.
- The widget is destroyed.
- Equivalent to widget.destroy()
- """
- widget.destroy()
-
- def gtk_window_activate_default(self, window, *args):
- """
- Predefined callback.
- The default widget of the window is activated.
- Equivalent to window.activate_default()
- """
- widget.activate_default()
-
- def gtk_true(self, *args):
- """
- Predefined callback.
- Equivalent to return True in a callback.
- Useful for stopping propagation of signals.
- """
- return True
-
- def gtk_false(self, *args):
- """
- Predefined callback.
- Equivalent to return False in a callback.
- """
- return False
-
- def gtk_main_quit(self, *args):
- """
- Predefined callback.
- Equivalent to self.quit()
- """
- self.quit()
-
- def main(self):
- """
- Starts the main loop of processing events.
- The default implementation calls gtk.main()
-
- Useful for applications that needs a non gtk main loop.
- For example, applications based on gstreamer needs to override
- this method with gst.main()
-
- Do not directly call this method in your programs.
- Use the method run() instead.
- """
- gtk.main()
-
- def quit(self):
- """
- Quit processing events.
- The default implementation calls gtk.main_quit()
-
- Useful for applications that needs a non gtk main loop.
- For example, applications based on gstreamer needs to override
- this method with gst.main_quit()
- """
- gtk.main_quit()
-
- def run(self):
- """
- Starts the main loop of processing events checking for Control-C.
-
- The default implementation checks wheter a Control-C is pressed,
- then calls on_keyboard_interrupt().
-
- Use this method for starting programs.
- """
- try:
- self.main()
- except KeyboardInterrupt:
- self.on_keyboard_interrupt()
-
- def on_keyboard_interrupt(self):
- """
- This method is called by the default implementation of run()
- after a program is finished by pressing Control-C.
- """
- pass
-
- def install_custom_handler(self, custom_handler):
- gtk.glade.set_custom_handler(custom_handler)
-
- def create_glade(self, glade_path, root, domain):
- return gtk.glade.XML(self.glade_path, root, domain)
-
- def get_widget(self, widget_name):
- return self.glade.get_widget(widget_name)
-
- def get_widgets(self):
- return self.glade.get_widget_prefix("")
#!@PYTHON@
# -*-python-*-
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!@PYTHON@
# -*-python-*-
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
try:
import avahi, gettext, gtk, gobject, dbus, avahi.ServiceTypeDatabase
- from avahi_discover.SimpleGladeApp import SimpleGladeApp
- gtk.glade.bindtextdomain(@GETTEXT_PACKAGE@, @LOCALEDIR@)
- gtk.glade.textdomain(@GETTEXT_PACKAGE@)
_ = gettext.gettext
except ImportError, e:
print "Sorry, to use this tool you need to install Avahi, pygtk and python-dbus.\n Error: %s" % e
sys.exit(1)
+except Exception, e:
+ print "Failed to initialize: %s" % e
+ sys.exit(1)
## !!NOTE!! ##
d.run()
d.destroy()
-glade_dir = "@interfacesdir@"
+ui_dir = "@interfacesdir@"
service_type_db = avahi.ServiceTypeDatabase.ServiceTypeDatabase()
-class Main_window(SimpleGladeApp):
- def __init__(self, path="avahi-discover.glade", root="main_window", domain=None, **kwargs):
- path = os.path.join(glade_dir, path)
+class Main_window:
+ def __init__(self, path="avahi-discover.ui", root="main_window", domain=None, **kwargs):
+ path = os.path.join(ui_dir, path)
gtk.window_set_default_icon_name("network-wired")
- SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
+ self.ui = gtk.Builder()
+ self.ui.add_from_file(path)
+ self.ui.connect_signals(self)
+ self.tree_view = self.ui.get_object("tree_view")
+ self.info_label = self.ui.get_object("info_label")
+ self.new()
def on_tree_view_cursor_changed(self, widget, *args):
(model, iter) = widget.get_selection().get_selected()
if protocol == avahi.PROTO_INET6:
return "IPv6"
return "n/a"
-
+
def siocgifname(self, interface):
if interface <= 0:
return "n/a"
return "Wide Area"
else:
return str(self.siocgifname(interface)) + " " + str(self.protoname(protocol))
-
+
def service_resolved(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags):
print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, stype, domain, interface, protocol)
print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(avahi.txt_array_to_string_array(txt)))
self.update_label(interface, protocol, name, stype, domain, host, aprotocol, address, port, avahi.txt_array_to_string_array(txt))
-
+
def print_error(self, err):
error_label = "<b>Error:</b> %s" % (err)
self.info_label.set_markup(error_label)
return service_type_db[stype]
except KeyError:
return stype
-
+
def new_service(self, interface, protocol, name, stype, domain, flags):
print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, stype, domain, interface, protocol)
if self.zc_ifaces.has_key((interface,protocol)) == False:
ifn = self.get_interface_name(interface, protocol)
-
+
self.zc_ifaces[(interface,protocol)] = self.insert_row(self.treemodel, None, ifn, None,interface,protocol,None,domain)
if self.zc_domains.has_key((interface,protocol,domain)) == False:
self.zc_domains[(interface,protocol,domain)] = self.insert_row(self.treemodel, self.zc_ifaces[(interface,protocol)], domain,None,interface,protocol,None,domain)
parent = self.treemodel.iter_parent(treeiter)
self.treemodel.remove(treeiter)
del self.zc_ifaces[(interface,protocol)]
-
+
def new_service_type(self, interface, protocol, stype, domain, flags):
global service_browsers
- # Are we already browsing this domain for this type?
+ # Are we already browsing this domain for this type?
if service_browsers.has_key((interface, protocol, stype, domain)):
return
-
+
print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (stype, domain, interface, protocol)
-
+
b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
b.connect_to_signal('ItemNew', self.new_service)
b.connect_to_signal('ItemRemove', self.remove_service)
print e
error_msg("You should check that the avahi daemon is running.\n\nError : %s" % e)
sys.exit(0)
-
+
b.connect_to_signal('ItemNew', self.new_service_type)
service_type_browsers[(interface, protocol, domain)] = b
if len(tmp[0]) > 0:
res[tmp[0]] = tmp[1]
return res
-
+
def update_label(self,interface, protocol, name, stype, domain, host, aprotocol, address, port, txt):
if len(txt) != 0:
return myiter
def new(self):
- print "A new main_window has been created"
self.treemodel=gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
self.tree_view.set_model(self.treemodel)
self.zc_domains = {}
self.zc_types = {}
self.services_browsed = {}
-
- self.bus = dbus.SystemBus()
- self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
+
+ try:
+ self.bus = dbus.SystemBus()
+ self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
+ except Exception, e:
+ print "Failed to connect to Avahi Server (Is it running?): %s" % e
+ sys.exit(1)
if self.domain is None:
# Explicitly browse .local
self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local")
-
+
# Browse for other browsable domains
db = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE, dbus.UInt32(0))), avahi.DBUS_INTERFACE_DOMAIN_BROWSER)
db.connect_to_signal('ItemNew', self.new_domain)
# Just browse the domain the user wants us to browse
self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain)
-
+ def gtk_main_quit(self, *args):
+ gtk.main_quit()
+
def main():
main_window = Main_window()
+ gtk.main()
- main_window.run()
-
if __name__ == "__main__":
main()
-
-
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
nodist_avahi_SCRIPTS = ServiceTypeDatabase.py
ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
- sed -e 's,@PYTHON\@,$(PYTHON),g' \
+ $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
-e 's,@DBM\@,gdbm,g' \
-e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \
-e 's,@CHECK_KEY\@,while key is not None:,g' \
-e 's,@NEXT_KEY\@,key = self.db.nextkey(key),g' \
- -e 's,@pkglibdir\@,$(pkglibdir),g' $< > $@
+ -e 's,@pkglibdir\@,$(pkglibdir),g' $< > $@ && \
chmod +x $@
endif
nodist_avahi_SCRIPTS = ServiceTypeDatabase.py
ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
- sed -e 's,@PYTHON\@,$(PYTHON),g' \
+ $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
-e 's,@DBM\@,dbm,g' \
-e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \
-e 's,@CHECK_KEY\@,for key in keys:,g' \
-e 's,@NEXT_KEY\@,,g' \
- -e 's,@pkglibdir\@,$(pkglibdir),g' $< > $@
+ -e 's,@pkglibdir\@,$(pkglibdir),g' $< > $@ && \
chmod +x $@
endif
#!@PYTHON@
# -*-python-*-
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
locale.setlocale(locale.LC_ALL, '')
class ServiceTypeDatabase:
+ """ServiceTypeDatabase maps service types to descriptions"""
def __init__(self, filename = "@pkglibdir@/service-types.db"):
def items(self):
- items = []
- @FIRST_KEY@
- @CHECK_KEY@
- if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
- localized_service_name = self[key]
- items.append((key, localized_service_name))
- @NEXT_KEY@
- return items
+ return list(self.iteritems())
def has_key(self, key):
return False
+ def __iter__(self):
+
+ @FIRST_KEY@
+ @CHECK_KEY@
+
+ if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
+ yield key
+
+ @NEXT_KEY@
+
+ def __len__(self):
+
+ count = 0
+ for _ in self:
+
+ count+=1
+
+ self.__len__ = lambda : count
+ return len(self)
+
+ def get(self, key, default=None):
+
+ if key in self:
+ return self[key]
+ else:
+ return default
+
+ def iteritems(self):
+
+ return ((key, self[key]) for key in self)
+
+ def iterkeys(self):
+
+ return self.__iter__()
+
+ def itervalues(self):
+
+ return (self[key] for key in self)
+
+ def keys(self):
+
+ return list(self)
+
+ def values(self):
+
+ return list(self.itervalues())
if __name__ == "__main__":
print b["_webdav._tcp"]
print b["_webdavs._tcp"]
- print b["gurki._tcp"]
+ print b.get("gurki._tcp")
+ print len(b)
+
+ for key, _ in zip(b, xrange(3)):
+
+ print key
+
+ for key, _ in zip(b.iteritems(), xrange(3)):
+
+ print key
+
+ for key, _ in zip(b.itervalues(), xrange(3)):
+
+ print key
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
AM_CFLAGS=-I$(top_srcdir)
-lib_LTLIBRARIES =
-BUILT_SOURCES =
+lib_LTLIBRARIES =
+BUILT_SOURCES =
if HAVE_QT3
avahiqt3includedir=$(includedir)/avahi-qt3
avahiqt3include_HEADERS = \
- qt-watch.h
+ qt-watch.h
lib_LTLIBRARIES += \
libavahi-qt3.la
BUILT_SOURCES += qt-watch.moc3
libavahi_qt3_la_SOURCES = \
- qt-watch.cpp
+ qt-watch.cpp
qt-watch.moc3: qt-watch.cpp
- $(MOC_QT3) $^ > $@
+ $(AM_V_GEN)$(MOC_QT3) $^ > $@
libavahi_qt3_la_CPPFLAGS = $(AM_CFLAGS) $(QT3_CFLAGS) $(VISIBILITY_HIDDEN_CFLAGS)
libavahi_qt3_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT3_LIBS)
avahiqt4includedir=$(includedir)/avahi-qt4
avahiqt4include_HEADERS = \
- qt-watch.h
+ qt-watch.h
lib_LTLIBRARIES += \
libavahi-qt4.la
BUILT_SOURCES += qt-watch.moc4
libavahi_qt4_la_SOURCES = \
- qt-watch.cpp
+ qt-watch.cpp
qt-watch.moc4: qt-watch.cpp
- $(MOC_QT4) $^ > $@
+ $(AM_V_GEN)$(MOC_QT4) $^ > $@
libavahi_qt4_la_CPPFLAGS = $(AM_CFLAGS) $(QT4_CFLAGS) -DQT4 $(VISIBILITY_HIDDEN_CFLAGS)
libavahi_qt4_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la $(QT4_LIBS)
-/* $Id$ */
-
/***
This file is part of avahi.
#ifndef QAVAHI_H
#define QAVAHI_H
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
this.address = address;
}
}
-
+
public class AddressResolver : ResolverBase, IDisposable
{
private IntPtr handle;
private ArrayList foundListeners = new ArrayList ();
private ArrayList timeoutListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_address_resolver_new (IntPtr client, int iface, Protocol proto,
IntPtr address, LookupFlags flags,
Stop (false);
}
}
-
+
public event EventHandler Timeout
{
add {
if (handle == IntPtr.Zero)
client.ThrowError ();
}
-
+
Utility.Free (addrPtr);
}
-/* $Id$ */
-
/***
This file is part of avahi.
using System.Runtime.CompilerServices;
//
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("(C) 2005 James Willcox <snorp@snorp.net>")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
-// Minor Version
+// Minor Version
// Build Number
// Revision
//
-// You can specify all the values or you can default the Revision and Build Numbers
+// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0")]
-/* $Id$ */
-
/***
This file is part of avahi.
if (args.State == EntryGroupState.Established) {
DomainBrowser browser = new DomainBrowser (client);
objects.Add (browser);
-
+
browser.DomainAdded += OnDomainAdded;
}
}
{
ServiceTypeBrowser stb = new ServiceTypeBrowser (client, domain);
objects.Add (stb);
-
+
stb.CacheExhausted += OnCacheExhausted;
stb.ServiceTypeAdded += OnServiceTypeAdded;
}
Console.WriteLine ("Got service type: " + args.ServiceType.ServiceType);
ServiceBrowser sb = new ServiceBrowser (client, args.ServiceType.ServiceType, args.ServiceType.Domain);
objects.Add (sb);
-
+
sb.ServiceAdded += OnServiceAdded;
}
private static void OnServiceResolved (object o, ServiceInfoArgs args)
{
objects.Remove (o);
-
+
Console.WriteLine ("Service '{0}' at {1}:{2}", args.Service.Name, args.Service.HostName, args.Service.Port);
foreach (byte[] bytes in args.Service.Text) {
Console.WriteLine ("Text: " + Encoding.UTF8.GetString (bytes));
private static void OnAddressResolved (object o, HostAddressArgs args)
{
objects.Remove (o);
-
+
Console.WriteLine ("Resolved {0} to {1}", args.Address, args.Host);
HostNameResolver hr = new HostNameResolver (client, args.Host);
objects.Add (hr);
-
+
hr.Found += OnHostNameResolved;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
Found,
Failure
}
-
+
internal enum BrowserEvent {
Added,
Removed,
this.error = error;
}
}
-
+
public enum Protocol {
Unspecified = -1,
IPv4 = 0,
Running,
Collision
}
-
+
public enum ClientState {
Registering = ServerState.Registering,
Running = ServerState.Running,
IgnoreUserConfig = 1,
NoFail = 2
}
-
+
public class Client : IDisposable
{
private IntPtr handle;
[DllImport ("avahi-client")]
private static extern int avahi_client_errno (IntPtr handle);
-
+
[DllImport ("avahi-common")]
private static extern IntPtr avahi_simple_poll_new ();
{
get { return handle; }
}
-
+
public string Version
{
get {
avahi_simple_poll_quit (spoll);
Monitor.Wait (this);
-
+
avahi_simple_poll_free (spoll);
}
}
IntPtr namePtr = Stdlib.malloc ((ulong) len);
IntPtr typePtr = Stdlib.malloc ((ulong) len);
IntPtr domainPtr = Stdlib.malloc ((ulong) len);
-
+
int ret = avahi_service_name_split (Utility.StringToBytes (service), namePtr, len, typePtr, len,
domainPtr, len);
Utility.Free (namePtr);
Utility.Free (typePtr);
Utility.Free (domainPtr);
-
+
name = null;
type = null;
domain = null;
if (error != ErrorCode.Ok)
throw new ClientException (error);
}
-
+
private void OnClientCallback (IntPtr client, ClientState state, IntPtr userData)
{
if (StateChanged != null)
-/* $Id$ */
-
/***
This file is part of avahi.
this.code = code;
}
}
-
+
public class ClientException : ApplicationException
{
private ErrorCode code;
[DllImport ("avahi-common")]
private static extern IntPtr avahi_strerror (ErrorCode code);
-
+
public ErrorCode ErrorCode
{
get { return code; }
internal ClientException (int code) : this ((ErrorCode) code) {
}
-
+
internal ClientException (ErrorCode code) : base (GetErrorString (code))
{
this.code = code;
-/* $Id$ */
-
/***
This file is part of avahi.
}
public delegate void DomainInfoHandler (object o, DomainInfoArgs args);
-
+
public class DomainBrowser : BrowserBase, IDisposable
{
private IntPtr handle;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_domain_browser_new (IntPtr client, int iface, int proto,
byte[] domain, int btype, LookupFlags flags,
Stop (false);
}
}
-
+
public event DomainInfoHandler DomainRemoved
{
add {
public DomainBrowser (Client client) : this (client, -1, Protocol.Unspecified, client.DomainName,
DomainBrowserType.Browse, LookupFlags.None) {
}
-
+
public DomainBrowser (Client client, int iface, Protocol proto, string domain,
DomainBrowserType btype, LookupFlags flags)
{
-/* $Id$ */
-
/***
This file is part of avahi.
UseWideArea = 128,
UseMulticast = 256
}
-
+
public enum EntryGroupState {
Uncommited,
Registering,
{
get { return state; }
}
-
+
public EntryGroupStateArgs (EntryGroupState state)
{
this.state = state;
internal delegate void EntryGroupCallback (IntPtr group, EntryGroupState state, IntPtr userdata);
public delegate void EntryGroupStateHandler (object o, EntryGroupStateArgs args);
-
+
public class EntryGroup : IDisposable
{
private Client client;
private IntPtr handle;
private EntryGroupCallback cb;
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_entry_group_new (IntPtr client, EntryGroupCallback cb, IntPtr userdata);
private static extern int avahi_entry_group_add_record (IntPtr group, int iface, Protocol proto,
PublishFlags flags, byte[] name, RecordClass clazz,
RecordType type, uint ttl, byte[] rdata, int size);
-
+
[DllImport ("avahi-client")]
private static extern void avahi_entry_group_free (IntPtr group);
private static extern IntPtr avahi_alternative_service_name (byte[] name);
public event EntryGroupStateHandler StateChanged;
-
+
public EntryGroupState State
{
get {
}
}
}
-
+
public EntryGroup (Client client)
{
this.client = client;
Utility.StringToBytes (domain),
Utility.StringToBytes (host), port, list);
}
-
+
avahi_string_list_free (list);
-
+
if (ret < 0) {
client.ThrowError ();
}
UpdateService (iface, proto, flags, name, type, domain, list);
}
-
+
private void UpdateService (int iface, Protocol proto, PublishFlags flags, string name, string type,
string domain, IntPtr list)
{
-/* $Id$ */
-
/***
This file is part of avahi.
private ArrayList foundListeners = new ArrayList ();
private ArrayList timeoutListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_host_name_resolver_new (IntPtr client, int iface, Protocol proto,
byte[] hostname, Protocol aproto, LookupFlags flags,
Stop (false);
}
}
-
+
public event EventHandler Timeout
{
add {
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
$(srcdir)/gencfg.sh
$(ASSEMBLY): $(AVAHISOURCES)
- mcs -keyfile:$(srcdir)/avahi.snk -target:library -out:$@ -debug $(AVAHISOURCES) -r:Mono.Posix
+ $(AM_V_GEN)MONO_SHARED_DIR=. mcs -keyfile:$(srcdir)/avahi.snk -target:library -out:$@ -debug $(AVAHISOURCES) -r:Mono.Posix
$(ASSEMBLY).config: $(ASSEMBLY).config.in
- $(srcdir)/gencfg.sh $(top_builddir)/avahi-client/libavahi-client.la \
+ $(AM_V_GEN)$(srcdir)/gencfg.sh $(top_builddir)/avahi-client/libavahi-client.la \
$(top_builddir)/avahi-common/libavahi-common.la \
$(top_builddir)/avahi-glib/libavahi-glib.la < $< > $@
if HAVE_MONODOC
update-docs: $(ASSEMBLY)
- $(MONODOCER) -assembly:$(ASSEMBLY) -path:en
+ $(AM_V_GEN)$(MONODOCER) -assembly:$(ASSEMBLY) -path:en
avahi-sharp-docs.zip: avahi-sharp-docs.tree
avahi-sharp-docs.tree: $(srcdir)/en/*/*
- $(MDASSEMBLER) --out avahi-sharp-docs --ecma $(srcdir)/en
+ $(AM_V_GEN)$(MDASSEMBLER) --out avahi-sharp-docs --ecma $(srcdir)/en
monodocdir = $(MONODOC_DIR)
monodoc_DATA = avahi-sharp-docs.zip avahi-sharp-docs.tree avahi-sharp-docs.source
endif
install-data-hook: $(ASSEMBLY)
- $(GACUTIL) /i $(ASSEMBLY) /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir)
+ $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /i $(ASSEMBLY) /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir)
uninstall-hook: $(ASSEMBLY)
- $(GACUTIL) /u avahi-sharp /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir)
+ $(AM_V_GEN)MONO_SHARED_DIR=. $(GACUTIL) /u avahi-sharp /package avahi-sharp /gacdir $(libdir) /root $(DESTDIR)$(libdir)
endif
endif
-/* $Id: ServiceBrowser.cs 635 2005-09-26 03:57:30Z snorp $ */
-
/***
This file is part of avahi.
{
public delegate void RecordInfoHandler (object o, RecordInfoArgs args);
-
+
internal delegate void RecordBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent,
IntPtr name, ushort clazz, ushort type, IntPtr rdata, int size,
LookupResultFlags flags, IntPtr userdata);
Aaa = 28,
Srv = 33
}
-
+
public struct RecordInfo
{
public int NetworkInterface;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_record_browser_new (IntPtr client, int iface, Protocol proto,
byte[] name, ushort clazz, ushort type,
Stop (false);
}
}
-
+
public event RecordInfoHandler RecordRemoved
{
add {
this (client, -1, Protocol.Unspecified, name, RecordClass.In, type, LookupFlags.None)
{
}
-
+
public RecordBrowser (Client client, int iface, Protocol proto, string name, RecordClass clazz,
RecordType type, LookupFlags flags)
{
{
if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero &&
(force || (addListeners.Count == 0 && removeListeners.Count == 0))) {
-
+
lock (client) {
avahi_record_browser_free (handle);
handle = IntPtr.Zero;
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
internal delegate void ServiceBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent,
IntPtr name, IntPtr type, IntPtr domain, LookupResultFlags flags,
IntPtr userdata);
-
+
public struct ServiceInfo
{
public int NetworkInterface;
}
public delegate void ServiceInfoHandler (object o, ServiceInfoArgs args);
-
+
public class ServiceBrowser : BrowserBase, IDisposable
{
private IntPtr handle;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_service_browser_new (IntPtr client, int iface, int proto, byte[] type,
byte[] domain, LookupFlags flags,
Stop (false);
}
}
-
+
public event ServiceInfoHandler ServiceRemoved
{
add {
public ServiceBrowser (Client client, string type) : this (client, type, client.DomainName)
{
}
-
+
public ServiceBrowser (Client client, string type, string domain) : this (client, -1, Protocol.Unspecified,
type, domain, LookupFlags.None)
{
}
-
+
public ServiceBrowser (Client client, int iface, Protocol proto, string type, string domain, LookupFlags flags)
{
this.client = client;
{
if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero &&
(force || (addListeners.Count == 0 && removeListeners.Count == 0))) {
-
+
lock (client) {
avahi_service_browser_free (handle);
handle = IntPtr.Zero;
-/* $Id$ */
-
/***
This file is part of avahi.
private ArrayList foundListeners = new ArrayList ();
private ArrayList timeoutListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_service_resolver_new (IntPtr client, int iface, Protocol proto,
byte[] name, byte[] type, byte[] domain,
Stop (false);
}
}
-
+
public event EventHandler Timeout
{
add {
GetLookupFlags (service.Flags))
{
}
-
+
public ServiceResolver (Client client, int iface, Protocol proto, string name,
string type, string domain, Protocol aproto, LookupFlags flags)
{
-/* $Id$ */
-
/***
This file is part of avahi.
internal delegate void ServiceTypeBrowserCallback (IntPtr browser, int iface, Protocol proto, BrowserEvent bevent,
IntPtr type, IntPtr domain, LookupResultFlags flags,
IntPtr userdata);
-
+
public struct ServiceTypeInfo
{
public int NetworkInterface;
}
public delegate void ServiceTypeInfoHandler (object o, ServiceTypeInfoArgs args);
-
+
public class ServiceTypeBrowser : BrowserBase, IDisposable
{
private IntPtr handle;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
-
+
[DllImport ("avahi-client")]
private static extern IntPtr avahi_service_type_browser_new (IntPtr client, int iface, int proto,
byte[] domain, LookupFlags flags,
Stop (false);
}
}
-
+
public event ServiceTypeInfoHandler ServiceTypeRemoved
{
add {
-/* $Id$ */
-
/***
This file is part of avahi.
{
if (ptr == IntPtr.Zero)
return null;
-
+
int len = strlen (ptr);
byte[] bytes = new byte[len];
Marshal.Copy (ptr, bytes, 0, len);
{
if (ptr == IntPtr.Zero)
return null;
-
+
string ret = PtrToString (ptr);
Free (ptr);
return ret;
public static IPAddress PtrToAddress (IntPtr ptr)
{
IPAddress address = null;
-
+
if (ptr != IntPtr.Zero) {
IntPtr buf = Stdlib.malloc (256);
IntPtr addrPtr = avahi_address_snprint (buf, 256, ptr);
--- /dev/null
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=${prefix}/include
+
+Name: avahi-ui
+Description: Avahi Multicast DNS Responder (Common GTK3 UI support)
+Requires: gtk+-3.0 avahi-client avahi-glib
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lavahi-ui-gtk3
+Cflags: -D_REENTRANT -I${includedir}
-# $Id: Makefile.am 1251 2006-08-21 23:31:59Z lennart $
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
$(srcdir)/bssh.cs
$(ASSEMBLY): $(AVAHISOURCES)
- mcs -keyfile:$(top_srcdir)/avahi-sharp/avahi.snk -target:library -out:$@ -debug $(AVAHISOURCES) -pkg:gtk-sharp-2.0 -r:$(top_builddir)/avahi-sharp/avahi-sharp.dll -r:Mono.Posix
+ $(AM_V_GEN)mcs -keyfile:$(top_srcdir)/avahi-sharp/avahi.snk -target:library -out:$@ -debug $(AVAHISOURCES) -pkg:gtk-sharp-2.0 -r:$(top_builddir)/avahi-sharp/avahi-sharp.dll -r:Mono.Posix
$(ASSEMBLY).config: $(ASSEMBLY).config.in
- $(srcdir)/gencfg.sh $(top_builddir)/avahi-common/libavahi-common.la < $< > $@
+ $(AM_V_GEN)$(srcdir)/gencfg.sh $(top_builddir)/avahi-common/libavahi-common.la < $< > $@
bssh.exe: $(srcdir)/bssh.cs $(ASSEMBLY)
- mcs -out:$@ $(srcdir)/bssh.cs -r:./avahi-ui-sharp.dll -r:../avahi-sharp/avahi-sharp.dll -pkg:gtk-sharp-2.0 -r:Mono.Posix
+ $(AM_V_GEN)mcs -out:$@ $(srcdir)/bssh.cs -r:./avahi-ui-sharp.dll -r:../avahi-sharp/avahi-sharp.dll -pkg:gtk-sharp-2.0 -r:Mono.Posix
if HAVE_MONO
if HAVE_DBUS
if HAVE_MONODOC
update-docs: $(ASSEMBLY)
- $(MONODOCER) -assembly:$(ASSEMBLY) -path:en
+ $(AM_V_GEN)$(MONODOCER) -assembly:$(ASSEMBLY) -path:en
avahi-ui-sharp-docs.zip: avahi-ui-sharp-docs.tree
avahi-ui-sharp-docs.tree: $(srcdir)/en/*/*
- $(MDASSEMBLER) --out avahi-ui-sharp-docs --ecma $(srcdir)/en
+ $(AM_V_GEN)$(MDASSEMBLER) --out avahi-ui-sharp-docs --ecma $(srcdir)/en
monodocdir = $(MONODOC_DIR)
monodoc_DATA = avahi-ui-sharp-docs.zip avahi-ui-sharp-docs.tree avahi-ui-sharp-docs.source
[DllImport ("avahi-ui")]
private static extern IntPtr aui_service_dialog_get_service_type (IntPtr dialog);
-
+
[DllImport ("avahi-ui")]
private static extern void aui_service_dialog_set_service_type (IntPtr dialog, IntPtr type);
[DllImport ("avahi-ui")]
private static extern IntPtr aui_service_dialog_get_service_name (IntPtr dialog);
-
+
[DllImport ("avahi-ui")]
private static extern void aui_service_dialog_set_service_name (IntPtr dialog, IntPtr type);
for (int i = 0;;i++) {
if (types[i] != IntPtr.Zero)
break;
-
+
GLib.Marshaller.Free (types[i]);
}
}
get {
ArrayList txtlist = new ArrayList ();
IntPtr txt = aui_service_dialog_get_txt_data (Raw);
-
+
for (IntPtr l = txt; l != IntPtr.Zero; l = avahi_string_list_get_next (l)) {
IntPtr buf = avahi_string_list_get_text (l);
int len = avahi_string_list_get_size (l);
-
+
byte[] txtbuf = new byte[len];
Marshal.Copy (buf, txtbuf, 0, len);
txtlist.Add (txtbuf);
aui_service_dialog_set_address_family (Raw, value);
}
}
-
+
public ServiceDialog (string title, Window parent, params object[] buttonData)
{
Raw = aui_service_dialog_new (title, parent == null ? IntPtr.Zero : parent.Handle,
private static IPAddress PtrToAddress (IntPtr ptr)
{
IPAddress address = null;
-
+
if (ptr != IntPtr.Zero) {
IntPtr buf = Stdlib.malloc (256);
IntPtr addrPtr = avahi_address_snprint (buf, 256, ptr);
public class EntryPoint {
public static void Main () {
- Application.Init ();
-
+ Application.Init ();
+
ServiceDialog dialog = new ServiceDialog ("Choose SSH Server", null,
Stock.Cancel, ResponseType.Cancel,
Stock.Connect, ResponseType.Accept);
Console.WriteLine ("Connecting to {0}:{1}", dialog.Address, dialog.Port);
string user = Environment.UserName;
-
+
foreach (byte[] txtBytes in dialog.TxtData) {
string txt = System.Text.Encoding.UTF8.GetString (txtBytes);
string[] splitTxt = txt.Split(new char[] { '=' }, 2);
-
+
if (splitTxt.Length != 2)
continue;
includedir=${prefix}/include
Name: avahi-ui
-Description: Avahi Multicast DNS Responder (Common GTK UI support)
+Description: Avahi Multicast DNS Responder (Common GTK2 UI support)
Requires: gtk+-2.0 avahi-client avahi-glib
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lavahi-ui
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
desktopdir = $(datadir)/applications
-desktop_DATA =
+desktop_DATA =
desktop_DATA_in = $(desktop_DATA_in_in:.in.in=.in)
desktop_DATA_in_in = bssh.desktop.in.in bvnc.desktop.in.in
EXTRA_DIST = $(desktop_DATA_in_in)
-if HAVE_GTK
+if HAVE_GTK2OR3
AM_CFLAGS += -DGNOMELOCALEDIR=\"$(datadir)/locale\"
if HAVE_DBUS
if HAVE_GLIB
avahiinclude_HEADERS = \
avahi-ui.h
-lib_LTLIBRARIES = \
- libavahi-ui.la
+lib_LTLIBRARIES =
+
+if HAVE_GTK
+lib_LTLIBRARIES += \
+ libavahi-ui.la
+endif
+
+if HAVE_GTK3
+lib_LTLIBRARIES += \
+ libavahi-ui-gtk3.la
+endif
libavahi_ui_la_SOURCES = \
avahi-ui.h avahi-ui.c
libavahi_ui_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GTK20_LIBS)
libavahi_ui_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_UI_VERSION_INFO)
+libavahi_ui_gtk3_la_SOURCES = $(libavahi_ui_la_SOURCES)
+libavahi_ui_gtk3_la_CFLAGS = $(AM_CFLAGS) $(GTK30_CFLAGS)
+libavahi_ui_gtk3_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GTK30_LIBS)
+libavahi_ui_gtk3_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_UI_VERSION_INFO)
+
if HAVE_GDBM
libavahi_ui_la_SOURCES += ../avahi-utils/stdb.h ../avahi-utils/stdb.c
libavahi_ui_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\"
libavahi_ui_la_LIBADD += -lgdbm
+
+libavahi_ui_gtk3_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\"
+libavahi_ui_gtk3_la_LIBADD += -lgdbm
endif
if HAVE_DBM
libavahi_ui_la_SOURCES += ../avahi-utils/stdb.h ../avahi-utils/stdb.c
libavahi_ui_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\"
+
+libavahi_ui_gtk3_la_CFLAGS += -DDATABASE_FILE=\"$(pkglibdir)/service-types.db\"
endif
bin_PROGRAMS = bssh
@INTLTOOL_DESKTOP_RULE@
bssh_SOURCES = bssh.c
+
+if HAVE_GTK3
+bssh_CFLAGS = $(AM_CFLAGS) $(GTK30_CFLAGS)
+bssh_LDADD = $(AM_LDADD) $(GTK30_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la libavahi-ui-gtk3.la
+else
bssh_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS)
bssh_LDADD = $(AM_LDADD) $(GTK20_LIBS) ../avahi-client/libavahi-client.la ../avahi-common/libavahi-common.la libavahi-ui.la
+endif
install-exec-local:
cd $(DESTDIR)/$(bindir) && \
$(LN_S) bssh bshell
bssh.desktop.in: bssh.desktop.in.in
- sed -e 's,@bindir\@,$(bindir),g' $< > $@
+ $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@
bvnc.desktop.in: bvnc.desktop.in.in
- sed -e 's,@bindir\@,$(bindir),g' $< > $@
+ $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@
endif # HAVE_GLIB
endif
-/* $Id$ */
-
/***
This file is part of avahi.
#include <net/if.h>
#include <gtk/gtk.h>
-#include <glib/gi18n.h>
#include <avahi-glib/glib-watch.h>
#include <avahi-client/client.h>
static int get_default_response(GtkDialog *dlg) {
gint ret = GTK_RESPONSE_NONE;
- if (GTK_WINDOW(dlg)->default_widget)
+ if (gtk_window_get_default_widget(GTK_WINDOW(dlg)))
/* Use the response of the default widget, if possible */
- ret = gtk_dialog_get_response_for_widget(dlg, GTK_WINDOW(dlg)->default_widget);
+ ret = gtk_dialog_get_response_for_widget(dlg, gtk_window_get_default_widget(GTK_WINDOW(dlg)));
if (ret == GTK_RESPONSE_NONE) {
/* Fall back to finding the first positive response */
GList *children, *t;
gint bad = GTK_RESPONSE_NONE;
- t = children = gtk_container_get_children(GTK_CONTAINER(dlg->action_area));
+ t = children = gtk_container_get_children(GTK_CONTAINER(gtk_dialog_get_action_area(dlg)));
while (t) {
GtkWidget *child = t->data;
gtk_widget_set_sensitive(GTK_WIDGET(dialog), FALSE);
cursor = gdk_cursor_new(GDK_WATCH);
- gdk_window_set_cursor(GTK_WIDGET(dialog)->window, cursor);
+ gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(dialog)), cursor);
gdk_cursor_unref(cursor);
if (!(d->priv->resolver = avahi_service_resolver_new(
vbox = gtk_vbox_new(FALSE, 8);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(p->domain_dialog)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(p->domain_dialog))), vbox, TRUE, TRUE, 0);
p->domain_entry = gtk_entry_new();
gtk_entry_set_max_length(GTK_ENTRY(p->domain_entry), AVAHI_DOMAIN_NAME_MAX);
vbox = gtk_vbox_new(FALSE, 8);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(d))), vbox, TRUE, TRUE, 0);
p->domain_label = gtk_label_new(_("Initializing..."));
gtk_label_set_ellipsize(GTK_LABEL(p->domain_label), TRUE);
p->domain_button = gtk_button_new_with_mnemonic(_("_Domain..."));
gtk_button_set_image(GTK_BUTTON(p->domain_button), gtk_image_new_from_stock(GTK_STOCK_NETWORK, GTK_ICON_SIZE_BUTTON));
g_signal_connect(p->domain_button, "clicked", G_CALLBACK(domain_button_clicked), d);
- gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), p->domain_button, FALSE, TRUE, 0);
- gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(GTK_DIALOG(d)->action_area), p->domain_button, TRUE);
+ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(d))), p->domain_button, FALSE, TRUE, 0);
+ gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(gtk_dialog_get_action_area(GTK_DIALOG(d))), p->domain_button, TRUE);
gtk_widget_show(p->domain_button);
gtk_dialog_set_default_response(GTK_DIALOG(d), GTK_RESPONSE_ACCEPT);
#ifndef fooavahiuihfoo
#define fooavahiuihfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
#include <getopt.h>
#include <gtk/gtk.h>
-#include <glib/gi18n.h>
#include <avahi-client/client.h>
#include <avahi-common/strlst.h>
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
} Command;
typedef struct Config {
- int verbose, no_fail;
+ int verbose, no_fail, no_reverse;
Command command;
char *name, *stype, *domain, *host;
uint16_t port;
if (config->command == COMMAND_PUBLISH_ADDRESS) {
- if (avahi_entry_group_add_address(entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, config->name, &config->address) < 0) {
+ if (avahi_entry_group_add_address(entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, config->no_reverse ? AVAHI_PUBLISH_NO_REVERSE : 0, config->name, &config->address) < 0) {
fprintf(stderr, _("Failed to add address: %s\n"), avahi_strerror(avahi_client_errno(client)));
return -1;
}
" -d --domain=DOMAIN Domain to publish service in\n"
" -H --host=DOMAIN Host where service resides\n"
" --subtype=SUBTYPE An additional subtype to register this service with\n"
+ " -R --no-reverse Do not publish reverse entry with address\n"
" -f --no-fail Don't fail if the daemon is not available\n"),
argv0, strstr(argv0, "service") ? "[-s]" : "-s",
argv0, strstr(argv0, "address") ? "[-a]" : "-a");
{ "domain", required_argument, NULL, 'd' },
{ "host", required_argument, NULL, 'H' },
{ "subtype", required_argument, NULL, ARG_SUBTYPE},
+ { "no-reverse", no_argument, NULL, 'R' },
{ "no-fail", no_argument, NULL, 'f' },
{ NULL, 0, NULL, 0 }
};
assert(c);
c->command = strstr(argv0, "address") ? COMMAND_PUBLISH_ADDRESS : (strstr(argv0, "service") ? COMMAND_PUBLISH_SERVICE : COMMAND_UNSPEC);
- c->verbose = c->no_fail = 0;
+ c->verbose = c->no_fail = c->no_reverse = 0;
c->host = c->name = c->domain = c->stype = NULL;
c->port = 0;
c->txt = c->subtypes = NULL;
- while ((o = getopt_long(argc, argv, "hVsavd:H:f", long_options, NULL)) >= 0) {
+ while ((o = getopt_long(argc, argv, "hVsavRd:H:f", long_options, NULL)) >= 0) {
switch(o) {
case 'h':
case 'v':
c->verbose = 1;
break;
+ case 'R':
+ c->no_reverse = 1;
+ break;
case 'd':
avahi_free(c->domain);
c->domain = avahi_strdup(optarg);
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
static int set_nonblock(int fd) {
int n;
-
+
assert(fd >= 0);
if ((n = fcntl(fd, F_GETFL)) < 0)
static void watch_callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) {
int s;
ssize_t l;
-
+
assert(w);
assert(fd == pipe_fds[0]);
assert(event == AVAHI_WATCH_IN);
int sigint_install(AvahiSimplePoll *spoll) {
struct sigaction sa;
const AvahiPoll *p;
-
+
assert(spoll);
assert(!simple_poll);
assert(pipe_fds[0] == -1 && pipe_fds[1] == -1);
close_pipe_fds();
return -1;
}
-
+
if (sigaction(SIGTERM, &sa, &old_sigterm_sa) < 0) {
sigaction(SIGINT, &old_sigint_sa, NULL);
fprintf(stderr, "sigaction() failed: %s\n", strerror(errno));
p = avahi_simple_poll_get(spoll);
watch = p->watch_new(p, pipe_fds[0], AVAHI_WATCH_IN, watch_callback, NULL);
assert(watch);
-
+
simple_poll = spoll;
return 0;
}
void sigint_uninstall(void) {
-
+
if (!simple_poll)
return;
#ifndef foosigchfoo
#define foosigchfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
data.dptr = NULL;
data.dsize = 0;
-
+
if ((loc = setlocale(LC_MESSAGES, NULL))) {
char k[256];
-
+
snprintf(k, sizeof(k), "%s[%s]", name, loc);
key.dptr = k;
key.dsize = strlen(k);
if (!data.dptr) {
char l[32], *e;
snprintf(l, sizeof(l), "%s", loc);
-
+
if ((e = strchr(l, '@'))) {
*e = 0;
snprintf(k, sizeof(k), "%s[%s]", name, l);
avahi_free(buffer);
buffer = avahi_strndup(data.dptr, data.dsize);
free(data.dptr);
-
+
return buffer;
-
+
fail:
return name;
char *stdb_getent(void) {
datum key;
-
+
if (init() < 0)
return NULL;
for (;;) {
-
+
if (!enum_key) {
#ifdef HAVE_GDBM
key = gdbm_firstkey(gdbm_file);
} else {
key.dptr = enum_key;
key.dsize = strlen(enum_key);
-
+
#ifdef HAVE_GDBM
key = gdbm_nextkey(gdbm_file, key);
#endif
avahi_free(enum_key);
enum_key = NULL;
-
+
if (!key.dptr)
return NULL;
-
+
enum_key = avahi_strndup(key.dptr, key.dsize);
free(key.dptr);
#ifndef foostdbhfoo
#define foostdbhfoo
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#!/bin/sh
-# $Id$
# This file is part of avahi.
#
;;
esac
-CFLAGS="$CFLAGS -g -O0" exec ./autogen.sh $FLAGS "$@"
+CFLAGS="$CFLAGS -g -O0" exec ./autogen.sh $FLAGS "$@" --enable-qt3=no
+intltool.m4
ChangeLog
gettext.m4
iconv.m4
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
--- /dev/null
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+ AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+ AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+ dnl enable/disable introspection
+ m4_if([$2], [require],
+ [dnl
+ enable_introspection=yes
+ ],[dnl
+ AC_ARG_ENABLE(introspection,
+ AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+ [Enable introspection for this build]),,
+ [enable_introspection=auto])
+ ])dnl
+
+ AC_MSG_CHECKING([for gobject-introspection])
+
+ dnl presence/version checking
+ AS_CASE([$enable_introspection],
+ [no], [dnl
+ found_introspection="no (disabled, use --enable-introspection to enable)"
+ ],dnl
+ [yes],[dnl
+ PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+ AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+ found_introspection=yes,
+ AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+ ],dnl
+ [auto],[dnl
+ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+ ],dnl
+ [dnl
+ AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+ ])dnl
+
+ AC_MSG_RESULT([$found_introspection])
+
+ INTROSPECTION_SCANNER=
+ INTROSPECTION_COMPILER=
+ INTROSPECTION_GENERATE=
+ INTROSPECTION_GIRDIR=
+ INTROSPECTION_TYPELIBDIR=
+ if test "x$found_introspection" = "xyes"; then
+ INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+ INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+ INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+ INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+ INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+ INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+ INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+ INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+ fi
+ AC_SUBST(INTROSPECTION_SCANNER)
+ AC_SUBST(INTROSPECTION_COMPILER)
+ AC_SUBST(INTROSPECTION_GENERATE)
+ AC_SUBST(INTROSPECTION_GIRDIR)
+ AC_SUBST(INTROSPECTION_TYPELIBDIR)
+ AC_SUBST(INTROSPECTION_CFLAGS)
+ AC_SUBST(INTROSPECTION_LIBS)
+ AC_SUBST(INTROSPECTION_MAKEFILE)
+
+ AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-AC_PREREQ(2.57)
+AC_PREREQ(2.63)
AC_INIT([avahi],[0.6.25],[avahi (at) lists (dot) freedesktop (dot) org])
AC_CONFIG_SRCDIR([avahi-core/server.c])
+AC_CONFIG_MACRO_DIR([common])
AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([foreign 1.9 -Wall])
+AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax])
AC_SUBST(PACKAGE_URL, [http://avahi.org/])
AC_SUBST(LIBAVAHI_COMPAT_HOWL_VERSION_INFO, [0:0:0])
AC_SUBST(HOWL_COMPAT_VERSION, [0.9.8])
-if type -p stow > /dev/null && test -d /usr/local/stow ; then
- AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
- ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
-fi
+AC_CANONICAL_HOST
+
+AM_SILENT_RULES([yes])
+
+AC_CHECK_PROG([STOW], [stow], [yes], [no])
+
+AS_IF([test "x$STOW" = "xyes" && test -d /usr/local/stow], [
+ AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
+ ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
+])
# Checks for programs.
AC_PROG_CC
+AC_PROG_CC_C99
AC_PROG_CXX
-AC_GNU_SOURCE
+AM_PROG_CC_C_O
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_GCC_TRADITIONAL
-AM_PROG_CC_C_O
-
# -fstack-protector
AC_ARG_ENABLE([stack-protector],
[AS_HELP_STRING([--disable-stack-protector],
, [], [
#include <sys/types.h>
#include <sys/socket.h>
+#include <net/if_dl.h>
])
AM_CONDITIONAL(HAVE_PF_ROUTE, [ test x"$HAVE_PF_ROUTE" = xyes ])
# If using GCC specify some additional parameters
if test "x$GCC" = "xyes" ; then
- DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Winline"
+ DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -fdiagnostics-show-option -Wno-cast-qual -fno-strict-aliasing"
if test "x$HAVE_NETLINK" = "xyes" ; then
# Test whether rtnetlink.h can be included when compiled with -std=c99
# Solaris stuff
AC_SEARCH_LIBS([inet_ntop],[nsl])
AC_SEARCH_LIBS([recv],[socket])
- AC_CHECK_DECL([CMSG_SPACE],,CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__")
+ AC_CHECK_DECL([CMSG_SPACE],,CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__", [[#include <sys/socket.h>]])
# Checks for library functions.
AC_FUNC_MEMCMP
avahilocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(avahilocaledir)
-
# Check for pkg-config manually first, as if its not installed the
# PKG_PROG_PKG_CONFIG macro won't be defined.
AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
fi
AM_CONDITIONAL(HAVE_GOBJECT, test "x$HAVE_GOBJECT" = "xyes")
+#
+# Introspection support.
+#
+GOBJECT_INTROSPECTION_CHECK([0.6.7])
+
#
# Check for Qt 3
#
AM_CONDITIONAL(HAVE_QT4, test "x$HAVE_QT4" = "xyes")
#
-# Check for GTK+
+# Check for GTK+ 2.0
#
AC_ARG_ENABLE(gtk,
- AS_HELP_STRING([--disable-gtk],[Disable use of GTK+]),
+ AS_HELP_STRING([--disable-gtk],[Disable use of GTK+ 2]),
[case "${enableval}" in
yes) HAVE_GTK=yes ;;
no) HAVE_GTK=no ;;
if test "x$HAVE_GTK" = "xyes" ; then
# Check for GTK 2.0
- PKG_CHECK_MODULES(GTK20, [ gtk+-2.0 >= 2.4.0 ])
+ PKG_CHECK_MODULES(GTK20, [ gtk+-2.0 >= 2.14.0 ])
AC_SUBST(GTK20_CFLAGS)
AC_SUBST(GTK20_LIBS)
-
- # Check for GLADE 2.0
- PKG_CHECK_MODULES(GLADE20, [ libglade-2.0 >= 2.4.0 ])
- AC_SUBST(GLADE20_CFLAGS)
- AC_SUBST(GLADE20_LIBS)
fi
AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
+#
+# Check for GTK+ 3.0
+#
+AC_ARG_ENABLE(gtk3,
+ AS_HELP_STRING([--disable-gtk3],[Disable use of GTK+ 3]),
+ [case "${enableval}" in
+ yes) HAVE_GTK3=yes ;;
+ no) HAVE_GTK3=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtk3) ;;
+ esac],
+ [HAVE_GTK3=yes])
+
+if test "x$HAVE_GTK3" = "xyes" ; then
+ # Check for GTK 3.0
+ PKG_CHECK_MODULES(GTK30, [ gtk+-3.0 ])
+ AC_SUBST(GTK30_CFLAGS)
+ AC_SUBST(GTK30_LIBS)
+fi
+AM_CONDITIONAL(HAVE_GTK3, test "x$HAVE_GTK3" = "xyes")
+
+AM_CONDITIONAL(HAVE_GTK2OR3, test "x$HAVE_GTK3" = "xyes" -o "x$HAVE_GTK2" = "xyes" )
+
#
# D-Bus
#
AM_CONDITIONAL([ENABLE_COMPAT_HOWL], [test "x$ENABLE_COMPAT_HOWL" = "xyes"])
+#
+# systemd
+#
+AC_ARG_WITH([systemdsystemunitdir],
+ AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
+ [],
+ [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
+AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir"])
# ==========================================================================
AC_CONFIG_FILES([
CFLAGS: ${CFLAGS}
Enable GLIB: ${HAVE_GLIB}
Enable GLIB GObject: ${HAVE_GOBJECT}
- Enable GTK: ${HAVE_GTK}
+ Enable GObject Introspection: ${found_introspection}
+ Enable GTK 2.0: ${HAVE_GTK}
+ Enable GTK 3.0: ${HAVE_GTK3}
Enable D-Bus: ${HAVE_DBUS}
With XML: ${with_xml}
Enable GDBM: ${HAVE_GDBM}
Enable chroot(): ${enable_chroot}
Enable Linux inotify: ${have_inotify}
Enable stack-smashing protection: ${enable_ssp}
+ systemd unit directory: ${with_systemdsystemunitdir}
"
BUILD_DAEMON="no (You need libdaemon and expat/bsdxml!)"
ENABLE_AUTOIPD="no (You need libdaemon!)"
fi
+HAVE_GTK2OR3=no
+if test "x$HAVE_GTK" = "xyes" -o "x$HAVE_GTK3" = "xyes" ; then
+ HAVE_GTK2OR3=yes
+fi
+
BUILD_UI="no"
-if test "x$HAVE_GTK" = "xyes" -a "x$BUILD_CLIENT" = "xyes" ; then
+if test "x$HAVE_GTK2OR3" = "xyes" -a "x$BUILD_CLIENT" = "xyes" ; then
BUILD_UI="yes"
fi
Building avahi-python: ${BUILD_PYTHON}
Building libavahi-glib: ${HAVE_GLIB}
Building libavahi-gobject: ${BUILD_GOBJECT}
- Building avahi-discover-standalone: ${HAVE_GTK}
+ Building avahi-discover-standalone: ${HAVE_GTK2OR3}
Building libavahi-qt3: ${HAVE_QT3}
Building libavahi-qt4: ${HAVE_QT4}
Building avahi-sharp: ${HAVE_MONO}
-*-text-*-
-
A terse (and incomplete) list of API changes between 0.5.2 and 0.6:
* Most browsing and registration functions and their callbacks gained
* There's now a client side AvahiRecordBrowser, and
avahi_entry_group_add_record().
-
-$Id$
$(includedir)/dns_sd.h
-- Lennart
-
-$Id$
-$Id$
-
* NOTE *
This file used to contain an overview of the DBUS API for Avahi, however
since it was no longer up to date you should now read the XML-formatted DBUS
Please comply with the following rules when hacking on Avahi:
- * When you add a new textual file to the repository please enable SVN
- keyword expansion for it:
-
- svn ps svn:keywords Id foo.c
+ * Before commiting check with "git st" that all built files are ignored
+ by git. To change the list of ignored files use
- * Before commiting check with "svn st" that all built files are ignored
- by svn. To change the list of ignored files use
-
- svn pe svn:ignore .
+ $VISUAL .gitignore
This is similar to the ".cvsignore" file in CVS times.
* Don't forget to add the autoconf config.h inclusion to all C source files:
-
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
For Makefile.am, python and shell code:
<snip>
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
For C source code:
<snip>
-/* $Id$ */
-
/***
This file is part of avahi.
USA.
***/
</snip>
-
-
-$Id$
If you plan to use avahi-autoipd you have to create the user/group
"avahi-autoipd" much the same way as "avahi".
-
-$Id$
abort() in case of OOM. The default allocator used by Avahi does this.
Eventually we will improve Avahi to deal with these things better.
-
-$Id$
* Fix potential endless loop in dns label unpacking code (Closes: #84)
* Fix bogus assertion in client-publish-service.c example
* Mild fix to some doxygen docs for avahi-common/address.h
- * Fix passing in custom priviledged group (previously ignored setting)
+ * Fix passing in custom privileged group (previously ignored setting)
(Closes: #85)
This release is backwards compatible with Avahi 0.6.x with x < 16.
Windows under the name APIPA. While it is not the first implemenatation of
this technology for Free operating systems it is clearly the most powerful
and hopefully even the most secure. (Because it chroot()s and drops
- priviliges and suchlike) For more information, especially about packaging
+ privileges and suchlike) For more information, especially about packaging
this new tool for distributions, please make sure to read:
http://avahi.org/wiki/AvahiAutoipd
and of course the man page included in the tarball. For the rationale for
Cheers,
The Avahi Team
-
-$Id$
struct sockaddr_storage sa;
socklen_t salen;
uint16_t port;
-
+
if ((s = socket(PF_INET6, SOCK_STREAM, 0)) < 0) {
if (errno == EAFNOSUPPORT)
s = socket(PF_INET, SOCK_STREAM, 0);
-
+
if (s < 0) {
perror("socket()");
return 1;
/* ... hic sunt leones ... */
sleep(60);
-
+
return 0;
}
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
case AVAHI_RESOLVER_FOUND: {
char a[AVAHI_ADDRESS_STR_MAX], *t;
-
+
fprintf(stderr, "Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
-
+
avahi_address_snprint(a, sizeof(a), address);
t = avahi_string_list_to_string(txt);
fprintf(stderr,
!!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA),
!!(flags & AVAHI_LOOKUP_RESULT_MULTICAST),
!!(flags & AVAHI_LOOKUP_RESULT_CACHED));
-
+
avahi_free(t);
}
}
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiClient *c = userdata;
assert(b);
switch (event) {
case AVAHI_BROWSER_FAILURE:
-
+
fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
avahi_simple_poll_quit(simple_poll);
return;
if (!(avahi_service_resolver_new(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c)))
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(c)));
-
+
break;
case AVAHI_BROWSER_REMOVE:
fprintf(stderr, "Failed to create client: %s\n", avahi_strerror(error));
goto fail;
}
-
+
/* Create the service browser */
if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, browse_callback, client))) {
fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client)));
/* Run the main loop */
avahi_simple_poll_loop(simple_poll);
-
+
ret = 0;
-
+
fail:
-
+
/* Cleanup things */
if (sb)
avahi_service_browser_free(sb);
-
+
if (client)
avahi_client_free(client);
-/* $Id$ */
-
/***
This file is part of avahi.
-/* $Id$ */
-
/* PLEASE NOTE *
* This file demonstrates how to use Avahi's core API, this is
* the embeddable mDNS stack for embedded applications.
* End user applications should *not* use this API and should use
* the D-Bus or C APIs, please see
* client-browse-services.c and glib-integration.c
- *
+ *
* I repeat, you probably do *not* want to use this example.
*/
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AvahiStringList *txt,
AvahiLookupResultFlags flags,
AVAHI_GCC_UNUSED void* userdata) {
-
+
assert(r);
/* Called whenever a service has been resolved successfully or timed out */
case AVAHI_RESOLVER_FOUND: {
char a[AVAHI_ADDRESS_STR_MAX], *t;
-
+
fprintf(stderr, "(Resolver) Service '%s' of type '%s' in domain '%s':\n", name, type, domain);
-
+
avahi_address_snprint(a, sizeof(a), address);
t = avahi_string_list_to_string(txt);
fprintf(stderr,
avahi_free(t);
}
}
-
+
avahi_s_service_resolver_free(r);
}
const char *domain,
AVAHI_GCC_UNUSED AvahiLookupResultFlags flags,
void* userdata) {
-
+
AvahiServer *s = userdata;
assert(b);
switch (event) {
case AVAHI_BROWSER_FAILURE:
-
+
fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_server_errno(server)));
avahi_simple_poll_quit(simple_poll);
return;
function we free it. If the server is terminated before
the callback function is called the server will free
the resolver for us. */
-
+
if (!(avahi_s_service_resolver_new(s, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, s)))
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_server_errno(s)));
-
+
break;
case AVAHI_BROWSER_REMOVE:
avahi_address_parse("192.168.50.1", AVAHI_PROTO_UNSPEC, &config.wide_area_servers[0]);
config.n_wide_area_servers = 1;
config.enable_wide_area = 1;
-
+
/* Allocate a new server */
server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, NULL, NULL, &error);
fprintf(stderr, "Failed to create server: %s\n", avahi_strerror(error));
goto fail;
}
-
+
/* Create the service browser */
if (!(sb = avahi_s_service_browser_new(server, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_http._tcp", NULL, 0, browse_callback, server))) {
fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_server_errno(server)));
goto fail;
}
-
+
/* Run the main loop */
avahi_simple_poll_loop(simple_poll);
-
+
ret = 0;
-
+
fail:
-
+
/* Cleanup things */
if (sb)
avahi_s_service_browser_free(sb);
-
+
if (server)
avahi_server_free(server);
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
/* Called whenever the entry group state changes */
switch (state) {
-
+
case AVAHI_ENTRY_GROUP_ESTABLISHED:
/* The entry group has been established successfully */
case AVAHI_ENTRY_GROUP_COLLISION: {
char *n;
-
+
/* A service name collision happened. Let's pick a new name */
n = avahi_alternative_service_name(name);
avahi_free(name);
name = n;
-
+
fprintf(stderr, "Service name collision, renaming service to '%s'\n", name);
-
+
/* And recreate the services */
create_services(s);
break;
}
-
+
case AVAHI_ENTRY_GROUP_FAILURE :
fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_server_errno(s)));
-
+
/* Some kind of failure happened while we were registering our services */
avahi_simple_poll_quit(simple_poll);
break;
fprintf(stderr, "avahi_entry_group_new() failed: %s\n", avahi_strerror(avahi_server_errno(s)));
goto fail;
}
-
+
fprintf(stderr, "Adding service '%s'\n", name);
/* Create some random TXT data */
case AVAHI_SERVER_RUNNING:
/* The serve has startup successfully and registered its host
* name on the network, so it's time to create our services */
-
+
if (!group)
create_services(s);
case AVAHI_SERVER_COLLISION: {
char *n;
int r;
-
+
/* A host name collision happened. Let's pick a new name for the server */
n = avahi_alternative_host_name(avahi_server_get_host_name(s));
fprintf(stderr, "Host name collision, retrying with '%s'\n", n);
r = avahi_server_set_host_name(s, n);
avahi_free(n);
-
+
if (r < 0) {
fprintf(stderr, "Failed to set new host name: %s\n", avahi_strerror(r));
-
+
avahi_simple_poll_quit(simple_poll);
return;
}
/* Fall through */
case AVAHI_SERVER_REGISTERING:
-
+
/* Let's drop our registered services. When the server is back
* in AVAHI_SERVER_RUNNING state we will register them
* again with the new host name. */
break;
case AVAHI_SERVER_FAILURE:
-
+
/* Terminate on failure */
-
+
fprintf(stderr, "Server failure: %s\n", avahi_strerror(avahi_server_errno(s)));
avahi_simple_poll_quit(simple_poll);
break;
AvahiServer *server = NULL;
int error;
int ret = 1;
-
+
/* Initialize the pseudo-RNG */
srand(time(NULL));
fprintf(stderr, "Failed to create simple poll object.\n");
goto fail;
}
-
+
name = avahi_strdup("MegaPrinter");
/* Let's set the host name for this server. */
avahi_server_config_init(&config);
config.host_name = avahi_strdup("gurkiman");
config.publish_workstation = 0;
-
+
/* Allocate a new server */
server = avahi_server_new(avahi_simple_poll_get(simple_poll), &config, server_callback, NULL, &error);
/* Run the main loop */
avahi_simple_poll_loop(simple_poll);
-
+
ret = 0;
-
+
fail:
-
+
/* Cleanup things */
if (server)
avahi_simple_poll_free(simple_poll);
avahi_free(name);
-
+
return ret;
}
-/* $Id$ */
-
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
GMainLoop *loop = userdata;
g_message ("GLIB API Timeout reached, quitting main loop!");
-
+
/* Quit the application */
g_main_loop_quit (loop);
goto fail;
}
-
+
/* Make a call to get the version string from the daemon */
version = avahi_client_get_version_string (client);
goto fail;
}
-
+
g_message ("Avahi Server Version: %s", version);
/* Start the GLIB Main Loop */
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-SUBDIRS =
+SUBDIRS =
if TARGET_LFS
SUBDIRS += lfs
-# $Id: Makefile.am 267 2005-08-08 10:19:22Z lennart $
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/bash
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/bash
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
org.freedesktop.avahi-daemon.plist: org.freedesktop.avahi-daemon.plist.in
sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
- chmod +x $@
org.freedesktop.avahi-dnsconfd.plist: org.freedesktop.avahi-dnsconfd.plist.in
sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
- chmod +x $@
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/sh
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/sh
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
CLEANFILES = avahi-daemon avahi-dnsconfd
avahi-daemon: avahi-daemon.in
- sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
+ $(AM_V_GEN)sed \
+ -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@localstatedir\@,$(localstatedir),g' \
+ $< > $@ && \
chmod +x $@
avahi-dnsconfd: avahi-dnsconfd.in
- sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
+ $(AM_V_GEN)sed \
+ -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@localstatedir\@,$(localstatedir),g' \
+ $< > $@ && \
chmod +x $@
-#! /bin/sh
+#!/bin/sh
#
-# avahi-daemon: Starts the Avahi Daemon
+# avahi-daemon: Starts the Avahi Daemon
#
-# chkconfig: 345 24 02
+# chkconfig: 345 24 02
# description: This is a daemon which runs on client machines to perform \
# Zeroconf service discovery on a network. avahi-daemon must be \
# running on systems that use Avahi for service discovery. \
# Avahi-daemon should not be running otherwise.
# processname: avahi-daemon
-# config:
+# pidfile: @localstatedir@/run/avahi-daemon/pid
AVAHI_BIN=@sbindir@/avahi-daemon
+AVAHI_OPTS="-D"
if [ "$1" = 'status' ]; then
test -x $AVAHI_BIN || exit 4
test -x $AVAHI_BIN || exit 5
fi
-OTHER_AVAHI_OPTS=""
-
# Source function library.
. /etc/init.d/functions
. /etc/sysconfig/network
-LOCKFILE=/var/lock/subsys/avahi-daemon
+LOCKFILE=@localstatedir@/lock/subsys/avahi-daemon
+PIDFILE=@localstatedir@/run/avahi-daemon/pid
+RETVAL=0
base=${0##*/}
if [ -s /etc/localtime ]; then
cp -fp /etc/localtime /etc/avahi/etc >/dev/null 2>&1
fi;
- $AVAHI_BIN -D
- RETVAL=$?
- if [ $RETVAL = 0 ]; then
- touch $LOCKFILE
- success $"$base startup"
- else
- failure $"$base startup"
- fi
- echo
+ daemon --pidfile=${PIDFILE} $AVAHI_BIN $AVAHI_OPTS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch ${LOCKFILE}
return $RETVAL
}
stop() {
echo -n $"Shutting down Avahi daemon: "
- $AVAHI_BIN -k
- RETVAL=$?
- [ $RETVAL = 0 ] && success $"$base shutdown" || failure $"$base shutdown"
- rm -f $LOCKFILE
- echo
+ killproc -p ${PIDFILE} $AVAHI_BIN
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
+ echo
return $RETVAL
}
reload() {
echo -n $"Reloading Avahi daemon... "
- $AVAHI_BIN -r
+ killproc -p ${PIDFILE} $AVAHI_BIN -HUP
RETVAL=$?
- [ $RETVAL = 0 ] && success $"$base reload" || failure $"$base reload"
echo
return $RETVAL
}
stop
;;
status)
- $AVAHI_BIN -c
- RETVAL=$?
- [ $RETVAL = 0 ] && echo $"Avahi daemon is running" || echo $"Avahi daemon is not running"
+ status -p ${PIDFILE} $AVAHI_BIN
+ RETVAL=$?
;;
restart)
restart
-#! /bin/sh
+#!/bin/sh
#
-# avahi-dnsconfd: Starts the Avahi dns configuration daemon
+# avahi-dnsconfd: Starts the Avahi dns configuration daemon
#
-# chkconfig: - 96 02
+# chkconfig: - 96 02
# description: avahi-dnsconfd connects to a running avahi-daemon and runs the script \
-# /etc/avahi/dnsconf.action for each unicast DNS server that is announced \
-# on the local LAN. This is useful for configuring unicast DNS servers in \
-# a DHCP-like fashion with mDNS.
+# /etc/avahi/dnsconf.action for each unicast DNS server that is announced \
+# on the local LAN. This is useful for configuring unicast DNS servers in \
+# a DHCP-like fashion with mDNS.
# processname: avahi-dnsconfd
-# config:
+# pidfile: @localstatedir@/run/avahi-dnsconfd.pid
AVAHI_BIN=@sbindir@/avahi-dnsconfd
+AVAHI_OPTS="-D"
if [ "$1" = 'status' ]; then
test -x $AVAHI_BIN || exit 4
test -x $AVAHI_BIN || exit 5
fi
-OTHER_AVAHI_OPTS=""
-
# Source function library.
. /etc/init.d/functions
. /etc/sysconfig/network
-LOCKFILE=/var/lock/subsys/avahi-dnsconfd
+LOCKFILE=@localstatedir@/lock/subsys/avahi-dnsconfd
+PIDFILE=@localstatedir@/run/avahi-dnsconfd.pid
+RETVAL=0
base=${0##*/}
[ ${NETWORKING} = "no" ] && exit 1
echo -n $"Starting Avahi DNS daemon... "
- $AVAHI_BIN -D
- RETVAL=$?
- if [ $RETVAL = 0 ]; then
- touch $LOCKFILE
- success $"$base startup"
- else
- failure $"$base startup"
- fi
- echo
- return $RETVAL
+ daemon --pidfile=${PIDFILE} $AVAHI_BIN $AVAHI_OPTS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch ${LOCKFILE}
+ return $RETVAL
}
stop() {
echo -n $"Shutting down Avahi DNS daemon: "
- $AVAHI_BIN -k
- RETVAL=$?
- [ $RETVAL = 0 ] && success $"$base shutdown" || failure $"$base shutdown"
- rm -f $LOCKFILE
- echo
- return $RETVAL
+ killproc -p ${PIDFILE} $AVAHI_BIN
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
+ echo
+ return $RETVAL
}
reload() {
echo -n $"Reloading Avahi DNS daemon... "
- $AVAHI_BIN -r
- RETVAL=$?
- [ $RETVAL = 0 ] && success $"$base startup" || failure $"$base startup"
- echo
- return $RETVAL
+ killproc -p ${PIDFILE} $AVAHI_BIN -HUP
+ RETVAL=$?
+ echo
+ return $RETVAL
}
restart() {
stop
;;
status)
- $AVAHI_BIN -c
+ status -p ${PIDFILE} $AVAHI_BIN
RETVAL=$?
- [ $RETVAL = 0 ] && echo $"Avahi DNS daemon is running" || echo $"Avahi DNS daemon is not running"
;;
restart)
restart
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
avahi-dnsconfd
avahi-daemon: avahi-daemon.in
-
+
sed -e 's,@sbindir\@,$(sbindir),g; $(NO_DBUS_DEPENDENCY)' $< > $@
chmod +x $@
#!/sbin/runscript
-# $Id$
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#!/sbin/runscript
-# $Id$
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id: Makefile.am 838 2005-10-22 21:23:02Z lennart $
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
. /etc/sysconfig/network
# Check that networking is configured.
-[ ${NETWORKING} = "no" ] && exit 0
+[ "${NETWORKING}" = "no" ] && exit 0
start() {
echo -n $"Starting Avahi daemon: "
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/bash
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
#!/bin/bash
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
;;
status)
echo -n "Checking for Avahi daemon: "
- $AVAHI_BIN -c
+ $AVAHI_BIN -c || _rc_status=3
rc_status -v
;;
*)
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
endif
endif
-avahi-browse.1.xml: avahi-browse.1.xml.in Makefile
- sed -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-publish.1.xml: avahi-publish.1.xml.in Makefile
- sed -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-resolve.1.xml: avahi-resolve.1.xml.in Makefile
- sed -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-set-host-name.1.xml: avahi-set-host-name.1.xml.in Makefile
- sed -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-daemon.8.xml: avahi-daemon.8.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@servicedir\@,$(servicedir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-discover.1.xml: avahi-discover.1.xml.in Makefile
- sed -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-bookmarks.1.xml: avahi-bookmarks.1.xml.in Makefile
- sed -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-dnsconfd.8.xml: avahi-dnsconfd.8.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-daemon.conf.5.xml: avahi-daemon.conf.5.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-dnsconfd.action.8.xml: avahi-dnsconfd.action.8.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi.service.5.xml: avahi.service.5.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
+%.xml: %.xml.in Makefile
+ $(AM_V_GEN) sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
-e 's,@servicedir\@,$(servicedir),g' \
-e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi.hosts.5.xml: avahi.hosts.5.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-autoipd.action.8.xml: avahi-autoipd.action.8.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-avahi-autoipd.8.xml: avahi-autoipd.8.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
-
-bssh.1.xml: bssh.1.xml.in Makefile
- sed -e 's,@pkgsysconfdir\@,$(pkgsysconfdir),g' \
- -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \
- -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
+ -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' $< > $@
if USE_XMLTOMAN
CLEANFILES += $(man_MANS)
-avahi-browse.1: avahi-browse.1.xml Makefile
- xmltoman $< > $@
-
-avahi-publish.1: avahi-publish.1.xml Makefile
- xmltoman $< > $@
-
-avahi-resolve.1: avahi-resolve.1.xml Makefile
- xmltoman $< > $@
-
-avahi-set-host-name.1: avahi-set-host-name.1.xml Makefile
- xmltoman $< > $@
-
-avahi-daemon.8: avahi-daemon.8.xml Makefile
- xmltoman $< > $@
-
-avahi-discover.1: avahi-discover.1.xml Makefile
- xmltoman $< > $@
-
-avahi-bookmarks.1: avahi-bookmarks.1.xml Makefile
- xmltoman $< > $@
-
-avahi-dnsconfd.8: avahi-dnsconfd.8.xml Makefile
- xmltoman $< > $@
-
-avahi-daemon.conf.5: avahi-daemon.conf.5.xml Makefile
- xmltoman $< > $@
-
-avahi-dnsconfd.action.8: avahi-dnsconfd.action.8.xml Makefile
- xmltoman $< > $@
-
-avahi.service.5: avahi.service.5.xml Makefile
- xmltoman $< > $@
-
-avahi.hosts.5: avahi.hosts.5.xml Makefile
- xmltoman $< > $@
-
-avahi-autoipd.action.8: avahi-autoipd.action.8.xml Makefile
- xmltoman $< > $@
+%.1: %.1.xml Makefile
+ $(AM_V_GEN)xmltoman $< > $@
-avahi-autoipd.8: avahi-autoipd.8.xml Makefile
- xmltoman $< > $@
+%.5: %.5.xml Makefile
+ $(AM_V_GEN)xmltoman $< > $@
-bssh.1: bssh.1.xml Makefile
- xmltoman $< > $@
+%.8: %.8.xml Makefile
+ $(AM_V_GEN)xmltoman $< > $@
xmllint: $(noinst_DATA)
for f in $(noinst_DATA) ; do \
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<cmd>avahi-autoipd <opt>--refresh</opt> <arg>interface</arg></cmd>
<cmd>avahi-autoipd <opt>--check</opt> <arg>interface</arg></cmd>
</synopsis>
-
+
<description>
<p>avahi-autoipd implements IPv4LL, "Dynamic Configuration of
IPv4 Link-Local Addresses" (IETF RFC3927), a protocol for
<p>See http://developer.apple.com/qa/qa2004/qa1357.html for more information.</p>
</description>
-
+
<options>
<option>
<option>
<p><opt>--no-drop-root</opt></p>
- <optdesc><p>Don't drop root priviliges after startup. We recommend not to use this option.</p></optdesc>
+ <optdesc><p>Don't drop root privileges after startup. We recommend not to use this option.</p></optdesc>
</option>
<option>
<p><opt>-w | --wait</opt></p>
<optdesc><p>Wait until a IP address has been sucessfully acquired before detaching. Only valid in combination with <opt>--daemonize</opt>.</p></optdesc>
</option>
-
+
<option>
<p><opt>--force-bind</opt></p>
<optdesc><p>Acquire an IPv4LL address, even if a routable address has been configured on the interface.</p></optdesc>
</options>
<section name="Files">
-
+
<p><file>@pkgsysconfdir@/avahi-autoipd.action</file>: the script to run when an IP address as been acquired or is lost.</p>
-
+
</section>
<section name="Signals">
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="autoipd.action" section="8"/>, <manref name="dhclient" section="8"/>
<p>http://avahi.org/wiki/AvahiAutoipd documents how avahi-autoipd is best packaged and integrated into distributions.</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id: avahi-autoipd.action.8.xml.in 263 2005-08-07 19:53:39Z lennart $ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>@pkgsysconfdir@/avahi-autoipd.action</cmd>
</synopsis>
-
+
<description>
<p><file>avahi-autoipd.action</file> is the action script that
is called whenever an IP address has been acquired by
script should add or remove the specified address from the
specified network interface.</p>
</description>
-
+
<section name="Parameters">
<option>
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-autoipd" section="8"/>, <manref name="dhclient-script" section="8"/>, <manref name="ip" section="8"/>, <manref name="ifconfig" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>avahi-bookmarks</cmd>
</synopsis>
-
+
<description>
<p>A web service for listing HTTP services that are announced
via mDNS/DNS-SD using the Avahi daemon. avahi-bookmarks opens a
returning a dynamic web site containing links to all services of
type _http._tcp on the LAN. Point your browser to
http://localhost:8080/ to make use of avahi-bookmarks.</p>
-
+
</description>
-
+
<options>
<option>
<p><opt>-p | --port=</opt> <arg>PORT</arg></p>
locally. This option conflicts with -H.</p></optdesc>
</option>
-
+
<option>
<p><opt>-d | --domain</opt>=<arg>DOMAIN</arg></p>
<optdesc><p>The domain to browse for services in.</p></optdesc>
- </option>
+ </option>
<option>
<p><opt>-h | --help</opt></p>
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-browse" section="1"/>, <manref name="avahi-daemon" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
<!--
This file is part of avahi.
<option>
<p><opt>-p | --parsable</opt></p>
- <optdesc><p>Make output easily parsable for usage in scripts. If enabled fields are seperated by semicolons (;), service names are escaped. It is recommended to combine this with <opt>--no-db-lookup</opt>.</p></optdesc>
+ <optdesc><p>Make output easily parsable for usage in scripts. If enabled fields are separated by semicolons (;), service names are escaped. It is recommended to combine this with <opt>--no-db-lookup</opt>.</p></optdesc>
</option>
<option>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<cmd>avahi-daemon <opt>--reload</opt></cmd>
<cmd>avahi-daemon <opt>--check</opt></cmd>
</synopsis>
-
+
<description>
<p>The Avahi mDNS/DNS-SD daemon implements Apple's Zeroconf
architecture (also known as "Rendezvous" or "Bonjour"). The daemon
(a libc NSS plugin, providing name resolution via mDNS). Finally
there is the D-Bus interface which provides a rich object
oriented interface to D-Bus enabled applications.</p>
-
+
<p>Upon startup avahi-daemon interprets its configuration file
<file>@pkgsysconfdir@/avahi-daemon.conf</file> and reads XML
fragments from <file>@servicedir@/*.service</file> which may
<file>avahi-daemon.conf</file> the file
<file>/etc/resolv.conf</file> will be read, too.</p>
</description>
-
+
<options>
<option>
<option>
<p><opt>--no-drop-root</opt></p>
- <optdesc><p>Don't drop root priviliges after startup and don't require daemon to be started as root. We recommend not to use this option.</p></optdesc>
+ <optdesc><p>Don't drop root privileges after startup and don't require daemon to be started as root. We recommend not to use this option.</p></optdesc>
</option>
<option>
</options>
<section name="Files">
-
+
<p><file>@pkgsysconfdir@/avahi-daemon.conf</file>: the default configuration file for avahi-daemon, <manref name="avahi-daemon.conf" section="5"/> for more information.</p>
<p><file>@pkgsysconfdir@/hosts</file>: additional static hostname mappings to publish in mDNS, see <manref name="avahi.hosts" section="5"/> for more information.</p>
<p><file>@servicedir@/*.service</file>: static service definitions, see <manref name="avahi.service" section="5"/> for more information.</p>
-
+
</section>
<section name="Signals">
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-daemon.conf" section="5"/>, <manref name="avahi.hosts" section="5"/>, <manref name="avahi.service" section="5"/>, <manref name="avahi-dnsconfd" section="8"/>, <manref name="avahi-set-host-name" section="1"/>
<p>http://avahi.org/wiki/AvahiAndUnicastDotLocal documents the problems when using Avahi in a unicast DNS zone .local.</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
<!--
This file is part of avahi.
USA.
-->
- <manpage name="avahi-daemon.conf" section="5" desc="avahi-daemon configuration file">
-
- <synopsis>
- <cmd>@pkgsysconfdir@/avahi-daemon.conf</cmd>
- </synopsis>
-
- <description>
- <p><file>avahi-daemon.conf</file> is the configuration file for avahi-daemon.</p>
- </description>
-
- <section name="Section [Server]">
-
- <option>
- <p><opt>host-name=</opt> Set the host name avahi-daemon tries
- to register on the LAN. If omited defaults to the system host
- name as set with the sethostname() system call.</p>
- </option>
-
- <option>
- <p><opt>domain-name=</opt> Set the default domain name avahi-daemon
- tries to register its host name and services on the LAN in. If
- omitted defaults to ".local".</p>
- </option>
-
- <option>
- <p><opt>browse-domains=</opt> Set a comma seperated list of
- browsing domains (in addition to the default one and those
- announced inside the default browsing domain). Please note
- that the user may specify additional browsing domains on the
- client side, either by setting $AVAHI_BROWSE_DOMAINS to a list
- of colon seperated domains or by adding them to the XDG config
- file <file>~/.config/avahi/browse-domains</file> (seperated by
- newlines).</p>
-
- </option>
-
- <option>
- <p><opt>use-ipv4=</opt> Takes a boolean value ("yes" or
- "no"). If set to "no" avahi-daemon will not use IPv4
- sockets. Default is "yes".</p>
- </option>
-
- <option>
- <p><opt>use-ipv6=</opt> Takes a boolean value ("yes" or
- "no"). If set to "no" avahi-daemon will not use IPv6
- sockets. Default is "yes".</p>
- </option>
-
- <option>
- <p><opt>allow-interfaces=</opt> Set a comma seperated list of
- allowed network interfaces that should be used by the
- avahi-daemon. Other interfaces will be ignored. If set to the
- empty list all local interfaces except loopback and
- point-to-point will be used.</p>
- </option>
-
- <option>
- <p><opt>deny-interfaces=</opt> Set a comma seperated list of
- network interfaces that should be ignored by avahi-daemon.
- Other not specified interfaces will be used, unless
- <opt>allow-interfaces</opt> is set. This option takes
- precedence over <opt>deny-interfaces</opt>.</p>
- </option>
-
- <option>
- <p><opt>check-response-ttl=</opt> Takes a boolean value ("yes"
- or "no"). If set to "yes", an additional security check is
- activated: incoming IP packets will be ignored unless the IP
- TTL is 255. Earlier mDNS specifications required this
- check. Since this feature may be incompatible with newer
- implementations of mDNS it defaults to "no". On the other hand
- it provides extra security.</p>
- </option>
-
- <option>
- <p><opt>use-iff-running=</opt> Takes a boolean value ("yes" or
- "no"). If set to "yes" avahi-daemon monitors the IFF_RUNNING
- flag bit which is used by some (modern) network drivers to
- tell user space if a network cable is plugged in (in case of
- copper ethernet), or the network card is associated with some
- kind of network (in case of WLAN). If IFF_RUNNING is set
- avahi-daemon will automatically announce its services on that
- network. Unfortunately far too many network drivers do not
- support this flag or support it in a broken way. Therefore
- this option defaults to "no".</p>
- </option>
-
- <option>
- <p><opt>enable-dbus=</opt> Takes either "yes", "no" or
- "warn". If set to "yes" avahi-daemon connects to D-Bus,
- offering an object oriented client API. It is only available
- if Avahi has been compiled with <opt>--enable-dbus</opt> in
- which case it defaults to "yes". "warn" behaves like "yes",
- but the daemon starts up even when it fails to connect to a
- D-Bus daemon. In addition, if the connection to the D-Bus
- daemon is terminated we try to reconnect. (Unless we are in a
- chroot() environment where this definitely will fail.) </p>
- </option>
-
- <option>
- <p><opt>disallow-other-stacks=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes" no other process is allowed
- to bind to UDP port 5353. This effectively impedes other mDNS
- stacks from running on the host. Use this as a security
- measure to make sure that only Avahi is responsible for mDNS
- traffic. Please note that we do not recommend running multiple
- mDNS stacks on the same host simultaneously. This hampers
- reliability and is a waste of resources. However, to not annoy
- people this option defaults to "no".</p>
- </option>
-
- <option>
- <p><opt>allow-point-to-point=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes" avahi-daemon will make use of
- interfaces with the POINTOPOINT flag set. This option defaults
- to "no" as it might make mDNS unreliable due to usually large
- latencies with such links and opens a potential security hole
- by allowing mDNS access from Internet connections. Use with
- care and YMMV!</p>
- </option>
-
- </section>
-
- <section name="Section [wide-area]">
- <option>
- <p><opt>enable-wide-area=</opt> Takes a boolean value
- ("yes" or "no"). Enable wide-area DNS-SD, aka
- DNS-SD over unicast DNS. If this is enabled only domains
- ending in .local will be resolved on mDNS, all other domains
- are resolved via unicast DNS. If you want to maintain multiple
- different multicast DNS domains even with this option enabled
- we encourage you to use subdomains of .local, such as
- "kitchen.local". This option defaults to "yes".</p>
- </option>
-
- </section>
-
- <section name="Section [publish]">
-
- <option><p><opt>disable-publishing=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes", no record will be published by
- Avahi, not even address records for the local host. Avahi will
- be started in a querying-only mode. Use this is a security
- measure. This option defaults to "no"</p></option>
-
- <option><p><opt>disable-user-service-publishing=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes", Avahi will still publish
- address records and suchlike but will not allow user
- applications to publish services. Use this is a security
- measure. This option defaults to "no"</p></option>
-
- <option>
- <p><opt>add-service-cookie=</opt> Takes a boolean value ("yes"
- or "no"). If set to "yes" an implicit TXT entry will be added
- to all locally registered services, containing a cookie value
- which is chosen randomly on daemon startup. This can be used
- to detect if two services on two different
- interfaces/protocols are actually identical. Defaults to
- "no".</p>
- </option>
-
- <option>
- <p><opt>publish-addresses=</opt> Takes a boolean value ("yes"
- or "no"). If set to "yes" avahi-daemon will register mDNS
- address records for all local IP addresses. Unless you want to
- use avahi-daemon exclusively for browsing it's recommended to
- enable this. If you plan to register local services you need
- to enable this option. Defaults to "yes".</p>
- </option>
-
- <option>
- <p><opt>publish-hinfo=</opt> Takes a boolean value ("yes" or
- "no"). If set to "yes" avahi-daemon will register an mDNS
- HINFO record on all interfaces which contains information
- about the local operating system and CPU, which might be
- useful for administrative purposes. This is recommended by the
- mDNS specification but not required. For the sake of privacy
- you might choose to disable this feature. Defaults to
- "yes."</p>
- </option>
-
- <option>
- <p><opt>publish-workstation=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes" avahi-daemon will register a
- service of type "_workstation._tcp" on the local LAN. This
- might be useful for administrative purposes (i.e. browse for
- all PCs on the LAN), but is not required or recommended by any
- specification. Newer MacOS X releases register a service of
- this type. Defaults to "yes".</p>
- </option>
-
- <option>
- <p><opt>publish-domain=</opt> Takes a boolean value ("yes" or
- "no"). If set to "yes" avahi-daemon will announce the locally
- used domain name (see above) for browsing by other
- hosts. Defaults to "yes".</p>
- </option>
-
- <option>
- <p><opt>publish-dns-servers=</opt> Takes a comma seperated
- list of IP addresses for unicast DNS servers. You can use this
- to announce unicast DNS servers via mDNS. When used in
- conjunction with avahi-dnsconfd on the client
- side this allows DHCP-like configuration of unicast DNS
- servers.</p>
- </option>
-
- <option>
- <p><opt>publish-resolv-conf-dns-servers=</opt> Takes a boolean
- value ("yes" or "no"). If set to "yes" avahi-daemon will
- publish the unicast DNS servers specified in
- <file>/etc/resolv.conf</file> in addition to those specified
- with <opt>publish-dns-servers</opt>. Send avahi-daemon a
- SIGHUP to have it reload this file. Defaults to "no".</p>
- </option>
-
- <option>
- <p><opt>publish-aaaa-on-ipv4=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes" avahi-daemon will publish an
- IPv6 AAAA record via IPv4, i.e. the local IPv6 addresses can be
- resolved using an IPv4 transport. Only useful when IPv4 is
- enabled with <opt>use-ipv4=true</opt>. Defaults to "yes".</p>
- </option>
-
- <option>
- <p><opt>publish-a-on-ipv6=</opt> Takes a boolean value
- ("yes" or "no"). If set to "yes" avahi-daemon will publish an
- IPv4 A record via IPv6, i.e. the local IPv4 addresses can be
- resolved using an IPv6 transport. Only useful when IPv6 is
- enabled with <opt>use-ipv6=true</opt>. Defaults to "no".</p>
- </option>
-
- </section>
-
- <section name="Section [reflector]">
- <option>
- <p><opt>enable-reflector=</opt> Takes a boolean value ("yes"
- or "no"). If set to "yes" avahi-daemon will reflect incoming
- mDNS requests to all local network interfaces, effectively
- allowing clients to browse mDNS/DNS-SD services on all
- networks connected to the gateway. The gateway is somewhat
- intelligent and should work with all kinds of mDNS traffic,
- though some functionality is lost (specifically the unicast
- reply bit, which is used rarely anyway). Make sure to not run
- multiple reflectors between the same networks, this might
- cause them to play Ping Pong with mDNS packets. Defaults to
- "no".</p>
- </option>
-
- <option>
- <p><opt>reflect-ipv=</opt> Takes a boolean value ("yes" or
- "no"). If set to "yes" and <opt>enable-reflector</opt> is
- enabled, avahi-daemon will forward mDNS traffic between IPv4
- and IPv6, which is usually not recommended. Defaults to "no".</p>
- </option>
- </section>
-
- <section name="Section [rlimits]">
- <p>This section is used to define system resource limits for the
- daemon. See <manref section="2" name="setrlimit"/> for more
- information. If any of the options is not specified in the configuration
- file, avahi-daemon does not change it from the system
- defaults.</p>
-
-
- <option>
- <p><opt>rlimit-as=</opt> Value in bytes for RLIMIT_AS (maximum size of the process's virtual memory). Sensible values are heavily system dependent.</p>
- </option>
-
- <option>
- <p><opt>rlimit-core=</opt> Value in bytes for RLIMIT_CORE (maximum core file size). Unless you want to debug avahi-daemon, it is safe to set this to 0.</p>
- </option>
-
- <option>
- <p><opt>rlimit-data=</opt> Value in bytes for RLIMIT_DATA (maximum size of the process's data segment). Sensible values are heavily system dependent.</p>
- </option>
-
- <option>
- <p><opt>rlimit-fsize=</opt> Value for RLIMIT_FSIZE (maximum size of files the process may create). Since avahi-daemon shouldn't write any files to disk, it is safe to set this to 0.</p>
- </option>
-
- <option>
- <p><opt>rlimit-nofile=</opt> Value for RLIMIT_NOFILE (open file descriptors). avahi-daemon shouldn't need more than 15 to 20 open file descriptors concurrently.</p>
- </option>
-
- <option>
- <p><opt>rlimit-stack=</opt> Value in bytes for RLIMIT_STACK (maximum size of the process stack). Sensible values are heavily system dependent.</p>
- </option>
-
- <option>
- <p><opt>rlimit-nproc=</opt> Value for RLIMIT_NPROC (number of process of user). avahi-daemon forks of a helper process on systems where <manref name="chroot" section="2"/> is available. Therefore this value should not be set below 2.</p>
- </option>
-
- </section>
-
- <section name="Authors">
- <p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
- available from <url href="@PACKAGE_URL@"/></p>
- </section>
-
- <section name="See also">
- <p>
- <manref name="avahi-daemon" section="8"/>, <manref name="avahi-dnsconfd" section="8"/>
- </p>
- </section>
-
- <section name="Comments">
- <p>This man page was written using <manref name="xml2man" section="1"
- href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
- </section>
-
- </manpage>
+<manpage name="avahi-daemon.conf" section="5" desc="avahi-daemon configuration file">
+
+ <synopsis>
+ <cmd>@pkgsysconfdir@/avahi-daemon.conf</cmd>
+ </synopsis>
+
+ <description>
+ <p><file>avahi-daemon.conf</file> is the configuration file for avahi-daemon.</p>
+ </description>
+
+ <section name="Section [Server]">
+
+ <option>
+ <p><opt>host-name=</opt> Set the host name avahi-daemon tries
+ to register on the LAN. If omited defaults to the system host
+ name as set with the sethostname() system call.</p>
+ </option>
+
+ <option>
+ <p><opt>domain-name=</opt> Set the default domain name avahi-daemon
+ tries to register its host name and services on the LAN in. If
+ omitted defaults to ".local".</p>
+ </option>
+
+ <option>
+ <p><opt>browse-domains=</opt> Set a comma separated list of
+ browsing domains (in addition to the default one and those
+ announced inside the default browsing domain). Please note
+ that the user may specify additional browsing domains on the
+ client side, either by setting $AVAHI_BROWSE_DOMAINS to a list
+ of colon separated domains or by adding them to the XDG config
+ file <file>~/.config/avahi/browse-domains</file> (separated by
+ newlines).</p>
+
+ </option>
+
+ <option>
+ <p><opt>use-ipv4=</opt> Takes a boolean value ("yes" or
+ "no"). If set to "no" avahi-daemon will not use IPv4
+ sockets. Default is "yes".</p>
+ </option>
+
+ <option>
+ <p><opt>use-ipv6=</opt> Takes a boolean value ("yes" or
+ "no"). If set to "no" avahi-daemon will not use IPv6
+ sockets. Default is "yes".</p>
+ </option>
+
+ <option>
+ <p><opt>allow-interfaces=</opt> Set a comma separated list of
+ allowed network interfaces that should be used by the
+ avahi-daemon. Traffic on other interfaces will be ignored. If
+ set to an empty list all local interfaces except loopback and
+ point-to-point will be used.</p>
+ </option>
+
+ <option>
+ <p><opt>deny-interfaces=</opt> Set a comma separated list of
+ network interfaces that should be ignored by avahi-daemon.
+ Other not specified interfaces will be used, unless
+ <opt>allow-interfaces=</opt> is set. This option takes
+ precedence over <opt>allow-interfaces=</opt>.</p>
+ </option>
+
+ <option>
+ <p><opt>check-response-ttl=</opt> Takes a boolean value ("yes"
+ or "no"). If set to "yes", an additional security check is
+ activated: incoming IP packets will be ignored unless the IP
+ TTL is 255. Earlier mDNS specifications required this
+ check. Since this feature may be incompatible with newer
+ implementations of mDNS it defaults to "no". On the other hand
+ it provides extra security.</p>
+ </option>
+
+ <option>
+ <p><opt>use-iff-running=</opt> Takes a boolean value ("yes" or
+ "no"). If set to "yes" avahi-daemon monitors the IFF_RUNNING
+ flag bit which is used by some (modern) network drivers to
+ tell user space if a network cable is plugged in (in case of
+ copper ethernet), or the network card is associated with some
+ kind of network (in case of WLAN). If IFF_RUNNING is set
+ avahi-daemon will automatically announce its services on that
+ network. Unfortunately far too many network drivers do not
+ support this flag or support it in a broken way. Therefore
+ this option defaults to "no".</p>
+ </option>
+
+ <option>
+ <p><opt>enable-dbus=</opt> Takes either "yes", "no" or
+ "warn". If set to "yes" avahi-daemon connects to D-Bus,
+ offering an object oriented client API. It is only available
+ if Avahi has been compiled with <opt>--enable-dbus</opt> in
+ which case it defaults to "yes". "warn" behaves like "yes",
+ but the daemon starts up even when it fails to connect to a
+ D-Bus daemon. In addition, if the connection to the D-Bus
+ daemon is terminated we try to reconnect. (Unless we are in a
+ chroot() environment where this definitely will fail.) </p>
+ </option>
+
+ <option>
+ <p><opt>disallow-other-stacks=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes" no other process is allowed
+ to bind to UDP port 5353. This effectively impedes other mDNS
+ stacks from running on the host. Use this as a security
+ measure to make sure that only Avahi is responsible for mDNS
+ traffic. Please note that we do not recommend running multiple
+ mDNS stacks on the same host simultaneously. This hampers
+ reliability and is a waste of resources. However, to not annoy
+ people this option defaults to "no".</p>
+ </option>
+
+ <option>
+ <p><opt>allow-point-to-point=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes" avahi-daemon will make use of
+ interfaces with the POINTOPOINT flag set. This option defaults
+ to "no" as it might make mDNS unreliable due to usually large
+ latencies with such links and opens a potential security hole
+ by allowing mDNS access from Internet connections. Use with
+ care and YMMV!</p>
+ </option>
+
+ <option>
+ <p><opt>cache-entries-max=</opt> Takes an unsigned integer
+ specifying how many resource records are cached per
+ interface. Bigger values allow mDNS work correctly in large LANs
+ but also increase memory consumption.</p>
+ </option>
+
+ <option>
+ <p><opt>clients-max=</opt> Takes an unsigned integer. The
+ maximum number of concurrent D-Bus clients allowed. If the
+ maximum number is reached further clients will be refused until
+ at least one existing client disconnects.</p>
+ </option>
+
+ <option>
+ <p><opt>objects-per-client-max=</opt> Takes an unsigned
+ integer. The maximum number of objects (entry groups, browsers,
+ resolvers) that may be registered per client at a time. If the
+ maximum number is reached further object creation will be
+ refused until at least one object is freed.</p>
+ </option>
+
+ <option>
+ <p><opt>entries-per-entry-group-max=</opt> Takes an unsigned
+ integer. The maximum number of entries (resource records) per
+ entry group at a time. If the maximum number is reached further
+ resource records may not be added to an entry group.</p>
+ </option>
+
+ </section>
+
+ <section name="Section [wide-area]">
+ <option>
+ <p><opt>enable-wide-area=</opt> Takes a boolean value
+ ("yes" or "no"). Enable wide-area DNS-SD, aka
+ DNS-SD over unicast DNS. If this is enabled only domains
+ ending in .local will be resolved on mDNS, all other domains
+ are resolved via unicast DNS. If you want to maintain multiple
+ different multicast DNS domains even with this option enabled
+ we encourage you to use subdomains of .local, such as
+ "kitchen.local". This option defaults to "yes".</p>
+ </option>
+
+ </section>
+
+ <section name="Section [publish]">
+
+ <option><p><opt>disable-publishing=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes", no record will be published by
+ Avahi, not even address records for the local host. Avahi will
+ be started in a querying-only mode. Use this is a security
+ measure. This option defaults to "no"</p></option>
+
+ <option><p><opt>disable-user-service-publishing=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes", Avahi will still publish
+ address records and suchlike but will not allow user
+ applications to publish services. Use this is a security
+ measure. This option defaults to "no"</p></option>
+
+ <option>
+ <p><opt>add-service-cookie=</opt> Takes a boolean value ("yes"
+ or "no"). If set to "yes" an implicit TXT entry will be added
+ to all locally registered services, containing a cookie value
+ which is chosen randomly on daemon startup. This can be used
+ to detect if two services on two different
+ interfaces/protocols are actually identical. Defaults to
+ "no".</p>
+ </option>
+
+ <option>
+ <p><opt>publish-addresses=</opt> Takes a boolean value ("yes"
+ or "no"). If set to "yes" avahi-daemon will register mDNS
+ address records for all local IP addresses. Unless you want to
+ use avahi-daemon exclusively for browsing it's recommended to
+ enable this. If you plan to register local services you need
+ to enable this option. Defaults to "yes".</p>
+ </option>
+
+ <option>
+ <p><opt>publish-hinfo=</opt> Takes a boolean value ("yes" or
+ "no"). If set to "yes" avahi-daemon will register an mDNS
+ HINFO record on all interfaces which contains information
+ about the local operating system and CPU, which might be
+ useful for administrative purposes. This is recommended by the
+ mDNS specification but not required. For the sake of privacy
+ you might choose to disable this feature. Defaults to
+ "yes."</p>
+ </option>
+
+ <option>
+ <p><opt>publish-workstation=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes" avahi-daemon will register a
+ service of type "_workstation._tcp" on the local LAN. This
+ might be useful for administrative purposes (i.e. browse for
+ all PCs on the LAN), but is not required or recommended by any
+ specification. Newer MacOS X releases register a service of
+ this type. Defaults to "yes".</p>
+ </option>
+
+ <option>
+ <p><opt>publish-domain=</opt> Takes a boolean value ("yes" or
+ "no"). If set to "yes" avahi-daemon will announce the locally
+ used domain name (see above) for browsing by other
+ hosts. Defaults to "yes".</p>
+ </option>
+
+ <option>
+ <p><opt>publish-dns-servers=</opt> Takes a comma separated
+ list of IP addresses for unicast DNS servers. You can use this
+ to announce unicast DNS servers via mDNS. When used in
+ conjunction with avahi-dnsconfd on the client
+ side this allows DHCP-like configuration of unicast DNS
+ servers.</p>
+ </option>
+
+ <option>
+ <p><opt>publish-resolv-conf-dns-servers=</opt> Takes a boolean
+ value ("yes" or "no"). If set to "yes" avahi-daemon will
+ publish the unicast DNS servers specified in
+ <file>/etc/resolv.conf</file> in addition to those specified
+ with <opt>publish-dns-servers</opt>. Send avahi-daemon a
+ SIGHUP to have it reload this file. Defaults to "no".</p>
+ </option>
+
+ <option>
+ <p><opt>publish-aaaa-on-ipv4=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes" avahi-daemon will publish an
+ IPv6 AAAA record via IPv4, i.e. the local IPv6 addresses can be
+ resolved using an IPv4 transport. Only useful when IPv4 is
+ enabled with <opt>use-ipv4=true</opt>. Defaults to "yes".</p>
+ </option>
+
+ <option>
+ <p><opt>publish-a-on-ipv6=</opt> Takes a boolean value
+ ("yes" or "no"). If set to "yes" avahi-daemon will publish an
+ IPv4 A record via IPv6, i.e. the local IPv4 addresses can be
+ resolved using an IPv6 transport. Only useful when IPv6 is
+ enabled with <opt>use-ipv6=true</opt>. Defaults to "no".</p>
+ </option>
+
+ </section>
+
+ <section name="Section [reflector]">
+ <option>
+ <p><opt>enable-reflector=</opt> Takes a boolean value ("yes"
+ or "no"). If set to "yes" avahi-daemon will reflect incoming
+ mDNS requests to all local network interfaces, effectively
+ allowing clients to browse mDNS/DNS-SD services on all
+ networks connected to the gateway. The gateway is somewhat
+ intelligent and should work with all kinds of mDNS traffic,
+ though some functionality is lost (specifically the unicast
+ reply bit, which is used rarely anyway). Make sure to not run
+ multiple reflectors between the same networks, this might
+ cause them to play Ping Pong with mDNS packets. Defaults to
+ "no".</p>
+ </option>
+
+ <option>
+ <p><opt>reflect-ipv=</opt> Takes a boolean value ("yes" or
+ "no"). If set to "yes" and <opt>enable-reflector</opt> is
+ enabled, avahi-daemon will forward mDNS traffic between IPv4
+ and IPv6, which is usually not recommended. Defaults to "no".</p>
+ </option>
+ </section>
+
+ <section name="Section [rlimits]">
+ <p>This section is used to define system resource limits for the
+ daemon. See <manref section="2" name="setrlimit"/> for more
+ information. If any of the options is not specified in the configuration
+ file, avahi-daemon does not change it from the system
+ defaults.</p>
+
+ <option>
+ <p><opt>rlimit-as=</opt> Value in bytes for RLIMIT_AS (maximum size of the process's virtual memory). Sensible values are heavily system dependent.</p>
+ </option>
+
+ <option>
+ <p><opt>rlimit-core=</opt> Value in bytes for RLIMIT_CORE (maximum core file size). Unless you want to debug avahi-daemon, it is safe to set this to 0.</p>
+ </option>
+
+ <option>
+ <p><opt>rlimit-data=</opt> Value in bytes for RLIMIT_DATA (maximum size of the process's data segment). Sensible values are heavily system dependent.</p>
+ </option>
+
+ <option>
+ <p><opt>rlimit-fsize=</opt> Value for RLIMIT_FSIZE (maximum size of files the process may create). Since avahi-daemon shouldn't write any files to disk, it is safe to set this to 0.</p>
+ </option>
+
+ <option>
+ <p><opt>rlimit-nofile=</opt> Value for RLIMIT_NOFILE (open file descriptors). avahi-daemon shouldn't need more than 15 to 20 open file descriptors concurrently.</p>
+ </option>
+
+ <option>
+ <p><opt>rlimit-stack=</opt> Value in bytes for RLIMIT_STACK (maximum size of the process stack). Sensible values are heavily system dependent.</p>
+ </option>
+
+ <option>
+ <p><opt>rlimit-nproc=</opt> Value for RLIMIT_NPROC (number of process of user). avahi-daemon forks of a helper process on systems where <manref name="chroot" section="2"/> is available. Therefore this value should not be set below 2.</p>
+ </option>
+
+ </section>
+
+ <section name="Authors">
+ <p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
+ available from <url href="@PACKAGE_URL@"/></p>
+ </section>
+
+ <section name="See also">
+ <p>
+ <manref name="avahi-daemon" section="8"/>, <manref name="avahi-dnsconfd" section="8"/>
+ </p>
+ </section>
+
+ <section name="Comments">
+ <p>This man page was written using <manref name="xml2man" section="1"
+ href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
+ </section>
+
+</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>avahi-discover</cmd>
</synopsis>
-
+
<description>
<p>Show a real-time graphical browse list for mDNS/DNS-SD
network services running on the local LAN using the Avahi
daemon.</p>
-
+
</description>
-
+
<options>
<p>avahi-discover takes no command line arguments at the moment.</p>
</options>
-
+
<section name="Authors">
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-daemon" section="8"/>, <manref name="avahi-browse" section="1"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<cmd>avahi-dnsconfd <opt>--refresh</opt></cmd>
<cmd>avahi-dnsconfd <opt>--check</opt></cmd>
</synopsis>
-
+
<description>
<p>avahi-dnsconfd connects to a running avahi-daemon and runs
the script <file>@pkgsysconfdir@/dnsconfd.action</file> for each unicast DNS
configuring unicast DNS servers in a DHCP-like fashion with
mDNS.</p>
</description>
-
+
<options>
<option>
<optdesc><p>Daemonize after startup and redirect log messages to syslog.</p></optdesc>
</option>
+ <option>
+ <p><opt>-s | --syslog</opt></p>
+ <optdesc><p>Log to syslog instead of STDERR. Implied by <opt>--daemonize</opt>.</p></optdesc>
+ </option>
+
<option>
<p><opt>-k | --kill</opt></p>
<optdesc><p>Kill an already running avahi-dnsconfd. (equivalent to sending a SIGTERM)</p></optdesc>
</options>
<section name="Files">
-
+
<p><file>@pkgsysconfdir@/avahi-dnsconfd.action</file>: the script to run when a DNS server is found or removed.</p>
-
+
</section>
<section name="Signals">
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-daemon" section="8"/>, <manref name="avahi-dnsconfd.action" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>@pkgsysconfdir@/avahi-dnsconfd.action</cmd>
</synopsis>
-
+
<description>
<p><file>avahi-dnsconfd.action</file> is the action script that
is called whenever a new unicast DNS server is found or
with avahi patches <file>/etc/resolv.conf</file> to reflect the
changed unicast DNS server configuration.</p>
</description>
-
+
<section name="Parameters">
<option>
<option>
<p><opt>AVAHI_INTERFACE</opt> Contains the textual interface name the corresponds with argv[3]. (e.g. "eth0")</p>
</option>
-
+
<option><p><opt>AVAHI_INTERFACE_DNS_SERVERS</opt> Contains a
list of all DNS servers that avahi-dnsconfd found on the
interface <opt>$AVAHI_INTERFACE</opt>, separated by
DNS server that avahi-dnsconfd found on all interfaces,
separated by spaces.</p></option>
- </section>
+ </section>
<section name="Authors">
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-dnsconfd" section="8"/>, <manref name="avahi-daemon" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<cmd>avahi-publish -a [<arg>options</arg>] <arg>host name</arg> <arg>address</arg></cmd>
<cmd>avahi-publish-address [<arg>options</arg>] <arg>host name</arg> <arg>address</arg></cmd>
</synopsis>
-
+
<description>
<p>Register an mDNS/DNS-SD service or host name/address mapping using the Avahi daemon.</p>
</description>
-
+
<options>
<p>When calling in service registration mode, specify a DNS-SD
command line. When calling in address/host name registration
mode specify a fully qualified host name and an address (IPv4 or
IPv6).</p>
-
+
<option>
<p><opt>-s | --service</opt></p>
<optdesc><p>Register a service. avahi-publish-service is equivalent to avahi-publish -s.</p></optdesc>
</option>
</options>
-
+
<section name="Authors">
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-resolve" section="1"/>, <manref
name="avahi-daemon" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<cmd>avahi-resolve --address <arg>address ...</arg></cmd>
<cmd>avahi-resolve-address <arg>address ...</arg></cmd>
</synopsis>
-
+
<description>
<p>Resolve one or more mDNS/DNS host name(s) to IP address(es) (and vice versa) using the Avahi daemon.</p>
</description>
-
+
<options>
-
+
<p>When passing -n, specify one or more fully qualified mDNS/DNS host name(s)
(e.g. "foo.local") to resolve into IP addresses on the
command line. When passing -a, specify one or more IP address
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
- <manref name="avahi-publish-address" section="1"/>,
+ <manref name="avahi-publish-address" section="1"/>,
<manref
name="avahi-daemon" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>avahi-set-host-name <arg>host-name</arg></cmd>
</synopsis>
-
+
<description>
<p>Set the mDNS host name of a currently running Avahi
daemon. The effect of this operation is not persistent across
daemon restarts. This operation is usually privileged.</p>
</description>
-
+
<options>
-
+
<option>
<p><opt>-v | --verbose</opt></p>
<optdesc><p>Enable verbose mode.</p></optdesc>
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-daemon" section="8"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man" section="1"
href="http://masqmail.cx/xml2man/"/> by Oliver Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>@pkgsysconfdir@/hosts</cmd>
</synopsis>
-
+
<description>
<p><file>@pkgsysconfdir@/hosts</file> is a file which may be used
to define static host name to IP address mappings for multicast
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-daemon" section="8"/>, <manref name="avahi.service" section="5"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man"
section="1" href="http://masqmail.cx/xml2man/"/> by Oliver
Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
<synopsis>
<cmd>@servicedir@/*.service</cmd>
</synopsis>
-
+
<description> <p><file>@servicedir@/*.service</file> are XML
fragments containing static DNS-SD service data. Every service
file can contain multiple service definitions which share the
same name. This is useful for publishing service data for
services which implement multiple protocols. (i.e. a printer
implementing _ipp._tcp and _printer._tcp)</p> </description>
-
+
<section name="XML Tags">
-
+
<option>
<p><opt><service-group></opt> The document tag of avahi
service files. Should contain one <opt><name></opt> and one or more
<p>The Avahi Developers <@PACKAGE_BUGREPORT@>; Avahi is
available from <url href="@PACKAGE_URL@"/></p>
</section>
-
+
<section name="See also">
<p>
<manref name="avahi-daemon" section="8"/>, <manref name="avahi.hosts" section="5"/>
</p>
</section>
-
+
<section name="Comments">
<p>This man page was written using <manref name="xml2man"
section="1" href="http://masqmail.cx/xml2man/"/> by Oliver
Kurth.</p>
</section>
-
+
</manpage>
<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
-<!-- $Id$ -->
-
<!--
This file is part of avahi.
-/* $Id$ */
-
/***
This file is part of avahi.
-<!-- $Id$ -->
-
-<!--
+<!--
This file is part of avahi.
avahi is free software; you can redistribute it and/or modify it under
You should have received a copy of the GNU General Public License
along with avahi; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-->
<!ELEMENT manpage (synopsis | description | section | options | seealso)*>
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-->
-<!-- $Id$ -->
-
<xsl:output method="xml" version="1.0" encoding="iso-8859-15" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes"/>
<xsl:template match="/manpage">
# List of source files which contain translatable strings.
avahi-common/error.c
-avahi-discover-standalone/avahi-discover.glade
+[type: gettext/glade]avahi-discover-standalone/avahi-discover.ui
avahi-python/avahi-discover/avahi-discover.desktop.in.in
avahi-ui/avahi-ui.c
avahi-ui/bssh.c
-avahi-discover-standalone/avahi-discover.glade
avahi-ui/bssh.desktop.in
avahi-ui/bvnc.desktop.in
tests/c-plus-plus-test-gen.py
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
pkglib_DATA+=service-types.db
build-db: build-db.in
- sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,gdbm,g' $< > $@
+ $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
+ -e 's,@DBM\@,gdbm,g' $< > $@ && \
chmod +x $@
service-types.db: service-types build-db
- $(PYTHON) build-db $< $@.coming
+ $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
mv $@.coming $@
CLEANFILES = service-types.db build-db
pkglib_DATA+=service-types.db.pag service-types.db.dir
build-db: build-db.in
- sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,dbm,g' $< > $@
+ $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
+ -e 's,@DBM\@,dbm,g' $< > $@ && \
chmod +x $@
service-types.db.pag: service-types.db
- mv service-types.db.coming.pag service-types.db.pag
+ $(AM_V_GEN)mv service-types.db.coming.pag service-types.db.pag
service-types.db.dir: service-types.db
- mv service-types.db.coming.dir service-types.db.dir
+ $(AM_V_GEN)mv service-types.db.coming.dir service-types.db.dir
service-types.db: service-types build-db
- $(PYTHON) build-db $< $@.coming
+ $(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
if test -f "$@.coming"; then mv $@.coming $@; fi
CLEANFILES = service-types.db* build-db
#!@PYTHON@
# -*-python-*-
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
-# $Id$
-
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# available database unless its license is known and compatible with
# our project! The database available on
#
-# http://www.dns-sd.org/ServiceTypes.html
+# http://www.dns-sd.org/ServiceTypes.html
#
# is not a source that complies with the criterion!
_apt._tcp:APT Package Repository
_apt._tcp[it]:APT - Repository dei Pacchetti
+_odisk._tcp:DVD or CD Sharing
+
+_adisk._tcp:Apple TimeMachine
+
# Remote machine access
_ssh._tcp[it]:SSH Terminale remoto
_rfb._tcp:VNC Remote Access
-_rfb._tcp[it]:Controllo remoto VNC
+_rfb._tcp[it]:Controllo remoto VNC
_telnet._tcp:Telnet Remote Terminal
_telnet._tcp[it]:Telnet Terminale Remoto
_net-assistant._udp:Apple Net Assistant
+_udisks-ssh._tcp:Remote Disk Management
# Mail
_mpd._tcp:Music Player Daemon
+_remote-jukebox._tcp:Remote Jukebox
+
# DAAP share provided by iTunes on behalf of an iPod Touch
_touch-able._tcp:iPod Touch Music Library
_distcc._tcp[de]:Verteilter Compiler
_distcc._tcp[it]:Compilatore Distribuito
+_bzr._tcp:Bazaar
+
# Vendor specific
_adobe-vc._tcp:Adobe Version Cue
+_home-sharing._tcp:Apple Home Sharing
+
# Other
_tps._tcp:Thousand Parsec Server (Secure)
_tp-http._tcp:Thousand Parsec Server (HTTP Tunnel)
_tp-https._tcp:Thousand Parsec Server (Secure HTTP Tunnel)
+
+_shifter._tcp:Window Shifter
+
+_libvirt._tcp:Virtual Machine Manager
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
#!/usr/bin/python
-# $Id$
-#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
print "#include <%s/%s>" % (dir, f)
-print """/* $Id$ */
-
-/***
+print """/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-/* $Id$ */
-
/***
This file is part of avahi.