aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/pfcp/pfcp_msg.h25
-rw-r--r--src/libosmo-pfcp/pfcp_msg.c40
2 files changed, 45 insertions, 20 deletions
diff --git a/include/osmocom/pfcp/pfcp_msg.h b/include/osmocom/pfcp/pfcp_msg.h
index 4affa54..fed1114 100644
--- a/include/osmocom/pfcp/pfcp_msg.h
+++ b/include/osmocom/pfcp/pfcp_msg.h
@@ -42,26 +42,8 @@ struct osmo_pfcp_msg;
#define OSMO_PFCP_MSGB_ALLOC_SIZE 2048
-#define OSMO_LOG_PFCP_MSG_SRC(M, LEVEL, file, line, FMT, ARGS...) do { \
- struct osmo_fsm_inst *_fi = (M) ? ((M)->ctx.session_fi ?: (M)->ctx.peer_fi) : NULL; \
- enum osmo_pfcp_cause *cause = osmo_pfcp_msg_cause(M); \
- if ((M)->h.seid_present) { \
- LOGPFSMSLSRC(_fi, DLPFCP, LEVEL, file, line, \
- "%s%s PFCP seq-%u SEID-0x%"PRIx64" %s%s%s: " FMT, \
- _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) : "", ##ARGS); \
- } else { \
- LOGPFSMSLSRC(_fi, DLPFCP, LEVEL, file, line, \
- "%s%s PFCP seq-%u %s%s%s: " FMT, \
- _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) : "", ##ARGS); \
- } \
- } while (0)
+#define OSMO_LOG_PFCP_MSG_SRC(M, LEVEL, file, line, FMT, ARGS...) \
+ osmo_log_pfcp_msg_src(M, LEVEL, file, line, FMT, ##ARGS)
#define OSMO_LOG_PFCP_MSG(M, LEVEL, FMT, ARGS...) \
OSMO_LOG_PFCP_MSG_SRC(M, LEVEL, __FILE__, __LINE__, FMT, ##ARGS)
@@ -198,3 +180,6 @@ static inline struct osmo_pfcp_ie_node_id *osmo_pfcp_msg_node_id(const struct os
int osmo_pfcp_msg_to_str_buf(char *buf, size_t buflen, const struct osmo_pfcp_msg *m);
char *osmo_pfcp_msg_to_str_c(void *ctx, const struct osmo_pfcp_msg *m);
+
+void osmo_log_pfcp_msg_src(const struct osmo_pfcp_msg *m, unsigned int level, const char *file, int line,
+ const char *fmt, ...);
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);
+}