diff options
author | shurd <shurd@FreeBSD.org> | 2017-04-16 11:12:08 +0800 |
---|---|---|
committer | shurd <shurd@FreeBSD.org> | 2017-04-16 11:12:08 +0800 |
commit | f2cf545765e91138089c5afa3b260b8a6ebca701 (patch) | |
tree | a4e699822fd7d8495b61938732a4e9ba440d7af3 /comms/hamlib | |
parent | f1312c5de919732ba0c1d688f5b73ebded3e64c9 (diff) | |
download | freebsd-ports-gnome-f2cf545765e91138089c5afa3b260b8a6ebca701.tar.gz freebsd-ports-gnome-f2cf545765e91138089c5afa3b260b8a6ebca701.tar.zst freebsd-ports-gnome-f2cf545765e91138089c5afa3b260b8a6ebca701.zip |
Small fixes for rig type 2
1) Disable Nagle on the socket since all queries are sent as a single
string
2) Stop using sizeof("\n") to get the length of the string "\n"
These need to be submitted upstream as well.
Diffstat (limited to 'comms/hamlib')
-rw-r--r-- | comms/hamlib/Makefile | 1 | ||||
-rw-r--r-- | comms/hamlib/files/patch-dummy_netrigctl.c | 177 | ||||
-rw-r--r-- | comms/hamlib/files/patch-src_network.c | 29 |
3 files changed, 207 insertions, 0 deletions
diff --git a/comms/hamlib/Makefile b/comms/hamlib/Makefile index 1d719e582399..e8b42dc7d9d3 100644 --- a/comms/hamlib/Makefile +++ b/comms/hamlib/Makefile @@ -3,6 +3,7 @@ PORTNAME= hamlib PORTVERSION= 3.1 +PORTREVISION= 1 CATEGORIES= comms hamradio MASTER_SITES= SF diff --git a/comms/hamlib/files/patch-dummy_netrigctl.c b/comms/hamlib/files/patch-dummy_netrigctl.c new file mode 100644 index 000000000000..a75f3b4ee373 --- /dev/null +++ b/comms/hamlib/files/patch-dummy_netrigctl.c @@ -0,0 +1,177 @@ +--- dummy/netrigctl.c.orig 2017-04-16 02:56:42 UTC ++++ dummy/netrigctl.c +@@ -54,7 +54,7 @@ static int netrigctl_transaction(RIG *ri + if (ret != RIG_OK) + return ret; + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret < 0) + return ret; + +@@ -87,18 +87,18 @@ static int netrigctl_open(RIG *rig) + if (prot_ver < RIGCTLD_PROT_VER) + return -RIG_EPROTO; + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->itu_region = atoi(buf); + + for (i=0; i<FRQRANGESIZ; i++) { +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -117,7 +117,7 @@ static int netrigctl_open(RIG *rig) + break; + } + for (i=0; i<FRQRANGESIZ; i++) { +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -136,7 +136,7 @@ static int netrigctl_open(RIG *rig) + break; + } + for (i=0; i<TSLSTSIZ; i++) { +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -150,7 +150,7 @@ static int netrigctl_open(RIG *rig) + } + + for (i=0; i<FLTLSTSIZ; i++) { +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -168,31 +168,31 @@ static int netrigctl_open(RIG *rig) + chan_t chan_list[CHANLSTSIZ]; /*!< Channel list, zero ended */ + #endif + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->max_rit = atol(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->max_xit = atol(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->max_ifshift = atol(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->announces = atoi(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -205,7 +205,7 @@ chan_t chan_list[CHANLSTSIZ]; /*!< Chann + ret = 0; + rs->preamp[ret] = RIG_DBLST_END; + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -218,37 +218,37 @@ chan_t chan_list[CHANLSTSIZ]; /*!< Chann + ret = 0; + rs->attenuator[ret] = RIG_DBLST_END; + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->has_get_func = strtol(buf, NULL, 0); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->has_set_func = strtol(buf, NULL, 0); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->has_get_level = strtol(buf, NULL, 0); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->has_set_level = strtol(buf, NULL, 0); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + + rs->has_get_parm = strtol(buf, NULL, 0); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -354,7 +354,7 @@ static int netrigctl_get_mode(RIG *rig, + if (ret > 0 && buf[ret-1]=='\n') buf[ret-1] = '\0'; /* chomp */ + *mode = rig_parse_mode(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -761,7 +761,7 @@ static int netrigctl_get_split_mode(RIG + if (ret > 0 && buf[ret-1]=='\n') buf[ret-1] = '\0'; /* chomp */ + *tx_mode = rig_parse_mode(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + +@@ -804,7 +804,7 @@ static int netrigctl_get_split_vfo(RIG * + + *split = atoi(buf); + +- ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", sizeof("\n")); ++ ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); + if (ret <= 0) + return (ret < 0) ? ret : -RIG_EPROTO; + diff --git a/comms/hamlib/files/patch-src_network.c b/comms/hamlib/files/patch-src_network.c new file mode 100644 index 000000000000..dc6b46a502b7 --- /dev/null +++ b/comms/hamlib/files/patch-src_network.c @@ -0,0 +1,29 @@ +--- src/network.c.orig 2016-12-31 20:01:25 UTC ++++ src/network.c +@@ -48,6 +48,7 @@ + + #ifdef HAVE_NETINET_IN_H + #include <netinet/in.h> ++#include <netinet/tcp.h> + #endif + #if HAVE_NETDB_H + #include <netdb.h> +@@ -117,6 +118,7 @@ int network_open(hamlib_port_t *rp, int + { + int fd; /* File descriptor for the port */ + int status; ++ int flag; + struct addrinfo hints, *res, *saved_res; + char *hoststr = NULL, *portstr = NULL, *bracketstr1, *bracketstr2; + char hostname[FILPATHLEN]; +@@ -202,6 +204,10 @@ int network_open(hamlib_port_t *rp, int + return -RIG_EIO; + } + ++ /* Disable Nagle */ ++ flag = 1; ++ setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)); ++ + if ((status = connect(fd, res->ai_addr, res->ai_addrlen)) == 0) + { + break; |