Skip to contentSkip to conversation

: Support for Mandatory options

PATCH In review Gerrit Renker 2 participants 2 messages Oct 1, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 4/11 : Support for Mandatory options

[DCCP]: Support for Mandatory options

Support for Mandatory options is provided by this patch, which will be used by subsequent feature-negotiation patches.

---
 net/dccp/feat.h    |    2 ++
 net/dccp/options.c |   15 +++++++++++++++
 2 files changed, 17 insertions(+)
net/dccp/feat.h +2 -0
@@ -122,4 +122,6 @@ static inline u8 dccp_bytes_per_value(co
 
 extern void dccp_encode_value_var(const u64 value, u8 *to, const u8 len);
 extern u64  dccp_decode_value_var(const u8 *bf, const u8 len);
+
+extern int  dccp_insert_option_mandatory(struct sk_buff *skb);
 #endif /* _DCCP_FEAT_H */
net/dccp/options.c +15 -0
@@ -441,6 +441,21 @@ static int dccp_insert_option_timestamp_
 	return 0;
 }
 
+/**
+ * dccp_insert_option_mandatory  -  Mandatory option (5.8.2)
+ * 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)
+{
+	if (DCCP_SKB_CB(skb)->dccpd_opt_len >= DCCP_MAX_OPT_LEN)
+		return -1;
+
+	DCCP_SKB_CB(skb)->dccpd_opt_len++;
+	*skb_push(skb, 1) = DCCPO_MANDATORY;
+	return 0;
+}
+
 static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
 				u8 *val, u8 len)
 {