mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
client: add missing mandatory SDP fields
The mcgp message generator function mgcp_msg_gen() lacks support for the mandatory SDP fields (v)ersion, (o)rigin, (s)ession and (t)ime. - Automatically generate the missing fields when SDP is generated. Change-Id: I5fbc31a17e8ac10c7cc5dbc31357b61e8920aaa5 Related: OS#2837
This commit is contained in:
committed by
Harald Welte
parent
490cbaa89e
commit
9d25d7a2e6
@@ -740,6 +740,7 @@ struct msgb *mgcp_msg_gen(struct mgcp_client *mgcp, struct mgcp_msg *mgcp_msg)
|
|||||||
uint32_t mandatory_mask;
|
uint32_t mandatory_mask;
|
||||||
struct msgb *msg = msgb_alloc_headroom(4096, 128, "MGCP tx");
|
struct msgb *msg = msgb_alloc_headroom(4096, 128, "MGCP tx");
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
char local_ip[INET_ADDRSTRLEN];
|
||||||
|
|
||||||
msg->l2h = msg->data;
|
msg->l2h = msg->data;
|
||||||
msg->cb[MSGB_CB_MGCP_TRANS_ID] = trans_id;
|
msg->cb[MSGB_CB_MGCP_TRANS_ID] = trans_id;
|
||||||
@@ -820,9 +821,32 @@ struct msgb *mgcp_msg_gen(struct mgcp_client *mgcp, struct mgcp_msg *mgcp_msg)
|
|||||||
msgb_printf(msg, "M: %s\r\n",
|
msgb_printf(msg, "M: %s\r\n",
|
||||||
mgcp_client_cmode_name(mgcp_msg->conn_mode));
|
mgcp_client_cmode_name(mgcp_msg->conn_mode));
|
||||||
|
|
||||||
/* Add RTP address and port (SDP) */
|
/* Add SDP body */
|
||||||
if (mgcp_msg->presence & MGCP_MSG_PRESENCE_AUDIO_IP
|
if (mgcp_msg->presence & MGCP_MSG_PRESENCE_AUDIO_IP
|
||||||
&& mgcp_msg->presence & MGCP_MSG_PRESENCE_AUDIO_PORT) {
|
&& mgcp_msg->presence & MGCP_MSG_PRESENCE_AUDIO_PORT) {
|
||||||
|
|
||||||
|
/* Add separator to mark the beginning of the SDP block */
|
||||||
|
rc += msgb_printf(msg, "\r\n");
|
||||||
|
|
||||||
|
/* Add SDP protocol version */
|
||||||
|
rc += msgb_printf(msg, "v=0\r\n");
|
||||||
|
|
||||||
|
/* Add session name (none) */
|
||||||
|
rc += msgb_printf(msg, "s=-\r\n");
|
||||||
|
|
||||||
|
/* Determine local IP-Address */
|
||||||
|
if (osmo_sock_local_ip(local_ip, mgcp->actual.remote_addr) < 0) {
|
||||||
|
LOGP(DLMGCP, LOGL_ERROR,
|
||||||
|
"Could not determine local IP-Address!\n");
|
||||||
|
msgb_free(msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add owner/creator (SDP) */
|
||||||
|
rc += msgb_printf(msg, "o=- %x 23 IN IP4 %s\r\n",
|
||||||
|
mgcp_msg->call_id, local_ip);
|
||||||
|
|
||||||
|
/* Add RTP address and port */
|
||||||
if (mgcp_msg->audio_port == 0) {
|
if (mgcp_msg->audio_port == 0) {
|
||||||
LOGP(DLMGCP, LOGL_ERROR,
|
LOGP(DLMGCP, LOGL_ERROR,
|
||||||
"Invalid port number, can not generate MGCP message\n");
|
"Invalid port number, can not generate MGCP message\n");
|
||||||
@@ -835,11 +859,13 @@ struct msgb *mgcp_msg_gen(struct mgcp_client *mgcp, struct mgcp_msg *mgcp_msg)
|
|||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rc += msgb_printf(msg, "\r\n");
|
|
||||||
rc += msgb_printf(msg, "c=IN IP4 %s\r\n", mgcp_msg->audio_ip);
|
rc += msgb_printf(msg, "c=IN IP4 %s\r\n", mgcp_msg->audio_ip);
|
||||||
rc +=
|
rc +=
|
||||||
msgb_printf(msg, "m=audio %u RTP/AVP 255\r\n",
|
msgb_printf(msg, "m=audio %u RTP/AVP 255\r\n",
|
||||||
mgcp_msg->audio_port);
|
mgcp_msg->audio_port);
|
||||||
|
|
||||||
|
/* Add time description, active time (SDP) */
|
||||||
|
rc += msgb_printf(msg, "t=0 0\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
@@ -43,8 +43,12 @@ C: 2f
|
|||||||
I: 11
|
I: 11
|
||||||
M: sendrecv
|
M: sendrecv
|
||||||
|
|
||||||
|
v=0
|
||||||
|
s=-
|
||||||
|
o=- 2f 23 IN IP4 127.0.0.1
|
||||||
c=IN IP4 192.168.100.23
|
c=IN IP4 192.168.100.23
|
||||||
m=audio 1234 RTP/AVP 255
|
m=audio 1234 RTP/AVP 255
|
||||||
|
t=0 0
|
||||||
|
|
||||||
Generated DLCX message:
|
Generated DLCX message:
|
||||||
DLCX 3 23@mgw MGCP 1.0
|
DLCX 3 23@mgw MGCP 1.0
|
||||||
|
Reference in New Issue
Block a user