blob: c480c506a4a47c7708cea4ed2ce877fbc62ece88 [file] [log] [blame]
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -07001/*
2 * net/dccp/options.c
3 *
4 * An implementation of the DCCP protocol
Ian McDonald1bc09862005-08-20 00:23:43 -03005 * Copyright (c) 2005 Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
6 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
7 * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -07008 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14#include <linux/config.h>
15#include <linux/dccp.h>
16#include <linux/module.h>
17#include <linux/types.h>
18#include <linux/kernel.h>
19#include <linux/skbuff.h>
20
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070021#include "ackvec.h"
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070022#include "ccid.h"
23#include "dccp.h"
24
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070025/* stores the default values for new connection. may be changed with sysctl */
26static const struct dccp_options dccpo_default_values = {
27 .dccpo_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW,
28 .dccpo_ccid = DCCPF_INITIAL_CCID,
29 .dccpo_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR,
30 .dccpo_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT,
31};
32
33void dccp_options_init(struct dccp_options *dccpo)
34{
35 memcpy(dccpo, &dccpo_default_values, sizeof(*dccpo));
36}
37
38static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
39{
40 u32 value = 0;
41
42 if (len > 3)
43 value += *bf++ << 24;
44 if (len > 2)
45 value += *bf++ << 16;
46 if (len > 1)
47 value += *bf++ << 8;
48 if (len > 0)
49 value += *bf;
50
51 return value;
52}
53
54int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
55{
56 struct dccp_sock *dp = dccp_sk(sk);
Arnaldo Carvalho de Melo725ba8e2005-08-13 20:35:39 -030057#ifdef CONFIG_IP_DCCP_DEBUG
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -030058 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
59 "CLIENT rx opt: " : "server rx opt: ";
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070060#endif
61 const struct dccp_hdr *dh = dccp_hdr(skb);
62 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
63 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
64 unsigned char *opt_ptr = options;
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -030065 const unsigned char *opt_end = (unsigned char *)dh +
66 (dh->dccph_doff * 4);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070067 struct dccp_options_received *opt_recv = &dp->dccps_options_received;
68 unsigned char opt, len;
69 unsigned char *value;
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -030070 u32 elapsed_time;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070071
72 memset(opt_recv, 0, sizeof(*opt_recv));
73
74 while (opt_ptr != opt_end) {
75 opt = *opt_ptr++;
76 len = 0;
77 value = NULL;
78
79 /* Check if this isn't a single byte option */
80 if (opt > DCCPO_MAX_RESERVED) {
81 if (opt_ptr == opt_end)
82 goto out_invalid_option;
83
84 len = *opt_ptr++;
85 if (len < 3)
86 goto out_invalid_option;
87 /*
88 * Remove the type and len fields, leaving
89 * just the value size
90 */
91 len -= 2;
92 value = opt_ptr;
93 opt_ptr += len;
94
95 if (opt_ptr > opt_end)
96 goto out_invalid_option;
97 }
98
99 switch (opt) {
100 case DCCPO_PADDING:
101 break;
102 case DCCPO_NDP_COUNT:
103 if (len > 3)
104 goto out_invalid_option;
105
106 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300107 dccp_pr_debug("%sNDP count=%d\n", debug_prefix,
108 opt_recv->dccpor_ndp);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700109 break;
110 case DCCPO_ACK_VECTOR_0:
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700111 case DCCPO_ACK_VECTOR_1:
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700112 if (pkt_type == DCCP_PKT_DATA)
113 continue;
114
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700115 if (dp->dccps_options.dccpo_send_ack_vector &&
116 dccp_ackvec_parse(sk, skb, opt, value, len))
117 goto out_invalid_option;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700118 break;
119 case DCCPO_TIMESTAMP:
120 if (len != 4)
121 goto out_invalid_option;
122
123 opt_recv->dccpor_timestamp = ntohl(*(u32 *)value);
124
125 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300126 dccp_timestamp(sk, &dp->dccps_timestamp_time);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700127
128 dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n",
129 debug_prefix, opt_recv->dccpor_timestamp,
David S. Millerf6ccf552005-08-09 20:27:14 -0700130 (unsigned long long)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700131 DCCP_SKB_CB(skb)->dccpd_ack_seq);
132 break;
133 case DCCPO_TIMESTAMP_ECHO:
Ian McDonald1bc09862005-08-20 00:23:43 -0300134 if (len != 4 && len != 6 && len != 8)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700135 goto out_invalid_option;
136
137 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value);
138
Ian McDonald1bc09862005-08-20 00:23:43 -0300139 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, ",
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300140 debug_prefix,
141 opt_recv->dccpor_timestamp_echo,
David S. Millerf6ccf552005-08-09 20:27:14 -0700142 len + 2,
143 (unsigned long long)
Ian McDonald1bc09862005-08-20 00:23:43 -0300144 DCCP_SKB_CB(skb)->dccpd_ack_seq);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700145
Ian McDonald1bc09862005-08-20 00:23:43 -0300146
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300147 if (len == 4)
148 break;
149
150 if (len == 6)
151 elapsed_time = ntohs(*(u16 *)(value + 4));
152 else
153 elapsed_time = ntohl(*(u32 *)(value + 4));
154
155 /* Give precedence to the biggest ELAPSED_TIME */
156 if (elapsed_time > opt_recv->dccpor_elapsed_time)
157 opt_recv->dccpor_elapsed_time = elapsed_time;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700158 break;
159 case DCCPO_ELAPSED_TIME:
Ian McDonald1bc09862005-08-20 00:23:43 -0300160 if (len != 2 && len != 4)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700161 goto out_invalid_option;
162
163 if (pkt_type == DCCP_PKT_DATA)
164 continue;
Ian McDonald1bc09862005-08-20 00:23:43 -0300165
166 if (len == 2)
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300167 elapsed_time = ntohs(*(u16 *)value);
Ian McDonald1bc09862005-08-20 00:23:43 -0300168 else
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300169 elapsed_time = ntohl(*(u32 *)value);
170
171 if (elapsed_time > opt_recv->dccpor_elapsed_time)
172 opt_recv->dccpor_elapsed_time = elapsed_time;
Ian McDonald1bc09862005-08-20 00:23:43 -0300173
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700174 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix,
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300175 elapsed_time);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700176 break;
177 /*
178 * From draft-ietf-dccp-spec-11.txt:
179 *
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300180 * Option numbers 128 through 191 are for
181 * options sent from the HC-Sender to the
182 * HC-Receiver; option numbers 192 through 255
183 * are for options sent from the HC-Receiver to
184 * the HC-Sender.
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700185 */
186 case 128 ... 191: {
187 const u16 idx = value - options;
188
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300189 if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
190 opt, len, idx,
191 value) != 0)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700192 goto out_invalid_option;
193 }
194 break;
195 case 192 ... 255: {
196 const u16 idx = value - options;
197
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300198 if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
199 opt, len, idx,
200 value) != 0)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700201 goto out_invalid_option;
202 }
203 break;
204 default:
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300205 pr_info("DCCP(%p): option %d(len=%d) not "
206 "implemented, ignoring\n",
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700207 sk, opt, len);
208 break;
209 }
210 }
211
212 return 0;
213
214out_invalid_option:
215 DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT);
216 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_OPTION_ERROR;
217 pr_info("DCCP(%p): invalid option %d, len=%d\n", sk, opt, len);
218 return -1;
219}
220
221static void dccp_encode_value_var(const u32 value, unsigned char *to,
222 const unsigned int len)
223{
224 if (len > 3)
225 *to++ = (value & 0xFF000000) >> 24;
226 if (len > 2)
227 *to++ = (value & 0xFF0000) >> 16;
228 if (len > 1)
229 *to++ = (value & 0xFF00) >> 8;
230 if (len > 0)
231 *to++ = (value & 0xFF);
232}
233
234static inline int dccp_ndp_len(const int ndp)
235{
236 return likely(ndp <= 0xFF) ? 1 : ndp <= 0xFFFF ? 2 : 3;
237}
238
239void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
240 const unsigned char option,
241 const void *value, const unsigned char len)
242{
243 unsigned char *to;
244
245 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) {
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300246 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
247 "%d option!\n", option);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700248 return;
249 }
250
251 DCCP_SKB_CB(skb)->dccpd_opt_len += len + 2;
252
253 to = skb_push(skb, len + 2);
254 *to++ = option;
255 *to++ = len + 2;
256
257 memcpy(to, value, len);
258}
259
260EXPORT_SYMBOL_GPL(dccp_insert_option);
261
262static void dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb)
263{
264 struct dccp_sock *dp = dccp_sk(sk);
265 int ndp = dp->dccps_ndp_count;
266
267 if (dccp_non_data_packet(skb))
268 ++dp->dccps_ndp_count;
269 else
270 dp->dccps_ndp_count = 0;
271
272 if (ndp > 0) {
273 unsigned char *ptr;
274 const int ndp_len = dccp_ndp_len(ndp);
275 const int len = ndp_len + 2;
276
277 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
278 return;
279
280 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
281
282 ptr = skb_push(skb, len);
283 *ptr++ = DCCPO_NDP_COUNT;
284 *ptr++ = len;
285 dccp_encode_value_var(ndp, ptr, ndp_len);
286 }
287}
288
289static inline int dccp_elapsed_time_len(const u32 elapsed_time)
290{
Ian McDonaldb1c9fe72005-08-18 20:45:29 -0300291 return elapsed_time == 0 ? 0 : elapsed_time <= 0xFFFF ? 2 : 4;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700292}
293
294void dccp_insert_option_elapsed_time(struct sock *sk,
295 struct sk_buff *skb,
296 u32 elapsed_time)
297{
Arnaldo Carvalho de Melo725ba8e2005-08-13 20:35:39 -0300298#ifdef CONFIG_IP_DCCP_DEBUG
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700299 struct dccp_sock *dp = dccp_sk(sk);
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300300 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
301 "CLIENT TX opt: " : "server TX opt: ";
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700302#endif
303 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
304 const int len = 2 + elapsed_time_len;
305 unsigned char *to;
306
Ian McDonald1bc09862005-08-20 00:23:43 -0300307 if (elapsed_time_len == 0)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700308 return;
309
310 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300311 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
312 "insert elapsed time!\n");
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700313 return;
314 }
315
316 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
317
318 to = skb_push(skb, len);
319 *to++ = DCCPO_ELAPSED_TIME;
320 *to++ = len;
321
Ian McDonald1bc09862005-08-20 00:23:43 -0300322 if (elapsed_time_len == 2) {
323 const u16 var16 = htons((u16)elapsed_time);
324 memcpy(to, &var16, 2);
325 } else {
326 const u32 var32 = htonl(elapsed_time);
327 memcpy(to, &var32, 4);
328 }
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700329
330 dccp_pr_debug("%sELAPSED_TIME=%u, len=%d, seqno=%llu\n",
331 debug_prefix, elapsed_time,
David S. Millerf6ccf552005-08-09 20:27:14 -0700332 len,
333 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700334}
335
Arnaldo Carvalho de Melod4b81ff2005-08-23 21:51:36 -0700336EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700337
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300338void dccp_timestamp(const struct sock *sk, struct timeval *tv)
339{
340 const struct dccp_sock *dp = dccp_sk(sk);
341
342 do_gettimeofday(tv);
343 tv->tv_sec -= dp->dccps_epoch.tv_sec;
344 tv->tv_usec -= dp->dccps_epoch.tv_usec;
345
346 while (tv->tv_usec < 0) {
347 tv->tv_sec--;
348 tv->tv_usec += USEC_PER_SEC;
349 }
350}
351
352EXPORT_SYMBOL_GPL(dccp_timestamp);
353
Arnaldo Carvalho de Melod4b81ff2005-08-23 21:51:36 -0700354void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700355{
Ian McDonald1bc09862005-08-20 00:23:43 -0300356 struct timeval tv;
357 u32 now;
358
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300359 dccp_timestamp(sk, &tv);
360 now = timeval_usecs(&tv) / 10;
Ian McDonald1bc09862005-08-20 00:23:43 -0300361 /* yes this will overflow but that is the point as we want a
362 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
363
364 now = htonl(now);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700365 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
366}
367
Arnaldo Carvalho de Melod4b81ff2005-08-23 21:51:36 -0700368EXPORT_SYMBOL_GPL(dccp_insert_option_timestamp);
369
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300370static void dccp_insert_option_timestamp_echo(struct sock *sk,
371 struct sk_buff *skb)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700372{
373 struct dccp_sock *dp = dccp_sk(sk);
Arnaldo Carvalho de Melo725ba8e2005-08-13 20:35:39 -0300374#ifdef CONFIG_IP_DCCP_DEBUG
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300375 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
376 "CLIENT TX opt: " : "server TX opt: ";
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700377#endif
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300378 struct timeval now;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700379 u32 tstamp_echo;
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300380 u32 elapsed_time;
381 int len, elapsed_time_len;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700382 unsigned char *to;
383
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300384 dccp_timestamp(sk, &now);
385 elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10;
386 elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
387 len = 6 + elapsed_time_len;
388
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700389 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300390 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
391 "timestamp echo!\n");
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700392 return;
393 }
394
395 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
396
397 to = skb_push(skb, len);
398 *to++ = DCCPO_TIMESTAMP_ECHO;
399 *to++ = len;
400
401 tstamp_echo = htonl(dp->dccps_timestamp_echo);
402 memcpy(to, &tstamp_echo, 4);
403 to += 4;
Ian McDonald1bc09862005-08-20 00:23:43 -0300404
405 if (elapsed_time_len == 2) {
406 const u16 var16 = htons((u16)elapsed_time);
407 memcpy(to, &var16, 2);
408 } else if (elapsed_time_len == 4) {
409 const u32 var32 = htonl(elapsed_time);
410 memcpy(to, &var32, 4);
411 }
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700412
413 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, seqno=%llu\n",
414 debug_prefix, dp->dccps_timestamp_echo,
David S. Millerf6ccf552005-08-09 20:27:14 -0700415 len,
416 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700417
418 dp->dccps_timestamp_echo = 0;
Ian McDonald1bc09862005-08-20 00:23:43 -0300419 dp->dccps_timestamp_time.tv_sec = 0;
420 dp->dccps_timestamp_time.tv_usec = 0;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700421}
422
423void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
424{
425 struct dccp_sock *dp = dccp_sk(sk);
426
427 DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
428
429 if (dp->dccps_options.dccpo_send_ndp_count)
430 dccp_insert_option_ndp(sk, skb);
431
432 if (!dccp_packet_without_ack(skb)) {
433 if (dp->dccps_options.dccpo_send_ack_vector &&
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700434 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec))
435 dccp_insert_option_ackvec(sk, skb);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700436 if (dp->dccps_timestamp_echo != 0)
437 dccp_insert_option_timestamp_echo(sk, skb);
438 }
439
Arnaldo Carvalho de Melo507d37c2005-09-09 02:30:07 -0300440 if (dp->dccps_hc_rx_insert_options) {
441 ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb);
442 dp->dccps_hc_rx_insert_options = 0;
443 }
444 if (dp->dccps_hc_tx_insert_options) {
445 ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb);
446 dp->dccps_hc_tx_insert_options = 0;
447 }
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700448
449 /* XXX: insert other options when appropriate */
450
451 if (DCCP_SKB_CB(skb)->dccpd_opt_len != 0) {
452 /* The length of all options has to be a multiple of 4 */
453 int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
454
455 if (padding != 0) {
456 padding = 4 - padding;
457 memset(skb_push(skb, padding), 0, padding);
458 DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
459 }
460 }
461}