[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 699927b3e7d7424c9e18e
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2020-07-04 16:22:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 699927b3e7d7424c9e18e504689f24ebe61f6aca (commit) via 5ebb95bb43bc025a0a3e81a8c534f6e3e2da6e63 (commit) via ed3a26296dc34913dab7ca21426930cbcb436c84 (commit) from b2dce86e91f0a75fb1ac5448a77409d8fc3af16e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 699927b3e7d7424c9e18e504689f24ebe61f6aca Author: Michael Black W9MDB <mdb...@ya...> Date: Sat Jul 4 11:20:38 2020 -0500 Add additional get_freq if freq > 100MHz to update cache This covers rigs that round VHF/UHF freqs to different intervals https://github.com/Hamlib/Hamlib/issues/334 diff --git a/src/rig.c b/src/rig.c index 6cf1cd80..46d524a1 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1362,6 +1362,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) // we'll try this all the time and if it works out OK eliminate the #else if ((unsigned long long)freq % 100 != 0 // only need to do if < 100Hz interval + || freq > 100e6 // or if we are in the VHF and up range #if 0 // do we need to only do this when cache is turned on? 2020-07-02 W9MDB && rig->state.cache.timeout_ms > 0 commit 5ebb95bb43bc025a0a3e81a8c534f6e3e2da6e63 Author: Michael Black W9MDB <mdb...@ya...> Date: Sat Jul 4 07:21:02 2020 -0500 Add testnet.c for testing IPV4/IPV6 address/port combinations diff --git a/tests/testnet.c b/tests/testnet.c new file mode 100644 index 00000000..ab11f0dd --- /dev/null +++ b/tests/testnet.c @@ -0,0 +1,154 @@ +/* Test network address variations in hamlib */ +#include <stdlib.h> +#include <stdio.h> /* Standard input/output definitions */ +#include <string.h> /* String function definitions */ +#include <unistd.h> /* UNIX standard function definitions */ +#include <fcntl.h> /* File control definitions */ +#include <errno.h> /* Error number definitions */ +#include <sys/time.h> +#include <sys/types.h> +#include <signal.h> + +#define HAVE_NETINET_IN_H +#define HAVE_NETDB_H +#define HAVE_ARPA_INET_H + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#ifdef HAVE_NETDB_H +# include <netdb.h> +#endif + +#ifdef HAVE_ARPA_INET_H +# include <arpa/inet.h> +#endif + +int rig_network_addr(char *hoststr, char *portstr) +{ + + struct in6_addr serveraddr; + struct addrinfo hints, *res; + int status; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + + + status = getaddrinfo(hoststr, portstr, &hints, &res); + + if (status == 0 && res->ai_family == AF_INET6) + { + printf("Using IPV6 for %s:%s\n", hoststr, portstr); + } + else if (status == 0) + { + printf("Using IPV4 for %s:%s\n", hoststr, portstr); + } + + if (status != 0) + { + printf("%s: cannot get host \"%s\": %s\n", + __func__, + hoststr, + gai_strerror(errno)); + return 1; + } + + status = inet_pton(AF_INET, hoststr, &serveraddr); + + if (status != 1) /* not valid IPv4 address, maybe IPV6? */ + { + status = inet_pton(AF_INET6, hoststr, &serveraddr); + + if (status != 1) /* nope */ + { + return 1; + } + } + + return 0; +} + +int test_host(char *hoststr, char host[256], char port[6]) +{ + int status; + char host2[256], port2[6]; + status = parse_hoststr(hoststr, host2, port2); + + printf("---------------------\n"); + + if (status == 0) + { + if (strcmp(host, host2) || strcmp(port, port2)) + { + printf("%s: Mismatch, expected host=%s, port=%s, got host=%s, port=%s\n", + __func__, + host, port, host2, port2); + return -1; + } + else + { + rig_network_addr(host, port); + } + + printf("%s: %s, host=%s, port=%s\n", __func__, hoststr, host, port); + return 0; + } + else + { + printf("%s: ERROR!! %s, host=%s, port=%s\n", __func__, hoststr, host, port); + return -1; + } +} + +int +main(int argc, char *argv[]) +{ + // IPV4 + test_host("127.0.0.1", "127.0.0.1", ""); + test_host("127.0.0.1:4532", "127.0.0.1", "4532"); + test_host("192.168.1.1", "192.168.1.1", ""); + test_host("192.168.1.1:4532", "192.168.1.1", "4532"); + test_host("mdblack-VirtualBox", "mdblack-VirtualBox", ""); + test_host("mdblack-VirtualBox:4532", "mdblack-VirtualBox", "4532"); + test_host("localhost", "localhost", ""); + test_host("localhost:4532", "localhost", "4532"); + // IPV6 with brackets + test_host("[fe80::e034:55ef:ce2a:dc83]", "fe80::e034:55ef:ce2a:dc83", ""); + test_host("[fe80::e034:55ef:ce2a:dc83]:4532", "fe80::e034:55ef:ce2a:dc83", + "4532"); + + test_host("fe80::e034:55ef:ce2a:dc83", "fe80::e034:55ef:ce2a:dc83", ""); + test_host("fe80::e034:55ef:ce2a:dc83:4532", "fe80::e034:55ef:ce2a:dc83", + "4532"); + test_host("fe80:e034:55ef:ce2a:dc83:1234:5678:9abc", + "fe80:e034:55ef:ce2a:dc83:1234:5678:9abc", ""); + test_host("fe80:e034:55ef:ce2a:dc83:1234:5678:9abc:4532", + "fe80:e034:55ef:ce2a:dc83:1234:5678:9abc", + "4532"); + test_host("::1", "::1", ""); + test_host("::1:4532", "::1", "4532"); + +#if 1 // server side addresses with IPV6 + test_host("fe80::e034:55ef:ce2a:dc83%eth0", "fe80::e034:55ef:ce2a:dc83%eth0", + ""); + test_host("[fe80::e034:55ef:ce2a:dc83%1]", "fe80::e034:55ef:ce2a:dc83%1", ""); + test_host("[fe80::e034:55ef:ce2a:dc83%1]:4532", "fe80::e034:55ef:ce2a:dc83%1", + "4532"); + test_host("fe80::e034:55ef:ce2a:dc83%eth0:4532", + "fe80::e034:55ef:ce2a:dc83%eth0", "4532"); + test_host("fe80::e034:55ef:ce2a:dc83%1", "fe80::e034:55ef:ce2a:dc83%1", ""); + test_host("fe80::e034:55ef:ce2a:dc83%1:4532", "fe80::e034:55ef:ce2a:dc83%1", + "4532"); + test_host("[fe80::e034:55ef:ce2a:dc83%eth0]", + "fe80::e034:55ef:ce2a:dc83%eth0", ""); + test_host("[fe80::e034:55ef:ce2a:dc83%eth0]:4532", + "fe80::e034:55ef:ce2a:dc83%eth0", "4532"); +#endif + + return 0; +} commit ed3a26296dc34913dab7ca21426930cbcb436c84 Author: Michael Black W9MDB <mdb...@ya...> Date: Sat Jul 4 07:17:45 2020 -0500 Fix cppcheck warnings diff --git a/tests/memcsv.c b/tests/memcsv.c index fe14ddd1..ce53b7ac 100644 --- a/tests/memcsv.c +++ b/tests/memcsv.c @@ -290,7 +290,7 @@ static char *mystrtok(char *s, char delim) { } - if (str[ pos + 1 ] == '\0') + if (str && str[ pos + 1 ] == '\0') { return NULL; } @@ -1038,6 +1038,11 @@ int find_on_list(char **list, char *what) return -1; } + if (!list[i]) + { + return -1; + } + while (list[i] != NULL) { if (strcmp(list[i], what) == 0) @@ -1049,13 +1054,5 @@ int find_on_list(char **list, char *what) i++; } } - - if (!list[i]) - { - return -1; - } - else - { - return i; - } + return i; } ----------------------------------------------------------------------- Summary of changes: src/rig.c | 1 + tests/memcsv.c | 17 +++---- tests/testnet.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 tests/testnet.c hooks/post-receive -- Hamlib -- Ham radio control libraries |