From c01c48a0aaa5a6ef9ca9ad29cc416ce7d46264d3 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 27 Nov 2022 14:26:52 +0100 Subject: [PATCH] Hacking on main.c --- main.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index b7b5d8b..e7f503d 100644 --- a/main.c +++ b/main.c @@ -49,6 +49,10 @@ #include #include "logging.h" +#include "v5x_internal.h" +#include "v5x_protocol.h" +#include "v51_le_ctrl.h" +#include "lapv5.h" #define _GNU_SOURCE #include @@ -59,6 +63,7 @@ #endif void *tall_v5le_ctx = NULL; +struct v5x_instance *v5i = NULL; struct v5le_config { }; @@ -86,11 +91,33 @@ static const struct e1inp_line_ops v5le_e1_line_ops = { .sign_link = v5le_rx_sign, }; +#include "v5x_protocol.h" +/* data L1 -> L2 */ static void hdlc_rx_cb(struct e1inp_ts *ts, struct msgb *msg) { - LOGP(DLINP, LOGL_NOTICE, "HDLC Rx: %s\n", msgb_hexdump(msg)); +#warning HACKING + struct v5x_interface *v5if = (struct v5x_interface *)v5i->interfaces.next; + struct v5x_user_port *v5up; + uint16_t dladdr; - msgb_free(msg); + LOGP(DLINP, LOGL_NOTICE, "L1->L2: %s\n", msgb_hexdump(msg)); + + lapv5ef_rx(v5if->primary_link, msg); +} + +/* l2 -> L1 */ +int ph_data_req(struct msgb *msg, void *cbdata) +{ + msg->l2h = msgb_push(msg, 2); + msg->l2h[0] = msg->l2h[2] & 0xfd; + msg->l2h[1] = msg->l2h[3]; + LOGP(DLINP, LOGL_NOTICE, "L2->L1: %s\n", msgb_hexdump(msg)); + +#warning hacking + struct e1inp_line *e1_line = e1inp_line_find(0); + struct e1inp_ts *ts = &e1_line->ts[16-1]; + + return e1inp_ts_send_hdlc(ts, msg); } static int e1_init(void) @@ -284,6 +311,9 @@ int main(int argc, char **argv) rate_ctr_init(tall_v5le_ctx); osmo_stats_init(tall_v5le_ctx); + // FIXME: + osmo_fsm_register(&v51_ctrl_fsm); + rc = vty_read_config_file(config_file, NULL); if (rc < 0) return rc; @@ -297,6 +327,23 @@ int main(int argc, char **argv) if (rc < 0) return rc; + /* create v5x instance */ + v5i = v5x_instance_alloc(tall_v5le_ctx); + if (!v5i) + return -ENOMEM; + + // FIXME: move this to VTY code + /* create v5x interface */ + struct v5x_interface *v5if; + struct v5x_user_port *v5up; + uint32_t interface_id = 1; + uint8_t interface_variant = 1; + v5if = v5x_interface_alloc(v5i, V5X_DIALECT_V51, interface_id, interface_variant, ph_data_req); + if (!v5if) + return -ENOMEM; + v5up = v5x_user_port_create(v5if, 1001, 1); + if (!v5up) + return -ENOMEM; #if 0 cfg->ctrl = v5le_ctrl_interface_setup(cfg, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_MGW); if (!cfg->ctrl) {