1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _INET_COMMON_H
3#define _INET_COMMON_H
4
5#include <linux/indirect_call_wrapper.h>
6#include <linux/net.h>
7#include <linux/netdev_features.h>
8#include <linux/types.h>
9#include <net/sock.h>
10
11extern const struct proto_ops inet_stream_ops;
12extern const struct proto_ops inet_dgram_ops;
13
14/*
15 * INET4 prototypes used by INET6
16 */
17
18struct msghdr;
19struct net;
20struct page;
21struct sock;
22struct sockaddr;
23struct socket;
24
25int inet_release(struct socket *sock);
26int inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
27 int addr_len, int flags);
28int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
29 int addr_len, int flags, int is_sendmsg);
30int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
31 int addr_len, int flags);
32int inet_accept(struct socket *sock, struct socket *newsock, int flags,
33 bool kern);
34int inet_send_prepare(struct sock *sk);
35int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size);
36ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset,
37 size_t size, int flags);
38int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
39 int flags);
40int inet_shutdown(struct socket *sock, int how);
41int inet_listen(struct socket *sock, int backlog);
42void inet_sock_destruct(struct sock *sk);
43int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
44/* Don't allocate port at this moment, defer to connect. */
45#define BIND_FORCE_ADDRESS_NO_PORT (1 << 0)
46/* Grab and release socket lock. */
47#define BIND_WITH_LOCK (1 << 1)
48/* Called from BPF program. */
49#define BIND_FROM_BPF (1 << 2)
50/* Skip CAP_NET_BIND_SERVICE check. */
51#define BIND_NO_CAP_NET_BIND_SERVICE (1 << 3)
52int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
53 u32 flags);
54int inet_getname(struct socket *sock, struct sockaddr *uaddr,
55 int peer);
56int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
57int inet_ctl_sock_create(struct sock **sk, unsigned short family,
58 unsigned short type, unsigned char protocol,
59 struct net *net);
60int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
61 int *addr_len);
62
63struct sk_buff *inet_gro_receive(struct list_head *head, struct sk_buff *skb);
64int inet_gro_complete(struct sk_buff *skb, int nhoff);
65struct sk_buff *inet_gso_segment(struct sk_buff *skb,
66 netdev_features_t features);
67
68static inline void inet_ctl_sock_destroy(struct sock *sk)
69{
70 if (sk)
71 sock_release(sk->sk_socket);
72}
73
74#define indirect_call_gro_receive(f2, f1, cb, head, skb) \
75({ \
76 unlikely(gro_recursion_inc_test(skb)) ? \
77 NAPI_GRO_CB(skb)->flush |= 1, NULL : \
78 INDIRECT_CALL_2(cb, f2, f1, head, skb); \
79})
80
81#endif
82

source code of linux/include/net/inet_common.h