Out of 3 calls of this function only one doesn't have TCP vs. UDP
hardcoded. It's easier to move string check to that place and make this
function take "int tcp" argument instead.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
- service_announce_services(iface, name, announce_ttl);
+ if (!strcmp(name, sdudp))
+ service_announce_services(iface, 0, announce_ttl);
+ else if (!strcmp(name, sdtcp))
+ service_announce_services(iface, 1, announce_ttl);
service_reply(iface, name, announce_ttl);
break;
service_reply(iface, name, announce_ttl);
break;
static struct blob_buf b;
static VLIST_TREE(services, avl_strcmp, service_update, false, false);
static struct blob_buf b;
static VLIST_TREE(services, avl_strcmp, service_update, false, false);
-static char *sdudp = "_services._dns-sd._udp.local";
-static char *sdtcp = "_services._dns-sd._tcp.local";
+char *sdudp = "_services._dns-sd._udp.local";
+char *sdtcp = "_services._dns-sd._tcp.local";
static int service_init_announce;
static const char *
static int service_init_announce;
static const char *
-service_announce_services(struct interface *iface, const char *service, int ttl)
+service_announce_services(struct interface *iface, int tcp, int ttl)
- int tcp = 1;
-
- if (!strcmp(service, sdudp))
- tcp = 0;
- else if (strcmp(service, sdtcp))
- return;
vlist_for_each_element(&services, s, node) {
if (!strstr(s->service, "._tcp") && tcp)
vlist_for_each_element(&services, s, node) {
if (!strstr(s->service, "._tcp") && tcp)
void
service_announce(struct interface *iface, int ttl)
{
void
service_announce(struct interface *iface, int ttl)
{
- service_announce_services(iface, sdudp, ttl);
- service_announce_services(iface, sdtcp, ttl);
+ service_announce_services(iface, 0, ttl);
+ service_announce_services(iface, 1, ttl);
#ifndef _SERVICE_H__
#define _SERVICE_H__
#ifndef _SERVICE_H__
#define _SERVICE_H__
+extern char *sdudp;
+extern char *sdtcp;
extern void service_init(int announce);
extern void service_cleanup(void);
extern void service_announce(struct interface *iface, int ttl);
extern void service_init(int announce);
extern void service_cleanup(void);
extern void service_announce(struct interface *iface, int ttl);
-extern void service_announce_services(struct interface *iface, const char *service, int ttl);
extern void service_reply(struct interface *iface, const char *match, int ttl);
extern void service_reply(struct interface *iface, const char *match, int ttl);
+extern void service_announce_services(struct interface *iface, int tcp, int ttl);