Hacking on main

This commit is contained in:
Andreas Eversberg 2022-12-16 16:34:00 +01:00
parent 0325fbedc1
commit f5e54dfa77
1 changed files with 91 additions and 37 deletions

128
main.c
View File

@ -55,6 +55,9 @@
#include "v5x_protocol.h"
#include "v51_le_ctrl.h"
#include "v52_le_user_port_fsm.h"
#include "v5x_le_pstn_fsm.h"
#include "v5x_l2_mgmt.h"
#include "v51_le_provisioning.h"
#include "lapv5.h"
#define _GNU_SOURCE
@ -106,58 +109,103 @@ static void hdlc_rx_cb(struct e1inp_ts *ts, struct msgb *msg)
{
#warning HACKING
struct v5x_interface *v5if = (struct v5x_interface *)v5i->interfaces.next;
struct v5x_user_port *v5up;
uint16_t dladdr;
LOGP(DLINP, LOGL_NOTICE, "L1->L2: %s\n", msgb_hexdump(msg));
LOGP(DLINP, LOGL_DEBUG, "L1->L2: %s\n", msgb_hexdump(msg));
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, 0, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
lapv5ef_rx(v5if->primary_link, msg);
}
static void raw_rx_cb(struct e1inp_ts *ts, struct msgb *msg)
{
#warning HACKING
struct v5x_interface *v5if = (struct v5x_interface *)v5i->interfaces.next;
struct v5x_user_port *v5up = v5if->links[0].ts[ts->num].v5up;
/* not used by any user port */
if (!v5up) {
msgb_free(msg);
return;
}
if (v5up->ts_nr[0] == ts->num && v5up->ts_activated[0])
ph_socket_tx_msg(&v5up->ph_socket, 1, PH_PRIM_DATA_IND, msg->data, msg->len);
if (v5up->ts_nr[1] == ts->num && v5up->ts_activated[1])
ph_socket_tx_msg(&v5up->ph_socket, 2, PH_PRIM_DATA_IND, msg->data, msg->len);
msgb_free(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));
LOGP(DLINP, LOGL_DEBUG, "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];
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, 0, ts->num, GSMTAP_E1T1_V5EF,
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
return e1inp_ts_send_hdlc(ts, msg);
}
#warning hacking
int ph_data_req_hack(struct msgb *msg)
{
LOGP(DLINP, LOGL_DEBUG, "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];
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
return e1inp_ts_send_hdlc(ts, msg);
}
#warning hacking
int ph_data_req_raw(struct msgb *msg, int ts_nr)
{
#warning hacking
struct e1inp_line *e1_line = e1inp_line_find(0);
struct e1inp_ts *ts = &e1_line->ts[ts_nr-1];
return e1inp_ts_send_raw(ts, msg);
}
static int e1_init(void)
{
int line_nr = 1;
int line_nr = 1, ts;
struct e1inp_line *e1_line;
int rc;
e1_line = e1inp_line_find(0);
OSMO_ASSERT(e1_line);
e1inp_line_bind_ops(e1_line, &v5le_e1_line_ops);
struct e1inp_ts *sign_ts = &e1_line->ts[16-1];
//e1inp_ts_config_sign(sign_ts, e1_line);
//e1inp_sign_link_create(sign_ts, E1INP_SIGN_NONE, NULL, 115/*TEI*/, 0/*SAPI*/);
e1inp_ts_config_hdlc(sign_ts, e1_line, hdlc_rx_cb);
for (ts = 1; ts <= 31; ts++) {
struct e1inp_ts *e1_ts = &e1_line->ts[ts-1];
if (ts == 16) { // FIXME: make this depending on c_channel
//e1inp_ts_config_sign(e1_ts, e1_line);
//e1inp_sign_link_create(e1_ts, E1INP_SIGN_NONE, NULL, 115/*TEI*/, 0/*SAPI*/);
e1inp_ts_config_hdlc(e1_ts, e1_line, hdlc_rx_cb);
} else
e1inp_ts_config_raw(e1_ts, e1_line, raw_rx_cb);
}
return e1inp_line_update(e1_line);
}
static struct v5le_config *g_cfg;
static int daemonize = 0;
@ -318,7 +366,7 @@ int main(int argc, char **argv)
logging_vty_add_cmds();
osmo_talloc_vty_add_cmds();
osmo_stats_vty_add_cmds();
//mgcp_vty_init();
v5x_vty_init();
ctrl_vty_init(g_cfg);
e1inp_vty_init();
osmo_cpu_sched_vty_init(tall_v5le_ctx);
@ -328,16 +376,37 @@ 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);
osmo_fsm_register(&v51_ctrl_le_i_port_fsm);
osmo_fsm_register(&v51_ctrl_le_p_port_fsm);
/* global inits of protocols */
v51_ctrl_init();
v51_port_ctrl_init();
v51_pstn_init();
v51_provisioning_init();
v51_mgmt_init();
/* 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, V5X_USER_TYPE_ISDN, 1, 2);
// v5up = v5x_user_port_create(v5if, 1002, V5X_USER_TYPE_PSTN, 3, 0);
// if (!v5up)
// return -ENOMEM;
rc = vty_read_config_file(config_file, NULL);
if (rc < 0)
return rc;
g_gti = gsmtap_source_init("localhost", GSMTAP_UDP_PORT, 0);
g_gti = gsmtap_source_init("224.0.0.1", GSMTAP_UDP_PORT, 0);
OSMO_ASSERT(g_gti);
gsmtap_source_add_sink(g_gti);
@ -350,23 +419,6 @@ 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, V5X_USER_TYPE_ISDN);
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) {
@ -405,6 +457,8 @@ int main(int argc, char **argv)
/* initialisation */
srand(time(NULL));
if (daemonize) {
rc = osmo_daemonize();
if (rc < 0) {