diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-07-24 21:25:38 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2010-07-25 10:19:34 +0200 |
commit | 66c3ca052741b060e07683c6661fdc25de34cd43 (patch) | |
tree | b4563b9202a1002417ff282b0fa3230d0ae1fd68 /src/host | |
parent | da6bc3b5773d8421e9528dd8a2ac2dc0638f9c07 (diff) |
layer23: Switch to using gsmtap_util from libosmocom
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/layer23/include/osmocom/Makefile.am | 2 | ||||
-rw-r--r-- | src/host/layer23/include/osmocom/gsmtap_util.h | 16 | ||||
-rw-r--r-- | src/host/layer23/src/Makefile.am | 2 | ||||
-rw-r--r-- | src/host/layer23/src/app_bcch_scan.c | 1 | ||||
-rw-r--r-- | src/host/layer23/src/app_echo_test.c | 1 | ||||
-rw-r--r-- | src/host/layer23/src/app_mobile.c | 1 | ||||
-rw-r--r-- | src/host/layer23/src/app_phone.c | 1 | ||||
-rw-r--r-- | src/host/layer23/src/bcch_scan.c | 1 | ||||
-rw-r--r-- | src/host/layer23/src/gsmtap_util.c | 179 | ||||
-rw-r--r-- | src/host/layer23/src/l1ctl.c | 2 | ||||
-rw-r--r-- | src/host/layer23/src/main.c | 2 |
11 files changed, 4 insertions, 204 deletions
diff --git a/src/host/layer23/include/osmocom/Makefile.am b/src/host/layer23/include/osmocom/Makefile.am index 86537aa5..f4002f54 100644 --- a/src/host/layer23/include/osmocom/Makefile.am +++ b/src/host/layer23/include/osmocom/Makefile.am @@ -1,2 +1,2 @@ noinst_HEADERS = l1ctl.h osmocom_data.h lapdm.h rslms.h layer3.h \ - gsmtap_util.h logging.h + logging.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..5caea00a 100644 --- a/src/host/layer23/src/Makefile.am +++ b/src/host/layer23/src/Makefile.am @@ -3,7 +3,7 @@ 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 \ +liblayer23_a_SOURCES = l1l2_interface.c l1ctl.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 \ diff --git a/src/host/layer23/src/app_bcch_scan.c b/src/host/layer23/src/app_bcch_scan.c index ce5ef9e9..325345dd 100644 --- a/src/host/layer23/src/app_bcch_scan.c +++ b/src/host/layer23/src/app_bcch_scan.c @@ -25,7 +25,6 @@ #include <osmocom/l1ctl.h> #include <osmocom/layer3.h> #include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> #include <osmocom/logging.h> #include <osmocore/msgb.h> diff --git a/src/host/layer23/src/app_echo_test.c b/src/host/layer23/src/app_echo_test.c index 285b80ab..a3cf59b5 100644 --- a/src/host/layer23/src/app_echo_test.c +++ b/src/host/layer23/src/app_echo_test.c @@ -25,7 +25,6 @@ #include <osmocom/l1ctl.h> #include <osmocom/layer3.h> #include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> #include <osmocom/logging.h> #include <osmocore/msgb.h> diff --git a/src/host/layer23/src/app_mobile.c b/src/host/layer23/src/app_mobile.c index 41bba19d..53e26bc1 100644 --- a/src/host/layer23/src/app_mobile.c +++ b/src/host/layer23/src/app_mobile.c @@ -32,7 +32,6 @@ #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/vty/telnet_interface.h> diff --git a/src/host/layer23/src/app_phone.c b/src/host/layer23/src/app_phone.c index de122f54..b225a9ae 100644 --- a/src/host/layer23/src/app_phone.c +++ b/src/host/layer23/src/app_phone.c @@ -25,7 +25,6 @@ #include <osmocom/l1ctl.h> #include <osmocom/layer3.h> #include <osmocom/lapdm.h> -#include <osmocom/gsmtap_util.h> #include <osmocom/logging.h> #include <osmocore/msgb.h> diff --git a/src/host/layer23/src/bcch_scan.c b/src/host/layer23/src/bcch_scan.c index c542129a..d0383231 100644 --- a/src/host/layer23/src/bcch_scan.c +++ b/src/host/layer23/src/bcch_scan.c @@ -42,7 +42,6 @@ #include <osmocom/osmocom_data.h> #include <osmocom/lapdm.h> #include <osmocom/logging.h> -#include <osmocom/gsmtap_util.h> /* somewhere in 05.08 */ #define MAX_CELLS_IN_BA 32 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/l1ctl.c b/src/host/layer23/src/l1ctl.c index a2880633..993c7db8 100644 --- a/src/host/layer23/src/l1ctl.c +++ b/src/host/layer23/src/l1ctl.c @@ -36,6 +36,7 @@ #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> @@ -45,7 +46,6 @@ #include <osmocom/l1l2_interface.h> #include <osmocom/lapdm.h> #include <osmocom/logging.h> -#include <osmocom/gsmtap_util.h> static struct msgb *osmo_l1_alloc(uint8_t msg_type) { diff --git a/src/host/layer23/src/main.c b/src/host/layer23/src/main.c index 1816e150..4a32e863 100644 --- a/src/host/layer23/src/main.c +++ b/src/host/layer23/src/main.c @@ -26,7 +26,6 @@ #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> @@ -34,6 +33,7 @@ #include <osmocore/talloc.h> #include <osmocore/select.h> #include <osmocore/linuxlist.h> +#include <osmocore/gsmtap_util.h> #include <arpa/inet.h> |