diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-07-29 11:10:09 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-07-29 11:10:09 +0200 |
commit | df3c7a9c99ff4f965f7a830febc0c43d95e66289 (patch) | |
tree | c4e136be798410b9feb3a41fd11c6f1bf85bc14c | |
parent | d42f73a1ffb4e5db97484d0e732423d2ece22242 (diff) | |
parent | 0cbd5d0139123913d392d149f49807e68261c704 (diff) |
Merge remote branch 'origin/sylvain/pending'
86 files changed, 650 insertions, 733 deletions
diff --git a/include/l1a_l23_interface.h b/include/l1ctl_proto.h index 6c47246b..060922ab 100644 --- a/include/l1a_l23_interface.h +++ b/include/l1ctl_proto.h @@ -21,28 +21,31 @@ * */ -#ifndef l1a_l23_interface_h -#define l1a_l23_interface_h - -#define L1CTL_FBSB_REQ 1 -#define L1CTL_FBSB_CONF 2 -#define L1CTL_DATA_IND 3 -#define L1CTL_RACH_REQ 4 -#define L1CTL_DM_EST_REQ 5 -#define L1CTL_DATA_REQ 7 -#define L1CTL_RESET_IND 8 -#define L1CTL_PM_REQ 9 /* power measurement */ -#define L1CTL_PM_CONF 10 /* power measurement */ -#define L1CTL_ECHO_REQ 11 -#define L1CTL_ECHO_CONF 12 -#define L1CTL_RACH_CONF 13 -#define L1CTL_RESET_REQ 14 -#define L1CTL_RESET_CONF 15 -#define L1CTL_DATA_CONF 16 -#define L1CTL_CCCH_MODE_REQ 17 -#define L1CTL_CCCH_MODE_CONF 18 -#define L1CTL_DM_REL_REQ 19 -#define L1CTL_PARAM_REQ 20 +#ifndef __L1CTL_PROTO_H__ +#define __L1CTL_PROTO_H__ + +enum { + _L1CTL_NONE = 0, + L1CTL_FBSB_REQ, + L1CTL_FBSB_CONF, + L1CTL_DATA_IND, + L1CTL_RACH_REQ, + L1CTL_DM_EST_REQ, + L1CTL_DATA_REQ, + L1CTL_RESET_IND, + L1CTL_PM_REQ, /* power measurement */ + L1CTL_PM_CONF, /* power measurement */ + L1CTL_ECHO_REQ, + L1CTL_ECHO_CONF, + L1CTL_RACH_CONF, + L1CTL_RESET_REQ, + L1CTL_RESET_CONF, + L1CTL_DATA_CONF, + L1CTL_CCCH_MODE_REQ, + L1CTL_CCCH_MODE_CONF, + L1CTL_DM_REL_REQ, + L1CTL_PARAM_REQ, +}; enum ccch_mode { CCCH_MODE_NONE = 0, @@ -211,4 +214,4 @@ struct l1ctl_reset { uint8_t pad[3]; } __attribute__((packed)); -#endif +#endif /* __L1CTL_PROTO_H__ */ diff --git a/src/Makefile b/src/Makefile index 5151bfb5..6d16b7d6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -36,7 +36,7 @@ shared/libosmocore/build-target: shared/libosmocore/build-target/Makefile: shared/libosmocore/configure shared/libosmocore/build-target cd shared/libosmocore/build-target && ../configure \ - --host=arm-elf-linux --disable-vty \ + --host=arm-elf-linux --disable-vty --enable-panic-infloop \ --disable-shared --disable-talloc --disable-tests \ CC="$(CROSS_TOOL_PREFIX)gcc" CFLAGS="-Os -ffunction-sections -I../../../../target/firmware/include" diff --git a/src/host/layer23/configure.ac b/src/host/layer23/configure.ac index 036161c0..1be98eec 100644 --- a/src/host/layer23/configure.ac +++ b/src/host/layer23/configure.ac @@ -23,6 +23,13 @@ dnl Checks for typedefs, structures and compiler characteristics AC_OUTPUT( src/Makefile + src/common/Makefile + src/misc/Makefile + src/mobile/Makefile include/Makefile include/osmocom/Makefile + include/osmocom/bb/Makefile + include/osmocom/bb/common/Makefile + include/osmocom/bb/misc/Makefile + include/osmocom/bb/mobile/Makefile Makefile) diff --git a/src/host/layer23/include/Makefile.am b/src/host/layer23/include/Makefile.am index ca774b6b..297ece97 100644 --- a/src/host/layer23/include/Makefile.am +++ b/src/host/layer23/include/Makefile.am @@ -1,2 +1,2 @@ -noinst_HEADERS = l1a_l23_interface.h +noinst_HEADERS = l1ctl_proto.h SUBDIRS = osmocom diff --git a/src/host/layer23/include/l1a_l23_interface.h b/src/host/layer23/include/l1a_l23_interface.h deleted file mode 120000 index 2bbc9679..00000000 --- a/src/host/layer23/include/l1a_l23_interface.h +++ /dev/null @@ -1 +0,0 @@ -../../../../include/l1a_l23_interface.h
\ No newline at end of file diff --git a/src/host/layer23/include/l1ctl_proto.h b/src/host/layer23/include/l1ctl_proto.h new file mode 120000 index 00000000..f12ba71e --- /dev/null +++ b/src/host/layer23/include/l1ctl_proto.h @@ -0,0 +1 @@ +../../../../include/l1ctl_proto.h
\ No newline at end of file diff --git a/src/host/layer23/include/osmocom/Makefile.am b/src/host/layer23/include/osmocom/Makefile.am index 86537aa5..5adf9df5 100644 --- a/src/host/layer23/include/osmocom/Makefile.am +++ b/src/host/layer23/include/osmocom/Makefile.am @@ -1,2 +1 @@ -noinst_HEADERS = l1ctl.h osmocom_data.h lapdm.h rslms.h layer3.h \ - gsmtap_util.h logging.h +SUBDIRS = bb diff --git a/src/host/layer23/include/osmocom/bb/Makefile.am b/src/host/layer23/include/osmocom/bb/Makefile.am new file mode 100644 index 00000000..58a5f7fb --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = common misc mobile diff --git a/src/host/layer23/include/osmocom/bb/common/Makefile.am b/src/host/layer23/include/osmocom/bb/common/Makefile.am new file mode 100644 index 00000000..fa467575 --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/Makefile.am @@ -0,0 +1,2 @@ +noinst_HEADERS = l1ctl.h l1l2_interface.h l23_app.h lapdm.h logging.h networks.h \ + osmocom_data.h diff --git a/src/host/layer23/include/osmocom/l1ctl.h b/src/host/layer23/include/osmocom/bb/common/l1ctl.h index 9e76382c..ad113237 100644 --- a/src/host/layer23/include/osmocom/l1ctl.h +++ b/src/host/layer23/include/osmocom/bb/common/l1ctl.h @@ -2,7 +2,7 @@ #define osmocom_l1ctl_h #include <osmocore/msgb.h> -#include <osmocom/osmocom_data.h> +#include <osmocom/bb/common/osmocom_data.h> struct osmocom_ms; @@ -10,32 +10,34 @@ struct osmocom_ms; int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg); /* Transmit L1CTL_DATA_REQ */ -int tx_ph_data_req(struct osmocom_ms *ms, struct msgb *msg, uint8_t chan_nr, +int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg, uint8_t chan_nr, uint8_t link_id); /* Transmit L1CTL_PARAM_REQ */ -int l1ctl_tx_ph_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power); +int l1ctl_tx_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power); /* Transmit L1CTL_RACH_REQ */ -int tx_ph_rach_req(struct osmocom_ms *ms, uint8_t ra, uint8_t fn51, +int l1ctl_tx_rach_req(struct osmocom_ms *ms, uint8_t ra, uint8_t fn51, uint8_t mf_off); /* Transmit L1CTL_DM_EST_REQ */ -int tx_ph_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, +int l1ctl_tx_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, uint8_t chan_nr, uint8_t tsc); -int tx_ph_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, +int l1ctl_tx_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, uint16_t *ma, uint8_t ma_len, uint8_t chan_nr, uint8_t tsc); /* Transmit L1CTL_DM_REL_REQ */ -int tx_ph_dm_rel_req(struct osmocom_ms *ms); +int l1ctl_tx_dm_rel_req(struct osmocom_ms *ms); /* Transmit FBSB_REQ */ int l1ctl_tx_fbsb_req(struct osmocom_ms *ms, uint16_t arfcn, uint8_t flags, uint16_t timeout, uint8_t sync_info_idx, uint8_t ccch_mode); +/* Transmit CCCH_MODE_REQ */ int l1ctl_tx_ccch_mode_req(struct osmocom_ms *ms, uint8_t ccch_mode); +/* Transmit ECHO_REQ */ int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len); /* Transmit L1CTL_RESET_REQ */ diff --git a/src/host/layer23/include/osmocom/l1l2_interface.h b/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h index 41403d87..41403d87 100644 --- a/src/host/layer23/include/osmocom/l1l2_interface.h +++ b/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h diff --git a/src/host/layer23/include/osmocom/l23_app.h b/src/host/layer23/include/osmocom/bb/common/l23_app.h index 1a228567..1a228567 100644 --- a/src/host/layer23/include/osmocom/l23_app.h +++ b/src/host/layer23/include/osmocom/bb/common/l23_app.h diff --git a/src/host/layer23/include/osmocom/lapdm.h b/src/host/layer23/include/osmocom/bb/common/lapdm.h index ab048b8a..de954fb1 100644 --- a/src/host/layer23/include/osmocom/lapdm.h +++ b/src/host/layer23/include/osmocom/bb/common/lapdm.h @@ -6,7 +6,7 @@ #include <osmocore/timer.h> #include <osmocore/msgb.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> enum lapdm_state { LAPDm_STATE_NULL = 0, diff --git a/src/host/layer23/include/osmocom/logging.h b/src/host/layer23/include/osmocom/bb/common/logging.h index 1a11cf9d..1a11cf9d 100644 --- a/src/host/layer23/include/osmocom/logging.h +++ b/src/host/layer23/include/osmocom/bb/common/logging.h diff --git a/src/host/layer23/include/osmocom/networks.h b/src/host/layer23/include/osmocom/bb/common/networks.h index e8c1b18e..e8c1b18e 100644 --- a/src/host/layer23/include/osmocom/networks.h +++ b/src/host/layer23/include/osmocom/bb/common/networks.h diff --git a/src/host/layer23/include/osmocom/osmocom_data.h b/src/host/layer23/include/osmocom/bb/common/osmocom_data.h index 6fdeef78..dc7ba11d 100644 --- a/src/host/layer23/include/osmocom/osmocom_data.h +++ b/src/host/layer23/include/osmocom/bb/common/osmocom_data.h @@ -7,15 +7,16 @@ struct osmocom_ms; -#include <osmocom/support.h> -#include <osmocom/settings.h> -#include <osmocom/subscriber.h> -#include <osmocom/lapdm.h> -#include <osmocom/gsm48_rr.h> -#include <osmocom/sysinfo.h> -#include <osmocom/gsm322.h> -#include <osmocom/gsm48_mm.h> -#include <osmocom/gsm48_cc.h> + /* FIXME no 'mobile' specific stuff should be here */ +#include <osmocom/bb/mobile/support.h> +#include <osmocom/bb/mobile/settings.h> +#include <osmocom/bb/mobile/subscriber.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/mobile/gsm48_rr.h> +#include <osmocom/bb/mobile/sysinfo.h> +#include <osmocom/bb/mobile/gsm322.h> +#include <osmocom/bb/mobile/gsm48_mm.h> +#include <osmocom/bb/mobile/gsm48_cc.h> /* A layer2 entity */ struct osmol2_entity { diff --git a/src/host/layer23/include/osmocom/bb/misc/Makefile.am b/src/host/layer23/include/osmocom/bb/misc/Makefile.am new file mode 100644 index 00000000..71c9d389 --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/misc/Makefile.am @@ -0,0 +1 @@ +noinst_HEADERS = layer3.h rslms.h diff --git a/src/host/layer23/include/osmocom/layer3.h b/src/host/layer23/include/osmocom/bb/misc/layer3.h index bf68102d..dc7da87f 100644 --- a/src/host/layer23/include/osmocom/layer3.h +++ b/src/host/layer23/include/osmocom/bb/misc/layer3.h @@ -2,7 +2,7 @@ #define _OSMOCOM_L3_H #include <osmocore/msgb.h> -#include <osmocom/osmocom_data.h> +#include <osmocom/bb/common/osmocom_data.h> int gsm48_rx_ccch(struct msgb *msg, struct osmocom_ms *ms); int gsm48_rx_dcch(struct msgb *msg, struct osmocom_ms *ms); diff --git a/src/host/layer23/include/osmocom/rslms.h b/src/host/layer23/include/osmocom/bb/misc/rslms.h index 8f17b818..8b62ba92 100644 --- a/src/host/layer23/include/osmocom/rslms.h +++ b/src/host/layer23/include/osmocom/bb/misc/rslms.h @@ -2,7 +2,7 @@ #define _OSMOCOM_RSLMS_H #include <osmocore/msgb.h> -#include <osmocom/osmocom_data.h> +#include <osmocom/bb/common/osmocom_data.h> /* From L3 into RSLMS (direction -> L2) */ diff --git a/src/host/layer23/include/osmocom/bb/mobile/Makefile.am b/src/host/layer23/include/osmocom/bb/mobile/Makefile.am new file mode 100644 index 00000000..49c8378b --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/mobile/Makefile.am @@ -0,0 +1,2 @@ +noinst_HEADERS = gsm322.h gsm48_cc.h gsm48_mm.h gsm48_rr.h mncc.h settings.h \ + subscriber.h support.h sysinfo.h transaction.h diff --git a/src/host/layer23/include/osmocom/gsm322.h b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h index 78e380fe..78e380fe 100755..100644 --- a/src/host/layer23/include/osmocom/gsm322.h +++ b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h diff --git a/src/host/layer23/include/osmocom/gsm48_cc.h b/src/host/layer23/include/osmocom/bb/mobile/gsm48_cc.h index d6ea5756..d6ea5756 100644 --- a/src/host/layer23/include/osmocom/gsm48_cc.h +++ b/src/host/layer23/include/osmocom/bb/mobile/gsm48_cc.h diff --git a/src/host/layer23/include/osmocom/gsm48_mm.h b/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h index b988bd9a..b988bd9a 100644 --- a/src/host/layer23/include/osmocom/gsm48_mm.h +++ b/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h diff --git a/src/host/layer23/include/osmocom/gsm48_rr.h b/src/host/layer23/include/osmocom/bb/mobile/gsm48_rr.h index f5d52206..f5d52206 100644 --- a/src/host/layer23/include/osmocom/gsm48_rr.h +++ b/src/host/layer23/include/osmocom/bb/mobile/gsm48_rr.h diff --git a/src/host/layer23/include/osmocom/mncc.h b/src/host/layer23/include/osmocom/bb/mobile/mncc.h index d1d4d38f..d1d4d38f 100644 --- a/src/host/layer23/include/osmocom/mncc.h +++ b/src/host/layer23/include/osmocom/bb/mobile/mncc.h diff --git a/src/host/layer23/include/osmocom/settings.h b/src/host/layer23/include/osmocom/bb/mobile/settings.h index be13d208..be13d208 100644 --- a/src/host/layer23/include/osmocom/settings.h +++ b/src/host/layer23/include/osmocom/bb/mobile/settings.h diff --git a/src/host/layer23/include/osmocom/subscriber.h b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h index 34f45289..34f45289 100644 --- a/src/host/layer23/include/osmocom/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/mobile/subscriber.h diff --git a/src/host/layer23/include/osmocom/support.h b/src/host/layer23/include/osmocom/bb/mobile/support.h index 9af4d1b6..9af4d1b6 100644 --- a/src/host/layer23/include/osmocom/support.h +++ b/src/host/layer23/include/osmocom/bb/mobile/support.h diff --git a/src/host/layer23/include/osmocom/sysinfo.h b/src/host/layer23/include/osmocom/bb/mobile/sysinfo.h index 6f57fcd5..6f57fcd5 100644 --- a/src/host/layer23/include/osmocom/sysinfo.h +++ b/src/host/layer23/include/osmocom/bb/mobile/sysinfo.h diff --git a/src/host/layer23/include/osmocom/transaction.h b/src/host/layer23/include/osmocom/bb/mobile/transaction.h index 4be82c19..4be82c19 100644 --- a/src/host/layer23/include/osmocom/transaction.h +++ b/src/host/layer23/include/osmocom/bb/mobile/transaction.h diff --git a/src/host/layer23/include/osmocom/vty.h b/src/host/layer23/include/osmocom/bb/mobile/vty.h index f9e65a12..70faef5b 100644 --- a/src/host/layer23/include/osmocom/vty.h +++ b/src/host/layer23/include/osmocom/bb/mobile/vty.h @@ -1,7 +1,7 @@ #ifndef OSMOCOM_VTY_H #define OSMOCOM_VTY_H -#include <osmocom/osmocom_data.h> +#include <osmocom/bb/common/osmocom_data.h> #include <osmocom/vty/vty.h> #include <osmocom/vty/buffer.h> #include <osmocom/vty/command.h> diff --git a/src/host/layer23/include/osmocom/gsmtap_util.h b/src/host/layer23/include/osmocom/gsmtap_util.h deleted file mode 100644 index 30fc1267..00000000 --- a/src/host/layer23/include/osmocom/gsmtap_util.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _GSMTAP_UTIL_H -#define _GSMTAP_UTIL_H - -#include <stdint.h> - -/* convert RSL channel number to GSMTAP channel type */ -uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id); - -/* receive a message from L1/L2 and put it in GSMTAP */ -int gsmtap_sendmsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, - uint32_t fn, int8_t signal_dbm, uint8_t snr, - const uint8_t *data, unsigned int len); - -int gsmtap_init(uint32_t dst_ip); - -#endif /* _GSMTAP_UTIL_H */ diff --git a/src/host/layer23/src/Makefile.am b/src/host/layer23/src/Makefile.am index 6b25352c..58a5f7fb 100644 --- a/src/host/layer23/src/Makefile.am +++ b/src/host/layer23/src/Makefile.am @@ -1,26 +1 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) -#AM_LDFLAGS = $(LIBOSMOCORE_LIBS) - -noinst_LIBRARIES = liblayer23.a -liblayer23_a_SOURCES = l1l2_interface.c l1ctl.c gsmtap_util.c lapdm.c rslms.c \ - layer3.c logging.c bcch_scan.c settings.c \ - gsm48_cc.c transaction.c gsm48_mm.c gsm48_rr.c \ - gsm322.c support.c subscriber.c sysinfo.c networks.c \ - mnccms.c vty_interface.c - -bin_PROGRAMS = bcch_scan layer23 echo_test mobile - -bcch_scan_SOURCES = main.c app_bcch_scan.c -bcch_scan_LDADD = liblayer23.a $(LIBOSMOCORE_LIBS) - -layer23_SOURCES = main.c app_phone.c -layer23_LDADD = liblayer23.a $(LIBOSMOCORE_LIBS) - -echo_test_SOURCES = main.c app_echo_test.c -echo_test_LDADD = liblayer23.a $(LIBOSMOCORE_LIBS) - -mobile_SOURCES = main.c app_mobile.c -mobile_LDADD = liblayer23.a $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) - - +SUBDIRS = common misc mobile diff --git a/src/host/layer23/src/common/Makefile.am b/src/host/layer23/src/common/Makefile.am new file mode 100644 index 00000000..5c0d41bb --- /dev/null +++ b/src/host/layer23/src/common/Makefile.am @@ -0,0 +1,5 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) + +noinst_LIBRARIES = liblayer23.a +liblayer23_a_SOURCES = l1ctl.c l1l2_interface.c lapdm.c logging.c networks.c diff --git a/src/host/layer23/src/l1ctl.c b/src/host/layer23/src/common/l1ctl.c index a2880633..2aa3ab5a 100644 --- a/src/host/layer23/src/l1ctl.c +++ b/src/host/layer23/src/common/l1ctl.c @@ -28,7 +28,7 @@ #include <arpa/inet.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> #include <osmocore/signal.h> #include <osmocore/logging.h> @@ -36,16 +36,16 @@ #include <osmocore/msgb.h> #include <osmocore/tlv.h> #include <osmocore/gsm_utils.h> +#include <osmocore/gsmtap_util.h> #include <osmocore/protocol/gsm_04_08.h> #include <osmocore/protocol/gsm_08_58.h> #include <osmocore/rsl.h> -#include <osmocom/l1ctl.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/l1l2_interface.h> -#include <osmocom/lapdm.h> -#include <osmocom/logging.h> -#include <osmocom/gsmtap_util.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1l2_interface.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> static struct msgb *osmo_l1_alloc(uint8_t msg_type) { @@ -121,33 +121,6 @@ static int rx_l1_rach_conf(struct osmocom_ms *ms, struct msgb *msg) return 0; } -char *chan_nr2string(uint8_t chan_nr) -{ - static char str[20]; - uint8_t cbits = chan_nr >> 3; - - str[0] = '\0'; - - if (cbits == 0x01) - sprintf(str, "TCH/F"); - else if ((cbits & 0x1e) == 0x02) - sprintf(str, "TCH/H(%u)", cbits & 0x01); - else if ((cbits & 0x1c) == 0x04) - sprintf(str, "SDCCH/4(%u)", cbits & 0x03); - else if ((cbits & 0x18) == 0x08) - sprintf(str, "SDCCH/8(%u)", cbits & 0x07); - else if (cbits == 0x10) - sprintf(str, "BCCH"); - else if (cbits == 0x11) - sprintf(str, "RACH"); - else if (cbits == 0x12) - sprintf(str, "PCH/AGCH"); - else - sprintf(str, "UNKNOWN"); - - return str; -} - /* Receive L1CTL_DATA_IND (Data Indication from L1) */ static int rx_ph_data_ind(struct osmocom_ms *ms, struct msgb *msg) { @@ -173,7 +146,7 @@ static int rx_ph_data_ind(struct osmocom_ms *ms, struct msgb *msg) gsm_fn2gsmtime(&tm, ntohl(dl->frame_nr)); rsl_dec_chan_nr(dl->chan_nr, &chan_type, &chan_ss, &chan_ts); DEBUGP(DL1C, "%s (%.4u/%.2u/%.2u) %s\n", - chan_nr2string(dl->chan_nr), tm.t1, tm.t2, tm.t3, + rsl_chan_nr_str(dl->chan_nr), tm.t1, tm.t2, tm.t3, hexdump(ccch->data, sizeof(ccch->data))); meas->frames++; @@ -233,8 +206,8 @@ static int rx_ph_data_conf(struct osmocom_ms *ms, struct msgb *msg) } /* Transmit L1CTL_DATA_REQ */ -int tx_ph_data_req(struct osmocom_ms *ms, struct msgb *msg, uint8_t chan_nr, - uint8_t link_id) +int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg, + uint8_t chan_nr, uint8_t link_id) { struct l1ctl_hdr *l1h; struct l1ctl_info_ul *l1i_ul; @@ -323,7 +296,7 @@ int l1ctl_tx_ccch_mode_req(struct osmocom_ms *ms, uint8_t ccch_mode) } /* Transmit L1CTL_PARAM_REQ */ -int l1ctl_tx_ph_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power) +int l1ctl_tx_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power) { struct msgb *msg; struct l1ctl_info_ul *ul; @@ -343,7 +316,7 @@ int l1ctl_tx_ph_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power) } /* Transmit L1CTL_RACH_REQ */ -int tx_ph_rach_req(struct osmocom_ms *ms, uint8_t ra, uint8_t fn51, +int l1ctl_tx_rach_req(struct osmocom_ms *ms, uint8_t ra, uint8_t fn51, uint8_t mf_off) { struct msgb *msg; @@ -365,8 +338,8 @@ int tx_ph_rach_req(struct osmocom_ms *ms, uint8_t ra, uint8_t fn51, } /* Transmit L1CTL_DM_EST_REQ */ -int tx_ph_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, - uint8_t chan_nr, uint8_t tsc) +int l1ctl_tx_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, + uint8_t chan_nr, uint8_t tsc) { struct msgb *msg; struct l1ctl_info_ul *ul; @@ -393,8 +366,9 @@ int tx_ph_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, return osmo_send_l1(ms, msg); } -int tx_ph_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, - uint16_t *ma, uint8_t ma_len, uint8_t chan_nr, uint8_t tsc) +int l1ctl_tx_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, + uint16_t *ma, uint8_t ma_len, + uint8_t chan_nr, uint8_t tsc) { struct msgb *msg; struct l1ctl_info_ul *ul; @@ -427,7 +401,7 @@ int tx_ph_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, } /* Transmit L1CTL_DM_REL_REQ */ -int tx_ph_dm_rel_req(struct osmocom_ms *ms) +int l1ctl_tx_dm_rel_req(struct osmocom_ms *ms) { struct msgb *msg; struct l1ctl_info_ul *ul; diff --git a/src/host/layer23/src/l1l2_interface.c b/src/host/layer23/src/common/l1l2_interface.c index 3c359e84..2061adb3 100644 --- a/src/host/layer23/src/l1l2_interface.c +++ b/src/host/layer23/src/common/l1l2_interface.c @@ -21,9 +21,9 @@ * */ -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/logging.h> #include <sys/socket.h> #include <sys/un.h> @@ -37,6 +37,7 @@ #include <stdlib.h> #define GSM_L2_LENGTH 256 +#define GSM_L2_HEADROOM 32 extern int quit; @@ -46,7 +47,7 @@ static int layer2_read(struct bsc_fd *fd) u_int16_t len; int rc; - msg = msgb_alloc(GSM_L2_LENGTH, "Layer2"); + msg = msgb_alloc_headroom(GSM_L2_LENGTH+GSM_L2_HEADROOM, GSM_L2_HEADROOM, "Layer2"); if (!msg) { LOGP(DL1C, LOGL_ERROR, "Failed to allocate msg.\n"); return -ENOMEM; diff --git a/src/host/layer23/src/lapdm.c b/src/host/layer23/src/common/lapdm.c index e798cdc7..f165f4e3 100644 --- a/src/host/layer23/src/lapdm.c +++ b/src/host/layer23/src/common/lapdm.c @@ -65,12 +65,12 @@ #include <osmocore/protocol/gsm_04_08.h> #include <osmocore/protocol/gsm_08_58.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/lapdm.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> /* TS 04.06 Figure 4 / Section 3.2 */ #define LAPDm_LPD_NORMAL 0 @@ -306,7 +306,7 @@ for (i = 0; i < msgb_l2len(msg); i++) printf("\n"); #endif lapdm_pad_msgb(msg, n201); - return tx_ph_data_req(ms, msg, chan_nr, link_id); + return l1ctl_tx_data_req(ms, msg, chan_nr, link_id); } /* get next frame from the tx queue. because the ms has multiple datalinks, @@ -362,7 +362,7 @@ for (i = 0; i < msgb_l2len(msg); i++) printf("\n"); #endif lapdm_pad_msgb(msg, n201); - return tx_ph_data_req(ms, msg, chan_nr, link_id); + return l1ctl_tx_data_req(ms, msg, chan_nr, link_id); } /* Create RSLms various RSLms messages */ @@ -2013,9 +2013,9 @@ static int rslms_rx_chan_rqd(struct osmocom_ms *ms, struct msgb *msg) } /* TA = 0 - delay */ - rc = l1ctl_tx_ph_param_req(ms, 0 - cch->data[5], cch->data[7]); + rc = l1ctl_tx_param_req(ms, 0 - cch->data[5], cch->data[7]); - rc = tx_ph_rach_req(ms, cch->data[1], cch->data[2], cch->data[3]); + rc = l1ctl_tx_rach_req(ms, cch->data[1], cch->data[2], cch->data[3]); msgb_free(msg); diff --git a/src/host/layer23/src/logging.c b/src/host/layer23/src/common/logging.c index 82195327..281f46fb 100644 --- a/src/host/layer23/src/logging.c +++ b/src/host/layer23/src/common/logging.c @@ -23,7 +23,7 @@ #include <osmocore/utils.h> #include <osmocore/logging.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/logging.h> static const struct log_info_cat default_categories[] = { [DRSL] = { diff --git a/src/host/layer23/src/main.c b/src/host/layer23/src/common/main.c index 1816e150..4bf14d08 100644 --- a/src/host/layer23/src/main.c +++ b/src/host/layer23/src/common/main.c @@ -21,19 +21,19 @@ * */ -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/l1l2_interface.h> -#include <osmocom/layer3.h> -#include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> -#include <osmocom/logging.h> -#include <osmocom/l23_app.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/l1l2_interface.h> +#include <osmocom/bb/misc/layer3.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/l23_app.h> #include <osmocore/msgb.h> #include <osmocore/talloc.h> #include <osmocore/select.h> #include <osmocore/linuxlist.h> +#include <osmocore/gsmtap_util.h> #include <arpa/inet.h> diff --git a/src/host/layer23/src/networks.c b/src/host/layer23/src/common/networks.c index ae14d80c..77a42c25 100644 --- a/src/host/layer23/src/networks.c +++ b/src/host/layer23/src/common/networks.c @@ -2,7 +2,7 @@ #include <stdint.h> #include <stdio.h> -#include <osmocom/networks.h> +#include <osmocom/bb/common/networks.h> /* list of networks */ diff --git a/src/host/layer23/src/gsmtap_util.c b/src/host/layer23/src/gsmtap_util.c deleted file mode 100644 index a63fc882..00000000 --- a/src/host/layer23/src/gsmtap_util.c +++ /dev/null @@ -1,179 +0,0 @@ -/* GSMTAP output for Osmocom Layer2 (will only work on the host PC) */ -/* - * (C) 2010 by Harald Welte <laforge@gnumonks.org> - * - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include <osmocom/osmocom_data.h> -#include <osmocom/gsmtap_util.h> -#include <osmocore/logging.h> -#include <osmocore/protocol/gsm_04_08.h> -#include <osmocore/gsmtap.h> -#include <osmocore/msgb.h> -#include <osmocore/rsl.h> - -#include <arpa/inet.h> -#include <sys/socket.h> -#include <netinet/in.h> - -#include <stdio.h> -#include <unistd.h> -#include <stdint.h> -#include <string.h> -#include <errno.h> - -static struct bsc_fd gsmtap_bfd = { .fd = -1 }; -static LLIST_HEAD(gsmtap_txqueue); - -uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t link_id) -{ - uint8_t ret = GSMTAP_CHANNEL_UNKNOWN; - - switch (rsl_chantype) { - case RSL_CHAN_Bm_ACCHs: - ret = GSMTAP_CHANNEL_TCH_F; - break; - case RSL_CHAN_Lm_ACCHs: - ret = GSMTAP_CHANNEL_TCH_H; - break; - case RSL_CHAN_SDCCH4_ACCH: - ret = GSMTAP_CHANNEL_SDCCH4; - break; - case RSL_CHAN_SDCCH8_ACCH: - ret = GSMTAP_CHANNEL_SDCCH8; - break; - case RSL_CHAN_BCCH: - ret = GSMTAP_CHANNEL_BCCH; - break; - case RSL_CHAN_RACH: - ret = GSMTAP_CHANNEL_RACH; - break; - case RSL_CHAN_PCH_AGCH: - /* it could also be AGCH... */ - ret = GSMTAP_CHANNEL_PCH; - break; - } - - if (link_id & 0x40) - ret |= GSMTAP_CHANNEL_ACCH; - - return ret; -} - -/* receive a message from L1/L2 and put it in GSMTAP */ -int gsmtap_sendmsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, - uint32_t fn, int8_t signal_dbm, uint8_t snr, - const uint8_t *data, unsigned int len) -{ - struct msgb *msg; - struct gsmtap_hdr *gh; - uint8_t *dst; - - /* gsmtap was never initialized, so don't try to send anything */ - if (gsmtap_bfd.fd == -1) - return 0; - - msg = msgb_alloc(sizeof(*gh) + len, "gsmtap_tx"); - if (!msg) - return -ENOMEM; - - gh = (struct gsmtap_hdr *) msgb_put(msg, sizeof(*gh)); - - gh->version = GSMTAP_VERSION; - gh->hdr_len = sizeof(*gh)/4; - gh->type = GSMTAP_TYPE_UM; - gh->timeslot = ts; - gh->sub_slot = ss; - gh->arfcn = htons(arfcn); - gh->snr_db = snr; - gh->signal_dbm = signal_dbm; - gh->frame_number = htonl(fn); - gh->sub_type = chan_type; - gh->antenna_nr = 0; - - dst = msgb_put(msg, len); - memcpy(dst, data, len); - - msgb_enqueue(&gsmtap_txqueue, msg); - gsmtap_bfd.when |= BSC_FD_WRITE; - - return 0; -} - -/* Callback from select layer if we can write to the socket */ -static int gsmtap_fd_cb(struct bsc_fd *fd, unsigned int flags) -{ - struct msgb *msg; - int rc; - - if (!(flags & BSC_FD_WRITE)) - return 0; - - msg = msgb_dequeue(&gsmtap_txqueue); - if (!msg) { - /* no more messages in the queue, disable READ cb */ - gsmtap_bfd.when = 0; - return 0; - } - rc = write(gsmtap_bfd.fd, msg->data, msg->len); - if (rc < 0) { - perror("writing msgb to gsmtap fd"); - msgb_free(msg); - return rc; - } - if (rc != msg->len) { - perror("short write to gsmtap fd"); - msgb_free(msg); - return -EIO; - } - - msgb_free(msg); - return 0; -} - -int gsmtap_init(uint32_t dst_ip) -{ - int rc; - struct sockaddr_in sin; - - sin.sin_family = AF_INET; - sin.sin_port = htons(GSMTAP_UDP_PORT); - sin.sin_addr.s_addr = htonl(dst_ip); - - /* FIXME: create socket */ - rc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (rc < 0) { - perror("creating UDP socket"); - return rc; - } - gsmtap_bfd.fd = rc; - rc = connect(rc, (struct sockaddr *)&sin, sizeof(sin)); - if (rc < 0) { - perror("connecting UDP socket"); - close(gsmtap_bfd.fd); - gsmtap_bfd.fd = 0; - return rc; - } - - gsmtap_bfd.when = BSC_FD_WRITE; - gsmtap_bfd.cb = gsmtap_fd_cb; - gsmtap_bfd.data = NULL; - - return bsc_register_fd(&gsmtap_bfd); -} diff --git a/src/host/layer23/src/misc/Makefile.am b/src/host/layer23/src/misc/Makefile.am new file mode 100644 index 00000000..954c5a88 --- /dev/null +++ b/src/host/layer23/src/misc/Makefile.am @@ -0,0 +1,10 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) +LDADD = ../common/liblayer23.a $(LIBOSMOCORE_LIBS) + +bin_PROGRAMS = bcch_scan layer23 echo_test + +bcch_scan_SOURCES = ../common/main.c app_bcch_scan.c bcch_scan.c +layer23_SOURCES = ../common/main.c app_phone.c layer3.c rslms.c +echo_test_SOURCES = ../common/main.c app_echo_test.c + diff --git a/src/host/layer23/src/app_bcch_scan.c b/src/host/layer23/src/misc/app_bcch_scan.c index ce5ef9e9..35145535 100644 --- a/src/host/layer23/src/app_bcch_scan.c +++ b/src/host/layer23/src/misc/app_bcch_scan.c @@ -21,12 +21,11 @@ * */ -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/layer3.h> -#include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/misc/layer3.h> #include <osmocore/msgb.h> #include <osmocore/talloc.h> diff --git a/src/host/layer23/src/app_echo_test.c b/src/host/layer23/src/misc/app_echo_test.c index 285b80ab..56ab6740 100644 --- a/src/host/layer23/src/app_echo_test.c +++ b/src/host/layer23/src/misc/app_echo_test.c @@ -21,12 +21,11 @@ * */ -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/layer3.h> -#include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/misc/layer3.h> #include <osmocore/msgb.h> #include <osmocore/talloc.h> diff --git a/src/host/layer23/src/app_phone.c b/src/host/layer23/src/misc/app_phone.c index de122f54..ced0154b 100644 --- a/src/host/layer23/src/app_phone.c +++ b/src/host/layer23/src/misc/app_phone.c @@ -21,12 +21,11 @@ * */ -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/layer3.h> -#include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/misc/layer3.h> #include <osmocore/msgb.h> #include <osmocore/talloc.h> diff --git a/src/host/layer23/src/bcch_scan.c b/src/host/layer23/src/misc/bcch_scan.c index c542129a..dff4dc9b 100644 --- a/src/host/layer23/src/bcch_scan.c +++ b/src/host/layer23/src/misc/bcch_scan.c @@ -25,7 +25,7 @@ #include <string.h> #include <errno.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> #include <osmocore/logging.h> #include <osmocore/talloc.h> @@ -38,11 +38,10 @@ #include <osmocore/protocol/gsm_08_58.h> #include <osmocore/rsl.h> -#include <osmocom/l1ctl.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/lapdm.h> -#include <osmocom/logging.h> -#include <osmocom/gsmtap_util.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> /* somewhere in 05.08 */ #define MAX_CELLS_IN_BA 32 diff --git a/src/host/layer23/src/layer3.c b/src/host/layer23/src/misc/layer3.c index 0680afb0..69f558d7 100644 --- a/src/host/layer23/src/layer3.c +++ b/src/host/layer23/src/misc/layer3.c @@ -7,12 +7,12 @@ #include <osmocore/tlv.h> #include <osmocore/protocol/gsm_04_08.h> -#include <osmocom/logging.h> -#include <osmocom/lapdm.h> -#include <osmocom/rslms.h> -#include <osmocom/layer3.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/misc/rslms.h> +#include <osmocom/bb/misc/layer3.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> static int ccch_mode = CCCH_MODE_NONE; @@ -187,7 +187,7 @@ static int gsm48_rx_imm_ass(struct msgb *msg, struct osmocom_ms *ms) } /* request L1 to go to dedicated mode on assigned channel */ - tx_ph_dm_est_req_h0(ms, arfcn, ia->chan_desc.chan_nr, + l1ctl_tx_dm_est_req_h0(ms, arfcn, ia->chan_desc.chan_nr, ia->chan_desc.h0.tsc); /* request L2 to establish the SAPI0 connection */ diff --git a/src/host/layer23/src/rslms.c b/src/host/layer23/src/misc/rslms.c index 90920787..7231fda4 100644 --- a/src/host/layer23/src/rslms.c +++ b/src/host/layer23/src/misc/rslms.c @@ -29,12 +29,12 @@ #include <osmocore/tlv.h> #include <osmocore/protocol/gsm_04_08.h> -#include <osmocom/logging.h> -#include <osmocom/lapdm.h> -#include <osmocom/rslms.h> -#include <osmocom/layer3.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/misc/rslms.h> +#include <osmocom/bb/misc/layer3.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> /* Send a 'simple' RLL request to L2 */ int rslms_tx_rll_req(struct osmocom_ms *ms, uint8_t msg_type, @@ -81,7 +81,7 @@ static int rslms_rx_udata_ind(struct msgb *msg, struct osmocom_ms *ms) } else if (rllh->chan_nr == RSL_CHAN_BCCH) { rc = gsm48_rx_bcch(msg, ms); if (ccch_enabled && (rach_count < 2)) { - tx_ph_rach_req(ms, rach_count, 27, 0); + l1ctl_tx_rach_req(ms, rach_count, 27, 0); rach_count++; } } diff --git a/src/host/layer23/src/mobile/Makefile.am b/src/host/layer23/src/mobile/Makefile.am new file mode 100644 index 00000000..5dbda72a --- /dev/null +++ b/src/host/layer23/src/mobile/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) +LDADD = ../common/liblayer23.a $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) + +noinst_LIBRARIES = libmobile.a +libmobile_a_SOURCES = gsm322.c gsm48_cc.c gsm48_mm.c gsm48_rr.c \ + mnccms.c settings.c subscriber.c support.c \ + sysinfo.c transaction.c vty_interface.c + +bin_PROGRAMS = mobile + +mobile_SOURCES = ../common/main.c app_mobile.c +mobile_LDADD = libmobile.a $(LDADD) + + diff --git a/src/host/layer23/src/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index 41bba19d..aa62be19 100644 --- a/src/host/layer23/src/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -26,15 +26,14 @@ #include <signal.h> #include <time.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/l1ctl.h> -#include <osmocom/l23_app.h> -#include <osmocom/gsm48_rr.h> -#include <osmocom/sysinfo.h> -#include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> -#include <osmocom/logging.h> -#include <osmocom/vty.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/l23_app.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/mobile/gsm48_rr.h> +#include <osmocom/bb/mobile/sysinfo.h> +#include <osmocom/bb/mobile/vty.h> #include <osmocom/vty/telnet_interface.h> #include <osmocore/msgb.h> diff --git a/src/host/layer23/src/gsm322.c b/src/host/layer23/src/mobile/gsm322.c index 405483c7..9098f24c 100644 --- a/src/host/layer23/src/gsm322.c +++ b/src/host/layer23/src/mobile/gsm322.c @@ -31,12 +31,12 @@ #include <osmocore/gsm48.h> #include <osmocore/signal.h> -#include <osmocom/logging.h> -#include <osmocom/l1ctl.h> -#include <osmocom/l23_app.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/networks.h> -#include <osmocom/vty.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/common/l23_app.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/networks.h> +#include <osmocom/bb/mobile/vty.h> extern void *l23_ctx; diff --git a/src/host/layer23/src/gsm48_cc.c b/src/host/layer23/src/mobile/gsm48_cc.c index 820ce665..d7bfca5d 100644 --- a/src/host/layer23/src/gsm48_cc.c +++ b/src/host/layer23/src/mobile/gsm48_cc.c @@ -30,11 +30,11 @@ #include <osmocore/gsm48.h> #include <osmocore/talloc.h> -#include <osmocom/logging.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/mncc.h> -#include <osmocom/transaction.h> -#include <osmocom/gsm48_cc.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/mobile/mncc.h> +#include <osmocom/bb/mobile/transaction.h> +#include <osmocom/bb/mobile/gsm48_cc.h> extern void *l23_ctx; diff --git a/src/host/layer23/src/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c index 82d09a7e..d048e89d 100644 --- a/src/host/layer23/src/gsm48_mm.c +++ b/src/host/layer23/src/mobile/gsm48_mm.c @@ -31,12 +31,12 @@ #include <osmocore/gsm48.h> #include <osmocore/talloc.h> -#include <osmocom/logging.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/gsm48_cc.h> -#include <osmocom/l23_app.h> -#include <osmocom/networks.h> -#include <osmocom/l1ctl.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l23_app.h> +#include <osmocom/bb/common/networks.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/mobile/gsm48_cc.h> extern void *l23_ctx; diff --git a/src/host/layer23/src/gsm48_rr.c b/src/host/layer23/src/mobile/gsm48_rr.c index 37d8a671..f34cdcf4 100644 --- a/src/host/layer23/src/gsm48_rr.c +++ b/src/host/layer23/src/mobile/gsm48_rr.c @@ -54,12 +54,12 @@ #include <osmocore/gsm48.h> #include <osmocore/bitvec.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/l1l2_interface.h> -#include <osmocom/logging.h> -#include <osmocom/networks.h> -#include <osmocom/l1ctl.h> -#include <osmocom/vty.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/l1l2_interface.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/networks.h> +#include <osmocom/bb/common/l1ctl.h> +#include <osmocom/bb/mobile/vty.h> static void start_rr_t_monitor(struct gsm48_rrlayer *rr, int sec, int micro); static void stop_rr_t_monitor(struct gsm48_rrlayer *rr); @@ -226,7 +226,7 @@ static void new_rr_state(struct gsm48_rrlayer *rr, int state) struct gsm322_msg *em; /* release dedicated mode, if any */ - tx_ph_dm_rel_req(rr->ms); + l1ctl_tx_dm_rel_req(rr->ms); l1ctl_tx_reset_req(rr->ms, L1CTL_RES_T_FULL); /* free establish message, if any */ rr->rr_est_req = 0; @@ -3161,7 +3161,7 @@ static int gsm48_rr_dl_est(struct osmocom_ms *ms) rr->ind_ta = rr->cd_now.ta; LOGP(DRR, LOGL_INFO, "setting indicated TA %d (actual TA %d)\n", rr->ind_ta, rr->ind_ta - set->alter_delay); - l1ctl_tx_ph_param_req(ms, rr->ind_ta - set->alter_delay, + l1ctl_tx_param_req(ms, rr->ind_ta - set->alter_delay, (set->alter_tx_power) ? set->alter_tx_power_value : rr->ind_tx_power); @@ -3178,10 +3178,10 @@ static int gsm48_rr_dl_est(struct osmocom_ms *ms) exit(-ENOTSUP); } if (rr->cd_now.h) - tx_ph_dm_est_req_h1(ms, rr->cd_now.maio, rr->cd_now.hsn, + l1ctl_tx_dm_est_req_h1(ms, rr->cd_now.maio, rr->cd_now.hsn, ma, ma_len, rr->cd_now.chan_nr, rr->cd_now.tsc); else - tx_ph_dm_est_req_h0(ms, rr->cd_now.arfcn, rr->cd_now.chan_nr, + l1ctl_tx_dm_est_req_h0(ms, rr->cd_now.arfcn, rr->cd_now.chan_nr, rr->cd_now.tsc); #endif @@ -3811,7 +3811,7 @@ static int gsm48_rr_rx_acch(struct osmocom_ms *ms, struct msgb *msg) ind_tx_power); if (ind_ta != rr->ind_ta || ind_tx_power != rr->ind_tx_power) { LOGP(DRR, LOGL_INFO, "setting new ta and tx_power\n"); - l1ctl_tx_ph_param_req(ms, ind_ta - set->alter_delay, + l1ctl_tx_param_req(ms, ind_ta - set->alter_delay, (set->alter_tx_power) ? set->alter_tx_power_value : ind_tx_power); rr->ind_ta = ind_ta; @@ -4456,7 +4456,7 @@ static int gsm48_rr_mdl_error_ind(struct osmocom_ms *ms, struct msgb *msg) } /* deactivate channel */ - tx_ph_dm_rel_req(ms, arfcn, rr->chan_desc.chan_desc.chan_nr); + l1ctl_tx_dm_rel_req(ms, arfcn, rr->chan_desc.chan_desc.chan_nr); /* send abort ind to upper layer */ nmsg = gsm48_mm_msgb_alloc(); diff --git a/src/host/layer23/src/mnccms.c b/src/host/layer23/src/mobile/mnccms.c index 8d5a54bf..70c33c89 100644 --- a/src/host/layer23/src/mnccms.c +++ b/src/host/layer23/src/mobile/mnccms.c @@ -27,10 +27,10 @@ #include <osmocore/talloc.h> -#include <osmocom/logging.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/mncc.h> -#include <osmocom/vty.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/mobile/mncc.h> +#include <osmocom/bb/mobile/vty.h> void *l23_ctx; static uint32_t new_callref = 1; diff --git a/src/host/layer23/src/settings.c b/src/host/layer23/src/mobile/settings.c index 096b3db7..1aef48b0 100644 --- a/src/host/layer23/src/settings.c +++ b/src/host/layer23/src/mobile/settings.c @@ -24,9 +24,9 @@ #include <string.h> #include <osmocore/talloc.h> -#include <osmocom/logging.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/networks.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/networks.h> int gsm_settings_init(struct osmocom_ms *ms) { diff --git a/src/host/layer23/src/subscriber.c b/src/host/layer23/src/mobile/subscriber.c index 8245cdcc..44434901 100644 --- a/src/host/layer23/src/subscriber.c +++ b/src/host/layer23/src/mobile/subscriber.c @@ -24,9 +24,9 @@ #include <string.h> #include <osmocore/talloc.h> -#include <osmocom/logging.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/networks.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/networks.h> void *l23_ctx; diff --git a/src/host/layer23/src/support.c b/src/host/layer23/src/mobile/support.c index 8b8b183e..40cf1b09 100644 --- a/src/host/layer23/src/support.c +++ b/src/host/layer23/src/mobile/support.c @@ -23,7 +23,7 @@ #include <stdint.h> #include <string.h> -#include <osmocom/osmocom_data.h> +#include <osmocom/bb/common/osmocom_data.h> void gsm_support_init(struct osmocom_ms *ms) { diff --git a/src/host/layer23/src/sysinfo.c b/src/host/layer23/src/mobile/sysinfo.c index 0f425b48..a16d39d4 100644 --- a/src/host/layer23/src/sysinfo.c +++ b/src/host/layer23/src/mobile/sysinfo.c @@ -23,8 +23,8 @@ #include <stdint.h> #include <string.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/networks.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/networks.h> int gsm48_sysinfo_dump(struct gsm48_sysinfo *s, uint16_t arfcn, void (*print)(void *, const char *, ...), void *priv) diff --git a/src/host/layer23/src/transaction.c b/src/host/layer23/src/mobile/transaction.c index 59ec17bd..abd3c2d1 100644 --- a/src/host/layer23/src/transaction.c +++ b/src/host/layer23/src/mobile/transaction.c @@ -25,10 +25,10 @@ #include <osmocore/timer.h> #include <osmocore/msgb.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/mncc.h> -#include <osmocom/transaction.h> -#include <osmocom/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/mobile/mncc.h> +#include <osmocom/bb/mobile/transaction.h> extern void *l23_ctx; diff --git a/src/host/layer23/src/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index d627d317..426c0d82 100644 --- a/src/host/layer23/src/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -25,14 +25,14 @@ #include <unistd.h> #include <sys/types.h> -#include <osmocom/vty.h> -#include <osmocom/vty/telnet_interface.h> - #include <osmocore/gsm48.h> -#include <osmocom/osmocom_data.h> -#include <osmocom/networks.h> -#include <osmocom/mncc.h> -#include <osmocom/transaction.h> + +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/networks.h> +#include <osmocom/bb/mobile/mncc.h> +#include <osmocom/bb/mobile/transaction.h> +#include <osmocom/bb/mobile/vty.h> +#include <osmocom/vty/telnet_interface.h> int mncc_call(struct osmocom_ms *ms, char *number); int mncc_hangup(struct osmocom_ms *ms); diff --git a/src/host/layer23/src/telnet_interface.c b/src/host/layer23/src/telnet_interface.c deleted file mode 100644 index c7b06f72..00000000 --- a/src/host/layer23/src/telnet_interface.c +++ /dev/null @@ -1,240 +0,0 @@ -/* minimalistic telnet/ms interface it might turn into a wire interface */ -/* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include <sys/socket.h> -#include <netinet/in.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#include <osmocom/telnet_interface.h> -#include <osmocore/talloc.h> - -#include <vty/buffer.h> - -#define WRITE_CONNECTION(fd, msg...) \ - int ret; \ - char buf[4096]; \ - snprintf(buf, sizeof(buf), msg); \ - ret = write(fd, buf, strlen(buf)); - - -/* per connection data */ -LLIST_HEAD(active_connections); - -void *l23_ctx; -static void *tall_telnet_ctx; - -/* per ms data */ -static int telnet_new_connection(struct bsc_fd *fd, unsigned int what); - -static struct bsc_fd server_socket = { - .when = BSC_FD_READ, - .cb = telnet_new_connection, - .priv_nr = 0, -}; - -int telnet_init(struct osmocom_ms *ms, int port) { - struct sockaddr_in sock_addr; - int fd, on = 1; - - tall_telnet_ctx = talloc_named_const(l23_ctx, 1, - "telnet_connection"); - - ms_vty_init(ms); - - fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); - - if (fd < 0) { - fprintf(stderr, "Telnet interface socket creation failed\n"); - return -1; - } - - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - - memset(&sock_addr, 0, sizeof(sock_addr)); - sock_addr.sin_family = AF_INET; - sock_addr.sin_port = htons(port); - sock_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if (bind(fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr)) < 0) { - fprintf(stderr, "Telnet interface failed to bind\n"); - return -1; - } - - if (listen(fd, 0) < 0) { - fprintf(stderr, "Telnet interface failed to listen\n"); - return -1; - } - - server_socket.data = ms; - server_socket.fd = fd; - bsc_register_fd(&server_socket); - - return 0; -} - -static void print_welcome(int fd) { - int ret; - static char *msg = - "Welcome to the Osmocom Control interface\n" - "License GPLv2+: GNU GPL version 2 or later " - "<http://gnu.org/licenses/gpl.html>\n" - "This is free software: you are free to change " - "and redistribute it.\n" - "There is NO WARRANTY, to the extent permitted " - "by law.\nType \"help\" to get a short introduction.\n"; - - ret = write(fd, msg, strlen(msg)); -} - -int telnet_close_client(struct bsc_fd *fd) { - struct telnet_connection *conn = (struct telnet_connection*)fd->data; - - close(fd->fd); - bsc_unregister_fd(fd); - - if (conn->dbg) { -// debug_del_target(conn->dbg); - talloc_free(conn->dbg); - } - - llist_del(&conn->entry); - talloc_free(conn); - return 0; -} - -static int client_data(struct bsc_fd *fd, unsigned int what) -{ - struct telnet_connection *conn = fd->data; - int rc = 0; - - if (what & BSC_FD_READ) { - conn->fd.when &= ~BSC_FD_READ; - rc = vty_read(conn->vty); - } - - /* vty might have been closed from vithin vty_read() */ - if (!conn->vty) - return rc; - - if (what & BSC_FD_WRITE) { - rc = buffer_flush_all(conn->vty->obuf, fd->fd); - if (rc == BUFFER_EMPTY) - conn->fd.when &= ~BSC_FD_WRITE; - } - - return rc; -} - -static int telnet_new_connection(struct bsc_fd *fd, unsigned int what) { - struct telnet_connection *connection; - struct sockaddr_in sockaddr; - socklen_t len = sizeof(sockaddr); - int new_connection = accept(fd->fd, (struct sockaddr*)&sockaddr, &len); - - if (new_connection < 0) { - fprintf(stderr, "telnet accept failed\n"); - return -1; - } - - - connection = talloc_zero(tall_telnet_ctx, struct telnet_connection); - connection->ms = (struct osmocom_ms*)fd->data; - connection->fd.data = connection; - connection->fd.fd = new_connection; - connection->fd.when = BSC_FD_READ; - connection->fd.cb = client_data; - bsc_register_fd(&connection->fd); - llist_add_tail(&connection->entry, &active_connections); - - print_welcome(new_connection); - - connection->vty = vty_create(new_connection, connection); - if (!connection->vty) { - fprintf(stderr, "couldn't create VTY\n"); - return -1; - } - - return 0; -} - -/* callback from VTY code */ -void vty_event(enum event event, int sock, struct vty *vty) -{ - struct telnet_connection *connection = vty->priv; - struct bsc_fd *bfd = &connection->fd; - - if (vty->type != VTY_TERM) - return; - - switch (event) { - case VTY_READ: - bfd->when |= BSC_FD_READ; - break; - case VTY_WRITE: - bfd->when |= BSC_FD_WRITE; - break; - case VTY_CLOSED: - /* vty layer is about to free() vty */ - connection->vty = NULL; - telnet_close_client(bfd); - break; - default: - break; - } -} - -void vty_notify(struct osmocom_ms *ms, const char *fmt, ...) -{ - struct telnet_connection *connection; - char buffer[1000]; - va_list args; - struct vty *vty; - - if (fmt) { - va_start(args, fmt); - vsnprintf(buffer, sizeof(buffer) - 1, fmt, args); - buffer[sizeof(buffer) - 1] = '\0'; - va_end(args); - - if (!buffer[0]) - return; - } - - llist_for_each_entry(connection, &active_connections, entry) { - vty = connection->vty; - if (!vty) - continue; - if (!fmt) { - vty_out(vty, "%s%% (MS %s)%s", VTY_NEWLINE, ms->name, - VTY_NEWLINE); - continue; - } - if (buffer[strlen(buffer) - 1] == '\n') { - buffer[strlen(buffer) - 1] = '\0'; - vty_out(vty, "%% %s%s", buffer, VTY_NEWLINE); - buffer[strlen(buffer)] = '\n'; - } else - vty_out(vty, "%% %s", buffer); - } -} - diff --git a/src/shared/libosmocore/configure.in b/src/shared/libosmocore/configure.in index e3e178c0..c3e00610 100644 --- a/src/shared/libosmocore/configure.in +++ b/src/shared/libosmocore/configure.in @@ -35,25 +35,48 @@ dnl Generate the output AM_CONFIG_HEADER(config.h) AC_ARG_ENABLE(talloc, - [ --disable-talloc Disable building talloc memory allocator ], + [AS_HELP_STRING( + [--disable-talloc], + [Disable building talloc memory allocator] + )], [enable_talloc=0], [enable_talloc=1]) AM_CONDITIONAL(ENABLE_TALLOC, test "x$enable_talloc" = "x1") AC_ARG_ENABLE(plugin, - [ --disable-plugin Disable support for dlopen plugins ], + [AS_HELP_STRING( + [--disable-plugin], + [Disable support for dlopen plugins], + )], [enable_plugin=0], [enable_plugin=1]) AM_CONDITIONAL(ENABLE_PLUGIN, test "x$enable_plugin" = "x1") AC_ARG_ENABLE(tests, - [ --disable-tests Disable building test programs ], + [AS_HELP_STRING( + [--disable-tests], + [Disable building test programs] + )], [enable_tests=0], [enable_tests=1]) AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = "x1") AC_ARG_ENABLE(vty, - [ --disable-vty Disable building VTY telnet interface ], + [AS_HELP_STRING( + [--disable-vty], + [Disable building VTY telnet interface] + )], [enable_vty=0], [enable_vty=1]) AM_CONDITIONAL(ENABLE_VTY, test "x$enable_vty" = "x1") +AC_ARG_ENABLE(panic_infloop, + [AS_HELP_STRING( + [--enable-panic-infloop], + [Trigger infinite loop on panic rather than fprintf/abort] + )], + [panic_infloop=1], [panic_infloop=0]) +if test "x$panic_infloop" = "x1" +then + AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) +fi + AC_OUTPUT( libosmocore.pc diff --git a/src/shared/libosmocore/include/osmocore/Makefile.am b/src/shared/libosmocore/include/osmocore/Makefile.am index 8334f148..ecdc65c9 100644 --- a/src/shared/libosmocore/include/osmocore/Makefile.am +++ b/src/shared/libosmocore/include/osmocore/Makefile.am @@ -2,7 +2,7 @@ osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h \ tlv.h bitvec.h comp128.h statistics.h gsm_utils.h utils.h \ gsmtap.h write_queue.h rsl.h gsm48.h rxlev_stat.h mncc.h \ gsm48_ie.h logging.h gsm0808.h rate_ctr.h gsmtap_util.h \ - plugin.h crc16.h + plugin.h crc16.h panic.h if ENABLE_TALLOC osmocore_HEADERS += talloc.h diff --git a/src/shared/libosmocore/include/osmocore/gsm0808.h b/src/shared/libosmocore/include/osmocore/gsm0808.h index 9166e54f..2d609c9e 100644 --- a/src/shared/libosmocore/include/osmocore/gsm0808.h +++ b/src/shared/libosmocore/include/osmocore/gsm0808.h @@ -24,14 +24,14 @@ struct msgb; -struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, int ci); +struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, uint16_t ci); struct msgb *gsm0808_create_reset(void); struct msgb *gsm0808_create_clear_complete(void); struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id); struct msgb *gsm0808_create_cipher_reject(uint8_t cause); struct msgb *gsm0808_create_classmark_update(const uint8_t *classmark, uint8_t length); struct msgb *gsm0808_create_sapi_reject(uint8_t link_id); -struct msgb *gsm0808_create_assignment_completed(struct gsm_lchan *lchan, uint8_t rr_cause, +struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause, uint8_t chosen_channel, uint8_t encr_alg_id, uint8_t speech_mode); struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause); diff --git a/src/shared/libosmocore/include/osmocore/msgb.h b/src/shared/libosmocore/include/osmocore/msgb.h index 2841dc56..354c5d88 100644 --- a/src/shared/libosmocore/include/osmocore/msgb.h +++ b/src/shared/libosmocore/include/osmocore/msgb.h @@ -23,6 +23,8 @@ #include <stdint.h> #include "linuxlist.h" +#define MSGB_DEBUG + struct msgb { struct llist_head list; @@ -58,6 +60,14 @@ extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg); extern struct msgb *msgb_dequeue(struct llist_head *queue); extern void msgb_reset(struct msgb *m); +#ifdef MSGB_DEBUG +#include <osmocore/panic.h> +static inline void msgb_abort(struct msgb *msg, const char *text) +{ + osmo_panic("%s", text); +} +#endif + #define msgb_l1(m) ((void *)(m->l1h)) #define msgb_l2(m) ((void *)(m->l2h)) #define msgb_l3(m) ((void *)(m->l3h)) @@ -82,9 +92,24 @@ static inline unsigned int msgb_headlen(const struct msgb *msgb) { return msgb->len - msgb->data_len; } + +static inline int msgb_tailroom(const struct msgb *msgb) +{ + return (msgb->head + msgb->data_len) - msgb->tail; +} + +static inline int msgb_headroom(const struct msgb *msgb) +{ + return (msgb->data - msgb->head); +} + static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len) { unsigned char *tmp = msgb->tail; +#ifdef MSGB_DEBUG + if (msgb_tailroom(msgb) < len) + msgb_abort(msgb, "Not enough tailroom\n"); +#endif msgb->tail += len; msgb->len += len; return tmp; @@ -132,6 +157,10 @@ static inline uint32_t msgb_get_u32(struct msgb *msgb) } static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len) { +#ifdef MSGB_DEBUG + if (msgb_headroom(msgb) < len) + msgb_abort(msgb, "Not enough headroom\n"); +#endif msgb->data -= len; msgb->len += len; return msgb->data; @@ -141,10 +170,6 @@ static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len) msgb->len -= len; return msgb->data += len; } -static inline int msgb_tailroom(const struct msgb *msgb) -{ - return (msgb->head + msgb->data_len) - msgb->tail; -} /* increase the headroom of an empty msgb, reducing the tailroom */ static inline void msgb_reserve(struct msgb *msg, int len) diff --git a/src/shared/libosmocore/include/osmocore/panic.h b/src/shared/libosmocore/include/osmocore/panic.h new file mode 100644 index 00000000..cee95358 --- /dev/null +++ b/src/shared/libosmocore/include/osmocore/panic.h @@ -0,0 +1,11 @@ +#ifndef OSMOCORE_PANIC_H +#define OSMOCORE_PANIC_H + +#include <stdarg.h> + +typedef void (*osmo_panic_handler_t)(const char *fmt, va_list args); + +void osmo_panic(const char *fmt, ...); +void osmo_set_panic_handler(osmo_panic_handler_t *h); + +#endif diff --git a/src/shared/libosmocore/include/osmocore/protocol/Makefile.am b/src/shared/libosmocore/include/osmocore/protocol/Makefile.am index 557950ec..5df9fe74 100644 --- a/src/shared/libosmocore/include/osmocore/protocol/Makefile.am +++ b/src/shared/libosmocore/include/osmocore/protocol/Makefile.am @@ -1,3 +1,4 @@ -osmocore_proto_HEADERS = gsm_04_08.h gsm_04_11.h gsm_04_80.h gsm_08_58.h gsm_12_21.h gsm_08_08.h +osmocore_proto_HEADERS = gsm_04_08.h gsm_04_11.h gsm_04_80.h gsm_08_58.h \ + gsm_12_21.h gsm_08_08.h gsm_04_12.h osmocore_protodir = $(includedir)/osmocore/protocol diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h b/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h new file mode 100644 index 00000000..bd9e0884 --- /dev/null +++ b/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h @@ -0,0 +1,31 @@ +#ifndef PROTO_GSM_04_12_H +#define PROTO_GSM_04_12_H + +#include <stdint.h> + +/* GSM TS 04.12 definitions for Short Message Service Cell Broadcast */ + +#define GSM412_SEQ_FST_BLOCK 0x0 +#define GSM412_SEQ_SND_BLOCK 0x1 +#define GSM412_SEQ_TRD_BLOCK 0x2 +#define GSM412_SEQ_FTH_BLOCK 0x3 +#define GSM412_SEQ_FST_SCHED_BLOCK 0x8 +#define GSM413_SEQ_NULL_MSG 0xf + +struct gsm412_block_type { + uint8_t seq_nr : 4, + lb : 1, + lpd : 2, + spare : 1; +} __attribute__((packed)); + +struct gsm413_sched_msg { + uint8_t beg_slot_nr : 6, + type : 2; + uint8_t end_slot_nr : 6, + spare1 : 1, spare2: 1; + uint8_t cbsms_msg_map[6]; + uint8_t data[0]; +} __attribute__((packed)); + +#endif diff --git a/src/shared/libosmocore/include/osmocore/rsl.h b/src/shared/libosmocore/include/osmocore/rsl.h index cd84057b..54d67032 100644 --- a/src/shared/libosmocore/include/osmocore/rsl.h +++ b/src/shared/libosmocore/include/osmocore/rsl.h @@ -17,6 +17,9 @@ extern const struct tlv_definition rsl_att_tlvdef; uint8_t rsl_enc_chan_nr(uint8_t type, uint8_t subch, uint8_t timeslot); /* decode channel number as per Section 9.3.1 */ int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *timeslot); +/* Turns channel number into a string */ +const char *rsl_chan_nr_str(uint8_t chan_nr); + const char *rsl_err_name(uint8_t err); const char *rsl_rlm_cause_name(uint8_t err); diff --git a/src/shared/libosmocore/src/Makefile.am b/src/shared/libosmocore/src/Makefile.am index a20fbc86..e197e179 100644 --- a/src/shared/libosmocore/src/Makefile.am +++ b/src/shared/libosmocore/src/Makefile.am @@ -13,7 +13,7 @@ libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c rxlev_stat.c \ tlv_parser.c bitvec.c comp128.c gsm_utils.c statistics.c \ write_queue.c utils.c rsl.c gsm48.c gsm48_ie.c \ logging.c gsm0808.c rate_ctr.c gsmtap_util.c \ - gprs_cipher_core.c crc16.c + gprs_cipher_core.c crc16.c panic.c if ENABLE_PLUGIN libosmocore_la_SOURCES += plugin.c diff --git a/src/shared/libosmocore/src/gsm0808.c b/src/shared/libosmocore/src/gsm0808.c index 1dc035b3..c8dc6645 100644 --- a/src/shared/libosmocore/src/gsm0808.c +++ b/src/shared/libosmocore/src/gsm0808.c @@ -27,10 +27,15 @@ #define BSSMAP_MSG_SIZE 512 #define BSSMAP_MSG_HEADROOM 128 -struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc, int lac, int _ci) +static void put_data_16(uint8_t *data, const uint16_t val) +{ + memcpy(data, &val, sizeof(val)); +} + +struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc, int lac, uint16_t _ci) { uint8_t *data; - uint16_t *ci; + uint8_t *ci; struct msgb* msg; struct gsm48_loc_area_id *lai; @@ -56,8 +61,8 @@ struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai)); gsm48_generate_lai(lai, cc, nc, lac); - ci = (uint16_t *) msgb_put(msg, 2); - *ci = htons(_ci); + ci = msgb_put(msg, 2); + put_data_16(ci, htons(_ci)); /* copy the layer3 data */ data = msgb_put(msg, msgb_l3len(msg_l3) + 2); @@ -187,7 +192,7 @@ struct msgb *gsm0808_create_sapi_reject(uint8_t link_id) return msg; } -struct msgb *gsm0808_create_assignment_completed(struct gsm_lchan *lchan, uint8_t rr_cause, +struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause, uint8_t chosen_channel, uint8_t encr_alg_id, uint8_t speech_mode) { diff --git a/src/shared/libosmocore/src/gsm_utils.c b/src/shared/libosmocore/src/gsm_utils.c index dc97ceff..4b4e2c60 100644 --- a/src/shared/libosmocore/src/gsm_utils.c +++ b/src/shared/libosmocore/src/gsm_utils.c @@ -2,6 +2,7 @@ * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de> * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> + * (C) 2010 by Nico Golde <nico@ngolde.de> * * All Rights Reserved * @@ -34,53 +35,140 @@ #include "../config.h" -/* GSM 03.38 6.2.1 Charachter packing */ +/* ETSI GSM 03.38 6.2.1 and 6.2.1.1 default alphabet + * Greek symbols at hex positions 0x10 and 0x12-0x1a + * left out as they can't be handled with a char and + * since most phones don't display or write these + * characters this would only needlessly make the code + * more complex +*/ +static unsigned char gsm_7bit_alphabet[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0x0d, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, + 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, + 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, + 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x3c, 0x2f, 0x3e, 0x14, 0x11, 0xff, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x28, 0x40, 0x29, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5e, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x40, 0xff, 0x01, 0xff, + 0x03, 0xff, 0x7b, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5c, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5b, 0x7e, 0x5d, 0xff, 0x7c, 0xff, 0xff, 0xff, + 0xff, 0x5b, 0x0e, 0x1c, 0x09, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5d, + 0xff, 0xff, 0xff, 0xff, 0x5c, 0xff, 0x0b, 0xff, 0xff, 0xff, 0x5e, 0xff, 0xff, 0x1e, 0x7f, + 0xff, 0xff, 0xff, 0x7b, 0x0f, 0x1d, 0xff, 0x04, 0x05, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, + 0xff, 0x7d, 0x08, 0xff, 0xff, 0xff, 0x7c, 0xff, 0x0c, 0x06, 0xff, 0xff, 0x7e, 0xff, 0xff +}; + +/* GSM 03.38 6.2.1 Character lookup for decoding */ +static int gsm_septet_lookup(uint8_t ch) +{ + int i = 0; + for(; i < sizeof(gsm_7bit_alphabet); i++){ + if(gsm_7bit_alphabet[i] == ch) + return i; + } + return -1; +} + +/* GSM 03.38 6.2.1 Character unpacking */ int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t length) { int i = 0; int l = 0; + int septet_l = (length * 8) / 7; + uint8_t *rtext = calloc(septet_l, sizeof(uint8_t)); + uint8_t tmp; - /* FIXME: We need to account for user data headers here */ + /* FIXME: We need to account for user data headers here */ i += l; - for (; i < length; i ++) - *(text ++) = + for (; i < septet_l; i++){ + rtext[i] = ((user_data[(i * 7 + 7) >> 3] << (7 - ((i * 7 + 7) & 7))) | (user_data[(i * 7) >> 3] >> ((i * 7) & 7))) & 0x7f; + } + + for(i = 0; i < septet_l; i++){ + /* this is an extension character */ + if(rtext[i] == 0x1b && i + 1 < length){ + tmp = rtext[i+1]; + *(text++) = gsm_7bit_alphabet[0x7f + tmp]; + i++; + continue; + } + + *(text++) = gsm_septet_lookup(rtext[i]); + } + *text = '\0'; + free(rtext); - return i - l; + return i; } +/* GSM 03.38 6.2.1 Prepare character packing */ +static int gsm_septet_encode(uint8_t *result, const char *data) +{ + int i, y = 0; + uint8_t ch; + for(i = 0; i < strlen(data); i++){ + ch = data[i]; + switch(ch){ + /* fall-through for extension characters */ + case 0x0c: + case 0x5e: + case 0x7b: + case 0x7d: + case 0x5c: + case 0x5b: + case 0x7e: + case 0x5d: + case 0x7c: + result[y++] = 0x1b; + default: + result[y] = gsm_7bit_alphabet[ch]; + break; + } + y++; + } -/* GSM 03.38 6.2.1 Charachter packing */ + return y; +} + +/* GSM 03.38 6.2.1 Character packing */ int gsm_7bit_encode(uint8_t *result, const char *data) { - int i,j = 0; - unsigned char ch1, ch2; + int i,y,z = 0; + /* prepare for the worst case, every character expanding to two bytes */ + uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t)); + uint8_t cb, nb; int shift = 0; - for ( i=0; i<strlen(data); i++ ) { + y = gsm_septet_encode(rdata, data); - ch1 = data[i] & 0x7F; - ch1 = ch1 >> shift; - ch2 = data[(i+1)] & 0x7F; - ch2 = ch2 << (7-shift); + for(i = 0; i < y; i++) { + if(shift == 7 && i + 1 < y){ + shift = 0; + continue; + } - ch1 = ch1 | ch2; + cb = (rdata[i] & 0x7f) >> shift; + if(i + 1 < y){ + nb = (rdata[i + 1] & 0x7f) << (7 - shift); + cb = cb | nb; + } - result[j++] = ch1; + result[z++] = cb; shift++; - - if ((shift == 7) && (i+1<strlen(data))) { - shift = 0; - i++; - } } - return i; + free(rdata); + return z; } /* determine power control level for given dBm value, as indicated diff --git a/src/shared/libosmocore/src/panic.c b/src/shared/libosmocore/src/panic.c new file mode 100644 index 00000000..a25067de --- /dev/null +++ b/src/shared/libosmocore/src/panic.c @@ -0,0 +1,71 @@ +/* Panic handling */ +/* + * (C) 2010 by Sylvain Munaut <tnt@246tNt.com> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <osmocore/panic.h> + +#include "../config.h" + + +static osmo_panic_handler_t osmo_panic_handler = (void*)0; + + +#ifndef PANIC_INFLOOP + +#include <stdio.h> +#include <stdlib.h> + +static void osmo_panic_default(const char *fmt, va_list args) +{ + vfprintf(stderr, fmt, args); + abort(); +} + +#else + +static void osmo_panic_default(const char *fmt, va_list args) +{ + while (1); +} + +#endif + + +void osmo_panic(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + + if (osmo_panic_handler) + osmo_panic_handler(fmt, args); + else + osmo_panic_default(fmt, args); + + va_end(args); +} + + +void osmo_set_panic_handler(osmo_panic_handler_t *h) +{ + osmo_panic_handler = h; +} + diff --git a/src/shared/libosmocore/src/rsl.c b/src/shared/libosmocore/src/rsl.c index 7bc1712f..10fba9b2 100644 --- a/src/shared/libosmocore/src/rsl.c +++ b/src/shared/libosmocore/src/rsl.c @@ -183,6 +183,32 @@ int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *tim return 0; } +const char *rsl_chan_nr_str(uint8_t chan_nr) +{ + static char str[20]; + int ts = chan_nr & 7; + uint8_t cbits = chan_nr >> 3; + + if (cbits == 0x01) + sprintf(str, "TCH/F on TS%d", ts); + else if ((cbits & 0x1e) == 0x02) + sprintf(str, "TCH/H(%u) on TS%d", cbits & 0x01, ts); + else if ((cbits & 0x1c) == 0x04) + sprintf(str, "SDCCH/4(%u) on TS%d", cbits & 0x03, ts); + else if ((cbits & 0x18) == 0x08) + sprintf(str, "SDCCH/8(%u) on TS%d", cbits & 0x07, ts); + else if (cbits == 0x10) + sprintf(str, "BCCH on TS%d", ts); + else if (cbits == 0x11) + sprintf(str, "RACH on TS%d", ts); + else if (cbits == 0x12) + sprintf(str, "PCH/AGCH on TS%d", ts); + else + sprintf(str, "UNKNOWN on TS%d", ts); + + return str; +} + static const struct value_string rsl_err_vals[] = { { RSL_ERR_RADIO_IF_FAIL, "Radio Interface Failure" }, { RSL_ERR_RADIO_LINK_FAIL, "Radio Link Failure" }, diff --git a/src/shared/libosmocore/tests/sms/sms_test.c b/src/shared/libosmocore/tests/sms/sms_test.c index f5183d54..9d87b5bc 100644 --- a/src/shared/libosmocore/tests/sms/sms_test.c +++ b/src/shared/libosmocore/tests/sms/sms_test.c @@ -1,5 +1,6 @@ /* * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de> + * (C) 2010 by Nico Golde <nico@ngolde.de> * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -24,6 +25,56 @@ #include <sys/types.h> #include <osmocore/msgb.h> #include <osmocore/gsm_utils.h> +#include <osmocore/utils.h> + +struct test_case { + const uint8_t *input; + const uint16_t input_length; + + const uint8_t *expected; + const uint16_t expected_length; +}; + +static const char simple_text[] = "test text"; +static const uint8_t simple_enc[] = { + 0xf4, 0xf2, 0x9c, 0x0e, 0xa2, 0x97, 0xf1, 0x74 +}; + +static const char escape_text[] = "!$ a more#^- complicated test@@?_\%! case"; +static const uint8_t escape_enc[] = { + 0x21, 0x01, 0x28, 0x0c, 0x6a, 0xbf, 0xe5, 0xe5, 0xd1, + 0x86, 0xd2, 0x02, 0x8d, 0xdf, 0x6d, 0x38, 0x3b, 0x3d, + 0x0e, 0xd3, 0xcb, 0x64, 0x10, 0xbd, 0x3c, 0xa7, 0x03, + 0x00, 0xbf, 0x48, 0x29, 0x04, 0x1a, 0x87, 0xe7, 0x65, +}; + +static const struct test_case test_encode[] = +{ + { + .input = simple_text, + .expected = simple_enc, + .expected_length = sizeof(simple_enc), + }, + { + .input = escape_text, + .expected = escape_enc, + .expected_length = sizeof(escape_enc), + }, +}; + +static const struct test_case test_decode[] = +{ + { + .input = simple_enc, + .input_length = sizeof(simple_enc), + .expected = simple_text, + }, + { + .input = escape_enc, + .input_length = sizeof(escape_enc), + .expected = escape_text, + }, +}; int main(int argc, char** argv) { @@ -32,16 +83,40 @@ int main(int argc, char** argv) uint8_t *sms; uint8_t i; - /* test 7-bit coding/decoding */ - const char *input = "test text"; uint8_t length; uint8_t coded[256]; char result[256]; - length = gsm_7bit_encode(coded, input); - gsm_7bit_decode(result, coded, length); - if (strcmp(result, input) != 0) { - printf("7 Bit coding failed... life sucks\n"); - printf("Wanted: '%s' got '%s'\n", input, result); + /* test 7-bit encoding */ + for (i = 0; i < ARRAY_SIZE(test_encode); ++i) { + memset(coded, 0x42, sizeof(coded)); + length = gsm_7bit_encode(coded, test_encode[i].input); + + if (length != test_encode[i].expected_length) { + fprintf(stderr, "Failed to encode case %d. Got %d, expected %d\n", + i, length, test_encode[i].expected_length); + return -1; + } + + if (memcmp(coded, test_encode[i].expected, length) != 0) { + fprintf(stderr, "Encoded content does not match for %d\n", + i); + return -1; + } } + + /* test 7-bit decoding */ + for (i = 0; i < ARRAY_SIZE(test_decode); ++i) { + memset(result, 0x42, sizeof(coded)); + gsm_7bit_decode(result, test_decode[i].input, + test_decode[i].input_length); + + if (strcmp(result, test_decode[i].expected) != 0) { + fprintf(stderr, "Test case %d failed to decode.\n", i); + return -1; + } + } + + printf("OK\n"); + return 0; } diff --git a/src/target/firmware/include/layer1/l23_api.h b/src/target/firmware/include/layer1/l23_api.h index 1ba6d173..b1602705 100644 --- a/src/target/firmware/include/layer1/l23_api.h +++ b/src/target/firmware/include/layer1/l23_api.h @@ -3,7 +3,7 @@ #include <stdint.h> #include <osmocore/msgb.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> void l1a_l23api_init(void); void l1_queue_for_l2(struct msgb *msg); diff --git a/src/target/firmware/include/layer1/sync.h b/src/target/firmware/include/layer1/sync.h index 76134497..257244b1 100644 --- a/src/target/firmware/include/layer1/sync.h +++ b/src/target/firmware/include/layer1/sync.h @@ -5,7 +5,7 @@ #include <osmocore/gsm_utils.h> #include <layer1/tdma_sched.h> #include <layer1/mframe_sched.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> /* structure representing L1 sync information about a cell */ struct l1_cell_info { diff --git a/src/target/firmware/layer1/l23_api.c b/src/target/firmware/layer1/l23_api.c index d9d341ad..8cd8ad00 100644 --- a/src/target/firmware/layer1/l23_api.c +++ b/src/target/firmware/layer1/l23_api.c @@ -39,11 +39,11 @@ #include <rf/trf6151.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> /* the size we will allocate struct msgb* for HDLC */ #define L3_MSG_HEAD 4 -#define L3_MSG_SIZE (sizeof(struct l1ctl_info_dl)+sizeof(struct l1ctl_data_ind) + L3_MSG_HEAD) +#define L3_MSG_SIZE (sizeof(struct l1ctl_hdr)+sizeof(struct l1ctl_info_dl)+sizeof(struct l1ctl_data_ind) + L3_MSG_HEAD) void l1_queue_for_l2(struct msgb *msg) { diff --git a/src/target/firmware/layer1/prim_fbsb.c b/src/target/firmware/layer1/prim_fbsb.c index 4360f7c4..a399d903 100644 --- a/src/target/firmware/layer1/prim_fbsb.c +++ b/src/target/firmware/layer1/prim_fbsb.c @@ -47,7 +47,7 @@ #include <layer1/tpu_window.h> #include <layer1/l23_api.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> #define FB0_RETRY_COUNT 3 #define AFC_RETRY_COUNT 30 diff --git a/src/target/firmware/layer1/prim_pm.c b/src/target/firmware/layer1/prim_pm.c index 80650f60..b5260cb9 100644 --- a/src/target/firmware/layer1/prim_pm.c +++ b/src/target/firmware/layer1/prim_pm.c @@ -45,7 +45,7 @@ #include <layer1/tpu_window.h> #include <layer1/l23_api.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> static void l1ddsp_meas_read(uint8_t nbmeas, uint16_t *pm) { diff --git a/src/target/firmware/layer1/prim_rach.c b/src/target/firmware/layer1/prim_rach.c index 6f4ad6d3..763ec61c 100644 --- a/src/target/firmware/layer1/prim_rach.c +++ b/src/target/firmware/layer1/prim_rach.c @@ -46,7 +46,7 @@ #include <layer1/tpu_window.h> #include <layer1/l23_api.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> struct { uint32_t fn; diff --git a/src/target/firmware/layer1/prim_rx_nb.c b/src/target/firmware/layer1/prim_rx_nb.c index 036f4e6d..e49e1a41 100644 --- a/src/target/firmware/layer1/prim_rx_nb.c +++ b/src/target/firmware/layer1/prim_rx_nb.c @@ -47,7 +47,7 @@ #include <layer1/l23_api.h> #include <layer1/rfch.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> struct l1s_rxnb_state { struct l1s_meas_hdr meas[4]; diff --git a/src/target/firmware/layer1/prim_tx_nb.c b/src/target/firmware/layer1/prim_tx_nb.c index 7e4bd960..f1398e0d 100644 --- a/src/target/firmware/layer1/prim_tx_nb.c +++ b/src/target/firmware/layer1/prim_tx_nb.c @@ -48,7 +48,7 @@ #include <layer1/l23_api.h> #include <layer1/rfch.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> /* Channel type definitions for DEDICATED mode */ #define INVALID_CHANNEL 0 diff --git a/src/target/firmware/layer1/sync.c b/src/target/firmware/layer1/sync.c index d4d2aed3..7d7d29f6 100644 --- a/src/target/firmware/layer1/sync.c +++ b/src/target/firmware/layer1/sync.c @@ -56,7 +56,7 @@ #include <layer1/tpu_window.h> #include <layer1/l23_api.h> -#include <l1a_l23_interface.h> +#include <l1ctl_proto.h> struct l1s_state l1s; diff --git a/src/target/firmware/rf/trf6151.c b/src/target/firmware/rf/trf6151.c index 1d000fd7..b465611d 100644 --- a/src/target/firmware/rf/trf6151.c +++ b/src/target/firmware/rf/trf6151.c @@ -117,7 +117,7 @@ static void trf6151_reg_write(uint16_t reg, uint16_t val) int trf6151_set_gain(uint8_t dbm, int high) { uint16_t reg = trf6151_reg_cache[REG_RX] & 0x07ff; - printf("trf6151_set_gain(%u, %d)\n", dbm, high); + printd("trf6151_set_gain(%u, %d)\n", dbm, high); if (dbm < 14 || dbm > 40) return -1; |