aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmgcp/mgcp_protocol.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-04-09 12:32:51 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-08-30 14:12:37 +0200
commitefe85d33d4948a20de1baec2e8956113714ec72e (patch)
tree144135f7b5ae2584ca71377c424024c9b535ed73 /src/libmgcp/mgcp_protocol.c
parent868dd5d8d31f756e404a7bfb7896aed21d20f905 (diff)
Implement AoIP, port to M3UA SIGTRAN (large addition and refactoring)
This was originally a long series of commits converging to the final result seen in this patch. It does not make much sense to review the smaller steps' trial and error, we need to review this entire change as a whole. Implement AoIP in osmo-msc and osmo-bsc. Change over to the new libosmo-sigtran API with support for proper SCCP/M3UA/SCTP stacking, as mandated by 3GPP specifications for the IuCS and IuPS interfaces. From here on, a separate osmo-stp process is required for SCCP routing between OsmoBSC / OsmoHNBGW <-> OsmoMSC / OsmoSGSN jenkins.sh: build from libosmo-sccp and osmo-iuh master branches now for new M3UA SIGTRAN. Patch-by: pmaier, nhofmeyr, laforge Change-Id: I5ae4e05ee7c57cad341ea5e86af37c1f6b0ffa77
Diffstat (limited to 'src/libmgcp/mgcp_protocol.c')
-rw-r--r--src/libmgcp/mgcp_protocol.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/libmgcp/mgcp_protocol.c b/src/libmgcp/mgcp_protocol.c
index 96542c5a0..c8b6e8660 100644
--- a/src/libmgcp/mgcp_protocol.c
+++ b/src/libmgcp/mgcp_protocol.c
@@ -66,6 +66,45 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp);
static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data);
+/* Display an mgcp message on the log output */
+void display_mgcp_message(unsigned char *message, unsigned int len,
+ char *preamble)
+{
+ unsigned char line[80];
+ unsigned char *ptr;
+ unsigned int consumed = 0;
+ unsigned int consumed_line = 0;
+ unsigned int line_count = 0;
+
+ if (!log_check_level(DMGCP, LOGL_DEBUG))
+ return;
+
+ while (1) {
+ memset(line, 0, sizeof(line));
+ ptr = line;
+ consumed_line = 0;
+ do {
+ if (*message != '\n' && *message != '\r') {
+ *ptr = *message;
+ ptr++;
+ }
+ message++;
+ consumed++;
+ consumed_line++;
+ } while (*message != '\n' && consumed < len
+ && consumed_line < sizeof(line));
+
+ if (strlen((const char *)line)) {
+ LOGP(DMGCP, LOGL_DEBUG, "%s: line #%02u: %s\n",
+ preamble, line_count, line);
+ line_count++;
+ }
+
+ if (consumed >= len)
+ return;
+ }
+}
+
static int mgcp_check_param(const struct mgcp_endpoint *endp, const char *line)
{
const size_t line_len = strlen(line);
@@ -157,7 +196,8 @@ static struct msgb *create_resp(struct mgcp_endpoint *endp, int code,
}
res->l2h = msgb_put(res, len);
- LOGP(DMGCP, LOGL_DEBUG, "Generated response: code: %d for '%s'\n", code, res->l2h);
+ LOGP(DMGCP, LOGL_DEBUG, "Generated response: code=%d\n", code);
+ display_mgcp_message(res->l2h, msgb_l2len(res), "Generated response");
/*
* Remember the last transmission per endpoint.
@@ -329,6 +369,8 @@ struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg)
if (mgcp_msg_terminate_nul(msg))
return NULL;
+ display_mgcp_message(msg->l2h, msgb_l2len(msg), "Received message");
+
/* attempt to treat it as a response */
if (sscanf((const char *)&msg->l2h[0], "%3d %*s", &code) == 1) {
LOGP(DMGCP, LOGL_DEBUG, "Response: Code: %d\n", code);