From cc419cf01d9c060a3bd3fc318f9b9bc9e736dae9 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 25 Oct 2025 11:43:59 -0700 Subject: Add stream direct address functions for socket addresses. This is going to be used to facilitate debugging, and eliminate some inconveniences around these things. We plan to move the pipe functions to use these directly, hopefully moving away from the pipe_getopt hack. (The transport API will need to grow these. For now this is just the streams.) --- src/core/socket.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/core/socket.c') diff --git a/src/core/socket.c b/src/core/socket.c index 7112014e..a7633c9e 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1301,7 +1301,8 @@ dialer_start_pipe(nni_dialer *d, nni_pipe *p) char addr[NNG_MAXADDRSTRLEN]; nng_log_debug("NNG-PIPEREJECT", "Pipe on socket<%u> from %s rejected by callback", - nni_pipe_sock_id(p), nni_pipe_peer_addr(p, addr)); + nni_pipe_sock_id(p), + nni_pipe_peer_str_addr(p, addr)); } nni_pipe_rele(p); return; @@ -1323,10 +1324,13 @@ dialer_start_pipe(nni_dialer *d, nni_pipe *p) #endif nni_pipe_run_cb(p, NNG_PIPE_EV_ADD_POST); if (nng_log_get_level() >= NNG_LOG_DEBUG) { - char addr[NNG_MAXADDRSTRLEN]; + char peer_addr[NNG_MAXADDRSTRLEN]; + char self_addr[NNG_MAXADDRSTRLEN]; nng_log_debug("NNG-CONNECT", - "Connected pipe<%u> on socket<%u> to %s", nni_pipe_id(p), - nni_sock_id(s), nni_pipe_peer_addr(p, addr)); + "Connected pipe<%u> on socket<%u> at %s to %s", + nni_pipe_id(p), nni_sock_id(s), + nni_pipe_self_str_addr(p, self_addr), + nni_pipe_peer_str_addr(p, peer_addr)); } nni_pipe_rele(p); } @@ -1429,10 +1433,13 @@ listener_start_pipe(nni_listener *l, nni_pipe *p) #endif nni_pipe_run_cb(p, NNG_PIPE_EV_ADD_POST); if (nng_log_get_level() >= NNG_LOG_DEBUG) { - char addr[NNG_MAXADDRSTRLEN]; + char peer_addr[NNG_MAXADDRSTRLEN]; + char self_addr[NNG_MAXADDRSTRLEN]; nng_log_debug("NNG-ACCEPT", - "Accepted pipe<%u> on socket<%u> from %s", nni_pipe_id(p), - nni_sock_id(s), nni_pipe_peer_addr(p, addr)); + "Accepted pipe<%u> on socket<%u> at %s from %s", + nni_pipe_id(p), nni_sock_id(s), + nni_pipe_self_str_addr(p, self_addr), + nni_pipe_peer_str_addr(p, peer_addr)); } // the socket now "owns" the pipe, and a pipe close should immediately -- cgit v1.2.3-70-g09d2