aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core/socket.h
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2021-12-01 10:25:02 +0100
committerneels <nhofmeyr@sysmocom.de>2022-01-31 15:03:53 +0000
commit09d6574a457d3f06a372990b83311bbd4b98757c (patch)
tree06c379f68d470995f66220aa9ec8a1083dd2aa36 /include/osmocom/core/socket.h
parente56f1b67f4330978c152a0b9cbfb4e37b974bb67 (diff)
add osmo_sockaddr_to_str_c(), osmo_sockaddr_to_str_buf2()
To easily log and print a sockaddr using OTC_SELECT, add osmo_sockaddr_to_str_c(). Implement osmo_sockaddr_to_str_buf2() using osmo_strbuf, so that we can return the chars_needed which osmo_sockaddr_to_str_c() uses. From previous osmo_sockaddr_to_str_buf(), call osmo_sockaddr_to_str_buf2() and return NULL if the buf_len was insufficient, to mimick previous behavior. This makes it more consistently returning NULL for insufficient buf_len, as shown in the tweak that is needed in socket_test.c. Before osmo_sockaddr_to_str_buf() would return a truncated port number, now it's all or NULL. I will use osmo_sockaddr_to_str_c() in the new osmo-upf implementation. Related: SYS#5599 Change-Id: I12771bf8a021e6785217b1faad03c09ec1cfef0e
Diffstat (limited to 'include/osmocom/core/socket.h')
-rw-r--r--include/osmocom/core/socket.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index a053391d..6d11e6f0 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -130,6 +130,8 @@ int osmo_sockaddr_cmp(const struct osmo_sockaddr *a,
const char *osmo_sockaddr_to_str(const struct osmo_sockaddr *sockaddr);
char *osmo_sockaddr_to_str_buf(char *buf, size_t buf_len,
const struct osmo_sockaddr *sockaddr);
+int osmo_sockaddr_to_str_buf2(char *buf, size_t buf_len, const struct osmo_sockaddr *sockaddr);
+char *osmo_sockaddr_to_str_c(void *ctx, const struct osmo_sockaddr *sockaddr);
int osmo_sock_set_dscp(int fd, uint8_t dscp);
int osmo_sock_set_priority(int fd, int prio);