libosmo-netif  0.0.7.20171026
Osmocom network interface library
 All Data Structures Files Functions Modules
stream.h
1 #ifndef _OSMO_STREAM_H_
2 #define _OSMO_STREAM_H_
3 
4 #include <stdbool.h>
5 #include <stdint.h>
6 
12 #define msgb_sctp_ppid(msg) (msg)->cb[3]
13 
14 #define msgb_sctp_stream(msg) (msg)->cb[4]
15 
18 
21 
22 void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay);
23 void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr);
24 void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port);
25 void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto);
26 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));
27 void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data);
29 struct osmo_fd *osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link);
30 
33 
36 struct osmo_stream_srv;
37 
38 struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, int (*cb)(struct osmo_stream_srv *conn), int (*closed_cb)(struct osmo_stream_srv *conn), void *data);
39 void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn);
41 struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv);
42 void osmo_stream_srv_destroy(struct osmo_stream_srv *conn);
43 
44 void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data);
45 
46 void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg);
47 int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg);
48 
50 struct osmo_stream_cli;
51 
52 void osmo_stream_cli_set_nodelay(struct osmo_stream_cli *cli, bool nodelay);
53 void osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr);
54 void osmo_stream_cli_set_port(struct osmo_stream_cli *cli, uint16_t port);
55 void osmo_stream_cli_set_proto(struct osmo_stream_cli *cli, uint16_t proto);
56 void osmo_stream_cli_set_local_addr(struct osmo_stream_cli *cli, const char *addr);
57 void osmo_stream_cli_set_local_port(struct osmo_stream_cli *cli, uint16_t port);
58 void osmo_stream_cli_set_data(struct osmo_stream_cli *cli, void *data);
59 void osmo_stream_cli_set_reconnect_timeout(struct osmo_stream_cli *cli, int timeout);
60 void *osmo_stream_cli_get_data(struct osmo_stream_cli *cli);
61 struct osmo_fd *osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli);
62 void osmo_stream_cli_set_connect_cb(struct osmo_stream_cli *cli, int (*connect_cb)(struct osmo_stream_cli *cli));
63 void osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli, int (*read_cb)(struct osmo_stream_cli *cli));
65 
66 struct osmo_stream_cli *osmo_stream_cli_create(void *ctx);
68 
69 int osmo_stream_cli_open(struct osmo_stream_cli *cli);
70 int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect);
71 void osmo_stream_cli_close(struct osmo_stream_cli *cli);
72 
73 void osmo_stream_cli_send(struct osmo_stream_cli *cli, struct msgb *msg);
74 int osmo_stream_cli_recv(struct osmo_stream_cli *conn, struct msgb *msg);
75 
78 #endif
Definition: stream.c:111
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.
Definition: stream.c:395
void * osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link)
Get application private data of the stream server link.
Definition: stream.c:673
void osmo_stream_cli_close(struct osmo_stream_cli *cli)
Close an Osmocom Stream Client.
Definition: stream.c:152
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.c:307
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 conf...
Definition: stream.c:708
Definition: stream.c:744
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.c:329
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 automati...
Definition: stream.c:460
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.c:350
void osmo_stream_srv_destroy(struct osmo_stream_srv *conn)
Destroy given Stream Server This function closes the Stream Server socket, unregisters from select lo...
Definition: stream.c:891
void * osmo_stream_cli_get_data(struct osmo_stream_cli *cli)
Get application private data of the stream client socket.
Definition: stream.c:367
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...
Definition: stream.c:735
struct osmo_stream_srv * osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, int(*cb)(struct osmo_stream_srv *conn), int(*closed_cb)(struct osmo_stream_srv *conn), void *data)
Create a Stream Server inside the specified link.
Definition: stream.c:821
struct osmo_fd * osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link)
Get Osmocom File Descriptor of the stream server link.
Definition: stream.c:682
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.c:664
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.c:653
void * osmo_stream_srv_get_data(struct osmo_stream_srv *conn)
Get application private data of the stream server.
Definition: stream.c:865
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.c:494
void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link)
Destroy the stream server link. Closes + Releases Memory.
Definition: stream.c:699
struct osmo_fd * osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli)
Get Osmocom File Descriptor of the stream client socket.
Definition: stream.c:376
void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli)
Re-connect an Osmocom Stream Client If re-connection is enabled for this client, we close any existin...
Definition: stream.c:134
void osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr)
Set the remote address to which we connect.
Definition: stream.c:296
void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data)
Set application private data of the stream server.
Definition: stream.c:856
struct osmo_stream_cli * osmo_stream_cli_create(void *ctx)
Create an Osmocom stream client.
Definition: stream.c:269
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 automati...
Definition: stream.c:618
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.c:903
void osmo_stream_cli_destroy(struct osmo_stream_cli *cli)
Destroy a Osmocom stream client (includes close)
Definition: stream.c:403
int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect)
Open connection of an Osmocom stream client.
Definition: stream.c:414
struct osmo_stream_srv_link * osmo_stream_srv_get_master(struct osmo_stream_srv *conn)
Get the master (Link) from a Stream Server.
Definition: stream.c:882
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.
Definition: stream.c:385
struct osmo_fd * osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv)
Get Osmocom File Descriptor of the stream server.
Definition: stream.c:874
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.
Definition: stream.c:690
int osmo_stream_cli_open(struct osmo_stream_cli *cli)
Open connection of an Osmocom stream client.
Definition: stream.c:470
int osmo_stream_cli_recv(struct osmo_stream_cli *conn, struct msgb *msg)
Receive data via an Osmocom stream client.
Definition: stream.c:504
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.c:630
int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg)
Receive data via Osmocom stream server.
Definition: stream.c:914
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.c:318
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.c:641
void osmo_stream_cli_set_data(struct osmo_stream_cli *cli, void *data)
Set application private data of the stream client socket.
Definition: stream.c:359
void osmo_stream_cli_set_proto(struct osmo_stream_cli *cli, uint16_t proto)
Set the protocol for the stream client socket.
Definition: stream.c:340
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 indivi...
Definition: stream.c:594