aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Stumpf <sebastian.stumpf87@googlemail.com>2017-02-06 14:27:41 +0100
committerSebastian Stumpf <sebastian.stumpf87@googlemail.com>2017-02-06 14:27:41 +0100
commit5928334909b0b1700af634285a8cbd089b3d6798 (patch)
treefc3d637aa4bff8977a1230b467ded32a0adf464b
parentf0f95a9b8a662641faa7bc51e2465f7cf7575c47 (diff)
VIRT-PHY: Cleanup dirs, makefile, dependencies and formatting code.
-rw-r--r--src/osmo-bts-virtual/Makefile.am9
-rw-r--r--src/osmo-bts-virtual/include/virtphy/l1_if.h (renamed from src/osmo-bts-virtual/l1_if.h)0
-rw-r--r--src/osmo-bts-virtual/include/virtphy/osmo_mcast_sock.h (renamed from src/osmo-bts-virtual/osmo_mcast_sock.h)0
-rw-r--r--src/osmo-bts-virtual/include/virtphy/virtual_um.h (renamed from src/osmo-bts-virtual/virtual_um.h)4
-rw-r--r--src/osmo-bts-virtual/l1_if.c28
-rw-r--r--src/osmo-bts-virtual/scheduler_virtbts.c5
-rw-r--r--src/osmo-bts-virtual/shared/osmo_mcast_sock.c (renamed from src/osmo-bts-virtual/osmo_mcast_sock.c)3
-rw-r--r--src/osmo-bts-virtual/shared/virtual_um.c (renamed from src/osmo-bts-virtual/virtual_um.c)10
-rw-r--r--tests/virtsock/Makefile.am6
-rw-r--r--tests/virtsock/virt_um_bts.c3
-rw-r--r--tests/virtsock/virt_um_ms.c4
-rw-r--r--tests/virtsock/virtsock_client_mcast.c5
-rw-r--r--tests/virtsock/virtsock_client_unix_domain.c2
-rw-r--r--tests/virtsock/virtsock_server_mcast_bidir.c4
-rw-r--r--tests/virtsock/virtsock_server_unix_domain.c3
15 files changed, 43 insertions, 43 deletions
diff --git a/src/osmo-bts-virtual/Makefile.am b/src/osmo-bts-virtual/Makefile.am
index a8742c06..ac22d8e8 100644
--- a/src/osmo-bts-virtual/Makefile.am
+++ b/src/osmo-bts-virtual/Makefile.am
@@ -1,13 +1,8 @@
AM_CFLAGS = -Wall -fno-strict-aliasing $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBGPS_CFLAGS) $(ORTP_CFLAGS)
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR)
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) -Iinclude
COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) $(ORTP_LIBS)
-# disable optimization and enable debugging
-CFLAGS = -g -O0
-
-EXTRA_DIST = virtual_um.h
-
bin_PROGRAMS = osmo-bts-virtual
-osmo_bts_virtual_SOURCES = main.c bts_model.c virtualbts_vty.c scheduler_virtbts.c l1_if.c virtual_um.c osmo_mcast_sock.c
+osmo_bts_virtual_SOURCES = main.c bts_model.c virtualbts_vty.c scheduler_virtbts.c l1_if.c shared/virtual_um.c shared/osmo_mcast_sock.c
osmo_bts_virtual_LDADD = $(top_builddir)/src/common/libbts.a $(top_builddir)/src/common/libl1sched.a $(COMMON_LDADD)
diff --git a/src/osmo-bts-virtual/l1_if.h b/src/osmo-bts-virtual/include/virtphy/l1_if.h
index b11602f6..b11602f6 100644
--- a/src/osmo-bts-virtual/l1_if.h
+++ b/src/osmo-bts-virtual/include/virtphy/l1_if.h
diff --git a/src/osmo-bts-virtual/osmo_mcast_sock.h b/src/osmo-bts-virtual/include/virtphy/osmo_mcast_sock.h
index f318ffea..f318ffea 100644
--- a/src/osmo-bts-virtual/osmo_mcast_sock.h
+++ b/src/osmo-bts-virtual/include/virtphy/osmo_mcast_sock.h
diff --git a/src/osmo-bts-virtual/virtual_um.h b/src/osmo-bts-virtual/include/virtphy/virtual_um.h
index 6b782af4..5c883deb 100644
--- a/src/osmo-bts-virtual/virtual_um.h
+++ b/src/osmo-bts-virtual/include/virtphy/virtual_um.h
@@ -17,8 +17,8 @@ struct virt_um_inst {
};
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));
void virt_um_destroy(struct virt_um_inst *vui);
diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index 2de50822..7f52f777 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -40,8 +40,7 @@
#include <osmo-bts/amr.h>
#include <osmo-bts/abis.h>
#include <osmo-bts/scheduler.h>
-
-#include "virtual_um.h"
+#include <virtphy/virtual_um.h>
extern int vbts_sched_start(struct gsm_bts *bts);
@@ -84,7 +83,8 @@ extern int vbts_sched_start(struct gsm_bts *bts);
*
* TODO: move this to a library used by both ms and bts virt um
*/
-void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, uint8_t *link_id)
+void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
+ uint8_t *link_id)
{
// switch case with removed acch flag
switch (gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH & 0xff) {
@@ -115,7 +115,8 @@ void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, uint8_t
break;
}
- *link_id = gsmtap_chantype & GSMTAP_CHANNEL_ACCH ? LID_SACCH : LID_DEDIC;
+ *link_id = gsmtap_chantype & GSMTAP_CHANNEL_ACCH ?
+ LID_SACCH : LID_DEDIC;
}
@@ -159,8 +160,7 @@ static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg)
// see 04.08 - 3.3.1.3.1: the IMMEDIATE_ASSIGNMENT coming back from the network has to be
// sent with the same ra reference as in the CHANNEL_REQUEST that was received
osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_PH_RACH,
- PRIM_OP_INDICATION,
- msg);
+ PRIM_OP_INDICATION, msg);
l1sap.u.rach_ind.chan_nr = chan_nr;
// TODO: why is ra her 16bits long instead of 8 like in the reference 04.08 - 9.1.8 - Channel request?
@@ -178,12 +178,12 @@ static void virt_um_rcv_cb(struct virt_um_inst *vui, struct msgb *msg)
// TODO: check if separate handling is needed
case GSMTAP_CHANNEL_TCH_H:
// check if associated control flag is set
- if(gsmtap_chantype & GSMTAP_CHANNEL_ACCH) {
+ if (gsmtap_chantype & GSMTAP_CHANNEL_ACCH) {
// TODO: check if handling is different for ACCH
// TODO: does FACCH need special handling?
}
osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_PH_DATA,
- PRIM_OP_INDICATION, msg);
+ PRIM_OP_INDICATION, msg);
l1sap.u.data.chan_nr = chan_nr;
l1sap.u.data.link_id = link_id;
@@ -280,8 +280,10 @@ int bts_model_phy_link_open(struct phy_link *plink)
// init lapdm layer 3 callback for the trx on timeslot 0 == BCCH
lchan_init_lapdm(&pinst->trx->ts[0].lchan[CCCH_LCHAN]);
/* This is probably the wrong location to set the ccch to active... the oml link def. needs to be reworked and fixed. */
- pinst->trx->ts[0].lchan[CCCH_LCHAN].rel_act_kind = LCHAN_REL_ACT_OML;
- lchan_set_state(&pinst->trx->ts[0].lchan[CCCH_LCHAN], LCHAN_S_ACTIVE);
+ pinst->trx->ts[0].lchan[CCCH_LCHAN].rel_act_kind =
+ LCHAN_REL_ACT_OML;
+ lchan_set_state(&pinst->trx->ts[0].lchan[CCCH_LCHAN],
+ LCHAN_S_ACTIVE);
}
}
@@ -445,9 +447,11 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
break;
}
/* activate dedicated channel */
- trx_sched_set_lchan(sched, chan_nr, LID_DEDIC, 1);
+ trx_sched_set_lchan(sched, chan_nr, LID_DEDIC,
+ 1);
/* activate associated channel */
- trx_sched_set_lchan(sched, chan_nr, LID_SACCH, 1);
+ trx_sched_set_lchan(sched, chan_nr, LID_SACCH,
+ 1);
/* set mode */
trx_sched_set_mode(sched, chan_nr,
lchan->rsl_cmode,
diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c
index 9d4a211a..30732758 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -41,8 +41,7 @@
#include <osmo-bts/amr.h>
#include <osmo-bts/scheduler.h>
#include <osmo-bts/scheduler_backend.h>
-
-#include "virtual_um.h"
+#include <virtphy/virtual_um.h>
/**
* Send a message over the virtual um interface.
@@ -80,7 +79,7 @@ static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
if (outmsg) {
struct phy_instance *pinst = trx_phy_instance(l1t->trx);
- struct gsmtap_hdr *gh = msgb_data(outmsg);
+ struct gsmtap_hdr *gh = (struct gsmtap_hdr *)msgb_data(outmsg);
if (virt_um_write_msg(pinst->phy_link->u.virt.virt_um, outmsg)
== -1) {
LOGP(DL1C, LOGL_ERROR,
diff --git a/src/osmo-bts-virtual/osmo_mcast_sock.c b/src/osmo-bts-virtual/shared/osmo_mcast_sock.c
index c1777347..acc6bcb1 100644
--- a/src/osmo-bts-virtual/osmo_mcast_sock.c
+++ b/src/osmo-bts-virtual/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/osmo-bts-virtual/virtual_um.c b/src/osmo-bts-virtual/shared/virtual_um.c
index e2e86e44..9415bfbb 100644
--- a/src/osmo-bts-virtual/virtual_um.c
+++ b/src/osmo-bts-virtual/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/tests/virtsock/Makefile.am b/tests/virtsock/Makefile.am
index 29c7442f..6beb681c 100644
--- a/tests/virtsock/Makefile.am
+++ b/tests/virtsock/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR)
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_srcdir)/src/osmo-bts-virtual/include -I$(OPENBSC_INCDIR)
AM_CFLAGS = -D_GNU_SOURCE -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(ORTP_CFLAGS)
LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(ORTP_LIBS)
noinst_PROGRAMS = client_bidir client_mcast client_unix server_bidir server_mcast server_unix virt_um_bts virt_um_ms
@@ -11,5 +11,5 @@ client_mcast_SOURCES = virtsock_client_mcast.c
server_mcast_SOURCES = virtsock_server_mcast.c
client_unix_SOURCES = virtsock_client_unix_domain.c
server_unix_SOURCES = virtsock_server_unix_domain.c
-virt_um_ms_SOURCES = virt_um_ms.c $(top_srcdir)/src/osmo-bts-virtual/virtual_um.c $(top_srcdir)/src/osmo-bts-virtual/osmo_mcast_sock.c
-virt_um_bts_SOURCES = virt_um_bts.c $(top_srcdir)/src/osmo-bts-virtual/virtual_um.c $(top_srcdir)/src/osmo-bts-virtual/osmo_mcast_sock.c
+virt_um_ms_SOURCES = virt_um_ms.c $(top_srcdir)/src/osmo-bts-virtual/shared/virtual_um.c $(top_srcdir)/src/osmo-bts-virtual/shared/osmo_mcast_sock.c
+virt_um_bts_SOURCES = virt_um_bts.c $(top_srcdir)/src/osmo-bts-virtual/shared/virtual_um.c $(top_srcdir)/src/osmo-bts-virtual/shared/osmo_mcast_sock.c
diff --git a/tests/virtsock/virt_um_bts.c b/tests/virtsock/virt_um_bts.c
index 37807b70..1044e331 100644
--- a/tests/virtsock/virt_um_bts.c
+++ b/tests/virtsock/virt_um_bts.c
@@ -5,8 +5,7 @@
#include <string.h>
#include <talloc.h>
#include <unistd.h>
-
-#include "../../src/osmo-bts-virtual/virtual_um.h"
+#include <virtphy/virtual_um.h>
static char *rx_mcast_group = "224.0.0.1";
static int rx_mcast_port = 6666;
diff --git a/tests/virtsock/virt_um_ms.c b/tests/virtsock/virt_um_ms.c
index ce061888..cb38b504 100644
--- a/tests/virtsock/virt_um_ms.c
+++ b/tests/virtsock/virt_um_ms.c
@@ -1,10 +1,10 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
+#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-
-#include "../../src/osmo-bts-virtual/virtual_um.h"
+#include <virtphy/virtual_um.h>
static char *tx_mcast_group = "224.0.0.1";
static int tx_mcast_port = 6666;
diff --git a/tests/virtsock/virtsock_client_mcast.c b/tests/virtsock/virtsock_client_mcast.c
index 4072f6df..b49d7551 100644
--- a/tests/virtsock/virtsock_client_mcast.c
+++ b/tests/virtsock/virtsock_client_mcast.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
/* Adresse für multicast IP */
static char *host_name = "224.0.0.1";
static int port = 6666;
@@ -79,7 +80,7 @@ static int setup_multicast_socket(void)
int main(void)
{
int iter = 0;
- int sin_len;
+ socklen_t sin_len;
char message[256];
int socket;
struct sockaddr_in sin;
@@ -91,7 +92,7 @@ int main(void)
socket = setup_multicast_socket();
/* Broadcast-Nachrichten empfangen */
// while (iter++ <= 10) {
- while (++iter) {
+ while (++iter <= INT_MAX) {
sin_len = sizeof(sin);
char addr[32];
int port;
diff --git a/tests/virtsock/virtsock_client_unix_domain.c b/tests/virtsock/virtsock_client_unix_domain.c
index a22c271c..fdbcc58a 100644
--- a/tests/virtsock/virtsock_client_unix_domain.c
+++ b/tests/virtsock/virtsock_client_unix_domain.c
@@ -7,13 +7,13 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#define BUF 1024
#define UDS_FILE "/tmp/osmocom_l2"
int main(int argc, char **argv) {
int create_socket;
char *buffer = malloc(BUF);
struct sockaddr_un address;
- int size;
if ((create_socket = socket(PF_LOCAL, SOCK_STREAM, 0)) > 0)
printf("Socket wurde angelegt\n");
address.sun_family = AF_LOCAL;
diff --git a/tests/virtsock/virtsock_server_mcast_bidir.c b/tests/virtsock/virtsock_server_mcast_bidir.c
index b3366315..8a3bfddc 100644
--- a/tests/virtsock/virtsock_server_mcast_bidir.c
+++ b/tests/virtsock/virtsock_server_mcast_bidir.c
@@ -11,6 +11,7 @@
#include <errno.h>
#include <fcntl.h>
#include <strings.h>
+#include <limits.h>
#include "mcast_sock.h"
@@ -29,7 +30,7 @@ int main(void)
perror("Error initializing bidirectional sock");
}
- while (++i) {
+ while (++i <= INT_MAX) {
char *ibuf;
strcpy(tx_buf, "MSG NR.");
asprintf(&ibuf, "%d", i);
@@ -51,4 +52,5 @@ int main(void)
perror("Error closing sockets.");
}
+ return 0;
}
diff --git a/tests/virtsock/virtsock_server_unix_domain.c b/tests/virtsock/virtsock_server_unix_domain.c
index 956c3592..8f2960bb 100644
--- a/tests/virtsock/virtsock_server_unix_domain.c
+++ b/tests/virtsock/virtsock_server_unix_domain.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
+
#define BUF 1024
#define UDS_FILE "/tmp/osmocom_l2"
int main(void) {
@@ -15,7 +17,6 @@ int main(void) {
char *buffer = malloc(BUF);
ssize_t size;
struct sockaddr_un address;
- const int y = 1;
printf("\e[2J");
if ((create_socket = socket(AF_LOCAL, SOCK_STREAM, 0)) > 0)
printf("Socket wurde angelegt\n");