neels has uploaded this change for review.
add LOG_HNBP() for hnb_persistent
Add macro for the pattern LOGP(DHNB, ..., "%s: ...", hnbp->id_str)
and use where applicable.
Change-Id: I23334124074491fb3b91e720b67c97181c16bc21
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw.c
2 files changed, 23 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/75/37075/1
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index 9b07584..c28f8bc 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -41,6 +41,12 @@
#define LOGHNB(HNB_CTX, ss, lvl, fmt, args ...) \
LOGP(ss, lvl, "(%s) " fmt, hnb_context_name(HNB_CTX), ## args)
+#define LOG_HNBP(HNBP, lvl, fmt, args...) \
+ LOGP(DHNB, lvl, "(%s) " fmt, \
+ (HNBP) ? \
+ (((HNBP)->id_str && *(HNBP)->id_str) ? (HNBP)->id_str : "no-cell-id") \
+ : "null", ## args)
+
#define DOMAIN_CS RANAP_CN_DomainIndicator_cs_domain
#define DOMAIN_PS RANAP_CN_DomainIndicator_ps_domain
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index 20a665e..20d6aa6 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -613,19 +613,17 @@
fd = osmo_stream_srv_get_fd(hnbp->ctx->conn);
if (fd < 0) {
- LOGP(DHNB, LOGL_ERROR, "%s: no active socket fd, cannot set up traffic counters\n", hnbp->id_str);
+ LOG_HNBP(hnbp, LOGL_ERROR, "no active socket fd, cannot set up traffic counters\n");
return;
}
socklen = sizeof(struct osmo_sockaddr);
if (getpeername(fd, &osa.u.sa, &socklen)) {
- LOGP(DHNB, LOGL_ERROR, "%s: cannot read remote address, cannot set up traffic counters\n",
- hnbp->id_str);
+ LOG_HNBP(hnbp, LOGL_ERROR, "cannot read remote address, cannot set up traffic counters\n");
return;
}
if (osmo_sockaddr_str_from_osa(&remote_str, &osa)) {
- LOGP(DHNB, LOGL_ERROR, "%s: cannot parse remote address, cannot set up traffic counters\n",
- hnbp->id_str);
+ LOG_HNBP(hnbp, LOGL_ERROR, "cannot parse remote address, cannot set up traffic counters\n");
return;
}
@@ -634,7 +632,7 @@
remote_str.port = 2152;
if (nft_kpi_hnb_start(hnbp, &remote_str))
- LOGP(DHNB, LOGL_ERROR, "%s: failed to set up traffic counters\n", hnbp->id_str);
+ LOG_HNBP(hnbp, LOGL_ERROR, "failed to set up traffic counters\n");
}
/* Whenever HNBAP registers a HNB, hnbgw_hnbap.c calls this function to let the hnb_persistent update its state to the
@@ -643,7 +641,7 @@
void hnb_persistent_registered(struct hnb_persistent *hnbp)
{
if (!hnbp->ctx) {
- LOGP(DHNB, LOGL_ERROR, "hnb_persistent_registered() invoked, but there is no hnb_ctx\n");
+ LOG_HNBP(hnbp, LOGL_ERROR, "hnb_persistent_registered() invoked, but there is no hnb_ctx\n");
return;
}
To view, visit change 37075. To unsubscribe, or for help writing mail filters, visit settings.