libosmo-netif
1.4.0.19-26cd.202401052026
Osmocom network interface library
|
Files | |
file | stream.c |
Osmocom stream socket helpers. | |
file | stream_cli.c |
Osmocom stream socket helpers (client side) | |
file | stream_srv.c |
Osmocom stream socket helpers (server side) | |
Data Structures | |
struct | osmo_stream_cli |
struct | osmo_stream_srv_link |
struct | osmo_stream_srv |
Macros | |
#define | OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION 0x80 /* sctp_recvmsg() flags=MSG_NOTIFICATION, msgb_data() contains "union sctp_notification*" */ |
Access SCTP flags from the msgb control buffer. | |
#define | msgb_sctp_msg_flags(msg) (msg)->cb[2] |
#define | msgb_sctp_ppid(msg) (msg)->cb[3] |
Access the SCTP PPID from the msgb control buffer. | |
#define | msgb_sctp_stream(msg) (msg)->cb[4] |
Access the SCTP Stream ID from the msgb control buffer. | |
#define | LOGSCLI(cli, level, fmt, args...) |
#define | OSMO_STREAM_CLI_F_RECONF (1 << 0) |
#define | OSMO_STREAM_CLI_F_NODELAY (1 << 1) |
#define | LOGSLNK(link, level, fmt, args...) |
#define | LOGSSRV(srv, level, fmt, args...) |
#define | OSMO_STREAM_SRV_F_RECONF (1 << 0) |
#define | OSMO_STREAM_SRV_F_NODELAY (1 << 1) |
#define | OSMO_STREAM_SRV_F_FLUSH_DESTROY (1 << 0) |
Functions | |
struct osmo_stream_srv_link * | osmo_stream_srv_link_create (void *ctx) |
Create an Osmocom Stream Server Link A Stream Server Link is the listen()+accept() "parent" to individual Stream Servers. More... | |
void | osmo_stream_srv_link_destroy (struct osmo_stream_srv_link *link) |
Destroy the stream server link. Closes + Releases Memory. More... | |
void | osmo_stream_srv_link_set_name (struct osmo_stream_srv_link *link, const char *name) |
Set a name on the srv_link object (used during logging) More... | |
void | osmo_stream_srv_link_set_nodelay (struct osmo_stream_srv_link *link, bool nodelay) |
Set the NODELAY socket option to avoid Nagle-like behavior Setting this to nodelay=true will automatically set the NODELAY socket option on any socket established via this server link, before calling the accept_cb() More... | |
void | osmo_stream_srv_link_set_addr (struct osmo_stream_srv_link *link, const char *addr) |
Set the local address to which we bind. More... | |
int | osmo_stream_srv_link_set_addrs (struct osmo_stream_srv_link *link, const char **addr, size_t addrcnt) |
Set the local address set to which we bind. Useful for protocols allowing bind on more than one address (such as SCTP) More... | |
void | osmo_stream_srv_link_set_port (struct osmo_stream_srv_link *link, uint16_t port) |
Set the local port number to which we bind. More... | |
void | osmo_stream_srv_link_set_proto (struct osmo_stream_srv_link *link, uint16_t proto) |
Set the protocol for the stream server link. More... | |
int | osmo_stream_srv_link_set_type (struct osmo_stream_srv_link *link, int type) |
Set the socket type for the stream server link. More... | |
int | osmo_stream_srv_link_set_domain (struct osmo_stream_srv_link *link, int domain) |
Set the socket type for the stream server link. More... | |
void | osmo_stream_srv_link_set_accept_cb (struct osmo_stream_srv_link *link, int(*accept_cb)(struct osmo_stream_srv_link *link, int fd)) |
Set the accept() call-back of the stream server link. More... | |
void | osmo_stream_srv_link_set_data (struct osmo_stream_srv_link *link, void *data) |
Set application private data of the stream server link. More... | |
void * | osmo_stream_srv_link_get_data (struct osmo_stream_srv_link *link) |
Get application private data of the stream server link. More... | |
char * | osmo_stream_srv_link_get_sockname (const struct osmo_stream_srv_link *link) |
Get description of the stream server link e. g. 127.0.0.1:1234. More... | |
struct osmo_fd * | osmo_stream_srv_link_get_ofd (struct osmo_stream_srv_link *link) |
Get Osmocom File Descriptor of the stream server link. More... | |
int | osmo_stream_srv_link_get_fd (const struct osmo_stream_srv_link *link) |
Get File Descriptor of the stream server link. More... | |
bool | osmo_stream_srv_link_is_opened (const struct osmo_stream_srv_link *link) |
Check whether the stream server link is opened. More... | |
int | osmo_stream_srv_link_open (struct osmo_stream_srv_link *link) |
Open the stream server link. This actually initializes the underlying socket and binds it to the configured ip/port. More... | |
void | osmo_stream_srv_link_close (struct osmo_stream_srv_link *link) |
Close the stream server link and unregister from select loop Does not destroy the server link, merely closes it! More... | |
int | osmo_stream_srv_link_set_param (struct osmo_stream_srv_link *link, enum osmo_stream_srv_link_param par, void *val, size_t val_len) |
struct osmo_stream_srv * | osmo_stream_srv_create (void *ctx, struct osmo_stream_srv_link *link, int fd, int(*read_cb)(struct osmo_stream_srv *conn), int(*closed_cb)(struct osmo_stream_srv *conn), void *data) |
Create a Stream Server inside the specified link. More... | |
struct osmo_stream_srv * | osmo_stream_srv_create2 (void *ctx, struct osmo_stream_srv_link *link, int fd, void *data) |
Create a Stream Server inside the specified link. More... | |
void | osmo_stream_srv_set_name (struct osmo_stream_srv *conn, const char *name) |
Set a name on the srv object (used during logging) More... | |
void | osmo_stream_srv_set_read_cb (struct osmo_stream_srv *conn, int(*read_cb)(struct osmo_stream_srv *conn, struct msgb *msg)) |
Set the call-back function when data was read from the stream server socket Only for osmo_stream_srv created with osmo_stream_srv_create2() More... | |
void | osmo_stream_srv_set_closed_cb (struct osmo_stream_srv *conn, int(*closed_cb)(struct osmo_stream_srv *conn)) |
Set the call-back function called when the stream server socket was closed. More... | |
void * | osmo_stream_srv_get_data (struct osmo_stream_srv *conn) |
Get application private data of the stream server. More... | |
struct osmo_stream_srv_link * | osmo_stream_srv_get_master (struct osmo_stream_srv *conn) |
Get the master (Link) from a Stream Server. More... | |
const char * | osmo_stream_srv_get_sockname (const struct osmo_stream_srv *conn) |
Get the stream server socket description. More... | |
struct osmo_fd * | osmo_stream_srv_get_ofd (struct osmo_stream_srv *conn) |
Get Osmocom File Descriptor of the stream server. More... | |
int | osmo_stream_srv_get_fd (const struct osmo_stream_srv *conn) |
Get File Descriptor of the stream server. More... | |
void | osmo_stream_srv_destroy (struct osmo_stream_srv *conn) |
Destroy given Stream Server This function closes the Stream Server socket, unregisters from select loop, invokes the connection's closed_cb() callback to allow API users to clean up any associated state they have for this connection, and then de-allocates associated memory. More... | |
void | osmo_stream_srv_set_flush_and_destroy (struct osmo_stream_srv *conn) |
Prepare to send out all pending messages on the connection's Tx queue and then automatically destroy the stream with osmo_stream_srv_destroy(). This function disables queuing of new messages on the connection and also disables reception of new messages on the connection. More... | |
void | osmo_stream_srv_set_data (struct osmo_stream_srv *conn, void *data) |
Set application private data of the stream server. More... | |
void | osmo_stream_srv_set_segmentation_cb (struct osmo_stream_srv *conn, int(*segmentation_cb)(struct msgb *msg)) |
Set the segmentation callback for target osmo_stream_srv structure. The connection has to have been established prior to calling this function. More... | |
void | osmo_stream_srv_send (struct osmo_stream_srv *conn, struct msgb *msg) |
Enqueue data to be sent via an Osmocom stream server. More... | |
int | osmo_stream_srv_recv (struct osmo_stream_srv *conn, struct msgb *msg) |
Receive data via Osmocom stream server. More... | |
void | osmo_stream_srv_clear_tx_queue (struct osmo_stream_srv *conn) |
void | osmo_stream_cli_set_name (struct osmo_stream_cli *cli, const char *name) |
Set a name on the cli object (used during logging) More... | |
void | osmo_stream_cli_set_nodelay (struct osmo_stream_cli *cli, bool nodelay) |
Set the NODELAY socket option to avoid Nagle-like behavior Setting this to nodelay=true will automatically set the NODELAY socket option on any socket established via osmo_stream_cli_open or any re-connect. You have to set this before opening the socket. More... | |
void | osmo_stream_cli_set_addr (struct osmo_stream_cli *cli, const char *addr) |
Set the remote address to which we connect. More... | |
int | osmo_stream_cli_set_addrs (struct osmo_stream_cli *cli, const char **addr, size_t addrcnt) |
Set the remote address set to which we connect. Useful for protocols allowing connecting to more than one address (such as SCTP) More... | |
void | osmo_stream_cli_set_port (struct osmo_stream_cli *cli, uint16_t port) |
Set the remote port number to which we connect. More... | |
int | osmo_stream_cli_set_type (struct osmo_stream_cli *cli, int type) |
Set the socket type for the stream server link. More... | |
int | osmo_stream_cli_set_domain (struct osmo_stream_cli *cli, int domain) |
Set the socket type for the stream server link. More... | |
void | osmo_stream_cli_set_proto (struct osmo_stream_cli *cli, uint16_t proto) |
Set the protocol for the stream client socket. More... | |
void | osmo_stream_cli_set_local_addr (struct osmo_stream_cli *cli, const char *addr) |
Set the local address for the socket (to be bound to) More... | |
int | osmo_stream_cli_set_local_addrs (struct osmo_stream_cli *cli, const char **addr, size_t addrcnt) |
Set the local address set to which we connect. Useful for protocols allowing bind to more than one address (such as SCTP) More... | |
void | osmo_stream_cli_set_local_port (struct osmo_stream_cli *cli, uint16_t port) |
Set the local port number for the socket (to be bound to) More... | |
void | osmo_stream_cli_set_data (struct osmo_stream_cli *cli, void *data) |
Set application private data of the stream client socket. More... | |
void | osmo_stream_cli_set_reconnect_timeout (struct osmo_stream_cli *cli, int timeout) |
Set the reconnect time of the stream client socket. More... | |
void * | osmo_stream_cli_get_data (struct osmo_stream_cli *cli) |
Get application private data of the stream client socket. More... | |
char * | osmo_stream_cli_get_sockname (const struct osmo_stream_cli *cli) |
Get the stream client socket description. More... | |
struct osmo_fd * | osmo_stream_cli_get_ofd (struct osmo_stream_cli *cli) |
Get Osmocom File Descriptor of the stream client socket. More... | |
int | osmo_stream_cli_get_fd (const struct osmo_stream_cli *cli) |
Get file descriptor of the stream client socket. More... | |
void | osmo_stream_cli_set_connect_cb (struct osmo_stream_cli *cli, int(*connect_cb)(struct osmo_stream_cli *cli)) |
Set the call-back function called on connect of the stream client socket. More... | |
void | osmo_stream_cli_set_disconnect_cb (struct osmo_stream_cli *cli, int(*disconnect_cb)(struct osmo_stream_cli *cli)) |
Set the call-back function called on disconnect of the stream client socket. More... | |
void | osmo_stream_cli_set_read_cb (struct osmo_stream_cli *cli, int(*read_cb)(struct osmo_stream_cli *cli)) |
Set the call-back function called to read from the stream client socket This function will configure osmo_stream_cli to use osmo_ofd internally. More... | |
void | osmo_stream_cli_set_read_cb2 (struct osmo_stream_cli *cli, int(*read_cb)(struct osmo_stream_cli *cli, struct msgb *msg)) |
Set the call-back function called to read from the stream client socket This function will configure osmo_stream_cli to use osmo_iofd internally. More... | |
void | osmo_stream_cli_set_segmentation_cb (struct osmo_stream_cli *cli, int(*segmentation_cb)(struct msgb *msg)) |
Set the segmentation callback for the client. More... | |
void | osmo_stream_cli_reconnect (struct osmo_stream_cli *cli) |
Re-connect an Osmocom Stream Client If re-connection is enabled for this client (which is the case unless negative timeout was explicitly set via osmo_stream_cli_set_reconnect_timeout() call), we close any existing connection (if any) and schedule a re-connect timer. | |
bool | osmo_stream_cli_is_connected (struct osmo_stream_cli *cli) |
Check if Osmocom Stream Client is in connected state. More... | |
struct osmo_stream_cli * | osmo_stream_cli_create (void *ctx) |
Create an Osmocom stream client. More... | |
void | osmo_stream_cli_destroy (struct osmo_stream_cli *cli) |
Destroy a Osmocom stream client (includes close) More... | |
int | osmo_stream_cli_open (struct osmo_stream_cli *cli) |
Open connection of an Osmocom stream client By default the client will automatically reconnect after default timeout. To disable this, use osmo_stream_cli_set_reconnect_timeout() before calling this function. More... | |
int | osmo_stream_cli_open2 (struct osmo_stream_cli *cli, int reconnect) |
DEPRECATED: use osmo_stream_cli_set_reconnect_timeout() or osmo_stream_cli_reconnect() instead! Open connection of an Osmocom stream client. More... | |
void | osmo_stream_cli_close (struct osmo_stream_cli *cli) |
Close an Osmocom Stream Client. More... | |
void | osmo_stream_cli_send (struct osmo_stream_cli *cli, struct msgb *msg) |
Enqueue data to be sent via an Osmocom stream client. More... | |
int | osmo_stream_cli_recv (struct osmo_stream_cli *cli, struct msgb *msg) |
Receive data via an Osmocom stream client. More... | |
void | osmo_stream_cli_clear_tx_queue (struct osmo_stream_cli *cli) |
int | osmo_stream_cli_set_param (struct osmo_stream_cli *cli, enum osmo_stream_cli_param par, void *val, size_t val_len) |
int | stream_sctp_sock_activate_events (int fd) |
int | stream_setsockopt_nodelay (int fd, int proto, int on) |
int | stream_sctp_recvmsg_wrapper (int fd, struct msgb *msg, const char *log_pfx) |
static void | osmo_stream_cli_close_iofd (struct osmo_stream_cli *cli) |
static void | osmo_stream_cli_close_ofd (struct osmo_stream_cli *cli) |
static void | osmo_stream_cli_read (struct osmo_stream_cli *cli) |
static int | osmo_stream_cli_write (struct osmo_stream_cli *cli) |
static int | _setsockopt_nosigpipe (struct osmo_stream_cli *cli) |
static void | stream_cli_handle_connecting (struct osmo_stream_cli *cli, int res) |
static int | osmo_stream_cli_fd_cb (struct osmo_fd *ofd, unsigned int what) |
static void | cli_timer_cb (void *data) |
static void | stream_cli_iofd_read_cb (struct osmo_io_fd *iofd, int res, struct msgb *msg) |
static void | stream_cli_iofd_write_cb (struct osmo_io_fd *iofd, int res, struct msgb *msg) |
static void | configure_cli_segmentation_cb (struct osmo_io_fd *iofd, int(*segmentation_cb)(struct msgb *msg)) |
static int | _setsockopt_nosigpipe (struct osmo_stream_srv_link *link, int new_fd) |
static int | osmo_stream_srv_link_ofd_cb (struct osmo_fd *ofd, unsigned int what) |
static char * | get_local_sockname_buf (char *buf, size_t buf_len, int fd, int proto) |
static void | stream_srv_iofd_read_cb (struct osmo_io_fd *iofd, int res, struct msgb *msg) |
static void | stream_srv_iofd_write_cb (struct osmo_io_fd *iofd, int res, struct msgb *msg) |
static int | osmo_stream_srv_read (struct osmo_stream_srv *conn) |
static void | osmo_stream_srv_write (struct osmo_stream_srv *conn) |
static int | osmo_stream_srv_cb (struct osmo_fd *ofd, unsigned int what) |
Variables | |
static const struct value_string | stream_cli_state_names [] |
static struct osmo_io_ops | osmo_stream_cli_ioops |
static struct osmo_io_ops | srv_ioops |
This code is intended to abstract any use of stream-type sockets, such as TCP and SCTP. It offers both server and client side implementations, fully integrated with the libosmocore select loop abstraction.
This code is intended to abstract any use of stream-type sockets, such as TCP and SCTP. It offers client side implementation, fully integrated with the libosmocore select loop abstraction.
This code is intended to abstract any use of stream-type sockets, such as TCP and SCTP. It offers server side implementation, fully integrated with the libosmocore select loop abstraction.
#define LOGSCLI | ( | cli, | |
level, | |||
fmt, | |||
args... | |||
) |
#define LOGSLNK | ( | link, | |
level, | |||
fmt, | |||
args... | |||
) |
#define LOGSSRV | ( | srv, | |
level, | |||
fmt, | |||
args... | |||
) |
void osmo_stream_cli_close | ( | struct osmo_stream_cli * | cli | ) |
Close an Osmocom Stream Client.
[in] | cli | Osmocom Stream Client to be closed We unregister the socket fd from the osmocom select() loop abstraction and close the socket |
Referenced by osmo_stream_cli_destroy(), and osmo_stream_cli_reconnect().
struct osmo_stream_cli * osmo_stream_cli_create | ( | void * | ctx | ) |
Create an Osmocom stream client.
[in] | ctx | talloc context from which to allocate memory This function allocates a new osmo_stream_cli and initializes it with default values (5s reconnect timer, TCP protocol) |
void osmo_stream_cli_destroy | ( | struct osmo_stream_cli * | cli | ) |
Destroy a Osmocom stream client (includes close)
[in] | cli | Stream Client to destroy |
References osmo_stream_cli_close().
void * osmo_stream_cli_get_data | ( | struct osmo_stream_cli * | cli | ) |
Get application private data of the stream client socket.
[in] | cli | Stream Client to modify |
int osmo_stream_cli_get_fd | ( | const struct osmo_stream_cli * | cli | ) |
Get file descriptor of the stream client socket.
[in] | cli | Stream Client of which we want to obtain the file descriptor |
Referenced by osmo_stream_cli_get_sockname().
struct osmo_fd * osmo_stream_cli_get_ofd | ( | struct osmo_stream_cli * | cli | ) |
Get Osmocom File Descriptor of the stream client socket.
[in] | cli | Stream Client to modify |
char * osmo_stream_cli_get_sockname | ( | const struct osmo_stream_cli * | cli | ) |
Get the stream client socket description.
[in] | cli | Stream Client to examine |
References osmo_stream_cli_get_fd().
bool osmo_stream_cli_is_connected | ( | struct osmo_stream_cli * | cli | ) |
Check if Osmocom Stream Client is in connected state.
[in] | cli | Osmocom Stream Client |
int osmo_stream_cli_open | ( | struct osmo_stream_cli * | cli | ) |
Open connection of an Osmocom stream client By default the client will automatically reconnect after default timeout. To disable this, use osmo_stream_cli_set_reconnect_timeout() before calling this function.
[in] | cli | Stream Client to connect |
int osmo_stream_cli_open2 | ( | struct osmo_stream_cli * | cli, |
int | reconnect | ||
) |
DEPRECATED: use osmo_stream_cli_set_reconnect_timeout() or osmo_stream_cli_reconnect() instead! Open connection of an Osmocom stream client.
[in] | cli | Stream Client to connect |
[in] | reconect | 1 if we should not automatically reconnect |
int osmo_stream_cli_recv | ( | struct osmo_stream_cli * | cli, |
struct msgb * | msg | ||
) |
Receive data via an Osmocom stream client.
[in] | cli | Stream Client through which we want to send |
msg | pre-allocate message buffer to which received data is appended |
If conn is an SCTP connection, additional specific considerations shall be taken:
void osmo_stream_cli_send | ( | struct osmo_stream_cli * | cli, |
struct msgb * | msg | ||
) |
Enqueue data to be sent via an Osmocom stream client.
[in] | cli | Stream Client through which we want to send |
[in] | msg | Message buffer to enqueue in transmit queue |
void osmo_stream_cli_set_addr | ( | struct osmo_stream_cli * | cli, |
const char * | addr | ||
) |
Set the remote address to which we connect.
[in] | cli | Stream Client to modify |
[in] | addr | Remote IP address |
References osmo_stream_cli_set_addrs().
int osmo_stream_cli_set_addrs | ( | struct osmo_stream_cli * | cli, |
const char ** | addr, | ||
size_t | addrcnt | ||
) |
Set the remote address set to which we connect. Useful for protocols allowing connecting to more than one address (such as SCTP)
[in] | cli | Stream Client to modify |
[in] | addr | Remote IP address set |
Referenced by osmo_stream_cli_set_addr().
void osmo_stream_cli_set_connect_cb | ( | struct osmo_stream_cli * | cli, |
int(*)(struct osmo_stream_cli *cli) | connect_cb | ||
) |
Set the call-back function called on connect of the stream client socket.
[in] | cli | Stream Client to modify |
[in] | connect_cb | Call-back function to be called upon connect |
void osmo_stream_cli_set_data | ( | struct osmo_stream_cli * | cli, |
void * | data | ||
) |
Set application private data of the stream client socket.
[in] | cli | Stream Client to modify |
[in] | data | User-specific data (available in call-back functions) |
void osmo_stream_cli_set_disconnect_cb | ( | struct osmo_stream_cli * | cli, |
int(*)(struct osmo_stream_cli *cli) | disconnect_cb | ||
) |
Set the call-back function called on disconnect of the stream client socket.
[in] | cli | Stream Client to modify |
[in] | disconnect_cb | Call-back function to be called upon disconnect |
int osmo_stream_cli_set_domain | ( | struct osmo_stream_cli * | cli, |
int | domain | ||
) |
Set the socket type for the stream server link.
[in] | cli | Stream Client to modify |
[in] | type | Socket Domain (like AF_UNSPEC (default for IP), AF_UNIX, AF_INET, ...) |
void osmo_stream_cli_set_local_addr | ( | struct osmo_stream_cli * | cli, |
const char * | addr | ||
) |
Set the local address for the socket (to be bound to)
[in] | cli | Stream Client to modify |
[in] | port | Local host name |
References osmo_stream_cli_set_local_addrs().
int osmo_stream_cli_set_local_addrs | ( | struct osmo_stream_cli * | cli, |
const char ** | addr, | ||
size_t | addrcnt | ||
) |
Set the local address set to which we connect. Useful for protocols allowing bind to more than one address (such as SCTP)
[in] | cli | Stream Client to modify |
[in] | addr | Local IP address set |
Referenced by osmo_stream_cli_set_local_addr().
void osmo_stream_cli_set_local_port | ( | struct osmo_stream_cli * | cli, |
uint16_t | port | ||
) |
Set the local port number for the socket (to be bound to)
[in] | cli | Stream Client to modify |
[in] | port | Local port number |
void osmo_stream_cli_set_name | ( | struct osmo_stream_cli * | cli, |
const char * | name | ||
) |
Set a name on the cli object (used during logging)
[in] | cli | stream_cli whose name is to be set |
[in] | name | the name to be set on cli |
void osmo_stream_cli_set_nodelay | ( | struct osmo_stream_cli * | cli, |
bool | nodelay | ||
) |
Set the NODELAY socket option to avoid Nagle-like behavior Setting this to nodelay=true will automatically set the NODELAY socket option on any socket established via osmo_stream_cli_open or any re-connect. You have to set this before opening the socket.
[in] | cli | Stream client whose sockets are to be configured |
[in] | nodelay | whether to set (true) NODELAY before connect() |
void osmo_stream_cli_set_port | ( | struct osmo_stream_cli * | cli, |
uint16_t | port | ||
) |
Set the remote port number to which we connect.
[in] | cli | Stream Client to modify |
[in] | port | Remote port number |
void osmo_stream_cli_set_proto | ( | struct osmo_stream_cli * | cli, |
uint16_t | proto | ||
) |
Set the protocol for the stream client socket.
[in] | cli | Stream Client to modify |
[in] | proto | Protocol (like IPPROTO_TCP (default), IPPROTO_SCTP, ...) |
void osmo_stream_cli_set_read_cb | ( | struct osmo_stream_cli * | cli, |
int(*)(struct osmo_stream_cli *cli) | read_cb | ||
) |
Set the call-back function called to read from the stream client socket This function will configure osmo_stream_cli to use osmo_ofd internally.
[in] | cli | Stream Client to modify |
[in] | read_cb | Call-back function to be called when we want to read |
void osmo_stream_cli_set_read_cb2 | ( | struct osmo_stream_cli * | cli, |
int(*)(struct osmo_stream_cli *cli, struct msgb *msg) | read_cb | ||
) |
Set the call-back function called to read from the stream client socket This function will configure osmo_stream_cli to use osmo_iofd internally.
[in] | cli | Stream Client to modify |
[in] | read_cb | Call-back function to be called when data was read from the socket |
void osmo_stream_cli_set_reconnect_timeout | ( | struct osmo_stream_cli * | cli, |
int | timeout | ||
) |
Set the reconnect time of the stream client socket.
[in] | cli | Stream Client to modify |
[in] | timeout | Re-connect timeout in seconds or negative value to disable auto-reconnection |
void osmo_stream_cli_set_segmentation_cb | ( | struct osmo_stream_cli * | cli, |
int(*)(struct msgb *msg) | segmentation_cb | ||
) |
Set the segmentation callback for the client.
[in,out] | cli | Stream Client to modify |
[in] | segmentation_cb | Target segmentation callback |
int osmo_stream_cli_set_type | ( | struct osmo_stream_cli * | cli, |
int | type | ||
) |
Set the socket type for the stream server link.
[in] | cli | Stream Client to modify |
[in] | type | Socket Type (like SOCK_STREAM (default), SOCK_SEQPACKET, ...) |
struct osmo_stream_srv * osmo_stream_srv_create | ( | void * | ctx, |
struct osmo_stream_srv_link * | link, | ||
int | fd, | ||
int(*)(struct osmo_stream_srv *conn) | read_cb, | ||
int(*)(struct osmo_stream_srv *conn) | closed_cb, | ||
void * | data | ||
) |
Create a Stream Server inside the specified link.
[in] | ctx | talloc allocation context from which to allocate |
[in] | link | Stream Server Link to which we belong |
[in] | fd | system file descriptor of the new connection |
[in] | read_cb | Call-back to call when the socket is readable |
[in] | closed_cb | Call-back to call when the connection is closed |
[in] | data | User data to save in the new Stream Server struct |
struct osmo_stream_srv * osmo_stream_srv_create2 | ( | void * | ctx, |
struct osmo_stream_srv_link * | link, | ||
int | fd, | ||
void * | data | ||
) |
Create a Stream Server inside the specified link.
[in] | ctx | talloc allocation context from which to allocate |
[in] | link | Stream Server Link to which we belong |
[in] | fd | system file descriptor of the new connection |
[in] | data | User data to save in the new Stream Server struct |
void osmo_stream_srv_destroy | ( | struct osmo_stream_srv * | conn | ) |
Destroy given Stream Server This function closes the Stream Server socket, unregisters from select loop, invokes the connection's closed_cb() callback to allow API users to clean up any associated state they have for this connection, and then de-allocates associated memory.
[in] | conn | Stream Server to be destroyed |
void * osmo_stream_srv_get_data | ( | struct osmo_stream_srv * | conn | ) |
Get application private data of the stream server.
[in] | conn | Stream Server |
int osmo_stream_srv_get_fd | ( | const struct osmo_stream_srv * | conn | ) |
Get File Descriptor of the stream server.
[in] | conn | Stream Server |
Referenced by osmo_stream_srv_get_sockname().
struct osmo_stream_srv_link * osmo_stream_srv_get_master | ( | struct osmo_stream_srv * | conn | ) |
Get the master (Link) from a Stream Server.
[in] | conn | Stream Server of which we want to know the Link |
struct osmo_fd * osmo_stream_srv_get_ofd | ( | struct osmo_stream_srv * | conn | ) |
Get Osmocom File Descriptor of the stream server.
[in] | conn | Stream Server |
const char * osmo_stream_srv_get_sockname | ( | const struct osmo_stream_srv * | conn | ) |
Get the stream server socket description.
[in] | cli | Stream Server to examine |
References osmo_stream_srv_get_fd().
void osmo_stream_srv_link_close | ( | struct osmo_stream_srv_link * | link | ) |
Close the stream server link and unregister from select loop Does not destroy the server link, merely closes it!
[in] | link | Stream Server Link to close |
References osmo_stream_srv_link_is_opened().
Referenced by osmo_stream_srv_link_destroy().
struct osmo_stream_srv_link * osmo_stream_srv_link_create | ( | void * | ctx | ) |
Create an Osmocom Stream Server Link A Stream Server Link is the listen()+accept() "parent" to individual Stream Servers.
[in] | ctx | talloc allocation context |
void osmo_stream_srv_link_destroy | ( | struct osmo_stream_srv_link * | link | ) |
Destroy the stream server link. Closes + Releases Memory.
[in] | link | Stream Server Link |
References osmo_stream_srv_link_close().
void * osmo_stream_srv_link_get_data | ( | struct osmo_stream_srv_link * | link | ) |
Get application private data of the stream server link.
[in] | link | Stream Server Link to modify |
int osmo_stream_srv_link_get_fd | ( | const struct osmo_stream_srv_link * | link | ) |
Get File Descriptor of the stream server link.
[in] | conn | Stream Server Link |
struct osmo_fd * osmo_stream_srv_link_get_ofd | ( | struct osmo_stream_srv_link * | link | ) |
Get Osmocom File Descriptor of the stream server link.
[in] | link | Stream Server Link |
char * osmo_stream_srv_link_get_sockname | ( | const struct osmo_stream_srv_link * | link | ) |
Get description of the stream server link e. g. 127.0.0.1:1234.
[in] | link | Stream Server Link to examine |
bool osmo_stream_srv_link_is_opened | ( | const struct osmo_stream_srv_link * | link | ) |
Check whether the stream server link is opened.
[in] | link | Stream Server Link to check |
Referenced by osmo_stream_srv_link_close().
int osmo_stream_srv_link_open | ( | struct osmo_stream_srv_link * | link | ) |
Open the stream server link. This actually initializes the underlying socket and binds it to the configured ip/port.
[in] | link | Stream Server Link to open |
void osmo_stream_srv_link_set_accept_cb | ( | struct osmo_stream_srv_link * | link, |
int(*)(struct osmo_stream_srv_link *link, int fd) | accept_cb | ||
) |
Set the accept() call-back of the stream server link.
[in] | link | Stream Server Link |
[in] | accept_cb | Call-back function executed upon accept() |
void osmo_stream_srv_link_set_addr | ( | struct osmo_stream_srv_link * | link, |
const char * | addr | ||
) |
Set the local address to which we bind.
[in] | link | Stream Server Link to modify |
[in] | addr | Local IP address |
References osmo_stream_srv_link_set_addrs().
int osmo_stream_srv_link_set_addrs | ( | struct osmo_stream_srv_link * | link, |
const char ** | addr, | ||
size_t | addrcnt | ||
) |
Set the local address set to which we bind. Useful for protocols allowing bind on more than one address (such as SCTP)
[in] | link | Stream Server Link to modify |
[in] | addr | Local IP address |
Referenced by osmo_stream_srv_link_set_addr().
void osmo_stream_srv_link_set_data | ( | struct osmo_stream_srv_link * | link, |
void * | data | ||
) |
Set application private data of the stream server link.
[in] | link | Stream Server Link to modify |
[in] | data | User-specific data (available in call-back functions) |
int osmo_stream_srv_link_set_domain | ( | struct osmo_stream_srv_link * | link, |
int | domain | ||
) |
Set the socket type for the stream server link.
[in] | link | Stream Server Link to modify |
[in] | type | Socket Domain (like AF_UNSPEC (default for IP), AF_UNIX, AF_INET, ...) |
void osmo_stream_srv_link_set_name | ( | struct osmo_stream_srv_link * | link, |
const char * | name | ||
) |
Set a name on the srv_link object (used during logging)
[in] | link | server link whose name is to be set |
[in] | name | the name to be set on link |
void osmo_stream_srv_link_set_nodelay | ( | struct osmo_stream_srv_link * | link, |
bool | nodelay | ||
) |
Set the NODELAY socket option to avoid Nagle-like behavior Setting this to nodelay=true will automatically set the NODELAY socket option on any socket established via this server link, before calling the accept_cb()
[in] | link | server link whose sockets are to be configured |
[in] | nodelay | whether to set (true) NODELAY after accept |
void osmo_stream_srv_link_set_port | ( | struct osmo_stream_srv_link * | link, |
uint16_t | port | ||
) |
Set the local port number to which we bind.
[in] | link | Stream Server Link to modify |
[in] | port | Local port number |
void osmo_stream_srv_link_set_proto | ( | struct osmo_stream_srv_link * | link, |
uint16_t | proto | ||
) |
Set the protocol for the stream server link.
[in] | link | Stream Server Link to modify |
[in] | proto | Protocol (like IPPROTO_TCP (default), IPPROTO_SCTP, ...) |
int osmo_stream_srv_link_set_type | ( | struct osmo_stream_srv_link * | link, |
int | type | ||
) |
Set the socket type for the stream server link.
[in] | link | Stream Server Link to modify |
[in] | type | Socket Type (like SOCK_STREAM (default), SOCK_SEQPACKET, ...) |
int osmo_stream_srv_recv | ( | struct osmo_stream_srv * | conn, |
struct msgb * | msg | ||
) |
Receive data via Osmocom stream server.
[in] | conn | Stream Server from which to receive |
msg | pre-allocate message buffer to which received data is appended |
If conn is an SCTP connection, additional specific considerations shall be taken:
void osmo_stream_srv_send | ( | struct osmo_stream_srv * | conn, |
struct msgb * | msg | ||
) |
Enqueue data to be sent via an Osmocom stream server.
[in] | conn | Stream Server through which we want to send |
[in] | msg | Message buffer to enqueue in transmit queue |
void osmo_stream_srv_set_closed_cb | ( | struct osmo_stream_srv * | conn, |
int(*)(struct osmo_stream_srv *conn) | closed_cb | ||
) |
Set the call-back function called when the stream server socket was closed.
[in] | conn | Stream Server to modify |
[in] | closed_cb | Call-back function to be called when the connection was closed |
void osmo_stream_srv_set_data | ( | struct osmo_stream_srv * | conn, |
void * | data | ||
) |
Set application private data of the stream server.
[in] | conn | Stream Server to modify |
[in] | data | User-specific data (available in call-back functions) |
void osmo_stream_srv_set_flush_and_destroy | ( | struct osmo_stream_srv * | conn | ) |
Prepare to send out all pending messages on the connection's Tx queue and then automatically destroy the stream with osmo_stream_srv_destroy(). This function disables queuing of new messages on the connection and also disables reception of new messages on the connection.
[in] | conn | Stream Server to modify |
void osmo_stream_srv_set_name | ( | struct osmo_stream_srv * | conn, |
const char * | name | ||
) |
Set a name on the srv object (used during logging)
[in] | conn | server whose name is to be set |
[in] | name | the name to be set on conn |
void osmo_stream_srv_set_read_cb | ( | struct osmo_stream_srv * | conn, |
int(*)(struct osmo_stream_srv *conn, struct msgb *msg) | read_cb | ||
) |
Set the call-back function when data was read from the stream server socket Only for osmo_stream_srv created with osmo_stream_srv_create2()
[in] | conn | Stream Server to modify |
[in] | read_cb | Call-back function to be called when data was read |
void osmo_stream_srv_set_segmentation_cb | ( | struct osmo_stream_srv * | conn, |
int(*)(struct msgb *msg) | segmentation_cb | ||
) |
Set the segmentation callback for target osmo_stream_srv structure. The connection has to have been established prior to calling this function.
[in,out] | conn | Target Stream Server to modify |
[in] | segmentation_cb | Segmentation callback to be set |
|
static |
|
static |
|
static |