diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2006-11-14 09:48:10 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:22:29 -0500 |
commit | c02fdc0e81e9c735d8d895af1e201b235df326d8 (patch) | |
tree | f30af6744e4ecea9e5bb12483addb306d49ce458 /net/dccp/feat.h | |
parent | 6a128e053e75a5f1be9fb53d0d53159f88197c61 (diff) |
[DCCP]: Make feature negotiation more readable
This patch replaces cryptic feature negotiation messages of type
Oct 31 15:42:20 kernel: dccp_feat_change: feat change type=32 feat=1
Oct 31 15:42:21 kernel: dccp_feat_change: feat change type=34 feat=1
Oct 31 15:42:21 kernel: dccp_feat_change: feat change type=32 feat=5
into ones of type:
Nov 2 13:54:45 kernel: dccp_feat_change: ChangeL(CCID (1), 3)
Nov 2 13:54:45 kernel: dccp_feat_change: ChangeR(CCID (1), 3)
Nov 2 13:54:45 kernel: dccp_feat_change: ChangeL(Ack Ratio (5), 2)
Also,
* completed the feature number list wrt RFC 4340 sec. 6.4
* annotating which ones have been implemented so far
* implemented rudimentary sanity checking in feat.c (FIXMEs)
* some minor fixes
Commiter note: uninlined dccp_feat_name and dccp_feat_typename, for
consistency with dccp_{state,packet}_name, that, BTW,
should be compiled only if CONFIG_IP_DCCP_DEBUG is
selected, leaving this to another cset tho. Also
shortened dccp_feat_negotiation_debug to dccp_feat_debug.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp/feat.h')
-rw-r--r-- | net/dccp/feat.h | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/net/dccp/feat.h b/net/dccp/feat.h index 6048373c7186..2c373ad7edcf 100644 --- a/net/dccp/feat.h +++ b/net/dccp/feat.h | |||
@@ -12,9 +12,46 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include "dccp.h" | ||
15 | 16 | ||
16 | struct sock; | 17 | static inline int dccp_feat_is_valid_length(u8 type, u8 feature, u8 len) |
17 | struct dccp_minisock; | 18 | { |
19 | /* sec. 6.1: Confirm has at least length 3, | ||
20 | * sec. 6.2: Change has at least length 4 */ | ||
21 | if (len < 3) | ||
22 | return 1; | ||
23 | if (len < 4 && (type == DCCPO_CHANGE_L || type == DCCPO_CHANGE_R)) | ||
24 | return 1; | ||
25 | /* XXX: add per-feature length validation (sec. 6.6.8) */ | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | static inline int dccp_feat_is_reserved(const u8 feat) | ||
30 | { | ||
31 | return (feat > DCCPF_DATA_CHECKSUM && | ||
32 | feat < DCCPF_MIN_CCID_SPECIFIC) || | ||
33 | feat == DCCPF_RESERVED; | ||
34 | } | ||
35 | |||
36 | /* feature negotiation knows only these four option types (RFC 4340, sec. 6) */ | ||
37 | static inline int dccp_feat_is_valid_type(const u8 optnum) | ||
38 | { | ||
39 | return optnum >= DCCPO_CHANGE_L && optnum <= DCCPO_CONFIRM_R; | ||
40 | |||
41 | } | ||
42 | |||
43 | #ifdef CONFIG_IP_DCCP_DEBUG | ||
44 | extern const char *dccp_feat_typename(const u8 type); | ||
45 | extern const char *dccp_feat_name(const u8 feat); | ||
46 | |||
47 | static inline void dccp_feat_debug(const u8 type, const u8 feat, const u8 val) | ||
48 | { | ||
49 | dccp_pr_debug("%s(%s (%d), %d)\n", dccp_feat_typename(type), | ||
50 | dccp_feat_name(feat), feat, val); | ||
51 | } | ||
52 | #else | ||
53 | #define dccp_feat_debug(type, feat, val) | ||
54 | #endif /* CONFIG_IP_DCCP_DEBUG */ | ||
18 | 55 | ||
19 | extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, | 56 | extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, |
20 | u8 *val, u8 len, gfp_t gfp); | 57 | u8 *val, u8 len, gfp_t gfp); |