From 77f7afe08e2529ff7be301f6cf5298207370807f Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 3 Feb 2010 09:54:43 +0100 Subject: [mgcp] Prepare the in process MGCP handling by adding callbacks * Call a callback when the endpoint was created, modified or deleted. This can be used by the BSC MUX to send a MGCP packet over TCP to the right the BSC to allocate the endpoint there with the right data, or it can be used in the BSC to send the right commands to the BTS. --- openbsc/src/mgcp/mgcp_protocol.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'openbsc/src') diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c index 763dadbcc..d09615743 100644 --- a/openbsc/src/mgcp/mgcp_protocol.c +++ b/openbsc/src/mgcp/mgcp_protocol.c @@ -162,6 +162,9 @@ static int handle_create_con(int fd, struct msgb *msg, struct sockaddr_in *sourc static int handle_delete_con(int fd, struct msgb *msg, struct sockaddr_in *source); static int handle_modify_con(int fd, struct msgb *msg, struct sockaddr_in *source); +static mgcp_change change_cb; +static void *change_cb_data; + static int generate_call_id() { int i; @@ -661,6 +664,9 @@ static int handle_create_con(int fd, struct msgb *msg, struct sockaddr_in *sourc LOGP(DMGCP, LOGL_NOTICE, "Creating endpoint on: 0x%x CI: %u port: %u\n", ENDPOINT_NUMBER(endp), endp->ci, endp->rtp_port); + if (change_cb) + change_cb(ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX, endp->rtp_port, change_cb_data); + return send_with_sdp(fd, endp, "CRCX", trans_id, source); error: LOGP(DMGCP, LOGL_ERROR, "Malformed line: %s on 0x%x with: line_start: %d %d\n", @@ -752,6 +758,8 @@ static int handle_modify_con(int fd, struct msgb *msg, struct sockaddr_in *sourc /* modify */ LOGP(DMGCP, LOGL_NOTICE, "Modified endpoint on: 0x%x Server: %s:%u\n", ENDPOINT_NUMBER(endp), inet_ntoa(endp->remote), endp->net_rtp); + if (change_cb) + change_cb(ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX, endp->rtp_port, change_cb_data); return send_with_sdp(fd, endp, "MDCX", trans_id, source); error: @@ -814,6 +822,8 @@ static int handle_delete_con(int fd, struct msgb *msg, struct sockaddr_in *sourc } endp->net_rtp = endp->net_rtcp = endp->bts_rtp = endp->bts_rtcp = 0; + if (change_cb) + change_cb(ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX, endp->rtp_port, change_cb_data); return send_response(fd, 250, "DLCX", trans_id, source); @@ -1117,3 +1127,9 @@ int mgcp_parse_config(const char *config_file, struct gsm_network *dummy_network return !!forward_ip; } + +void mgcp_set_change_cb(mgcp_change cb, void *data) +{ + change_cb = cb; + change_cb_data = data; +} -- cgit v1.2.3