From 3a3e1b57c63883de296f4a071710e92514d598ef Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 22 Dec 2023 02:46:28 +0100 Subject: [PATCH] client SDP: more verbose error logging So far it was pure guess work to find out why a message fails. Change-Id: Ibc6343db82281789004c140ba98d99e5f6f73d83 --- src/libosmo-mgcp-client/mgcp_client.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c index 8df65cdc0..489ce6942 100644 --- a/src/libosmo-mgcp-client/mgcp_client.c +++ b/src/libosmo-mgcp-client/mgcp_client.c @@ -329,20 +329,31 @@ static int mgcp_parse_audio_port_pt(struct mgcp_response *r, char *line) errno = 0; pt = strtoul(pt_str, &pt_end, 0); if ((errno == ERANGE && pt == ULONG_MAX) || (errno && !pt) || - pt_str == pt_end) + pt_str == pt_end) { + LOGP(DLMGCP, LOGL_ERROR, "SDP: cannot parse payload type number from '%s'\n", pt_str); goto response_parse_failure_pt; + } - if (pt >> 7) /* PT is 7 bit field, higher values not allowed */ + /* PT is 7 bit field, higher values not allowed */ + if (pt >> 7) { + LOGP(DLMGCP, LOGL_ERROR, "SDP: payload type number out of range: %lu > 127\n", pt); goto response_parse_failure_pt; + } /* Do not allow duplicate payload types */ - for (i = 0; i < ptmap_len; i++) - if (r->ptmap[i].pt == pt) + for (i = 0; i < ptmap_len; i++) { + if (r->ptmap[i].pt == pt) { + LOGP(DLMGCP, LOGL_ERROR, "SDP: payload type number %lu listed twice\n", pt); goto response_parse_failure_pt; + } + } /* Do not allow excessive payload types */ - if (ptmap_len >= ARRAY_SIZE(r->ptmap)) + if (ptmap_len >= ARRAY_SIZE(r->ptmap)) { + LOGP(DLMGCP, LOGL_ERROR, + "SDP: can parse only up to %zu payload type numbers\n", ARRAY_SIZE(r->ptmap)); goto response_parse_failure_pt; + } /* Some payload type numbers imply a specific codec. For those, using the PT number as enum mgcp_codecs * yields the correct result. If no more specific information on the codec follows in "a=rtpmap:N"