Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS-SD publishing of KISS over TCP service on Linux and Mac #307

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ elseif(APPLE)
set(CMAKE_MACOSX_RPATH ON)
message(STATUS "RPATH support: ${CMAKE_MACOSX_RPATH}")

# just blindly enable dns-sd
set(USE_MACOS_DNSSD ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_MACOS_DNSSD")

elseif (WIN32)
if(NOT VS2015 AND NOT VS2017)
message(FATAL_ERROR "You must use Microsoft Visual Studio 2015 or 2017 as compiler")
Expand Down Expand Up @@ -276,6 +280,11 @@ if(LINUX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
endif()

find_package(Avahi)
if(AVAHI_CLIENT_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AVAHI_CLIENT")
endif()

elseif (NOT WIN32 AND NOT CYGWIN)
find_package(Portaudio REQUIRED)
if(PORTAUDIO_FOUND)
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ On Debian / Ubuntu / Raspbian / Raspberry Pi OS:
sudo apt-get install cmake
sudo apt-get install libasound2-dev
sudo apt-get install libudev-dev
sudo apt-get install libavahi-client-dev

Or on Red Hat / Fedora / CentOS:

sudo yum install git
sudo yum install gcc
sudo yum install gcc-c++
sudo yum install make
sudo yum install git
sudo yum install gcc
sudo yum install gcc-c++
sudo yum install make
sudo yum install alsa-lib-devel
sudo yum install libudev-devel
sudo yum install avahi-devel

CentOS 6 & 7 currently have cmake 2.8 but we need 3.1 or later.
First you need to enable the EPEL repository. Add a symlink if you don't already have the older version and want to type cmake rather than cmake3.
Expand Down
19 changes: 19 additions & 0 deletions cmake/modules/FindAvahi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

find_library(AVAHI_COMMON_LIBRARY NAMES avahi-common PATHS ${PC_AVAHI_CLIENT_LIBRARY_DIRS})
if(AVAHI_COMMON_LIBRARY)
set(AVAHI_COMMON_FOUND TRUE)
endif()

find_library(AVAHI_CLIENT_LIBRARY NAMES avahi-client PATHS ${PC_AVAHI_CLIENT_LIBRARY_DIRS})
if(AVAHI_CLIENT_LIBRARY)
set(AVAHI_CLIENT_FOUND TRUE)
endif()

FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVAHI DEFAULT_MSG AVAHI_COMMON_FOUND AVAHI_CLIENT_FOUND)

if (AVAHI_FOUND)
set(AVAHI_INCLUDE_DIRS ${AVAHI_UI_INCLUDE_DIR})
set(AVAHI_LIBRARIES ${AVAHI_COMMON_LIBRARY} ${AVAHI_CLIENT_LIBRARY})
endif()

mark_as_advanced(AVAHI_INCLUDE_DIRS AVAHI_LIBRARIES)
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ if(LINUX)
cm108.c
)
endif()
if(AVAHI_CLIENT_FOUND)
list(APPEND direwolf_SOURCES
dns_sd_common.c
dns_sd_avahi.c
)
endif()
elseif(WIN32 OR CYGWIN) # windows
list(APPEND direwolf_SOURCES
audio_win.c
Expand All @@ -111,6 +117,12 @@ if(LINUX)
list(APPEND direwolf_SOURCES
audio_portaudio.c
)
if(USE_MACOS_DNSSD)
list(APPEND direwolf_SOURCES
dns_sd_common.c
dns_sd_macos.c
)
endif()
endif()

add_executable(direwolf
Expand All @@ -127,6 +139,7 @@ target_link_libraries(direwolf
${ALSA_LIBRARIES}
${UDEV_LIBRARIES}
${PORTAUDIO_LIBRARIES}
${AVAHI_LIBRARIES}
)

if(WIN32 OR CYGWIN)
Expand Down
39 changes: 39 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
p_misc_config->enable_kiss_pt = 0; /* -p option */
p_misc_config->kiss_copy = 0;

p_misc_config->dns_sd_enabled = 1;

/* Defaults from http://info.aprs.net/index.php?title=SmartBeaconing */

p_misc_config->sb_configured = 0; /* TRUE if SmartBeaconing is configured. */
Expand Down Expand Up @@ -4564,6 +4566,43 @@ void config_init (char *fname, struct audio_s *p_audio_config,
}


/*
* DNSSD - Enable or disable (1/0) dns-sd, DNS Service Discovery announcements
* DNSSDNAME - Set DNS-SD service name, defaults to "Dire Wolf on <hostname>"
*/

else if (strcasecmp(t, "DNSSD") == 0) {
int n;
t = split(NULL,0);
if (t == NULL) {
text_color_set(DW_COLOR_ERROR);
dw_printf ("Line %d: Missing integer value for DNSSD command.\n", line);
continue;
}
n = atoi(t);
if (n == 0 || n == 1) {
p_misc_config->dns_sd_enabled = n;
} else {
p_misc_config->dns_sd_enabled = 0;
text_color_set(DW_COLOR_ERROR);
dw_printf ("Line %d: Invalid integer value for DNSSD. Disabling dns-sd.\n", line);
}
}

else if (strcasecmp(t, "DNSSDNAME") == 0) {
t = split(NULL, 1);
if (t == NULL) {
text_color_set(DW_COLOR_ERROR);
dw_printf ("Line %d: Missing service name for DNSSDNAME.\n", line);
continue;
}
else {
strlcpy(p_misc_config->dns_sd_name, t, sizeof(p_misc_config->dns_sd_name));
}
}



/*
* GPSNMEA - Device name for reading from GPS receiver.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ struct misc_config_s {

char log_path[80]; /* Either directory or full file name depending on above. */

int dns_sd_enabled; /* DNS Service Discovery announcement enabled. */
char dns_sd_name[64]; /* Name announced on dns-sd; defaults to "Dire Wolf on <hostname>" */

int sb_configured; /* TRUE if SmartBeaconing is configured. */
int sb_fast_speed; /* MPH */
int sb_fast_rate; /* seconds */
Expand Down
6 changes: 6 additions & 0 deletions src/direwolf.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
#include "dtime_now.h"
#include "fx25.h"
#include "dwsock.h"
#include "dns_sd_dw.h"


//static int idx_decoded = 0;
Expand Down Expand Up @@ -944,6 +945,11 @@ int main (int argc, char *argv[])
server_init (&audio_config, &misc_config);
kissnet_init (&misc_config);

#if (USE_AVAHI_CLIENT|USE_MACOS_DNSSD)
if (misc_config.kiss_port > 0 && misc_config.dns_sd_enabled)
dns_sd_announce(&misc_config);
#endif

/*
* Create a pseudo terminal and KISS TNC emulator.
*/
Expand Down
Loading