2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifndef _INET_COMMON_H
|
|
|
|
|
#define _INET_COMMON_H
|
|
|
|
|
|
2018-12-14 11:51:58 +01:00
|
|
|
#include <linux/indirect_call_wrapper.h>
|
2022-07-20 16:57:58 -07:00
|
|
|
#include <linux/net.h>
|
|
|
|
|
#include <linux/netdev_features.h>
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
#include <net/sock.h>
|
2018-12-14 11:51:58 +01:00
|
|
|
|
2010-07-10 20:41:06 +00:00
|
|
|
extern const struct proto_ops inet_stream_ops;
|
|
|
|
|
extern const struct proto_ops inet_dgram_ops;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* INET4 prototypes used by INET6
|
|
|
|
|
*/
|
|
|
|
|
|
2005-08-09 20:00:51 -07:00
|
|
|
struct msghdr;
|
2022-07-20 16:57:58 -07:00
|
|
|
struct net;
|
|
|
|
|
struct page;
|
2005-08-09 20:00:51 -07:00
|
|
|
struct sock;
|
|
|
|
|
struct socket;
|
|
|
|
|
|
2013-09-21 10:22:41 -07:00
|
|
|
int inet_release(struct socket *sock);
|
2025-11-03 16:26:11 -08:00
|
|
|
int inet_stream_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
|
2013-09-21 10:22:41 -07:00
|
|
|
int addr_len, int flags);
|
2025-11-03 16:26:11 -08:00
|
|
|
int __inet_stream_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
|
2017-01-25 14:42:46 +01:00
|
|
|
int addr_len, int flags, int is_sendmsg);
|
2025-11-03 16:26:11 -08:00
|
|
|
int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
|
2013-09-21 10:22:41 -07:00
|
|
|
int addr_len, int flags);
|
2024-05-09 09:20:08 -06:00
|
|
|
int inet_accept(struct socket *sock, struct socket *newsock,
|
|
|
|
|
struct proto_accept_arg *arg);
|
2023-05-17 12:16:14 -07:00
|
|
|
void __inet_accept(struct socket *sock, struct socket *newsock,
|
|
|
|
|
struct sock *newsk);
|
2019-07-03 16:06:52 +02:00
|
|
|
int inet_send_prepare(struct sock *sk);
|
2015-03-02 15:37:48 +08:00
|
|
|
int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size);
|
2023-06-07 19:19:13 +01:00
|
|
|
void inet_splice_eof(struct socket *sock);
|
2015-03-02 15:37:48 +08:00
|
|
|
int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
|
|
|
|
|
int flags);
|
2013-09-21 10:22:41 -07:00
|
|
|
int inet_shutdown(struct socket *sock, int how);
|
|
|
|
|
int inet_listen(struct socket *sock, int backlog);
|
2023-08-11 17:57:19 +02:00
|
|
|
int __inet_listen_sk(struct sock *sk, int backlog);
|
2013-09-21 10:22:41 -07:00
|
|
|
void inet_sock_destruct(struct sock *sk);
|
2025-11-03 16:26:10 -08:00
|
|
|
int inet_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int addr_len);
|
2025-11-03 16:26:13 -08:00
|
|
|
int inet_bind_sk(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len);
|
2020-05-08 10:46:10 -07:00
|
|
|
/* Don't allocate port at this moment, defer to connect. */
|
|
|
|
|
#define BIND_FORCE_ADDRESS_NO_PORT (1 << 0)
|
|
|
|
|
/* Grab and release socket lock. */
|
|
|
|
|
#define BIND_WITH_LOCK (1 << 1)
|
2020-05-08 10:46:11 -07:00
|
|
|
/* Called from BPF program. */
|
|
|
|
|
#define BIND_FROM_BPF (1 << 2)
|
2021-01-27 11:31:39 -08:00
|
|
|
/* Skip CAP_NET_BIND_SERVICE check. */
|
|
|
|
|
#define BIND_NO_CAP_NET_BIND_SERVICE (1 << 3)
|
2025-11-03 16:26:13 -08:00
|
|
|
int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,
|
2020-05-08 10:46:10 -07:00
|
|
|
u32 flags);
|
2018-02-12 20:00:20 +01:00
|
|
|
int inet_getname(struct socket *sock, struct sockaddr *uaddr,
|
2013-09-21 10:22:41 -07:00
|
|
|
int peer);
|
|
|
|
|
int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
|
|
|
|
|
int inet_ctl_sock_create(struct sock **sk, unsigned short family,
|
|
|
|
|
unsigned short type, unsigned char protocol,
|
|
|
|
|
struct net *net);
|
2026-02-27 15:11:20 +00:00
|
|
|
int inet_recv_error(struct sock *sk, struct msghdr *msg, int len);
|
2008-04-03 14:28:30 -07:00
|
|
|
|
2018-06-24 14:13:49 +09:00
|
|
|
struct sk_buff *inet_gro_receive(struct list_head *head, struct sk_buff *skb);
|
2016-05-18 09:06:23 -07:00
|
|
|
int inet_gro_complete(struct sk_buff *skb, int nhoff);
|
|
|
|
|
struct sk_buff *inet_gso_segment(struct sk_buff *skb,
|
|
|
|
|
netdev_features_t features);
|
|
|
|
|
|
2008-04-03 14:28:30 -07:00
|
|
|
static inline void inet_ctl_sock_destroy(struct sock *sk)
|
|
|
|
|
{
|
2015-11-02 07:50:07 -08:00
|
|
|
if (sk)
|
|
|
|
|
sock_release(sk->sk_socket);
|
2008-04-03 14:28:30 -07:00
|
|
|
}
|
2008-04-03 14:22:32 -07:00
|
|
|
|
2018-12-14 11:51:59 +01:00
|
|
|
#define indirect_call_gro_receive(f2, f1, cb, head, skb) \
|
|
|
|
|
({ \
|
|
|
|
|
unlikely(gro_recursion_inc_test(skb)) ? \
|
|
|
|
|
NAPI_GRO_CB(skb)->flush |= 1, NULL : \
|
|
|
|
|
INDIRECT_CALL_2(cb, f2, f1, head, skb); \
|
|
|
|
|
})
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|