libosmo-netif 1.7.0.10-3a9e Osmocom network interface library

stream_private.h
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5
6#include <osmocom/core/socket.h>
7
8#include "config.h"
9
10#ifdef HAVE_LIBSCTP
11#include <netinet/sctp.h>
12 #define OSMO_STREAM_MAX_ADDRS OSMO_SOCK_MAX_ADDRS
13 /*
14 * Platforms that don't have MSG_NOSIGNAL (which disables SIGPIPE)
15 * usually have SO_NOSIGPIPE (set via setsockopt).
16 */
17 #ifndef MSG_NOSIGNAL
18 #define MSG_NOSIGNAL 0
19 #endif
20#else
21 #define OSMO_STREAM_MAX_ADDRS 1
22#endif
23
26 enum osmo_stream_mode {
27 OSMO_STREAM_MODE_UNKNOWN,
28 OSMO_STREAM_MODE_OSMO_FD,
29 OSMO_STREAM_MODE_OSMO_IO,
30};
31
32 struct stream_tcp_keepalive_pars {
33 bool enable;
34 bool time_present;
35 bool intvl_present;
36 bool probes_present;
37 int time_value; /* seconds */
38 int intvl_value; /* seconds */
39 int probes_value;
40};
41 int stream_setsockopt_tcp_keepalive(int fd, int on);
42 int stream_setsockopt_tcp_keepidle(int fd, int keepalive_time);
43 int stream_setsockopt_tcp_keepintvl(int fd, int keepalive_intvl);
44 int stream_setsockopt_tcp_keepcnt(int fd, int keepalive_probes);
45 int stream_tcp_keepalive_pars_apply(int fd, const struct stream_tcp_keepalive_pars *tkp);
46
47 struct stream_tcp_pars {
48 struct stream_tcp_keepalive_pars ka;
49 bool user_timeout_present;
50 unsigned int user_timeout_value;
51};
52 int stream_setsockopt_tcp_user_timeout(int fd, unsigned int user_timeout);
53
54 struct osmo_io_fd;
55 struct msghdr;
56
57 int stream_sctp_sock_activate_events(int fd);
58 int stream_setsockopt_nodelay(int fd, int proto, int on);
59 int stream_sctp_recvmsg_wrapper(int fd, struct msgb *msg, const char *log_pfx);
60
61 int stream_iofd_sctp_send_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int sendmsg_flags);
62 int stream_iofd_sctp_recvmsg_trailer(struct osmo_io_fd *iofd, struct msgb *msg, int ret, const struct msghdr *msgh);
63