client: add an optional FSM interface
the client API is not very intuitive and requires a lot of extra
care when it is used from an osmo-fsm.
- Add an FSM that permits comfortable handling of an MGCP
connection.
Change-Id: I887ce0c15a831dffeb6251a975337b83942af566
diff --git a/include/Makefile.am b/include/Makefile.am
index b52e5ea..e8fc211 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -7,6 +7,7 @@
osmocom/legacy_mgcp/mgcp_internal.h \
osmocom/legacy_mgcp/osmux.h \
osmocom/mgcp_client/mgcp_client.h \
+ osmocom/mgcp_client/mgcp_client_fsm.h \
osmocom/mgcp_client/mgcp_common.h \
osmocom/mgcp/mgcp.h \
osmocom/mgcp/mgcp_common.h \
diff --git a/include/osmocom/mgcp_client/mgcp_client_fsm.h b/include/osmocom/mgcp_client/mgcp_client_fsm.h
new file mode 100644
index 0000000..7d06178
--- /dev/null
+++ b/include/osmocom/mgcp_client/mgcp_client_fsm.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <osmocom/mgcp_client/mgcp_common.h>
+#include <osmocom/mgcp_client/mgcp_client.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+
+/*! This struct organizes the connection infromation one connection side
+ * (either remote or local). It is used to pass parameters (local) to the FSM
+ * and get responses (remote) from the FSM as pointer attached to the FSM
+ * event.
+ *
+ * When modifiying a connection, the endpoint and call_id members may be left
+ * unpopulated. The call_id field is ignored in this case. If an endpoint
+ * identifier is supplied it is checked against the internal state to make
+ * sure it is correct. */
+struct mgcp_conn_peer {
+ /*!< RTP connection IP-Address (optional, string e.g. "127.0.0.1") */
+ char addr[INET_ADDRSTRLEN];
+
+ /*!< RTP connection IP-Port (optional) */
+ uint16_t port;
+
+ /*!< RTP endpoint */
+ char endpoint[MGCP_ENDPOINT_MAXLEN];
+
+ /*!< CALL ID (unique per connection) */
+ unsigned int call_id;
+};
+
+struct osmo_fsm_inst *mgcp_conn_create(struct mgcp_client *mgcp, struct osmo_fsm_inst *parent_fi, uint32_t parent_term_evt,
+ uint32_t parent_evt, struct mgcp_conn_peer *conn_peer);
+int mgcp_conn_modify(struct osmo_fsm_inst *fi, uint32_t parent_evt, struct mgcp_conn_peer *conn_peer);
+void mgcp_conn_delete(struct osmo_fsm_inst *fi);