libosmo-trx 1.8.0.50-7f5e
Osmocom TRX protocol (TRXC/TRXD) library
ep.h
Go to the documentation of this file.
1
3#pragma once
4
5#include <stdint.h>
6#include <stdbool.h>
7
8#include <osmocom/trx/trxc.h>
9#include <osmocom/trx/trxd.h>
10
15struct osmo_trx_ep;
16
25};
26
27/* Decoded RX handlers: to avoid indirect calls on the hot path, these are
28 * plain function prototypes the API user implements (link-time binding,
29 * like bts_model_*() in osmo-bts), not function pointers. The library
30 * provides weak default stubs (logging an error), so an application only
31 * needs to implement the handlers for the directions it consumes. */
32
37extern void osmo_trx_ep_rx_clck_ind(struct osmo_trx_ep *ep, uint32_t fn);
38
46extern void osmo_trx_ep_rx_ctrl_msg(struct osmo_trx_ep *ep, unsigned int chan,
47 const struct osmo_trxc_msg *msg);
48
55extern void osmo_trx_ep_rx_burst_ind(struct osmo_trx_ep *ep, unsigned int chan,
56 const struct osmo_trxd_burst_ind *bi);
57
64extern void osmo_trx_ep_rx_burst_req(struct osmo_trx_ep *ep, unsigned int chan,
65 const struct osmo_trxd_burst_req *br);
66
67struct osmo_trx_ep *osmo_trx_ep_alloc(void *ctx, unsigned int num_chans);
68int osmo_trx_ep_open(struct osmo_trx_ep *ep);
69void osmo_trx_ep_close(struct osmo_trx_ep *ep);
70void osmo_trx_ep_free(struct osmo_trx_ep *ep);
71bool osmo_trx_ep_is_open(const struct osmo_trx_ep *ep);
72bool osmo_trx_ep_is_closing(const struct osmo_trx_ep *ep);
73
76typedef void (*osmo_trx_ep_closed_cb_t)(struct osmo_trx_ep *ep);
78
79void osmo_trx_ep_set_priv(struct osmo_trx_ep *ep, void *priv);
80void *osmo_trx_ep_get_priv(const struct osmo_trx_ep *ep);
81int osmo_trx_ep_set_name(struct osmo_trx_ep *ep, const char *fmt, ...);
82const char *osmo_trx_ep_get_name(const struct osmo_trx_ep *ep);
83void osmo_trx_ep_set_log_cat(struct osmo_trx_ep *ep, int log_cat);
84int osmo_trx_ep_set_num_chans(struct osmo_trx_ep *ep, unsigned int num_chans);
85unsigned int osmo_trx_ep_get_num_chans(const struct osmo_trx_ep *ep);
86
89
91int osmo_trx_ep_set_laddr(struct osmo_trx_ep *ep, const char *addr);
92const char *osmo_trx_ep_get_laddr(const struct osmo_trx_ep *ep);
93int osmo_trx_ep_set_raddr(struct osmo_trx_ep *ep, const char *addr);
94const char *osmo_trx_ep_get_raddr(const struct osmo_trx_ep *ep);
95
102int osmo_trx_ep_set_base_port(struct osmo_trx_ep *ep, uint16_t base_port);
103uint16_t osmo_trx_ep_get_base_port(const struct osmo_trx_ep *ep);
104
106int osmo_trx_ep_set_clock_socket(struct osmo_trx_ep *ep, bool enable);
107bool osmo_trx_ep_get_clock_socket(const struct osmo_trx_ep *ep);
108
110int osmo_trx_ep_set_ctrl_promisc(struct osmo_trx_ep *ep, bool enable);
111bool osmo_trx_ep_get_ctrl_promisc(const struct osmo_trx_ep *ep);
112
113void osmo_trx_ep_set_pdu_batch(struct osmo_trx_ep *ep, bool enable);
114bool osmo_trx_ep_get_pdu_batch(const struct osmo_trx_ep *ep);
115
117int osmo_trx_ep_set_pdu_ver(struct osmo_trx_ep *ep, unsigned int chan, uint8_t ver);
118int osmo_trx_ep_get_pdu_ver(const struct osmo_trx_ep *ep, unsigned int chan);
119
120/* TX paths (encode + transmit) */
121int osmo_trx_ep_send_clck_ind(struct osmo_trx_ep *ep, uint32_t fn);
122int osmo_trx_ep_send_ctrl_msg(struct osmo_trx_ep *ep, unsigned int chan,
123 const struct osmo_trxc_msg *msg);
124int osmo_trx_ep_send_burst_ind(struct osmo_trx_ep *ep, unsigned int chan,
125 const struct osmo_trxd_burst_ind *bi);
126int osmo_trx_ep_send_burst_req(struct osmo_trx_ep *ep, unsigned int chan,
127 const struct osmo_trxd_burst_req *br);
128int osmo_trx_ep_send_burst_fin(struct osmo_trx_ep *ep, unsigned int chan);
int osmo_trx_ep_set_clock_socket(struct osmo_trx_ep *ep, bool enable)
Open the clock socket (base port + 0); default: false.
Definition: trx_ep.c:765
bool osmo_trx_ep_get_clock_socket(const struct osmo_trx_ep *ep)
Whether the clock socket is enabled.
Definition: trx_ep.c:778
int osmo_trx_ep_open(struct osmo_trx_ep *ep)
Open the clock/ctrl/data sockets of the given endpoint.
Definition: trx_ep.c:529
const char * osmo_trx_ep_get_name(const struct osmo_trx_ep *ep)
Obtain the name (log prefix) of the given instance.
Definition: trx_ep.c:845
struct osmo_trx_ep * osmo_trx_ep_alloc(void *ctx, unsigned int num_chans)
Allocate a TRX endpoint instance.
Definition: trx_ep.c:501
bool osmo_trx_ep_get_ctrl_promisc(const struct osmo_trx_ep *ep)
Whether promiscuous ctrl socket mode is enabled.
Definition: trx_ep.c:801
void osmo_trx_ep_close(struct osmo_trx_ep *ep)
Close all sockets of the given endpoint.
Definition: trx_ep.c:575
unsigned int osmo_trx_ep_get_num_chans(const struct osmo_trx_ep *ep)
Obtain the number of channels.
Definition: trx_ep.c:660
void osmo_trx_ep_rx_burst_ind(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxd_burst_ind *bi)
Handle a received burst indication (OSMO_TRX_EP_MODE_L1 only).
osmo_trx_ep_mode
Endpoint mode: which side of the TRX protocol this endpoint implements.
Definition: ep.h:20
@ OSMO_TRX_EP_MODE_TRX
TRX side (e.g.
Definition: ep.h:24
@ OSMO_TRX_EP_MODE_L1
L1 side (e.g.
Definition: ep.h:22
const char * osmo_trx_ep_get_raddr(const struct osmo_trx_ep *ep)
Obtain the remote IP address.
Definition: trx_ep.c:743
bool osmo_trx_ep_is_closing(const struct osmo_trx_ep *ep)
Whether a ctrl socket from a previous osmo_trx_ep_close() is still flushing a queued TRXC message in ...
Definition: trx_ep.c:630
int osmo_trx_ep_set_mode(struct osmo_trx_ep *ep, enum osmo_trx_ep_mode mode)
Set the endpoint mode (default: OSMO_TRX_EP_MODE_L1)
Definition: trx_ep.c:699
void osmo_trx_ep_set_closed_cb(struct osmo_trx_ep *ep, osmo_trx_ep_closed_cb_t closed_cb)
Set the call-back invoked once osmo_trx_ep_close() has fully completed: immediately if no ctrl chan n...
Definition: trx_ep.c:642
void osmo_trx_ep_rx_clck_ind(struct osmo_trx_ep *ep, uint32_t fn)
Handle a received clock indication ("IND CLOCK <fn>").
void osmo_trx_ep_set_pdu_batch(struct osmo_trx_ep *ep, bool enable)
Enable/disable batching BURST.ind/req PDUs on the data sockets (default: true): when enabled and TRXD...
Definition: trx_ep.c:812
int osmo_trx_ep_send_burst_ind(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxd_burst_ind *bi)
Send a burst indication on the data socket of the given channel (OSMO_TRX_EP_MODE_TRX only).
Definition: trx_ep.c:964
int osmo_trx_ep_send_burst_req(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxd_burst_req *br)
Send a burst transmit request on the data socket of the given channel (OSMO_TRX_EP_MODE_L1 only).
Definition: trx_ep.c:1008
bool osmo_trx_ep_is_open(const struct osmo_trx_ep *ep)
Whether the endpoint's sockets are currently open.
Definition: trx_ep.c:623
void * osmo_trx_ep_get_priv(const struct osmo_trx_ep *ep)
Obtain the application-private data.
Definition: trx_ep.c:654
void osmo_trx_ep_rx_ctrl_msg(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxc_msg *msg)
Handle a received TRXC message (CMD on the TRX side, RSP on the L1 side).
enum osmo_trx_ep_mode osmo_trx_ep_get_mode(const struct osmo_trx_ep *ep)
Obtain the endpoint mode.
Definition: trx_ep.c:709
int osmo_trx_ep_send_burst_fin(struct osmo_trx_ep *ep, unsigned int chan)
Flush the TRXDv2 batching buffer accumulated by osmo_trx_ep_send_burst_ind() or osmo_trx_ep_send_burs...
Definition: trx_ep.c:1050
uint16_t osmo_trx_ep_get_base_port(const struct osmo_trx_ep *ep)
Obtain the base UDP port.
Definition: trx_ep.c:759
int osmo_trx_ep_set_base_port(struct osmo_trx_ep *ep, uint16_t base_port)
Base UDP port (default: 5700).
Definition: trx_ep.c:749
int osmo_trx_ep_set_pdu_ver(struct osmo_trx_ep *ep, unsigned int chan, uint8_t ver)
Per-channel TRXD PDU version in use (set after SETFORMAT negotiation)
Definition: trx_ep.c:858
int osmo_trx_ep_send_ctrl_msg(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxc_msg *msg)
Send a TRXC message on the ctrl socket of the given channel.
Definition: trx_ep.c:909
int osmo_trx_ep_set_num_chans(struct osmo_trx_ep *ep, unsigned int num_chans)
Change the number of channels; only valid before osmo_trx_ep_open().
Definition: trx_ep.c:670
int osmo_trx_ep_set_ctrl_promisc(struct osmo_trx_ep *ep, bool enable)
Unconnected ctrl socket accepting/replying to any peer; default: false.
Definition: trx_ep.c:788
void osmo_trx_ep_rx_burst_req(struct osmo_trx_ep *ep, unsigned int chan, const struct osmo_trxd_burst_req *br)
Handle a received burst transmit request (OSMO_TRX_EP_MODE_TRX only).
void osmo_trx_ep_set_priv(struct osmo_trx_ep *ep, void *priv)
Set the application-private data.
Definition: trx_ep.c:648
int osmo_trx_ep_send_clck_ind(struct osmo_trx_ep *ep, uint32_t fn)
Send a clock indication ("IND CLOCK <fn>") on the clock socket.
Definition: trx_ep.c:885
bool osmo_trx_ep_get_pdu_batch(const struct osmo_trx_ep *ep)
Whether batching BURST.ind/req PDUs on the data sockets is enabled.
Definition: trx_ep.c:821
void osmo_trx_ep_set_log_cat(struct osmo_trx_ep *ep, int log_cat)
Set the logging category (e.g.
Definition: trx_ep.c:851
int osmo_trx_ep_set_raddr(struct osmo_trx_ep *ep, const char *addr)
Set the remote IP address (copied)
Definition: trx_ep.c:732
int osmo_trx_ep_set_name(struct osmo_trx_ep *ep, const char *fmt,...)
Set the name (log prefix) of the given instance, e.g.
Definition: trx_ep.c:827
int osmo_trx_ep_set_laddr(struct osmo_trx_ep *ep, const char *addr)
Local/remote IP address (copied); must be set before osmo_trx_ep_open()
Definition: trx_ep.c:715
int osmo_trx_ep_get_pdu_ver(const struct osmo_trx_ep *ep, unsigned int chan)
Get the TRXD PDU version in use for the given channel.
Definition: trx_ep.c:871
const char * osmo_trx_ep_get_laddr(const struct osmo_trx_ep *ep)
Obtain the local IP address.
Definition: trx_ep.c:726
void osmo_trx_ep_free(struct osmo_trx_ep *ep)
Free the given endpoint instance (closes all sockets).
Definition: trx_ep.c:602
void(* osmo_trx_ep_closed_cb_t)(struct osmo_trx_ep *ep)
Called once osmo_trx_ep_close() has fully completed (see osmo_trx_ep_set_closed_cb())
Definition: ep.h:76
Definition: trx_ep.c:89
osmo_trx_ep_closed_cb_t closed_cb
Definition: trx_ep.c:104
void * priv
Definition: trx_ep.c:95
uint16_t base_port
Definition: trx_ep.c:94
enum osmo_trx_ep_mode mode
Definition: trx_ep.c:91
int log_cat
Definition: trx_ep.c:97
unsigned int num_chans
Definition: trx_ep.c:100
A single de-/serialized TRXC message.
Definition: trxc.h:32
TRX -> L1: received burst indication (soft bits + measurements).
Definition: trxd.h:57
L1 -> TRX: burst transmit request (hard bits).
Definition: trxd.h:78
TRXC (control) protocol and clock indications: I/O-free message codec.
TRXD (burst data) protocol: I/O-free PDU codec.