aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-21 21:25:13 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-21 21:25:13 +0800
commitc71013091aa7995986438bcf06703e6df9e7f3eb (patch)
tree1d56094e9a04bbe3ce824412914a5956e60ab43b
parent4b1cde10fe52312fafd9a61796aef075593b94bb (diff)
[mgcp] Add a dummy send method...
This can be used by higher level code to send one dummy message from the audio port to the network. This can be used to make the remote discover the nated port of this endpoint.
-rw-r--r--openbsc/include/openbsc/mgcp_internal.h1
-rw-r--r--openbsc/src/mgcp/mgcp_network.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index 3a2832436..d5aec3080 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -73,5 +73,6 @@ struct mgcp_msg_ptr {
int mgcp_analyze_header(struct mgcp_config *cfg, struct msgb *msg,
struct mgcp_msg_ptr *ptr, int size,
const char **transaction_id, struct mgcp_endpoint **endp);
+int mgcp_send_dummy(struct mgcp_endpoint *endp);
#endif
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index a4ab70c97..e9c86fb66 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -73,6 +73,8 @@ enum {
PROTO_RTCP,
};
+#define DUMMY_LOAD 0x23
+
static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
{
@@ -84,6 +86,14 @@ static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len)
return sendto(fd, buf, len, 0, (struct sockaddr *)&out, sizeof(out));
}
+int mgcp_send_dummy(struct mgcp_endpoint *endp)
+{
+ static char buf[] = { DUMMY_LOAD };
+
+ return udp_send(endp->local_rtp.fd, &endp->remote,
+ endp->net_rtp, buf, 1);
+}
+
static void patch_payload(int payload, char *data, int len)
{
struct rtp_hdr *rtp_hdr;
@@ -163,6 +173,14 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
LOGP(DMGCP, LOGL_NOTICE, "Found BTS for endpoint: 0x%x on port: %d/%d of %s\n",
ENDPOINT_NUMBER(endp), ntohs(endp->bts_rtp), ntohs(endp->bts_rtcp),
inet_ntoa(addr.sin_addr));
+
+ /* throw away dummy message */
+ if (rc == 1 && buf[0] == DUMMY_LOAD) {
+ LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy on 0x%x\n",
+ ENDPOINT_NUMBER(endp));
+ return 0;
+ }
+
}
}