linux/include/linux/socket.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_SOCKET_H
#define _LINUX_SOCKET_H


#include <asm/socket.h>			/* arch-dependent defines	*/
#include <linux/sockios.h>		/* the SIOCxxx I/O controls	*/
#include <linux/uio.h>			/* iovec support		*/
#include <linux/types.h>		/* pid_t			*/
#include <linux/compiler.h>		/* __user			*/
#include <uapi/linux/socket.h>

struct file;
struct pid;
struct cred;
struct socket;
struct sock;
struct sk_buff;
struct proto_accept_arg;

#define __sockaddr_check_size(size)

#ifdef CONFIG_PROC_FS
struct seq_file;
extern void socket_seq_show(struct seq_file *seq);
#endif

sa_family_t;

/*
 *	1003.1g requires sa_family_t and that sa_data is char.
 */

struct sockaddr {};

struct linger {};

#define sockaddr_storage

/*
 *	As we do 4.4BSD message passing we use a 4.4BSD message passing
 *	system, not 4.3. Thus msg_accrights(len) are now missing. They
 *	belong in an obscure libc emulation or the bin.
 */

struct msghdr {};

struct user_msghdr {};

/* For recvmmsg/sendmmsg */
struct mmsghdr {};

/*
 *	POSIX 1003.1g - ancillary data object information
 *	Ancillary data consists of a sequence of pairs of
 *	(cmsghdr, cmsg_data[])
 */

struct cmsghdr {};

/*
 *	Ancillary data object information MACROS
 *	Table 5-14 of POSIX 1003.1g
 */

#define __CMSG_NXTHDR(ctl, len, cmsg)
#define CMSG_NXTHDR(mhdr, cmsg)

#define CMSG_ALIGN(len)

#define CMSG_DATA(cmsg)
#define CMSG_USER_DATA(cmsg)
#define CMSG_SPACE(len)
#define CMSG_LEN(len)

#define __CMSG_FIRSTHDR(ctl,len)
#define CMSG_FIRSTHDR(msg)
#define CMSG_OK(mhdr, cmsg)
#define for_each_cmsghdr(cmsg, msg)

/*
 *	Get the next cmsg header
 *
 *	PLEASE, do not touch this function. If you think, that it is
 *	incorrect, grep kernel sources and think about consequences
 *	before trying to improve it.
 *
 *	Now it always returns valid, not truncated ancillary object
 *	HEADER. But caller still MUST check, that cmsg->cmsg_len is
 *	inside range, given by msg->msg_controllen before using
 *	ancillary object DATA.				--ANK (980731)
 */

static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size,
					       struct cmsghdr *__cmsg)
{}

static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg)
{}

static inline size_t msg_data_left(struct msghdr *msg)
{}

/* "Socket"-level control message types: */

#define SCM_RIGHTS
#define SCM_CREDENTIALS
#define SCM_SECURITY
#define SCM_PIDFD

struct ucred {};

/* Supported address families. */
#define AF_UNSPEC
#define AF_UNIX
#define AF_LOCAL
#define AF_INET
#define AF_AX25
#define AF_IPX
#define AF_APPLETALK
#define AF_NETROM
#define AF_BRIDGE
#define AF_ATMPVC
#define AF_X25
#define AF_INET6
#define AF_ROSE
#define AF_DECnet
#define AF_NETBEUI
#define AF_SECURITY
#define AF_KEY
#define AF_NETLINK
#define AF_ROUTE
#define AF_PACKET
#define AF_ASH
#define AF_ECONET
#define AF_ATMSVC
#define AF_RDS
#define AF_SNA
#define AF_IRDA
#define AF_PPPOX
#define AF_WANPIPE
#define AF_LLC
#define AF_IB
#define AF_MPLS
#define AF_CAN
#define AF_TIPC
#define AF_BLUETOOTH
#define AF_IUCV
#define AF_RXRPC
#define AF_ISDN
#define AF_PHONET
#define AF_IEEE802154
#define AF_CAIF
#define AF_ALG
#define AF_NFC
#define AF_VSOCK
#define AF_KCM
#define AF_QIPCRTR
#define AF_SMC
#define AF_XDP
#define AF_MCTP

#define AF_MAX

/* Protocol families, same as address families. */
#define PF_UNSPEC
#define PF_UNIX
#define PF_LOCAL
#define PF_INET
#define PF_AX25
#define PF_IPX
#define PF_APPLETALK
#define PF_NETROM
#define PF_BRIDGE
#define PF_ATMPVC
#define PF_X25
#define PF_INET6
#define PF_ROSE
#define PF_DECnet
#define PF_NETBEUI
#define PF_SECURITY
#define PF_KEY
#define PF_NETLINK
#define PF_ROUTE
#define PF_PACKET
#define PF_ASH
#define PF_ECONET
#define PF_ATMSVC
#define PF_RDS
#define PF_SNA
#define PF_IRDA
#define PF_PPPOX
#define PF_WANPIPE
#define PF_LLC
#define PF_IB
#define PF_MPLS
#define PF_CAN
#define PF_TIPC
#define PF_BLUETOOTH
#define PF_IUCV
#define PF_RXRPC
#define PF_ISDN
#define PF_PHONET
#define PF_IEEE802154
#define PF_CAIF
#define PF_ALG
#define PF_NFC
#define PF_VSOCK
#define PF_KCM
#define PF_QIPCRTR
#define PF_SMC
#define PF_XDP
#define PF_MCTP
#define PF_MAX

/* Maximum queue length specifiable by listen.  */
#define SOMAXCONN

/* Flags we can use with send/ and recv.
   Added those for 1003.1g not all are supported yet
 */

#define MSG_OOB
#define MSG_PEEK
#define MSG_DONTROUTE
#define MSG_TRYHARD
#define MSG_CTRUNC
#define MSG_PROBE
#define MSG_TRUNC
#define MSG_DONTWAIT
#define MSG_EOR
#define MSG_WAITALL
#define MSG_FIN
#define MSG_SYN
#define MSG_CONFIRM
#define MSG_RST
#define MSG_ERRQUEUE
#define MSG_NOSIGNAL
#define MSG_MORE
#define MSG_WAITFORONE
#define MSG_SENDPAGE_NOPOLICY
#define MSG_BATCH
#define MSG_EOF
#define MSG_NO_SHARED_FRAGS
#define MSG_SENDPAGE_DECRYPTED

#define MSG_ZEROCOPY
#define MSG_SPLICE_PAGES
#define MSG_FASTOPEN
#define MSG_CMSG_CLOEXEC
#if defined(CONFIG_COMPAT)
#define MSG_CMSG_COMPAT
#else
#define MSG_CMSG_COMPAT
#endif

/* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */
#define MSG_INTERNAL_SENDMSG_FLAGS

/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
#define SOL_IP
/* #define SOL_ICMP	1	No-no-no! Due to Linux :-) we cannot use SOL_ICMP=1 */
#define SOL_TCP
#define SOL_UDP
#define SOL_IPV6
#define SOL_ICMPV6
#define SOL_SCTP
#define SOL_UDPLITE
#define SOL_RAW
#define SOL_IPX
#define SOL_AX25
#define SOL_ATALK
#define SOL_NETROM
#define SOL_ROSE
#define SOL_DECNET
#define SOL_X25
#define SOL_PACKET
#define SOL_ATM
#define SOL_AAL
#define SOL_IRDA
#define SOL_NETBEUI
#define SOL_LLC
#define SOL_DCCP
#define SOL_NETLINK
#define SOL_TIPC
#define SOL_RXRPC
#define SOL_PPPOL2TP
#define SOL_BLUETOOTH
#define SOL_PNPIPE
#define SOL_RDS
#define SOL_IUCV
#define SOL_CAIF
#define SOL_ALG
#define SOL_NFC
#define SOL_KCM
#define SOL_TLS
#define SOL_XDP
#define SOL_MPTCP
#define SOL_MCTP
#define SOL_SMC
#define SOL_VSOCK

/* IPX options */
#define IPX_TYPE

extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr);
extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);

struct timespec64;
struct __kernel_timespec;
struct old_timespec32;

struct scm_timestamping_internal {};

extern void put_cmsg_scm_timestamping64(struct msghdr *msg, struct scm_timestamping_internal *tss);
extern void put_cmsg_scm_timestamping(struct msghdr *msg, struct scm_timestamping_internal *tss);

/* The __sys_...msg variants allow MSG_CMSG_COMPAT iff
 * forbid_cmsg_compat==false
 */
extern long __sys_recvmsg(int fd, struct user_msghdr __user *msg,
			  unsigned int flags, bool forbid_cmsg_compat);
extern long __sys_sendmsg(int fd, struct user_msghdr __user *msg,
			  unsigned int flags, bool forbid_cmsg_compat);
extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg,
			  unsigned int vlen, unsigned int flags,
			  struct __kernel_timespec __user *timeout,
			  struct old_timespec32 __user *timeout32);
extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg,
			  unsigned int vlen, unsigned int flags,
			  bool forbid_cmsg_compat);
extern long __sys_sendmsg_sock(struct socket *sock, struct msghdr *msg,
			       unsigned int flags);
extern long __sys_recvmsg_sock(struct socket *sock, struct msghdr *msg,
			       struct user_msghdr __user *umsg,
			       struct sockaddr __user *uaddr,
			       unsigned int flags);
extern int __copy_msghdr(struct msghdr *kmsg,
			 struct user_msghdr *umsg,
			 struct sockaddr __user **save_addr);

/* helpers which do the actual work for syscalls */
extern int __sys_recvfrom(int fd, void __user *ubuf, size_t size,
			  unsigned int flags, struct sockaddr __user *addr,
			  int __user *addr_len);
extern int __sys_sendto(int fd, void __user *buff, size_t len,
			unsigned int flags, struct sockaddr __user *addr,
			int addr_len);
extern struct file *do_accept(struct file *file, struct proto_accept_arg *arg,
			      struct sockaddr __user *upeer_sockaddr,
			      int __user *upeer_addrlen, int flags);
extern int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
			 int __user *upeer_addrlen, int flags);
extern int __sys_socket(int family, int type, int protocol);
extern struct file *__sys_socket_file(int family, int type, int protocol);
extern int __sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen);
extern int __sys_bind_socket(struct socket *sock, struct sockaddr_storage *address,
			     int addrlen);
extern int __sys_connect_file(struct file *file, struct sockaddr_storage *addr,
			      int addrlen, int file_flags);
extern int __sys_connect(int fd, struct sockaddr __user *uservaddr,
			 int addrlen);
extern int __sys_listen(int fd, int backlog);
extern int __sys_listen_socket(struct socket *sock, int backlog);
extern int __sys_getsockname(int fd, struct sockaddr __user *usockaddr,
			     int __user *usockaddr_len);
extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr,
			     int __user *usockaddr_len);
extern int __sys_socketpair(int family, int type, int protocol,
			    int __user *usockvec);
extern int __sys_shutdown_sock(struct socket *sock, int how);
extern int __sys_shutdown(int fd, int how);
#endif /* _LINUX_SOCKET_H */