libosmo-netif  1.5.1.31-5199.202501192026
Osmocom network interface library
stream.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdbool.h>
4 #include <stdint.h>
5 #include <unistd.h>
6 
7 #include <osmocom/core/msgb.h>
8 
12 #define OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION 0x80 /* sctp_recvmsg() flags=MSG_NOTIFICATION, msgb_data() contains "union sctp_notification*" */
13 #define msgb_sctp_msg_flags(msg) (msg)->cb[2]
14 
16 #define msgb_sctp_ppid(msg) (msg)->cb[3]
18 #define msgb_sctp_stream(msg) (msg)->cb[4]
19 
66 struct osmo_stream_srv_link;
67 
68 typedef int (*osmo_stream_srv_link_accept_cb_t)(struct osmo_stream_srv_link *link, int fd);
69 
70 struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx);
71 void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link);
72 
73 void osmo_stream_srv_link_set_name(struct osmo_stream_srv_link *link, const char *name);
74 const char *osmo_stream_srv_link_get_name(const struct osmo_stream_srv_link *link);
75 void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay);
76 int osmo_stream_srv_link_set_priority(struct osmo_stream_srv_link *link, int sk_prio);
77 int osmo_stream_srv_link_set_ip_dscp(struct osmo_stream_srv_link *link, uint8_t ip_dscp);
78 void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr);
79 int osmo_stream_srv_link_set_addrs(struct osmo_stream_srv_link *link, const char **addr, size_t addrcnt);
80 void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port);
81 void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto);
82 int osmo_stream_srv_link_set_type(struct osmo_stream_srv_link *link, int type);
83 int osmo_stream_srv_link_set_domain(struct osmo_stream_srv_link *link, int domain);
84 void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, osmo_stream_srv_link_accept_cb_t accept_cb);
85 void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data);
86 void *osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link);
87 int osmo_stream_srv_link_set_tx_queue_max_length(struct osmo_stream_srv_link *link, unsigned int size);
88 char *osmo_stream_srv_link_get_sockname(const struct osmo_stream_srv_link *link);
89 struct osmo_fd *osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link);
90 int osmo_stream_srv_link_get_fd(const struct osmo_stream_srv_link *link);
91 bool osmo_stream_srv_link_is_opened(const struct osmo_stream_srv_link *link);
92 int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link);
93 void osmo_stream_srv_link_close(struct osmo_stream_srv_link *link);
94 
95 enum osmo_stream_srv_link_param {
96  OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, /* uint8_t: 0 disable, 1 enable, 2 force disable, 3 force enable */
97  OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, /* uint8_t: 0 disable, 1 enable, 2 force disable, 3 force enable */
98  OSMO_STREAM_SRV_LINK_PAR_SCTP_INIT_NUM_OSTREAMS, /* uint16_t: amount of streams */
99  OSMO_STREAM_SRV_LINK_PAR_SCTP_INIT_MAX_INSTREAMS, /* uint16_t: amount of streams */
100 };
101 
102 int osmo_stream_srv_link_set_param(struct osmo_stream_srv_link *link, enum osmo_stream_srv_link_param par,
103  void *val, size_t val_len);
104 
107 struct osmo_stream_srv;
108 
109 typedef int (*osmo_stream_srv_read_cb_t)(struct osmo_stream_srv *conn);
110 typedef int (*osmo_stream_srv_closed_cb_t)(struct osmo_stream_srv *conn);
111 
117 typedef int (*osmo_stream_srv_read_cb2_t)(struct osmo_stream_srv *conn, int res, struct msgb *msg);
118 
119 typedef int (*osmo_stream_srv_segmentation_cb_t)(struct msgb *msg);
120 typedef int (*osmo_stream_srv_segmentation_cb2_t)(struct osmo_stream_srv *conn, struct msgb *msg);
121 
122 struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd,
123  osmo_stream_srv_read_cb_t read_cb,
124  osmo_stream_srv_closed_cb_t closed_cb,
125  void *data);
126 struct osmo_stream_srv *osmo_stream_srv_create2(void *ctx, struct osmo_stream_srv_link *link, int fd, void *data);
127 void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name);
128 const char *osmo_stream_srv_get_name(const struct osmo_stream_srv *conn);
129 void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, osmo_stream_srv_read_cb2_t read_cb);
130 void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, osmo_stream_srv_closed_cb_t close_cb);
131 void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn);
132 struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv *conn);
133 const char *osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn);
134 struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv);
135 int osmo_stream_srv_get_fd(const struct osmo_stream_srv *srv);
136 struct osmo_io_fd *osmo_stream_srv_get_iofd(const struct osmo_stream_srv *srv);
137 void osmo_stream_srv_destroy(struct osmo_stream_srv *conn);
138 
139 void osmo_stream_srv_set_flush_and_destroy(struct osmo_stream_srv *conn);
140 void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data);
141 
142 void osmo_stream_srv_set_segmentation_cb(struct osmo_stream_srv *conn, osmo_stream_srv_segmentation_cb_t segmentation_cb) OSMO_DEPRECATED("Use osmo_stream_srv_set_segmentation_cb2() instead");
143 void osmo_stream_srv_set_segmentation_cb2(struct osmo_stream_srv *conn, osmo_stream_srv_segmentation_cb2_t segmentation_cb2);
144 
145 void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg);
146 int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg);
147 
148 void osmo_stream_srv_clear_tx_queue(struct osmo_stream_srv *conn);
149 
188 struct osmo_stream_cli;
189 
190 typedef int (*osmo_stream_cli_connect_cb_t)(struct osmo_stream_cli *cli);
191 typedef int (*osmo_stream_cli_disconnect_cb_t)(struct osmo_stream_cli *cli);
192 typedef int (*osmo_stream_cli_read_cb_t)(struct osmo_stream_cli *cli);
193 
199 typedef int (*osmo_stream_cli_read_cb2_t)(struct osmo_stream_cli *cli, int res, struct msgb *msg);
200 
201 typedef int (*osmo_stream_cli_segmentation_cb_t)(struct msgb *msg);
202 typedef int (*osmo_stream_cli_segmentation_cb2_t)(struct osmo_stream_cli *cli, struct msgb *msg);
203 
204 void osmo_stream_cli_set_name(struct osmo_stream_cli *cli, const char *name);
205 const char *osmo_stream_cli_get_name(const struct osmo_stream_cli *cli);
206 void osmo_stream_cli_set_nodelay(struct osmo_stream_cli *cli, bool nodelay);
207 int osmo_stream_cli_set_priority(struct osmo_stream_cli *cli, int sk_prio);
208 int osmo_stream_cli_set_ip_dscp(struct osmo_stream_cli *cli, uint8_t ip_dscp);
209 void osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr);
210 int osmo_stream_cli_set_addrs(struct osmo_stream_cli *cli, const char **addr, size_t addrcnt);
211 void osmo_stream_cli_set_port(struct osmo_stream_cli *cli, uint16_t port);
212 int osmo_stream_cli_set_type(struct osmo_stream_cli *cli, int type);
213 int osmo_stream_cli_set_domain(struct osmo_stream_cli *cli, int domain);
214 void osmo_stream_cli_set_proto(struct osmo_stream_cli *cli, uint16_t proto);
215 void osmo_stream_cli_set_local_addr(struct osmo_stream_cli *cli, const char *addr);
216 int osmo_stream_cli_set_local_addrs(struct osmo_stream_cli *cli, const char **addr, size_t addrcnt);
217 void osmo_stream_cli_set_local_port(struct osmo_stream_cli *cli, uint16_t port);
218 void osmo_stream_cli_set_data(struct osmo_stream_cli *cli, void *data);
219 void osmo_stream_cli_set_reconnect_timeout(struct osmo_stream_cli *cli, int timeout);
220 void *osmo_stream_cli_get_data(struct osmo_stream_cli *cli);
221 int osmo_stream_cli_set_tx_queue_max_length(struct osmo_stream_cli *cli, unsigned int size);
222 char *osmo_stream_cli_get_sockname(const struct osmo_stream_cli *cli);
223 struct osmo_fd *osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli);
224 int osmo_stream_cli_get_fd(const struct osmo_stream_cli *cli);
225 struct osmo_io_fd *osmo_stream_cli_get_iofd(const struct osmo_stream_cli *cli);
226 void osmo_stream_cli_set_connect_cb(struct osmo_stream_cli *cli, osmo_stream_cli_connect_cb_t connect_cb);
227 void osmo_stream_cli_set_disconnect_cb(struct osmo_stream_cli *cli, osmo_stream_cli_disconnect_cb_t disconnect_cb);
228 void osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli, osmo_stream_cli_read_cb_t read_cb);
229 void osmo_stream_cli_set_read_cb2(struct osmo_stream_cli *cli, osmo_stream_cli_read_cb2_t read_cb);
230 void osmo_stream_cli_set_segmentation_cb(struct osmo_stream_cli *cli, osmo_stream_cli_segmentation_cb_t segmentation_cb) OSMO_DEPRECATED("Use osmo_stream_cli_set_segmentation_cb2() instead");
231 void osmo_stream_cli_set_segmentation_cb2(struct osmo_stream_cli *cli, osmo_stream_cli_segmentation_cb2_t segmentation_cb2);
232 void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli);
233 bool osmo_stream_cli_is_connected(struct osmo_stream_cli *cli);
234 
235 struct osmo_stream_cli *osmo_stream_cli_create(void *ctx);
236 void osmo_stream_cli_destroy(struct osmo_stream_cli *cli);
237 
238 int osmo_stream_cli_open(struct osmo_stream_cli *cli);
239 int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect) \
240  OSMO_DEPRECATED("Use osmo_stream_cli_set_reconnect_timeout() or osmo_stream_cli_reconnect() instead");
241 void osmo_stream_cli_close(struct osmo_stream_cli *cli);
242 
243 void osmo_stream_cli_send(struct osmo_stream_cli *cli, struct msgb *msg);
244 int osmo_stream_cli_recv(struct osmo_stream_cli *cli, struct msgb *msg);
245 
246 void osmo_stream_cli_clear_tx_queue(struct osmo_stream_cli *cli);
247 
248 enum osmo_stream_cli_param {
249  OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, /* uint8_t: 0 disable, 1 enable, 2 force disable, 3 force enable */
250  OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, /* uint8_t: 0 disable, 1 enable, 2 force disable, 3 force enable */
251  OSMO_STREAM_CLI_PAR_SCTP_INIT_NUM_OSTREAMS, /* uint16_t: amount of streams */
252  OSMO_STREAM_CLI_PAR_SCTP_INIT_MAX_INSTREAMS, /* uint16_t: amount of streams */
253  OSMO_STREAM_CLI_PAR_SCTP_INIT_MAX_ATTEMPTS, /* uint16_t: amount of attempts */
254  OSMO_STREAM_CLI_PAR_SCTP_INIT_TIMEOUT, /* uint16_t: milliseconds */
255 };
256 
257 int osmo_stream_cli_set_param(struct osmo_stream_cli *cli, enum osmo_stream_cli_param par,
258  void *val, size_t val_len);
259 
void osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr)
Set the remote address to which we connect.
Definition: stream_cli.c:690
struct osmo_fd * osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli)
Retrieve Osmocom File Descriptor of the stream client socket.
Definition: stream_cli.c:954
int osmo_stream_cli_set_param(struct osmo_stream_cli *cli, enum osmo_stream_cli_param par, void *val, size_t val_len)
Set given parameter of stream client to given value.
Definition: stream_cli.c:1455
int osmo_stream_cli_recv(struct osmo_stream_cli *cli, struct msgb *msg)
Receive data via an Osmocom stream client in osmo_fd mode.
Definition: stream_cli.c:1375
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 bind.
Definition: stream_cli.c:763
const char * osmo_stream_cli_get_name(const struct osmo_stream_cli *cli)
Retrieve name previously set on the cli object (see osmo_stream_cli_set_name()).
Definition: stream_cli.c:679
int(* osmo_stream_cli_read_cb2_t)(struct osmo_stream_cli *cli, int res, struct msgb *msg)
Completion call-back function when something was read from from the stream client socket.
Definition: stream.h:199
void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli)
Re-connect an Osmocom Stream Client.
Definition: stream_cli.c:253
int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect) OSMO_DEPRECATED("Use osmo_stream_cli_set_reconnect_timeout() or osmo_stream_cli_reconnect() instead")
DEPRECATED: use osmo_stream_cli_set_reconnect_timeout() or osmo_stream_cli_reconnect() instead!...
Definition: stream_cli.c:1040
struct osmo_stream_cli * osmo_stream_cli_create(void *ctx)
Create an Osmocom stream client.
Definition: stream_cli.c:499
int osmo_stream_cli_set_ip_dscp(struct osmo_stream_cli *cli, uint8_t ip_dscp)
Set the DSCP (differentiated services code point) of the stream socket.
Definition: stream_cli.c:1165
int osmo_stream_cli_set_domain(struct osmo_stream_cli *cli, int domain)
Set the socket type for the stream server link.
Definition: stream_cli.c:874
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).
Definition: stream_cli.c:739
int osmo_stream_cli_set_type(struct osmo_stream_cli *cli, int type)
Set the socket type for the stream server link.
Definition: stream_cli.c:854
void osmo_stream_cli_set_data(struct osmo_stream_cli *cli, void *data)
Set application private data of the stream client socket.
Definition: stream_cli.c:903
void * osmo_stream_cli_get_data(struct osmo_stream_cli *cli)
Retrieve application private data of the stream client socket.
Definition: stream_cli.c:911
void osmo_stream_cli_set_disconnect_cb(struct osmo_stream_cli *cli, osmo_stream_cli_disconnect_cb_t disconnect_cb)
Set the call-back function called on disconnect of the stream client socket.
Definition: stream_cli.c:975
void osmo_stream_cli_set_connect_cb(struct osmo_stream_cli *cli, osmo_stream_cli_connect_cb_t connect_cb)
Set the call-back function called on connect of the stream client socket.
Definition: stream_cli.c:966
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).
Definition: stream_cli.c:751
void osmo_stream_cli_set_read_cb2(struct osmo_stream_cli *cli, osmo_stream_cli_read_cb2_t read_cb)
Set the call-back function called to read from the stream client socket.
Definition: stream_cli.c:999
void osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli, osmo_stream_cli_read_cb_t read_cb)
Set the call-back function called to read from the stream client socket.
Definition: stream_cli.c:986
bool osmo_stream_cli_is_connected(struct osmo_stream_cli *cli)
Check if Osmocom Stream Client is in connected state.
Definition: stream_cli.c:262
int osmo_stream_cli_open(struct osmo_stream_cli *cli)
Open connection of an Osmocom stream client.
Definition: stream_cli.c:1194
int osmo_stream_cli_set_tx_queue_max_length(struct osmo_stream_cli *cli, unsigned int size)
Set the maximum length queue of the stream client.
Definition: stream_cli.c:922
void osmo_stream_cli_set_proto(struct osmo_stream_cli *cli, uint16_t proto)
Set the protocol for the stream client socket.
Definition: stream_cli.c:788
void osmo_stream_cli_destroy(struct osmo_stream_cli *cli)
Destroy a Osmocom stream client (includes close).
Definition: stream_cli.c:1009
void osmo_stream_cli_set_nodelay(struct osmo_stream_cli *cli, bool nodelay)
Set the NODELAY socket option to avoid Nagle-like behavior.
Definition: stream_cli.c:1105
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.
Definition: stream_cli.c:702
void osmo_stream_cli_send(struct osmo_stream_cli *cli, struct msgb *msg)
Enqueue data to be sent via an Osmocom stream client.
Definition: stream_cli.c:1318
void osmo_stream_cli_set_segmentation_cb(struct osmo_stream_cli *cli, osmo_stream_cli_segmentation_cb_t segmentation_cb) OSMO_DEPRECATED("Use osmo_stream_cli_set_segmentation_cb2() instead")
Set the segmentation callback for the client.
Definition: stream_cli.c:826
void osmo_stream_cli_set_port(struct osmo_stream_cli *cli, uint16_t port)
Set the remote port number to which we connect.
Definition: stream_cli.c:727
struct osmo_io_fd * osmo_stream_cli_get_iofd(const struct osmo_stream_cli *cli)
Retrieve osmo_io descriptor of the stream client socket.
Definition: stream_cli.c:302
int osmo_stream_cli_set_priority(struct osmo_stream_cli *cli, int sk_prio)
Set the priority value of the stream socket.
Definition: stream_cli.c:1134
void osmo_stream_cli_close(struct osmo_stream_cli *cli)
Close an Osmocom Stream Client.
Definition: stream_cli.c:221
void osmo_stream_cli_set_reconnect_timeout(struct osmo_stream_cli *cli, int timeout)
Set the reconnect time of the stream client socket.
Definition: stream_cli.c:894
void osmo_stream_cli_set_name(struct osmo_stream_cli *cli, const char *name)
Set a name on the cli object (used during logging).
Definition: stream_cli.c:668
char * osmo_stream_cli_get_sockname(const struct osmo_stream_cli *cli)
Retrieve the stream client socket description.
Definition: stream_cli.c:939
void osmo_stream_cli_set_segmentation_cb2(struct osmo_stream_cli *cli, osmo_stream_cli_segmentation_cb2_t segmentation_cb2)
Set the segmentation callback for the client.
Definition: stream_cli.c:839
void osmo_stream_cli_clear_tx_queue(struct osmo_stream_cli *cli)
Clear the transmit queue of the stream client.
Definition: stream_cli.c:1430
int osmo_stream_cli_get_fd(const struct osmo_stream_cli *cli)
Retrieve file descriptor of the stream client socket.
Definition: stream_cli.c:282
struct osmo_stream_srv * osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, osmo_stream_srv_read_cb_t read_cb, osmo_stream_srv_closed_cb_t closed_cb, void *data)
Create a legacy osmo_fd mode Stream Server inside the specified link.
Definition: stream_srv.c:891
int osmo_stream_srv_link_set_type(struct osmo_stream_srv_link *link, int type)
Set the socket type for the stream server link.
Definition: stream_srv.c:345
void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name)
Set a name on the srv object (used during logging).
Definition: stream_srv.c:980
void osmo_stream_srv_link_set_accept_cb(struct osmo_stream_srv_link *link, osmo_stream_srv_link_accept_cb_t accept_cb)
Set the accept() call-back of the stream server link.
Definition: stream_srv.c:502
void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto)
Set the protocol for the stream server link.
Definition: stream_srv.c:331
bool osmo_stream_srv_link_is_opened(const struct osmo_stream_srv_link *link)
Check whether the stream server link is opened.
Definition: stream_srv.c:576
void osmo_stream_srv_set_segmentation_cb2(struct osmo_stream_srv *conn, osmo_stream_srv_segmentation_cb2_t segmentation_cb2)
Set the segmentation callback for target osmo_stream_srv structure.
Definition: stream_srv.c:1109
int osmo_stream_srv_link_set_priority(struct osmo_stream_srv_link *link, int sk_prio)
Set the priority value of the stream socket.
Definition: stream_srv.c:257
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.
Definition: stream_srv.c:241
struct osmo_fd * osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv)
Retrieve Osmocom File Descriptor of a stream server in osmo_fd mode.
Definition: stream_srv.c:1146
void osmo_stream_srv_destroy(struct osmo_stream_srv *conn)
Destroy given Stream Server.
Definition: stream_srv.c:1194
const char * osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn)
Retrieve the stream server socket description.
Definition: stream_srv.c:1132
int osmo_stream_srv_link_set_ip_dscp(struct osmo_stream_srv_link *link, uint8_t ip_dscp)
Set the DSCP (differentiated services code point) of the stream socket.
Definition: stream_srv.c:270
void osmo_stream_srv_set_segmentation_cb(struct osmo_stream_srv *conn, osmo_stream_srv_segmentation_cb_t segmentation_cb) OSMO_DEPRECATED("Use osmo_stream_srv_set_segmentation_cb2() instead")
Set the segmentation callback for target osmo_stream_srv structure.
Definition: stream_srv.c:1086
int(* osmo_stream_srv_read_cb2_t)(struct osmo_stream_srv *conn, int res, struct msgb *msg)
Completion call-back function when something was read from from the stream client socket.
Definition: stream.h:117
void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data)
Set application private data of the stream server link.
Definition: stream_srv.c:385
int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link)
Open the stream server link.
Definition: stream_srv.c:523
const char * osmo_stream_srv_link_get_name(const struct osmo_stream_srv_link *link)
Retrieve name previously set on the srv_link object (see osmo_stream_srv_link_set_name()).
Definition: stream_srv.c:229
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)
Set given parameter of stream_srv_link to given value.
Definition: stream_srv.c:606
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.
Definition: stream_srv.c:318
struct osmo_fd * osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link)
Retrieve Osmocom File Descriptor of the stream server link.
Definition: stream_srv.c:483
char * osmo_stream_srv_link_get_sockname(const struct osmo_stream_srv_link *link)
Retrieve description of the stream server link e.
Definition: stream_srv.c:470
int osmo_stream_srv_get_fd(const struct osmo_stream_srv *srv)
Retrieve File Descriptor of the stream server.
Definition: stream_srv.c:1156
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.
Definition: stream_srv.c:1030
void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link)
Destroy the stream server link.
Definition: stream_srv.c:511
struct osmo_stream_srv * osmo_stream_srv_create2(void *ctx, struct osmo_stream_srv_link *link, int fd, void *data)
Create an osmo_iofd mode Stream Server inside the specified link.
Definition: stream_srv.c:934
int osmo_stream_srv_link_set_domain(struct osmo_stream_srv_link *link, int domain)
Set the socket type for the stream server link.
Definition: stream_srv.c:365
void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data)
Set application private data of the stream server.
Definition: stream_srv.c:1039
struct osmo_stream_srv_link * osmo_stream_srv_get_master(struct osmo_stream_srv *conn)
Retrieve the master (Link) from a Stream Server.
Definition: stream_srv.c:1184
struct osmo_io_fd * osmo_stream_srv_get_iofd(const struct osmo_stream_srv *srv)
Retrieve osmo_io descriptor of the stream server socket.
Definition: stream_srv.c:1175
void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg)
Enqueue data to be sent via an Osmocom stream server.
Definition: stream_srv.c:1222
struct osmo_stream_srv_link * osmo_stream_srv_link_create(void *ctx)
Create an Osmocom Stream Server Link.
Definition: stream_srv.c:196
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.
Definition: stream_srv.c:294
int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg)
Receive data via an Osmocom stream server in osmo_fd mode.
Definition: stream_srv.c:1276
void * osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link)
Retrieve application private data of the stream server link.
Definition: stream_srv.c:394
void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr)
Set the local address to which we bind.
Definition: stream_srv.c:281
void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, osmo_stream_srv_read_cb2_t read_cb)
Set the call-back function for incoming data on an osmo_io stream_srv.
Definition: stream_srv.c:1005
void osmo_stream_srv_link_close(struct osmo_stream_srv_link *link)
Close the stream server link and unregister from select loop.
Definition: stream_srv.c:590
const char * osmo_stream_srv_get_name(const struct osmo_stream_srv *conn)
Retrieve name previously set on the srv object (see osmo_stream_srv_set_name()).
Definition: stream_srv.c:991
int osmo_stream_srv_link_set_tx_queue_max_length(struct osmo_stream_srv_link *link, unsigned int size)
Set the maximum length queue of the stream servers accepted and allocated from this server link.
Definition: stream_srv.c:405
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).
Definition: stream_srv.c:220
void * osmo_stream_srv_get_data(struct osmo_stream_srv *conn)
Retrieve application private data of the stream server.
Definition: stream_srv.c:1123
int osmo_stream_srv_link_get_fd(const struct osmo_stream_srv_link *link)
Retrieve File Descriptor of the stream server link.
Definition: stream_srv.c:491
void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, osmo_stream_srv_closed_cb_t close_cb)
Set the call-back function called when the stream server socket was closed.
Definition: stream_srv.c:1018