zeroconf: pass global port to init function
This commit is contained in:
parent
d527d4b530
commit
a312629aad
|
@ -24,7 +24,6 @@
|
|||
#include "avahi/Publisher.hxx"
|
||||
#include "avahi/Service.hxx"
|
||||
#include "ZeroconfInternal.hxx"
|
||||
#include "Listen.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "Log.hxx"
|
||||
|
@ -55,7 +54,7 @@ public:
|
|||
static AvahiGlue *avahi_glue;
|
||||
|
||||
void
|
||||
AvahiInit(EventLoop &loop, const char *serviceName)
|
||||
AvahiInit(EventLoop &loop, const char *serviceName, unsigned port)
|
||||
{
|
||||
LogDebug(avahi_domain, "Initializing interface");
|
||||
|
||||
|
@ -65,7 +64,7 @@ AvahiInit(EventLoop &loop, const char *serviceName)
|
|||
std::forward_list<Avahi::Service> services;
|
||||
services.emplace_front(AVAHI_IF_UNSPEC,
|
||||
AVAHI_PROTO_UNSPEC,
|
||||
SERVICE_TYPE, listen_port);
|
||||
SERVICE_TYPE, port);
|
||||
|
||||
avahi_glue = new AvahiGlue(loop, serviceName, std::move(services));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class EventLoop;
|
||||
|
||||
void
|
||||
AvahiInit(EventLoop &loop, const char *service_name);
|
||||
AvahiInit(EventLoop &loop, const char *service_name, unsigned port);
|
||||
|
||||
void
|
||||
AvahiDeinit();
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "ZeroconfBonjour.hxx"
|
||||
#include "ZeroconfInternal.hxx"
|
||||
#include "Listen.hxx"
|
||||
#include "event/SocketEvent.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
@ -84,13 +83,13 @@ dnsRegisterCallback([[maybe_unused]] DNSServiceRef sdRef,
|
|||
}
|
||||
|
||||
void
|
||||
BonjourInit(EventLoop &loop, const char *service_name)
|
||||
BonjourInit(EventLoop &loop, const char *service_name, unsigned port)
|
||||
{
|
||||
DNSServiceRef dnsReference;
|
||||
DNSServiceErrorType error = DNSServiceRegister(&dnsReference,
|
||||
0, 0, service_name,
|
||||
SERVICE_TYPE, nullptr, nullptr,
|
||||
htons(listen_port), 0,
|
||||
htons(port), 0,
|
||||
nullptr,
|
||||
dnsRegisterCallback,
|
||||
nullptr);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class EventLoop;
|
||||
|
||||
void
|
||||
BonjourInit(EventLoop &loop, const char *service_name);
|
||||
BonjourInit(EventLoop &loop, const char *service_name, unsigned port);
|
||||
|
||||
void
|
||||
BonjourDeinit();
|
||||
|
|
|
@ -82,11 +82,11 @@ ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop)
|
|||
}
|
||||
|
||||
#ifdef HAVE_AVAHI
|
||||
AvahiInit(loop, serviceName);
|
||||
AvahiInit(loop, serviceName, listen_port);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BONJOUR
|
||||
BonjourInit(loop, serviceName);
|
||||
BonjourInit(loop, serviceName, listen_port);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,13 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned listen_port = 1234;
|
||||
|
||||
int
|
||||
main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
|
||||
{
|
||||
EventLoop event_loop;
|
||||
const ShutdownHandler shutdown_handler(event_loop);
|
||||
|
||||
AvahiInit(event_loop, "test");
|
||||
AvahiInit(event_loop, "test", 1234);
|
||||
|
||||
event_loop.Run();
|
||||
|
||||
|
|
Loading…
Reference in New Issue