Change in libosmo-abis[master]: e1_input: Allow to change the pcap fd and/or unset it

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

tnt gerrit-no-reply at lists.osmocom.org
Sat May 9 15:31:28 UTC 2020


tnt has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/18113 )

Change subject: e1_input: Allow to change the pcap fd and/or unset it
......................................................................

e1_input: Allow to change the pcap fd and/or unset it

This will update the pcap fd in all open lines and close
the previous one (if applicable).

Signed-off-by: Sylvain Munaut <tnt at 246tNt.com>
Change-Id: I5c7dd740ba0a90b40c69a53b3dcc9d6d6a98f660
---
M src/e1_input.c
1 file changed, 27 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/e1_input.c b/src/e1_input.c
index ad4e25c..379cc53 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -142,7 +142,7 @@
 
 int e1_set_pcap_fd(int fd)
 {
-	struct pcap_hdr header = {
+	const struct pcap_hdr header = {
 		.magic_number	= 0xa1b2c3d4,
 		.version_major	= 2,
 		.version_minor	= 4,
@@ -151,9 +151,34 @@
 		.snaplen	= 65535,
 		.network	= DLT_LINUX_LAPD,
 	};
+	struct e1inp_line *line;
+	int i;
 
+	/* write header */
+	if (fd >= 0) {
+		int rc = write(fd, &header, sizeof(header));
+		if (rc < 0)
+			return rc;
+	}
+
+	/* update fd in all lines in our global list of e1 lines */
+	llist_for_each_entry(line, &e1inp_line_list, list) {
+		/* Set the PCAP file descriptor for all timeslots that have
+		 * software LAPD instances, to ensure the osmo_lapd_pcap code is
+		 * used to write PCAP files (if requested) */
+		for (i = 0; i < ARRAY_SIZE(line->ts); i++) {
+			struct e1inp_ts *e1i_ts = &line->ts[i];
+			if (e1i_ts->lapd)
+				e1i_ts->lapd->pcap_fd = fd;
+		}
+	}
+
+	/* close previous and update global */
+	if (pcap_fd >= 0)
+		close(pcap_fd);
 	pcap_fd = fd;
-	return write(pcap_fd, &header, sizeof(header));
+
+	return 0;
 }
 
 /* This currently only works for the D-Channel */

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/18113
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I5c7dd740ba0a90b40c69a53b3dcc9d6d6a98f660
Gerrit-Change-Number: 18113
Gerrit-PatchSet: 3
Gerrit-Owner: tnt <tnt at 246tNt.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200509/31c16875/attachment.htm>


More information about the gerrit-log mailing list