mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-01 20:43:47 +00:00
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
This commit is contained in:
@@ -71,7 +71,9 @@ static inline void mgcp_parse_hdr_pars_init(struct mgcp_parse_hdr_pars *hpars)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -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 @@ int mgcp_parse_hdr_pars(struct mgcp_parse_data *pdata)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,6 +332,7 @@ struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg)
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user