liblo icon indicating copy to clipboard operation
liblo copied to clipboard

oscdump doesn't show origin of messages. + oscsendfile doesn't handle some typetag variants correctly.

Open 7890 opened this issue 4 years ago • 0 comments

When using oscdump something I missed is to see where the messages are coming from.

The following patch adds IPAddress:Port to every dump line right after the timetag.

diff --git a/src/tools/oscdump.c b/src/tools/oscdump.c
index f4e2962..6842ed2 100644
--- a/src/tools/oscdump.c
+++ b/src/tools/oscdump.c
@@ -87,7 +87,7 @@ int messageHandler(const char *path, const char *types, lo_arg ** argv,
     int i;
 
     if (bundled) {
-        printf("%08x.%08x %s %s", tt_bundle.sec, tt_bundle.frac, path, types);
+        printf("%08x.%08x", tt_bundle.sec, tt_bundle.frac);
     }
     else {
         lo_timetag tt = lo_message_get_timestamp(msg);
@@ -95,12 +95,18 @@ int messageHandler(const char *path, const char *types, lo_arg ** argv,
             tt.frac == LO_TT_IMMEDIATE.frac)
         {
             lo_timetag_now(&tt_now);
-            printf("%08x.%08x %s %s", tt_now.sec, tt_now.frac, path, types);
+            printf("%08x.%08x", tt_now.sec, tt_now.frac);
         }
         else
-            printf("%08x.%08x %s %s", tt.sec, tt.frac, path, types);
+            printf("%08x.%08x", tt.sec, tt.frac);
     }
 
+    //print ip:port of remote host
+    printf(" %s:%s %s %s",
+           lo_address_get_hostname(lo_message_get_source(msg)),
+           lo_address_get_port    (lo_message_get_source(msg)),
+           path, types);
+
     for (i = 0; i < argc; i++) {
         printf(" ");
         lo_arg_pp((lo_type) types[i], argv[i]);

For the oscsendfile tool, to support new oscdump output (keeping support for old format):

diff --git a/src/tools/oscsendfile.c b/src/tools/oscsendfile.c
index 9353fea..b343d13 100644
--- a/src/tools/oscsendfile.c
+++ b/src/tools/oscsendfile.c
@@ -213,15 +213,19 @@ lo_message create_message(char **argv)
             }
         case LO_TRUE:
             lo_message_add_true(message);
+            argi++;
             break;
         case LO_FALSE:
             lo_message_add_false(message);
+            argi++;
             break;
         case LO_NIL:
             lo_message_add_nil(message);
+            argi++;
             break;
         case LO_INFINITUM:
             lo_message_add_infinitum(message);
+            argi++;
             break;
         default:
             fprintf(stderr, "Type '%c' is not supported or invalid.\n",
@@ -326,6 +330,11 @@ int send_file(lo_address target, double speed) {
                 tt_this->frac = 1;
             }
         }
+
+        //skip ip:port column (if present)
+        if (s && s[0] != '/')
+            s = strtok_r(0, delim, &p);
+
         if (s)
             path = s;
         else

Please note: the inserted argi++ are necessary to support more typetag variants. With the current implementation, a message /hi iFf 42 .42 shows the error (interleaved non-value type).

Best regards

7890 avatar Dec 24 '20 02:12 7890