Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 122104
b: refs/heads/master
c: 02fa460
h: refs/heads/master
v: v3
  • Loading branch information
Gerrit Renker authored and David S. Miller committed Nov 24, 2008
1 parent e52806d commit ad5b2e2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 71c262a3dd42dea73700646d969b0af7a4102edf
refs/heads/master: 02fa460ef553faabc7e0b15ff9f607f028739808
14 changes: 14 additions & 0 deletions trunk/net/dccp/feat.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,18 @@ extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk);
extern int dccp_feat_clone_list(struct list_head const *, struct list_head *);
extern int dccp_feat_init(struct sock *sk);

/*
* Encoding variable-length options and their maximum length.
*
* This affects NN options (SP options are all u8) and other variable-length
* options (see table 3 in RFC 4340). The limit is currently given the Sequence
* Window NN value (sec. 7.5.2) and the NDP count (sec. 7.7) option, all other
* options consume less than 6 bytes (timestamps are 4 bytes).
* When updating this constant (e.g. due to new internet drafts / RFCs), make
* sure that you also update all code which refers to it.
*/
#define DCCP_OPTVAL_MAXLEN 6

extern void dccp_encode_value_var(const u64 value, u8 *to, const u8 len);
extern u64 dccp_decode_value_var(const u8 *bf, const u8 len);
#endif /* _DCCP_FEAT_H */
21 changes: 14 additions & 7 deletions trunk/net/dccp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID;
int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR;
int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT;

static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
u64 dccp_decode_value_var(const u8 *bf, const u8 len)
{
u32 value = 0;
u64 value = 0;

if (len >= DCCP_OPTVAL_MAXLEN)
value += ((u64)*bf++) << 40;
if (len > 4)
value += ((u64)*bf++) << 32;
if (len > 3)
value += *bf++ << 24;
value += ((u64)*bf++) << 24;
if (len > 2)
value += *bf++ << 16;
value += ((u64)*bf++) << 16;
if (len > 1)
value += *bf++ << 8;
value += ((u64)*bf++) << 8;
if (len > 0)
value += *bf;

Expand Down Expand Up @@ -298,9 +302,12 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,

EXPORT_SYMBOL_GPL(dccp_parse_options);

static void dccp_encode_value_var(const u32 value, unsigned char *to,
const unsigned int len)
void dccp_encode_value_var(const u64 value, u8 *to, const u8 len)
{
if (len >= DCCP_OPTVAL_MAXLEN)
*to++ = (value & 0xFF0000000000ull) >> 40;
if (len > 4)
*to++ = (value & 0xFF00000000ull) >> 32;
if (len > 3)
*to++ = (value & 0xFF000000) >> 24;
if (len > 2)
Expand Down

0 comments on commit ad5b2e2

Please sign in to comment.