![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 #ifndef _DCCP_FEAT_H 0003 #define _DCCP_FEAT_H 0004 /* 0005 * net/dccp/feat.h 0006 * 0007 * Feature negotiation for the DCCP protocol (RFC 4340, section 6) 0008 * Copyright (c) 2008 Gerrit Renker <gerrit@erg.abdn.ac.uk> 0009 * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk> 0010 */ 0011 #include <linux/types.h> 0012 #include "dccp.h" 0013 0014 /* 0015 * Known limit values 0016 */ 0017 /* Ack Ratio takes 2-byte integer values (11.3) */ 0018 #define DCCPF_ACK_RATIO_MAX 0xFFFF 0019 /* Wmin=32 and Wmax=2^46-1 from 7.5.2 */ 0020 #define DCCPF_SEQ_WMIN 32 0021 #define DCCPF_SEQ_WMAX 0x3FFFFFFFFFFFull 0022 /* Maximum number of SP values that fit in a single (Confirm) option */ 0023 #define DCCP_FEAT_MAX_SP_VALS (DCCP_SINGLE_OPT_MAXLEN - 2) 0024 0025 enum dccp_feat_type { 0026 FEAT_AT_RX = 1, /* located at RX side of half-connection */ 0027 FEAT_AT_TX = 2, /* located at TX side of half-connection */ 0028 FEAT_SP = 4, /* server-priority reconciliation (6.3.1) */ 0029 FEAT_NN = 8, /* non-negotiable reconciliation (6.3.2) */ 0030 FEAT_UNKNOWN = 0xFF /* not understood or invalid feature */ 0031 }; 0032 0033 enum dccp_feat_state { 0034 FEAT_DEFAULT = 0, /* using default values from 6.4 */ 0035 FEAT_INITIALISING, /* feature is being initialised */ 0036 FEAT_CHANGING, /* Change sent but not confirmed yet */ 0037 FEAT_UNSTABLE, /* local modification in state CHANGING */ 0038 FEAT_STABLE /* both ends (think they) agree */ 0039 }; 0040 0041 /** 0042 * dccp_feat_val - Container for SP or NN feature values 0043 * @nn: single NN value 0044 * @sp.vec: single SP value plus optional preference list 0045 * @sp.len: length of @sp.vec in bytes 0046 */ 0047 typedef union { 0048 u64 nn; 0049 struct { 0050 u8 *vec; 0051 u8 len; 0052 } sp; 0053 } dccp_feat_val; 0054 0055 /** 0056 * struct feat_entry - Data structure to perform feature negotiation 0057 * @val: feature's current value (SP features may have preference list) 0058 * @state: feature's current state 0059 * @feat_num: one of %dccp_feature_numbers 0060 * @needs_mandatory: whether Mandatory options should be sent 0061 * @needs_confirm: whether to send a Confirm instead of a Change 0062 * @empty_confirm: whether to send an empty Confirm (depends on @needs_confirm) 0063 * @is_local: feature location (1) or feature-remote (0) 0064 * @node: list pointers, entries arranged in FIFO order 0065 */ 0066 struct dccp_feat_entry { 0067 dccp_feat_val val; 0068 enum dccp_feat_state state:8; 0069 u8 feat_num; 0070 0071 bool needs_mandatory, 0072 needs_confirm, 0073 empty_confirm, 0074 is_local; 0075 0076 struct list_head node; 0077 }; 0078 0079 static inline u8 dccp_feat_genopt(struct dccp_feat_entry *entry) 0080 { 0081 if (entry->needs_confirm) 0082 return entry->is_local ? DCCPO_CONFIRM_L : DCCPO_CONFIRM_R; 0083 return entry->is_local ? DCCPO_CHANGE_L : DCCPO_CHANGE_R; 0084 } 0085 0086 /** 0087 * struct ccid_dependency - Track changes resulting from choosing a CCID 0088 * @dependent_feat: one of %dccp_feature_numbers 0089 * @is_local: local (1) or remote (0) @dependent_feat 0090 * @is_mandatory: whether presence of @dependent_feat is mission-critical or not 0091 * @val: corresponding default value for @dependent_feat (u8 is sufficient here) 0092 */ 0093 struct ccid_dependency { 0094 u8 dependent_feat; 0095 bool is_local:1, 0096 is_mandatory:1; 0097 u8 val; 0098 }; 0099 0100 /* 0101 * Sysctls to seed defaults for feature negotiation 0102 */ 0103 extern unsigned long sysctl_dccp_sequence_window; 0104 extern int sysctl_dccp_rx_ccid; 0105 extern int sysctl_dccp_tx_ccid; 0106 0107 int dccp_feat_init(struct sock *sk); 0108 void dccp_feat_initialise_sysctls(void); 0109 int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local, 0110 u8 const *list, u8 len); 0111 int dccp_feat_parse_options(struct sock *, struct dccp_request_sock *, 0112 u8 mand, u8 opt, u8 feat, u8 *val, u8 len); 0113 int dccp_feat_clone_list(struct list_head const *, struct list_head *); 0114 0115 /* 0116 * Encoding variable-length options and their maximum length. 0117 * 0118 * This affects NN options (SP options are all u8) and other variable-length 0119 * options (see table 3 in RFC 4340). The limit is currently given the Sequence 0120 * Window NN value (sec. 7.5.2) and the NDP count (sec. 7.7) option, all other 0121 * options consume less than 6 bytes (timestamps are 4 bytes). 0122 * When updating this constant (e.g. due to new internet drafts / RFCs), make 0123 * sure that you also update all code which refers to it. 0124 */ 0125 #define DCCP_OPTVAL_MAXLEN 6 0126 0127 void dccp_encode_value_var(const u64 value, u8 *to, const u8 len); 0128 u64 dccp_decode_value_var(const u8 *bf, const u8 len); 0129 u64 dccp_feat_nn_get(struct sock *sk, u8 feat); 0130 0131 int dccp_insert_option_mandatory(struct sk_buff *skb); 0132 int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat, u8 *val, u8 len, 0133 bool repeat_first); 0134 #endif /* _DCCP_FEAT_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |