Harald Welte | e779c36 | 2010-06-29 20:51:13 +0200 | [diff] [blame] | 1 | #ifndef _GSMTAP_UTIL_H |
| 2 | #define _GSMTAP_UTIL_H |
| 3 | |
| 4 | #include <stdint.h> |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 5 | #include <osmocom/core/write_queue.h> |
| 6 | #include <osmocom/core/select.h> |
Harald Welte | e779c36 | 2010-06-29 20:51:13 +0200 | [diff] [blame] | 7 | |
Harald Welte | 47379ca | 2011-08-17 16:35:24 +0200 | [diff] [blame] | 8 | /*! \defgroup gsmtap GSMTAP |
| 9 | * @{ |
| 10 | */ |
| 11 | /*! \file gsmtap_util.h */ |
| 12 | |
Harald Welte | e779c36 | 2010-06-29 20:51:13 +0200 | [diff] [blame] | 13 | uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id); |
| 14 | |
Sylvain Munaut | 15ae715 | 2011-09-26 13:05:07 +0200 | [diff] [blame] | 15 | struct msgb *gsmtap_makemsg_ex(uint8_t type, 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 Welte | e34a940 | 2010-06-29 22:31:21 +0200 | [diff] [blame] | 19 | struct msgb *gsmtap_makemsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, |
| 20 | uint8_t ss, uint32_t fn, int8_t signal_dbm, |
| 21 | uint8_t snr, const uint8_t *data, unsigned int len); |
| 22 | |
Harald Welte | 47379ca | 2011-08-17 16:35:24 +0200 | [diff] [blame] | 23 | /*! \brief one gsmtap instance */ |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 24 | struct gsmtap_inst { |
Harald Welte | 47379ca | 2011-08-17 16:35:24 +0200 | [diff] [blame] | 25 | int ofd_wq_mode; /*!< \brief wait queue mode? */ |
| 26 | struct osmo_wqueue wq; /*!< \brief the wait queue */ |
| 27 | struct osmo_fd sink_ofd;/*!< \brief file descriptor */ |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 28 | }; |
Harald Welte | e779c36 | 2010-06-29 20:51:13 +0200 | [diff] [blame] | 29 | |
Harald Welte | 47379ca | 2011-08-17 16:35:24 +0200 | [diff] [blame] | 30 | /*! \brief obtain the file descriptor associated with a gsmtap instance */ |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 31 | static inline int gsmtap_inst_fd(struct gsmtap_inst *gti) |
| 32 | { |
| 33 | return gti->wq.bfd.fd; |
| 34 | } |
Harald Welte | e779c36 | 2010-06-29 20:51:13 +0200 | [diff] [blame] | 35 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 36 | int gsmtap_source_init_fd(const char *host, uint16_t port); |
| 37 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 38 | int gsmtap_source_add_sink_fd(int gsmtap_fd); |
| 39 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 40 | struct gsmtap_inst *gsmtap_source_init(const char *host, uint16_t port, |
| 41 | int ofd_wq_mode); |
| 42 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 43 | int gsmtap_source_add_sink(struct gsmtap_inst *gti); |
| 44 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 45 | int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg); |
| 46 | |
Sylvain Munaut | 15ae715 | 2011-09-26 13:05:07 +0200 | [diff] [blame] | 47 | int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_t ts, |
| 48 | uint8_t chan_type, uint8_t ss, uint32_t fn, |
| 49 | int8_t signal_dbm, uint8_t snr, const uint8_t *data, |
| 50 | unsigned int len); |
| 51 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 52 | int gsmtap_send(struct gsmtap_inst *gti, uint16_t arfcn, uint8_t ts, |
| 53 | uint8_t chan_type, uint8_t ss, uint32_t fn, |
| 54 | int8_t signal_dbm, uint8_t snr, const uint8_t *data, |
| 55 | unsigned int len); |
Harald Welte | d58ba46 | 2011-04-27 10:57:49 +0200 | [diff] [blame] | 56 | |
Katerina Barone-Adesi | c28c6a0 | 2013-02-15 13:27:59 +0100 | [diff] [blame] | 57 | /*! @} */ |
| 58 | |
Harald Welte | e779c36 | 2010-06-29 20:51:13 +0200 | [diff] [blame] | 59 | #endif /* _GSMTAP_UTIL_H */ |