diff options
Diffstat (limited to 'net/dccp/options.c')
-rw-r--r-- | net/dccp/options.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/net/dccp/options.c b/net/dccp/options.c index 523250b45ea5..f496d4dc7efc 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c | |||
@@ -46,7 +46,13 @@ static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len) | |||
46 | return value; | 46 | return value; |
47 | } | 47 | } |
48 | 48 | ||
49 | int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | 49 | /** |
50 | * dccp_parse_options - Parse DCCP options present in @skb | ||
51 | * @sk: client|server|listening dccp socket (when @dreq != NULL) | ||
52 | * @dreq: request socket to use during connection setup, or NULL | ||
53 | */ | ||
54 | int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq, | ||
55 | struct sk_buff *skb) | ||
50 | { | 56 | { |
51 | struct dccp_sock *dp = dccp_sk(sk); | 57 | struct dccp_sock *dp = dccp_sk(sk); |
52 | const struct dccp_hdr *dh = dccp_hdr(skb); | 58 | const struct dccp_hdr *dh = dccp_hdr(skb); |
@@ -92,6 +98,20 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
92 | goto out_invalid_option; | 98 | goto out_invalid_option; |
93 | } | 99 | } |
94 | 100 | ||
101 | /* | ||
102 | * CCID-Specific Options (from RFC 4340, sec. 10.3): | ||
103 | * | ||
104 | * Option numbers 128 through 191 are for options sent from the | ||
105 | * HC-Sender to the HC-Receiver; option numbers 192 through 255 | ||
106 | * are for options sent from the HC-Receiver to the HC-Sender. | ||
107 | * | ||
108 | * CCID-specific options are ignored during connection setup, as | ||
109 | * negotiation may still be in progress (see RFC 4340, 10.3). | ||
110 | * | ||
111 | */ | ||
112 | if (dreq != NULL && opt >= 128) | ||
113 | goto ignore_option; | ||
114 | |||
95 | switch (opt) { | 115 | switch (opt) { |
96 | case DCCPO_PADDING: | 116 | case DCCPO_PADDING: |
97 | break; | 117 | break; |
@@ -150,6 +170,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
150 | opt_val = get_unaligned((__be32 *)value); | 170 | opt_val = get_unaligned((__be32 *)value); |
151 | opt_recv->dccpor_timestamp = ntohl(opt_val); | 171 | opt_recv->dccpor_timestamp = ntohl(opt_val); |
152 | 172 | ||
173 | /* FIXME: if dreq != NULL, don't store this on listening socket */ | ||
153 | dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; | 174 | dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; |
154 | dp->dccps_timestamp_time = ktime_get_real(); | 175 | dp->dccps_timestamp_time = ktime_get_real(); |
155 | 176 | ||
@@ -213,15 +234,6 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
213 | dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n", | 234 | dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n", |
214 | dccp_role(sk), elapsed_time); | 235 | dccp_role(sk), elapsed_time); |
215 | break; | 236 | break; |
216 | /* | ||
217 | * From RFC 4340, sec. 10.3: | ||
218 | * | ||
219 | * Option numbers 128 through 191 are for | ||
220 | * options sent from the HC-Sender to the | ||
221 | * HC-Receiver; option numbers 192 through 255 | ||
222 | * are for options sent from the HC-Receiver to | ||
223 | * the HC-Sender. | ||
224 | */ | ||
225 | case 128 ... 191: { | 237 | case 128 ... 191: { |
226 | const u16 idx = value - options; | 238 | const u16 idx = value - options; |
227 | 239 | ||
@@ -245,7 +257,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
245 | "implemented, ignoring", sk, opt, len); | 257 | "implemented, ignoring", sk, opt, len); |
246 | break; | 258 | break; |
247 | } | 259 | } |
248 | 260 | ignore_option: | |
249 | if (opt != DCCPO_MANDATORY) | 261 | if (opt != DCCPO_MANDATORY) |
250 | mandatory = 0; | 262 | mandatory = 0; |
251 | } | 263 | } |