diff options
18 files changed, 85 insertions, 107 deletions
diff --git a/src/Makefile b/src/Makefile index e83175c4..f5e2128e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -47,8 +47,7 @@ host/osmocon/osmocon: host/osmocon/Makefile make -C host/osmocon .PHONY: virtphy -virtphy: host/virt_phy/Makefile - cd host/virt_phy && make +virtphy: host/virt_phy/virtphy host/virt_phy/configure: host/virt_phy/configure.ac cd host/virt_phy && autoreconf -i @@ -56,6 +55,9 @@ host/virt_phy/configure: host/virt_phy/configure.ac host/virt_phy/Makefile: host/virt_phy/configure cd host/virt_phy && ./configure $(HOST_CONFARGS) +host/virt_phy/virtphy: host/virt_phy/Makefile + make -C host/virt_phy + .PHONY: gsmmap gsmmap: host/gsmmap/gsmmap diff --git a/src/host/virt_phy/configure.ac b/src/host/virt_phy/configure.ac index bcdbf91d..860082e7 100644 --- a/src/host/virt_phy/configure.ac +++ b/src/host/virt_phy/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script AC_INIT([virtphy], 0.0.0) AM_CONFIG_HEADER([config.h]) -AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects]) dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/src/host/virt_phy/src/gsmtapl1_if.h b/src/host/virt_phy/include/virtphy/gsmtapl1_if.h index 6311e07b..c5115608 100644 --- a/src/host/virt_phy/src/gsmtapl1_if.h +++ b/src/host/virt_phy/include/virtphy/gsmtapl1_if.h @@ -2,10 +2,9 @@ #include <osmocom/core/msgb.h> #include <osmocom/core/gsmtap.h> - -#include "l1ctl_sock.h" -#include "virtual_um.h" -#include "virt_l1_model.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> +#include <virtphy/virt_l1_model.h> void gsmtapl1_init(struct l1_model_ms *model); void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui, diff --git a/src/host/virt_phy/src/l1ctl_sap.h b/src/host/virt_phy/include/virtphy/l1ctl_sap.h index 9472013d..902eb177 100644 --- a/src/host/virt_phy/src/l1ctl_sap.h +++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h @@ -3,10 +3,9 @@ #include <stdint.h> #include <osmocom/core/msgb.h> #include <l1ctl_proto.h> - -#include "l1ctl_sock.h" -#include "virtual_um.h" -#include "virt_l1_model.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> +#include <virtphy/virt_l1_model.h> /* following sizes are used for message allocation */ /* size of layer 3 header */ @@ -22,7 +21,8 @@ void l1ctl_sap_init(struct l1_model_ms *model); void l1ctl_sap_tx_to_l23_inst(struct l1ctl_sock_inst *lsi, struct msgb *msg); void l1ctl_sap_tx_to_l23(struct msgb *msg); -void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_inst *lsi, struct msgb *msg); +void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_inst *lsi, + struct msgb *msg); void l1ctl_sap_rx_from_l23(struct msgb *msg); void l1ctl_sap_handler(struct msgb *msg); diff --git a/src/host/virt_phy/src/l1ctl_sock.h b/src/host/virt_phy/include/virtphy/l1ctl_sock.h index ef9799c2..ef9799c2 100644 --- a/src/host/virt_phy/src/l1ctl_sock.h +++ b/src/host/virt_phy/include/virtphy/l1ctl_sock.h diff --git a/src/host/virt_phy/src/logging.h b/src/host/virt_phy/include/virtphy/logging.h index 87f12f77..87f12f77 100644 --- a/src/host/virt_phy/src/logging.h +++ b/src/host/virt_phy/include/virtphy/logging.h diff --git a/src/host/virt_phy/src/osmo_mcast_sock.h b/src/host/virt_phy/include/virtphy/osmo_mcast_sock.h index f318ffea..f318ffea 100644 --- a/src/host/virt_phy/src/osmo_mcast_sock.h +++ b/src/host/virt_phy/include/virtphy/osmo_mcast_sock.h diff --git a/src/host/virt_phy/src/virt_l1_model.h b/src/host/virt_phy/include/virtphy/virt_l1_model.h index 38d9efe5..561025e0 100644 --- a/src/host/virt_phy/src/virt_l1_model.h +++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h @@ -1,7 +1,7 @@ #pragma once -#include "l1ctl_sock.h" -#include "virtual_um.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> #define L1S_NUM_NEIGH_CELL 6 #define A5_KEY_LEN 8 @@ -16,17 +16,17 @@ struct l1_model_ms { /* structure representing L1 sync information about a cell */ struct l1_cell_info { /* on which ARFCN (+band) is the cell? */ - uint16_t arfcn; + uint16_t arfcn; /* what's the BSIC of the cell (from SCH burst decoding) */ - uint8_t bsic; + uint8_t bsic; /* Combined or non-combined CCCH */ - uint8_t ccch_mode; /* enum ccch_mode */ + uint8_t ccch_mode; /* enum ccch_mode */ /* whats the delta of the cells current GSM frame number * compared to our current local frame number */ - int32_t fn_offset; + int32_t fn_offset; /* how much does the TPU need adjustment (delta) to synchronize * with the cells burst */ - uint32_t time_alignment; + uint32_t time_alignment; }; struct crypto_info_ms { diff --git a/src/host/virt_phy/src/virtual_um.h b/src/host/virt_phy/include/virtphy/virtual_um.h index eafb9940..5c883deb 100644 --- a/src/host/virt_phy/src/virtual_um.h +++ b/src/host/virt_phy/include/virtphy/virtual_um.h @@ -16,8 +16,10 @@ struct virt_um_inst { void (*recv_cb)(struct virt_um_inst *vui, struct msgb *msg); }; -struct virt_um_inst *virt_um_init(void *ctx, const char *tx_mcast_group, uint16_t tx_mcast_port, const char *rx_mcast_group, uint16_t rx_mcast_port, - void (*recv_cb)(struct virt_um_inst *vui, struct msgb *msg)); +struct virt_um_inst *virt_um_init( + void *ctx, char *tx_mcast_group, uint16_t tx_mcast_port, + char *rx_mcast_group, uint16_t rx_mcast_port, + void (*recv_cb)(struct virt_um_inst *vui, struct msgb *msg)); void virt_um_destroy(struct virt_um_inst *vui); diff --git a/src/host/virt_phy/src/Makefile.am b/src/host/virt_phy/src/Makefile.am index 2dac297c..85085092 100644 --- a/src/host/virt_phy/src/Makefile.am +++ b/src/host/virt_phy/src/Makefile.am @@ -1,18 +1,8 @@ -OSMOCOM_DIR = /home/basti/Osmocom -OSMO_BB_DIR = $(OSMOCOM_DIR)/osmocom-bb -OSMO_BTS_DIR = $(OSMOCOM_DIR)/osmo-bts -OPENBSC_DIR = $(OSMOCOM_DIR)/openbsc - AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OSMO_BB_DIR)/include -I$(OSMO_BTS_DIR)/include -I$(OPENBSC_DIR)/openbsc/include -I$(OSMO_BB_DIR)/src/host/layer23/include -# TODO: somehow this include path causes errors, thus the needed files are copied into $(top_srcdir)/include. Would be better to include directly from $(OSMO_BB_DIR)/src/target/firmware/include to avoid redundancy. -# -I$(OSMO_BB_DIR)/src/target/firmware/include - -# disable optimization and enable debugging -CFLAGS = -g -O0 +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_srcdir)/../layer23/include sbin_PROGRAMS = virtphy -virtphy_SOURCES = virtphy.c l1ctl_sock.c l1ctl_sap.c gsmtapl1_if.c logging.c virt_l1_model.c virtual_um.c osmo_mcast_sock.c +virtphy_SOURCES = virtphy.c l1ctl_sock.c l1ctl_sap.c gsmtapl1_if.c logging.c virt_l1_model.c shared/virtual_um.c shared/osmo_mcast_sock.c virtphy_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) # debug output diff --git a/src/host/virt_phy/src/gsmtapl1_if.c b/src/host/virt_phy/src/gsmtapl1_if.c index d46bb2fb..338f99c6 100644 --- a/src/host/virt_phy/src/gsmtapl1_if.c +++ b/src/host/virt_phy/src/gsmtapl1_if.c @@ -29,13 +29,12 @@ #include <stdlib.h> #include <string.h> #include <l1ctl_proto.h> - -#include "virtual_um.h" -#include "l1ctl_sock.h" -#include "virt_l1_model.h" -#include "l1ctl_sap.h" -#include "gsmtapl1_if.h" -#include "logging.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> +#include <virtphy/virt_l1_model.h> +#include <virtphy/l1ctl_sap.h> +#include <virtphy/gsmtapl1_if.h> +#include <virtphy/logging.h> static struct l1_model_ms *l1_model_ms = NULL; @@ -162,6 +161,8 @@ void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui, struct gsmtap_hdr *gh = msgb_l1(msg); struct msgb *l1ctl_msg = NULL; struct l1ctl_info_dl *l1dl; + struct l1ctl_traffic_ind * l1ti; + struct l1ctl_data_ind * l1di; uint32_t fn = ntohl(gh->frame_number); // frame number of the rcv msg uint16_t arfcn = ntohs(gh->arfcn); // arfcn of the cell we currently camp on uint8_t gsmtap_chantype = gh->sub_type; // gsmtap channel type @@ -188,7 +189,6 @@ void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui, switch (gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH & 0xff) { case GSMTAP_CHANNEL_TCH_H: case GSMTAP_CHANNEL_TCH_F: - struct l1ctl_traffic_ind * l1ti; l1ctl_msg = l1ctl_msgb_alloc(L1CTL_TRAFFIC_IND); l1dl = (struct l1ctl_info_dl *)msgb_put(l1ctl_msg, sizeof(struct l1ctl_info_dl)); @@ -214,7 +214,6 @@ void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui, case GSMTAP_CHANNEL_AGCH: case GSMTAP_CHANNEL_PCH: case GSMTAP_CHANNEL_BCCH: - struct l1ctl_data_ind * l1di; l1ctl_msg = l1ctl_msgb_alloc(L1CTL_DATA_IND); l1dl = (struct l1ctl_info_dl *)msgb_put(l1ctl_msg, sizeof(struct l1ctl_info_dl)); diff --git a/src/host/virt_phy/src/l1ctl_sap.c b/src/host/virt_phy/src/l1ctl_sap.c index 91f1d10d..3be6b9d2 100644 --- a/src/host/virt_phy/src/l1ctl_sap.c +++ b/src/host/virt_phy/src/l1ctl_sap.c @@ -11,13 +11,12 @@ #include <l1ctl_proto.h> #include <netinet/in.h> #include <string.h> - -#include "virtual_um.h" -#include "l1ctl_sock.h" -#include "virt_l1_model.h" -#include "l1ctl_sap.h" -#include "logging.h" -#include "gsmtapl1_if.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> +#include <virtphy/virt_l1_model.h> +#include <virtphy/l1ctl_sap.h> +#include <virtphy/gsmtapl1_if.h> +#include <virtphy/logging.h> static struct l1_model_ms *l1_model_ms = NULL; diff --git a/src/host/virt_phy/src/l1ctl_sock.c b/src/host/virt_phy/src/l1ctl_sock.c index b507369f..5e0ba43f 100644 --- a/src/host/virt_phy/src/l1ctl_sock.c +++ b/src/host/virt_phy/src/l1ctl_sock.c @@ -44,9 +44,9 @@ #include <l1ctl_proto.h> -#include "l1ctl_sock.h" -#include "virtual_um.h" -#include "logging.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> +#include <virtphy/logging.h> #define L1CTL_SOCK_MSGB_SIZE 256 @@ -87,8 +87,8 @@ static int l1ctl_sock_data_cb(struct osmo_fd *ofd, unsigned int what) lsi->recv_cb(lsi, msg); return 0; } -ERR: - perror("Failed to receive msg from l2. Connection will be closed.\n"); + ERR: perror( + "Failed to receive msg from l2. Connection will be closed.\n"); l1ctl_sock_disconnect(lsi); } return 0; diff --git a/src/host/virt_phy/src/logging.c b/src/host/virt_phy/src/logging.c index a017a521..1cfb40fb 100644 --- a/src/host/virt_phy/src/logging.c +++ b/src/host/virt_phy/src/logging.c @@ -20,11 +20,9 @@ * */ - #include <osmocom/core/utils.h> #include <osmocom/core/application.h> - -#include "logging.h" +#include <virtphy/logging.h> const char* l1ctlPrimNames[] = { "_L1CTL_NONE", @@ -57,41 +55,33 @@ const char* l1ctlPrimNames[] = { "L1CTL_NEIGH_PM_IND", "L1CTL_TRAFFIC_REQ", "L1CTL_TRAFFIC_CONF", - "L1CTL_TRAFFIC_IND" -}; + "L1CTL_TRAFFIC_IND"}; -static const struct log_info_cat default_categories[] = { - [DL1C] = { - .name = "DL1C", - .description = "Layer 1 Control", - .color = "\033[1;31m", - .enabled = 1, - .loglevel = LOGL_DEBUG, - }, - [DVIRPHY] = { - .name = "DVIRPHY", - .description = "Virtual Layer 1 Interface", - .color = "\033[1;31m", - .enabled = 1, - .loglevel = LOGL_DEBUG, - } -}; +static const struct log_info_cat default_categories[] = {[DL1C] = { + .name = "DL1C", + .description = "Layer 1 Control", + .color = "\033[1;31m", + .enabled = 1, + .loglevel = LOGL_DEBUG, }, [DVIRPHY] = { + .name = "DVIRPHY", + .description = "Virtual Layer 1 Interface", + .color = "\033[1;31m", + .enabled = 1, + .loglevel = LOGL_DEBUG, }}; -const struct log_info ms_log_info = { - .filter_fn = NULL, - .cat = default_categories, - .num_cat = ARRAY_SIZE(default_categories), -}; +const struct log_info ms_log_info = {.filter_fn = NULL, .cat = + default_categories, .num_cat = ARRAY_SIZE(default_categories), }; /** * Initialize the logging system for the virtual physical layer. */ -int ms_log_init(char *cat_mask) { +int ms_log_init(char *cat_mask) +{ struct log_target *stderr_target; log_init(&ms_log_info, NULL); stderr_target = log_target_create_stderr(); - if(!stderr) { + if (!stderr) { return -1; } log_add_target(stderr_target); @@ -101,7 +91,7 @@ int ms_log_init(char *cat_mask) { log_set_use_color(stderr_target, 0); log_set_print_timestamp(stderr_target, 1); log_set_print_category(stderr_target, 1); - if(cat_mask) { + if (cat_mask) { log_parse_category_mask(stderr_target, cat_mask); } return 0; diff --git a/src/host/virt_phy/src/osmo_mcast_sock.c b/src/host/virt_phy/src/shared/osmo_mcast_sock.c index c1777347..acc6bcb1 100644 --- a/src/host/virt_phy/src/osmo_mcast_sock.c +++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c @@ -8,8 +8,7 @@ #include <string.h> #include <talloc.h> #include <unistd.h> - -#include "osmo_mcast_sock.h" +#include <virtphy/osmo_mcast_sock.h> struct mcast_server_sock *mcast_server_sock_setup(void *ctx, char* tx_mcast_group, diff --git a/src/host/virt_phy/src/virtual_um.c b/src/host/virt_phy/src/shared/virtual_um.c index e2e86e44..9415bfbb 100644 --- a/src/host/virt_phy/src/virtual_um.c +++ b/src/host/virt_phy/src/shared/virtual_um.c @@ -25,9 +25,9 @@ #include <osmocom/core/gsmtap.h> #include <osmocom/core/msgb.h> #include <osmocom/core/talloc.h> - -#include "virtual_um.h" -#include "osmo_mcast_sock.h" +#include <virtphy/osmo_mcast_sock.h> +#include <virtphy/virtual_um.h> +#include <unistd.h> /** * Virtual UM interface file descriptor callback. @@ -68,8 +68,8 @@ static int virt_um_fd_cb(struct osmo_fd *ofd, unsigned int what) } struct virt_um_inst *virt_um_init( - void *ctx, const char *tx_mcast_group, uint16_t tx_mcast_port, - const char *rx_mcast_group, uint16_t rx_mcast_port, + void *ctx, char *tx_mcast_group, uint16_t tx_mcast_port, + char *rx_mcast_group, uint16_t rx_mcast_port, void (*recv_cb)(struct virt_um_inst *vui, struct msgb *msg)) { struct virt_um_inst *vui = talloc_zero(ctx, struct virt_um_inst); diff --git a/src/host/virt_phy/src/virt_l1_model.c b/src/host/virt_phy/src/virt_l1_model.c index f2e16905..1b1d0dfd 100644 --- a/src/host/virt_phy/src/virt_l1_model.c +++ b/src/host/virt_phy/src/virt_l1_model.c @@ -1,14 +1,16 @@ -#include "virt_l1_model.h" - -struct l1_model_ms* l1_model_ms_init(void *ctx) { +#include <virtphy/virt_l1_model.h> +#include <talloc.h> +struct l1_model_ms* l1_model_ms_init(void *ctx) +{ struct l1_model_ms *model = talloc_zero(ctx, struct l1_model_ms); model->state = talloc_zero(ctx, struct l1_state_ms); - return model; + } -void l1_model_ms_destroy(struct l1_model_ms *model) { +void l1_model_ms_destroy(struct l1_model_ms *model) +{ virt_um_destroy(model->vui); l1ctl_sock_destroy(model->lsi); talloc_free(model->state); diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c index b2a2d4fa..5007146b 100644 --- a/src/host/virt_phy/src/virtphy.c +++ b/src/host/virt_phy/src/virtphy.c @@ -1,19 +1,16 @@ /* osmocom includes */ -#include "logging.h" #include <osmocom/core/msgb.h> #include <osmocom/core/select.h> -#include <osmo-bts/scheduler.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <virt_l1_model.h> - -#include "virtual_um.h" -#include "l1ctl_sock.h" -#include "virt_l1_model.h" -#include "gsmtapl1_if.h" -#include "l1ctl_sap.h" +#include <virtphy/virtual_um.h> +#include <virtphy/l1ctl_sock.h> +#include <virtphy/virt_l1_model.h> +#include <virtphy/l1ctl_sap.h> +#include <virtphy/gsmtapl1_if.h> +#include <virtphy/logging.h> int main(void) { @@ -29,9 +26,8 @@ int main(void) // TODO: make this configurable model->vui = virt_um_init(NULL, DEFAULT_BTS_MCAST_GROUP, - DEFAULT_BTS_MCAST_PORT, DEFAULT_MS_MCAST_GROUP, - DEFAULT_MS_MCAST_PORT, - gsmtapl1_rx_from_virt_um_inst_cb); + DEFAULT_BTS_MCAST_PORT, DEFAULT_MS_MCAST_GROUP, + DEFAULT_MS_MCAST_PORT, gsmtapl1_rx_from_virt_um_inst_cb); model->lsi = l1ctl_sock_init(NULL, l1ctl_sap_rx_from_l23_inst_cb, NULL); gsmtapl1_init(model); |