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 2023

  • 1 participants
  • 2205 discussions
Change in libosmocore[master]: gsm_08_58: add IEI to signal HR GSM RTP format via RSL
by pespin 11 Jan '23

11 Jan '23
Attention is currently required from: dexter. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30724 ) Change subject: gsm_08_58: add IEI to signal HR GSM RTP format via RSL ...................................................................... Patch Set 2: Code-Review-1 (2 comments) Commit Message: https://gerrit.osmocom.org/c/libosmocore/+/30724/comment/f0841a1a_44089297 PS2, Line 12: packets. (In the receiving direction the BTS automatically detects the If the BTS automatically detects the RTP format upon rx, why cannot we simply detect it automatically at osmo-mgw upon rx too and be done with it? IMHO this is the incorrect way to go. I think it would make more sense to simply have BTS_FEATURE indicating the BSC the formats which the BTS can handle, so that the BSC can configure the MGW to use the proper codec to transmit data to it. On the other direction, we don't really care, the MGW should be able to cope with all of them. If at all, add a VTY config to osmo-bts to choose using one format or another to transmit. Patchset: PS2: I'd like to hear feedback from others here, since I don't think the current proposal in the patch is the way to go. I'm happy to discuss the issue further and change opinion if others think differently. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30724 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I843c8a0cbe5898311f3af3294cec7c8bc96c4eb8 Gerrit-Change-Number: 30724 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Wed, 11 Jan 2023 15:54:51 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in libosmocore[master]: gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd
by Jenkins Builder 11 Jan '23

11 Jan '23
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30936 ) Change subject: gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd ...................................................................... Patch Set 1: (1 comment) File src/gb/gprs_ns2_udp.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2610): https://gerrit.osmocom.org/c/libosmocore/+/30936/comment/047f6896_cc101d63 PS1, Line 185: static void handle_nsip_recvmsg(struct osmo_io_fd * iofd, int error, struct msgb *msg, "foo * bar" should be "foo *bar" -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30936 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Id776d2d9f35c304620f3d5b94492148dd987f5a0 Gerrit-Change-Number: 30936 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Wed, 11 Jan 2023 15:54:38 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in libosmocore[master]: libosmogsm: Add osmo_io support to ipa
by Jenkins Builder 11 Jan '23

11 Jan '23
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30935 ) Change subject: libosmogsm: Add osmo_io support to ipa ...................................................................... Patch Set 1: (1 comment) File include/osmocom/gsm/ipa.h: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2609): https://gerrit.osmocom.org/c/libosmocore/+/30935/comment/51929e76_48e373c8 PS1, Line 93: int ipa_iofd_segmentation_cb(struct msgb *msg, int read); adding a line without newline at end of file -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30935 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I0f955d5a36afe7a08d31b8ba4185260362c2bcca Gerrit-Change-Number: 30935 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Wed, 11 Jan 2023 15:54:36 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in libosmocore[master]: control_if: Use osmo_io instead of osmo_fd
by Jenkins Builder 11 Jan '23

11 Jan '23
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30937 ) Change subject: control_if: Use osmo_io instead of osmo_fd ...................................................................... Patch Set 1: (1 comment) File src/ctrl/control_if.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2607): https://gerrit.osmocom.org/c/libosmocore/+/30937/comment/4a6ecadf_b98c885d PS1, Line 488: } void function return statements are not generally useful -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30937 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I2977e6f90a2f5a74910ddf3bafb8865dda081b5a Gerrit-Change-Number: 30937 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Wed, 11 Jan 2023 15:54:31 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in libosmocore[master]: Add osmo_io with initial poll backend
by Jenkins Builder 11 Jan '23

11 Jan '23
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30934 ) Change subject: Add osmo_io with initial poll backend ...................................................................... Patch Set 1: (24 comments) File include/osmocom/core/osmo_io.h: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/a06005a2_b630304e PS1, Line 28: void (*read_cb)(struct osmo_io_fd *, int res, struct msgb *); function definition argument 'struct osmo_io_fd *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/a6882882_97172bed PS1, Line 28: void (*read_cb)(struct osmo_io_fd *, int res, struct msgb *); function definition argument 'struct msgb *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/34dae675_42dee70d PS1, Line 30: void (*write_cb)(struct osmo_io_fd *, int res, struct msgb *); function definition argument 'struct osmo_io_fd *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/4daaa2a1_cf98da01 PS1, Line 30: void (*write_cb)(struct osmo_io_fd *, int res, struct msgb *); function definition argument 'struct msgb *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/e73886e1_eeeaf2c4 PS1, Line 33: void (*sendmsg_cb)(struct osmo_io_fd *, int res, struct msgb *); function definition argument 'struct osmo_io_fd *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/90bd2fce_ca06ee12 PS1, Line 33: void (*sendmsg_cb)(struct osmo_io_fd *, int res, struct msgb *); function definition argument 'struct msgb *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/e4f803f5_59a8b316 PS1, Line 35: void (*recvmsg_cb)(struct osmo_io_fd *, int res, struct msgb *, struct osmo_sockaddr *); function definition argument 'struct osmo_io_fd *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/dfd5ab6a_2d4e0773 PS1, Line 35: void (*recvmsg_cb)(struct osmo_io_fd *, int res, struct msgb *, struct osmo_sockaddr *); function definition argument 'struct msgb *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/cc035462_005f9fb0 PS1, Line 35: void (*recvmsg_cb)(struct osmo_io_fd *, int res, struct msgb *, struct osmo_sockaddr *); function definition argument 'struct osmo_sockaddr *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/d82689fd_e87daffe PS1, Line 38: int (*segmentation_cb)(struct msgb *, int data_len); function definition argument 'struct msgb *' should also have an identifier name Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/36042dd0_0772c714 PS1, Line 41: void osmo_io_init(); Bad function definition - void osmo_io_init() should probably be void osmo_io_init(void) Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/a936804e_ce32a8bc PS1, Line 52: const struct osmo_sockaddr *dest); code indent should use tabs where possible Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/d3eef3f3_083169f7 PS1, Line 52: const struct osmo_sockaddr *dest); please, no spaces at the start of a line File src/osmo_io.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/99590406_b38a3166 PS1, Line 53: void osmo_iofd_init() Bad function definition - void osmo_iofd_init() should probably be void osmo_iofd_init(void) Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/a6271d9a_bb9bafff PS1, Line 226: memcpy(msgb_data(msg_pending), msgb_data(msg)+ len, pending_len); need consistent spacing around '+' (ctx:VxW) (or typedef missing in osmo-ci/lint/checkpatch/typedefs_osmo.txt?) Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/bd552a2b_5ca6e479 PS1, Line 237: void iofd_handle_segmented_read(struct osmo_io_fd *iofd, struct msgb *msg, int rc) { open brace '{' following function definitions go on the next line Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/faf5728a_cd6bc557 PS1, Line 278: LOGP(DLIO, LOGL_ERROR, "iofd(%s) enqueueing message failed (%i). Rejecting msgb\n", iofd->name, rc); Use %d instead of %i Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/0d760490_668e3395 PS1, Line 314: LOGP(DLIO, LOGL_ERROR, "iofd(%s) enqueueing message failed (%i). Rejecting msgb\n", iofd->name, rc); Use %d instead of %i Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/ea9a86bb_c1b53d3e PS1, Line 401: void osmo_iofd_close(struct osmo_io_fd* iofd) "foo* bar" should be "foo *bar" Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/68e2e3e3_910b42c8 PS1, Line 440: } adding a line without newline at end of file File src/osmo_io_internal.h: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/00a26127_b6684372 PS1, Line 53: /*! size of msgb to allocte (excluding headroom) */ 'allocte' may be misspelled - perhaps 'allocate'? File src/osmo_io_poll.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/ff326b3c_14e933ee PS1, Line 86: } void function return statements are not generally useful Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/f5e5ec12_2b561022 PS1, Line 146: } void function return statements are not generally useful Robot Comment from checkpatch (run ID jenkins-gerrit-lint-2606): https://gerrit.osmocom.org/c/libosmocore/+/30934/comment/bcdbf899_b439231c PS1, Line 219: }; adding a line without newline at end of file -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30934 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I50d73cf550d6ce8154bf827bf47408131cf5b0a0 Gerrit-Change-Number: 30934 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-CC: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Wed, 11 Jan 2023 15:50:21 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in libosmocore[master]: ctrl_if: Fix test
by daniel 11 Jan '23

11 Jan '23
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/30938 ) Change subject: ctrl_if: Fix test ...................................................................... ctrl_if: Fix test Change-Id: If35aa2340f69f9ac6178f07b7a4bbe392217a1f5 --- M src/Makefile.am M tests/Makefile.am M tests/ctrl/ctrl_test.c 3 files changed, 31 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/30938/1 diff --git a/src/Makefile.am b/src/Makefile.am index ba0926e..1065dd4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,6 +67,7 @@ conv_acc_neon_impl.h \ crcXXgen.c.tpl \ stat_item_internal.h \ + osmo_io_internal.h \ $(NULL) libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined diff --git a/tests/Makefile.am b/tests/Makefile.am index 8c7e40a..0c12b25 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -114,6 +114,7 @@ abis_abis_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la ctrl_ctrl_test_SOURCES = ctrl/ctrl_test.c +ctrl_ctrl_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src ctrl_ctrl_test_LDADD = $(LDADD) \ $(top_builddir)/src/ctrl/libosmoctrl.la \ $(top_builddir)/src/gsm/libosmogsm.la \ diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c index 1d4d4d7..074dfd7 100644 --- a/tests/ctrl/ctrl_test.c +++ b/tests/ctrl/ctrl_test.c @@ -4,6 +4,7 @@ #include <string.h> #include <stdbool.h> +#include <osmocom/core/osmo_io.h> #include <osmocom/core/utils.h> #include <osmocom/ctrl/control_cmd.h> #include <osmocom/core/logging.h> @@ -11,6 +12,9 @@ #include <osmocom/core/application.h> #include <osmocom/gsm/protocol/ipaccess.h> #include <osmocom/ctrl/control_if.h> +#include <osmo_io_internal.h> + +extern struct iofd_backend_ops g_iofd_ops; static void check_type(enum ctrl_type c) { @@ -109,13 +113,14 @@ msg = msgb_from_string(t->cmd_str); ctrl_handle_msg(ctrl, ccon, msg); - if (llist_empty(&ccon->write_queue.msg_queue)) { + if (ccon->iofd->tx_queue.current_length == 0) { if (t->reply_str) { printf("Got no reply, but expected \"%s\"\n", osmo_escape_str(t->reply_str, -1)); OSMO_ASSERT(!t->reply_str); } } else { - struct msgb *sent_msg = msgb_dequeue(&ccon->write_queue.msg_queue); + struct iofd_msghdr *sent_msghdr = iofd_txqueue_dequeue(ccon->iofd); + struct msgb *sent_msg = sent_msghdr->msg; OSMO_ASSERT(sent_msg); char *strbuf = talloc_size(sent_msg, msgb_l2len(sent_msg) + 1); @@ -126,8 +131,8 @@ OSMO_ASSERT(t->reply_str); OSMO_ASSERT(!strcmp(t->reply_str, strbuf)); msgb_free(sent_msg); + iofd_msghdr_free(sent_msghdr); } - osmo_wqueue_clear(&ccon->write_queue); msgb_free(msg); @@ -343,10 +348,11 @@ ctrl = ctrl_handle_alloc2(ctx, NULL, NULL, 0); ccon = talloc_zero(ctx, struct ctrl_connection); - osmo_wqueue_init(&ccon->write_queue, 1); - - for (i = 0; i < ARRAY_SIZE(test_messages_list); i++) + for (i = 0; i < ARRAY_SIZE(test_messages_list); i++) { + ccon->iofd = osmo_iofd_setup(ccon, 0, 0, -1, "iofd test", OSMO_IO_FD_MODE_READ_WRITE, NULL, ccon, 0); assert_test(ctrl, ccon, &test_messages_list[i]); + osmo_iofd_close(ccon->iofd); + } talloc_free(ccon); talloc_free(ctrl); @@ -405,8 +411,7 @@ ctrl = ctrl_handle_alloc2(ctx, NULL, NULL, 0); ccon = talloc_zero(ctx, struct ctrl_connection); INIT_LLIST_HEAD(&ccon->def_cmds); - - osmo_wqueue_init(&ccon->write_queue, 1); + ccon->iofd = osmo_iofd_setup(ccon, 0, 0, -1, "iofd test", OSMO_IO_FD_MODE_READ_WRITE, NULL, ccon, 0); ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_test_defer); @@ -431,7 +436,9 @@ ctrl_test_defer_cb(test_defer_cd); /* simulate sending of the reply */ - osmo_wqueue_clear(&ccon->write_queue); + struct iofd_msghdr *msghdr = iofd_txqueue_dequeue(ccon->iofd); + msgb_free(msghdr->msg); + iofd_msghdr_free(msghdr); /* And now the deferred cmd should be cleaned up completely. */ if (talloc_total_size(ctx) != ctx_size_before_defer) { @@ -460,8 +467,21 @@ .num_cat = ARRAY_SIZE(test_categories), }; + +static void iofd_dummy_x_y(struct osmo_io_fd *iofd) +{ +} + int main(int argc, char **argv) { + /* Override the iofd backend functions */ + g_iofd_ops.setup = NULL; + g_iofd_ops.close = NULL; + g_iofd_ops.write_enable = iofd_dummy_x_y; + g_iofd_ops.write_disable = iofd_dummy_x_y; + g_iofd_ops.read_enable = iofd_dummy_x_y; + g_iofd_ops.read_disable = iofd_dummy_x_y; + ctx = talloc_named_const(NULL, 1, "ctrl_test"); osmo_init_logging2(ctx, &info); msgb_talloc_ctx_init(ctx, 0); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30938 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If35aa2340f69f9ac6178f07b7a4bbe392217a1f5 Gerrit-Change-Number: 30938 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmocore[master]: control_if: Use osmo_io instead of osmo_fd
by daniel 11 Jan '23

11 Jan '23
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/30937 ) Change subject: control_if: Use osmo_io instead of osmo_fd ...................................................................... control_if: Use osmo_io instead of osmo_fd * uses the ipa support for osmo_io introduced to libosmogsm Change-Id: I2977e6f90a2f5a74910ddf3bafb8865dda081b5a --- M include/osmocom/ctrl/control_cmd.h M include/osmocom/ctrl/control_if.h M src/ctrl/control_cmd.c M src/ctrl/control_if.c 4 files changed, 96 insertions(+), 89 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/30937/1 diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h index 276a7de..0b0f6c7 100644 --- a/include/osmocom/ctrl/control_cmd.h +++ b/include/osmocom/ctrl/control_cmd.h @@ -45,11 +45,8 @@ struct ctrl_connection { struct llist_head list_entry; - /*! The queue for sending data back */ - struct osmo_wqueue write_queue; - - /*! Buffer for partial input data */ - struct msgb *pending_msg; + /*! The io_fd of the connection */ + struct osmo_io_fd *iofd; /*! Callback if the connection was closed */ void (*closed_cb)(struct ctrl_connection *conn); @@ -59,6 +56,9 @@ /*! Pending deferred command responses for this connection */ struct llist_head def_cmds; + + /*! User data pointer to be passed through*/ + void *data; }; struct ctrl_cmd_def; @@ -123,7 +123,7 @@ int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *data); int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd); -int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd); +int ctrl_cmd_send(struct osmo_io_fd *iofd, struct ctrl_cmd *cmd); int ctrl_cmd_send_to_all(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd); struct ctrl_cmd *ctrl_cmd_parse3(void *ctx, struct msgb *msg, bool *parse_failed); struct ctrl_cmd *ctrl_cmd_parse2(void *ctx, struct msgb *msg); diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h index 98cd100..f35a3e0 100644 --- a/include/osmocom/ctrl/control_if.h +++ b/include/osmocom/ctrl/control_if.h @@ -28,7 +28,7 @@ }; -int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd); +int ctrl_cmd_send(struct osmo_io_fd *iofd, struct ctrl_cmd *cmd); int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value); struct ctrl_handle *ctrl_handle_alloc(void *ctx, void *data, ctrl_cmd_lookup lookup); struct ctrl_handle *ctrl_handle_alloc2(void *ctx, void *data, @@ -47,7 +47,7 @@ uint16_t port, ctrl_cmd_lookup lookup, unsigned int node_count) OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE; -struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data); +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data, int fd); int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data); struct ctrl_cmd *ctrl_cmd_exec_from_string(struct ctrl_handle *ch, const char *cmdstr); diff --git a/src/ctrl/control_cmd.c b/src/ctrl/control_cmd.c index b069ca4..e18f091 100644 --- a/src/ctrl/control_cmd.c +++ b/src/ctrl/control_cmd.c @@ -637,7 +637,7 @@ cmd->type = CTRL_TYPE_ERROR; } - rc = ctrl_cmd_send(&cmd->ccon->write_queue, cmd); + rc = ctrl_cmd_send(cmd->ccon->iofd, cmd); talloc_free(cmd); llist_del(&cd->list); diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index 9438f7e..b1f6756 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -23,6 +23,7 @@ */ #include "config.h" +#include <osmocom/core/osmo_io.h> #include <errno.h> #include <inttypes.h> @@ -106,7 +107,7 @@ llist_for_each_entry(ccon, &ctrl->ccon_list, list_entry) { if (ccon == cmd->ccon) continue; - if (ctrl_cmd_send(&ccon->write_queue, cmd)) + if (ctrl_cmd_send(ccon->iofd, cmd)) ret++; } return ret; @@ -116,7 +117,7 @@ * \param[inout] queue write queue to which encoded \a cmd shall be appended * \param[in] cmd decoded command representation * \returns 0 in case of success; negative on error */ -int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd) +int ctrl_cmd_send(struct osmo_io_fd *iofd, struct ctrl_cmd *cmd) { int ret; struct msgb *msg; @@ -130,7 +131,7 @@ ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_CTRL); ipa_prepend_header(msg, IPAC_PROTO_OSMO); - ret = osmo_wqueue_enqueue(queue, msg); + ret = osmo_iofd_write_msgb(iofd, msg); if (ret != 0) { LOGP(DLCTRL, LOGL_ERROR, "Failed to enqueue the command.\n"); msgb_free(msg); @@ -178,18 +179,17 @@ static void control_close_conn(struct ctrl_connection *ccon) { struct ctrl_cmd_def *cd, *cd2; - char *name = osmo_sock_get_name(ccon, ccon->write_queue.bfd.fd); + struct osmo_io_fd *iofd = ccon->iofd; + char *name = osmo_sock_get_name(ccon, osmo_iofd_get_fd(iofd)); LOGP(DLCTRL, LOGL_INFO, "close()d CTRL connection %s\n", name); talloc_free(name); - osmo_wqueue_clear(&ccon->write_queue); - close(ccon->write_queue.bfd.fd); - osmo_fd_unregister(&ccon->write_queue.bfd); + osmo_iofd_close(iofd); + llist_del(&ccon->list_entry); if (ccon->closed_cb) ccon->closed_cb(ccon); - msgb_free(ccon->pending_msg); /* clean up deferred commands */ llist_for_each_entry_safe(cd, cd2, &ccon->def_cmds, list) { @@ -339,41 +339,41 @@ } -static int handle_control_read(struct osmo_fd * bfd) -{ - int ret; - struct osmo_wqueue *queue; - struct ctrl_connection *ccon; - struct msgb *msg = NULL; - struct ctrl_handle *ctrl = bfd->data; - - queue = container_of(bfd, struct osmo_wqueue, bfd); - ccon = container_of(queue, struct ctrl_connection, write_queue); - - ret = ipa_msg_recv_buffered(bfd->fd, &msg, &ccon->pending_msg); - if (ret == 0) { - /* msg was already discarded. */ - goto close_fd; - } else if (ret == -EAGAIN) { - /* received part of a message, it is stored in ccon->pending_msg and there's - * nothing left to do now. */ - return 0; - } else if (ret < 0) { - LOGP(DLCTRL, LOGL_ERROR, "Failed to parse ip access message: %d (%s)\n", ret, strerror(-ret)); - return 0; - } - - ret = ctrl_handle_msg(ctrl, ccon, msg); - msgb_free(msg); - if (ret) - goto close_fd; - - return 0; - -close_fd: - control_close_conn(ccon); - return -EBADF; -} +//static int handle_control_read(struct osmo_fd * bfd) +//{ +// int ret; +// struct osmo_wqueue *queue; +// struct ctrl_connection *ccon; +// struct msgb *msg = NULL; +// struct ctrl_handle *ctrl = bfd->data; +// +// queue = container_of(bfd, struct osmo_wqueue, bfd); +// ccon = container_of(queue, struct ctrl_connection, write_queue); +// +// ret = ipa_msg_recv_buffered(bfd->fd, &msg, &ccon->pending_msg); +// if (ret == 0) { +// /* msg was already discarded. */ +// goto close_fd; +// } else if (ret == -EAGAIN) { +// /* received part of a message, it is stored in ccon->pending_msg and there's +// * nothing left to do now. */ +// return 0; +// } else if (ret < 0) { +// LOGP(DLCTRL, LOGL_ERROR, "Failed to parse ip access message: %d (%s)\n", ret, strerror(-ret)); +// return 0; +// } +// +// ret = ctrl_handle_msg(ctrl, ccon, msg); +// msgb_free(msg); +// if (ret) +// goto close_fd; +// +// return 0; +// +//close_fd: +// control_close_conn(ccon); +// return -EBADF; +//} /*! Handle a received CTRL command contained in a \ref msgb. * \param[in] ctrl CTRL interface handle @@ -382,6 +382,7 @@ * \returns 0 on success; negative on error */ int ctrl_handle_msg(struct ctrl_handle *ctrl, struct ctrl_connection *ccon, struct msgb *msg) { + struct osmo_io_fd *iofd = ccon->iofd; struct ctrl_cmd *cmd; bool parse_failed; struct ipaccess_head *iph; @@ -397,13 +398,13 @@ uint8_t msg_type = *(msg->l2h); switch (msg_type) { case IPAC_MSGT_PING: - if (ipa_ccm_send_pong(ccon->write_queue.bfd.fd) < 0) + if (ipa_ccm_send_pong_iofd(iofd) < 0) LOGP(DLINP, LOGL_ERROR, "Cannot send PONG message. Reason: %s\n", strerror(errno)); break; case IPAC_MSGT_PONG: break; case IPAC_MSGT_ID_ACK: - if (ipa_ccm_send_id_ack(ccon->write_queue.bfd.fd) < 0) + if (ipa_ccm_send_id_ack_iofd(iofd) < 0) LOGP(DLINP, LOGL_ERROR, "Cannot send ID_ACK message. Reason: %s\n", strerror(errno)); break; default: @@ -464,60 +465,74 @@ send_reply: /* There is a reply or error that should be reported back to the sender. */ - ctrl_cmd_send(&ccon->write_queue, cmd); + ctrl_cmd_send(iofd, cmd); just_free: talloc_free(cmd); return 0; } -static int control_write_cb(struct osmo_fd *bfd, struct msgb *msg) +void ctrl_ioops_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) { - struct osmo_wqueue *queue; - struct ctrl_connection *ccon; - int rc; + int rc = -EINVAL; + struct ctrl_connection *ccon = osmo_iofd_get_data(iofd); + struct ctrl_handle *ctrl = ccon->data; - queue = container_of(bfd, struct osmo_wqueue, bfd); - ccon = container_of(queue, struct ctrl_connection, write_queue); + if (res > 0) + rc = ctrl_handle_msg(ctrl, ccon, msg); - rc = write(bfd->fd, msg->data, msg->len); - if (rc == 0) { + msgb_free(msg); + if (rc) control_close_conn(ccon); - return -EBADF; - } - if (rc < 0) { - LOGP(DLCTRL, LOGL_ERROR, "Failed to write message to the CTRL connection.\n"); - return 0; - } - if (rc < msg->len) { - msgb_pull(msg, rc); - return -EAGAIN; + + return; +} + +void ctrl_ioops_write_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ + struct ctrl_connection *ccon = osmo_iofd_get_data(iofd); + + if (res == 0) { + control_close_conn(ccon); + return; } - return 0; + if (res < 0) { + LOGP(DLCTRL, LOGL_ERROR, "Failed to write message to the CTRL connection.\n"); + return; + } } +int ipa_iofd_segmentation_cb(struct msgb *msg, int read); + +static struct osmo_io_ops ctrl_ioops = { + .read_cb = ctrl_ioops_read_cb, + .write_cb = ctrl_ioops_write_cb, + .segmentation_cb = ipa_iofd_segmentation_cb, +}; + /*! Allocate CTRL connection * \param[in] ctx Context from which talloc should allocate it * \param[in] data caller's private data parameter which should assigned to write queue's file descriptor data parameter. * \return Allocated CTRL connection structure or NULL in case of errors */ -struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data) +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data, int fd) { struct ctrl_connection *ccon = talloc_zero(ctx, struct ctrl_connection); if (!ccon) return NULL; - osmo_wqueue_init(&ccon->write_queue, 100); /* Error handling here? */ INIT_LLIST_HEAD(&ccon->cmds); INIT_LLIST_HEAD(&ccon->def_cmds); - ccon->write_queue.bfd.data = data; - ccon->write_queue.bfd.fd = -1; - ccon->write_queue.write_cb = control_write_cb; - ccon->write_queue.read_cb = handle_control_read; + ccon->data = data; + ccon->iofd = osmo_iofd_setup(ctx, 1024, 0, fd, NULL, OSMO_IO_FD_MODE_READ_WRITE, &ctrl_ioops, ccon, 0); + if (!ccon->iofd) { + talloc_free(ccon); + return NULL; + } return ccon; } @@ -549,7 +564,7 @@ } #endif ctrl = listen_bfd->data; - ccon = osmo_ctrl_conn_alloc(listen_bfd->data, ctrl); + ccon = osmo_ctrl_conn_alloc(listen_bfd->data, ctrl, fd); if (!ccon) { LOGP(DLCTRL, LOGL_ERROR, "Failed to allocate.\n"); close(fd); @@ -559,15 +574,7 @@ name = osmo_sock_get_name(ccon, fd); LOGP(DLCTRL, LOGL_INFO, "accept()ed new CTRL connection from %s\n", name); - ccon->write_queue.bfd.fd = fd; - ccon->write_queue.bfd.when = OSMO_FD_READ; - - ret = osmo_fd_register(&ccon->write_queue.bfd); - if (ret < 0) { - LOGP(DLCTRL, LOGL_ERROR, "Could not register FD.\n"); - close(ccon->write_queue.bfd.fd); - talloc_free(ccon); - } + osmo_iofd_read_enable(ccon->iofd); llist_add(&ccon->list_entry, &ctrl->ccon_list); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30937 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I2977e6f90a2f5a74910ddf3bafb8865dda081b5a Gerrit-Change-Number: 30937 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmocore[master]: osmo-stat-dummy: Link to libosmogsm
by daniel 11 Jan '23

11 Jan '23
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/30939 ) Change subject: osmo-stat-dummy: Link to libosmogsm ...................................................................... osmo-stat-dummy: Link to libosmogsm Change-Id: I4ea20087ceeb276e4f0fbb7ce50da6a61446beb5 --- M utils/osmo-stat-dummy/Makefile.am 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/30939/1 diff --git a/utils/osmo-stat-dummy/Makefile.am b/utils/osmo-stat-dummy/Makefile.am index d28b982..5cad4b3 100644 --- a/utils/osmo-stat-dummy/Makefile.am +++ b/utils/osmo-stat-dummy/Makefile.am @@ -4,7 +4,8 @@ osmo_stat_dummy_LDADD = $(LDADD) $(TALLOC_LIBS) \ $(top_builddir)/src/vty/libosmovty.la \ $(top_builddir)/src/ctrl/libosmoctrl.la \ + $(top_builddir)/src/gsm/libosmogsm.la \ $(top_builddir)/src/libosmocore.la -osmo_stat_dummy_CFLAGS = -Wall $(TALLOC_CFLAGS) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOCTRL_CFLAGS) +osmo_stat_dummy_CFLAGS = -Wall $(TALLOC_CFLAGS) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOGSM_CFLAGS) osmo_stat_dummy_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include endif -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30939 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4ea20087ceeb276e4f0fbb7ce50da6a61446beb5 Gerrit-Change-Number: 30939 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmocore[master]: gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd
by daniel 11 Jan '23

11 Jan '23
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/30936 ) Change subject: gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd ...................................................................... gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd Change-Id: Id776d2d9f35c304620f3d5b94492148dd987f5a0 --- M src/gb/gprs_ns2_udp.c 1 file changed, 31 insertions(+), 72 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/36/30936/1 diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index 4816021..faeece4 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -35,6 +35,7 @@ #include "common_vty.h" #include "gprs_ns2_internal.h" +#include "osmocom/core/osmo_io.h" static void free_bind(struct gprs_ns2_vc_bind *bind); @@ -46,7 +47,7 @@ }; struct priv_bind { - struct osmo_fd fd; + struct osmo_io_fd *fd; struct osmo_sockaddr addr; int dscp; uint8_t priority; @@ -68,7 +69,8 @@ priv = bind->priv; - osmo_fd_close(&priv->fd); + if (priv->fd) + osmo_iofd_close(priv->fd); talloc_free(priv); } @@ -148,10 +150,7 @@ int rc; struct priv_bind *priv = bind->priv; - rc = sendto(priv->fd.fd, msg->data, msg->len, 0, - &dest->u.sa, sizeof(*dest)); - - msgb_free(msg); + rc = osmo_iofd_sendto_msgb(priv->fd, msg, dest); return rc; } @@ -171,39 +170,6 @@ return rc; } -/* Read a single NS-over-IP message */ -static struct msgb *read_nsip_msg(struct osmo_fd *bfd, int *error, struct osmo_sockaddr *saddr, - const struct gprs_ns2_vc_bind *bind) -{ - struct msgb *msg = ns2_msgb_alloc(); - int ret = 0; - socklen_t saddr_len = sizeof(*saddr); - - if (!msg) { - *error = -ENOMEM; - return NULL; - } - - ret = recvfrom(bfd->fd, msg->data, NS_ALLOC_SIZE - NS_ALLOC_HEADROOM, 0, - &saddr->u.sa, &saddr_len); - if (ret < 0) { - LOGBIND(bind, LOGL_ERROR, "recv error %s during NSIP recvfrom %s\n", - strerror(errno), osmo_sock_get_name2(bfd->fd)); - msgb_free(msg); - *error = ret; - return NULL; - } else if (ret == 0) { - msgb_free(msg); - *error = ret; - return NULL; - } - - msg->l2h = msg->data; - msgb_put(msg, ret); - - return msg; -} - static struct priv_vc *ns2_driver_alloc_vc(struct gprs_ns2_vc_bind *bind, struct gprs_ns2_vc *nsvc, struct osmo_sockaddr *remote) { struct priv_vc *priv = talloc_zero(bind, struct priv_vc); @@ -216,24 +182,22 @@ return priv; } -static int handle_nsip_read(struct osmo_fd *bfd) +static void handle_nsip_recvmsg(struct osmo_io_fd * iofd, int error, struct msgb *msg, + struct osmo_sockaddr *saddr) { int rc = 0; - int error = 0; - struct gprs_ns2_vc_bind *bind = bfd->data; - struct osmo_sockaddr saddr; + struct gprs_ns2_vc_bind *bind = osmo_iofd_get_data(iofd); struct gprs_ns2_vc *nsvc; - struct msgb *msg = read_nsip_msg(bfd, &error, &saddr, bind); + struct msgb *reject; - if (!msg) - return -EINVAL; + msg->l2h = msgb_data(msg); /* check if a vc is available */ - nsvc = gprs_ns2_nsvc_by_sockaddr_bind(bind, &saddr); + nsvc = gprs_ns2_nsvc_by_sockaddr_bind(bind, saddr); if (!nsvc) { /* VC not found */ - rc = ns2_create_vc(bind, msg, &saddr, "newconnection", &reject, &nsvc); + rc = ns2_create_vc(bind, msg, saddr, "newconnection", &reject, &nsvc); switch (rc) { case NS2_CS_FOUND: break; @@ -243,10 +207,10 @@ goto out; case NS2_CS_REJECTED: /* nsip_sendmsg will free reject */ - rc = nsip_sendmsg(bind, reject, &saddr); + rc = nsip_sendmsg(bind, reject, saddr); goto out; case NS2_CS_CREATED: - ns2_driver_alloc_vc(bind, nsvc, &saddr); + ns2_driver_alloc_vc(bind, nsvc, saddr); /* only start the fsm for non SNS. SNS will take care of its own */ if (nsvc->nse->dialect != GPRS_NS2_DIALECT_SNS) ns2_vc_fsm_start(nsvc); @@ -254,29 +218,15 @@ } } - return ns2_recv_vc(nsvc, msg); + ns2_recv_vc(nsvc, msg); + return; out: msgb_free(msg); - return rc; } -static int handle_nsip_write(struct osmo_fd *bfd) +static void handle_nsip_sendmsg(struct osmo_io_fd *iofd, int res, struct msgb *msg) { - /* FIXME: actually send the data here instead of nsip_sendmsg() */ - return -EIO; -} - -static int nsip_fd_cb(struct osmo_fd *bfd, unsigned int what) -{ - int rc = 0; - - if (what & OSMO_FD_READ) - rc = handle_nsip_read(bfd); - if (what & OSMO_FD_WRITE) - rc = handle_nsip_write(bfd); - - return rc; } /*! Find NS bind for a given socket address @@ -321,6 +271,11 @@ struct priv_bind *priv; int rc; + struct osmo_io_ops ioops = { + .sendmsg_cb = &handle_nsip_sendmsg, + .recvmsg_cb = &handle_nsip_recvmsg, + }; + if (local->u.sa.sa_family != AF_INET && local->u.sa.sa_family != AF_INET6) return -EINVAL; @@ -353,12 +308,11 @@ gprs_ns2_free_bind(bind); return -ENOMEM; } - priv->fd.cb = nsip_fd_cb; - priv->fd.data = bind; + priv->addr = *local; priv->dscp = dscp; - rc = osmo_sock_init_osa_ofd(&priv->fd, SOCK_DGRAM, IPPROTO_UDP, + rc = osmo_sock_init_osa(SOCK_DGRAM, IPPROTO_UDP, local, NULL, OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(priv->dscp)); if (rc < 0) { @@ -366,6 +320,11 @@ return rc; } + priv->fd = osmo_iofd_setup(bind, 4096, 128, rc, "NS bind", + OSMO_IO_FD_MODE_RECVFROM_SENDTO, &ioops, bind, 0); + + osmo_iofd_read_enable(priv->fd); + /* IPv4: max fragmented payload can be (13 bit) * 8 byte => 65535. * IPv6: max payload can be 65535 (RFC 2460). * UDP header = 8 byte */ @@ -521,7 +480,7 @@ if (dscp != priv->dscp) { priv->dscp = dscp; - rc = osmo_sock_set_dscp(priv->fd.fd, dscp); + rc = osmo_sock_set_dscp(osmo_iofd_get_fd(priv->fd), dscp); if (rc < 0) { LOGBIND(bind, LOGL_ERROR, "Failed to set the DSCP to %u with ret(%d) errno(%d)\n", dscp, rc, errno); @@ -543,7 +502,7 @@ if (priority != priv->priority) { priv->priority = priority; - rc = osmo_sock_set_priority(priv->fd.fd, priority); + rc = osmo_sock_set_priority(osmo_iofd_get_fd(priv->fd), priority); if (rc < 0) { LOGBIND(bind, LOGL_ERROR, "Failed to set the priority to %u with ret(%d) errno(%d)\n", priority, rc, errno); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30936 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Id776d2d9f35c304620f3d5b94492148dd987f5a0 Gerrit-Change-Number: 30936 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmocore[master]: libosmogsm: Add osmo_io support to ipa
by daniel 11 Jan '23

11 Jan '23
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/30935 ) Change subject: libosmogsm: Add osmo_io support to ipa ...................................................................... libosmogsm: Add osmo_io support to ipa * ipa_iofd_segmentation_cb() to segment ipa-style messages * add ipa_ccm_send_*iofd() that work with an osmo_io_fd Change-Id: I0f955d5a36afe7a08d31b8ba4185260362c2bcca --- M TODO-RELEASE M include/osmocom/gsm/ipa.h M src/gsm/ipa.c M src/gsm/libosmogsm.map 4 files changed, 146 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/35/30935/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index ef629c7..2308756 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -10,3 +10,4 @@ libosmocore new API osmo_sockaddr_is_any() libosmocore ABI breakage OSMO_NUM_DLIB change affecting internal_cat[] libosmocore new API osmo_io_* +libosmogsm new API ipa_ccm_*_iofd, ipa_iofd_segmentation_cb diff --git a/include/osmocom/gsm/ipa.h b/include/osmocom/gsm/ipa.h index 851b58e..c3fb615 100644 --- a/include/osmocom/gsm/ipa.h +++ b/include/osmocom/gsm/ipa.h @@ -5,6 +5,7 @@ #include <stdint.h> #include <osmocom/core/msgb.h> +#include <osmocom/core/osmo_io.h> #include <osmocom/gsm/tlv.h> struct osmo_fd; @@ -56,12 +57,15 @@ /* Send an IPA CCM PONG via the given FD */ int ipa_ccm_send_pong(int fd); +int ipa_ccm_send_pong_iofd(struct osmo_io_fd *iofd); /* Send an IPA CCM ID_ACK via the given FD */ int ipa_ccm_send_id_ack(int fd); +int ipa_ccm_send_id_ack_iofd(struct osmo_io_fd *iofd); /* Send an IPA CCM ID_REQ via the given FD */ int ipa_ccm_send_id_req(int fd); +int ipa_ccm_send_id_req_iofd(struct osmo_io_fd *iofd); /* Common handling of IPA CCM, BSC side */ int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); @@ -69,6 +73,12 @@ /* Common handling of IPA CCM, BTS side */ int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd); +/* Common handling of IPA CCM, BSC side */ +int ipa_ccm_rcvmsg_base_iofd(struct msgb *msg, struct osmo_io_fd *iofd); + +/* Common handling of IPA CCM, BTS side */ +int ipa_ccm_rcvmsg_bts_base_iofd(struct msgb *msg, struct osmo_io_fd *iofd); + /* prepend (push) an ipaccess_head_ext to the msgb */ void ipa_prepend_header_ext(struct msgb *msg, int proto); @@ -79,3 +89,5 @@ int ipa_msg_recv(int fd, struct msgb **rmsg); int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg); + +int ipa_iofd_segmentation_cb(struct msgb *msg, int read); \ No newline at end of file diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c index 447e8e3..c48b5cc 100644 --- a/src/gsm/ipa.c +++ b/src/gsm/ipa.c @@ -39,6 +39,7 @@ #include <osmocom/core/logging.h> #include <osmocom/core/macaddr.h> #include <osmocom/core/select.h> +#include <osmocom/core/osmo_io.h> #include <osmocom/gsm/tlv.h> #include <osmocom/gsm/protocol/ipaccess.h> @@ -468,6 +469,36 @@ return ipa_send(fd, ipa_id_req_msg, sizeof(ipa_id_req_msg)); } +int ipa_ccm_send_pong_iofd(struct osmo_io_fd *iofd) +{ + uint8_t *data; + struct msgb *msg = msgb_alloc(sizeof(ipa_pong_msg), "IPA PONG"); + data = msgb_put(msg, sizeof(ipa_pong_msg)); + memcpy(data, ipa_pong_msg, sizeof(ipa_pong_msg)); + + return osmo_iofd_write_msgb(iofd, msg); +} + +int ipa_ccm_send_id_ack_iofd(struct osmo_io_fd *iofd) +{ + uint8_t *data; + struct msgb *msg = msgb_alloc(sizeof(ipa_id_ack_msg), "IPA ID ACK"); + data = msgb_put(msg, sizeof(ipa_id_ack_msg)); + memcpy(data, ipa_id_ack_msg, sizeof(ipa_id_ack_msg)); + + return osmo_iofd_write_msgb(iofd, msg); +} + +int ipa_ccm_send_id_req_iofd(struct osmo_io_fd *iofd) +{ + uint8_t *data; + struct msgb *msg = msgb_alloc(sizeof(ipa_id_req_msg), "IPA ID REQ"); + data = msgb_put(msg, sizeof(ipa_id_req_msg)); + memcpy(data, ipa_id_req_msg, sizeof(ipa_id_req_msg)); + + return osmo_iofd_write_msgb(iofd, msg); +} + /* base handling of the ip.access protocol */ int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd) { @@ -507,6 +538,44 @@ } /* base handling of the ip.access protocol */ +int ipa_ccm_rcvmsg_base_iofd(struct msgb *msg, struct osmo_io_fd *iofd) +{ + uint8_t msg_type = *(msg->l2h); + int ret; + + switch (msg_type) { + case IPAC_MSGT_PING: + ret = ipa_ccm_send_pong_iofd(iofd); + if (ret < 0) { + LOGP(DLINP, LOGL_ERROR, "Cannot send PING " + "message. Reason: %s\n", strerror(errno)); + break; + } + ret = 1; + break; + case IPAC_MSGT_PONG: + DEBUGP(DLMI, "PONG!\n"); + ret = 1; + break; + case IPAC_MSGT_ID_ACK: + DEBUGP(DLMI, "ID_ACK? -> ACK!\n"); + ret = ipa_ccm_send_id_ack_iofd(iofd); + if (ret < 0) { + LOGP(DLINP, LOGL_ERROR, "Cannot send ID_ACK " + "message. Reason: %s\n", strerror(errno)); + break; + } + ret = 1; + break; + default: + /* This is not an IPA PING, PONG or ID_ACK message */ + ret = 0; + break; + } + return ret; +} + +/* base handling of the ip.access protocol */ int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd) { uint8_t msg_type = *(msg->l2h); @@ -530,6 +599,30 @@ return ret; } +/* base handling of the ip.access protocol */ +int ipa_ccm_rcvmsg_bts_base_iofd(struct msgb *msg, struct osmo_io_fd *iofd) +{ + uint8_t msg_type = *(msg->l2h); + int ret = 0; + + switch (msg_type) { + case IPAC_MSGT_PING: + ret = ipa_ccm_send_pong_iofd(iofd); + if (ret < 0) { + LOGP(DLINP, LOGL_ERROR, "Cannot send PONG " + "message. Reason: %s\n", strerror(errno)); + } + break; + case IPAC_MSGT_PONG: + DEBUGP(DLMI, "PONG!\n"); + break; + case IPAC_MSGT_ID_ACK: + DEBUGP(DLMI, "ID_ACK\n"); + break; + } + return ret; +} + void ipa_prepend_header_ext(struct msgb *msg, int proto) { @@ -718,4 +811,38 @@ return nmsg; } +void ipa_iofd_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ + +} + +void ipa_iofd_write_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ + +} + +int ipa_iofd_segmentation_cb(struct msgb *msg, int read) +{ + struct ipaccess_head *hh; + int len; + if (read < sizeof(*hh)) + return sizeof(*hh); + + msg->l1h = msg->data; + hh = (struct ipaccess_head *) msg->data; + + /* then read the length as specified in header */ + len = osmo_ntohs(hh->len); + + if (len < 0 || IPA_ALLOC_SIZE < len + sizeof(*hh)) { + LOGP(DLINP, LOGL_ERROR, "bad message length of %d bytes, " + "received %d bytes\n", len, msg->len); + return -EIO; + } + + msg->l2h = hh->data; + + return sizeof(*hh) + len; +} + /*! @} */ diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 7b5cd94..8498ffa 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -618,10 +618,15 @@ gan_pdisc_vals; ipa_ccm_rcvmsg_base; +ipa_ccm_rcvmsg_base_iofd; ipa_ccm_rcvmsg_bts_base; +ipa_ccm_rcvmsg_bts_base_iofd; ipa_ccm_send_id_ack; +ipa_ccm_send_id_ack_iofd; ipa_ccm_send_id_req; +ipa_ccm_send_id_req_iofd; ipa_ccm_send_pong; +ipa_ccm_send_pong_iofd; ipa_ccm_tlv_to_unitdata; ipa_ccm_idtag_name; ipa_ccm_idtag_parse; @@ -637,6 +642,7 @@ ipa_prepend_header; ipa_prepend_header_ext; ipa_send; +ipa_iofd_segmentation_cb; osmo_apn_qualify; osmo_apn_qualify_buf; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30935 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I0f955d5a36afe7a08d31b8ba4185260362c2bcca Gerrit-Change-Number: 30935 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • ...
  • 221
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.