1/*************************************************
2*     Exim - an Internet mail transport agent    *
3*************************************************/
4
5/* Copyright (c) Jeremy Harris 1995 - 2020 */
6/* See the file NOTICE for conditions of use and distribution. */
7
8/* FreeBSD-specific code. This is concatenated onto the generic
9src/os.c file. */
10
11
12/*************
13Sendfile shim
14*************/
15
16ssize_t
17os_sendfile(int out, int in, off_t * offp, size_t cnt)
18{
19off_t loff = offp ? *offp : 0;
20off_t written;
21
22if (sendfile(in, out, loff, cnt, NULL, &written, 0) < 0) return (ssize_t)-1;
23if (offp) *offp = loff + written;
24return (ssize_t)written;
25}
26
27/*************************************************
28TCP Fast Open:  check that the ioctl is accepted
29*************************************************/
30
31#ifndef COMPILE_UTILITY
32void
33tfo_probe(void)
34{
35# ifdef TCP_FASTOPEN
36int sock;
37
38if (  (sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0
39   && setsockopt(sock, IPPROTO_TCP, TCP_FASTOPEN, &on, sizeof(on) >= 0)
40   )
41  f.tcp_fastopen_ok = TRUE;
42close(sock);
43# endif
44}
45#endif
46
47
48/* End of os.c-Linux */
49