MGCP: Connection Identifiers are hex strings
The MGCP spec in RFC3435 is quite clear: Connection Identifiers are
hexadecimal strings of up to 32 characters. We should not print and
parse them as integers on either client or server.
Change the internal uint32_t representation of connection identifiers
to a string representation in the client and also in the server.
Closes: OS#2649
Change-Id: I0531a1b670d00cec50078423a2868207135b2436
diff --git a/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h
index 0eb1388..29dc458 100644
--- a/include/osmocom/mgcp/mgcp_common.h
+++ b/include/osmocom/mgcp/mgcp_common.h
@@ -68,4 +68,8 @@
return 0;
}
+/* String length of Connection Identifiers
+ * (see also RFC3435 2.1.3.2 Names of Connections) */
+#define MGCP_CONN_ID_LENGTH 32+1
+
#endif
diff --git a/include/osmocom/mgcp/mgcp_conn.h b/include/osmocom/mgcp/mgcp_conn.h
index e0ae021..982a311 100644
--- a/include/osmocom/mgcp/mgcp_conn.h
+++ b/include/osmocom/mgcp/mgcp_conn.h
@@ -28,12 +28,12 @@
#include <inttypes.h>
struct mgcp_conn *mgcp_conn_alloc(void *ctx, struct mgcp_endpoint *endp,
- uint32_t id, enum mgcp_conn_type type,
+ const char *id, enum mgcp_conn_type type,
char *name);
-struct mgcp_conn *mgcp_conn_get(struct mgcp_endpoint *endp, uint32_t id);
+struct mgcp_conn *mgcp_conn_get(struct mgcp_endpoint *endp, const char *id);
struct mgcp_conn_rtp *mgcp_conn_get_rtp(struct mgcp_endpoint *endp,
- uint32_t id);
-void mgcp_conn_free(struct mgcp_endpoint *endp, uint32_t id);
+ const char *id);
+void mgcp_conn_free(struct mgcp_endpoint *endp, const char *id);
void mgcp_conn_free_oldest(struct mgcp_endpoint *endp);
void mgcp_conn_free_all(struct mgcp_endpoint *endp);
char *mgcp_conn_dump(struct mgcp_conn *conn);
diff --git a/include/osmocom/mgcp/mgcp_internal.h b/include/osmocom/mgcp/mgcp_internal.h
index b9c1731..c3f9ba1 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -30,8 +30,10 @@
#define CI_UNUSED 0
-#define CONN_ID_BTS 0
-#define CONN_ID_NET 1
+/* FIXME: This this is only needed to compile the currently
+ * broken OSMUX support. Remove when fixed */
+#define CONN_ID_BTS "0"
+#define CONN_ID_NET "1"
enum mgcp_trunk_type {
MGCP_TRUNK_VIRTUAL,
@@ -203,7 +205,7 @@
enum mgcp_connection_mode mode_orig;
/*!< connection id to identify the conntion */
- uint32_t id;
+ char id[MGCP_CONN_ID_LENGTH];
/*!< human readable name (vty, logging) */
char name[256];
diff --git a/include/osmocom/mgcp/mgcp_msg.h b/include/osmocom/mgcp/mgcp_msg.h
index b7d52bb..7732865 100644
--- a/include/osmocom/mgcp/mgcp_msg.h
+++ b/include/osmocom/mgcp/mgcp_msg.h
@@ -43,7 +43,7 @@
int mgcp_verify_call_id(struct mgcp_endpoint *endp, const char *callid);
-int mgcp_verify_ci(struct mgcp_endpoint *endp, const char *ci);
+int mgcp_verify_ci(struct mgcp_endpoint *endp, const char *conn_id);
char *mgcp_strline(char *str, char **saveptr);
@@ -54,5 +54,3 @@
#define for_each_non_empty_line(line, save)\
for (line = strtok_r(NULL, "\r\n", &save); line;\
line = strtok_r(NULL, "\r\n", &save))
-
-int mgcp_parse_ci(uint32_t *conn_id, const char *ci);