]> git.proxmox.com Git - mirror_frr.git/blame - lib/sockopt.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / sockopt.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/* Router advertisement
3 * Copyright (C) 1999 Kunihiro Ishiguro
718e3744 4 */
5
6#ifndef _ZEBRA_SOCKOPT_H
7#define _ZEBRA_SOCKOPT_H
8
0df7c91f
PJ
9#include "sockunion.h"
10
5e244469
RW
11#ifdef __cplusplus
12extern "C" {
13#endif
14
d62a17ae 15extern void setsockopt_so_recvbuf(int sock, int size);
16extern void setsockopt_so_sendbuf(const int sock, int size);
17extern int getsockopt_so_sendbuf(const int sock);
772aae8b 18extern int getsockopt_so_recvbuf(const int sock);
0b3acf4f 19
d62a17ae 20extern int setsockopt_ipv6_pktinfo(int, int);
d62a17ae 21extern int setsockopt_ipv6_multicast_hops(int, int);
22extern int setsockopt_ipv6_unicast_hops(int, int);
23extern int setsockopt_ipv6_hoplimit(int, int);
24extern int setsockopt_ipv6_multicast_loop(int, int);
25extern int setsockopt_ipv6_tclass(int, int);
718e3744 26
0d6f7fd6 27#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof(struct in6_pktinfo));
e6822768 28
afa43b23 29/*
30 * Size defines for control messages used to get ifindex. We define
31 * values for each method, and define a macro that can be used by code
32 * that is unaware of which method is in use.
69e1325f 33 * These values are without any alignment needed (see CMSG_SPACE in RFC3542).
afa43b23 34 */
d62a17ae 35#if defined(IP_PKTINFO)
afa43b23 36/* Linux in_pktinfo. */
0d6f7fd6 37#define SOPT_SIZE_CMSG_PKTINFO_IPV4() (CMSG_SPACE(sizeof(struct in_pktinfo)))
afa43b23 38/* XXX This should perhaps be defined even if IP_PKTINFO is not. */
d62a17ae 39#define SOPT_SIZE_CMSG_PKTINFO(af) \
e6822768 40 ((af == AF_INET) ? SOPT_SIZE_CMSG_PKTINFO_IPV4() \
41 : SOPT_SIZE_CMSG_PKTINFO_IPV6()
23b9c61e 42#endif /* IP_PKTINFO */
e6822768 43
d62a17ae 44#if defined(IP_RECVIF)
23b9c61e 45/* BSD/Solaris */
afa43b23 46
0d6f7fd6 47#define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof(struct sockaddr_dl))
23b9c61e 48#endif /* IP_RECVIF */
e6822768 49
23b9c61e 50/* SOPT_SIZE_CMSG_IFINDEX_IPV4 - portable type */
d62a17ae 51#if defined(SOPT_SIZE_CMSG_PKTINFO)
23b9c61e 52#define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_PKTINFO_IPV4()
d62a17ae 53#elif defined(SOPT_SIZE_CMSG_RECVIF_IPV4)
23b9c61e 54#define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_RECVIF_IPV4()
d62a17ae 55#else /* Nothing available */
0d6f7fd6 56#define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof(char *))
23b9c61e 57#endif /* SOPT_SIZE_CMSG_IFINDEX_IPV4 */
4f7baa0e 58
d62a17ae 59#define SOPT_SIZE_CMSG_IFINDEX(af) \
23b9c61e 60 (((af) == AF_INET) : SOPT_SIZE_CMSG_IFINDEX_IPV4() \
61 ? SOPT_SIZE_CMSG_PKTINFO_IPV6())
4f7baa0e 62
4a3867d0 63extern int setsockopt_ipv4_multicast_if(int sock, struct in_addr if_addr,
b892f1dd 64 ifindex_t ifindex);
69bf3a39 65extern int setsockopt_ipv4_multicast(int sock, int optname,
d62a17ae 66 struct in_addr if_addr,
67 unsigned int mcast_addr,
68 ifindex_t ifindex);
d7c0a89a 69extern int setsockopt_ipv4_multicast_loop(int sock, uint8_t val);
c5bdb09f 70
1423c809 71extern int setsockopt_ipv4_tos(int sock, int tos);
e6822768 72
afa43b23 73/* Ask for, and get, ifindex, by whatever method is supported. */
d62a17ae 74extern int setsockopt_ifindex(int, int, ifindex_t);
75extern ifindex_t getsockopt_ifindex(int, struct msghdr *);
96e27c99 76
d62a17ae 77/* swab the fields in iph between the host order and system order expected
96e27c99 78 * for IP_HDRINCL.
79 */
d62a17ae 80extern void sockopt_iphdrincl_swab_htosys(struct ip *iph);
81extern void sockopt_iphdrincl_swab_systoh(struct ip *iph);
96e27c99 82
d62a17ae 83extern int sockopt_tcp_rtt(int);
b33e4666
QY
84
85/*
86 * TCP MD5 signature option. This option allows TCP MD5 to be enabled on
87 * addresses.
88 *
89 * sock
90 * Socket to enable option on.
91 *
92 * su
93 * Sockunion specifying address to enable option on.
94 *
95 * password
96 * MD5 auth password
97 */
0df7c91f 98extern int sockopt_tcp_signature(int sock, union sockunion *su,
d62a17ae 99 const char *password);
5e244469 100
b33e4666
QY
101/*
102 * Extended TCP MD5 signature option. This option allows TCP MD5 to be enabled
103 * on prefixes.
104 *
105 * sock
106 * Socket to enable option on.
107 *
108 * su
109 * Sockunion specifying address (or prefix) to enable option on.
110 *
111 * prefixlen
112 * 0 - su is an address; fall back to non-extended mode
113 * Else - su is a prefix; prefixlen is the mask length
114 *
115 * password
116 * MD5 auth password
117 */
118extern int sockopt_tcp_signature_ext(int sock, union sockunion *su,
119 uint16_t prefixlen, const char *password);
120
4ab46701
AR
121/*
122 * set TCP max segment size. This option allows user to configure
123 * max segment size for TCP session
124 *
125 * sock
126 * Socket to enable option on.
127 *
128 * tcp_maxseg
129 * value used for TCP segment size negotiation during SYN
130 */
131extern int sockopt_tcp_mss_set(int sock, int tcp_maxseg);
132
133/*
134 * get TCP max segment size. This option allows user to get
135 * the segment size for TCP session
136 *
137 * sock
138 * Socket to get max segement size.
139 */
140extern int sockopt_tcp_mss_get(int sock);
5c480b5d
XL
141
142/*
143 * Configure TCP keepalive for a given socket
144 *
145 * sock
146 * Socket to enable keepalive option on.
147 *
148 * keepalive_idle
149 * number of seconds a connection needs to be idle
150 * before sending out keep-alive proves
151 *
152 * keepalive_intvl
153 * number of seconds between TCP keep-alive probes
154 *
155 * keepalive_probes
156 * max number of probers to send before giving up
157 * and killing tcp connection
158 */
159extern int setsockopt_tcp_keepalive(int sock, uint16_t keepalive_idle,
160 uint16_t keepalive_intvl,
161 uint16_t keepalive_probes);
162
5e244469
RW
163#ifdef __cplusplus
164}
165#endif
166
718e3744 167#endif /*_ZEBRA_SOCKOPT_H */