diff --git a/examples/normCast.cpp b/examples/normCast.cpp index e280337..cea2fa1 100755 --- a/examples/normCast.cpp +++ b/examples/normCast.cpp @@ -89,9 +89,9 @@ class NormCaster assert(NORM_SESSION_INVALID != norm_session); NormSetMulticastInterface(norm_session, ifaceName); } - bool SetNormTxPort(UINT16 txPort, - bool enableReuse, - const char* txAddress) + bool SetNormTxPort(UINT16 txPort, + bool enableReuse, + const char* txAddress) { assert(NORM_SESSION_INVALID != norm_session); return NormSetTxPort(norm_session, txPort, enableReuse, txAddress); @@ -370,7 +370,7 @@ bool NormCaster::OpenNormSession(NormInstanceHandle instance, const char* addr, //NormSetTxRobustFactor(norm_session, 20); - NormSetGrttProbingTOS(norm_session, probe_tos); + NormSetGrttProbingTOS(norm_session, probe_tos); // this was for some experimental protocol work NormSetGrttProbingMode(norm_session, probe_mode); return true; @@ -895,8 +895,8 @@ void Usage() { fprintf(stderr, "Usage: normCast {send &| recv } [silent {on|off}]\n" " [repeat [updatesOnly]] [id ]\n" - " [addr [/]] [txAddr [/]]\n" - " [interface ] [loopback]\n" + " [addr [/]][txaddr [/]][txport ]\n" + " [interface ][reuse][loopback]\n" " [ack auto|[,,...]] [segment ]\n" " [block ] [parity ] [auto ]\n" " [cc|cce|ccl|rate ] [rxloss ]\n" @@ -924,9 +924,8 @@ int main(int argc, char* argv[]) unsigned int sessionPort = 6003; char sessionTxAddr[64]; - strcpy(sessionTxAddr, ""); + sessionTxAddr[0] = '\0'; unsigned int sessionTxPort = 0; - bool autoAck = false; @@ -947,6 +946,7 @@ int main(int argc, char* argv[]) double grtt_estimate = 0.001; NormProbingMode grtt_probing_mode = NORM_PROBE_ACTIVE; bool loopback = false; + bool reuse = false; NormCaster normCast; if (!normCast.Init()) @@ -1068,7 +1068,7 @@ int main(int argc, char* argv[]) sessionPort = atoi(portPtr); } } - else if (0 == strncmp(cmd, "txAddr", len)) + else if (0 == strncmp(cmd, "txaddr", len)) { const char* addrPtr = argv[i++]; const char* portPtr = strchr(addrPtr, '/'); @@ -1080,14 +1080,46 @@ int main(int argc, char* argv[]) else { size_t addrLen = portPtr - addrPtr; - if (addrLen > 63) addrLen = 63; // should issue error message + if (addrLen > 63) + { + fprintf(stderr, "normCast error: 'txaddr' value too long!\n"); + Usage(); + return -1; + } strncpy(sessionTxAddr, addrPtr, addrLen); sessionTxAddr[addrLen] = '\0'; portPtr++; - sessionTxPort = atoi(portPtr); + int txPort = atoi(argv[i++]); + if ((txPort <=0) || (txPort > 0x0000ffff)) + { + fprintf(stderr, "normCast error: invalid 'txport' value!\n"); + Usage(); + return -1; + } + sessionTxPort = txPort; } } - + else if (0 == strncmp(cmd, "txport", len)) + { + if (i >= argc) + { + fprintf(stderr, "normCast error: missing 'txport' value!\n"); + Usage(); + return -1; + } + int txPort = atoi(argv[i++]); + if ((txPort <=0) || (txPort > 0x0000ffff)) + { + fprintf(stderr, "normCast error: invalid 'txport' value!\n"); + Usage(); + return -1; + } + sessionTxPort = txPort; + } + else if (0 == strncmp(cmd, "reuse", len)) + { + reuse = true; + } else if (0 == strncmp(cmd, "id", len)) { if (i >= argc) @@ -1547,9 +1579,8 @@ int main(int argc, char* argv[]) normCast.SetNormTxRate(txRate); if (NULL != mcastIface) normCast.SetNormMulticastInterface(mcastIface); - if (NULL != sessionTxAddr) { - normCast.SetNormSetTxPort(sessionTxPort, true, sessionTxAddr); - } + if ('\0' != sessionTxAddr[0]) + normCast.SetNormTxPort(sessionTxPort, reuse, sessionTxAddr); if (trace) normCast.SetNormMessageTrace(true); diff --git a/makefiles/Makefile.macosx b/makefiles/Makefile.macosx index bb6068c..568fcf1 100755 --- a/makefiles/Makefile.macosx +++ b/makefiles/Makefile.macosx @@ -44,8 +44,10 @@ SYSTEM_SRC = ../protolib/src/unix/bpfCap.cpp # The "SYSTEM" keyword can be used for dependent makes SYSTEM = macosx +# TBD - provide means to build universal Mac OSX library (x86/arm64) + CC = g++ -SYSTEM_CFLAGS = -Wall -Wcast-align -fPIC -arch x86_64 +SYSTEM_CFLAGS = -Wall -Wcast-align -fPIC SYSTEM_SOFLAGS = -dynamiclib SYSTEM_SOEXT = dylib RANLIB = ranlib