Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
feat.h
Go to the documentation of this file.
1 #ifndef _DCCP_FEAT_H
2 #define _DCCP_FEAT_H
3 /*
4  * net/dccp/feat.h
5  *
6  * Feature negotiation for the DCCP protocol (RFC 4340, section 6)
7  * Copyright (c) 2008 Gerrit Renker <[email protected]>
8  * Copyright (c) 2005 Andrea Bittau <[email protected]>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 #include <linux/types.h>
15 #include "dccp.h"
16 
17 /*
18  * Known limit values
19  */
20 /* Ack Ratio takes 2-byte integer values (11.3) */
21 #define DCCPF_ACK_RATIO_MAX 0xFFFF
22 /* Wmin=32 and Wmax=2^46-1 from 7.5.2 */
23 #define DCCPF_SEQ_WMIN 32
24 #define DCCPF_SEQ_WMAX 0x3FFFFFFFFFFFull
25 /* Maximum number of SP values that fit in a single (Confirm) option */
26 #define DCCP_FEAT_MAX_SP_VALS (DCCP_SINGLE_OPT_MAXLEN - 2)
27 
29  FEAT_AT_RX = 1, /* located at RX side of half-connection */
30  FEAT_AT_TX = 2, /* located at TX side of half-connection */
31  FEAT_SP = 4, /* server-priority reconciliation (6.3.1) */
32  FEAT_NN = 8, /* non-negotiable reconciliation (6.3.2) */
33  FEAT_UNKNOWN = 0xFF /* not understood or invalid feature */
34 };
35 
37  FEAT_DEFAULT = 0, /* using default values from 6.4 */
38  FEAT_INITIALISING, /* feature is being initialised */
39  FEAT_CHANGING, /* Change sent but not confirmed yet */
40  FEAT_UNSTABLE, /* local modification in state CHANGING */
41  FEAT_STABLE /* both ends (think they) agree */
42 };
43 
50 typedef union {
52  struct {
53  u8 *vec;
55  } sp;
57 
72  u8 feat_num;
73 
77  is_local;
78 
79  struct list_head node;
80 };
81 
82 static inline u8 dccp_feat_genopt(struct dccp_feat_entry *entry)
83 {
84  if (entry->needs_confirm)
85  return entry->is_local ? DCCPO_CONFIRM_L : DCCPO_CONFIRM_R;
86  return entry->is_local ? DCCPO_CHANGE_L : DCCPO_CHANGE_R;
87 }
88 
98  bool is_local:1,
99  is_mandatory:1;
101 };
102 
103 /*
104  * Sysctls to seed defaults for feature negotiation
105  */
106 extern unsigned long sysctl_dccp_sequence_window;
107 extern int sysctl_dccp_rx_ccid;
108 extern int sysctl_dccp_tx_ccid;
109 
110 extern int dccp_feat_init(struct sock *sk);
111 extern void dccp_feat_initialise_sysctls(void);
112 extern int dccp_feat_register_sp(struct sock *sk, u8 feat, u8 is_local,
113  u8 const *list, u8 len);
114 extern int dccp_feat_parse_options(struct sock *, struct dccp_request_sock *,
115  u8 mand, u8 opt, u8 feat, u8 *val, u8 len);
116 extern int dccp_feat_clone_list(struct list_head const *, struct list_head *);
117 
118 /*
119  * Encoding variable-length options and their maximum length.
120  *
121  * This affects NN options (SP options are all u8) and other variable-length
122  * options (see table 3 in RFC 4340). The limit is currently given the Sequence
123  * Window NN value (sec. 7.5.2) and the NDP count (sec. 7.7) option, all other
124  * options consume less than 6 bytes (timestamps are 4 bytes).
125  * When updating this constant (e.g. due to new internet drafts / RFCs), make
126  * sure that you also update all code which refers to it.
127  */
128 #define DCCP_OPTVAL_MAXLEN 6
129 
130 extern void dccp_encode_value_var(const u64 value, u8 *to, const u8 len);
131 extern u64 dccp_decode_value_var(const u8 *bf, const u8 len);
132 extern u64 dccp_feat_nn_get(struct sock *sk, u8 feat);
133 
134 extern int dccp_insert_option_mandatory(struct sk_buff *skb);
135 extern int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat,
136  u8 *val, u8 len, bool repeat_first);
137 #endif /* _DCCP_FEAT_H */