blob: 36cbf5321b6cc1817e1f4b815cc9aecd18274bde [file] [log] [blame]
Harald Weltee779c362010-06-29 20:51:13 +02001#ifndef _GSMTAP_UTIL_H
2#define _GSMTAP_UTIL_H
3
4#include <stdint.h>
Harald Welte33cb71a2011-05-21 18:54:32 +02005#include <osmocom/core/write_queue.h>
6#include <osmocom/core/select.h>
Harald Weltee779c362010-06-29 20:51:13 +02007
Harald Welte47379ca2011-08-17 16:35:24 +02008/*! \defgroup gsmtap GSMTAP
9 * @{
10 */
11/*! \file gsmtap_util.h */
12
Harald Weltee779c362010-06-29 20:51:13 +020013uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id);
14
Harald Weltee34a9402010-06-29 22:31:21 +020015struct msgb *gsmtap_makemsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type,
16 uint8_t ss, uint32_t fn, int8_t signal_dbm,
17 uint8_t snr, const uint8_t *data, unsigned int len);
18
Harald Welte47379ca2011-08-17 16:35:24 +020019/*! \brief one gsmtap instance */
Harald Welte33cb71a2011-05-21 18:54:32 +020020struct gsmtap_inst {
Harald Welte47379ca2011-08-17 16:35:24 +020021 int ofd_wq_mode; /*!< \brief wait queue mode? */
22 struct osmo_wqueue wq; /*!< \brief the wait queue */
23 struct osmo_fd sink_ofd;/*!< \brief file descriptor */
Harald Welte33cb71a2011-05-21 18:54:32 +020024};
Harald Weltee779c362010-06-29 20:51:13 +020025
Harald Welte47379ca2011-08-17 16:35:24 +020026/*! \brief obtain the file descriptor associated with a gsmtap instance */
Harald Welte33cb71a2011-05-21 18:54:32 +020027static inline int gsmtap_inst_fd(struct gsmtap_inst *gti)
28{
29 return gti->wq.bfd.fd;
30}
Harald Weltee779c362010-06-29 20:51:13 +020031
Harald Welte33cb71a2011-05-21 18:54:32 +020032int gsmtap_source_init_fd(const char *host, uint16_t port);
33
Harald Welte33cb71a2011-05-21 18:54:32 +020034int gsmtap_source_add_sink_fd(int gsmtap_fd);
35
Harald Welte33cb71a2011-05-21 18:54:32 +020036struct gsmtap_inst *gsmtap_source_init(const char *host, uint16_t port,
37 int ofd_wq_mode);
38
Harald Welte33cb71a2011-05-21 18:54:32 +020039int gsmtap_source_add_sink(struct gsmtap_inst *gti);
40
Harald Welte33cb71a2011-05-21 18:54:32 +020041int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg);
42
Harald Welte33cb71a2011-05-21 18:54:32 +020043int gsmtap_send(struct gsmtap_inst *gti, uint16_t arfcn, uint8_t ts,
44 uint8_t chan_type, uint8_t ss, uint32_t fn,
45 int8_t signal_dbm, uint8_t snr, const uint8_t *data,
46 unsigned int len);
Harald Welted58ba462011-04-27 10:57:49 +020047
Harald Weltee779c362010-06-29 20:51:13 +020048#endif /* _GSMTAP_UTIL_H */