layer23: update to new GSMTAP API in libosmocore >= 0.3.1

This commit is contained in:
Harald Welte 2011-05-22 12:36:55 +02:00
parent 8226b8eae9
commit 308f9e506e
3 changed files with 23 additions and 23 deletions

View File

@ -47,6 +47,8 @@
#include <osmocom/bb/common/lapdm.h> #include <osmocom/bb/common/lapdm.h>
#include <osmocom/bb/common/logging.h> #include <osmocom/bb/common/logging.h>
extern struct gsmtap_inst *gsmtap_inst;
static struct msgb *osmo_l1_alloc(uint8_t msg_type) static struct msgb *osmo_l1_alloc(uint8_t msg_type)
{ {
struct l1ctl_hdr *l1h; struct l1ctl_hdr *l1h;
@ -214,9 +216,9 @@ printf("Dropping frame with %u bit errors\n", dl->num_biterr);
/* send CCCH data via GSMTAP */ /* send CCCH data via GSMTAP */
gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, dl->link_id); gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, dl->link_id);
gsmtap_sendmsg(ntohs(dl->band_arfcn), chan_ts, gsmtap_chan_type, chan_ss, gsmtap_send(gsmtap_inst, ntohs(dl->band_arfcn), chan_ts,
tm.fn, dl->rx_level-110, dl->snr, ccch->data, gsmtap_chan_type, chan_ss, tm.fn, dl->rx_level-110,
sizeof(ccch->data)); dl->snr, ccch->data, sizeof(ccch->data));
/* determine LAPDm entity based on SACCH or not */ /* determine LAPDm entity based on SACCH or not */
if (dl->link_id & 0x40) if (dl->link_id & 0x40)
@ -280,8 +282,8 @@ int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg,
/* send copy via GSMTAP */ /* send copy via GSMTAP */
rsl_dec_chan_nr(chan_nr, &chan_type, &chan_ss, &chan_ts); rsl_dec_chan_nr(chan_nr, &chan_type, &chan_ss, &chan_ts);
gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, link_id); gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, link_id);
gsmtap_sendmsg(0|0x4000, chan_ts, gsmtap_chan_type, chan_ss, gsmtap_send(gsmtap_inst, 0|0x4000, chan_ts, gsmtap_chan_type,
0, 127, 255, msg->l2h, msgb_l2len(msg)); chan_ss, 0, 127, 255, msg->l2h, msgb_l2len(msg));
/* prepend uplink info header */ /* prepend uplink info header */
l1i_ul = (struct l1ctl_info_ul *) msgb_push(msg, sizeof(*l1i_ul)); l1i_ul = (struct l1ctl_info_ul *) msgb_push(msg, sizeof(*l1i_ul));

View File

@ -35,6 +35,7 @@
#include <osmocom/core/select.h> #include <osmocom/core/select.h>
#include <osmocom/core/linuxlist.h> #include <osmocom/core/linuxlist.h>
#include <osmocom/core/gsmtap_util.h> #include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/utils.h> #include <osmocom/core/utils.h>
#include <arpa/inet.h> #include <arpa/inet.h>
@ -50,15 +51,18 @@
struct log_target *stderr_target; struct log_target *stderr_target;
void *l23_ctx = NULL; void *l23_ctx = NULL;
static char *layer2_socket_path = "/tmp/osmocom_l2"; static char *layer2_socket_path = "/tmp/osmocom_l2";
static char *sap_socket_path = "/tmp/osmocom_sap"; static char *sap_socket_path = "/tmp/osmocom_sap";
struct llist_head ms_list; struct llist_head ms_list;
static struct osmocom_ms *ms = NULL; static struct osmocom_ms *ms = NULL;
static uint32_t gsmtap_ip = 0; static char *gsmtap_ip = NULL;
unsigned short vty_port = 4247; unsigned short vty_port = 4247;
int (*l23_app_work) (struct osmocom_ms *ms) = NULL; int (*l23_app_work) (struct osmocom_ms *ms) = NULL;
int (*l23_app_exit) (struct osmocom_ms *ms) = NULL; int (*l23_app_exit) (struct osmocom_ms *ms) = NULL;
int quit = 0; int quit = 0;
struct gsmtap_inst *gsmtap_inst;
const char *openbsc_copyright = const char *openbsc_copyright =
"%s" "%s"
@ -139,7 +143,6 @@ static void build_config(char **opt, struct option **option)
static void handle_options(int argc, char **argv) static void handle_options(int argc, char **argv)
{ {
struct sockaddr_in gsmtap;
struct l23_app_info *app = l23_app_info(); struct l23_app_info *app = l23_app_info();
struct option *long_options; struct option *long_options;
char *opt; char *opt;
@ -170,11 +173,7 @@ static void handle_options(int argc, char **argv)
ms->test_arfcn = atoi(optarg); ms->test_arfcn = atoi(optarg);
break; break;
case 'i': case 'i':
if (!inet_aton(optarg, &gsmtap.sin_addr)) { gsmtap_ip = optarg;
perror("inet_aton");
exit(2);
}
gsmtap_ip = ntohl(gsmtap.sin_addr.s_addr);
break; break;
case 'v': case 'v':
vty_port = atoi(optarg); vty_port = atoi(optarg);
@ -263,11 +262,12 @@ int main(int argc, char **argv)
exit(1); exit(1);
if (gsmtap_ip) { if (gsmtap_ip) {
rc = gsmtap_init(gsmtap_ip); gsmtap_inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);
if (rc < 0) { if (!gsmtap_inst) {
fprintf(stderr, "Failed during gsmtap_init()\n"); fprintf(stderr, "Failed during gsmtap_init()\n");
exit(1); exit(1);
} }
gsmtap_source_add_sink(gsmtap_inst);
} }
signal(SIGINT, sighandler); signal(SIGINT, sighandler);

View File

@ -28,6 +28,7 @@
#include <osmocom/core/talloc.h> #include <osmocom/core/talloc.h>
#include <osmocom/core/linuxlist.h> #include <osmocom/core/linuxlist.h>
#include <osmocom/core/gsmtap_util.h> #include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/signal.h> #include <osmocom/core/signal.h>
#include <arpa/inet.h> #include <arpa/inet.h>
@ -48,7 +49,8 @@ struct log_target *stderr_target;
void *l23_ctx = NULL; void *l23_ctx = NULL;
struct llist_head ms_list; struct llist_head ms_list;
static uint32_t gsmtap_ip = 0; static char *gsmtap_ip = 0;
struct gsmtap_inst *gsmtap_inst = NULL;
unsigned short vty_port = 4247; unsigned short vty_port = 4247;
int debug_set = 0; int debug_set = 0;
char *config_dir = NULL; char *config_dir = NULL;
@ -85,7 +87,6 @@ static void print_help()
static void handle_options(int argc, char **argv) static void handle_options(int argc, char **argv)
{ {
struct sockaddr_in gsmtap;
while (1) { while (1) {
int option_index = 0, c; int option_index = 0, c;
static struct option long_options[] = { static struct option long_options[] = {
@ -108,11 +109,7 @@ static void handle_options(int argc, char **argv)
exit(0); exit(0);
break; break;
case 'i': case 'i':
if (!inet_aton(optarg, &gsmtap.sin_addr)) { gsmtap_ip = optarg;
perror("inet_aton");
exit(2);
}
gsmtap_ip = ntohl(gsmtap.sin_addr.s_addr);
break; break;
case 'v': case 'v':
vty_port = atoi(optarg); vty_port = atoi(optarg);
@ -171,11 +168,12 @@ int main(int argc, char **argv)
log_set_log_level(stderr_target, LOGL_INFO); log_set_log_level(stderr_target, LOGL_INFO);
if (gsmtap_ip) { if (gsmtap_ip) {
rc = gsmtap_init(gsmtap_ip); gsmtap_inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);
if (rc < 0) { if (!gsmtap_inst) {
fprintf(stderr, "Failed during gsmtap_init()\n"); fprintf(stderr, "Failed during gsmtap_init()\n");
exit(1); exit(1);
} }
gsmtap_source_add_sink(gsmtap_inst);
} }
home = getenv("HOME"); home = getenv("HOME");