aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/options.c
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-12-13 09:29:24 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:57:50 -0500
commit8b819412481494fb6861c08d360b75fabcbbfbbf (patch)
treeddd9f976f051fb5cff794992b38613bbbfcb9cc1 /net/dccp/options.c
parent7913350663e2756ecb91dd3a7c773806b943426e (diff)
[DCCP]: Allow to parse options on Request Sockets
The option parsing code currently only parses on full sk's. This causes a problem for options sent during the initial handshake (in particular timestamps and feature-negotiation options). Therefore, this patch extends the option parsing code with an additional argument for request_socks: if it is non-NULL, options are parsed on the request socket, otherwise the normal path (parsing on the sk) is used. Subsequent patches, which implement feature negotiation during connection setup, make use of this facility. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-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.c34
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
49int 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 */
54int 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 260ignore_option:
249 if (opt != DCCPO_MANDATORY) 261 if (opt != DCCPO_MANDATORY)
250 mandatory = 0; 262 mandatory = 0;
251 } 263 }