diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2022-04-29 20:17:49 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2022-06-16 13:04:33 +0200 |
commit | ace6adb548a4f89a3ae1c59dd8c34b0b5b2a337d (patch) | |
tree | 370a84e0bd54ebc2f05733d4d9d524643b0faa74 /src | |
parent | 184360f3b7acb9a54173dc36a74d4302ed78a8a0 (diff) |
api: add osmo_pfcp_ie_node_id_to_str_c()
So far we had only osmo_pfcp_enc_to_str_node_id(), used for PFCP message
to string conversion. It behaves like a common _to_str_buf() function,
but has an inconvenient void* arg (for use with libosmo-tlv).
Implement the string conversion as common _to_str_buf() and _to_str_c()
functions, and call that from osmo_pfcp_enc_to_str_node_id(). That's
useful for log messages coming up in a subsequent patch.
Related: SYS#5599
Change-Id: I5c580bc510afce58a03dea0861db9630b063b2ae
Diffstat (limited to 'src')
-rw-r--r-- | src/libosmo-pfcp/pfcp_ies_custom.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 660a08d..5975a29 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -317,9 +317,8 @@ int osmo_pfcp_enc_node_id(struct osmo_gtlv_put *tlv, const void *decoded_struct, return 0; } -int osmo_pfcp_enc_to_str_node_id(char *buf, size_t buflen, const void *encode_from) +int osmo_pfcp_ie_node_id_to_str_buf(char *buf, size_t buflen, const struct osmo_pfcp_ie_node_id *node_id) { - const struct osmo_pfcp_ie_node_id *node_id = encode_from; struct osmo_strbuf sb = { .buf = buf, .len = buflen }; switch (node_id->type) { @@ -343,6 +342,16 @@ int osmo_pfcp_enc_to_str_node_id(char *buf, size_t buflen, const void *encode_fr return sb.chars_needed; } +char *osmo_pfcp_ie_node_id_to_str_c(void *ctx, const struct osmo_pfcp_ie_node_id *node_id) +{ + OSMO_NAME_C_IMPL(ctx, 64, "ERROR", osmo_pfcp_ie_node_id_to_str_buf, node_id) +} + +int osmo_pfcp_enc_to_str_node_id(char *buf, size_t buflen, const void *encode_from) +{ + return osmo_pfcp_ie_node_id_to_str_buf(buf, buflen, encode_from); +} + bool osmo_pfcp_bits_get(const uint8_t *bits, unsigned int bitpos) { unsigned int bytenum = bitpos / 8; |