libosmo-netif  0.2.0-dirty
Osmocom network interface library
include/osmocom/netif/stream.h
00001 #ifndef _OSMO_STREAM_H_
00002 #define _OSMO_STREAM_H_
00003 
00004 #include <stdbool.h>
00005 #include <stdint.h>
00006 
00012 #define msgb_sctp_ppid(msg)             (msg)->cb[3]
00013 
00014 #define msgb_sctp_stream(msg)           (msg)->cb[4]
00015 
00017 struct osmo_stream_srv_link;
00018 
00019 struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx);
00020 void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link);
00021 
00022 void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay);
00023 void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr);
00024 void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port);
00025 void osmo_stream_srv_link_set_proto(struct osmo_stream_srv_link *link, uint16_t proto);
00026 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));
00027 void osmo_stream_srv_link_set_data(struct osmo_stream_srv_link *link, void *data);
00028 void *osmo_stream_srv_link_get_data(struct osmo_stream_srv_link *link);
00029 struct osmo_fd *osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link);
00030 
00031 int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link);
00032 void osmo_stream_srv_link_close(struct osmo_stream_srv_link *link);
00033 
00036 struct osmo_stream_srv;
00037 
00038 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);
00039 void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn);
00040 struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv *conn);
00041 struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv);
00042 void osmo_stream_srv_destroy(struct osmo_stream_srv *conn);
00043 
00044 void osmo_stream_srv_set_flush_and_destroy(struct osmo_stream_srv *conn);
00045 void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data);
00046 
00047 void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg);
00048 int osmo_stream_srv_recv(struct osmo_stream_srv *conn, struct msgb *msg);
00049 
00051 struct osmo_stream_cli;
00052 
00053 void osmo_stream_cli_set_nodelay(struct osmo_stream_cli *cli, bool nodelay);
00054 void osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr);
00055 void osmo_stream_cli_set_port(struct osmo_stream_cli *cli, uint16_t port);
00056 void osmo_stream_cli_set_proto(struct osmo_stream_cli *cli, uint16_t proto);
00057 void osmo_stream_cli_set_local_addr(struct osmo_stream_cli *cli, const char *addr);
00058 void osmo_stream_cli_set_local_port(struct osmo_stream_cli *cli, uint16_t port);
00059 void osmo_stream_cli_set_data(struct osmo_stream_cli *cli, void *data);
00060 void osmo_stream_cli_set_reconnect_timeout(struct osmo_stream_cli *cli, int timeout);
00061 void *osmo_stream_cli_get_data(struct osmo_stream_cli *cli);
00062 struct osmo_fd *osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli);
00063 void osmo_stream_cli_set_connect_cb(struct osmo_stream_cli *cli, int (*connect_cb)(struct osmo_stream_cli *cli));
00064 void osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli, int (*read_cb)(struct osmo_stream_cli *cli));
00065 void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli);
00066 
00067 struct osmo_stream_cli *osmo_stream_cli_create(void *ctx);
00068 void osmo_stream_cli_destroy(struct osmo_stream_cli *cli);
00069 
00070 int osmo_stream_cli_open(struct osmo_stream_cli *cli);
00071 int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect);
00072 void osmo_stream_cli_close(struct osmo_stream_cli *cli);
00073 
00074 void osmo_stream_cli_send(struct osmo_stream_cli *cli, struct msgb *msg);
00075 int osmo_stream_cli_recv(struct osmo_stream_cli *conn, struct msgb *msg);
00076 
00079 #endif
 All Data Structures Files Functions