Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _CCID_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _CCID_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  net/dccp/ccid.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  An implementation of the DCCP protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  CCID infrastructure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/dccp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /* maximum value for a CCID (RFC 4340, 19.5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define CCID_MAX		255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define CCID_SLAB_NAME_LENGTH	32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct tcp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *  struct ccid_operations  -  Interface to Congestion-Control Infrastructure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *  @ccid_id: numerical CCID ID (up to %CCID_MAX, cf. table 5 in RFC 4340, 10.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *  @ccid_ccmps: the CCMPS including network/transport headers (0 when disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *  @ccid_name: alphabetical identifier string for @ccid_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *  @ccid_hc_{r,t}x_slab: memory pool for the receiver/sender half-connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *  @ccid_hc_{r,t}x_obj_size: size of the receiver/sender half-connection socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *  @ccid_hc_{r,t}x_init: CCID-specific initialisation routine (before startup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *  @ccid_hc_{r,t}x_exit: CCID-specific cleanup routine (before destruction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *  @ccid_hc_rx_packet_recv: implements the HC-receiver side
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *  @ccid_hc_{r,t}x_parse_options: parsing routine for CCID/HC-specific options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *  @ccid_hc_{r,t}x_insert_options: insert routine for CCID/HC-specific options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *  @ccid_hc_tx_packet_recv: implements feedback processing for the HC-sender
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *  @ccid_hc_tx_send_packet: implements the sending part of the HC-sender
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *  @ccid_hc_tx_packet_sent: does accounting for packets in flight by HC-sender
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *  @ccid_hc_{r,t}x_get_info: INET_DIAG information for HC-receiver/sender
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *  @ccid_hc_{r,t}x_getsockopt: socket options specific to HC-receiver/sender
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct ccid_operations {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	unsigned char		ccid_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	__u32			ccid_ccmps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	const char		*ccid_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct kmem_cache	*ccid_hc_rx_slab,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 				*ccid_hc_tx_slab;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	char			ccid_hc_rx_slab_name[CCID_SLAB_NAME_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	char			ccid_hc_tx_slab_name[CCID_SLAB_NAME_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	__u32			ccid_hc_rx_obj_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				ccid_hc_tx_obj_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	/* Interface Routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	int		(*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	int		(*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	void		(*ccid_hc_rx_exit)(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	void		(*ccid_hc_tx_exit)(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	void		(*ccid_hc_rx_packet_recv)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 						  struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int		(*ccid_hc_rx_parse_options)(struct sock *sk, u8 pkt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 						    u8 opt, u8 *val, u8 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int		(*ccid_hc_rx_insert_options)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 						     struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	void		(*ccid_hc_tx_packet_recv)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 						  struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int		(*ccid_hc_tx_parse_options)(struct sock *sk, u8 pkt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 						    u8 opt, u8 *val, u8 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	int		(*ccid_hc_tx_send_packet)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 						  struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	void		(*ccid_hc_tx_packet_sent)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 						  unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	void		(*ccid_hc_rx_get_info)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 					       struct tcp_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	void		(*ccid_hc_tx_get_info)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 					       struct tcp_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int		(*ccid_hc_rx_getsockopt)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 						 const int optname, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 						 u32 __user *optval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 						 int __user *optlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int		(*ccid_hc_tx_getsockopt)(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 						 const int optname, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 						 u32 __user *optval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 						 int __user *optlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) extern struct ccid_operations ccid2_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #ifdef CONFIG_IP_DCCP_CCID3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) extern struct ccid_operations ccid3_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) int ccid_initialize_builtins(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) void ccid_cleanup_builtins(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) struct ccid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct ccid_operations *ccid_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	char		       ccid_priv[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline void *ccid_priv(const struct ccid *ccid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return (void *)ccid->ccid_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) bool ccid_support_check(u8 const *ccid_array, u8 array_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 				  char __user *, int __user *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct ccid *ccid_new(const u8 id, struct sock *sk, bool rx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct ccid *ccid = dp->dccps_hc_rx_ccid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (ccid == NULL || ccid->ccid_ops == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	return ccid->ccid_ops->ccid_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline int ccid_get_current_tx_ccid(struct dccp_sock *dp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct ccid *ccid = dp->dccps_hc_tx_ccid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (ccid == NULL || ccid->ccid_ops == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	return ccid->ccid_ops->ccid_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * Congestion control of queued data packets via CCID decision.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * The TX CCID performs its congestion-control by indicating whether and when a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * queued packet may be sent, using the return code of ccid_hc_tx_send_packet().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * The following modes are supported via the symbolic constants below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * - timer-based pacing    (CCID returns a delay value in milliseconds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * - autonomous dequeueing (CCID internally schedules dccps_xmitlet).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) enum ccid_dequeueing_decision {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	CCID_PACKET_SEND_AT_ONCE =	 0x00000,  /* "green light": no delay */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	CCID_PACKET_DELAY_MAX =		 0x0FFFF,  /* maximum delay in msecs  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	CCID_PACKET_DELAY =		 0x10000,  /* CCID msec-delay mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	CCID_PACKET_WILL_DEQUEUE_LATER = 0x20000,  /* CCID autonomous mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	CCID_PACKET_ERR =		 0xF0000,  /* error condition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static inline int ccid_packet_dequeue_eval(const int return_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (return_code < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		return CCID_PACKET_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (return_code == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		return CCID_PACKET_SEND_AT_ONCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (return_code <= CCID_PACKET_DELAY_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		return CCID_PACKET_DELAY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	return return_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 					 struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		return ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	return CCID_PACKET_SEND_AT_ONCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 					  unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 					  struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	if (ccid->ccid_ops->ccid_hc_rx_packet_recv != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		ccid->ccid_ops->ccid_hc_rx_packet_recv(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 					  struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (ccid->ccid_ops->ccid_hc_tx_packet_recv != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		ccid->ccid_ops->ccid_hc_tx_packet_recv(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * ccid_hc_tx_parse_options  -  Parse CCID-specific options sent by the receiver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  * @pkt: type of packet that @opt appears on (RFC 4340, 5.1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * @opt: the CCID-specific option type (RFC 4340, 5.8 and 10.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * @val: value of @opt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  * @len: length of @val in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 					   u8 pkt, u8 opt, u8 *val, u8 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (!ccid || !ccid->ccid_ops->ccid_hc_tx_parse_options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	return ccid->ccid_ops->ccid_hc_tx_parse_options(sk, pkt, opt, val, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * ccid_hc_rx_parse_options  -  Parse CCID-specific options sent by the sender
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * Arguments are analogous to ccid_hc_tx_parse_options()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 					   u8 pkt, u8 opt, u8 *val, u8 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	if (!ccid || !ccid->ccid_ops->ccid_hc_rx_parse_options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	return ccid->ccid_ops->ccid_hc_rx_parse_options(sk, pkt, opt, val, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static inline int ccid_hc_rx_insert_options(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 					    struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (ccid->ccid_ops->ccid_hc_rx_insert_options != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		return ccid->ccid_ops->ccid_hc_rx_insert_options(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline void ccid_hc_rx_get_info(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				       struct tcp_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	if (ccid->ccid_ops->ccid_hc_rx_get_info != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		ccid->ccid_ops->ccid_hc_rx_get_info(sk, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 				       struct tcp_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (ccid->ccid_ops->ccid_hc_tx_get_info != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		ccid->ccid_ops->ccid_hc_tx_get_info(sk, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 					const int optname, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 					u32 __user *optval, int __user *optlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	int rc = -ENOPROTOOPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	if (ccid != NULL && ccid->ccid_ops->ccid_hc_rx_getsockopt != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		rc = ccid->ccid_ops->ccid_hc_rx_getsockopt(sk, optname, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 						 optval, optlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 					const int optname, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 					u32 __user *optval, int __user *optlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	int rc = -ENOPROTOOPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	if (ccid != NULL && ccid->ccid_ops->ccid_hc_tx_getsockopt != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		rc = ccid->ccid_ops->ccid_hc_tx_getsockopt(sk, optname, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 						 optval, optlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) #endif /* _CCID_H */