summaryrefslogtreecommitdiff
path: root/ccast
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-08-23 12:17:05 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-08-23 12:17:05 +0200
commitc0b89ac5bfb90835ef01573267020e42d4fe070c (patch)
tree733c16852d964d84b7565af4bdaff0bcca901b88 /ccast
parent094535c010320967639e8e86f974d878e80baa72 (diff)
Imported Upstream version 1.8.0upstream/1.8.0
Diffstat (limited to 'ccast')
-rwxr-xr-x[-rw-r--r--]ccast/Jamfile18
-rwxr-xr-x[-rw-r--r--]ccast/License.txt0
-rw-r--r--ccast/afiles4
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/Jamfile2
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/aes.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/asn1.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/axTLS_config.h (renamed from ccast/axTLS/config.h)0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/axTLS_version.h (renamed from ccast/axTLS/version.h)0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/bigint.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/bigint.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/bigint_impl.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/cert.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/crypto.h2
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/crypto_misc.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/crypto_misc.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/gen_cert.c2
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/hmac.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/loader.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/md2.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/md5.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/openssl.c2
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/os_int.h3
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/os_port.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/os_port.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/p12.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/private_key.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/rc4.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/rsa.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/sha1.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/ssl.h0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/temp0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/tls1.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/tls1.h4
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/tls1_clnt.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/tls1_svr.c0
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/x509.c0
-rwxr-xr-x[-rw-r--r--]ccast/cast_channel.proto0
-rwxr-xr-x[-rw-r--r--]ccast/ccast.c186
-rwxr-xr-x[-rw-r--r--]ccast/ccast.h0
-rwxr-xr-x[-rw-r--r--]ccast/ccmdns.c200
-rwxr-xr-x[-rw-r--r--]ccast/ccmdns.h0
-rwxr-xr-x[-rw-r--r--]ccast/ccmes.c52
-rwxr-xr-x[-rw-r--r--]ccast/ccmes.h0
-rwxr-xr-x[-rw-r--r--]ccast/ccpacket.c208
-rwxr-xr-x[-rw-r--r--]ccast/ccpacket.h0
-rwxr-xr-x[-rw-r--r--]ccast/cctest.c2
-rwxr-xr-x[-rw-r--r--]ccast/chan/cast_channel.pb-c.c0
-rwxr-xr-x[-rw-r--r--]ccast/chan/cast_channel.pb-c.h0
-rwxr-xr-x[-rw-r--r--]ccast/chan/protobuf-c.c0
-rwxr-xr-x[-rw-r--r--]ccast/chan/protobuf-c.h0
-rwxr-xr-x[-rw-r--r--]ccast/dpat.c4
-rwxr-xr-x[-rw-r--r--]ccast/filt.c0
52 files changed, 391 insertions, 298 deletions
diff --git a/ccast/Jamfile b/ccast/Jamfile
index ff216ff..3d03a2f 100644..100755
--- a/ccast/Jamfile
+++ b/ccast/Jamfile
@@ -9,9 +9,12 @@ if $(NT) {
DEFINES += WIN32 ;
}
-SubInclude axTLS ;
+if $(SSLLIB) {
+ DEFINES += USING_AXTLS ; # Trigger right #include
+ SubInclude axTLS ;
+}
-HDRS = ../h ../numlib ../spectro axTLS chan ../yajl ;
+HDRS = ../h ../numlib ../spectro $(SSLINC) chan ../yajl ;
# We create the channel protocol buffers implementation files thus:
# /src/protobuf_c/protobuf.exe --c_out=chan cast_channel.proto
@@ -21,14 +24,19 @@ CHAN_SRC =
chan/protobuf-c.c
;
+Objects ccmes.c $(CHAN_SRC) : : : axTLS ;
+Objects ccmdns.c ccpacket.c ccast.c dpat.c ;
+
# ccast library
-Library libccast : ccmdns.c ccpacket.c ccmes.c ccast.c $(CHAN_SRC) dpat.c ;
+LibraryFromObjects libccast : ccmdns ccpacket ccmes ccast $(CHAN_SRC) dpat ;
-LINKLIBS = ./libccast axTLS/libaxtls ../yajl/libyajl ../numlib/libnum ../spectro/libconv ;
+LINKLIBS = ./libccast $(SSLLIB) ../yajl/libyajl ../numlib/libnum ../spectro/libconv ;
+
+# If run in ccast dir, the following don't link from clean,
+# due to the _NormPaths rule not resolving ../ccast into .
# Test harness
#Main cctest : cctest.c ;
Main filt : filt.c ;
-
MainVariant dpat : dpat.c : : STANDALONE_TEST ;
diff --git a/ccast/License.txt b/ccast/License.txt
index a871fcf..a871fcf 100644..100755
--- a/ccast/License.txt
+++ b/ccast/License.txt
diff --git a/ccast/afiles b/ccast/afiles
index 0f8ffda..3d81ff0 100644
--- a/ccast/afiles
+++ b/ccast/afiles
@@ -22,7 +22,7 @@ axTLS/bigint.c
axTLS/bigint.h
axTLS/bigint_impl.h
axTLS/cert.h
-axTLS/config.h
+axTLS/axTLS_config.h
axTLS/crypto.h
axTLS/crypto_misc.c
axTLS/crypto_misc.h
@@ -46,7 +46,7 @@ axTLS/tls1.c
axTLS/tls1.h
axTLS/tls1_clnt.c
axTLS/tls1_svr.c
-axTLS/version.h
+axTLS/axTLS_version.h
axTLS/x509.c
chan/cast_channel.pb-c.c
chan/cast_channel.pb-c.h
diff --git a/ccast/axTLS/Jamfile b/ccast/axTLS/Jamfile
index 2e8b027..9a8aff4 100644..100755
--- a/ccast/axTLS/Jamfile
+++ b/ccast/axTLS/Jamfile
@@ -3,11 +3,9 @@ PREF_CCFLAGS = $(CCOPTFLAG) ; # Turn optimisation on
#PREF_CCFLAGS = $(CCDEBUGFLAG) ; # Debugging flags
PREF_LINKFLAGS = $(LINKDEBUGFLAG) ;
-# Copy the configuration file
if $(NT) {
DEFINES += WIN32 ;
} else {
-# File conf.h : tiffconf.vc.h ;
if $(OS) = MACOSX {
} else if $(OS) = FREEBSD {
} else {
diff --git a/ccast/axTLS/aes.c b/ccast/axTLS/aes.c
index 9b07e27..9b07e27 100644..100755
--- a/ccast/axTLS/aes.c
+++ b/ccast/axTLS/aes.c
diff --git a/ccast/axTLS/asn1.c b/ccast/axTLS/asn1.c
index b082275..b082275 100644..100755
--- a/ccast/axTLS/asn1.c
+++ b/ccast/axTLS/asn1.c
diff --git a/ccast/axTLS/config.h b/ccast/axTLS/axTLS_config.h
index ffda4e3..ffda4e3 100644..100755
--- a/ccast/axTLS/config.h
+++ b/ccast/axTLS/axTLS_config.h
diff --git a/ccast/axTLS/version.h b/ccast/axTLS/axTLS_version.h
index e8158cc..e8158cc 100644..100755
--- a/ccast/axTLS/version.h
+++ b/ccast/axTLS/axTLS_version.h
diff --git a/ccast/axTLS/bigint.c b/ccast/axTLS/bigint.c
index e9ca04c..e9ca04c 100644..100755
--- a/ccast/axTLS/bigint.c
+++ b/ccast/axTLS/bigint.c
diff --git a/ccast/axTLS/bigint.h b/ccast/axTLS/bigint.h
index 2966a3e..2966a3e 100644..100755
--- a/ccast/axTLS/bigint.h
+++ b/ccast/axTLS/bigint.h
diff --git a/ccast/axTLS/bigint_impl.h b/ccast/axTLS/bigint_impl.h
index 820620d..820620d 100644..100755
--- a/ccast/axTLS/bigint_impl.h
+++ b/ccast/axTLS/bigint_impl.h
diff --git a/ccast/axTLS/cert.h b/ccast/axTLS/cert.h
index 30c7b65..30c7b65 100644..100755
--- a/ccast/axTLS/cert.h
+++ b/ccast/axTLS/cert.h
diff --git a/ccast/axTLS/crypto.h b/ccast/axTLS/crypto.h
index 8a314a3..bf2c187 100644..100755
--- a/ccast/axTLS/crypto.h
+++ b/ccast/axTLS/crypto.h
@@ -39,7 +39,7 @@
extern "C" {
#endif
-#include "config.h"
+#include "axTLS_config.h"
#include "bigint_impl.h"
#include "bigint.h"
diff --git a/ccast/axTLS/crypto_misc.c b/ccast/axTLS/crypto_misc.c
index f43fd04..f43fd04 100644..100755
--- a/ccast/axTLS/crypto_misc.c
+++ b/ccast/axTLS/crypto_misc.c
diff --git a/ccast/axTLS/crypto_misc.h b/ccast/axTLS/crypto_misc.h
index acb5c73..acb5c73 100644..100755
--- a/ccast/axTLS/crypto_misc.h
+++ b/ccast/axTLS/crypto_misc.h
diff --git a/ccast/axTLS/gen_cert.c b/ccast/axTLS/gen_cert.c
index d5cb4d5..fa22c4e 100644..100755
--- a/ccast/axTLS/gen_cert.c
+++ b/ccast/axTLS/gen_cert.c
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#include "axTLS_config.h"
#ifdef CONFIG_SSL_GENERATE_X509_CERT
#include <string.h>
diff --git a/ccast/axTLS/hmac.c b/ccast/axTLS/hmac.c
index 24a04d7..24a04d7 100644..100755
--- a/ccast/axTLS/hmac.c
+++ b/ccast/axTLS/hmac.c
diff --git a/ccast/axTLS/loader.c b/ccast/axTLS/loader.c
index 92167be..92167be 100644..100755
--- a/ccast/axTLS/loader.c
+++ b/ccast/axTLS/loader.c
diff --git a/ccast/axTLS/md2.c b/ccast/axTLS/md2.c
index dee909a..dee909a 100644..100755
--- a/ccast/axTLS/md2.c
+++ b/ccast/axTLS/md2.c
diff --git a/ccast/axTLS/md5.c b/ccast/axTLS/md5.c
index 7f50713..7f50713 100644..100755
--- a/ccast/axTLS/md5.c
+++ b/ccast/axTLS/md5.c
diff --git a/ccast/axTLS/openssl.c b/ccast/axTLS/openssl.c
index e700436..e3f8972 100644..100755
--- a/ccast/axTLS/openssl.c
+++ b/ccast/axTLS/openssl.c
@@ -36,7 +36,7 @@
* port is.
*/
-#include "config.h"
+#include "axTLS_config.h"
#ifdef CONFIG_OPENSSL_COMPATIBLE
#include <stdlib.h>
diff --git a/ccast/axTLS/os_int.h b/ccast/axTLS/os_int.h
index 4918111..8ae5878 100644..100755
--- a/ccast/axTLS/os_int.h
+++ b/ccast/axTLS/os_int.h
@@ -33,7 +33,8 @@ extern "C" {
#if (__STDC_VERSION__ >= 199901L) /* C99 */ \
|| defined(_STDINT_H_) || defined(_STDINT_H) \
- || defined(_SYS_TYPES_H)
+ || defined(_SYS_TYPES_H) \
+ || (defined(__APPLE__) && defined(__POWERPC__))
#include <stdint.h>
diff --git a/ccast/axTLS/os_port.c b/ccast/axTLS/os_port.c
index 0bb74f8..0bb74f8 100644..100755
--- a/ccast/axTLS/os_port.c
+++ b/ccast/axTLS/os_port.c
diff --git a/ccast/axTLS/os_port.h b/ccast/axTLS/os_port.h
index 8ede75a..8ede75a 100644..100755
--- a/ccast/axTLS/os_port.h
+++ b/ccast/axTLS/os_port.h
diff --git a/ccast/axTLS/p12.c b/ccast/axTLS/p12.c
index 2bafaf7..2bafaf7 100644..100755
--- a/ccast/axTLS/p12.c
+++ b/ccast/axTLS/p12.c
diff --git a/ccast/axTLS/private_key.h b/ccast/axTLS/private_key.h
index ce7985c..ce7985c 100644..100755
--- a/ccast/axTLS/private_key.h
+++ b/ccast/axTLS/private_key.h
diff --git a/ccast/axTLS/rc4.c b/ccast/axTLS/rc4.c
index 12a1211..12a1211 100644..100755
--- a/ccast/axTLS/rc4.c
+++ b/ccast/axTLS/rc4.c
diff --git a/ccast/axTLS/rsa.c b/ccast/axTLS/rsa.c
index e707f2b..e707f2b 100644..100755
--- a/ccast/axTLS/rsa.c
+++ b/ccast/axTLS/rsa.c
diff --git a/ccast/axTLS/sha1.c b/ccast/axTLS/sha1.c
index 1082733..1082733 100644..100755
--- a/ccast/axTLS/sha1.c
+++ b/ccast/axTLS/sha1.c
diff --git a/ccast/axTLS/ssl.h b/ccast/axTLS/ssl.h
index 3f001da..3f001da 100644..100755
--- a/ccast/axTLS/ssl.h
+++ b/ccast/axTLS/ssl.h
diff --git a/ccast/axTLS/temp b/ccast/axTLS/temp
index 859e8be..859e8be 100644..100755
--- a/ccast/axTLS/temp
+++ b/ccast/axTLS/temp
diff --git a/ccast/axTLS/tls1.c b/ccast/axTLS/tls1.c
index b635263..b635263 100644..100755
--- a/ccast/axTLS/tls1.c
+++ b/ccast/axTLS/tls1.c
diff --git a/ccast/axTLS/tls1.h b/ccast/axTLS/tls1.h
index 0086302..14c6382 100644..100755
--- a/ccast/axTLS/tls1.h
+++ b/ccast/axTLS/tls1.h
@@ -40,8 +40,8 @@
extern "C" {
#endif
-#include "version.h"
-#include "config.h"
+#include "axTLS_version.h"
+#include "axTLS_config.h"
#include "os_int.h"
#include "crypto.h"
#include "crypto_misc.h"
diff --git a/ccast/axTLS/tls1_clnt.c b/ccast/axTLS/tls1_clnt.c
index cb8b990..cb8b990 100644..100755
--- a/ccast/axTLS/tls1_clnt.c
+++ b/ccast/axTLS/tls1_clnt.c
diff --git a/ccast/axTLS/tls1_svr.c b/ccast/axTLS/tls1_svr.c
index 51c9d76..51c9d76 100644..100755
--- a/ccast/axTLS/tls1_svr.c
+++ b/ccast/axTLS/tls1_svr.c
diff --git a/ccast/axTLS/x509.c b/ccast/axTLS/x509.c
index c2ca49f..c2ca49f 100644..100755
--- a/ccast/axTLS/x509.c
+++ b/ccast/axTLS/x509.c
diff --git a/ccast/cast_channel.proto b/ccast/cast_channel.proto
index d321eaf..d321eaf 100644..100755
--- a/ccast/cast_channel.proto
+++ b/ccast/cast_channel.proto
diff --git a/ccast/ccast.c b/ccast/ccast.c
index 5c1ed7b..981b5ae 100644..100755
--- a/ccast/ccast.c
+++ b/ccast/ccast.c
@@ -27,20 +27,19 @@
#else
#include "numsup.h"
#endif
-#include "yajl.h"
#include "conv.h"
#include "base64.h"
+#include "yajl.h"
#include "ccpacket.h"
#include "ccmes.h"
#include "ccast.h"
-#undef DEBUG
-#undef CHECK_JSON
+#undef DEBUG /* [und] */
+#undef USE_DEF_RECIEVER /* [und] */
+#undef CHECK_JSON /* [und] */
#ifdef DEBUG
-# define dbgo stdout
-# define DBG(xxx) fprintf xxx ;
-void cc_dump_bytes(FILE *fp, char *pfx, unsigned char *buf, int len);
+# define DBG(xxx) a1logd xxx ;
#else
# define DBG(xxx) ;
#endif /* DEBUG */
@@ -59,8 +58,8 @@ static void check_json(char *mesbuf) {
char errbuf[1024];
if ((node = yajl_tree_parse(mesbuf, errbuf, sizeof(errbuf))) == NULL) {
- fprintf(dbgo,"yajl_tree_parse of send message failed with '%s'\n",errbuf);
- fprintf(dbgo,"JSON = '%s'\n",mesbuf);
+ fprintf(g_log,0,"yajl_tree_parse of send message failed with '%s'\n",errbuf);
+ fprintf(g_log,0,"JSON = '%s'\n",mesbuf);
exit(1);
}
yajl_tree_free(node);
@@ -85,7 +84,7 @@ static int cc_rec_thread(void *context) {
yajl_val tyn, idn;
int rv = 0;
- DBG((dbgo,"ccthread starting\n"))
+ DBG((g_log,0,"ccthread starting\n"))
ccmes_init(&mes);
ccmes_init(&smes);
@@ -101,21 +100,21 @@ static int cc_rec_thread(void *context) {
if ((merr = sv->receive(sv, &mes)) != ccmessv_OK) {
if (merr == ccmessv_timeout) {
- DBG((dbgo,"ccthread: got receive timeout (OK)\n"))
+ DBG((g_log,0,"ccthread: got receive timeout (OK)\n"))
msec_sleep(100);
} else {
- DBG((dbgo,"ccthread: messv->receive failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"ccthread: messv->receive failed with '%s'\n",ccmessv_emes(merr)))
msec_sleep(100);
#ifdef NEVER
//This won't work - we need to re-join the session etc.,
if (p->messv->pk->reconnect(p->messv->pk)) {
- DBG((dbgo,"ccthread: reconnect after error failed\n"))
+ DBG((g_log,0,"ccthread: reconnect after error failed\n"))
rv = 1;
break;
}
#endif
if (errc++ > 20) { /* Too many failures */
- DBG((dbgo,"ccthread: too many errors - giving up\n"))
+ DBG((g_log,0,"ccthread: too many errors - giving up\n"))
/* Hmm. The connection seems to have gone down ? */
rv = 1;
break;
@@ -130,13 +129,13 @@ static int cc_rec_thread(void *context) {
if (mes.mtype != NULL && strcmp(mes.mtype, "CLOSE") == 0) {
/* Hmm. That indicates an error */
- DBG((dbgo,"ccthread: got CLOSE message - giving up\n"))
+ DBG((g_log,0,"ccthread: got CLOSE message - giving up\n"))
rv = 1;
break;
} else if (mes.mtype != NULL && strcmp(mes.mtype, "PING") == 0) {
if ((merr = sv->send(sv, &smes)) != ccmessv_OK) {
- DBG((dbgo,"ccthread: send PONG failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"ccthread: send PONG failed with '%s'\n",ccmessv_emes(merr)))
}
/* Got reply - add to linked list */
@@ -144,12 +143,12 @@ static int cc_rec_thread(void *context) {
int found;
#ifdef DEBUG
if (p->w_rq) {
- DBG((dbgo,"ccthread: waiting for ns '%s' and mes->ns '%s'\n",
+ DBG((g_log,0,"ccthread: waiting for ns '%s' and mes->ns '%s'\n",
p->w_rqns, mes.namespace))
- DBG((dbgo,"ccthread: waiting for id %d and mes->id %d\n",
+ DBG((g_log,0,"ccthread: waiting for id %d and mes->id %d\n",
p->w_rqid, mes.rqid))
} else {
- DBG((dbgo,"ccthread: has no client waiting\n"))
+ DBG((g_log,0,"ccthread: has no client waiting\n"))
}
#endif
@@ -161,18 +160,18 @@ static int cc_rec_thread(void *context) {
if (found || mes.rqid != 0) {
ccmes *nmes;
if ((nmes = (ccmes *)calloc(1, sizeof(ccmes))) == NULL) {
- DBG((dbgo,"ccthread: calloc failed\n"))
+ DBG((g_log,0,"ccthread: calloc failed\n"))
} else {
ccmes_transfer(nmes, &mes);
- DBG((dbgo,"ccthread: adding message type '%s' id %d to list (found %d)\n",nmes->mtype,nmes->rqid,found))
+ DBG((g_log,0,"ccthread: adding message type '%s' id %d to list (found %d)\n",nmes->mtype,nmes->rqid,found))
amutex_lock(p->rlock); /* We're modifying p->rmes list */
nmes->next = p->rmes; /* Put at start of list */
p->rmes = nmes;
/* Client is waiting for this */
if (found) {
- DBG((dbgo,"ccthread: client was waiting for this message\n"))
+ DBG((g_log,0,"ccthread: client was waiting for this message\n"))
acond_signal(p->rcond);
}
amutex_unlock(p->rlock); /* We've finished modifying p->rmes list */
@@ -183,7 +182,7 @@ static int cc_rec_thread(void *context) {
/* Got anonomous status message */
ccmes_empty(&mes);
}
- DBG((dbgo, "ccthread: about to exit - stop = %d\n",p->stop))
+ DBG((g_log,0, "ccthread: about to exit - stop = %d\n",p->stop))
/* We're bailing out or stopping */
p->stopped = 1;
@@ -191,12 +190,12 @@ static int cc_rec_thread(void *context) {
/* Release client if it was waiting */
amutex_lock(p->rlock);
if (p->w_rq != 0) {
- DBG((dbgo,"ccthread: client was waiting for message - abort it\n"))
+ DBG((g_log,0,"ccthread: client was waiting for message - abort it\n"))
acond_signal(p->rcond);
}
amutex_unlock(p->rlock);
- DBG((dbgo,"ccthread returning %d\n",rv))
+ DBG((g_log,0,"ccthread returning %d\n",rv))
return rv;
}
@@ -211,14 +210,14 @@ static int get_a_reply_id(ccast *p, char *namespace, int rqid, ccmes *rmes, int
ccmes *mes, *xmes, *fmes = NULL;
int rv = 0;
- DBG((dbgo," get_a_reply_id getting namespace '%s' id %d\n",
+ DBG((g_log,0," get_a_reply_id getting namespace '%s' id %d\n",
namespace == NULL ? "(none)" : namespace, rqid))
amutex_lock(p->rlock); /* We're modifying p->rmes list */
if (p->stop || p->stopped) {
amutex_unlock(p->rlock); /* Allow thread to modify p->rmes list */
- DBG((dbgo," get_a_reply_id: thread is stopping or stopped\n"))
+ DBG((g_log,0," get_a_reply_id: thread is stopping or stopped\n"))
return 1;
}
@@ -253,29 +252,29 @@ static int get_a_reply_id(ccast *p, char *namespace, int rqid, ccmes *rmes, int
/* We need to wait until it turns up */
/* Allow thread to modify p->rmes list and signal us */
if (acond_timedwait(p->rcond, p->rlock, to) != 0) {
- DBG((dbgo," get_a_reply_id timed out after %f secs\n",to/1000.0))
+ DBG((g_log,0," get_a_reply_id timed out after %f secs\n",to/1000.0))
rv = 2;
break;
}
#else
acond_wait(p->rcond, p->rlock);
#endif
- DBG((dbgo," get_a_reply_id got released\n"))
+ DBG((g_log,0," get_a_reply_id got released\n"))
}
p->w_rq = 0; /* We're not looking for anything now */
amutex_unlock(p->rlock); /* Allow thread to modify p->rmes list */
if (p->stop || p->stopped) {
- DBG((dbgo," get_a_reply_id failed because thread is stopped or stopping\n"))
+ DBG((g_log,0," get_a_reply_id failed because thread is stopped or stopping\n"))
ccmes_init(rmes);
return 1;
}
if (rv != 0) {
- DBG((dbgo," get_a_reply_id returning error %d\n",rv))
+ DBG((g_log,0," get_a_reply_id returning error %d\n",rv))
} else {
ccmes_transfer(rmes, fmes);
- DBG((dbgo," get_a_reply_id returning type '%s' id %d\n",rmes->mtype,rmes->rqid))
+ DBG((g_log,0," get_a_reply_id returning type '%s' id %d\n",rmes->mtype,rmes->rqid))
}
return rv;
@@ -288,7 +287,7 @@ void ccast_delete_from_cleanup_list(ccast *p);
/* Cleanup any created objects */
static void cleanup_ccast(ccast *p) {
- DBG((dbgo," cleanup_ccast() called\n"))
+ DBG((g_log,0," cleanup_ccast() called\n"))
p->stop = 1; /* Tell the thread to exit */
@@ -336,7 +335,7 @@ static void cleanup_ccast(ccast *p) {
static void shutdown_ccast(ccast *p) {
ccmes mes;
- DBG((dbgo," shutdown_ccast() called\n"))
+ DBG((g_log,0," shutdown_ccast() called\n"))
ccmes_init(&mes);
@@ -428,19 +427,19 @@ static int start_ccast(ccast *p) {
/* Hmm. Could put creation of pk inside new_ccmessv() ? */
if ((pk = new_ccpacket()) == NULL) {
- DBG((dbgo,"start_ccast: new_ccpacket() failed\n"))
+ DBG((g_log,0,"start_ccast: new_ccpacket() failed\n"))
goto retry;
}
if ((perr = pk->connect(pk, p->id.ip, 8009)) != ccpacket_OK) {
- DBG((dbgo,"start_ccast: ccpacket connect failed with '%s'\n",ccpacket_emes(perr)))
+ DBG((g_log,0,"start_ccast: ccpacket connect failed with '%s'\n",ccpacket_emes(perr)))
goto retry;
}
- DBG((dbgo,"Got TLS connection to '%s\n'",p->id.name))
+ DBG((g_log,0,"Got TLS connection to '%s\n'",p->id.name))
if ((p->messv = new_ccmessv(pk)) == NULL) {
- DBG((dbgo,"start_ccast: new_ccmessv() failed\n"))
+ DBG((g_log,0,"start_ccast: new_ccmessv() failed\n"))
goto retry;
}
pk = NULL; /* Will get deleted with messv now */
@@ -452,7 +451,7 @@ static int start_ccast(ccast *p) {
mes.binary = 0;
mes.data = (ORD8 *)"{ \"type\": \"CONNECT\" }";
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"start_ccast: CONNECT failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"start_ccast: CONNECT failed with '%s'\n",ccmessv_emes(merr)))
goto retry;
}
@@ -460,7 +459,7 @@ static int start_ccast(ccast *p) {
/* We don't want to start this until the TLS negotiations and */
/* the synchronous ssl_readi()'s it uses are complete. */
if ((p->rmesth = new_athread(cc_rec_thread, (void *)p)) == NULL) {
- DBG((dbgo,"start_ccast: creating message thread failed\n"))
+ DBG((g_log,0,"start_ccast: creating message thread failed\n"))
goto retry;
}
@@ -469,7 +468,7 @@ static int start_ccast(ccast *p) {
mes.namespace = heartbeat_chan;
mes.data = (ORD8 *)"{ \"type\": \"PING\" }";
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"start_ccast: PING failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"start_ccast: PING failed with '%s'\n",ccmessv_emes(merr)))
return 1;
}
@@ -498,14 +497,14 @@ static int start_ccast(ccast *p) {
sprintf(mesbuf, "{ \"requestId\": %d, \"type\": \"LAUNCH\", \"appId\": \"%s\" }",
reqid, appid);
- DBG((dbgo,"start_ccast: about to do LAUNCH\n"))
+ DBG((g_log,0,"start_ccast: about to do LAUNCH\n"))
/* Launch the default application */
/* (Presumably we would use the com.google.cast.receiver channel */
/* for monitoring and controlling the reciever) */
mes.namespace = receiver_chan;
mes.data = (ORD8 *)mesbuf;
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"start_ccast: LAUNCH failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"start_ccast: LAUNCH failed with '%s'\n",ccmessv_emes(merr)))
goto retry;
}
@@ -516,7 +515,7 @@ static int start_ccast(ccast *p) {
/* Wait for a reply to the LAUNCH (15 sec) */
if (get_a_reply_id(p, receiver_chan, reqid, &rmes, 15000) != 0) {
- DBG((dbgo,"start_ccast: LAUNCH failed to get a reply\n"))
+ DBG((g_log,0,"start_ccast: LAUNCH failed to get a reply\n"))
goto retry;
}
@@ -530,7 +529,7 @@ static int start_ccast(ccast *p) {
|| strcmp(rmes.mtype, "LAUNCH_ERROR") != 0
|| rmes.tnode == NULL
|| (app+1) >= naps) {
- DBG((dbgo,"start_ccast: LAUNCH failed to get a RECEIVER_STATUS or LAUNCH ERROR reply\n"))
+ DBG((g_log,0,"start_ccast: LAUNCH failed to get a RECEIVER_STATUS or LAUNCH ERROR reply\n"))
ccmes_empty(&rmes);
goto retry;
}
@@ -538,33 +537,33 @@ static int start_ccast(ccast *p) {
/* Try the next application */
}
- DBG((dbgo,"start_ccast: LAUNCH soceeded, load delay = %d msec\n",p->load_delay))
+ DBG((g_log,0,"start_ccast: LAUNCH soceeded, load delay = %d msec\n",p->load_delay))
{
yajl_val idn, tpn;
if ((idn = yajl_tree_get_first(rmes.tnode, "sessionId", yajl_t_string)) == NULL
|| (tpn = yajl_tree_get_first(rmes.tnode, "transportId", yajl_t_string)) == NULL) {
- DBG((dbgo,"start_ccast: LAUNCH failed to get sessionId & transportId\n"))
+ DBG((g_log,0,"start_ccast: LAUNCH failed to get sessionId & transportId\n"))
ccmes_empty(&rmes);
goto retry;
}
- p->sessionId = strdup(YAJL_GET_STRING(idn));
- p->transportId = strdup(YAJL_GET_STRING(tpn));
+ p->sessionId = YAJL_GET_STRINGDUP(idn);
+ p->transportId = YAJL_GET_STRINGDUP(tpn);
if (p->sessionId == NULL || p->transportId == NULL) {
- DBG((dbgo,"start_ccast: strdup failed\n"))
+ DBG((g_log,0,"start_ccast: strdup failed\n"))
ccmes_empty(&rmes);
goto retry;
}
}
ccmes_empty(&rmes);
- DBG((dbgo,"### Got sessionId = '%s', transportId = '%s'\n",p->sessionId, p->transportId))
+ DBG((g_log,0,"### Got sessionId = '%s', transportId = '%s'\n",p->sessionId, p->transportId))
/* Connect up to the reciever media channels */
mes.destination_id = p->transportId;
mes.namespace = connection_chan;
mes.data = (ORD8 *)"{ \"type\": \"CONNECT\" }";
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"messv->send CONNECT failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"messv->send CONNECT failed with '%s'\n",ccmessv_emes(merr)))
goto retry;
}
@@ -586,11 +585,11 @@ static int start_ccast(ccast *p) {
}
if (tries >= maxtries) {
- DBG((dbgo,"Failed to start ChromeCast\n"))
+ DBG((g_log,0,"Failed to start ChromeCast\n"))
return 1;
}
- DBG((dbgo,"Succeeded in starting ChromeCast\n"))
+ DBG((g_log,0,"Succeeded in starting ChromeCast\n"))
ccast_install_signal_handlers(p);
@@ -613,11 +612,11 @@ static int get_direct_send(ccast *p) {
/* Create a new ChromeCast */
/* Return NULL on error */
ccast *new_ccast(ccast_id *id,
-int forcedef) {
+int forcedef) { // Force default reciever
ccast *p = NULL;
if ((p = (ccast *)calloc(1, sizeof(ccast))) == NULL) {
- DBG((dbgo, "new_ccast: calloc failed\n"))
+ DBG((g_log,0, "new_ccast: calloc failed\n"))
return NULL;
}
@@ -628,6 +627,9 @@ int forcedef) {
p->get_load_delay = get_load_delay;
p->get_direct_send = get_direct_send;
+#ifdef USE_DEF_RECIEVER
+ forcedef = 1;
+#endif
p->forcedef = forcedef;
ccast_id_copy(&p->id, id);
@@ -672,15 +674,15 @@ static int load_ccast(
size_t iilen = ilen;
firstid = lastid = reqid = ++p->requestId;
- DBG((dbgo,"##### load_ccast try %d/%d\n",i+1,maxtries))
+ DBG((g_log,0,"##### load_ccast try %d/%d\n",i+1,maxtries))
if (p->messv == NULL) {
- DBG((dbgo,"mes->send LOAD failed due to lost connection\n"))
+ DBG((g_log,0,"mes->send LOAD failed due to lost connection\n"))
} else {
if (url == NULL && !p->patgenrcv) {
- DBG((dbgo,"mes->send not given URL\n"))
+ DBG((g_log,0,"mes->send not given URL\n"))
return 1;
}
@@ -720,7 +722,7 @@ static int load_ccast(
check_json((char *)mes.data);
#endif
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
rv = 1;
goto retry; /* Failed */
}
@@ -733,7 +735,7 @@ static int load_ccast(
int dlen;
if ((mesbuf = malloc(1024 + EBASE64LEN(iilen))) == NULL) {
- DBG((dbgo,"mes->send malloc failed\n"))
+ DBG((g_log,0,"mes->send malloc failed\n"))
return 1;
}
@@ -742,7 +744,7 @@ static int load_ccast(
"{ \"contentId\": \"data:image/png;base64,",reqid);
ebase64(&dlen, cp, iibuf, iilen);
cp += dlen;
- DBG((dbgo,"base64 encoded PNG = %d bytes\n",dlen))
+ DBG((g_log,0,"base64 encoded PNG = %d bytes\n",dlen))
sprintf(cp, "|rgb(%d, %d, %d)|%f|%f|%f|%f\","
"\"streamType\": \"LIVE\",\"contentType\": \"text/plain\" } }",
(int)(bg[0] * 255.0 + 0.5), (int)(bg[1] * 255.0 + 0.5), (int)(bg[2] * 255.0 + 0.5),
@@ -757,7 +759,7 @@ static int load_ccast(
check_json((char *)mes.data);
#endif
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
free(mesbuf);
rv = 1;
goto retry; /* Failed */
@@ -773,7 +775,7 @@ static int load_ccast(
int dlen; /* Encoded length to send */
if ((mesbuf = malloc(61 * 1024)) == NULL) {
- DBG((dbgo,"mes->send malloc failed\n"))
+ DBG((g_log,0,"mes->send malloc failed\n"))
return 1;
}
@@ -793,7 +795,7 @@ static int load_ccast(
cp += sprintf(cp, "\"encoding\": \"base64\",");
cp += sprintf(cp, "\"data\": \"");
ebase64(&dlen, cp, iibuf, meslen);
- DBG((dbgo,"part base64 encoded PNG = %d bytes\n",dlen))
+ DBG((g_log,0,"part base64 encoded PNG = %d bytes\n",dlen))
iibuf += meslen;
iilen -= meslen;
senclen += dlen;
@@ -821,7 +823,7 @@ static int load_ccast(
#endif
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
free(mesbuf);
rv = 1;
goto retry; /* Failed */
@@ -835,7 +837,7 @@ static int load_ccast(
if (meslen > maxlen)
meslen = maxlen;
- DBG((dbgo,"Sending %d bytes of %d remaining in image\n",meslen,iilen))
+ DBG((g_log,0,"Sending %d bytes of %d remaining in image\n",meslen,iilen))
lastid = reqid = ++p->requestId;
@@ -844,7 +846,7 @@ static int load_ccast(
cp += sprintf(cp, "\"requestId\": %d,",reqid);
cp += sprintf(cp, "\"foreground\": \"");
ebase64(&dlen, cp, iibuf, meslen);
- DBG((dbgo,"part base64 encoded PNG = %d bytes\n",dlen))
+ DBG((g_log,0,"part base64 encoded PNG = %d bytes\n",dlen))
iibuf += meslen;
iilen -= meslen;
senclen += dlen;
@@ -862,7 +864,7 @@ static int load_ccast(
check_json((char *)mes.data);
#endif
if ((merr = p->messv->send(p->messv, &mes)) != ccmessv_OK) {
- DBG((dbgo,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
+ DBG((g_log,0,"mes->send LOAD failed with '%s'\n",ccmessv_emes(merr)))
free(mesbuf);
rv = 1;
goto retry; /* Failed */
@@ -872,41 +874,41 @@ static int load_ccast(
/* Wait for an ACK, to make sure the channel doesn't get choked up */
if (get_a_reply_id(p, direct_chan, firstid, &mes, 10000) != 0) {
- DBG((dbgo,"load_ccast: failed to get reply\n"))
+ DBG((g_log,0,"load_ccast: failed to get reply\n"))
rv = 2;
goto retry; /* Failed */
}
if (mes.mtype == NULL) {
- DBG((dbgo,"load_ccast: mtype == NULL\n"))
+ DBG((g_log,0,"load_ccast: mtype == NULL\n"))
rv = 2;
goto retry; /* Failed */
} else if (dchan && strcmp(mes.mtype, "ACK") == 0) {
- DBG((dbgo,"load_ccast: got ACK\n"))
+ DBG((g_log,0,"load_ccast: got ACK\n"))
} else if (dchan && strcmp(mes.mtype, "NACK") == 0) {
/* Failed. Get error status */
yajl_val errors;
if ((errors = yajl_tree_get_first(mes.tnode, "errors", yajl_t_array)) != NULL) {
- DBG((dbgo,"NACK returned errors:\n"))
+ DBG((g_log,0,"NACK returned errors:\n"))
if (YAJL_IS_ARRAY(errors)) {
for (i = 0; i < errors->u.array.len; i++) {
yajl_val error = errors->u.array.values[i];
- DBG((dbgo,"%s\n",error->u.string))
+ DBG((g_log,0,"%s\n",error->u.string))
}
} else {
- DBG((dbgo,"NACK errors is not an array!\n"))
+ DBG((g_log,0,"NACK errors is not an array!\n"))
}
} else {
- DBG((dbgo,"NACK failed to return errors\n"))
+ DBG((g_log,0,"NACK failed to return errors\n"))
}
rv = 2;
goto retry; /* Failed */
} else {
rv = 3;
- DBG((dbgo,"load_ccast: got mtype '%s'\n",mes.mtype))
+ DBG((g_log,0,"load_ccast: got mtype '%s'\n",mes.mtype))
goto retry; /* Failed */
}
ccmes_empty(&mes);
@@ -922,7 +924,7 @@ static int load_ccast(
#endif /* !NEVER */
} else {
- DBG((dbgo,"mes->send not given URL or png data\n"))
+ DBG((g_log,0,"mes->send not given URL or png data\n"))
return 1;
}
}
@@ -931,7 +933,7 @@ static int load_ccast(
for (reqid = firstid; reqid <= lastid; reqid++) {
if (get_a_reply_id(p, dchan ? direct_chan : media_chan, reqid, &mes, 5000) != 0) {
- DBG((dbgo,"load_ccast: failed to get reply\n"))
+ DBG((g_log,0,"load_ccast: failed to get reply\n"))
rv = 2;
goto retry; /* Failed */
}
@@ -946,29 +948,29 @@ static int load_ccast(
NACK
*/
if (mes.mtype == NULL) {
- DBG((dbgo,"load_ccast: mtype == NULL\n"))
+ DBG((g_log,0,"load_ccast: mtype == NULL\n"))
rv = 2;
goto retry; /* Failed */
} else if (dchan && strcmp(mes.mtype, "ACK") == 0) {
- DBG((dbgo,"load_ccast: got ACK\n"))
+ DBG((g_log,0,"load_ccast: got ACK\n"))
} else if (dchan && strcmp(mes.mtype, "NACK") == 0) {
/* Failed. Get error status */
yajl_val errors;
if ((errors = yajl_tree_get_first(mes.tnode, "errors", yajl_t_array)) != NULL) {
- DBG((dbgo,"NACK returned errors:\n"))
+ DBG((g_log,0,"NACK returned errors:\n"))
if (YAJL_IS_ARRAY(errors)) {
for (i = 0; i < errors->u.array.len; i++) {
yajl_val error = errors->u.array.values[i];
- DBG((dbgo,"%s\n",error->u.string))
+ DBG((g_log,0,"%s\n",error->u.string))
}
} else {
- DBG((dbgo,"NACK errors is not an array!\n"))
+ DBG((g_log,0,"NACK errors is not an array!\n"))
}
} else {
- DBG((dbgo,"NACK failed to return errors\n"))
+ DBG((g_log,0,"NACK failed to return errors\n"))
}
rv = 2;
goto retry; /* Failed */
@@ -977,15 +979,15 @@ static int load_ccast(
yajl_val node, i;
if ((i = yajl_tree_get_first(mes.tnode, "mediaSessionId", yajl_t_number)) != NULL) {
p->mediaSessionId = YAJL_GET_INTEGER(i);
- DBG((dbgo,"MEDIA_STATUS returned mediaSessionId %d\n",p->mediaSessionId))
+ DBG((g_log,0,"MEDIA_STATUS returned mediaSessionId %d\n",p->mediaSessionId))
} else {
- DBG((dbgo,"MEDIA_STATUS failed to return mediaSessionId\n"))
+ DBG((g_log,0,"MEDIA_STATUS failed to return mediaSessionId\n"))
}
/* Suceeded */
} else {
rv = 3;
- DBG((dbgo,"load_ccast: got mtype '%s'\n",mes.mtype))
+ DBG((g_log,0,"load_ccast: got mtype '%s'\n",mes.mtype))
goto retry; /* Failed */
}
ccmes_empty(&mes);
@@ -1000,10 +1002,10 @@ static int load_ccast(
return rv; /* Too many tries - give up */
}
- DBG((dbgo,"load_ccast: failed on try %d/%d - re-connecting to chrome cast\n",i+1,maxtries))
+ DBG((g_log,0,"load_ccast: failed on try %d/%d - re-connecting to chrome cast\n",i+1,maxtries))
shutdown_ccast(p); /* Tear connection down */
if (start_ccast(p)) { /* Set it up again */
- DBG((dbgo,"load_ccast: re-connecting failed\n"))
+ DBG((g_log,0,"load_ccast: re-connecting failed\n"))
return 1;
}
/* And retry */
@@ -1135,6 +1137,7 @@ void ccastQuant(void *ctx, double out[3], double in[3]) {
double r = in[0], g = in[1], b = in[2];
double Y, Cb, Cr;
+double or = r, og = g, ob = b;
// printf("ccastQuant: %f %f %f",r,g,b);
/* Scale RGB to 8 bit then quantize, since that's the limit of the frame buffer */
@@ -1198,6 +1201,11 @@ void ccastQuant(void *ctx, double out[3], double in[3]) {
out[1] = g;
out[2] = b;
+if (fabs(or - r) > 3.0
+ || fabs(og - g) > 3.0
+ || fabs(ob - b) > 3.0) {
+ printf("%f %f %f -> %f %f %f\n",or,og,ob,r,g,b);
+}
// printf(" -> %f %f %f\n",r,g,b);
}
diff --git a/ccast/ccast.h b/ccast/ccast.h
index 7014679..7014679 100644..100755
--- a/ccast/ccast.h
+++ b/ccast/ccast.h
diff --git a/ccast/ccmdns.c b/ccast/ccmdns.c
index 8dd889e..0ba3318 100644..100755
--- a/ccast/ccmdns.c
+++ b/ccast/ccmdns.c
@@ -126,9 +126,7 @@ typedef int SOCKET;
#endif
#ifdef DEBUG
-# define dbgo stdout
-# define DBG(xxx) fprintf xxx ;
-void cc_dump_bytes(FILE *fp, char *pfx, unsigned char *buf, int len);
+# define DBG(xxx) a1logd xxx ;
#else
# define DBG(xxx) ;
#endif /* DEBUG */
@@ -190,7 +188,7 @@ static int init_mDNS() {
#ifdef NT
WSADATA data;
if (WSAStartup(MAKEWORD(2,2), &data)) {
- DBG((dbgo,"WSAStartup failed\n"))
+ DBG((g_log,0,"WSAStartup failed\n"))
return 1;
}
#endif
@@ -206,12 +204,12 @@ static int init_send_mDNS(SOCKET *psock) {
SOCKET sock;
struct sockaddr_in stSourceAddr;
- DBG((dbgo,"init_send_mDNS() called\n"))
+ DBG((g_log,0,"init_send_mDNS() called\n"))
/* get a datagram (UDP) socket */
sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock == INVALID_SOCKET) {
- DBG((dbgo,"opening UDP socked failed with %d\n",ERRNO))
+ DBG((g_log,0,"opening send UDP socked failed with %d\n",ERRNO))
return 1;
}
@@ -231,7 +229,7 @@ static int init_send_mDNS(SOCKET *psock) {
{
int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on))) {
- DBG((dbgo,"setsockopt(SO_REUSEADDR) failed with %d\n",ERRNO))
+ DBG((g_log,0,"setsockopt(SO_REUSEADDR) failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -246,7 +244,7 @@ static int init_send_mDNS(SOCKET *psock) {
# endif
# endif
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (const char *)&on, sizeof(on))) {
- DBG((dbgo,"setsockopt(SO_REUSEPORT) failed with %d\n",ERRNO))
+ DBG((g_log,0,"setsockopt(SO_REUSEPORT) failed with %d\n",ERRNO))
}
#endif
}
@@ -264,7 +262,7 @@ static int init_send_mDNS(SOCKET *psock) {
nRet = bind(sock, (struct sockaddr *)&stSourceAddr,
sizeof(struct sockaddr));
if (nRet == SOCKET_ERROR) {
- DBG((dbgo,"bind failed with %d\n",ERRNO))
+ DBG((g_log,0,"bind failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -283,7 +281,7 @@ static int init_send_mDNS(SOCKET *psock) {
* with loopback disabled), so this failure is of no consequence.
* However, if we *do* get loop-backed data, we'll know why
*/
- DBG((dbgo,"[disabling loopback failed with %d]\n",ERRNO))
+ DBG((g_log,0,"[disabling loopback failed with %d]\n",ERRNO))
}
#ifdef NEVER // We only want this to be local
@@ -294,7 +292,7 @@ static int init_send_mDNS(SOCKET *psock) {
nRet = setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL,
(char *)&nOptVal, sizeof(int));
if (nRet == SOCKET_ERROR) {
- DBG((dbgo,"increasing TTL failed with %d\n",ERRNO))
+ DBG((g_log,0,"increasing TTL failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -303,7 +301,7 @@ static int init_send_mDNS(SOCKET *psock) {
if (psock != NULL)
*psock = sock;
- DBG((dbgo,"init sending mDNS succeed\n",ERRNO))
+ DBG((g_log,0,"init sending mDNS succeed\n",ERRNO))
return 0;
}
@@ -317,7 +315,7 @@ static int send_mDNS(SOCKET sock) {
ORD8 achOutBuf[BUFSIZE];
struct sockaddr_in stDestAddr;
- DBG((dbgo,"send_mDNS() called\n"))
+ DBG((g_log,0,"send_mDNS() called\n"))
/* Initialize the Destination Address structure and send */
stDestAddr.sin_family = PF_INET;
@@ -325,22 +323,22 @@ static int send_mDNS(SOCKET sock) {
stDestAddr.sin_port = htons(DESTINATION_PORT);
/* Setup the FQDN data packet to send */
- write_ORD16_be(0, achOutBuf + 0); /* ID */
- write_ORD16_be(0, achOutBuf + 2); /* Flags */
- write_ORD16_be(1, achOutBuf + 4); /* QDCOUNT - one question */
- write_ORD16_be(0, achOutBuf + 6); /* ANCOUNT */
- write_ORD16_be(0, achOutBuf + 8); /* NSCOUNT */
- write_ORD16_be(0, achOutBuf + 10); /* ARCOUNT */
+ write_ORD16_be(achOutBuf + 0, 0); /* ID */
+ write_ORD16_be(achOutBuf + 2, 0); /* Flags */
+ write_ORD16_be(achOutBuf + 4, 1); /* QDCOUNT - one question */
+ write_ORD16_be(achOutBuf + 6, 0); /* ANCOUNT */
+ write_ORD16_be(achOutBuf + 8, 0); /* NSCOUNT */
+ write_ORD16_be(achOutBuf + 10, 0); /* ARCOUNT */
off = 12;
off = write_string(achOutBuf, off, "_googlecast");
off = write_string(achOutBuf, off, "_tcp");
off = write_string(achOutBuf, off, "local");
- write_ORD8(0, achOutBuf + off); /* null string */
+ write_ORD8(achOutBuf + off, 0); /* null string */
off += 1;
- write_ORD16_be(0x000c, achOutBuf + off); /* QCOUNT */
+ write_ORD16_be(achOutBuf + off, 0x000c); /* QCOUNT */
off += 2;
/* Set top bit to get a unicast response (not for ChromeCast though) */
- write_ORD16_be(0x0001, achOutBuf + off); /* QCLASS */
+ write_ORD16_be(achOutBuf + off, 0x0001); /* QCLASS */
off += 2;
nRet = sendto(sock, (char *)achOutBuf, off,
@@ -348,11 +346,11 @@ static int send_mDNS(SOCKET sock) {
(struct sockaddr *) &stDestAddr,
sizeof(struct sockaddr));
if (nRet == SOCKET_ERROR) {
- DBG((dbgo,"sending mDNS query failed with %d\n",ERRNO))
+ DBG((g_log,0,"sending mDNS query failed with %d\n",ERRNO))
return 1;
}
- DBG((dbgo,"sending mDNS query succeed\n",ERRNO))
+ DBG((g_log,0,"sending mDNS query succeed\n",ERRNO))
return 0;
}
@@ -384,12 +382,12 @@ static int init_receive_mDNS(SOCKET *psock) {
struct ip_mreq stIpMreq;
SOCKET sock;
- DBG((dbgo,"init_receive_mDNS() called\n"))
+ DBG((g_log,0,"init_receive_mDNS() called\n"))
/* get a datagram (UDP) socket */
sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock == INVALID_SOCKET) {
- DBG((dbgo,"opening UDP socked failed with %d\n",ERRNO))
+ DBG((g_log,0,"opening receive UDP socked failed with %d\n",ERRNO))
return 1;
}
@@ -399,7 +397,7 @@ static int init_receive_mDNS(SOCKET *psock) {
{
int on = 1, off = 0;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on))) {
- DBG((dbgo,"setsockopt(SO_REUSEADDR) failed with %d\n",ERRNO))
+ DBG((g_log,0,"setsockopt(SO_REUSEADDR) failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -414,7 +412,7 @@ static int init_receive_mDNS(SOCKET *psock) {
# endif
# endif
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (const char *)&on, sizeof(on))) {
- DBG((dbgo,"setsockopt(SO_REUSEPORT) failed with %d\n",ERRNO))
+ DBG((g_log,0,"setsockopt(SO_REUSEPORT) failed with %d\n",ERRNO))
}
#endif
}
@@ -432,7 +430,7 @@ static int init_receive_mDNS(SOCKET *psock) {
nRet = bind(sock, (struct sockaddr *)&stSourceAddr,
sizeof(struct sockaddr));
if (nRet == SOCKET_ERROR) {
- DBG((dbgo,"bind failed with %d\n",ERRNO))
+ DBG((g_log,0,"bind failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -444,7 +442,7 @@ static int init_receive_mDNS(SOCKET *psock) {
(char *)&stIpMreq, sizeof (struct ip_mreq));
if (nRet == SOCKET_ERROR) {
- DBG((dbgo,"registering for read events failed with %d\n",ERRNO))
+ DBG((g_log,0,"registering for read events failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -455,7 +453,7 @@ static int init_receive_mDNS(SOCKET *psock) {
DWORD tv;
tv = 100;
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv)) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d\n",ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -466,7 +464,7 @@ static int init_receive_mDNS(SOCKET *psock) {
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv)) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d\n",ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d\n",ERRNO))
closesocket(sock);
return 1;
}
@@ -497,7 +495,7 @@ static int receive_mDNS(SOCKET sock, ccast_id ***ids, int emsec) {
;
}
- DBG((dbgo,"receive_mDNS() called with %d ids\n",nids))
+ DBG((g_log,0,"receive_mDNS() called with %d ids\n",nids))
for (smsec = msec_time(), emsec += smsec;msec_time() <= emsec;) {
int i;
@@ -511,20 +509,20 @@ static int receive_mDNS(SOCKET sock, ccast_id ***ids, int emsec) {
if (size == SOCKET_ERROR) {
if (ERRNO == UDP_SOCKET_TIMEOUT)
continue; /* Timeout */
- DBG((dbgo,"recvfrom failed with %d\n",ERRNO))
+ DBG((g_log,0,"recvfrom failed with %d\n",ERRNO))
free_ccids(*ids);
*ids = NULL;
return 1;
}
- DBG((dbgo,"Got mDNS message length %d bytes\n",size))
+ DBG((g_log,0,"Got mDNS message length %d bytes\n",size))
#ifdef DEBUG
- cc_dump_bytes(dbgo, " ", achInBuf, size);
+ adump_bytes(g_log, " ", achInBuf, 0, size);
#endif
if (parse_dns(&name, &ip, achInBuf, size) != 0) {
- DBG((dbgo,"Failed to parse the reply\n"))
+ DBG((g_log,0,"Failed to parse the reply\n"))
} else {
- DBG((dbgo,"Parsed reply OK\n"))
+ DBG((g_log,0,"Parsed reply OK\n"))
//if (*pnids > 0) {
// name = strdup("Argyll1234");
@@ -532,7 +530,7 @@ static int receive_mDNS(SOCKET sock, ccast_id ***ids, int emsec) {
//}
/* If we found an entry */
if (name != NULL && ip != NULL) {
- DBG((dbgo,"Got a name '%s' & IP '%s'\n",name,ip))
+ DBG((g_log,0,"Got a name '%s' & IP '%s'\n",name,ip))
/* Check if it is a duplcate */
for (i = 0; i < nids; i++) {
if (strcmp((*ids)[i]->name, name) == 0
@@ -540,21 +538,21 @@ static int receive_mDNS(SOCKET sock, ccast_id ***ids, int emsec) {
break; /* yes */
}
if (i < nids) {
- DBG((dbgo,"Duplicate\n"))
+ DBG((g_log,0,"Duplicate\n"))
free(name);
free(ip);
} else {
ccast_id **tids;
if ((tids = realloc(*ids, (nids + 2) * sizeof(ccast_id *))) == NULL
|| (*ids = tids, (*ids)[nids] = malloc(sizeof(ccast_id)), (*ids)[nids]) == NULL) {
- DBG((dbgo,"realloc/malloc fail\n"))
+ DBG((g_log,0,"realloc/malloc fail\n"))
free(name);
free(ip);
free_ccids(*ids);
*ids = NULL;
return 1;
} else {
- DBG((dbgo,"Adding entry\n"))
+ DBG((g_log,0,"Adding entry\n"))
(*ids)[nids]->name = name;
(*ids)[nids]->ip = ip;
(*ids)[++nids] = NULL; /* End marker */
@@ -564,7 +562,7 @@ static int receive_mDNS(SOCKET sock, ccast_id ***ids, int emsec) {
}
}
- DBG((dbgo,"receive_mDNS() returning %d in list\n",nids))
+ DBG((g_log,0,"receive_mDNS() returning %d in list\n",nids))
return 0;
}
@@ -581,33 +579,33 @@ ccast_id **get_ccids() {
SOCKET ssock, rsock;
if (init_mDNS()) {
- DBG((dbgo,"init_mDNS() failed\n"))
+ DBG((g_log,0,"init_mDNS() failed\n"))
return NULL;
}
if (init_send_mDNS(&ssock)) {
- DBG((dbgo,"init_send_mDNS() failed\n"))
+ DBG((g_log,0,"init_send_mDNS() failed\n"))
return NULL;
}
if (init_receive_mDNS(&rsock)) {
- DBG((dbgo,"init_receive_mDNS() failed\n"))
+ DBG((g_log,0,"init_receive_mDNS() failed\n"))
closesocket(ssock);
return NULL;
}
smsec = msec_time();
- DBG((dbgo,"Sending mDNS query:\n"))
+ DBG((g_log,0,"Sending mDNS query:\n"))
if (send_mDNS(ssock)) {
- DBG((dbgo,"send_mDNS() #1 failed\n"))
+ DBG((g_log,0,"send_mDNS() #1 failed\n"))
closesocket(ssock);
closesocket(rsock);
return NULL;
}
if (receive_mDNS(rsock, &ids, 100)) {
- DBG((dbgo,"receive_mDNS() #1 failed\n"))
+ DBG((g_log,0,"receive_mDNS() #1 failed\n"))
closesocket(ssock);
closesocket(rsock);
return NULL;
@@ -615,16 +613,16 @@ ccast_id **get_ccids() {
if (ids == NULL && (msec_time() - smsec) < 200) {
- DBG((dbgo,"Sending another mDNS query:\n"))
+ DBG((g_log,0,"Sending another mDNS query:\n"))
if (send_mDNS(ssock)) {
- DBG((dbgo,"send_mDNS() #2 failed\n"))
+ DBG((g_log,0,"send_mDNS() #2 failed\n"))
closesocket(ssock);
closesocket(rsock);
return NULL;
}
if (receive_mDNS(rsock, &ids, 500)) {
- DBG((dbgo,"receive_mDNS() #2 failed\n"))
+ DBG((g_log,0,"receive_mDNS() #2 failed\n"))
closesocket(ssock);
closesocket(rsock);
return NULL;
@@ -633,16 +631,16 @@ ccast_id **get_ccids() {
if (ids == NULL) {
- DBG((dbgo,"Sending a final mDNS query:\n"))
+ DBG((g_log,0,"Sending a final mDNS query:\n"))
if (send_mDNS(ssock)) {
- DBG((dbgo,"send_mDNS() #3 failed\n"))
+ DBG((g_log,0,"send_mDNS() #3 failed\n"))
closesocket(ssock);
closesocket(rsock);
return NULL;
}
if (receive_mDNS(rsock, &ids, 500)) {
- DBG((dbgo,"receive_mDNS() #3 failed\n"))
+ DBG((g_log,0,"receive_mDNS() #3 failed\n"))
closesocket(ssock);
closesocket(rsock);
return NULL;
@@ -655,7 +653,7 @@ ccast_id **get_ccids() {
/* If no ChromCasts found, return an empty list */
if (ids == NULL) {
if ((ids = calloc(sizeof(ccast_id *), 1)) == NULL) {
- DBG((dbgo,"calloc fail\n"))
+ DBG((g_log,0,"calloc fail\n"))
return NULL;
}
}
@@ -814,21 +812,21 @@ int parse_query(ORD8 *buf, int off, int size) {
char *sv;
int qtype, qclass;
- DBG((dbgo,"Parsing query at 0x%x:\n",off))
+ DBG((g_log,0,"Parsing query at 0x%x:\n",off))
if ((off = read_string(&sv, buf, off, size)) < 0)
return -1;
- DBG((dbgo," Got string '%s'\n",sv))
+ DBG((g_log,0," Got string '%s'\n",sv))
free(sv);
if ((size - off) < 2)
return -1;
qtype = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," QTYPE = 0x%04x\n",qtype))
+ DBG((g_log,0," QTYPE = 0x%04x\n",qtype))
if ((size - off) < 2)
return -1;
qclass = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," QCLASS = 0x%04x\n",qtype))
+ DBG((g_log,0," QCLASS = 0x%04x\n",qtype))
return off;
}
@@ -840,29 +838,29 @@ int parse_reply(char **pname, char **pip, ORD8 *buf, int off, int size) {
int rtype, rclass, rdlength;
unsigned int ttl;
- DBG((dbgo,"Parsing reply at 0x%x:\n",off))
+ DBG((g_log,0,"Parsing reply at 0x%x:\n",off))
if ((off = read_string(&sv, buf, off, size)) < 0)
return -1;
- DBG((dbgo," Got string '%s'\n",sv))
+ DBG((g_log,0," Got string '%s'\n",sv))
if ((size - off) < 2) {
free(sv);
return -1;
}
rtype = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," RTYPE = %d\n",rtype))
+ DBG((g_log,0," RTYPE = %d\n",rtype))
if ((size - off) < 2) {
free(sv);
return -1;
}
rclass = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," RCLASS = 0x%04x\n",rclass))
+ DBG((g_log,0," RCLASS = 0x%04x\n",rclass))
/* rclass top bit is cache flush bit */
if ((rclass & 0x7fff) != DNS_CLASS_IN) {
- DBG((dbgo," response has RCLASS != 0x%04x\n",DNS_CLASS_IN))
+ DBG((g_log,0," response has RCLASS != 0x%04x\n",DNS_CLASS_IN))
free(sv);
return -1;
}
@@ -870,15 +868,15 @@ int parse_reply(char **pname, char **pip, ORD8 *buf, int off, int size) {
if ((size - off) < 4)
return -1;
ttl = read_ORD32_be(buf + off); off += 4;
- DBG((dbgo," TTL = %u\n",ttl))
+ DBG((g_log,0," TTL = %u\n",ttl))
if ((size - off) < 2)
return -1;
rdlength = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," RDLENGTH = %d\n",rdlength))
+ DBG((g_log,0," RDLENGTH = %d\n",rdlength))
if ((off + rdlength) > size) {
- DBG((dbgo," response RDLENGTH is longer than remaining buffer (%d)\n",size - off))
+ DBG((g_log,0," response RDLENGTH is longer than remaining buffer (%d)\n",size - off))
free(sv);
return -1;
}
@@ -892,31 +890,31 @@ int parse_reply(char **pname, char **pip, ORD8 *buf, int off, int size) {
}
*cp = '\000';
if (strcmp(cp+1, "_googlecast._tcp.local") != 0) {
- DBG((dbgo,"Not a chromecast (got '%s')\n",cp+1))
+ DBG((g_log,0,"Not a chromecast (got '%s')\n",cp+1))
free(sv);
return -1;
}
- DBG((dbgo," Chromacast '%s'\n", sv))
+ DBG((g_log,0," Chromacast '%s'\n", sv))
if ((*pname = strdup(sv)) == NULL) {
- DBG((dbgo,"strdup failed\n"))
+ DBG((g_log,0,"strdup failed\n"))
free(sv);
return -1;
}
} else if (rtype == DNS_TYPE_A) {
/* Should we check name matches ? */
if ((*pip = malloc(3 * 4 + 3 + 1)) == NULL) {
- DBG((dbgo,"malloc failed\n"))
+ DBG((g_log,0,"malloc failed\n"))
free(*pname);
free(sv);
}
sprintf(*pip, "%d.%d.%d.%d", buf[off], buf[off+1], buf[off+2], buf[off+3]);
- DBG((dbgo," V4 address = %s\n",*pip))
+ DBG((g_log,0," V4 address = %s\n",*pip))
} else if (rtype == DNS_TYPE_AAAA) { /* The IPV6 address */
/* Should we check name matches ? */
if ((*pip = malloc(8 * 4 + 7 + 1)) == NULL) {
- DBG((dbgo,"malloc failed\n"))
+ DBG((g_log,0,"malloc failed\n"))
free(*pname);
free(sv);
}
@@ -929,10 +927,10 @@ int parse_reply(char **pname, char **pip, ORD8 *buf, int off, int size) {
buf[off+10] * 245 + buf[off+11],
buf[off+12] * 245 + buf[off+13],
buf[off+14] * 245 + buf[off+15]);
- DBG((dbgo," V6 address = %s\n",*pip))
+ DBG((g_log,0," V6 address = %s\n",*pip))
} else {
- DBG((dbgo," Skipping reply at 0x%x\n",off))
+ DBG((g_log,0," Skipping reply at 0x%x\n",off))
}
off += rdlength;
free(sv);
@@ -947,7 +945,7 @@ static int parse_dns(char **pname, char **pip, ORD8 *buf, int size) {
int i, off = 0;
int id, flags, qdcount, ancount, nscount, arcount;
- DBG((dbgo,"Parsing mDNS reply:\n"))
+ DBG((g_log,0,"Parsing mDNS reply:\n"))
*pname = NULL;
*pip = NULL;
@@ -955,34 +953,34 @@ static int parse_dns(char **pname, char **pip, ORD8 *buf, int size) {
// Parse reply header
if ((size - off) < 2) return 1;
id = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," ID = %d\n",id))
+ DBG((g_log,0," ID = %d\n",id))
if ((size - off) < 2) return 1;
flags = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," FLAGS = 0x%04x\n",flags))
+ DBG((g_log,0," FLAGS = 0x%04x\n",flags))
if ((size - off) < 2) return 1;
qdcount = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," QDCOUNT = %d\n",qdcount))
+ DBG((g_log,0," QDCOUNT = %d\n",qdcount))
if ((size - off) < 2) return 1;
ancount = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," ANCOUNT = %d\n",ancount))
+ DBG((g_log,0," ANCOUNT = %d\n",ancount))
if ((size - off) < 2) return 1;
nscount = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," NSCOUNT = %d\n",nscount))
+ DBG((g_log,0," NSCOUNT = %d\n",nscount))
if ((size - off) < 2) return 1;
arcount = read_ORD16_be(buf + off); off += 2;
- DBG((dbgo," ARCOUNT = %d\n",arcount))
+ DBG((g_log,0," ARCOUNT = %d\n",arcount))
//printf("~1 after strings, off = 0x%x\n",off);
// Parse all the queries (QDCOUNT)
for (i = 0; i < qdcount; i++) {
if ((off = parse_query(buf, off, size)) < 0) {
- DBG((dbgo," ### Parsing query failed ###\n"))
+ DBG((g_log,0," ### Parsing query failed ###\n"))
return 1;
}
}
@@ -990,7 +988,7 @@ static int parse_dns(char **pname, char **pip, ORD8 *buf, int size) {
// Parse all the answers (ANCOUNT)
for (i = 0; i < ancount; i++) {
if ((off = parse_reply(pname, pip, buf, off, size)) < 0) {
- DBG((dbgo," ### Parsing answer failed ###\n"))
+ DBG((g_log,0," ### Parsing answer failed ###\n"))
return 1;
}
}
@@ -998,7 +996,7 @@ static int parse_dns(char **pname, char **pip, ORD8 *buf, int size) {
// Parse all the NS records (NSCOUNT)
for (i = 0; i < nscount; i++) {
if ((off = parse_reply(pname, pip, buf, off, size)) < 0) {
- DBG((dbgo," ### Parsing NS record failed ###\n"))
+ DBG((g_log,0," ### Parsing NS record failed ###\n"))
return 1;
}
}
@@ -1006,7 +1004,7 @@ static int parse_dns(char **pname, char **pip, ORD8 *buf, int size) {
// Parse all the addition RR answers (ARCOUNT)
for (i = 0; i < arcount; i++) {
if ((off = parse_reply(pname, pip, buf, off, size)) < 0) {
- DBG((dbgo," ### Parsing additional records failed ###\n"))
+ DBG((g_log,0," ### Parsing additional records failed ###\n"))
return 1;
}
}
@@ -1066,31 +1064,3 @@ static int parse_dns(char **pname, char **pip, ORD8 *buf, int size) {
*/
-/* ================================================================== */
-/* Debug */
-
-// Print bytes as hex to stdout
-void cc_dump_bytes(FILE *fp, char *pfx, unsigned char *buf, int len) {
- int i, j, ii;
- char oline[200] = { '\000' }, *bp = oline;
- for (i = j = 0; i < len; i++) {
- if ((i % 16) == 0)
- bp += sprintf(bp,"%s%04x:",pfx,i);
- bp += sprintf(bp," %02x",buf[i]);
- if ((i+1) >= len || ((i+1) % 16) == 0) {
- for (ii = i; ((ii+1) % 16) != 0; ii++)
- bp += sprintf(bp," ");
- bp += sprintf(bp," ");
- for (; j <= i; j++) {
- if (!(buf[j] & 0x80) && isprint(buf[j]))
- bp += sprintf(bp,"%c",buf[j]);
- else
- bp += sprintf(bp,".");
- }
- bp += sprintf(bp,"\n");
- fprintf(fp, "%s", oline);
- bp = oline;
- }
- }
-}
-
diff --git a/ccast/ccmdns.h b/ccast/ccmdns.h
index 5144448..5144448 100644..100755
--- a/ccast/ccmdns.h
+++ b/ccast/ccmdns.h
diff --git a/ccast/ccmes.c b/ccast/ccmes.c
index dbd5fd9..d0581d9 100644..100755
--- a/ccast/ccmes.c
+++ b/ccast/ccmes.c
@@ -28,13 +28,14 @@
#include "copyright.h"
#include "aconfig.h"
#include <sys/types.h>
-#ifndef SALONEINSTLIB
#include "numlib.h"
+
+#ifndef USING_AXTLS
+# include "openssl/ssl.h" /* OpenSSL header */
#else
-#include "numsup.h"
+# include "ssl.h" /* axTLS header */
#endif
-#include "ssl.h" /* axTLS header */
#include "yajl.h"
#include "conv.h"
#include "ccpacket.h"
@@ -47,11 +48,10 @@
/* ------------------------------------------------------------------- */
#ifdef DEBUG
-# define DBG(xxx) fprintf xxx ;
+# define DBG(xxx) a1logd xxx ;
#else
# define DBG(xxx) ;
#endif /* DEBUG */
-# define dbgo stdout
/* Error message from error number */
char *ccmessv_emes(ccmessv_err rv) {
@@ -91,50 +91,50 @@ char *ccmessv_emes(ccmessv_err rv) {
#if defined(LOWVERBTRACE) || defined(DEBUG)
static void mes_dump(ccmes *mes, char *pfx) {
#ifdef DEBUG
- fprintf(dbgo,"%s message:\n",pfx);
- fprintf(dbgo," source_id = '%s'\n",mes->source_id);
- fprintf(dbgo," destination_id = '%s'\n",mes->destination_id);
- fprintf(dbgo," namespace = '%s'\n",mes->namespace);
+ a1logd(g_log,0,"%s message:\n",pfx);
+ a1logd(g_log,0," source_id = '%s'\n",mes->source_id);
+ a1logd(g_log,0," destination_id = '%s'\n",mes->destination_id);
+ a1logd(g_log,0," namespace = '%s'\n",mes->namespace);
if (mes->binary) {
- fprintf(dbgo," payload =\n");
- cc_dump_bytes(dbgo," ", mes->data, mes->bin_len);
+ a1logd(g_log,0," payload =\n");
+ adump_bytes(g_log," ", mes->data, 0, mes->bin_len);
} else {
- fprintf(dbgo," payload = '%s'\n",mes->data);
+ a1logd(g_log,0," payload = '%s'\n",mes->data);
}
#else
- fprintf(dbgo,"%s '%s'",pfx,mes->namespace);
+ a1logd(g_log,0,"%s '%s'",pfx,mes->namespace);
#endif
if (mes->binary) {
#ifdef DEBUG
- fprintf(dbgo," %d bytes of binary data:\n",mes->bin_len);
- cc_dump_bytes(dbgo," ", mes->data, mes->bin_len);
+ a1logd(g_log,0," %d bytes of binary data:\n",mes->bin_len);
+ adump_bytes(g_log," ", mes->data, 0, mes->bin_len);
#else
- fprintf(dbgo,", %d bytes of bin data:\n",mes->bin_len);
+ a1logd(g_log,0,", %d bytes of bin data:\n",mes->bin_len);
#endif
} else {
/* Would like to pretty print the JSON data */
/* ie. convert json_reformat.c to a function */
#ifdef DEBUG
- fprintf(dbgo," %d bytes of text data:\n",strlen(mes->data));
- fprintf(dbgo," '%s'\n",mes->data);
+ a1logd(g_log,0," %d bytes of text data:\n",strlen(mes->data));
+ a1logd(g_log,0," '%s'\n",mes->data);
#else
yajl_val tnode, v, i;
int len = strlen((char *)mes->data);
tnode = yajl_tree_parse((char *)mes->data, NULL, 0);
if (tnode == NULL) {
- fprintf(dbgo,", %d bytes of text data\n",len);
+ a1logd(g_log,0,", %d bytes of text data\n",len);
} else {
if ((v = yajl_tree_get_first(tnode, "type", yajl_t_string)) != NULL) {
char *mtype = YAJL_GET_STRING(v);
if ((i = yajl_tree_get_first(tnode, "requestId", yajl_t_number)) != NULL) {
int rqid = YAJL_GET_INTEGER(i);
- fprintf(dbgo,", %d bytes of JSON data, type '%s' id %d\n",
+ a1logd(g_log,0,", %d bytes of JSON data, type '%s' id %d\n",
len,mtype,rqid);
} else {
- fprintf(dbgo,", %d bytes of JSON data, type '%s'\n",len,mtype);
+ a1logd(g_log,0,", %d bytes of JSON data, type '%s'\n",len,mtype);
}
} else {
- fprintf(dbgo,", %d bytes of JSON data\n",len);
+ a1logd(g_log,0,", %d bytes of JSON data\n",len);
}
}
#endif
@@ -284,15 +284,15 @@ ccmessv_err receive_ccmessv(ccmessv *p, ccmes *mes) {
char errbuf[1024];
if ((mes->tnode = yajl_tree_parse((char *)mes->data, errbuf, sizeof(errbuf))) == NULL) {
- DBG((dbgo,"ccthread: yajl_tree_parse failed with '%s'\n",errbuf))
+ DBG((g_log,0,"ccthread: yajl_tree_parse failed with '%s'\n",errbuf))
} else if ((tyn = yajl_tree_get_first(mes->tnode, "type", yajl_t_string)) == NULL) {
- DBG((dbgo,"ccthread: no type\n"))
+ DBG((g_log,0,"ccthread: no type\n"))
} else {
mes->mtype = YAJL_GET_STRING(tyn);
if ((idn = yajl_tree_get_first(mes->tnode, "requestId", yajl_t_number)) != NULL)
mes->rqid = YAJL_GET_INTEGER(idn);
else {
- DBG((dbgo,"ccthread: no id\n"))
+ DBG((g_log,0,"ccthread: no id\n"))
}
}
}
@@ -316,7 +316,7 @@ ccmessv *new_ccmessv(ccpacket *pk) {
ccmessv *p = NULL;
if ((p = (ccmessv *)calloc(1, sizeof(ccmessv))) == NULL) {
- DBG((dbgo, "calloc failed\n"))
+ DBG((g_log,0, "calloc failed\n"))
return NULL;
}
diff --git a/ccast/ccmes.h b/ccast/ccmes.h
index 5eae02a..5eae02a 100644..100755
--- a/ccast/ccmes.h
+++ b/ccast/ccmes.h
diff --git a/ccast/ccpacket.c b/ccast/ccpacket.c
index 4c138f2..97e28d7 100644..100755
--- a/ccast/ccpacket.c
+++ b/ccast/ccpacket.c
@@ -28,13 +28,14 @@
#include "copyright.h"
#include "aconfig.h"
#include <sys/types.h>
-#ifndef SALONEINSTLIB
#include "numlib.h"
+#include "conv.h"
+
+#ifdef USING_AXTLS
+# include "ssl.h" /* axTLS header */
#else
-#include "numsup.h"
+# include "openssl/ssl.h" /* OpenSSL header */
#endif
-#include "conv.h"
-#include "ssl.h" /* axTLS header */
#undef DEBUG
#undef DUMPSDATA /* Send data */
@@ -95,13 +96,15 @@ typedef int SOCKET;
/* ------------------------------------------------------------------- */
#ifdef DEBUG
-# define dbgo stdout
-# define DBG(xxx) fprintf xxx ;
-void cc_dump_bytes(FILE *fp, char *pfx, unsigned char *buf, int len);
+# define DBG(xxx) a1logd xxx ;
#else
# define DBG(xxx) ;
#endif /* DEBUG */
+/* Some OpenSSL's support
+ ERR_print_errors_fp(stderr);
+*/
+
/* Error message from error number */
char *ccpacket_emes(ccpacket_err rv) {
#ifndef SERVER_ONLY
@@ -150,14 +153,25 @@ static ccpacket_err connect_ccpacket_imp(
server.sin_addr.s_addr = inet_addr(p->dip);
server.sin_port = htons((short)p->dport);
- if ((p->ctx = ssl_ctx_new(SSL_SERVER_VERIFY_LATER, 1)) == NULL) {
- DBG((dbgo, "connect ssl_ctx_new failed\n"))
+#ifdef USING_AXTLS
+ if ((p->ctx = ssl_ctx_new(SSL_SERVER_VERIFY_LATER, 1)) == NULL)
+#else
+ // Want to use TLS_client_method(), but older OpenSSL doesn't have it...
+ if ((p->ctx = SSL_CTX_new(TLSv1_client_method())) == NULL)
+#endif
+ {
+ DBG((g_log,0, "connect ssl_ctx_new failed\n"))
return ccpacket_context;
}
+#ifndef USING_AXTLS
+ // SSL_CTX_set_mode();
+ SSL_CTX_set_verify(p->ctx, SSL_VERIFY_NONE, NULL);
+#endif
+
/* Open socket */
if ((p->sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
- DBG((dbgo, "socket() failed with errno %d\n",ERRNO))
+ DBG((g_log,0, "socket() failed with errno %d\n",ERRNO))
return ccpacket_connect;
}
@@ -173,13 +187,13 @@ static ccpacket_err connect_ccpacket_imp(
#endif
if ((rv = setsockopt(p->sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv,
sizeof(tv))) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
return ccpacket_connect;
}
tv = 2000;
if ((rv = setsockopt(p->sock, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv,
sizeof(tv))) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
return ccpacket_connect;
}
#else
@@ -193,14 +207,14 @@ static ccpacket_err connect_ccpacket_imp(
#endif
if ((rv = setsockopt(p->sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv,
sizeof(tv))) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
return ccpacket_connect;
}
tv.tv_sec = 2;
tv.tv_usec = 0;
if ((rv = setsockopt(p->sock, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv,
sizeof(tv))) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
return ccpacket_connect;
}
#endif
@@ -210,7 +224,7 @@ static ccpacket_err connect_ccpacket_imp(
ling.l_linger = 2; /* Two seconds */
if ((rv = setsockopt(p->sock, SOL_SOCKET, SO_LINGER, (const char*)&ling,
sizeof(ling))) < 0) {
- DBG((dbgo,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
+ DBG((g_log,0,"setsockopt timout failed with %d, errno %d",rv,ERRNO))
return ccpacket_connect;
}
#endif /* NEVER */
@@ -218,19 +232,26 @@ static ccpacket_err connect_ccpacket_imp(
/* Connect */
if (rv = (connect(p->sock, (struct sockaddr *)&server, sizeof(server))) != 0) {
- DBG((dbgo, "TCP connect IP '%s' port %d failed with %d, errno %d\n",p->dip, p->dport,rv,ERRNO))
+ DBG((g_log,0, "TCP connect IP '%s' port %d failed with %d, errno %d\n",p->dip, p->dport,rv,ERRNO))
return ccpacket_connect;
}
- DBG((dbgo, "socket connect IP '%s' port %d success\n",p->dip, p->dport))
+ DBG((g_log,0, "socket connect IP '%s' port %d success\n",p->dip, p->dport))
/* Establish TLS */
/* Return nz if we can send PNG directly as base64 + bg RGB, */
/* else have to setup webserver and send URL */
- if ((p->ssl = ssl_client_new(p->ctx, p->sock, sesid, 32)) == NULL) {
- DBG((dbgo, "connect IP '%s' port %d ssl_ctx_new failed\n",p->dip, p->dport))
+#ifdef USING_AXTLS
+ if ((p->ssl = ssl_client_new(p->ctx, p->sock, sesid, 32)) == NULL)
+#else
+ if ((p->ssl = SSL_new(p->ctx)) == NULL
+ || SSL_set_fd(p->ssl, p->sock) != 1
+ || SSL_connect(p->ssl) != 1)
+#endif
+ {
+ DBG((g_log,0, "connect IP '%s' port %d ssl_ctx_new failed\n",p->dip, p->dport))
return ccpacket_ssl;
}
- DBG((dbgo, "TLS connect IP '%s' port %d success\n",p->dip, p->dport))
+ DBG((g_log,0, "TLS connect IP '%s' port %d success\n",p->dip, p->dport))
return ccpacket_OK;
}
@@ -270,7 +291,7 @@ static ccpacket_err re_connect_ccpacket(
static ccpacket_err send_ccpacket(ccpacket *p,
ORD8 *buf, ORD32 len /* Message body to send */
) {
- int lens, rv;
+ int lens, ilen;
ORD8 *sbuf;
ORD32 slen;
@@ -281,17 +302,17 @@ static ccpacket_err send_ccpacket(ccpacket *p,
return ccpacket_malloc;
}
- write_ORD32_be(len, sbuf);
+ write_ORD32_be(sbuf, len);
memcpy(sbuf+4, buf, len);
slen = len + 4;
#if defined(DEBUG) && defined(DUMPSDATA)
printf("send_ccpacket sending packet:\n");
- cc_dump_bytes(dbgo," ", sbuf, slen);
+ adump_bytes(g_log," ", sbuf, 0, slen);
#endif
- for (lens = 0; lens < slen; lens += rv) {
- DBG((dbgo, "Sending packet %d bytes\n",slen - lens))
+ for (lens = 0; lens < slen; lens += ilen) {
+ DBG((g_log,0, "Sending packet %d bytes\n",slen - lens))
if (p->ssl == NULL) {
return ccpacket_ssl;
}
@@ -299,14 +320,29 @@ static ccpacket_err send_ccpacket(ccpacket *p,
amutex_lock(p->lock);
printf("~1 send locked\n");
#endif
- if ((rv = ssl_write(p->ssl, sbuf + lens, slen - lens)) < 0) {
- DBG((dbgo, "TLS send body failed with '%s'\n",ssl_error_string(rv)))
+#ifdef USING_AXTLS
+ if ((ilen = ssl_write(p->ssl, sbuf + lens, slen - lens)) < 0)
+#else
+ if ((ilen = SSL_write(p->ssl, sbuf + lens, slen - lens)) < 0)
+#endif
+ {
+#ifdef USING_AXTLS
+ DBG((g_log,0, "send failed with '%s'\n",ssl_error_string(ilen)))
+#else
+ DBG((g_log,0, "send failed with %d\n",SSL_get_error(p->ssl, ilen)))
+#endif
#ifdef SYNC_SSL
printf("~1 send unlocked\n");
amutex_unlock(p->lock);
#endif
free(sbuf);
- if (rv == SSL_TIMEDOUT)
+
+#ifdef USING_AXTLS
+ if (ilen == SSL_TIMEDOUT)
+#else
+ if (SSL_get_error(p->ssl, ilen) == SSL_ERROR_WANT_READ
+ || SSL_get_error(p->ssl, ilen) == SSL_ERROR_WANT_WRITE)
+#endif
return ccpacket_timeout;
return ccpacket_send;
}
@@ -338,24 +374,53 @@ static ccpacket_err receive_ccpacket(ccpacket *p,
printf("~1 receive locked\n");
#endif
+ tlen = 4;
+
+#ifndef USING_AXTLS
+ if ((ibuf = malloc(tlen)) == NULL) {
+ return ccpacket_malloc;
+ }
+ ibuf[0] = ibuf[1] = ibuf[2] = ibuf[2] = 0;
+#endif
+
/* Until we have 4 bytes for the header */
- for (tlen = 4, rlen = 0; rlen < tlen;) {
+ for (rlen = 0; rlen < tlen;) {
ioff = 0;
- if ((ilen = ssl_read(p->ssl, &ibuf)) < 0) {
- DBG((dbgo, "header recv failed with '%s'\n",ssl_error_string(ilen)))
- if (ilen == SSL_OK) /* Hmm. */
- continue;
+#ifdef USING_AXTLS
+ if ((ilen = ssl_read(p->ssl, &ibuf)) < 0)
+#else
+ if ((ilen = SSL_read(p->ssl, ibuf, tlen)) < 0)
+#endif
+ {
+#ifdef USING_AXTLS
+ DBG((g_log,0, "header recv failed with '%s'\n",ssl_error_string(ilen)))
+#else
+ DBG((g_log,0, "header recv failed with %d\n",SSL_get_error(p->ssl, ilen)))
+#endif
#ifdef SYNC_SSL
printf("~1 receive unlocked\n");
amutex_unlock(p->lock);
#endif
+#ifdef USING_AXTLS
if (ilen == SSL_TIMEDOUT)
+#else
+ free(ibuf);
+ if (SSL_get_error(p->ssl, ilen) == SSL_ERROR_WANT_READ
+ || SSL_get_error(p->ssl, ilen) == SSL_ERROR_WANT_WRITE)
+#endif
return ccpacket_timeout;
return ccpacket_recv;
}
- DBG((dbgo, "receive_ccpacket read %d bytes\n",ilen))
- if (ilen == 0)
+ DBG((g_log,0, "receive_ccpacket read %d bytes\n",ilen))
+ if (ilen == 0) {
+#ifdef USING_AXTLS
continue;
+#else
+ DBG((g_log,0, "SSL_read failed\n"))
+ free(ibuf);
+ return ccpacket_recv;
+#endif
+ }
if ((clen = ilen) > (tlen - rlen)) /* More than we need */
clen = tlen - rlen;
memcpy(rbuf + rlen, ibuf + ioff, clen);
@@ -364,17 +429,17 @@ printf("~1 receive unlocked\n");
ilen -= clen;
}
/* We have ilen left in ibuf at offset ioff */
- DBG((dbgo, "receive_ccpacket %d bytes left over\n",ilen))
+ DBG((g_log,0, "receive_ccpacket %d bytes left over\n",ilen))
- tlen = read_ORD32_be(ibuf);
- DBG((dbgo, "receive_ccpacket expecting %d more bytes\n",tlen))
+ tlen = read_ORD32_be(rbuf);
+ DBG((g_log,0, "receive_ccpacket expecting %d more bytes\n",tlen))
if (tlen < 0 || tlen > 64 * 2014) {
#ifdef SYNC_SSL
printf("~1 receive unlocked\n");
amutex_unlock(p->lock);
#endif
- DBG((dbgo, "receive_ccpacket got bad data length - returning error\n"))
+ DBG((g_log,0, "receive_ccpacket got bad data length - returning error\n"))
return ccpacket_recv;
}
@@ -383,7 +448,7 @@ printf("~1 receive unlocked\n");
printf("~1 receive unlocked\n");
amutex_unlock(p->lock);
#endif
- DBG((dbgo, "receive_ccpacket malloc failed\n"))
+ DBG((g_log,0, "receive_ccpacket malloc failed\n"))
return ccpacket_malloc;
}
rlen = 0;
@@ -392,31 +457,58 @@ printf("~1 receive unlocked\n");
if (ilen > 0) {
if ((clen = ilen) > (tlen - rlen))
clen = tlen - rlen;
- DBG((dbgo, "receive_ccpacket using %d spair bytesr\n",clen))
+ DBG((g_log,0, "receive_ccpacket using %d spair bytesr\n",clen))
memcpy(rbuf + rlen, ibuf + ioff, clen);
rlen += clen;
ioff += clen;
ilen -= clen;
}
+#ifndef USING_AXTLS
+ free(ibuf);
+ if ((ibuf = malloc(tlen)) == NULL) {
+ return ccpacket_malloc;
+ }
+#endif
+
/* Get the remainder of the body if we need to */
for (; rlen < tlen;) {
ioff = 0;
- if ((ilen = ssl_read(p->ssl, &ibuf)) < 0) {
- DBG((dbgo, "body recv failed with '%s'\n",ssl_error_string(ilen)))
- if (ilen == SSL_OK)
- continue;
+#ifdef USING_AXTLS
+ if ((ilen = ssl_read(p->ssl, &ibuf)) < 0)
+#else
+ if ((ilen = SSL_read(p->ssl, ibuf, tlen)) < 0)
+#endif
+ {
+#ifdef USING_AXTLS
+ DBG((g_log,0, "body recv failed with '%s'\n",ssl_error_string(ilen)))
+#else
+ DBG((g_log,0, "body recv failed with %d\n",SSL_get_error(p->ssl, ilen)))
+#endif
#ifdef SYNC_SSL
printf("~1 receive unlocked\n");
amutex_unlock(p->lock);
#endif
+#ifdef USING_AXTLS
if (ilen == SSL_TIMEDOUT)
+#else
+ free(ibuf);
+ if (SSL_get_error(p->ssl, ilen) == SSL_ERROR_WANT_READ
+ || SSL_get_error(p->ssl, ilen) == SSL_ERROR_WANT_WRITE)
+#endif
return ccpacket_timeout;
return ccpacket_recv;
}
- DBG((dbgo, "receive_ccpacket read %d bytes\n",ilen))
- if (ilen == 0)
+ DBG((g_log,0, "receive_ccpacket read %d bytes\n",ilen))
+ if (ilen == 0) {
+#ifdef USING_AXTLS
continue;
+#else
+ DBG((g_log,0, "SSL_read failed\n"))
+ free(ibuf);
+ return ccpacket_recv;
+#endif
+ }
if ((clen = ilen) > (tlen - rlen))
clen = tlen - rlen;
memcpy(rbuf + rlen, ibuf + ioff, clen);
@@ -429,11 +521,14 @@ printf("~1 receive unlocked\n");
amutex_unlock(p->lock);
#endif
if (ilen > 0) { /* Hmm. We should keep this for the next read ?*/
- DBG((dbgo, " ################## got %d byts left over ###########\n", ilen))
+ DBG((g_log,0, " ################## got %d byts left over ###########\n", ilen))
}
+#ifndef USING_AXTLS
+ free(ibuf);
+#endif
#if defined(DEBUG) && defined(DUMPRDATA)
printf("receive_ccpacket got:\n");
- cc_dump_bytes(dbgo," ", rbuf, rlen);
+ adump_bytes(g_log," ", rbuf, 0, rlen);
#endif
*pbuf = rbuf;
*plen = rlen;
@@ -446,11 +541,19 @@ static void clear_ccpacket(ccpacket *p) {
if (p != NULL) {
if (p->ssl != NULL) {
+#ifdef USING_AXTLS
ssl_free(p->ssl);
+#else
+ SSL_free(p->ssl);
+#endif
p->ssl = NULL;
}
if (p->ctx != NULL) {
+#ifdef USING_AXTLS
ssl_ctx_free(p->ctx);
+#else
+ SSL_CTX_free(p->ctx);
+#endif
p->ctx = NULL;
}
if (p->sock != INVALID_SOCKET) {
@@ -480,8 +583,13 @@ static void del_ccpacket(ccpacket *p) {
ccpacket *new_ccpacket() {
ccpacket *p = NULL;
+#ifndef USING_AXTLS
+ SSL_load_error_strings();
+ SSL_library_init();
+#endif
+
if ((p = (ccpacket *)calloc(1, sizeof(ccpacket))) == NULL) {
- DBG((dbgo, "calloc failed\n"))
+ DBG((g_log,0, "calloc failed\n"))
return NULL;
}
diff --git a/ccast/ccpacket.h b/ccast/ccpacket.h
index e4f6f76..e4f6f76 100644..100755
--- a/ccast/ccpacket.h
+++ b/ccast/ccpacket.h
diff --git a/ccast/cctest.c b/ccast/cctest.c
index 2c95ae1..2000cc5 100644..100755
--- a/ccast/cctest.c
+++ b/ccast/cctest.c
@@ -67,7 +67,7 @@ static int get_a_reply(ccmessv *mes, ORD8 **pdata) {
printf(" binary = %d\n",binary);
if (binary) {
printf(" payload =\n");
- cc_dump_bytes(stdout, " ", data, bin_len);
+ adump_bytes(g_log, " ", data, 0, bin_len);
} else {
printf(" payload = '%s'\n",data);
}
diff --git a/ccast/chan/cast_channel.pb-c.c b/ccast/chan/cast_channel.pb-c.c
index ec79608..ec79608 100644..100755
--- a/ccast/chan/cast_channel.pb-c.c
+++ b/ccast/chan/cast_channel.pb-c.c
diff --git a/ccast/chan/cast_channel.pb-c.h b/ccast/chan/cast_channel.pb-c.h
index 982e420..982e420 100644..100755
--- a/ccast/chan/cast_channel.pb-c.h
+++ b/ccast/chan/cast_channel.pb-c.h
diff --git a/ccast/chan/protobuf-c.c b/ccast/chan/protobuf-c.c
index 1157d8b..1157d8b 100644..100755
--- a/ccast/chan/protobuf-c.c
+++ b/ccast/chan/protobuf-c.c
diff --git a/ccast/chan/protobuf-c.h b/ccast/chan/protobuf-c.h
index 8c4ba1d..8c4ba1d 100644..100755
--- a/ccast/chan/protobuf-c.h
+++ b/ccast/chan/protobuf-c.h
diff --git a/ccast/dpat.c b/ccast/dpat.c
index 4962ae1..106c52a 100644..100755
--- a/ccast/dpat.c
+++ b/ccast/dpat.c
@@ -392,7 +392,7 @@ double get_ccast_dith(double ipat[DISIZE][DISIZE][3], double val[3]) {
/* 32 bit pseudo random sequencer based on XOR feedback */
/* generates number between 1 and 4294967295 */
-#define PSRAND32(S) (((S) & 0x80000000) ? (((S) << 1) ^ 0xa398655d) : ((S) << 1))
+#define PSRAND32F(S) (((S) & 0x80000000) ? (((S) << 1) ^ 0xa398655d) : ((S) << 1))
/* Locate the 8 surrounding RGB verticies */
for (n = 0; n < 8; n++) {
@@ -662,7 +662,7 @@ double get_ccast_dith(double ipat[DISIZE][DISIZE][3], double val[3]) {
// dot += d_rand(-rlevel, rlevel);
/* use a deterministic random element, so that */
/* the dither patterns are repeatable. */
- randv = PSRAND32(randv);
+ randv = PSRAND32F(randv);
dot += rlevel * 2.0 * ((randv - 1)/4294967294.0 - 0.5);
if (dot <= 0.0)
diff --git a/ccast/filt.c b/ccast/filt.c
index ab075ae..ab075ae 100644..100755
--- a/ccast/filt.c
+++ b/ccast/filt.c