[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>
This commit is contained in:
Gerrit Renker
2006-11-14 12:48:10 -02:00
committed by David S. Miller
parent 6a128e053e
commit c02fdc0e81
4 changed files with 145 additions and 41 deletions

View File

@@ -12,9 +12,46 @@
*/
#include <linux/types.h>
#include "dccp.h"
struct sock;
struct dccp_minisock;
static inline int dccp_feat_is_valid_length(u8 type, u8 feature, u8 len)
{
/* sec. 6.1: Confirm has at least length 3,
* sec. 6.2: Change has at least length 4 */
if (len < 3)
return 1;
if (len < 4 && (type == DCCPO_CHANGE_L || type == DCCPO_CHANGE_R))
return 1;
/* XXX: add per-feature length validation (sec. 6.6.8) */
return 0;
}
static inline int dccp_feat_is_reserved(const u8 feat)
{
return (feat > DCCPF_DATA_CHECKSUM &&
feat < DCCPF_MIN_CCID_SPECIFIC) ||
feat == DCCPF_RESERVED;
}
/* feature negotiation knows only these four option types (RFC 4340, sec. 6) */
static inline int dccp_feat_is_valid_type(const u8 optnum)
{
return optnum >= DCCPO_CHANGE_L && optnum <= DCCPO_CONFIRM_R;
}
#ifdef CONFIG_IP_DCCP_DEBUG
extern const char *dccp_feat_typename(const u8 type);
extern const char *dccp_feat_name(const u8 feat);
static inline void dccp_feat_debug(const u8 type, const u8 feat, const u8 val)
{
dccp_pr_debug("%s(%s (%d), %d)\n", dccp_feat_typename(type),
dccp_feat_name(feat), feat, val);
}
#else
#define dccp_feat_debug(type, feat, val)
#endif /* CONFIG_IP_DCCP_DEBUG */
extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,
u8 *val, u8 len, gfp_t gfp);