diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:30:19 -0400 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:45:26 -0400 |
commit | 5c7c9451f1f422b69bf0e161e471dd3976ecd408 (patch) | |
tree | be9afac388bb4b62a34db7025d83dc8730b4510c /net/dccp/feat.c | |
parent | 959fd992f05b7468bf30d759ac0c9fd0ef0fa80b (diff) |
dccp: Basic data structure for feature negotiation
This patch prepares for the new and extended feature-negotiation routines.
The following feature-negotiation data structures are provided:
* a container for the various (SP or NN) values,
* symbolic state names to track feature states,
* an entry struct which holds all current information together,
* elementary functions to fill in and process these structures.
Entry structs are arranged as FIFO for the following reason: RFC 4340 specifies
that if multiple options of the same type are present, they are processed in the
order of their appearance in the packet; which means that this order needs to be
preserved in the local data structure (the later insertion code also respects
this order).
The struct list_head has been chosen for the following reasons: the most
frequent operations are
* add new entry at tail (when receiving Change or setting socket options);
* delete entry (when Confirm has been received);
* deep copy of entire list (cloning from listening socket onto request socket).
The NN value has been set to 64 bit, which is a currently sufficient upper limit
(Sequence Window feature has 48 bit).
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Diffstat (limited to 'net/dccp/feat.c')
-rw-r--r-- | net/dccp/feat.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/dccp/feat.c b/net/dccp/feat.c index 933a0ecf8d4..94a81b8e5ef 100644 --- a/net/dccp/feat.c +++ b/net/dccp/feat.c | |||
@@ -23,6 +23,20 @@ | |||
23 | 23 | ||
24 | #define DCCP_FEAT_SP_NOAGREE (-123) | 24 | #define DCCP_FEAT_SP_NOAGREE (-123) |
25 | 25 | ||
26 | /* copy constructor, fval must not already contain allocated memory */ | ||
27 | static int dccp_feat_clone_sp_val(dccp_feat_val *fval, u8 const *val, u8 len) | ||
28 | { | ||
29 | fval->sp.len = len; | ||
30 | if (fval->sp.len > 0) { | ||
31 | fval->sp.vec = kmemdup(val, len, gfp_any()); | ||
32 | if (fval->sp.vec == NULL) { | ||
33 | fval->sp.len = 0; | ||
34 | return -ENOBUFS; | ||
35 | } | ||
36 | } | ||
37 | return 0; | ||
38 | } | ||
39 | |||
26 | int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, | 40 | int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, |
27 | u8 *val, u8 len, gfp_t gfp) | 41 | u8 *val, u8 len, gfp_t gfp) |
28 | { | 42 | { |