libosmocore 0.9.6-23.20170220git32ee5af8.fc42
Osmocom core library
Loading...
Searching...
No Matches
GSMTAP

Files

file  gsmtap_util.h
 
file  gsmtap_util.c
 

Data Structures

struct  gsmtap_inst
 one gsmtap instance More...
 

Functions

uint8_t chantype_rsl2gsmtap (uint8_t rsl_chantype, uint8_t link_id)
 convert RSL channel number to GSMTAP channel type
 
struct msgbgsmtap_makemsg_ex (uint8_t type, 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)
 create an arbitrary type GSMTAP message
 
struct msgbgsmtap_makemsg (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)
 create L1/L2 data and put it into GSMTAP
 
static int gsmtap_inst_fd (struct gsmtap_inst *gti)
 obtain the file descriptor associated with a gsmtap instance
 
int gsmtap_source_init_fd (const char *host, uint16_t port)
 Create a new (sending) GSMTAP source socket.
 
int gsmtap_source_add_sink_fd (int gsmtap_fd)
 Add a local sink to an existing GSMTAP source and return fd.
 
struct gsmtap_instgsmtap_source_init (const char *host, uint16_t port, int ofd_wq_mode)
 Open GSMTAP source socket, connect and register osmo_fd.
 
int gsmtap_source_add_sink (struct gsmtap_inst *gti)
 Add a local sink to an existing GSMTAP source and return fd.
 
int gsmtap_sendmsg (struct gsmtap_inst *gti, struct msgb *msg)
 Send a Message buffers through a GSMTAP source.
 
int gsmtap_send_ex (struct gsmtap_inst *gti, uint8_t type, 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)
 send an arbitrary type through GSMTAP. See gsmtap_makemsg_ex for arguments
 
int gsmtap_send (struct gsmtap_inst *gti, 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)
 send a message from L1/L2 through GSMTAP. See gsmtap_makemsg for arguments
 
static int gsmtap_wq_w_cb (struct osmo_fd *ofd, struct msgb *msg)
 
static int gsmtap_sink_fd_cb (struct osmo_fd *fd, unsigned int flags)
 

Detailed Description

Function Documentation

◆ chantype_rsl2gsmtap()

uint8_t chantype_rsl2gsmtap ( uint8_t rsl_chantype,
uint8_t link_id )

convert RSL channel number to GSMTAP channel type

Parameters
[in]rsl_chantypeRSL channel type
[in]link_idRSL link identifier
Returns
GSMTAP channel type

◆ gsmtap_inst_fd()

static int gsmtap_inst_fd ( struct gsmtap_inst * gti)
inlinestatic

obtain the file descriptor associated with a gsmtap instance

Parameters
[in]gtiGSMTAP instance
Returns
file descriptor of GSMTAP instance

References osmo_wqueue::bfd, osmo_fd::fd, and gsmtap_inst::wq.

Referenced by gsmtap_sendmsg(), and gsmtap_source_add_sink().

◆ gsmtap_makemsg()

struct msgb * gsmtap_makemsg ( 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 )

create L1/L2 data and put it into GSMTAP

Parameters
[in]arfcnGSM ARFCN (Channel Number)
[in]tsGSM time slot
[in]chan_typeChannel Type
[in]ssSub-slot
[in]fnGSM Frame Number
[in]signal_dbmSignal Strength (dBm)
[in]snrSignal/Noise Ratio (SNR)
[in]dataPointer to data buffer
[in]lenLength of data
Returns
message buffer or NULL in case of error

This function will allocate a new msgb and fill it with a GSMTAP header containing the information

References msgb::data, gsmtap_makemsg_ex(), and msgb::len.

◆ gsmtap_makemsg_ex()

struct msgb * gsmtap_makemsg_ex ( uint8_t type,
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 )

create an arbitrary type GSMTAP message

Parameters
[in]typeThe GSMTAP_TYPE_xxx constant of the message to create
[in]arfcnGSM ARFCN (Channel Number)
[in]tsGSM time slot
[in]chan_typeChannel Type
[in]ssSub-slot
[in]fnGSM Frame Number
[in]signal_dbmSignal Strength (dBm)
[in]snrSignal/Noise Ratio (SNR)
[in]dataPointer to data buffer
[in]lenLength of data
Returns
dynamically allocated message buffer containing data

This function will allocate a new msgb and fill it with a GSMTAP header containing the information

References gsmtap_hdr::antenna_nr, gsmtap_hdr::arfcn, gsmtap_hdr::frame_number, gsmtap_hdr::hdr_len, msgb_alloc(), msgb_put(), gsmtap_hdr::signal_dbm, gsmtap_hdr::snr_db, gsmtap_hdr::sub_slot, gsmtap_hdr::sub_type, gsmtap_hdr::timeslot, gsmtap_hdr::type, and gsmtap_hdr::version.

Referenced by gsmtap_makemsg(), and gsmtap_send_ex().

◆ gsmtap_sendmsg()

int gsmtap_sendmsg ( struct gsmtap_inst * gti,
struct msgb * msg )

Send a Message buffers through a GSMTAP source.

Parameters
[in]gtiGSMTAP instance
[in]msgmessage buffer
Returns
0 in case of success; negative in case of error

References msgb::data, gsmtap_inst_fd(), msgb::len, msgb_free(), gsmtap_inst::ofd_wq_mode, osmo_wqueue_enqueue(), and gsmtap_inst::wq.

Referenced by gsmtap_send_ex().

◆ gsmtap_source_add_sink()

int gsmtap_source_add_sink ( struct gsmtap_inst * gti)

Add a local sink to an existing GSMTAP source and return fd.

Parameters
[in]gsmtap_fdfile descriptor of the gsmtap socket
Returns
file descriptor of locally bound receive socket

In case the GSMTAP socket is connected to a local destination IP/port, this function creates a corresponding receiving socket bound to that destination IP + port.

In case the gsmtap socket is not connected to a local IP/port, or creation of the receiving socket fails, a negative error code is returned.

The file descriptor of the receiving socket is automatically added to the libosmocore select() handling.

References BSC_FD_READ, osmo_fd::cb, osmo_fd::fd, gsmtap_inst_fd(), gsmtap_source_add_sink_fd(), gsmtap_inst::ofd_wq_mode, osmo_fd_register(), gsmtap_inst::sink_ofd, and osmo_fd::when.

Referenced by log_target_create_gsmtap().

◆ gsmtap_source_add_sink_fd()

int gsmtap_source_add_sink_fd ( int gsmtap_fd)

Add a local sink to an existing GSMTAP source and return fd.

Parameters
[in]gsmtap_fdfile descriptor of the gsmtap socket
Returns
file descriptor of locally bound receive socket

In case the GSMTAP socket is connected to a local destination IP/port, this function creates a corresponding receiving socket bound to that destination IP + port.

In case the gsmtap socket is not connected to a local IP/port, or creation of the receiving socket fails, a negative error code is returned.

References OSMO_SOCK_F_BIND, osmo_sock_init_sa(), and osmo_sockaddr_is_local().

Referenced by gsmtap_source_add_sink().

◆ gsmtap_source_init()

struct gsmtap_inst * gsmtap_source_init ( const char * host,
uint16_t port,
int ofd_wq_mode )

Open GSMTAP source socket, connect and register osmo_fd.

Parameters
[in]hosthost name or IP address in string format
[in]portUDP port number in host byte order
[in]ofd_wq_modeRegister osmo_wqueue (1) or not (0)
Returns
callee-allocated gsmtap_inst

Open GSMTAP source (sending) socket, connect it to host/port, allocate 'struct gsmtap_inst' and optionally osmo_fd/osmo_wqueue registration. This means it is like gsmtap_init2 but integrated with libosmocore Select loop abstraction

References osmo_wqueue::bfd, osmo_fd::fd, gsmtap_source_init_fd(), gsmtap_inst::ofd_wq_mode, osmo_fd_register(), osmo_wqueue_init(), gsmtap_inst::sink_ofd, gsmtap_inst::wq, and osmo_wqueue::write_cb.

Referenced by log_target_create_gsmtap().

◆ gsmtap_source_init_fd()

int gsmtap_source_init_fd ( const char * host,
uint16_t port )

Create a new (sending) GSMTAP source socket.

Parameters
[in]hosthost name or IP address in string format
[in]portUDP port number in host byte order
Returns
file descriptor of the new socket

Opens a GSMTAP source (sending) socket, conncet it to host/port and return resulting fd. If host is NULL, the destination address will be localhost. If port is 0, the default GSMTAP_UDP_PORT will be used.

References OSMO_SOCK_F_CONNECT, and osmo_sock_init().

Referenced by gsmtap_source_init().