Change in mncc-python[master]: rtpsource: Make local RTP bind IP configurble via "-r" cmdline opt

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Mar 11 15:12:26 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/mncc-python/+/17431 )

Change subject: rtpsource: Make local RTP bind IP configurble via "-r" cmdline opt
......................................................................

rtpsource: Make local RTP bind IP configurble via "-r" cmdline opt

Change-Id: Ia742180326f3d945eb7933cebbef3fd17d127d51
---
M rtpsource/internal.h
M rtpsource/rtpsource.c
2 files changed, 28 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved; Verified



diff --git a/rtpsource/internal.h b/rtpsource/internal.h
index 788b695..13d07aa 100644
--- a/rtpsource/internal.h
+++ b/rtpsource/internal.h
@@ -27,6 +27,7 @@
 	struct llist_head connections;
 	struct osmo_fd timer_ofd;
 	struct ctrl_handle *ctrl;
+	char *rtp_bind_ip;
 };
 extern struct rtpsource_state *g_rss;
 
diff --git a/rtpsource/rtpsource.c b/rtpsource/rtpsource.c
index 58e6bf0..569d962 100644
--- a/rtpsource/rtpsource.c
+++ b/rtpsource/rtpsource.c
@@ -34,6 +34,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
+#include <getopt.h>
 #include <sys/signal.h>
 
 #include <osmocom/core/linuxlist.h>
@@ -77,7 +78,7 @@
 	conn->rtp_sock = osmo_rtp_socket_create(conn, OSMO_RTP_F_POLL);
 	OSMO_ASSERT(conn->rtp_sock);
 
-	rc = osmo_rtp_socket_bind(conn->rtp_sock, "127.23.23.23", -1);
+	rc = osmo_rtp_socket_bind(conn->rtp_sock, rss->rtp_bind_ip, -1);
 	OSMO_ASSERT(rc == 0);
 
 	rc = osmo_rtp_get_bound_addr(conn->rtp_sock, &host, &port);
@@ -200,6 +201,28 @@
 	}
 }
 
+static void handle_options(int argc, char **argv)
+{
+	while (1) {
+		int option_index = 0, c;
+		const struct option long_options[] = {
+			{"rtp-bind-ip", 1, 0, 'r' },
+			{ 0, 0, 0, 0}
+		};
+		c = getopt_long(argc, argv, "r:", long_options, &option_index);
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 'r':
+			g_rss->rtp_bind_ip = optarg;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
 int main(int argc, char **argv)
 {
 	struct timespec interval = {
@@ -226,6 +249,9 @@
 	g_rss = talloc_zero(g_tall_ctx, struct rtpsource_state);
 	OSMO_ASSERT(g_rss);
 	INIT_LLIST_HEAD(&g_rss->connections);
+	g_rss->rtp_bind_ip = "127.23.23.23";
+
+	handle_options(argc, argv);
 
 	/* Create CTRL interface */
 	//g_rss->ctrl = ctrl_interface_setup_dynip(g_rss, ctrl_vty_get_bind_addr(), 11111, NULL);

-- 
To view, visit https://gerrit.osmocom.org/c/mncc-python/+/17431
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: mncc-python
Gerrit-Branch: master
Gerrit-Change-Id: Ia742180326f3d945eb7933cebbef3fd17d127d51
Gerrit-Change-Number: 17431
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200311/36426a32/attachment.htm>


More information about the gerrit-log mailing list