]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
Add modifications suggested by https://github.com/mikebrady/nqptp/issues/14 to restri...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 27 Jan 2023 18:30:50 +0000 (18:30 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 27 Jan 2023 18:30:50 +0000 (18:30 +0000)
nqptp-utilities.c
nqptp-utilities.h
nqptp.c

index a28c9cea6c3a9822660896f46249bab954f538c7..89408685e6ab3b37e2870906879383f890bc0d70 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "debug.h"
 
-void open_sockets_at_port(uint16_t port, sockets_open_bundle *sockets_open_stuff) {
+void open_sockets_at_port(const char *node, uint16_t port, sockets_open_bundle *sockets_open_stuff) {
   // open up sockets for UDP ports 319 and 320
 
   struct addrinfo hints, *info, *p;
@@ -57,7 +57,7 @@ void open_sockets_at_port(uint16_t port, sockets_open_bundle *sockets_open_stuff
   char portstr[20];
   snprintf(portstr, 20, "%d", port);
 
-  ret = getaddrinfo(NULL, portstr, &hints, &info);
+  ret = getaddrinfo(node, portstr, &hints, &info);
   if (ret) {
     die("getifaddrs: %s", gai_strerror(ret));
   }
index 82adad6d8dfd8b68fed94cb3e02ba4781580f135..a0643a8cef23bb7e875b51748aabe5ab0d6ef61a 100644 (file)
@@ -38,7 +38,7 @@ typedef struct {
   socket_info sockets[MAX_OPEN_SOCKETS];
 } sockets_open_bundle;
 
-void open_sockets_at_port(uint16_t port, sockets_open_bundle *sockets_open_stuff);
+void open_sockets_at_port(const char *node, uint16_t port, sockets_open_bundle *sockets_open_stuff);
 void debug_print_buffer(int level, char *buf, size_t buf_len);
 uint64_t get_self_clock_id(); // a clock ID based on a MAC address
 #endif
\ No newline at end of file
diff --git a/nqptp.c b/nqptp.c
index aab6203d60abc9970d23ccfa017d44877ce13c32..2c2ba387f8e274d69d9e1f9899ac065fb5df2c60 100644 (file)
--- a/nqptp.c
+++ b/nqptp.c
@@ -253,9 +253,9 @@ int main(int argc, char **argv) {
 
   // open sockets 319 and 320
 
-  open_sockets_at_port(319, &sockets_open_stuff);
-  open_sockets_at_port(320, &sockets_open_stuff);
-  open_sockets_at_port(NQPTP_CONTROL_PORT,
+  open_sockets_at_port(NULL, 319, &sockets_open_stuff);
+  open_sockets_at_port(NULL, 320, &sockets_open_stuff);
+  open_sockets_at_port("localhost", NQPTP_CONTROL_PORT,
                        &sockets_open_stuff); // this for messages from the client
 
   // start the timed tasks