mirror of
https://agent.ghink.cloud/wb2osz/direwolf
synced 2025-04-11 09:08:34 +00:00
This allows client applications to locate the IP addresses and the port of the KISS TCP service, allowing the end user to just select a Dire Wolf from a list instead of trying to guess its dynamic IP address and typing it in manually. This is especially convenient on mobile devices. On Linux, the standard Avahi daemon is used via dbus and the avahi-client library. Building with it requires installing the development header package; README.md is updated accordingly. On Mac, the MacOS dnssd API is used: https://developer.apple.com/documentation/dnssd?language=objc I don't have Windows, but more recent Windows 10 builds apparently have a working DNS-SD mDNS implementation that can be used on 64-bit builds.
66 lines
2.0 KiB
C
66 lines
2.0 KiB
C
//
|
|
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
|
//
|
|
// Copyright (C) 2020 Heikki Hannikainen, OH7LZB
|
|
//
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program 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 General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/*------------------------------------------------------------------
|
|
*
|
|
* Module: dns_sd_common.c
|
|
*
|
|
* Purpose: Announce the KISS over TCP service using DNS-SD, common functions
|
|
*
|
|
* Description:
|
|
*
|
|
* Most people have typed in enough IP addresses and ports by now, and
|
|
* would rather just select an available TNC that is automatically
|
|
* discovered on the local network. Even more so on a mobile device
|
|
* such an Android or iOS phone or tablet.
|
|
*
|
|
* This module contains common functions needed on Linux and MacOS.
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
/* Get a default service name to publish. By default,
|
|
* "Dire Wolf on <hostname>", or just "Dire Wolf" if hostname cannot
|
|
* be obtained.
|
|
*/
|
|
char *dns_sd_default_service_name(void)
|
|
{
|
|
char hostname[51];
|
|
char sname[64];
|
|
|
|
int i = gethostname(hostname, sizeof(hostname));
|
|
if (i == 0) {
|
|
hostname[sizeof(hostname)-1] = 0;
|
|
|
|
// on some systems, an FQDN is returned; remove domain part
|
|
char *dot = strchr(hostname, '.');
|
|
if (dot)
|
|
*dot = 0;
|
|
|
|
snprintf(sname, sizeof(sname), "Dire Wolf on %s", hostname);
|
|
return strdup(sname);
|
|
}
|
|
|
|
return strdup("Dire Wolf");
|
|
}
|
|
|