#ifndef _DCCP_FEAT_H1#define _DCCP_FEAT_H2/*3* net/dccp/feat.h4*5* Feature negotiation for the DCCP protocol (RFC 4340, section 6)6* Copyright (c) 2008 Gerrit Renker <[email protected]>7* Copyright (c) 2005 Andrea Bittau <[email protected]>8*9* This program is free software; you can redistribute it and/or modify it10* under the terms of the GNU General Public License version 2 as11* published by the Free Software Foundation.12*/13#include <linux/types.h>14#include "dccp.h"1516/*17* Known limit values18*/19/* Ack Ratio takes 2-byte integer values (11.3) */20#define DCCPF_ACK_RATIO_MAX 0xFFFF21/* Wmin=32 and Wmax=2^46-1 from 7.5.2 */22#define DCCPF_SEQ_WMIN 3223#define DCCPF_SEQ_WMAX 0x3FFFFFFFFFFFull24/* Maximum number of SP values that fit in a single (Confirm) option */25#define DCCP_FEAT_MAX_SP_VALS (DCCP_SINGLE_OPT_MAXLEN - 2)2627enum dccp_feat_type {28FEAT_AT_RX = 1, /* located at RX side of half-connection */29FEAT_AT_TX = 2, /* located at TX side of half-connection */30FEAT_SP = 4, /* server-priority reconciliation (6.3.1) */31FEAT_NN = 8, /* non-negotiable reconciliation (6.3.2) */32FEAT_UNKNOWN = 0xFF /* not understood or invalid feature */33};3435enum dccp_feat_state {36FEAT_DEFAULT = 0, /* using default values from 6.4 */37FEAT_INITIALISING, /* feature is being initialised */38FEAT_CHANGING, /* Change sent but not confirmed yet */39FEAT_UNSTABLE, /* local modification in state CHANGING */40FEAT_STABLE /* both ends (think they) agree */41};4243/**44* dccp_feat_val - Container for SP or NN feature values45* @nn: single NN value46* @sp.vec: single SP value plus optional preference list47* @sp.len: length of @sp.vec in bytes48*/49typedef union {50u64 nn;51struct {52u8 *vec;53u8 len;54} sp;55} dccp_feat_val;5657/**58* struct feat_entry - Data structure to perform feature negotiation59* @val: feature's current value (SP features may have preference list)60* @state: feature's current state61* @feat_num: one of %dccp_feature_numbers62* @needs_mandatory: whether Mandatory options should be sent63* @needs_confirm: whether to send a Confirm instead of a Change64* @empty_confirm: whether to send an empty Confirm (depends on @needs_confirm)65* @is_local: feature location (1) or feature-remote (0)66* @node: list pointers, entries arranged in FIFO order67*/68struct dccp_feat_entry {69dccp_feat_val val;70enum dccp_feat_state state:8;71u8 feat_num;7273bool needs_mandatory,74needs_confirm,75empty_confirm,76is_local;7778struct list_head node;79};8081static inline u8 dccp_feat_genopt(struct dccp_feat_entry *entry)82{83if (entry->needs_confirm)84return entry->is_local ? DCCPO_CONFIRM_L : DCCPO_CONFIRM_R;85return entry->is_local ? DCCPO_CHANGE_L : DCCPO_CHANGE_R;86}8788/**89* struct ccid_dependency - Track changes resulting from choosing a CCID90* @dependent_feat: one of %dccp_feature_numbers91* @is_local: local (1) or remote (0) @dependent_feat92* @is_mandatory: whether presence of @dependent_feat is mission-critical or not93* @val: corresponding default value for @dependent_feat (u8 is sufficient here)94*/95struct ccid_dependency {96u8 dependent_feat;97bool is_local:1,98is_mandatory:1;99u8 val;100};101102/*103* Sysctls to seed defaults for feature negotiation104*/105extern unsigned long sysctl_dccp_sequence_window;106extern int sysctl_dccp_rx_ccid;107extern int sysctl_dccp_tx_ccid;108109extern int dccp_feat_init(struct sock *sk);110extern void dccp_feat_initialise_sysctls(void);111extern int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,112u8 const *list, u8 len);113extern int dccp_feat_parse_options(struct sock *, struct dccp_request_sock *,114u8 mand, u8 opt, u8 feat, u8 *val, u8 len);115extern int dccp_feat_clone_list(struct list_head const *, struct list_head *);116117/*118* Encoding variable-length options and their maximum length.119*120* This affects NN options (SP options are all u8) and other variable-length121* options (see table 3 in RFC 4340). The limit is currently given the Sequence122* Window NN value (sec. 7.5.2) and the NDP count (sec. 7.7) option, all other123* options consume less than 6 bytes (timestamps are 4 bytes).124* When updating this constant (e.g. due to new internet drafts / RFCs), make125* sure that you also update all code which refers to it.126*/127#define DCCP_OPTVAL_MAXLEN 6128129extern void dccp_encode_value_var(const u64 value, u8 *to, const u8 len);130extern u64 dccp_decode_value_var(const u8 *bf, const u8 len);131132extern int dccp_insert_option_mandatory(struct sk_buff *skb);133extern int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat,134u8 *val, u8 len, bool repeat_first);135#endif /* _DCCP_FEAT_H */136137138