From patchwork Fri Apr 29 10:39:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 616681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 3qx9FQ6F7Vz9s0M for ; Fri, 29 Apr 2016 20:40:10 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 6A2AF13FF9; Fri, 29 Apr 2016 10:40:09 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 582BC13FE7 for ; Fri, 29 Apr 2016 10:40:08 +0000 (UTC) Received: from mail.sysmocom.de (mail.sysmocom.de [144.76.43.93]) by mail.sysmocom.de (Postfix) with ESMTP id 1C48B1B9E15; Fri, 29 Apr 2016 10:39:38 +0000 (UTC) Received: from pbell.local (ip5b418565.dynamic.kabel-deutschland.de [91.65.133.101]) by mail.sysmocom.de (Postfix) with ESMTPSA id CE62D1B9E14; Fri, 29 Apr 2016 10:39:36 +0000 (UTC) From: msuraev@sysmocom.de To: openbsc@lists.osmocom.org Subject: [PATCH 1/3] Do not send RTP to port 0 Date: Fri, 29 Apr 2016 12:39:33 +0200 Message-Id: <1461926375-18893-1-git-send-email-msuraev@sysmocom.de> X-Mailer: git-send-email 2.8.1 X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Max Previously it was possible to send RTP data to port 0. This produce multiple errors during the beginning of RTP transmission. To address this OSMO_RTP_F_DISABLED flag was introduced. It's set by default for all new RTP sessions. It can be manually unset after the call to osmo_rtp_socket_create(). When the flag is set it prevents transmission and reception of RTP frames for the session. The flag is unset automatically in osmo_rtp_socket_connect() when session is bound to non-zero remote port. Fixes: OS#1662 --- include/osmocom/trau/osmo_ortp.h | 1 + src/trau/osmo_ortp.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/osmocom/trau/osmo_ortp.h b/include/osmocom/trau/osmo_ortp.h index c02cca8..2ca9cfc 100644 --- a/include/osmocom/trau/osmo_ortp.h +++ b/include/osmocom/trau/osmo_ortp.h @@ -29,6 +29,7 @@ enum osmo_rtp_param { /*! \brief Flag to indicate the socket is in polling-only mode */ #define OSMO_RTP_F_POLL 0x0001 +#define OSMO_RTP_F_DISABLED 2 /*! \brief A structure representing one RTP socket */ struct osmo_rtp_socket { diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c index 65ec269..22c5856 100644 --- a/src/trau/osmo_ortp.c +++ b/src/trau/osmo_ortp.c @@ -149,6 +149,8 @@ static void ortp_sig_cb_ts(RtpSession *rs, void *data) int osmo_rtp_socket_poll(struct osmo_rtp_socket *rs) { mblk_t *mblk; + if (rs->flags & OSMO_RTP_F_DISABLED) + return 0; mblk = rtp_session_recvm_with_ts(rs->sess, rs->rx_user_ts); if (mblk) { @@ -313,7 +315,7 @@ struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx, unsigned int fl if (!rs) return NULL; - rs->flags = flags; + rs->flags = OSMO_RTP_F_DISABLED | flags; rs->sess = rtp_session_new(RTP_SESSION_SENDRECV); if (!rs->sess) { talloc_free(rs); @@ -382,11 +384,16 @@ int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port) int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t port) { int rc; - + if (!port) { + LOGP(DLMIB, LOGL_INFO, "osmo_rtp_socket_connect() refused to " + "set remote %s:%u\n", ip, port); + return 0; + } /* enable the use of connect() so later getsockname() will * actually return the IP address that was chosen for the local * sid of the connection */ rtp_session_set_connected_mode(rs->sess, 1); + rs->flags &= ~OSMO_RTP_F_DISABLED; rc = rtp_session_set_remote_addr(rs->sess, ip, port); if (rc < 0) @@ -411,6 +418,9 @@ int osmo_rtp_send_frame(struct osmo_rtp_socket *rs, const uint8_t *payload, mblk_t *mblk; int rc; + if (rs->flags & OSMO_RTP_F_DISABLED) + return 0; + mblk = rtp_session_create_packet(rs->sess, RTP_FIXED_HEADER_SIZE, payload, payload_len); if (!mblk)