1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* RxRPC kernel service interface definitions
3 *
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#ifndef _NET_RXRPC_H
9#define _NET_RXRPC_H
10
11#include <linux/rxrpc.h>
12#include <linux/ktime.h>
13
14struct key;
15struct sock;
16struct socket;
17struct rxrpc_call;
18struct rxrpc_peer;
19enum rxrpc_abort_reason;
20
21enum rxrpc_interruptibility {
22	RXRPC_INTERRUPTIBLE,	/* Call is interruptible */
23	RXRPC_PREINTERRUPTIBLE,	/* Call can be cancelled whilst waiting for a slot */
24	RXRPC_UNINTERRUPTIBLE,	/* Call should not be interruptible at all */
25};
26
27/*
28 * Debug ID counter for tracing.
29 */
30extern atomic_t rxrpc_debug_id;
31
32typedef void (*rxrpc_notify_rx_t)(struct sock *, struct rxrpc_call *,
33				  unsigned long);
34typedef void (*rxrpc_notify_end_tx_t)(struct sock *, struct rxrpc_call *,
35				      unsigned long);
36typedef void (*rxrpc_notify_new_call_t)(struct sock *, struct rxrpc_call *,
37					unsigned long);
38typedef void (*rxrpc_discard_new_call_t)(struct rxrpc_call *, unsigned long);
39typedef void (*rxrpc_user_attach_call_t)(struct rxrpc_call *, unsigned long);
40
41void rxrpc_kernel_new_call_notification(struct socket *,
42					rxrpc_notify_new_call_t,
43					rxrpc_discard_new_call_t);
44struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
45					   struct rxrpc_peer *peer,
46					   struct key *key,
47					   unsigned long user_call_ID,
48					   s64 tx_total_len,
49					   u32 hard_timeout,
50					   gfp_t gfp,
51					   rxrpc_notify_rx_t notify_rx,
52					   u16 service_id,
53					   bool upgrade,
54					   enum rxrpc_interruptibility interruptibility,
55					   unsigned int debug_id);
56int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *,
57			   struct msghdr *, size_t,
58			   rxrpc_notify_end_tx_t);
59int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *,
60			   struct iov_iter *, size_t *, bool, u32 *, u16 *);
61bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
62			     u32, int, enum rxrpc_abort_reason);
63void rxrpc_kernel_shutdown_call(struct socket *sock, struct rxrpc_call *call);
64void rxrpc_kernel_put_call(struct socket *sock, struct rxrpc_call *call);
65struct rxrpc_peer *rxrpc_kernel_lookup_peer(struct socket *sock,
66					    struct sockaddr_rxrpc *srx, gfp_t gfp);
67void rxrpc_kernel_put_peer(struct rxrpc_peer *peer);
68struct rxrpc_peer *rxrpc_kernel_get_peer(struct rxrpc_peer *peer);
69struct rxrpc_peer *rxrpc_kernel_get_call_peer(struct socket *sock, struct rxrpc_call *call);
70const struct sockaddr_rxrpc *rxrpc_kernel_remote_srx(const struct rxrpc_peer *peer);
71const struct sockaddr *rxrpc_kernel_remote_addr(const struct rxrpc_peer *peer);
72unsigned int rxrpc_kernel_get_srtt(const struct rxrpc_peer *);
73int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
74			       rxrpc_user_attach_call_t, unsigned long, gfp_t,
75			       unsigned int);
76void rxrpc_kernel_set_tx_length(struct socket *, struct rxrpc_call *, s64);
77bool rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *);
78u32 rxrpc_kernel_get_epoch(struct socket *, struct rxrpc_call *);
79void rxrpc_kernel_set_max_life(struct socket *, struct rxrpc_call *,
80			       unsigned long);
81
82int rxrpc_sock_set_min_security_level(struct sock *sk, unsigned int val);
83int rxrpc_sock_set_security_keyring(struct sock *, struct key *);
84
85#endif /* _NET_RXRPC_H */
86