VIRT-PHY: Cleanup dirs, makefile, dependencies and formatting code.
Change-Id: Ibd68a03bcc439c262ba513782936c6b62937eaaa
This commit is contained in:
parent
fa2ce6396f
commit
2e265c897a
|
@ -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
|
||||
|
||||
|
|
|
@ -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])])
|
||||
|
|
|
@ -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,
|
|
@ -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);
|
||||
|
|
@ -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 {
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
|
@ -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);
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue