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 _DCCP_FEAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _DCCP_FEAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  net/dccp/feat.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Feature negotiation for the DCCP protocol (RFC 4340, section 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Copyright (c) 2008 Gerrit Renker <gerrit@erg.abdn.ac.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "dccp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * Known limit values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /* Ack Ratio takes 2-byte integer values (11.3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define DCCPF_ACK_RATIO_MAX	0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /* Wmin=32 and Wmax=2^46-1 from 7.5.2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define DCCPF_SEQ_WMIN		32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define DCCPF_SEQ_WMAX		0x3FFFFFFFFFFFull
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /* Maximum number of SP values that fit in a single (Confirm) option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define DCCP_FEAT_MAX_SP_VALS	(DCCP_SINGLE_OPT_MAXLEN - 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) enum dccp_feat_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	FEAT_AT_RX   = 1,	/* located at RX side of half-connection  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	FEAT_AT_TX   = 2,	/* located at TX side of half-connection  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	FEAT_SP      = 4,	/* server-priority reconciliation (6.3.1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	FEAT_NN	     = 8,	/* non-negotiable reconciliation (6.3.2)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	FEAT_UNKNOWN = 0xFF	/* not understood or invalid feature	  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) enum dccp_feat_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	FEAT_DEFAULT = 0,	/* using default values from 6.4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	FEAT_INITIALISING,	/* feature is being initialised  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	FEAT_CHANGING,		/* Change sent but not confirmed yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	FEAT_UNSTABLE,		/* local modification in state CHANGING */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	FEAT_STABLE		/* both ends (think they) agree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * dccp_feat_val  -  Container for SP or NN feature values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * @nn:     single NN value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * @sp.vec: single SP value plus optional preference list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * @sp.len: length of @sp.vec in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) typedef union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u64 nn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		u8	*vec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		u8	len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	}   sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) } dccp_feat_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * struct feat_entry  -  Data structure to perform feature negotiation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * @val: feature's current value (SP features may have preference list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * @state: feature's current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * @feat_num: one of %dccp_feature_numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * @needs_mandatory: whether Mandatory options should be sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * @needs_confirm: whether to send a Confirm instead of a Change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * @empty_confirm: whether to send an empty Confirm (depends on @needs_confirm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * @is_local: feature location (1) or feature-remote (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * @node: list pointers, entries arranged in FIFO order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) struct dccp_feat_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	dccp_feat_val           val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	enum dccp_feat_state    state:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u8                      feat_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	bool			needs_mandatory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				needs_confirm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 				empty_confirm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				is_local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct list_head	node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static inline u8 dccp_feat_genopt(struct dccp_feat_entry *entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (entry->needs_confirm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		return entry->is_local ? DCCPO_CONFIRM_L : DCCPO_CONFIRM_R;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	return entry->is_local ? DCCPO_CHANGE_L : DCCPO_CHANGE_R;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * struct ccid_dependency  -  Track changes resulting from choosing a CCID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * @dependent_feat: one of %dccp_feature_numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * @is_local: local (1) or remote (0) @dependent_feat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * @is_mandatory: whether presence of @dependent_feat is mission-critical or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * @val: corresponding default value for @dependent_feat (u8 is sufficient here)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) struct ccid_dependency {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	u8	dependent_feat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	bool	is_local:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		is_mandatory:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	u8	val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) };
^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)  * Sysctls to seed defaults for feature negotiation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) extern unsigned long sysctl_dccp_sequence_window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extern int	     sysctl_dccp_rx_ccid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) extern int	     sysctl_dccp_tx_ccid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int dccp_feat_init(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) void dccp_feat_initialise_sysctls(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			  u8 const *list, u8 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int dccp_feat_parse_options(struct sock *, struct dccp_request_sock *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			    u8 mand, u8 opt, u8 feat, u8 *val, u8 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int dccp_feat_clone_list(struct list_head const *, struct list_head *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * Encoding variable-length options and their maximum length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * This affects NN options (SP options are all u8) and other variable-length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * options (see table 3 in RFC 4340). The limit is currently given the Sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * Window NN value (sec. 7.5.2) and the NDP count (sec. 7.7) option, all other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * options consume less than 6 bytes (timestamps are 4 bytes).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * When updating this constant (e.g. due to new internet drafts / RFCs), make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * sure that you also update all code which refers to it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define DCCP_OPTVAL_MAXLEN	6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) void dccp_encode_value_var(const u64 value, u8 *to, const u8 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u64 dccp_decode_value_var(const u8 *bf, const u8 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) u64 dccp_feat_nn_get(struct sock *sk, u8 feat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int dccp_insert_option_mandatory(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat, u8 *val, u8 len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		       bool repeat_first);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #endif /* _DCCP_FEAT_H */