pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39720?usp=email )
Change subject: mgw: Add backpointer from pdata to req to have context available ...................................................................... mgw: Add backpointer from pdata to req to have context available This will also allow eg. parsing/validating differently based on the command being parsed, or incrementing rate counters per cmd group. Change-Id: I464258ca1a8817d58ae5c5426dfc3b7cee6763d3 --- M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_msg.c M src/libosmo-mgcp/mgcp_protocol.c 3 files changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/20/39720/1 diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index e61669c..2ef4c3e 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -71,7 +71,9 @@ } /* Internal structure while parsing a request */ +struct mgcp_request_data; struct mgcp_parse_data { + struct mgcp_request_data *rq; /* backpointer to request context */ char *save; /* MGCP Header: */ char *epname; diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c index 2269a66..af4f9d0 100644 --- a/src/libosmo-mgcp/mgcp_msg.c +++ b/src/libosmo-mgcp/mgcp_msg.c @@ -36,7 +36,7 @@ /* (same fmt as LOGPENDP()) */ #define LOG_MGCP_PDATA(PDATA, LEVEL, FMT, ARGS...) \ - LOGP(DLMGCP, LEVEL, "endpoint:%s " FMT, (PDATA) ? ((PDATA)->epname ? : "null-epname") : "null-pdata", ##ARGS) + LOGP(DLMGCP, LEVEL, "%s: endpoint(%s) " FMT, (PDATA)->rq->name, (PDATA)->epname ? : "null-epname", ##ARGS) /*! Display an mgcp message on the log output. * \param[in] message mgcp message string @@ -212,7 +212,7 @@ hp->have_sdp = true; goto mgcp_header_done; default: - LOG_MGCP_PDATA(pdata, LOGL_NOTICE, "CRCX: unhandled option: '%c'/%d\n", *line, *line); + LOG_MGCP_PDATA(pdata, LOGL_NOTICE, "unhandled option: '%c'/%d\n", *line, *line); return -539; } } diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 1215b95..1eb241b 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -332,6 +332,7 @@ memset(&rq, 0, sizeof(rq)); rq.cfg = cfg; memset(&pdata, 0, sizeof(pdata)); + pdata.rq = &rq; /* Parse command name: */ memcpy(rq.name, (const char *)&msg->l2h[0], sizeof(rq.name)-1); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39720?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I464258ca1a8817d58ae5c5426dfc3b7cee6763d3 Gerrit-Change-Number: 39720 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de>