summaryrefslogtreecommitdiffstats
path: root/openbsc/include
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-10-14 17:56:17 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-16 15:32:33 +0100
commit7c8a62a9406ab33feecd890b044f001aee7fadd9 (patch)
treec48a4097dace537bf4809e0914cc316349b5faf6 /openbsc/include
parent978e72e500ac5544ee9fbddbac03125f60fceef8 (diff)
mgcp: handle responses from the MGCP GW
Diffstat (limited to 'openbsc/include')
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h2
-rw-r--r--openbsc/include/openbsc/mgcpgw_client.h59
2 files changed, 50 insertions, 11 deletions
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index 6997b02e5..b58eb9b58 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -332,3 +332,5 @@ static inline const char *mgcp_bts_src_addr(struct mgcp_endpoint *endp)
return endp->cfg->bts_ports.bind_addr;
return endp->cfg->source_addr;
}
+
+int mgcp_msg_terminate_nul(struct msgb *msg);
diff --git a/openbsc/include/openbsc/mgcpgw_client.h b/openbsc/include/openbsc/mgcpgw_client.h
index c21011898..60e648d9b 100644
--- a/openbsc/include/openbsc/mgcpgw_client.h
+++ b/openbsc/include/openbsc/mgcpgw_client.h
@@ -1,6 +1,9 @@
#pragma once
#include <stdint.h>
+
+#include <osmocom/core/linuxlist.h>
+
enum mgcp_connection_mode;
struct msgb;
@@ -11,8 +14,6 @@ struct mgcpgw_client;
#define MGCPGW_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1"
#define MGCPGW_CLIENT_REMOTE_PORT_DEFAULT 2427
-typedef void (* mgcp_rx_cb_t )(struct msgb *msg, void *priv);
-
struct mgcpgw_client_conf {
const char *local_addr;
int local_port;
@@ -20,11 +21,35 @@ struct mgcpgw_client_conf {
int remote_port;
};
+struct mgcp_response_head {
+ int response_code;
+ unsigned int trans_id;
+ const char *comment;
+};
+
+struct mgcp_response {
+ char *data;
+ struct mgcp_response_head head;
+ uint16_t audio_port;
+};
+
+/* Invoked when an MGCP response is received or sending failed. When the
+ * response is passed as NULL, this indicates failure during transmission. */
+typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void *priv);
+
+struct mgcp_response_pending {
+ struct llist_head entry;
+
+ unsigned int trans_id;
+ mgcp_response_cb_t response_cb;
+ void *priv;
+};
+
+
void mgcpgw_client_conf_init(struct mgcpgw_client_conf *conf);
struct mgcpgw_client *mgcpgw_client_init(void *ctx,
- struct mgcpgw_client_conf *conf,
- mgcp_rx_cb_t rx_cb, void *rx_cb_priv);
+ struct mgcpgw_client_conf *conf);
const char *mgcpgw_client_remote_addr_str(struct mgcpgw_client *mgcp);
uint16_t mgcpgw_client_remote_port(struct mgcpgw_client *mgcp);
@@ -32,16 +57,28 @@ uint32_t mgcpgw_client_remote_addr_n(struct mgcpgw_client *mgcp);
unsigned int mgcpgw_client_next_endpoint(struct mgcpgw_client *client);
-int mgcpgw_client_tx_crcx(struct mgcpgw_client *client,
+int mgcp_response_parse_params(struct mgcp_response *r);
+
+int mgcpgw_client_tx_crcx(struct mgcpgw_client *mgcp,
+ mgcp_response_cb_t response_cb, void *priv,
uint16_t rtp_endpoint, unsigned int call_id,
enum mgcp_connection_mode mode);
-int mgcpgw_client_tx_mdcx(struct mgcpgw_client *client, uint16_t rtp_endpoint,
- const char *rtp_conn_addr, uint16_t rtp_port,
- enum mgcp_connection_mode mode);
+int mgcpgw_client_tx_mdcx(struct mgcpgw_client *mgcp,
+ mgcp_response_cb_t response_cb, void *priv,
+ uint16_t rtp_endpoint, const char *rtp_conn_addr,
+ uint16_t rtp_port, enum mgcp_connection_mode mode);
-int mgcpgw_client_tx_str(struct mgcpgw_client *mgcp, const char *fmt, ...);
-int mgcpgw_client_tx_buf(struct mgcpgw_client *mgcp, const char *buf, int len);
-int mgcpgw_client_tx(struct mgcpgw_client *mgcp, struct msgb *msg);
+int mgcpgw_client_tx_str(struct mgcpgw_client *mgcp,
+ mgcp_response_cb_t response_cb, void *priv,
+ unsigned int trans_id,
+ const char *fmt, ...);
+int mgcpgw_client_tx_buf(struct mgcpgw_client *mgcp,
+ mgcp_response_cb_t response_cb, void *priv,
+ const char *buf, int len,
+ unsigned int trans_id);
+int mgcpgw_client_tx(struct mgcpgw_client *mgcp,
+ mgcp_response_cb_t response_cb, void *priv,
+ struct msgb *msg, unsigned int trans_id);
void mgcpgw_client_vty_init(int node, struct mgcpgw_client_conf *conf);
int mgcpgw_client_config_write(struct vty *vty, const char *indent);