aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-10-24 21:53:40 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-04-16 09:17:21 +0200
commit462b7d7158937b51fbb833ea3066e01fe8322f37 (patch)
tree9588a91447f6496c36ea815af62fbc48721061b0 /openbsc/src/libmgcp
parentc327187259d74cf260c977f165963778de4bedb1 (diff)
nat: We want the remote to respond to our DLCX request
We want to send a TRAP with the MGCP statistics from the NAT and the connected BSC. The BSC endpoint can be either released because of a DLCX from the MGCP CallAgent or the SCCP Connection release on the A-link. This is why we need to queue the statistics when the deleting the endpoint on the BSC. The processing is continued once the response arrives. This code assumes that the response of the DLCX will be sent by the remote side. The current amount of outstanding responses can be seen on the VTY. This assumption is based on the fact that the BSC has already responded to the CRCX and maybe to the MDCX. The MGCP RFC is bended to prefix the transaction identifier with "nat-" to easily detect the response and hand it to the handler. This will then parse the response and generate the TRAP. The current version is v1. We assume that the transaction space is big enough and we will not re-assign the transaction identifier too early.
Diffstat (limited to 'openbsc/src/libmgcp')
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 6919a591d..dc5e0f992 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -1167,9 +1167,37 @@ void mgcp_format_stats(struct mgcp_endpoint *endp, char *msg, size_t size)
&expected, &ploss);
jitter = mgcp_state_calc_jitter(&endp->net_state);
- snprintf(msg, size, "\r\nP: PS=%u, OS=%u, PR=%u, OR=%u, PL=%d, JI=%d",
+ snprintf(msg, size, "\r\nP: PS=%u, OS=%u, PR=%u, OR=%u, PL=%d, JI=%u",
endp->bts_end.packets, endp->bts_end.octets,
endp->net_end.packets, endp->net_end.octets,
ploss, jitter);
msg[size - 1] = '\0';
}
+
+int mgcp_parse_stats(struct msgb *msg, uint32_t *ps, uint32_t *os,
+ uint32_t *pr, uint32_t *_or, int *loss, uint32_t *jitter)
+{
+ char *line, *save;
+ int rc;
+
+ /* initialize with bad values */
+ *ps = *os = *pr = *_or = *jitter = UINT_MAX;
+ *loss = INT_MAX;
+
+
+ line = strtok_r((char *) msg->l2h, "\r\n", &save);
+ if (!line)
+ return -1;
+
+ /* this can only parse the message that is created above... */
+ for_each_line(line, save) {
+ switch (line[0]) {
+ case 'P':
+ rc = sscanf(line, "P: PS=%u, OS=%u, PR=%u, OR=%u, PL=%d, JI=%u",
+ ps, os, pr, _or, loss, jitter);
+ return rc == 6 ? 0 : -1;
+ }
+ }
+
+ return -1;
+}