Compare commits

...

3 Commits

Author SHA1 Message Date
Andreas Eversberg 8b00969b4a Check double use of E1 interface and notify, if not defined
E1 interface may be used by one V5 link only.
Also notify user, if not created and application must be restarted when
created.
2023-01-28 21:42:56 +01:00
Andreas Eversberg 3aee692b1c Added GSMTAP IP option and fixed command line help output format 2023-01-24 18:33:04 +01:00
Andreas Eversberg 687e963fd4 Updated ph-socket interface 2023-01-24 18:07:52 +01:00
4 changed files with 78 additions and 28 deletions

View File

@ -1,4 +1,6 @@
#include <stdio.h>
#include <errno.h>
#include <osmocom/abis/e1_input.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/gsmtap_util.h>
@ -12,6 +14,7 @@
#include "v5x_le_management.h"
extern int test_sa7;
extern const char *gsmtap_ip;
extern struct v5x_instance *v5i;
@ -152,8 +155,10 @@ static void hdlc_rx_cb(struct e1inp_ts *ts, struct msgb *msg)
LOGP(DLINP, LOGL_DEBUG, "Link %d L1->L2: %s\n", v5l->id, msgb_hexdump(msg));
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
if (g_gti) {
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
}
lapv5ef_rx(v5l, msg);
}
@ -212,8 +217,10 @@ int ph_data_req_hdlc(struct msgb *msg, struct v5x_interface *v5if)
struct e1inp_ts *ts = &e1_line->ts[v5if->cc_link->c_channel[0].ts->nr - 1];
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
if (g_gti) {
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | 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);
}
@ -240,8 +247,10 @@ int ph_data_req_dl_cc(struct msgb *msg, void *cbdata)
LOGP(DLINP, LOGL_DEBUG, "Link %d L2->L1: %s\n", v5if->cc_link->id, msgb_hexdump(msg));
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
if (g_gti) {
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | 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);
}
@ -268,8 +277,10 @@ int ph_data_req_dl_prot(struct msgb *msg, void *cbdata)
LOGP(DLINP, LOGL_DEBUG, "Link %d L2->L1: %s\n", v5l->id, msgb_hexdump(msg));
/* send V5 data via gsmtap so wireshark can receive + decode it */
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
if (g_gti) {
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id | 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);
}
@ -366,9 +377,14 @@ int e1_init(void)
struct e1inp_line *e1_line;
int i, ts;
g_gti = gsmtap_source_init("224.0.0.1", GSMTAP_UDP_PORT, 0);
OSMO_ASSERT(g_gti);
gsmtap_source_add_sink(g_gti);
if (gsmtap_ip) {
g_gti = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 0);
if (!g_gti) {
fprintf(stderr, "Failed to use '%s' as IP for GSMTAP\n", gsmtap_ip);
return -EINVAL;
}
gsmtap_source_add_sink(g_gti);
}
for (i = 0; i < 256; i++) {
e1_line = e1inp_line_find(i);

View File

@ -72,6 +72,7 @@ void *tall_v5le_ctx = NULL;
struct v5x_instance *v5i = NULL;
static int daemonize = 0;
const char *gsmtap_ip = NULL;
int test_sa7 = 0;
const char *v5le_copyright =
@ -85,12 +86,13 @@ static char *config_file = "osmo-v5-le.cfg";
static void print_help()
{
printf("Some useful options:\n");
printf(" -h --help is printing this text.\n");
printf(" -c --config-file filename The config file to use.\n");
printf(" -s --disable-color\n");
printf(" -D --daemonize Fork the process into a background daemon\n");
printf(" -V --version Print the version number\n");
printf(" -7 --rest-sa7 Continously toggle Sa7 when received. (Do loop interface.)\n");
printf(" -h --help is printing this text.\n");
printf(" -c --config-file filename The config file to use.\n");
printf(" -s --disable-color Disable colors on debug output.\n");
printf(" -D --daemonize Fork the process into a background daemon\n");
printf(" -V --version Print the version number\n");
printf(" -T --gsmtap IP Send GSMTAP messages to ip. (e.g. 224.0.0.1)\n");
printf(" -7 --rest-sa7 Continously toggle Sa7 when received. (Do loop interface.)\n");
printf("\nVTY reference generation:\n");
printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
@ -135,11 +137,12 @@ static void handle_options(int argc, char **argv)
{"disable-color", 0, 0, 's'},
{"vty-ref-mode", 1, &long_option, 1},
{"vty-ref-xml", 0, &long_option, 2},
{"gsmtap", 1, 0, 'T'},
{"test-sa7", 0, 0, '7'},
{0, 0, 0, 0},
};
c = getopt_long(argc, argv, "hc:sVD7", long_options, &option_index);
c = getopt_long(argc, argv, "hc:sVDT:7", long_options, &option_index);
if (c == -1)
break;
@ -165,6 +168,9 @@ static void handle_options(int argc, char **argv)
case 'D':
daemonize = 1;
break;
case 'T':
gsmtap_ip = strdup(optarg);
break;
case '7':
test_sa7 = 1;
break;
@ -244,7 +250,8 @@ int main(int argc, char **argv)
}
rc = e1_init();
OSMO_ASSERT(rc == 0);
if (rc < 0)
return rc;
/* start telnet after reading config for vty_get_bind_addr() */
rc = telnet_init_dynif(tall_v5le_ctx, NULL,
@ -301,5 +308,7 @@ int main(int argc, char **argv)
/* destroy the universe */
v5x_instance_free(v5i);
free((char *)gsmtap_ip);
return 0;
}

View File

@ -32,14 +32,14 @@
#include "logging.h"
#include "ph_socket.h"
int ph_socket_listen_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)) what);
int ph_socket_connect_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)) what);
static int ph_socket_listen_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)) what);
static int ph_socket_connect_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)) what);
static void ph_socket_timeout_cb(void *data);
static void open_connection(ph_socket_t *s)
{
uint8_t enable = PH_CTRL_UNBLOCK;
int rc;
int rc, flags;
if (s->connect_ofd.fd > 0)
return;
@ -54,8 +54,12 @@ static void open_connection(ph_socket_t *s)
s->connect_ofd.fd = rc;
s->connect_ofd.data = s;
s->connect_ofd.when = BSC_FD_READ;
s->connect_ofd.cb = ph_socket_listen_cb;
s->connect_ofd.cb = ph_socket_connect_cb;
osmo_fd_register(&s->connect_ofd);
/* set nonblocking io, because we do multiple reads when handling read event */
flags = fcntl(s->connect_ofd.fd, F_GETFL);
flags |= O_NONBLOCK;
fcntl(s->connect_ofd.fd, F_SETFL, flags);
/* connect */
rc = connect(s->connect_ofd.fd, (struct sockaddr *)&s->sock_address, sizeof(s->sock_address));
if (rc < 0 && errno != EAGAIN) {
@ -176,12 +180,12 @@ void ph_socket_exit(ph_socket_t *s)
osmo_timer_del(&s->retry_timer);
}
int ph_socket_listen_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)) what)
static int ph_socket_listen_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)) what)
{
ph_socket_t *s = ofd->data;
struct sockaddr_un sock_address;
uint8_t enable = PH_CTRL_UNBLOCK;
int rc;
int rc, flags;
socklen_t sock_len = sizeof(sock_address);
/* see if there is an incoming connection */
@ -198,6 +202,10 @@ int ph_socket_listen_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)
s->connect_ofd.when = BSC_FD_READ;
s->connect_ofd.cb = ph_socket_connect_cb;
osmo_fd_register(&s->connect_ofd);
/* set nonblocking io, because we do multiple reads when handling read event */
flags = fcntl(s->connect_ofd.fd, F_GETFL);
flags |= O_NONBLOCK;
fcntl(s->connect_ofd.fd, F_SETFL, flags);
/* reset rx buffer */
s->rx_header_index = 0;
s->rx_data_index = 0;
@ -209,7 +217,7 @@ int ph_socket_listen_cb(struct osmo_fd *ofd, unsigned int __attribute__((unused)
return 0;
}
int ph_socket_connect_cb(struct osmo_fd *ofd, unsigned __attribute__((unused)) int what)
static int ph_socket_connect_cb(struct osmo_fd *ofd, unsigned __attribute__((unused)) int what)
{
ph_socket_t *s = ofd->data;
int rc;

View File

@ -1,5 +1,6 @@
#include <osmocom/vty/command.h>
#include <osmocom/abis/e1_input.h>
#include "v5x_internal.h"
#include "v5x_protocol.h"
@ -460,9 +461,25 @@ DEFUN(cfg_e1_line, cfg_e1_line_cmd,
"e1 line <0-255>",
"E1 configuration\n" "E1 line configuration\n" "E1 line number to use for link")
{
struct v5x_link *v5l = vty->index;
struct v5x_link *v5l = vty->index, *search_v5l;
struct e1inp_line *e1l;
int e1_line = atoi(argv[0]);
v5l->e1_line = atoi(argv[0]);
llist_for_each_entry(search_v5l, &v5l->interface->links, list) {
if (search_v5l->e1_line < 0)
continue;
if (search_v5l->e1_line == e1_line) {
vty_out(vty, "%%E1 line %d already used by another link ID %d.%s", e1_line, search_v5l->id,
VTY_NEWLINE);
return CMD_WARNING;
}
}
v5l->e1_line = e1_line;
e1l = e1inp_line_find(e1_line);
if (!e1l)
vty_out(vty, "%%E1 line %d is not created. Create it and restart application.%s", e1_line,
VTY_NEWLINE);
return CMD_SUCCESS;
}