diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2022-06-08 14:00:03 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2022-08-09 18:21:23 +0200 |
commit | ac517a9b6595aee327d0d3e766e220d24a4c9881 (patch) | |
tree | bae39f2ccec4f58c2bb6c63e8fd65fc35706c2f0 /src | |
parent | a2c40c4dbe035fb5420bef75eba35756ab1bf73e (diff) |
implement OSMO_LOG_PFCP_MSG_SRC as va function
This was requested by code review.
Change-Id: I1713868ebb9583c67f0a4ecc9558263f6888a24d
Diffstat (limited to 'src')
-rw-r--r-- | src/libosmo-pfcp/pfcp_msg.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libosmo-pfcp/pfcp_msg.c b/src/libosmo-pfcp/pfcp_msg.c index 5f55575..debd329 100644 --- a/src/libosmo-pfcp/pfcp_msg.c +++ b/src/libosmo-pfcp/pfcp_msg.c @@ -546,3 +546,43 @@ char *osmo_pfcp_msg_to_str_c(void *ctx, const struct osmo_pfcp_msg *m) { OSMO_NAME_C_IMPL(ctx, 256, "ERROR", osmo_pfcp_msg_to_str_buf, m) } + +void osmo_log_pfcp_msg_src(const struct osmo_pfcp_msg *m, unsigned int level, const char *file, int line, + const char *fmt, ...) +{ + va_list ap; + struct osmo_fsm_inst *fi; + enum osmo_pfcp_cause *cause; + char *msg; + + if (!log_check_level(DLPFCP, level)) + return; + + fi = m ? (m->ctx.session_fi ?: m->ctx.peer_fi) : NULL; + cause = osmo_pfcp_msg_cause(m); + + va_start(ap, fmt); + msg = talloc_vasprintf(m, fmt, ap); + va_end(ap); + + if (m->h.seid_present) { + LOGPFSMSLSRC(fi, DLPFCP, level, file, line, + "%s%s PFCP seq-%u SEID-0x%"PRIx64" %s%s%s: %s", + fi ? "" : osmo_sockaddr_to_str_c(OTC_SELECT, &m->remote_addr), + m->rx ? "-rx->" : "<-tx-", m->h.sequence_nr, + m->h.seid, + osmo_pfcp_message_type_str(m->h.message_type), cause ? ": " : "", + cause ? osmo_pfcp_cause_str(*cause) : "", + msg); + } else { + LOGPFSMSLSRC(fi, DLPFCP, level, file, line, + "%s%s PFCP seq-%u %s%s%s: %s", + fi ? "" : osmo_sockaddr_to_str_c(OTC_SELECT, &m->remote_addr), + m->rx ? "-rx->" : "<-tx-", m->h.sequence_nr, + osmo_pfcp_message_type_str(m->h.message_type), cause ? ": " : "", + cause ? osmo_pfcp_cause_str(*cause) : "", + msg); + } + + talloc_free(msg); +} |