// SPDX-License-Identifier: GPL-2.0-or-later /* * net/dccp/options.c * * An implementation of the DCCP protocol * Copyright (c) 2005 Aristeu Sergio Rozanski Filho <[email protected]> * Copyright (c) 2005 Arnaldo Carvalho de Melo <[email protected]> * Copyright (c) 2005 Ian McDonald <[email protected]> */ #include <linux/dccp.h> #include <linux/module.h> #include <linux/types.h> #include <linux/unaligned.h> #include <linux/kernel.h> #include <linux/skbuff.h> #include "ackvec.h" #include "ccid.h" #include "dccp.h" #include "feat.h" u64 dccp_decode_value_var(const u8 *bf, const u8 len) { … } /** * dccp_parse_options - Parse DCCP options present in @skb * @sk: client|server|listening dccp socket (when @dreq != NULL) * @dreq: request socket to use during connection setup, or NULL * @skb: frame to parse */ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq, struct sk_buff *skb) { … } EXPORT_SYMBOL_GPL(…); void dccp_encode_value_var(const u64 value, u8 *to, const u8 len) { … } static inline u8 dccp_ndp_len(const u64 ndp) { … } int dccp_insert_option(struct sk_buff *skb, const unsigned char option, const void *value, const unsigned char len) { … } EXPORT_SYMBOL_GPL(…); static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb) { … } static inline int dccp_elapsed_time_len(const u32 elapsed_time) { … } static int dccp_insert_option_timestamp(struct sk_buff *skb) { … } static int dccp_insert_option_timestamp_echo(struct dccp_sock *dp, struct dccp_request_sock *dreq, struct sk_buff *skb) { … } static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb) { … } /** * dccp_insert_option_mandatory - Mandatory option (5.8.2) * @skb: frame into which to insert option * * Note that since we are using skb_push, this function needs to be called * _after_ inserting the option it is supposed to influence (stack order). */ int dccp_insert_option_mandatory(struct sk_buff *skb) { … } /** * dccp_insert_fn_opt - Insert single Feature-Negotiation option into @skb * @skb: frame to insert feature negotiation option into * @type: %DCCPO_CHANGE_L, %DCCPO_CHANGE_R, %DCCPO_CONFIRM_L, %DCCPO_CONFIRM_R * @feat: one out of %dccp_feature_numbers * @val: NN value or SP array (preferred element first) to copy * @len: true length of @val in bytes (excluding first element repetition) * @repeat_first: whether to copy the first element of @val twice * * The last argument is used to construct Confirm options, where the preferred * value and the preference list appear separately (RFC 4340, 6.3.1). Preference * lists are kept such that the preferred entry is always first, so we only need * to copy twice, and avoid the overhead of cloning into a bigger array. */ int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat, u8 *val, u8 len, bool repeat_first) { … } /* The length of all options needs to be a multiple of 4 (5.8) */ static void dccp_insert_option_padding(struct sk_buff *skb) { … } int dccp_insert_options(struct sock *sk, struct sk_buff *skb) { … } int dccp_insert_options_rsk(struct dccp_request_sock *dreq, struct sk_buff *skb) { … }