blob: 0a76426c9aeab322f6eae5dd8e8e2309e1454d98 [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,
Arnaldo Carvalho de Melo561713c2005-09-18 00:18:52 -070028 .dccpo_rx_ccid = DCCPF_INITIAL_CCID,
29 .dccpo_tx_ccid = DCCPF_INITIAL_CCID,
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070030 .dccpo_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR,
31 .dccpo_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT,
32};
33
34void dccp_options_init(struct dccp_options *dccpo)
35{
36 memcpy(dccpo, &dccpo_default_values, sizeof(*dccpo));
37}
38
39static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
40{
41 u32 value = 0;
42
43 if (len > 3)
44 value += *bf++ << 24;
45 if (len > 2)
46 value += *bf++ << 16;
47 if (len > 1)
48 value += *bf++ << 8;
49 if (len > 0)
50 value += *bf;
51
52 return value;
53}
54
55int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
56{
57 struct dccp_sock *dp = dccp_sk(sk);
Arnaldo Carvalho de Melo725ba8e2005-08-13 20:35:39 -030058#ifdef CONFIG_IP_DCCP_DEBUG
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -030059 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
60 "CLIENT rx opt: " : "server rx opt: ";
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070061#endif
62 const struct dccp_hdr *dh = dccp_hdr(skb);
63 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
64 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
65 unsigned char *opt_ptr = options;
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -030066 const unsigned char *opt_end = (unsigned char *)dh +
67 (dh->dccph_doff * 4);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070068 struct dccp_options_received *opt_recv = &dp->dccps_options_received;
69 unsigned char opt, len;
70 unsigned char *value;
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -030071 u32 elapsed_time;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -070072
73 memset(opt_recv, 0, sizeof(*opt_recv));
74
75 while (opt_ptr != opt_end) {
76 opt = *opt_ptr++;
77 len = 0;
78 value = NULL;
79
80 /* Check if this isn't a single byte option */
81 if (opt > DCCPO_MAX_RESERVED) {
82 if (opt_ptr == opt_end)
83 goto out_invalid_option;
84
85 len = *opt_ptr++;
86 if (len < 3)
87 goto out_invalid_option;
88 /*
89 * Remove the type and len fields, leaving
90 * just the value size
91 */
92 len -= 2;
93 value = opt_ptr;
94 opt_ptr += len;
95
96 if (opt_ptr > opt_end)
97 goto out_invalid_option;
98 }
99
100 switch (opt) {
101 case DCCPO_PADDING:
102 break;
103 case DCCPO_NDP_COUNT:
104 if (len > 3)
105 goto out_invalid_option;
106
107 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300108 dccp_pr_debug("%sNDP count=%d\n", debug_prefix,
109 opt_recv->dccpor_ndp);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700110 break;
111 case DCCPO_ACK_VECTOR_0:
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700112 case DCCPO_ACK_VECTOR_1:
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700113 if (pkt_type == DCCP_PKT_DATA)
114 continue;
115
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700116 if (dp->dccps_options.dccpo_send_ack_vector &&
117 dccp_ackvec_parse(sk, skb, opt, value, len))
118 goto out_invalid_option;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700119 break;
120 case DCCPO_TIMESTAMP:
121 if (len != 4)
122 goto out_invalid_option;
123
124 opt_recv->dccpor_timestamp = ntohl(*(u32 *)value);
125
126 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300127 dccp_timestamp(sk, &dp->dccps_timestamp_time);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700128
129 dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n",
130 debug_prefix, opt_recv->dccpor_timestamp,
David S. Millerf6ccf552005-08-09 20:27:14 -0700131 (unsigned long long)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700132 DCCP_SKB_CB(skb)->dccpd_ack_seq);
133 break;
134 case DCCPO_TIMESTAMP_ECHO:
Ian McDonald1bc09862005-08-20 00:23:43 -0300135 if (len != 4 && len != 6 && len != 8)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700136 goto out_invalid_option;
137
138 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value);
139
Ian McDonald1bc09862005-08-20 00:23:43 -0300140 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, ",
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300141 debug_prefix,
142 opt_recv->dccpor_timestamp_echo,
David S. Millerf6ccf552005-08-09 20:27:14 -0700143 len + 2,
144 (unsigned long long)
Ian McDonald1bc09862005-08-20 00:23:43 -0300145 DCCP_SKB_CB(skb)->dccpd_ack_seq);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700146
Ian McDonald1bc09862005-08-20 00:23:43 -0300147
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300148 if (len == 4)
149 break;
150
151 if (len == 6)
152 elapsed_time = ntohs(*(u16 *)(value + 4));
153 else
154 elapsed_time = ntohl(*(u32 *)(value + 4));
155
156 /* Give precedence to the biggest ELAPSED_TIME */
157 if (elapsed_time > opt_recv->dccpor_elapsed_time)
158 opt_recv->dccpor_elapsed_time = elapsed_time;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700159 break;
160 case DCCPO_ELAPSED_TIME:
Ian McDonald1bc09862005-08-20 00:23:43 -0300161 if (len != 2 && len != 4)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700162 goto out_invalid_option;
163
164 if (pkt_type == DCCP_PKT_DATA)
165 continue;
Ian McDonald1bc09862005-08-20 00:23:43 -0300166
167 if (len == 2)
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300168 elapsed_time = ntohs(*(u16 *)value);
Ian McDonald1bc09862005-08-20 00:23:43 -0300169 else
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300170 elapsed_time = ntohl(*(u32 *)value);
171
172 if (elapsed_time > opt_recv->dccpor_elapsed_time)
173 opt_recv->dccpor_elapsed_time = elapsed_time;
Ian McDonald1bc09862005-08-20 00:23:43 -0300174
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700175 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix,
Arnaldo Carvalho de Melo1c14ac02005-09-09 02:32:01 -0300176 elapsed_time);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700177 break;
178 /*
179 * From draft-ietf-dccp-spec-11.txt:
180 *
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300181 * Option numbers 128 through 191 are for
182 * options sent from the HC-Sender to the
183 * HC-Receiver; option numbers 192 through 255
184 * are for options sent from the HC-Receiver to
185 * the HC-Sender.
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700186 */
187 case 128 ... 191: {
188 const u16 idx = value - options;
189
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300190 if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
191 opt, len, idx,
192 value) != 0)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700193 goto out_invalid_option;
194 }
195 break;
196 case 192 ... 255: {
197 const u16 idx = value - options;
198
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300199 if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
200 opt, len, idx,
201 value) != 0)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700202 goto out_invalid_option;
203 }
204 break;
205 default:
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300206 pr_info("DCCP(%p): option %d(len=%d) not "
207 "implemented, ignoring\n",
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700208 sk, opt, len);
209 break;
210 }
211 }
212
213 return 0;
214
215out_invalid_option:
216 DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT);
217 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_OPTION_ERROR;
218 pr_info("DCCP(%p): invalid option %d, len=%d\n", sk, opt, len);
219 return -1;
220}
221
222static void dccp_encode_value_var(const u32 value, unsigned char *to,
223 const unsigned int len)
224{
225 if (len > 3)
226 *to++ = (value & 0xFF000000) >> 24;
227 if (len > 2)
228 *to++ = (value & 0xFF0000) >> 16;
229 if (len > 1)
230 *to++ = (value & 0xFF00) >> 8;
231 if (len > 0)
232 *to++ = (value & 0xFF);
233}
234
235static inline int dccp_ndp_len(const int ndp)
236{
237 return likely(ndp <= 0xFF) ? 1 : ndp <= 0xFFFF ? 2 : 3;
238}
239
240void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
241 const unsigned char option,
242 const void *value, const unsigned char len)
243{
244 unsigned char *to;
245
246 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) {
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300247 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
248 "%d option!\n", option);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700249 return;
250 }
251
252 DCCP_SKB_CB(skb)->dccpd_opt_len += len + 2;
253
254 to = skb_push(skb, len + 2);
255 *to++ = option;
256 *to++ = len + 2;
257
258 memcpy(to, value, len);
259}
260
261EXPORT_SYMBOL_GPL(dccp_insert_option);
262
263static void dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb)
264{
265 struct dccp_sock *dp = dccp_sk(sk);
266 int ndp = dp->dccps_ndp_count;
267
268 if (dccp_non_data_packet(skb))
269 ++dp->dccps_ndp_count;
270 else
271 dp->dccps_ndp_count = 0;
272
273 if (ndp > 0) {
274 unsigned char *ptr;
275 const int ndp_len = dccp_ndp_len(ndp);
276 const int len = ndp_len + 2;
277
278 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
279 return;
280
281 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
282
283 ptr = skb_push(skb, len);
284 *ptr++ = DCCPO_NDP_COUNT;
285 *ptr++ = len;
286 dccp_encode_value_var(ndp, ptr, ndp_len);
287 }
288}
289
290static inline int dccp_elapsed_time_len(const u32 elapsed_time)
291{
Ian McDonaldb1c9fe72005-08-18 20:45:29 -0300292 return elapsed_time == 0 ? 0 : elapsed_time <= 0xFFFF ? 2 : 4;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700293}
294
295void dccp_insert_option_elapsed_time(struct sock *sk,
296 struct sk_buff *skb,
297 u32 elapsed_time)
298{
Arnaldo Carvalho de Melo725ba8e2005-08-13 20:35:39 -0300299#ifdef CONFIG_IP_DCCP_DEBUG
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700300 struct dccp_sock *dp = dccp_sk(sk);
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300301 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
302 "CLIENT TX opt: " : "server TX opt: ";
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700303#endif
304 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
305 const int len = 2 + elapsed_time_len;
306 unsigned char *to;
307
Ian McDonald1bc09862005-08-20 00:23:43 -0300308 if (elapsed_time_len == 0)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700309 return;
310
311 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300312 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
313 "insert elapsed time!\n");
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700314 return;
315 }
316
317 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
318
319 to = skb_push(skb, len);
320 *to++ = DCCPO_ELAPSED_TIME;
321 *to++ = len;
322
Ian McDonald1bc09862005-08-20 00:23:43 -0300323 if (elapsed_time_len == 2) {
324 const u16 var16 = htons((u16)elapsed_time);
325 memcpy(to, &var16, 2);
326 } else {
327 const u32 var32 = htonl(elapsed_time);
328 memcpy(to, &var32, 4);
329 }
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700330
331 dccp_pr_debug("%sELAPSED_TIME=%u, len=%d, seqno=%llu\n",
332 debug_prefix, elapsed_time,
David S. Millerf6ccf552005-08-09 20:27:14 -0700333 len,
334 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700335}
336
Arnaldo Carvalho de Melod4b81ff2005-08-23 21:51:36 -0700337EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700338
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300339void dccp_timestamp(const struct sock *sk, struct timeval *tv)
340{
341 const struct dccp_sock *dp = dccp_sk(sk);
342
343 do_gettimeofday(tv);
344 tv->tv_sec -= dp->dccps_epoch.tv_sec;
345 tv->tv_usec -= dp->dccps_epoch.tv_usec;
346
347 while (tv->tv_usec < 0) {
348 tv->tv_sec--;
349 tv->tv_usec += USEC_PER_SEC;
350 }
351}
352
353EXPORT_SYMBOL_GPL(dccp_timestamp);
354
Arnaldo Carvalho de Melod4b81ff2005-08-23 21:51:36 -0700355void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700356{
Ian McDonald1bc09862005-08-20 00:23:43 -0300357 struct timeval tv;
358 u32 now;
359
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300360 dccp_timestamp(sk, &tv);
361 now = timeval_usecs(&tv) / 10;
Ian McDonald1bc09862005-08-20 00:23:43 -0300362 /* yes this will overflow but that is the point as we want a
363 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
364
365 now = htonl(now);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700366 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
367}
368
Arnaldo Carvalho de Melod4b81ff2005-08-23 21:51:36 -0700369EXPORT_SYMBOL_GPL(dccp_insert_option_timestamp);
370
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300371static void dccp_insert_option_timestamp_echo(struct sock *sk,
372 struct sk_buff *skb)
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700373{
374 struct dccp_sock *dp = dccp_sk(sk);
Arnaldo Carvalho de Melo725ba8e2005-08-13 20:35:39 -0300375#ifdef CONFIG_IP_DCCP_DEBUG
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300376 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
377 "CLIENT TX opt: " : "server TX opt: ";
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700378#endif
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300379 struct timeval now;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700380 u32 tstamp_echo;
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300381 u32 elapsed_time;
382 int len, elapsed_time_len;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700383 unsigned char *to;
384
Arnaldo Carvalho de Melob0e56782005-09-09 02:38:35 -0300385 dccp_timestamp(sk, &now);
386 elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10;
387 elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
388 len = 6 + elapsed_time_len;
389
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700390 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
Arnaldo Carvalho de Melo7690af32005-08-13 20:34:54 -0300391 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
392 "timestamp echo!\n");
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700393 return;
394 }
395
396 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
397
398 to = skb_push(skb, len);
399 *to++ = DCCPO_TIMESTAMP_ECHO;
400 *to++ = len;
401
402 tstamp_echo = htonl(dp->dccps_timestamp_echo);
403 memcpy(to, &tstamp_echo, 4);
404 to += 4;
Ian McDonald1bc09862005-08-20 00:23:43 -0300405
406 if (elapsed_time_len == 2) {
407 const u16 var16 = htons((u16)elapsed_time);
408 memcpy(to, &var16, 2);
409 } else if (elapsed_time_len == 4) {
410 const u32 var32 = htonl(elapsed_time);
411 memcpy(to, &var32, 4);
412 }
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700413
414 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, seqno=%llu\n",
415 debug_prefix, dp->dccps_timestamp_echo,
David S. Millerf6ccf552005-08-09 20:27:14 -0700416 len,
417 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700418
419 dp->dccps_timestamp_echo = 0;
Ian McDonald1bc09862005-08-20 00:23:43 -0300420 dp->dccps_timestamp_time.tv_sec = 0;
421 dp->dccps_timestamp_time.tv_usec = 0;
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700422}
423
424void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
425{
426 struct dccp_sock *dp = dccp_sk(sk);
427
428 DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
429
430 if (dp->dccps_options.dccpo_send_ndp_count)
431 dccp_insert_option_ndp(sk, skb);
432
433 if (!dccp_packet_without_ack(skb)) {
434 if (dp->dccps_options.dccpo_send_ack_vector &&
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700435 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec))
436 dccp_insert_option_ackvec(sk, skb);
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700437 if (dp->dccps_timestamp_echo != 0)
438 dccp_insert_option_timestamp_echo(sk, skb);
439 }
440
Arnaldo Carvalho de Melo507d37c2005-09-09 02:30:07 -0300441 if (dp->dccps_hc_rx_insert_options) {
442 ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb);
443 dp->dccps_hc_rx_insert_options = 0;
444 }
445 if (dp->dccps_hc_tx_insert_options) {
446 ccid_hc_tx_insert_options(dp->dccps_hc_tx_ccid, sk, skb);
447 dp->dccps_hc_tx_insert_options = 0;
448 }
Arnaldo Carvalho de Melo7c657872005-08-09 20:14:34 -0700449
450 /* XXX: insert other options when appropriate */
451
452 if (DCCP_SKB_CB(skb)->dccpd_opt_len != 0) {
453 /* The length of all options has to be a multiple of 4 */
454 int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
455
456 if (padding != 0) {
457 padding = 4 - padding;
458 memset(skb_push(skb, padding), 0, padding);
459 DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
460 }
461 }
462}