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
[M] Change in osmo-bsc[master]: nokia_site: add missing element names
by csaba.sipos 09 Jan '25

09 Jan '25
Attention is currently required from: laforge, pespin. csaba.sipos has posted comments on this change by csaba.sipos. ( https://gerrit.osmocom.org/c/osmo-bsc/+/39252?usp=email ) Change subject: nokia_site: add missing element names ...................................................................... Patch Set 3: (1 comment) File src/osmo-bsc/bts_nokia_site.c: https://gerrit.osmocom.org/c/osmo-bsc/+/39252/comment/dacf1c14_ffd2010b?usp… : PS1, Line 551: if > As far as I read the diff, the original code has "Abis If" for 0xFA and you replace it with "Abis if […] Done -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/39252?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: Ia4026bbe458817e164b756847229cf6a90d02865 Gerrit-Change-Number: 39252 Gerrit-PatchSet: 3 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-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Jan 2025 17:14:05 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Comment-In-Reply-To: csaba.sipos <metro4(a)freemail.hu>
1 0
0 0
[M] Change in osmo-bsc[master]: nokia_site: add missing element names
by csaba.sipos 09 Jan '25

09 Jan '25
Attention is currently required from: csaba.sipos, laforge, pespin. Hello Jenkins Builder, laforge, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-bsc/+/39252?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review+1 by laforge, Code-Review+1 by pespin, Verified+1 by Jenkins Builder Change subject: nokia_site: add missing element names ...................................................................... nokia_site: add missing element names Change-Id: Ia4026bbe458817e164b756847229cf6a90d02865 Signed-off-by: csaba.sipos <metro4(a)freemail.hu> --- M src/osmo-bsc/bts_nokia_site.c 1 file changed, 81 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/52/39252/3 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/39252?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: Ia4026bbe458817e164b756847229cf6a90d02865 Gerrit-Change-Number: 39252 Gerrit-PatchSet: 3 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-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: csaba.sipos <metro4(a)freemail.hu> Gerrit-Attention: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-pcap[master]: server: Simplify code paths in read_cb_*
by pespin 09 Jan '25

09 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39271?usp=email ) Change subject: server: Simplify code paths in read_cb_* ...................................................................... server: Simplify code paths in read_cb_* Change-Id: Ib609af3b1788fe02d9d6957a08d85bc8bae821e8 --- M src/osmo_server_network.c 1 file changed, 29 insertions(+), 26 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/71/39271/1 diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index ff44198..f4f6b06 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -628,16 +628,17 @@ LOGP(DSERVER, LOGL_ERROR, "Someone got the pending read wrong: %d\n", conn->pend); return -1; - } else if (conn->pend == 0) { - conn->data->len = ntohs(conn->data->len); - - if (!pcap_data_valid(conn)) - return -1; - - conn->state = STATE_DATA; - conn->pend = conn->data->len; } + if (conn->pend > 0) + return 1; /* Wait for more data before continuing */ + conn->data->len = ntohs(conn->data->len); + + if (!pcap_data_valid(conn)) + return -1; + + conn->state = STATE_DATA; + conn->pend = conn->data->len; return 1; } @@ -659,29 +660,31 @@ LOGP(DSERVER, LOGL_ERROR, "Someone got the pending read wrong: %d\n", conn->pend); return -1; - } else if (conn->pend == 0) { - conn->state = STATE_INITIAL; - conn->pend = sizeof(*conn->data); + } + if (conn->pend > 0) + return 1; /* Wait for more data before continuing */ - /* count the full packet we got */ - rate_ctr_inc2(conn->ctrg, PEER_CTR_PKTS); - rate_ctr_inc2(conn->server->ctrg, SERVER_CTR_PKTS); + conn->state = STATE_INITIAL; + conn->pend = sizeof(*conn->data); - /* count the bytes of it */ - rate_ctr_add2(conn->ctrg, PEER_CTR_BYTES, conn->data->len); - rate_ctr_add2(conn->server->ctrg, SERVER_CTR_BYTES, conn->data->len); + /* count the full packet we got */ + rate_ctr_inc2(conn->ctrg, PEER_CTR_PKTS); + rate_ctr_inc2(conn->server->ctrg, SERVER_CTR_PKTS); - switch (conn->data->type) { - case PKT_LINK_HDR: - return rx_link_hdr(conn, conn->data); - break; - case PKT_LINK_DATA: - return rx_link_data(conn, conn->data); - break; - } + /* count the bytes of it */ + rate_ctr_add2(conn->ctrg, PEER_CTR_BYTES, conn->data->len); + rate_ctr_add2(conn->server->ctrg, SERVER_CTR_BYTES, conn->data->len); + + switch (conn->data->type) { + case PKT_LINK_HDR: + rc = rx_link_hdr(conn, conn->data); + case PKT_LINK_DATA: + rc = rx_link_data(conn, conn->data); + default: + OSMO_ASSERT(0); } - return 1; + return rc; } /* returns >0 on success, <= 0 on failure (closes conn) */ -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39271?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: Ib609af3b1788fe02d9d6957a08d85bc8bae821e8 Gerrit-Change-Number: 39271 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: server: Delay reopen of pcap only until necessary
by pespin 09 Jan '25

09 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39272?usp=email ) Change subject: server: Delay reopen of pcap only until necessary ...................................................................... server: Delay reopen of pcap only until necessary If we are asked to reopen a pcap file (eg due to external SIGUSR1) while in the middle of receiving a data packet (we already received the header of the segment so data will arrive soon), code exists to delay reopening so that we can include that last packet which arrived because the time where we were asked to reopen. However, the new pcap file was reopened only after next packet arrived. Instead, we want to reopen it as soon as that last packet is received, so that a new pcap file is created. This allows better tracking eg. empty traffic during time in between last data packet before reopen and the next data packet arriving. While at it, rename the variable to make it more informative, and convert it to a bool. Change-Id: Id79500717a2e186aac979cded340a5af6ce3035b --- M include/osmo-pcap/osmo_pcap_server.h M src/osmo_server_network.c 2 files changed, 8 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/72/39272/1 diff --git a/include/osmo-pcap/osmo_pcap_server.h b/include/osmo-pcap/osmo_pcap_server.h index dad81d3..030a353 100644 --- a/include/osmo-pcap/osmo_pcap_server.h +++ b/include/osmo-pcap/osmo_pcap_server.h @@ -97,7 +97,7 @@ /* read buffering */ int state; int pend; - int reopen; + bool reopen_delayed; struct osmo_pcap_data *data; /* statistics */ diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index f4f6b06..d57b42b 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -684,6 +684,12 @@ OSMO_ASSERT(0); } + if (conn->reopen_delayed) { + LOGP(DSERVER, LOGL_INFO, "Reopening log for %s now.\n", conn->name); + restart_pcap(conn); + conn->reopen_delayed = false; + } + return rc; } @@ -691,11 +697,6 @@ static int dispatch_read(struct osmo_pcap_conn *conn) { if (conn->state == STATE_INITIAL) { - if (conn->reopen) { - LOGP(DSERVER, LOGL_INFO, "Reopening log for %s now.\n", conn->name); - restart_pcap(conn); - conn->reopen = 0; - } return read_cb_initial(conn); } else if (conn->state == STATE_DATA) { return read_cb_data(conn); @@ -872,7 +873,7 @@ restart_pcap(conn); } else { LOGP(DSERVER, LOGL_INFO, "Delaying %s until current packet is complete.\n", conn->name); - conn->reopen = 1; + conn->reopen_delayed = true; } } } -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39272?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: Id79500717a2e186aac979cded340a5af6ce3035b Gerrit-Change-Number: 39272 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: cosmetic: server: document functions
by pespin 09 Jan '25

09 Jan '25
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-pcap/+/39270?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder Change subject: cosmetic: server: document functions ...................................................................... cosmetic: server: document functions Change-Id: I6709b720e236514b8572fe60834a990558e67f5c --- M src/osmo_server_network.c 1 file changed, 9 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/70/39270/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39270?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: I6709b720e236514b8572fe60834a990558e67f5c Gerrit-Change-Number: 39270 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder
1 0
0 0
[XS] Change in osmo-pcap[master]: cosmetic: server: document functions
by pespin 09 Jan '25

09 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39270?usp=email ) Change subject: cosmetic: server: document functions ...................................................................... cosmetic: server: document functions Change-Id: I6709b720e236514b8572fe60834a990558e67f5c --- M src/osmo_server_network.c 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/70/39270/1 diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index d55b30d..18836e5 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -610,6 +610,8 @@ return true; } +/* Read segment header, struct osmo_pcap_data (without payload) + * returns >0 on success, <= 0 on failure (closes conn) */ static int read_cb_initial(struct osmo_pcap_conn *conn) { int rc; @@ -639,6 +641,8 @@ return 1; } +/* Read segment payload, of size conn->data->len. + * returns >0 on success, <= 0 on failure (closes conn) */ static int read_cb_data(struct osmo_pcap_conn *conn) { int rc; @@ -680,6 +684,7 @@ return 1; } +/* returns >0 on success, <= 0 on failure (closes conn) */ static int dispatch_read(struct osmo_pcap_conn *conn) { if (conn->state == STATE_INITIAL) { @@ -760,6 +765,7 @@ rate_ctr_inc2(client->ctrg, PEER_CTR_CONNECT); + /* Prepare for first read of semgent header: */ client->state = STATE_INITIAL; client->pend = sizeof(*client->data); -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39270?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I6709b720e236514b8572fe60834a990558e67f5c Gerrit-Change-Number: 39270 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-pcap[master]: server: Rename static functions
by pespin 09 Jan '25

09 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39268?usp=email ) Change subject: server: Rename static functions ...................................................................... server: Rename static functions The current naming of those functions is totally misleadling with regards of the message type it processes. Let's clarify them. Change-Id: I72f21b38b696e80e481043825ad23c3b8d36ab16 --- M src/osmo_server_network.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/68/39268/1 diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index 9750170..a784af2 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -296,7 +296,7 @@ update_last_write(conn, now); } -static int link_data(struct osmo_pcap_conn *conn, struct osmo_pcap_data *data) +static int rx_link_hdr(struct osmo_pcap_conn *conn, struct osmo_pcap_data *data) { struct pcap_file_header *hdr; @@ -460,7 +460,7 @@ /* * Check if we are past the limit or on a day change */ -static int write_data(struct osmo_pcap_conn *conn, struct osmo_pcap_data *data) +static int rx_link_data(struct osmo_pcap_conn *conn, struct osmo_pcap_data *data) { time_t now = time(NULL); int rc; @@ -667,10 +667,10 @@ switch (conn->data->type) { case PKT_LINK_HDR: - return link_data(conn, conn->data); + return rx_link_hdr(conn, conn->data); break; case PKT_LINK_DATA: - return write_data(conn, conn->data); + return rx_link_data(conn, conn->data); break; } } -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39268?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I72f21b38b696e80e481043825ad23c3b8d36ab16 Gerrit-Change-Number: 39268 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: server: Simplify (store|no-store) feature
by pespin 09 Jan '25

09 Jan '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39269?usp=email ) Change subject: server: Simplify (store|no-store) feature ...................................................................... server: Simplify (store|no-store) feature Having a bool variable with a negation in its name just makes everything more complex for no good reason. Change-Id: If0b76e7a922c26859d04d339bcc3bdccd66a6922 --- M include/osmo-pcap/osmo_pcap_server.h M src/osmo_server_network.c M src/osmo_server_vty.c 3 files changed, 21 insertions(+), 27 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/69/39269/1 diff --git a/include/osmo-pcap/osmo_pcap_server.h b/include/osmo-pcap/osmo_pcap_server.h index bed1cb5..dad81d3 100644 --- a/include/osmo-pcap/osmo_pcap_server.h +++ b/include/osmo-pcap/osmo_pcap_server.h @@ -79,7 +79,7 @@ /* name */ char *name; char *remote_host; - int no_store; + bool store; struct in_addr remote_addr; /* Remote connection */ diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index a784af2..d55b30d 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -254,7 +254,7 @@ osmo_pcap_server_close_trace(conn); /* omit any storing/creation of the file */ - if (conn->no_store) { + if (!conn->store) { update_last_write(conn, now); talloc_free(conn->curr_filename); conn->curr_filename = NULL; @@ -309,10 +309,12 @@ return -1; } - if (!conn->no_store && conn->local_fd < 0) { + if (conn->store && conn->local_fd < 0) { + /* First received link hdr in conn */ conn->file_hdr = *hdr; restart_pcap(conn); } else if (memcmp(&conn->file_hdr, hdr, sizeof(*hdr)) != 0) { + /* Client changed the link hdr in conn */ conn->file_hdr = *hdr; restart_pcap(conn); } @@ -467,7 +469,7 @@ client_data(conn, data); - if (conn->no_store) { + if (!conn->store) { update_last_write(conn, now); return 1; } diff --git a/src/osmo_server_vty.c b/src/osmo_server_vty.c index 1e8e05c..b976857 100644 --- a/src/osmo_server_vty.c +++ b/src/osmo_server_vty.c @@ -128,7 +128,7 @@ llist_for_each_entry(conn, &pcap_server->conn, entry) { vty_out(vty, " client %s %s%s%s%s", conn->name, conn->remote_host, - conn->no_store ? " no-store" : " store", + conn->store ? " store" : " no-store", conn->tls_use ? " tls" : "", VTY_NEWLINE); } @@ -351,7 +351,7 @@ static int manage_client(struct osmo_pcap_server *pcap_server, struct vty *vty, const char *name, const char *remote_host, - bool no_store, bool use_tls) + bool store, bool use_tls) { struct osmo_pcap_conn *conn; conn = osmo_pcap_server_find(pcap_server, name); @@ -364,12 +364,10 @@ conn->remote_host = talloc_strdup(pcap_server, remote_host); inet_aton(remote_host, &conn->remote_addr); - /* Checking no-store and maybe closing a pcap file */ - if (no_store) { + /* Checking store and maybe closing a pcap file */ + if (!store) osmo_pcap_server_close_trace(conn); - conn->no_store = 1; - } else - conn->no_store = 0; + conn->store = store; if (use_tls) { /* force moving to TLS */ @@ -383,25 +381,20 @@ return CMD_SUCCESS; } - DEFUN(cfg_server_client, cfg_server_client_cmd, - "client NAME A.B.C.D [no-store] [tls]", - CLIENT_STR "Remote name used in filenames\n" - "IP of the remote\n" "Do not store traffic\n" + "client NAME A.B.C.D [(store|no-store)] [tls]", + CLIENT_STR + "Remote name used in filenames\n" + "IP of the remote\n" + "Store traffic\n" "Do not store traffic\n" "Use Transport Level Security\n") { - return manage_client(pcap_server, vty, argv[0], argv[1], argc >= 3, argc >= 4); -} - -DEFUN(cfg_server_client_store_tls, - cfg_server_client_store_tls_cmd, - "client NAME A.B.C.D store [tls]", - CLIENT_STR "Remote name used in filenames\n" - "IP of the remote\n" "Do not store traffic\n" - "Use Transport Level Security\n") -{ - return manage_client(pcap_server, vty, argv[0], argv[1], false, argc >= 3); + bool store = true; + if (argc >= 3 && strcmp(argv[2], "no-store") == 0) + store = false; + bool tls = argc >= 4; + return manage_client(pcap_server, vty, argv[0], argv[1], store, tls); } DEFUN(cfg_server_no_client, @@ -734,6 +727,5 @@ install_element(SERVER_NODE, &cfg_tls_dh_pkcs3_cmd); install_element(SERVER_NODE, &cfg_server_client_cmd); - install_element(SERVER_NODE, &cfg_server_client_store_tls_cmd); install_element(SERVER_NODE, &cfg_server_no_client_cmd); } -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39269?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: If0b76e7a922c26859d04d339bcc3bdccd66a6922 Gerrit-Change-Number: 39269 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: Use #pragma once in all header files
by pespin 09 Jan '25

09 Jan '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39267?usp=email ) Change subject: Use #pragma once in all header files ...................................................................... Use #pragma once in all header files osmo_pcap_client.h was missing a mechanism to re-include, such as #pragma once. While at it, change other files to use the pragma instead of defines. Change-Id: I35eb36898bb7a540c7b430db8021bb4c09b72da8 --- M include/osmo-pcap/osmo_pcap_client.h M include/osmo-pcap/osmo_pcap_server.h M include/osmo-pcap/wireformat.h 3 files changed, 3 insertions(+), 10 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h index 250a41f..09a4674 100644 --- a/include/osmo-pcap/osmo_pcap_client.h +++ b/include/osmo-pcap/osmo_pcap_client.h @@ -19,6 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ +#pragma once #include "osmo_tls.h" diff --git a/include/osmo-pcap/osmo_pcap_server.h b/include/osmo-pcap/osmo_pcap_server.h index 614ceca..bed1cb5 100644 --- a/include/osmo-pcap/osmo_pcap_server.h +++ b/include/osmo-pcap/osmo_pcap_server.h @@ -19,9 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ - -#ifndef OSMO_PCAP_SERVER_H -#define OSMO_PCAP_SERVER_H +#pragma once #include "wireformat.h" #include "osmo_tls.h" @@ -168,5 +166,3 @@ void vty_server_init(void); void osmo_pcap_server_close_trace(struct osmo_pcap_conn *conn); void osmo_pcap_server_close_conn(struct osmo_pcap_conn *conn); - -#endif diff --git a/include/osmo-pcap/wireformat.h b/include/osmo-pcap/wireformat.h index 54dce22..3838830 100644 --- a/include/osmo-pcap/wireformat.h +++ b/include/osmo-pcap/wireformat.h @@ -19,9 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ - -#ifndef WIREFORMAT_H -#define WIREFORMAT_H +#pragma once #include <inttypes.h> #include <pcap.h> @@ -49,5 +47,3 @@ uint32_t caplen; uint32_t len; } __attribute__((packed)); - -#endif -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39267?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: I35eb36898bb7a540c7b430db8021bb4c09b72da8 Gerrit-Change-Number: 39267 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in pysim[master]: javacard: add parser for JAVA-card CAP file format
by laforge 09 Jan '25

09 Jan '25
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/39198?usp=email ) Change subject: javacard: add parser for JAVA-card CAP file format ...................................................................... javacard: add parser for JAVA-card CAP file format To install JAVA-card applets we need to be able to extract the executeable loadfile and the AIDs of the applet and the loadfile. This patch adds the parser and related unittests. Related: OS#6679 Change-Id: I581483ccb9d8a254fcecc995fec3c811c5cf38eb --- M pySim/javacard.py A tests/unittests/test_javacard.cap A tests/unittests/test_javacard.py 3 files changed, 140 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/javacard.py b/pySim/javacard.py index 07b0f39..6005ab4 100644 --- a/pySim/javacard.py +++ b/pySim/javacard.py @@ -1,9 +1,30 @@ # JavaCard related utilities - +# +# (C) 2024 by Sysmocom s.f.m.c. GmbH +# All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# import zipfile import struct import sys import io +from osmocom.utils import b2h, Hexstr +from construct import Struct, Array, this, Int32ub, Int16ub, Int8ub +from osmocom.construct import * +from osmocom.tlv import * +from construct import Optional as COptional def ijc_to_cap(in_file: io.IOBase, out_zip: zipfile.ZipFile, p : str = "foo"): """Convert an ICJ (Interoperable Java Card) file [back] to a CAP file. @@ -19,3 +40,103 @@ out_zip.writestr(p+"/javacard/"+TAGS[tag-1]+".cap", b[0:3+size]) b = b[3+size:] +class CapFile(): + + # Java Card Platform Virtual Machine Specification, v3.2, section 6.4 + __header_component_compact = Struct('tag'/Int8ub, + 'size'/Int16ub, + 'magic'/Int32ub, + 'minor_version'/Int8ub, + 'major_version'/Int8ub, + 'flags'/Int8ub, + 'package'/Struct('minor_version'/Int8ub, + 'major_version'/Int8ub, + 'AID'/LV), + 'package_name'/COptional(LV)) #since CAP format 2.2 + + # Java Card Platform Virtual Machine Specification, v3.2, section 6.6 + __applet_component_compact = Struct('tag'/Int8ub, + 'size'/Int16ub, + 'count'/Int8ub, + 'applets'/Array(this.count, Struct('AID'/LV, + 'install_method_offset'/Int16ub)), + ) + + def __init__(self, filename:str): + + # In this dictionary we will keep all nested .cap file components by their file names (without .cap suffix) + # See also: Java Card Platform Virtual Machine Specification, v3.2, section 6.2.1 + self.__component = {} + + # Extract the nested .cap components from the .cap file + # See also: Java Card Platform Virtual Machine Specification, v3.2, section 6.2.1 + cap = zipfile.ZipFile(filename) + cap_namelist = cap.namelist() + for i, filename in enumerate(cap_namelist): + if filename.lower().endswith('.capx') and not filename.lower().endswith('.capx'): + #TODO: At the moment we only support the compact .cap format, add support for the extended .cap format. + raise ValueError("incompatible .cap file, extended .cap format not supported!") + + if filename.lower().endswith('.cap'): + key = filename.split('/')[-1].removesuffix('.cap') + self.__component[key] = cap.read(filename) + + # Make sure that all mandatory components are present + # See also: Java Card Platform Virtual Machine Specification, v3.2, section 6.2 + required_components = {'Header' : 'COMPONENT_Header', + 'Directory' : 'COMPONENT_Directory', + 'Import' : 'COMPONENT_Import', + 'ConstantPool' : 'COMPONENT_ConstantPool', + 'Class' : 'COMPONENT_Class', + 'Method' : 'COMPONENT_Method', + 'StaticField' : 'COMPONENT_StaticField', + 'RefLocation' : 'COMPONENT_ReferenceLocation', + 'Descriptor' : 'COMPONENT_Descriptor'} + for component in required_components: + if component not in self.__component.keys(): + raise ValueError("invalid cap file, %s missing!" % required_components[component]) + + def get_loadfile(self) -> bytes: + """Get the executeable loadfile as hexstring""" + # Concatenate all cap file components in the specified order + # see also: Java Card Platform Virtual Machine Specification, v3.2, section 6.3 + loadfile = self.__component['Header'] + loadfile += self.__component['Directory'] + loadfile += self.__component['Import'] + if 'Applet' in self.__component.keys(): + loadfile += self.__component['Applet'] + loadfile += self.__component['Class'] + loadfile += self.__component['Method'] + loadfile += self.__component['StaticField'] + if 'Export' in self.__component.keys(): + loadfile += self.__component['Export'] + loadfile += self.__component['ConstantPool'] + loadfile += self.__component['RefLocation'] + if 'Descriptor' in self.__component.keys(): + loadfile += self.__component['Descriptor'] + return loadfile + + def get_loadfile_aid(self) -> Hexstr: + """Get the loadfile AID as hexstring""" + header = self.__header_component_compact.parse(self.__component['Header']) + magic = header['magic'] or 0 + if magic != 0xDECAFFED: + raise ValueError("invalid cap file, COMPONENT_Header lacks magic number (0x%08X!=0xDECAFFED)!" % magic) + #TODO: check cap version and make sure we are compatible with it + return header['package']['AID'] + + def get_applet_aid(self, index:int = 0) -> Hexstr: + """Get the applet AID as hexstring""" + #To get the module AID, we must look into COMPONENT_Applet. Unfortunately, even though this component should + #be present in any .cap file, it is defined as an optional component. + if 'Applet' not in self.__component.keys(): + raise ValueError("can't get the AID, this cap file lacks the optional COMPONENT_Applet component!") + + applet = self.__applet_component_compact.parse(self.__component['Applet']) + + if index > applet['count']: + raise ValueError("can't get the AID for applet with index=%u, this .cap file only has %u applets!" % + (index, applet['count'])) + + return applet['applets'][index]['AID'] + diff --git a/tests/unittests/test_javacard.cap b/tests/unittests/test_javacard.cap new file mode 100644 index 0000000..f96ea24 --- /dev/null +++ b/tests/unittests/test_javacard.cap Binary files differ diff --git a/tests/unittests/test_javacard.py b/tests/unittests/test_javacard.py new file mode 100755 index 0000000..0363623 --- /dev/null +++ b/tests/unittests/test_javacard.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import os +import unittest +from pySim.javacard import * + +class TestJavacard(unittest.TestCase): + + def test_CapFile(self): + loadfile="01000fdecaffed010204000105d07002ca4402001f000f001f000c002800420018006d00320017000000a900040002002203010004002803020107a0000000620101060210a0000000090003ffffffff8910710002000107a000000062000103000c0108d07002ca44900101002006001843800301ff0007020000002f00398002008101010881000007006d000911188c00048d00012c18197b0002037b00029210240303038b000388007a02318f00053d8c00062e1b8b00077a0120188b000860037a7a02228d00092d1d10076b101a8b000a321fae006b06188c000b7a06118d000c2c1903077b000d037b000d928b000e198b000f3b7a08003200040002000203001857656c636f6d6520746f20546f6f7243616d70203230313203000a48656c6c6f2c2053544b0000000005004200100200000006810900050000020381090b0680030001000000060000010380030103800303068108000381080c0600005306810a000500000003810a1303810a1609001700021e2d0011050306040908040507090a0a06070404040b00a901000100000300030005800281018100ff080000000028ff08000002002800020000008003ff820001002f001d0000000000090020003f000d000000000701002f0042000800000000080100390046001800000000ff020053002f0018000000000010002200240028002a002fffff002f002f003100330022002f00370028003b002201300568109001b008b44323430110012005681080056810a00633b44104b431066800a10231" + cap = CapFile(os.path.dirname(os.path.abspath(__file__)) + "/test_javacard.cap") + self.assertTrue(b2h(cap.get_loadfile()) == loadfile) + self.assertTrue(cap.get_loadfile_aid() == "d07002ca44") + self.assertTrue(cap.get_applet_aid() == "d07002ca44900101") + + +if __name__ == "__main__": + unittest.main() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/39198?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I581483ccb9d8a254fcecc995fec3c811c5cf38eb Gerrit-Change-Number: 39198 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • ...
  • 150
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.