[MERGED] osmo-bsc[master]: abisip-find: add --interval option

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jan 8 12:56:12 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: abisip-find: add --interval option
......................................................................


abisip-find: add --interval option

Change-Id: I9540054bdda185b2585209289cee565f61f33dcf
---
M src/ipaccess/abisip-find.c
1 file changed, 17 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/ipaccess/abisip-find.c b/src/ipaccess/abisip-find.c
index 4e1d192..0f398b4 100644
--- a/src/ipaccess/abisip-find.c
+++ b/src/ipaccess/abisip-find.c
@@ -39,10 +39,12 @@
 
 static struct {
 	const char *ifname;
+	int send_interval;
 	bool list_view;
 	time_t list_view_timeout;
 } cmdline_opts = {
 	.ifname = NULL,
+	.send_interval = 5,
 	.list_view = false,
 	.list_view_timeout = 10,
 };
@@ -53,6 +55,7 @@
 	printf("Usage: abisip-find [-l] [<interface-name>]\n");
 	printf("  <interface-name>  Specify the outgoing network interface,\n"
 	       "                    e.g. 'eth0'\n");
+	printf("  -i --interval <s> Send broadcast frames every <s> seconds.\n");
 	printf("  -l --list-view    Instead of printing received responses,\n"
 	       "                    output a sorted list of currently present\n"
 	       "                    base stations and change events.\n");
@@ -67,12 +70,13 @@
 		int option_index = 0, c;
 		static struct option long_options[] = {
 			{"help", 0, 0, 'h'},
+			{"send-interval", 1, 0, 'i'},
 			{"list-view", 0, 0, 'l'},
 			{"timeout", 1, 0, 't'},
 			{0, 0, 0, 0}
 		};
 
-		c = getopt_long(argc, argv, "hlt:",
+		c = getopt_long(argc, argv, "hi:lt:",
 				long_options, &option_index);
 		if (c == -1)
 			break;
@@ -81,6 +85,14 @@
 		case 'h':
 			print_help();
 			exit(EXIT_SUCCESS);
+		case 'i':
+			errno = 0;
+			cmdline_opts.send_interval = strtoul(optarg, NULL, 10);
+			if (errno || cmdline_opts.send_interval < 1) {
+				fprintf(stderr, "Invalid interval value: %s\n", optarg);
+				exit(EXIT_FAILURE);
+			}
+			break;
 		case 't':
 			errno = 0;
 			cmdline_opts.list_view_timeout = strtoul(optarg, NULL, 10);
@@ -359,7 +371,7 @@
 
 	base_stations_bump(false);
 
-	osmo_timer_schedule(&timer, 5, 0);
+	osmo_timer_schedule(&timer, cmdline_opts.send_interval, 0);
 }
 
 int main(int argc, char **argv)
@@ -378,6 +390,8 @@
 			"  network interface, e.g. ``%s eth0''\n", argv[0]);
 	if (!cmdline_opts.list_view)
 		fprintf(stdout, "- You may find the --list-view option convenient.\n");
+	else if (cmdline_opts.send_interval >= cmdline_opts.list_view_timeout)
+		fprintf(stdout, "\nWARNING: the --timeout should be larger than --interval.\n\n");
 
 	bfd.cb = bfd_cb;
 	bfd.when = BSC_FD_READ | BSC_FD_WRITE;
@@ -394,7 +408,7 @@
 	}
 
 	osmo_timer_setup(&timer, timer_cb, &bfd);
-	osmo_timer_schedule(&timer, 5, 0);
+	osmo_timer_schedule(&timer, cmdline_opts.send_interval, 0);
 
 	printf("Trying to find ip.access BTS by broadcast UDP...\n");
 

-- 
To view, visit https://gerrit.osmocom.org/5590
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9540054bdda185b2585209289cee565f61f33dcf
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list