diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-11-23 19:07:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-23 19:07:53 -0500 |
commit | 02fa460ef553faabc7e0b15ff9f607f028739808 (patch) | |
tree | 04342d781df0b0a1953cfcc6c52cbca7e172896a /net/dccp/options.c | |
parent | 71c262a3dd42dea73700646d969b0af7a4102edf (diff) |
dccp: Increase the scope of variable-length htonl/ntohl functions
This extends the scope of two available functions,
encode|decode_value_var, to work up to 6 (8) bytes, to match maximum
requirements in the RFC.
These functions are going to be used both by general option processing
and feature negotiation code, hence declarations have been put into
feat.h.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/options.c')
-rw-r--r-- | net/dccp/options.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/net/dccp/options.c b/net/dccp/options.c index 515ad45013ad..9cb0ff894052 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c | |||
@@ -29,16 +29,20 @@ int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID; | |||
29 | int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR; | 29 | int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR; |
30 | int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT; | 30 | int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT; |
31 | 31 | ||
32 | static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len) | 32 | u64 dccp_decode_value_var(const u8 *bf, const u8 len) |
33 | { | 33 | { |
34 | u32 value = 0; | 34 | u64 value = 0; |
35 | 35 | ||
36 | if (len >= DCCP_OPTVAL_MAXLEN) | ||
37 | value += ((u64)*bf++) << 40; | ||
38 | if (len > 4) | ||
39 | value += ((u64)*bf++) << 32; | ||
36 | if (len > 3) | 40 | if (len > 3) |
37 | value += *bf++ << 24; | 41 | value += ((u64)*bf++) << 24; |
38 | if (len > 2) | 42 | if (len > 2) |
39 | value += *bf++ << 16; | 43 | value += ((u64)*bf++) << 16; |
40 | if (len > 1) | 44 | if (len > 1) |
41 | value += *bf++ << 8; | 45 | value += ((u64)*bf++) << 8; |
42 | if (len > 0) | 46 | if (len > 0) |
43 | value += *bf; | 47 | value += *bf; |
44 | 48 | ||
@@ -298,9 +302,12 @@ out_invalid_option: | |||
298 | 302 | ||
299 | EXPORT_SYMBOL_GPL(dccp_parse_options); | 303 | EXPORT_SYMBOL_GPL(dccp_parse_options); |
300 | 304 | ||
301 | static void dccp_encode_value_var(const u32 value, unsigned char *to, | 305 | void dccp_encode_value_var(const u64 value, u8 *to, const u8 len) |
302 | const unsigned int len) | ||
303 | { | 306 | { |
307 | if (len >= DCCP_OPTVAL_MAXLEN) | ||
308 | *to++ = (value & 0xFF0000000000ull) >> 40; | ||
309 | if (len > 4) | ||
310 | *to++ = (value & 0xFF00000000ull) >> 32; | ||
304 | if (len > 3) | 311 | if (len > 3) |
305 | *to++ = (value & 0xFF000000) >> 24; | 312 | *to++ = (value & 0xFF000000) >> 24; |
306 | if (len > 2) | 313 | if (len > 2) |