lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

January 2025

  • 1 participants
  • 1491 discussions
[XS] Change in osmo-pcap[master]: cosmetic: osmo_tls: Fix indentation whitespace
by pespin 13 Jan '25

13 Jan '25
Attention is currently required from: pespin. Hello Jenkins Builder, laforge, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-pcap/+/39304?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder The change is no longer submittable: Verified is unsatisfied now. Change subject: cosmetic: osmo_tls: Fix indentation whitespace ...................................................................... cosmetic: osmo_tls: Fix indentation whitespace Change-Id: I27e6d6ce64178384acbd0b8ee88d6f7ef6b2a61b --- M src/osmo_tls.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/04/39304/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39304?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I27e6d6ce64178384acbd0b8ee88d6f7ef6b2a61b Gerrit-Change-Number: 39304 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-pcap[master]: server: Support storing of pcapng format
by pespin 13 Jan '25

13 Jan '25
Attention is currently required from: daniel, laforge, osmith. Hello Jenkins Builder, daniel, laforge, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-pcap/+/39287?usp=email to look at the new patch set (#6). The following approvals got outdated and were removed: Code-Review+1 by laforge, Code-Review+1 by osmith, Verified+1 by Jenkins Builder Change subject: server: Support storing of pcapng format ...................................................................... server: Support storing of pcapng format Improve existing logic doing validation on payload data and generalize the file_hdr field to account for the possibily of receiving recordings in pcapng format. This requires, during LINK_HDR when file header is received, discerning whether the recording is being done in pcap vs pcapng, (and in pcapng figuring out the endianness of the file) and then applying validation based on that knowledge. With that knowledge, osmo-pcap-server can now store the pcap(ng) file using the proper suffix for the file. Related: SYS#5822 Change-Id: I275d28ab418a1514fa9c5c7c20f3d831cc6af8bb --- M include/osmo-pcap/osmo_pcap_file.h M include/osmo-pcap/osmo_pcap_server.h M src/Makefile.am M src/osmo_pcap_file.c M src/osmo_server_network.c M tests/rotate_localtime/Makefile.am 6 files changed, 333 insertions(+), 46 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/87/39287/6 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39287?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I275d28ab418a1514fa9c5c7c20f3d831cc6af8bb Gerrit-Change-Number: 39287 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-pcap[master]: server: Support storing of pcapng format
by pespin 13 Jan '25

13 Jan '25
Attention is currently required from: daniel, laforge. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39287?usp=email ) Change subject: server: Support storing of pcapng format ...................................................................... Patch Set 5: (2 comments) Commit Message: https://gerrit.osmocom.org/c/osmo-pcap/+/39287/comment/86103f8d_78958f5a?us… : PS5, Line 13: This requires, during LINK_HDR when file header is received, discering > I meant discerning, will fix […] Done File src/osmo_server_network.c: https://gerrit.osmocom.org/c/osmo-pcap/+/39287/comment/86d88434_434a2ee5?us… : PS5, Line 352: BLOCK_TYPE_SHB > This is wrong, I'll fix, thanks. Done -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39287?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I275d28ab418a1514fa9c5c7c20f3d831cc6af8bb Gerrit-Change-Number: 39287 Gerrit-PatchSet: 5 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Comment-Date: Mon, 13 Jan 2025 19:25:22 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-pcap[master]: client: Introduce osmo_pcap_file to prepare support for pcapng
by pespin 13 Jan '25

13 Jan '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39288?usp=email ) Change subject: client: Introduce osmo_pcap_file to prepare support for pcapng ...................................................................... client: Introduce osmo_pcap_file to prepare support for pcapng This patch is a preparation patch refactoring code to make it easier to add pcapng format in follow-up patch. Different types of encodings are grouped in helper functions. Change-Id: Ifd389a2a32897e101c62fd280ddca984d485d373 --- M include/osmo-pcap/Makefile.am M include/osmo-pcap/osmo_pcap_client.h A include/osmo-pcap/osmo_pcap_file.h M src/Makefile.am M src/osmo_client_core.c M src/osmo_client_network.c A src/osmo_pcap_file.c 7 files changed, 240 insertions(+), 78 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve diff --git a/include/osmo-pcap/Makefile.am b/include/osmo-pcap/Makefile.am index e377b6a..58c8a59 100644 --- a/include/osmo-pcap/Makefile.am +++ b/include/osmo-pcap/Makefile.am @@ -1,6 +1,7 @@ noinst_HEADERS = \ common.h \ osmo_pcap_client.h \ + osmo_pcap_file.h \ osmo_pcap_server.h \ osmo_tls.h \ wireformat.h \ diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h index 442244e..470edb6 100644 --- a/include/osmo-pcap/osmo_pcap_client.h +++ b/include/osmo-pcap/osmo_pcap_client.h @@ -139,7 +139,9 @@ struct osmo_pcap_client_conn *osmo_client_conn_alloc(struct osmo_pcap_client *client, const char *name); void osmo_client_conn_free(struct osmo_pcap_client_conn *conn); void osmo_client_conn_send_data(struct osmo_pcap_client_conn *conn, - struct pcap_pkthdr *hdr, const uint8_t *data); + const struct osmo_pcap_handle *ph, + const struct pcap_pkthdr *pkthdr, + const uint8_t *data); void osmo_client_conn_send_link(struct osmo_pcap_client_conn *conn); void osmo_client_conn_connect(struct osmo_pcap_client_conn *conn); void osmo_client_conn_disconnect(struct osmo_pcap_client_conn *conn); diff --git a/include/osmo-pcap/osmo_pcap_file.h b/include/osmo-pcap/osmo_pcap_file.h new file mode 100644 index 0000000..50a7706 --- /dev/null +++ b/include/osmo-pcap/osmo_pcap_file.h @@ -0,0 +1,37 @@ +/* + * Procedures to operate on pcap/pcapng file format + * + * (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <unistd.h> +#include <stdint.h> + +/*********************************************************** +* Libpcap File Format (.pcap) +* https://wiki.wireshark.org/Development/LibpcapFileFormat +***********************************************************/ + +#define OSMO_PCAP_FILE_MAGIC 0xa1b2c3d4 + +int osmo_pcap_file_msgb_append_global_header(struct msgb *msg, uint32_t snaplen, uint32_t linktype); + +unsigned int osmo_pcap_file_record_size(const struct pcap_pkthdr *in_hdr); +int osmo_pcap_file_msgb_append_record(struct msgb *msg, const struct pcap_pkthdr *in_hdr, const uint8_t *data); diff --git a/src/Makefile.am b/src/Makefile.am index 00c9ce9..bb70d21 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,6 +20,7 @@ osmo_client_network.c \ osmo_client_stats.c \ osmo_client_vty.c \ + osmo_pcap_file.c \ osmo_tls.c \ $(NULL) diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index a2ab894..538b68a 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -172,7 +172,7 @@ return 0; llist_for_each_entry(conn, &client->conns, entry) - osmo_client_conn_send_data(conn, &hdr, data); + osmo_client_conn_send_data(conn, ph, &hdr, data); return 0; } diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c index 70fe740..e14f4ca 100644 --- a/src/osmo_client_network.c +++ b/src/osmo_client_network.c @@ -1,6 +1,7 @@ /* * osmo-pcap-client code * + * (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> * (C) 2011-2016 by Holger Hans Peter Freyther <holger(a)moiji-mobile.com> * (C) 2011 by On-Waves * All Rights Reserved @@ -23,7 +24,9 @@ #include <osmo-pcap/osmo_pcap_client.h> #include <osmo-pcap/common.h> #include <osmo-pcap/wireformat.h> +#include <osmo-pcap/osmo_pcap_file.h> +#include <osmocom/core/utils.h> #include <osmocom/core/msgb.h> #include <osmocom/core/rate_ctr.h> #include <osmocom/core/select.h> @@ -160,112 +163,152 @@ } } -void osmo_client_conn_send_data(struct osmo_pcap_client_conn *conn, - struct pcap_pkthdr *in_hdr, const uint8_t *data) +static struct msgb *osmo_client_conn_prepare_msg_data_pcap(struct osmo_pcap_client_conn *conn, + const struct osmo_pcap_handle *ph, + const struct pcap_pkthdr *pkthdr, + const uint8_t *data) { struct osmo_pcap_data *om_hdr; - struct osmo_pcap_pkthdr *hdr; struct msgb *msg; - int offset, ip_len; - struct osmo_pcap_handle *ph; + unsigned int record_size = osmo_pcap_file_record_size(pkthdr); - if (in_hdr->len > in_hdr->caplen) { - LOGCONN(conn, LOGL_ERROR, "Recording truncated packet, len %zu > snaplen %zu\n", - (size_t) in_hdr->len, (size_t) in_hdr->caplen); - rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_2BIG); - } - - msg = msgb_alloc(in_hdr->caplen + sizeof(*om_hdr) + sizeof(*hdr), "data-data"); + msg = msgb_alloc(sizeof(*om_hdr) + record_size, "pcap-data"); if (!msg) { LOGCONN(conn, LOGL_ERROR, "Failed to allocate\n"); rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_NOMEM); - return; + return NULL; + } + + om_hdr = (struct osmo_pcap_data *) msgb_put(msg, sizeof(*om_hdr)); + om_hdr->type = PKT_LINK_DATA; + om_hdr->len = htons(record_size); + osmo_pcap_file_msgb_append_record(msg, pkthdr, data); + + return msg; +} + +static struct msgb *osmo_client_conn_prepare_msg_ipip(struct osmo_pcap_client_conn *conn, + const struct osmo_pcap_handle *ph, + const struct pcap_pkthdr *pkthdr, + const uint8_t *data) +{ + struct msgb *msg; + int offset, ip_len; + + offset = get_iphdr_offset(pcap_datalink(ph->handle)); + if (offset < 0) + return NULL; + + ip_len = pkthdr->caplen - offset; + if (ip_len < 0) + return NULL; + + + msg = msgb_alloc(ip_len, "ipip_msg"); + if (!msg) { + LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate data.\n"); + rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_NOMEM); + return NULL; + } + msg->l2h = msgb_put(msg, ip_len); + memcpy(msg->l2h, data+offset, ip_len); + return msg; +} + +void osmo_client_conn_send_data(struct osmo_pcap_client_conn *conn, + const struct osmo_pcap_handle *ph, + const struct pcap_pkthdr *pkthdr, + const uint8_t *data) +{ + struct osmo_pcap_client *client = conn->client; + struct msgb *msg; + + if (pkthdr->len > pkthdr->caplen) { + LOGCONN(conn, LOGL_ERROR, "Recording truncated packet, len %zu > snaplen %zu\n", + (size_t) pkthdr->len, (size_t) pkthdr->caplen); + rate_ctr_inc2(client->ctrg, CLIENT_CTR_2BIG); } switch (conn->protocol) { case PROTOCOL_OSMOPCAP: - om_hdr = (struct osmo_pcap_data *) msgb_put(msg, sizeof(*om_hdr)); - om_hdr->type = PKT_LINK_DATA; - - msg->l2h = msgb_put(msg, sizeof(*hdr)); - hdr = (struct osmo_pcap_pkthdr *) msg->l2h; - hdr->ts_sec = in_hdr->ts.tv_sec; - hdr->ts_usec = in_hdr->ts.tv_usec; - hdr->caplen = in_hdr->caplen; - hdr->len = in_hdr->len; - - msg->l3h = msgb_put(msg, in_hdr->caplen); - memcpy(msg->l3h, data, in_hdr->caplen); - - om_hdr->len = htons(msgb_l2len(msg)); - rate_ctr_add2(conn->client->ctrg, CLIENT_CTR_BYTES, hdr->caplen); - rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_PKTS); + msg = osmo_client_conn_prepare_msg_data_pcap(conn, ph, pkthdr, data); break; case PROTOCOL_IPIP: - /* TODO: support capturing from multiple interfaces here: */ - ph = llist_first_entry_or_null(&conn->client->handles, struct osmo_pcap_handle, entry); - if (!ph) { - msgb_free(msg); - return; - } - offset = get_iphdr_offset(pcap_datalink(ph->handle)); - if (offset < 0) { - msgb_free(msg); - return; - } - ip_len = in_hdr->caplen - offset; - if (ip_len < 0) { - msgb_free(msg); - return; - } - msg->l2h = msgb_put(msg, ip_len); - memcpy(msg->l2h, data+offset, ip_len); + msg = osmo_client_conn_prepare_msg_ipip(conn, ph, pkthdr, data); break; default: OSMO_ASSERT(0); } + if (!msg) + return; + + rate_ctr_add2(conn->client->ctrg, CLIENT_CTR_BYTES, pkthdr->caplen); + rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_PKTS); + write_data(conn, msg); } +static struct msgb *osmo_client_conn_prepare_msg_link_pcap(struct osmo_pcap_client_conn *conn) +{ + struct osmo_pcap_client *client = conn->client; + struct osmo_pcap_data *om_hdr; + struct msgb *msg; + struct osmo_pcap_handle *ph; + int rc; + int linktype; + + ph = llist_first_entry_or_null(&client->handles, struct osmo_pcap_handle, entry); + if (!ph || !ph->handle) { + LOGCONN(conn, LOGL_ERROR, "No pcap_handle not sending link info\n"); + return NULL; + } + linktype = pcap_datalink(ph->handle); + + /* Make sure others have same linktype, .pcap doesn't support different + * linktypes since traffic from all ifaces goes mixed together. */ + llist_for_each_entry(ph, &client->handles, entry) { + if (linktype != pcap_datalink(ph->handle)) { + LOGCONN(conn, LOGL_ERROR, + "File format 'pcap' doesn't support recording from multiple ifaces " + "with different link types!\n"); + return NULL; + } + } + + msg = msgb_alloc(sizeof(*om_hdr) + sizeof(struct pcap_file_header), "link-data"); + if (!msg) { + LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate data.\n"); + return NULL; + } + + + om_hdr = (struct osmo_pcap_data *)msgb_put(msg, sizeof(*om_hdr)); + om_hdr->type = PKT_LINK_HDR; + + rc = osmo_pcap_file_msgb_append_global_header(msg, client->snaplen, linktype); + if (rc < 0) { + LOGP(DCLIENT, LOGL_ERROR, "Failed to create pcap file global header.\n"); + msgb_free(msg); + return NULL; + } + + /* Update payload length: */ + om_hdr->len = htons(rc); + return msg; +} + void osmo_client_conn_send_link(struct osmo_pcap_client_conn *conn) { - struct osmo_pcap_handle *ph; - struct pcap_file_header *hdr; - struct osmo_pcap_data *om_hdr; struct msgb *msg; /* IPIP encapsulation has no linktype header */ if (conn->protocol == PROTOCOL_IPIP) return; - /* TODO: support capturing from multiple interfaces here: */ - ph = llist_first_entry_or_null(&conn->client->handles, struct osmo_pcap_handle, entry); - if (!ph || !ph->handle) { - LOGCONN(conn, LOGL_ERROR, "No pcap_handle not sending link info\n"); + msg = osmo_client_conn_prepare_msg_link_pcap(conn); + if (!msg) return; - } - - msg = msgb_alloc(sizeof(*om_hdr) + sizeof(*hdr), "link-data"); - if (!msg) { - LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate data.\n"); - return; - } - - - om_hdr = (struct osmo_pcap_data *) msgb_put(msg, sizeof(*om_hdr)); - om_hdr->type = PKT_LINK_HDR; - om_hdr->len = htons(sizeof(*hdr)); - - hdr = (struct pcap_file_header *) msgb_put(msg, sizeof(*hdr)); - hdr->magic = 0xa1b2c3d4; - hdr->version_major = 2; - hdr->version_minor = 4; - hdr->thiszone = 0; - hdr->sigfigs = 0; - hdr->snaplen = conn->client->snaplen; - hdr->linktype = pcap_datalink(ph->handle); - write_data(conn, msg); } diff --git a/src/osmo_pcap_file.c b/src/osmo_pcap_file.c new file mode 100644 index 0000000..eb8cc23 --- /dev/null +++ b/src/osmo_pcap_file.c @@ -0,0 +1,78 @@ +/* + * osmo-pcap-client code + * + * (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * (C) 2011-2016 by Holger Hans Peter Freyther <holger(a)moiji-mobile.com> + * (C) 2011 by On-Waves + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <pcap/pcap.h> + +#include <osmocom/core/msgb.h> + +#include <osmo-pcap/osmo_pcap_file.h> +#include <osmo-pcap/common.h> +#include <osmo-pcap/wireformat.h> + +/*********************************************************** + * Libpcap File Format (.pcap) + * https://wiki.wireshark.org/Development/LibpcapFileFormat + ***********************************************************/ + +/* Appends a Global Header to msg + * returns number of bytes appended on success, negative on error */ +int osmo_pcap_file_msgb_append_global_header(struct msgb *msg, uint32_t snaplen, uint32_t linktype) +{ + struct pcap_file_header *hdr; + + hdr = (struct pcap_file_header *) msgb_put(msg, sizeof(*hdr)); + hdr->magic = OSMO_PCAP_FILE_MAGIC; + hdr->version_major = 2; + hdr->version_minor = 4; + hdr->thiszone = 0; + hdr->sigfigs = 0; + hdr->snaplen = snaplen; + hdr->linktype = linktype; + + return sizeof(*hdr); +} + +/* Get required length to store a given record (packet) */ +unsigned int osmo_pcap_file_record_size(const struct pcap_pkthdr *in_hdr) +{ + return sizeof(struct osmo_pcap_pkthdr) + in_hdr->caplen; +} + +/* Appends a Record (Packet) Header to msg + * returns number of bytes appended on success, negative on error */ +int osmo_pcap_file_msgb_append_record(struct msgb *msg, const struct pcap_pkthdr *in_hdr, const uint8_t *data) +{ + struct osmo_pcap_pkthdr *hdr; + uint8_t *pkt_payload; + + hdr = (struct osmo_pcap_pkthdr *) msgb_put(msg, sizeof(*hdr)); + hdr->ts_sec = in_hdr->ts.tv_sec; + hdr->ts_usec = in_hdr->ts.tv_usec; + hdr->caplen = in_hdr->caplen; + hdr->len = in_hdr->len; + + pkt_payload = msgb_put(msg, in_hdr->caplen); + memcpy(pkt_payload, data, in_hdr->caplen); + + return osmo_pcap_file_record_size(in_hdr); +} -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39288?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: Ifd389a2a32897e101c62fd280ddca984d485d373 Gerrit-Change-Number: 39288 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-pcap[master]: client: Support generation of pcapng file format
by pespin 13 Jan '25

13 Jan '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39265?usp=email ) Change subject: client: Support generation of pcapng file format ...................................................................... client: Support generation of pcapng file format Support transmitting traffic recordings in pcapng towards osmo-pca-server based on VTY config. Old libpcap's file format (.pcap) is still left as default to to keep backward compatibility towards older osmo-pcap-server instances still running. Furthermore, .pcap support is more extended than .pcapng since it's way older. When pcapng file format is selected, osmo-pcap-client will use the same osmo-pcap protocol used in pcap mode, but the payloads encoded in messages will be in pcapng file format instead of pcap. This means, for LINK_HDR message type it will encode a file header with a payload consisting of 1 SHB + N IDB blocks (one for each network interface being monitored). Upon each packet recording received from the monitoring interface, it will encode a LINK_DATA message containing a payload with a encoded pcapng block. This works mostly transparetly on the osmo-pcap-server side, since in general it handles those payloads mostly transparently. Only some sanity checks will need to be updated and improve there to account for the new pcapng blocks. This in turn requires identifying pcap vs pcapng format being recieved from the client, and also placing the proper file suffix when creating the file. This will be done in a follow-up patch modyfing the server side. Related: SYS#5822 Change-Id: I3c80518a1e53a1f77e1aca8dfa83f683f9516ad6 --- M doc/manuals/chapters/client.adoc M include/osmo-pcap/osmo_pcap_client.h M include/osmo-pcap/osmo_pcap_file.h M src/osmo_client_core.c M src/osmo_client_network.c M src/osmo_client_vty.c M src/osmo_pcap_file.c 7 files changed, 534 insertions(+), 10 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve diff --git a/doc/manuals/chapters/client.adoc b/doc/manuals/chapters/client.adoc index f6ceac5..1769b60 100644 --- a/doc/manuals/chapters/client.adoc +++ b/doc/manuals/chapters/client.adoc @@ -44,15 +44,28 @@ .osmo-pcap-client VTY configuration for packet capture ---- client - pcap device eth0 <1> - pcap filter udp port 23000 <2> - pcap detect-loop 1 <3> + pcap file-format pcapng <1> + pcap device eth0 <2> + pcap device eth2 <3> + pcap filter udp port 23000 <4> + pcap detect-loop 1 <5> ---- -<1> the network device from which to obtain a capture -<2> the libpcap filter string (`udp port 23000` in this example) -<3> instruct osmo-pcap-client to automatically add a filter that prevents capturing - the traffic between osmo-pcap-client and osmo-pcap-server, which would create a loop. +<1> Prepare records in pcapng format. +<2> The network device from which to obtain a capture. +<3> Recording from multiple devices concurrently is supported. +<4> The libpcap filter string (`udp port 23000` in this example). +<5> Instruct osmo-pcap-client to automatically add a filter that prevents + capturing the traffic between osmo-pcap-client and osmo-pcap-server, + which would create a loop. +Adding or removing new recording network devices during operation is not really +supported, and a restart of osmo-pcap-client is expected for the new +configuration to be properly set up. + +NOTE:: Recording from multiple network devices using old libpcap .pcap format is +also supported, but since that file format doesn't allow storing per-interface +information, it will end up stored in the server as if all came from the same +interface. === Configuring the primary server diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h index 470edb6..1b66488 100644 --- a/include/osmo-pcap/osmo_pcap_client.h +++ b/include/osmo-pcap/osmo_pcap_client.h @@ -31,6 +31,7 @@ #include <osmocom/core/write_queue.h> #include <osmo-pcap/osmo_tls.h> +#include <osmo-pcap/osmo_pcap_file.h> #define WQUEUE_MAXLEN_DEFAULT 1000 @@ -115,6 +116,7 @@ int filter_itself; int gprs_filtering; int snaplen; + enum osmo_pcap_fmt pcap_fmt; struct osmo_pcap_client_conn *conn; struct llist_head conns; diff --git a/include/osmo-pcap/osmo_pcap_file.h b/include/osmo-pcap/osmo_pcap_file.h index 50a7706..705e6d2 100644 --- a/include/osmo-pcap/osmo_pcap_file.h +++ b/include/osmo-pcap/osmo_pcap_file.h @@ -24,6 +24,11 @@ #include <unistd.h> #include <stdint.h> +enum osmo_pcap_fmt { + OSMO_PCAP_FMT_PCAP = 0, + OSMO_PCAP_FMT_PCAPNG, +}; + /*********************************************************** * Libpcap File Format (.pcap) * https://wiki.wireshark.org/Development/LibpcapFileFormat @@ -35,3 +40,113 @@ unsigned int osmo_pcap_file_record_size(const struct pcap_pkthdr *in_hdr); int osmo_pcap_file_msgb_append_record(struct msgb *msg, const struct pcap_pkthdr *in_hdr, const uint8_t *data); + +/*********************************************************** + * PCAP Next Generation (pcapng) Capture File Format + * https://wiki.wireshark.org/Development/PcapNg + * https://ietf-opsawg-wg.github.io/draft-ietf-opsawg-pcap/draft-ietf-opsawg-p… + * Related: wireshark.git: wiretap/{pcapng.*, pcapio.c, pcapng_module.h}, wtap_opttypes.h, dumpcap.c + ***********************************************************/ + +#define OSMO_PCAPNG_FILE_MAGIC 0x1A2B3C4D +#define OSMO_PCAPNG_FILE_MAGIC_SWAPPED 0x4D3C2B1A + +#define BLOCK_TYPE_SHB 0x0A0D0D0A /* Section Header Block */ +#define BLOCK_TYPE_IDB 0x00000001 /* Interface Description Block */ +#define BLOCK_TYPE_PB 0x00000002 /* Packet Block (obsolete) */ +#define BLOCK_TYPE_SPB 0x00000003 /* Simple Packet Block */ +#define BLOCK_TYPE_EPB 0x00000006 /* Enhanced Packet Block */ + +/* Options for all blocks */ +#define OPT_EOFOPT 0 +#define OPT_COMMENT 1 +/* Section Header block (SHB) */ +#define OPT_SHB_HARDWARE 2 +#define OPT_SHB_OS 3 +#define OPT_SHB_USERAPPL 4 + +/* Interface Description block (IDB) */ +#define OPT_IDB_NAME 2 +#define OPT_IDB_DESCRIPTION 3 +#define OPT_IDB_IP4ADDR 4 +#define OPT_IDB_IP6ADDR 5 +#define OPT_IDB_MACADDR 6 +#define OPT_IDB_FILTER 11 + +/* filter Option: */ +enum osmo_pcapng_file_if_filter_type { + IF_FILTER_CAP = 0, /* pcap filter string */ + IF_FILTER_BPF = 1 /* BPF program */ +}; + +/* pcapng: common block header file encoding for every block type */ +struct pcapng_block_header { + uint32_t block_type; + uint32_t block_total_length; + uint8_t block_body[0]; /* x bytes block_body */ + /* uint32_t block_total_length */ +} __attribute__((packed)); + +struct pcapng_option_header { + uint16_t type; + uint16_t value_length; +} __attribute__((packed)); + +/* pcapng: section header block file encoding */ +struct pcapng_section_header_block { + /* pcapng_block_header_t */ + uint32_t magic; + uint16_t version_major; + uint16_t version_minor; + uint64_t section_length; /* might be -1 for unknown */ + /* ... Options ... */ +} __attribute__((packed)); + +/* pcapng: interface description block file encoding */ +struct pcapng_iface_descr_block { + uint16_t linktype; + uint16_t reserved; + uint32_t snaplen; + /* ... Options ... */ +} __attribute__((packed)); + +/* pcapng: enhanced packet block file encoding */ +struct pcapng_enhanced_packet_block { + uint32_t interface_id; + uint32_t timestamp_high; + uint32_t timestamp_low; + uint32_t captured_len; + uint32_t packet_len; + uint8_t packet_data[0]; /* ... Packet Data ... */ + /* ... Padding ... */ + /* ... Options ... */ +} __attribute__((packed)); + +/* Helper APIs to encode blocks: */ + +struct osmo_pcapng_file_shb_pars { + const char *hardware; + const char *os; + const char *userappl; +}; +unsigned int osmo_pcapng_file_shb_size(const struct osmo_pcapng_file_shb_pars *pars); +int osmo_pcapng_file_msgb_append_shb(struct msgb *msg, const struct osmo_pcapng_file_shb_pars *pars); + +struct osmo_pcapng_file_idb_pars { + const char *name; + const char *filter; + int link_type; + int snap_len; +}; +unsigned int osmo_pcapng_file_idb_size(const struct osmo_pcapng_file_idb_pars *pars); +int osmo_pcapng_file_msgb_append_idb(struct msgb *msg, const struct osmo_pcapng_file_idb_pars *pars); + +struct osmo_pcapng_file_epb_pars { + uint64_t timestamp_usec; + uint32_t interface_id; + const uint8_t *captured_data; + uint32_t captured_len; + uint32_t packet_len; +}; +unsigned int osmo_pcapng_file_epb_size(const struct osmo_pcapng_file_epb_pars *pars); +int osmo_pcapng_file_msgb_append_epb(struct msgb *msg, const struct osmo_pcapng_file_epb_pars *pars); diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 538b68a..dd16878 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -303,6 +303,7 @@ return NULL; client->snaplen = DEFAULT_SNAPLEN; + client->pcap_fmt = OSMO_PCAP_FMT_PCAP; INIT_LLIST_HEAD(&client->handles); INIT_LLIST_HEAD(&client->conns); diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c index e14f4ca..abdb7d3 100644 --- a/src/osmo_client_network.c +++ b/src/osmo_client_network.c @@ -187,6 +187,46 @@ return msg; } +static struct msgb *osmo_client_conn_prepare_msg_data_pcapng(struct osmo_pcap_client_conn *conn, + const struct osmo_pcap_handle *ph, + const struct pcap_pkthdr *pkthdr, + const uint8_t *data) +{ + struct osmo_pcap_data *om_hdr; + struct msgb *msg; + struct osmo_pcapng_file_epb_pars epb_pars; + unsigned int record_size; + int rc; + + epb_pars = (struct osmo_pcapng_file_epb_pars){ + .timestamp_usec = (pkthdr->ts.tv_sec * 1000 * 1000) + pkthdr->ts.tv_usec, + .interface_id = ph->idx, + .captured_data = data, + .captured_len = pkthdr->caplen, + .packet_len = pkthdr->len, + }; + + record_size = osmo_pcapng_file_epb_size(&epb_pars); + + msg = msgb_alloc(sizeof(*om_hdr) + record_size, "pcap-data"); + if (!msg) { + LOGCONN(conn, LOGL_ERROR, "Failed to allocate\n"); + rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_NOMEM); + return NULL; + } + + om_hdr = (struct osmo_pcap_data *) msgb_put(msg, sizeof(*om_hdr)); + om_hdr->type = PKT_LINK_DATA; + om_hdr->len = htons(record_size); + rc = osmo_pcapng_file_msgb_append_epb(msg, &epb_pars); + if (rc < 0) { + msgb_free(msg); + return NULL; + } + + return msg; +} + static struct msgb *osmo_client_conn_prepare_msg_ipip(struct osmo_pcap_client_conn *conn, const struct osmo_pcap_handle *ph, const struct pcap_pkthdr *pkthdr, @@ -231,7 +271,16 @@ switch (conn->protocol) { case PROTOCOL_OSMOPCAP: - msg = osmo_client_conn_prepare_msg_data_pcap(conn, ph, pkthdr, data); + switch (client->pcap_fmt) { + case OSMO_PCAP_FMT_PCAP: + msg = osmo_client_conn_prepare_msg_data_pcap(conn, ph, pkthdr, data); + break; + case OSMO_PCAP_FMT_PCAPNG: + msg = osmo_client_conn_prepare_msg_data_pcapng(conn, ph, pkthdr, data); + break; + default: + OSMO_ASSERT(0); + } break; case PROTOCOL_IPIP: msg = osmo_client_conn_prepare_msg_ipip(conn, ph, pkthdr, data); @@ -271,7 +320,7 @@ if (linktype != pcap_datalink(ph->handle)) { LOGCONN(conn, LOGL_ERROR, "File format 'pcap' doesn't support recording from multiple ifaces " - "with different link types!\n"); + "with different link types! Use VTY config 'pcap file-format pcapng'.\n"); return NULL; } } @@ -298,6 +347,81 @@ return msg; } +struct osmo_pcapng_file_shb_pars shb_pars = { + .hardware = "osmo-pcap hw", + .os = "osmo-pcap os", + .userappl = "osmo-pcap userappl", +}; + +static int pcap_handle_prepare_pcapng_idb_pars(const struct osmo_pcap_handle *ph, + struct osmo_pcapng_file_idb_pars *pars) +{ + struct osmo_pcap_client *client = ph->client; + memset(pars, 0, sizeof(*pars)); + + pars->name = ph->devname; + pars->filter = client->filter_string; + pars->link_type = pcap_datalink(ph->handle); + pars->snap_len = client->snaplen; + return 0; +} + +static struct msgb *osmo_client_conn_prepare_msg_link_pcapng(struct osmo_pcap_client_conn *conn) +{ + struct osmo_pcap_data *om_hdr; + struct msgb *msg; + struct osmo_pcap_handle *ph; + int rc; + uint32_t file_hdr_size = osmo_pcapng_file_shb_size(&shb_pars); + + /* Calculate size: */ + llist_for_each_entry(ph, &conn->client->handles, entry) { + struct osmo_pcapng_file_idb_pars idb_pars; + if (pcap_handle_prepare_pcapng_idb_pars(ph, &idb_pars) < 0) { + LOGPH(ph, LOGL_ERROR, "Failed preparing pcapng IDB from handle\n"); + return NULL; + } + file_hdr_size += osmo_pcapng_file_idb_size(&idb_pars); + } + + msg = msgb_alloc(sizeof(*om_hdr) + file_hdr_size, "link-data"); + if (!msg) { + LOGCONN(conn, LOGL_ERROR, "Failed to allocate data\n"); + return NULL; + } + + om_hdr = (struct osmo_pcap_data *)msgb_put(msg, sizeof(*om_hdr)); + om_hdr->type = PKT_LINK_HDR; + + rc = osmo_pcapng_file_msgb_append_shb(msg, &shb_pars); + if (rc < 0) { + LOGCONN(conn, LOGL_ERROR, "Failed to create pcapng SHB\n"); + msgb_free(msg); + return NULL; + } + om_hdr->len = rc; + + llist_for_each_entry(ph, &conn->client->handles, entry) { + struct osmo_pcapng_file_idb_pars idb_pars; + if (pcap_handle_prepare_pcapng_idb_pars(ph, &idb_pars) < 0) { + LOGPH(ph, LOGL_ERROR, "Failed preparing pcapng IDB from handle\n"); + msgb_free(msg); + return NULL; + } + rc = osmo_pcapng_file_msgb_append_idb(msg, &idb_pars); + if (rc < 0) { + LOGPH(ph, LOGL_ERROR, "Failed to append pcapng IDB to msgb\n"); + msgb_free(msg); + return NULL; + } + om_hdr->len += rc; + } + + OSMO_ASSERT(om_hdr->len == file_hdr_size); + om_hdr->len = htons(om_hdr->len); + return msg; +} + void osmo_client_conn_send_link(struct osmo_pcap_client_conn *conn) { struct msgb *msg; @@ -306,7 +430,17 @@ if (conn->protocol == PROTOCOL_IPIP) return; - msg = osmo_client_conn_prepare_msg_link_pcap(conn); + switch (conn->client->pcap_fmt) { + case OSMO_PCAP_FMT_PCAP: + msg = osmo_client_conn_prepare_msg_link_pcap(conn); + break; + case OSMO_PCAP_FMT_PCAPNG: + msg = osmo_client_conn_prepare_msg_link_pcapng(conn); + break; + default: + OSMO_ASSERT(0); + } + if (!msg) return; write_data(conn, msg); diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c index 009c735..1824324 100644 --- a/src/osmo_client_vty.c +++ b/src/osmo_client_vty.c @@ -1,6 +1,7 @@ /* * osmo-pcap-client code * + * (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> * (C) 2011-2016 by Holger Hans Peter Freyther <holger(a)moiji-mobile.com> * (C) 2011 by On-Waves * All Rights Reserved @@ -130,6 +131,8 @@ vty_out(vty, "client%s", VTY_NEWLINE); + if (pcap_client->pcap_fmt != OSMO_PCAP_FMT_PCAP) + vty_out(vty, " pcap file-format pcapng%s", VTY_NEWLINE); llist_for_each_entry(ph, &pcap_client->handles, entry) { vty_out(vty, " pcap device %s%s", ph->devname, VTY_NEWLINE); @@ -150,6 +153,22 @@ return CMD_SUCCESS; } +DEFUN(cfg_client_pcap_file_format, + cfg_client_pcap_file_format_cmd, + "pcap file-format (pcap|pcapng)", + PCAP_STRING "The pcap file format to use\n" + "Libpcap Capture File Format (.pcap)\n" + "PCAP Next Generation Capture File Format (.pcapng)\n") +{ + if (strcmp(argv[0], "pcap") == 0) + pcap_client->pcap_fmt = OSMO_PCAP_FMT_PCAP; + else if (strcmp(argv[0], "pcapng") == 0) + pcap_client->pcap_fmt = OSMO_PCAP_FMT_PCAPNG; + else + return CMD_WARNING; + return CMD_SUCCESS; +} + DEFUN(cfg_client_no_device, cfg_client_no_device_cmd, "no pcap device NAME", @@ -559,6 +578,7 @@ install_node(&server_node, config_write_server); + install_element(CLIENT_NODE, &cfg_client_pcap_file_format_cmd); install_element(CLIENT_NODE, &cfg_client_no_device_cmd); install_element(CLIENT_NODE, &cfg_client_device_cmd); install_element(CLIENT_NODE, &cfg_client_snaplen_cmd); diff --git a/src/osmo_pcap_file.c b/src/osmo_pcap_file.c index eb8cc23..4b8b114 100644 --- a/src/osmo_pcap_file.c +++ b/src/osmo_pcap_file.c @@ -76,3 +76,242 @@ return osmo_pcap_file_record_size(in_hdr); } + + +/*********************************************************** + * PCAP Next Generation (pcapng) Capture File Format + * https://wiki.wireshark.org/Development/PcapNg + * https://ietf-opsawg-wg.github.io/draft-ietf-opsawg-pcap/draft-ietf-opsawg-p… + * Related: wireshark.git: wiretap/{pcapng.*, pcapio.c, pcapng_module.h}, wtap_opttypes.h, dumpcap.c + ***********************************************************/ + +/* Get required length to store a string option */ +static unsigned int osmo_pcapng_file_opt_string_size(const char *str) +{ + size_t str_len = str ? strlen(str) : 0; + uint8_t pad = str_len % 4; + /* Each option is padded to 4 bytes: */ + if (pad) + pad = 4 - pad; + return sizeof(struct pcapng_option_header) + str_len + pad; +} + +/* Append a string option */ +static int osmo_pcapng_file_msgb_append_opt_string(struct msgb *msg, uint16_t type, const char *str) +{ + struct pcapng_option_header *opth; + size_t str_len = str ? strlen(str) : 0; + + opth = (struct pcapng_option_header *)msgb_put(msg, sizeof(*opth)); + opth->type = type; + opth->value_length = str_len; + if (str_len > 0) + memcpy(msgb_put(msg, str_len), str, str_len); + + /* Each option is padded to 4 bytes: */ + uint8_t pad = str_len % 4; + if (pad) { + pad = 4 - pad; + uint8_t *buf = (uint8_t *)msgb_put(msg, pad); + memset(buf, 0, pad); + } + return sizeof(*opth) + opth->value_length + pad; +} + +/* Get required length to store a if_filter option. + * This is a 1 byte enum osmo_pcapng_file_if_filter_type + string */ +static unsigned int osmo_pcapng_file_opt_if_filter_string_size(const char *str) +{ + size_t str_len = str ? strlen(str) : 0; + size_t len = 1 + str_len; + uint8_t pad = len % 4; + /* Each option is padded to 4 bytes: */ + if (pad) + pad = 4 - pad; + return sizeof(struct pcapng_option_header) + len + pad; +} + +/* Append a if_filter option (OPT_IDB_FILTER). */ +static int osmo_pcapng_file_msgb_append_opt_if_filter_string(struct msgb *msg, uint16_t type, const char *str) +{ + struct pcapng_option_header *opth; + uint8_t if_filter_type = IF_FILTER_CAP; + size_t str_len = str ? strlen(str) : 0; + + opth = (struct pcapng_option_header *)msgb_put(msg, sizeof(*opth)); + opth->type = type; + opth->value_length = 1 + str_len; + msgb_put_u8(msg, if_filter_type); + if (str_len > 0) + memcpy(msgb_put(msg, str_len), str, str_len); + + /* Each option is padded to 4 bytes: */ + uint8_t pad = opth->value_length % 4; + if (pad) { + pad = 4 - pad; + uint8_t *buf = (uint8_t *)msgb_put(msg, pad); + memset(buf, 0, pad); + } + return sizeof(*opth) + opth->value_length + pad; +} + +/* Get required length to store a OPT_EOFOPT option */ +static unsigned int osmo_pcapng_file_opt_eofopt_size(void) +{ + return sizeof(struct pcapng_option_header); +} + +/* Append a OPT_EOFOPT option */ +static int osmo_pcapng_file_msgb_append_opt_eofopt(struct msgb *msg) +{ + struct pcapng_option_header *opth; + + opth = (struct pcapng_option_header *)msgb_put(msg, sizeof(*opth)); + opth->type = OPT_EOFOPT; + opth->value_length = 0; + + return sizeof(*opth); +} + +/* Get required length to store a given record (packet) */ +unsigned int osmo_pcapng_file_shb_size(const struct osmo_pcapng_file_shb_pars *pars) +{ + uint32_t block_total_len = sizeof(struct pcapng_block_header) + + sizeof(struct pcapng_section_header_block) + + sizeof(uint32_t); + block_total_len += osmo_pcapng_file_opt_string_size(pars->hardware); + block_total_len += osmo_pcapng_file_opt_string_size(pars->os); + block_total_len += osmo_pcapng_file_opt_string_size(pars->userappl); + block_total_len += osmo_pcapng_file_opt_eofopt_size(); + return block_total_len; +} + +/* Appends a Section Header Block (SHB) to msg + * returns number of bytes appended on success, negative on error */ +int osmo_pcapng_file_msgb_append_shb(struct msgb *msg, const struct osmo_pcapng_file_shb_pars *pars) +{ + struct pcapng_block_header *bh; + struct pcapng_section_header_block *shb; + uint8_t *footer_len; + uint32_t block_total_len = osmo_pcapng_file_shb_size(pars); + + bh = (struct pcapng_block_header *)msgb_put(msg, sizeof(*bh)); + bh->block_type = BLOCK_TYPE_SHB; + bh->block_total_length = block_total_len; + + /* write block fixed content */ + shb = (struct pcapng_section_header_block *)msgb_put(msg, sizeof(*shb)); + shb->magic = 0x1A2B3C4D; + shb->version_major = 1; + shb->version_minor = 0; + shb->section_length = -1; + + /* Options (variable) */ + osmo_pcapng_file_msgb_append_opt_string(msg, OPT_SHB_HARDWARE, pars->hardware); + osmo_pcapng_file_msgb_append_opt_string(msg, OPT_SHB_OS, pars->os); + osmo_pcapng_file_msgb_append_opt_string(msg, OPT_SHB_USERAPPL, pars->userappl); + osmo_pcapng_file_msgb_append_opt_eofopt(msg); + + /* SHB Block Total Length */ + footer_len = (uint8_t *)msgb_put(msg, sizeof(uint32_t)); + memcpy(footer_len, &block_total_len, sizeof(uint32_t)); + + return block_total_len; +} + +unsigned int osmo_pcapng_file_idb_size(const struct osmo_pcapng_file_idb_pars *pars) +{ + uint32_t block_total_len = sizeof(struct pcapng_block_header) + + sizeof(struct pcapng_iface_descr_block) + + sizeof(uint32_t); + block_total_len += osmo_pcapng_file_opt_string_size(pars->name); + block_total_len += osmo_pcapng_file_opt_if_filter_string_size(pars->filter); + block_total_len += osmo_pcapng_file_opt_eofopt_size(); + return block_total_len; +} + +int osmo_pcapng_file_msgb_append_idb(struct msgb *msg, const struct osmo_pcapng_file_idb_pars *pars) +{ + struct pcapng_block_header *bh; + struct pcapng_iface_descr_block *idb; + uint8_t *footer_len; + uint32_t block_total_len = osmo_pcapng_file_idb_size(pars); + + bh = (struct pcapng_block_header *)msgb_put(msg, sizeof(*bh)); + bh->block_type = BLOCK_TYPE_IDB; + bh->block_total_length = block_total_len; + + /* write block fixed content */ + idb = (struct pcapng_iface_descr_block *)msgb_put(msg, sizeof(*idb)); + idb->linktype = pars->link_type; + idb->reserved = 0; + idb->snaplen = pars->snap_len; + + /* Options (variable) */ + osmo_pcapng_file_msgb_append_opt_string(msg, OPT_IDB_NAME, pars->name); + osmo_pcapng_file_msgb_append_opt_if_filter_string(msg, OPT_IDB_FILTER, pars->filter); + osmo_pcapng_file_msgb_append_opt_eofopt(msg); + + /* IDB Block Total Length */ + footer_len = (uint8_t *)msgb_put(msg, sizeof(uint32_t)); + memcpy(footer_len, &block_total_len, sizeof(uint32_t)); + + return block_total_len; +} + +unsigned int osmo_pcapng_file_epb_size(const struct osmo_pcapng_file_epb_pars *pars) +{ + uint32_t block_total_len = sizeof(struct pcapng_block_header) + + sizeof(struct pcapng_enhanced_packet_block) + + pars->captured_len + + sizeof(uint32_t); + /* Packet data is padded to 4 bytes: */ + uint8_t pad = pars->captured_len % 4; + if (pad) + block_total_len += (4 - pad); + + /* TODO: other Options */ + block_total_len += osmo_pcapng_file_opt_eofopt_size(); + return block_total_len; +} + +int osmo_pcapng_file_msgb_append_epb(struct msgb *msg, const struct osmo_pcapng_file_epb_pars *pars) +{ + struct pcapng_block_header *bh; + struct pcapng_enhanced_packet_block *epb; + uint8_t *footer_len; + uint32_t block_total_len = osmo_pcapng_file_epb_size(pars); + + bh = (struct pcapng_block_header *)msgb_put(msg, sizeof(*bh)); + bh->block_type = BLOCK_TYPE_EPB; + bh->block_total_length = block_total_len; + + /* write block fixed content */ + epb = (struct pcapng_enhanced_packet_block *)msgb_put(msg, sizeof(*epb)); + epb->interface_id = pars->interface_id; + epb->timestamp_high = pars->timestamp_usec >> 32; + epb->timestamp_low = (uint32_t)(pars->timestamp_usec & 0xffffffff); + epb->captured_len = pars->captured_len; + epb->packet_len = pars->packet_len; + + /* Packet Data */ + if (pars->captured_len > 0) + memcpy(msgb_put(msg, pars->captured_len), pars->captured_data, pars->captured_len); + + /* Each option is padded to 4 bytes: */ + uint8_t pad = pars->captured_len % 4; + if (pad) { + pad = 4 - pad; + uint8_t *buf = (uint8_t *)msgb_put(msg, pad); + memset(buf, 0, pad); + } + + /* Options (variable) */ + osmo_pcapng_file_msgb_append_opt_eofopt(msg); + + /* EPB Block Total Length */ + footer_len = (uint8_t *)msgb_put(msg, sizeof(uint32_t)); + memcpy(footer_len, &block_total_len, sizeof(uint32_t)); + + return block_total_len; +} -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39265?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I3c80518a1e53a1f77e1aca8dfa83f683f9516ad6 Gerrit-Change-Number: 39265 Gerrit-PatchSet: 9 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-pcap[master]: client: Support generation of pcapng file format
by pespin 13 Jan '25

13 Jan '25
Attention is currently required from: daniel. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39265?usp=email ) Change subject: client: Support generation of pcapng file format ...................................................................... Patch Set 9: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39265?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I3c80518a1e53a1f77e1aca8dfa83f683f9516ad6 Gerrit-Change-Number: 39265 Gerrit-PatchSet: 9 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Comment-Date: Mon, 13 Jan 2025 19:23:16 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[L] Change in osmo-pcap[master]: client: Introduce osmo_pcap_file to prepare support for pcapng
by pespin 13 Jan '25

13 Jan '25
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39288?usp=email ) Change subject: client: Introduce osmo_pcap_file to prepare support for pcapng ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39288?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: Ifd389a2a32897e101c62fd280ddca984d485d373 Gerrit-Change-Number: 39288 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 13 Jan 2025 19:23:12 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[L] Change in osmo-pcap[master]: server: Support storing of pcapng format
by pespin 13 Jan '25

13 Jan '25
Attention is currently required from: daniel, laforge. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39287?usp=email ) Change subject: server: Support storing of pcapng format ...................................................................... Patch Set 5: (2 comments) Commit Message: https://gerrit.osmocom.org/c/osmo-pcap/+/39287/comment/42739e69_1946850e?us… : PS5, Line 13: This requires, during LINK_HDR when file header is received, discering > discering? do you mean distinguishing? I meant discerning, will fix https://dictionary.cambridge.org/dictionary/english/discern File src/osmo_server_network.c: https://gerrit.osmocom.org/c/osmo-pcap/+/39287/comment/c9b1deeb_a8c7f19c?us… : PS5, Line 352: BLOCK_TYPE_SHB > why LOGL_DEBUG here vs LOGL_ERROR above for the other implausible things? This is wrong, I'll fix, thanks. -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39287?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I275d28ab418a1514fa9c5c7c20f3d831cc6af8bb Gerrit-Change-Number: 39287 Gerrit-PatchSet: 5 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Comment-Date: Mon, 13 Jan 2025 19:22:10 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in osmo-bsc[master]: nokia_site: introduce hopping control for Nokia *Site
by laforge 13 Jan '25

13 Jan '25
Attention is currently required from: csaba.sipos, fixeria. laforge has posted comments on this change by csaba.sipos. ( https://gerrit.osmocom.org/c/osmo-bsc/+/39290?usp=email ) Change subject: nokia_site: introduce hopping control for Nokia *Site ...................................................................... Patch Set 8: (2 comments) Patchset: PS7: > Patch set 7 is runtime tested with BB and RF hopping both working against MetroSite. Done File src/osmo-bsc/bts_vty.c: https://gerrit.osmocom.org/c/osmo-bsc/+/39290/comment/8b758bfd_cfa6102f?usp… : PS6, Line 474: CMD_ATTR_IMMEDIATE > I am just using the previously implemented schemes here. […] In that case it should be X(BSC_VTY_ATTR_RESTART_ABIS_OML_LINK) or X(BSC_VTY_ATTR_RESTART_ABIS_RSL_LINK). Please update your current patch and then feel freee to send a second patch fixing old code. -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/39290?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: Idb1d269d2ee80d72ede2394125e8acedf0ee8b06 Gerrit-Change-Number: 39290 Gerrit-PatchSet: 8 Gerrit-Owner: csaba.sipos <metro4(a)freemail.hu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: csaba.sipos <metro4(a)freemail.hu> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 13 Jan 2025 19:17:25 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: csaba.sipos <metro4(a)freemail.hu> Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[XL] Change in osmo-pcap[master]: server: Split network code into its own file
by laforge 13 Jan '25

13 Jan '25
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39302?usp=email ) Change subject: server: Split network code into its own file ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39302?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I41d6e0398605becbea109a7bb5aac8981d65ab1b Gerrit-Change-Number: 39302 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 13 Jan 2025 19:14:58 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • ...
  • 150
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.