]>
git.proxmox.com Git - mirror_frr.git/blob - lib/sockopt.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Router advertisement
3 * Copyright (C) 1999 Kunihiro Ishiguro
6 #ifndef _ZEBRA_SOCKOPT_H
7 #define _ZEBRA_SOCKOPT_H
15 extern void setsockopt_so_recvbuf(int sock
, int size
);
16 extern void setsockopt_so_sendbuf(const int sock
, int size
);
17 extern int getsockopt_so_sendbuf(const int sock
);
18 extern int getsockopt_so_recvbuf(const int sock
);
20 extern int setsockopt_ipv6_pktinfo(int, int);
21 extern int setsockopt_ipv6_multicast_hops(int, int);
22 extern int setsockopt_ipv6_unicast_hops(int, int);
23 extern int setsockopt_ipv6_hoplimit(int, int);
24 extern int setsockopt_ipv6_multicast_loop(int, int);
25 extern int setsockopt_ipv6_tclass(int, int);
27 #define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof(struct in6_pktinfo));
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.
33 * These values are without any alignment needed (see CMSG_SPACE in RFC3542).
35 #if defined(IP_PKTINFO)
36 /* Linux in_pktinfo. */
37 #define SOPT_SIZE_CMSG_PKTINFO_IPV4() (CMSG_SPACE(sizeof(struct in_pktinfo)))
38 /* XXX This should perhaps be defined even if IP_PKTINFO is not. */
39 #define SOPT_SIZE_CMSG_PKTINFO(af) \
40 ((af == AF_INET) ? SOPT_SIZE_CMSG_PKTINFO_IPV4() \
41 : SOPT_SIZE_CMSG_PKTINFO_IPV6()
42 #endif /* IP_PKTINFO */
44 #if defined(IP_RECVIF)
47 #define SOPT_SIZE_CMSG_RECVIF_IPV4() (sizeof(struct sockaddr_dl))
48 #endif /* IP_RECVIF */
50 /* SOPT_SIZE_CMSG_IFINDEX_IPV4 - portable type */
51 #if defined(SOPT_SIZE_CMSG_PKTINFO)
52 #define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_PKTINFO_IPV4()
53 #elif defined(SOPT_SIZE_CMSG_RECVIF_IPV4)
54 #define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_RECVIF_IPV4()
55 #else /* Nothing available */
56 #define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof(char *))
57 #endif /* SOPT_SIZE_CMSG_IFINDEX_IPV4 */
59 #define SOPT_SIZE_CMSG_IFINDEX(af) \
60 (((af) == AF_INET) : SOPT_SIZE_CMSG_IFINDEX_IPV4() \
61 ? SOPT_SIZE_CMSG_PKTINFO_IPV6())
63 extern int setsockopt_ipv4_multicast_if(int sock
, struct in_addr if_addr
,
65 extern int setsockopt_ipv4_multicast(int sock
, int optname
,
66 struct in_addr if_addr
,
67 unsigned int mcast_addr
,
69 extern int setsockopt_ipv4_multicast_loop(int sock
, uint8_t val
);
71 extern int setsockopt_ipv4_tos(int sock
, int tos
);
73 /* Ask for, and get, ifindex, by whatever method is supported. */
74 extern int setsockopt_ifindex(int, int, ifindex_t
);
75 extern ifindex_t
getsockopt_ifindex(int, struct msghdr
*);
77 /* swab the fields in iph between the host order and system order expected
80 extern void sockopt_iphdrincl_swab_htosys(struct ip
*iph
);
81 extern void sockopt_iphdrincl_swab_systoh(struct ip
*iph
);
83 extern int sockopt_tcp_rtt(int);
86 * TCP MD5 signature option. This option allows TCP MD5 to be enabled on
90 * Socket to enable option on.
93 * Sockunion specifying address to enable option on.
98 extern int sockopt_tcp_signature(int sock
, union sockunion
*su
,
99 const char *password
);
102 * Extended TCP MD5 signature option. This option allows TCP MD5 to be enabled
106 * Socket to enable option on.
109 * Sockunion specifying address (or prefix) to enable option on.
112 * 0 - su is an address; fall back to non-extended mode
113 * Else - su is a prefix; prefixlen is the mask length
118 extern int sockopt_tcp_signature_ext(int sock
, union sockunion
*su
,
119 uint16_t prefixlen
, const char *password
);
122 * set TCP max segment size. This option allows user to configure
123 * max segment size for TCP session
126 * Socket to enable option on.
129 * value used for TCP segment size negotiation during SYN
131 extern int sockopt_tcp_mss_set(int sock
, int tcp_maxseg
);
134 * get TCP max segment size. This option allows user to get
135 * the segment size for TCP session
138 * Socket to get max segement size.
140 extern int sockopt_tcp_mss_get(int sock
);
143 * Configure TCP keepalive for a given socket
146 * Socket to enable keepalive option on.
149 * number of seconds a connection needs to be idle
150 * before sending out keep-alive proves
153 * number of seconds between TCP keep-alive probes
156 * max number of probers to send before giving up
157 * and killing tcp connection
159 extern int setsockopt_tcp_keepalive(int sock
, uint16_t keepalive_idle
,
160 uint16_t keepalive_intvl
,
161 uint16_t keepalive_probes
);
167 #endif /*_ZEBRA_SOCKOPT_H */