4 * Definitions for the CAN network socket buffer
6 * Copyright (C) 2012 Oliver Hartkopp <socketcan@hartkopp.net>
13 #include <linux/types.h>
14 #include <linux/skbuff.h>
15 #include <linux/can.h>
19 * The struct can_skb_priv is used to transport additional information along
20 * with the stored struct can(fd)_frame that can not be contained in existing
21 * struct sk_buff elements.
22 * N.B. that this information must not be modified in cloned CAN sk_buffs.
23 * To modify the CAN frame content or the struct can_skb_priv content
24 * skb_copy() needs to be used instead of skb_clone().
28 * struct can_skb_priv - private additional data inside CAN sk_buffs
29 * @ifindex: ifindex of the first interface the CAN frame appeared on
30 * @cf: align to the following CAN frame at skb->data
34 struct can_frame cf[0];
37 static inline struct can_skb_priv *can_skb_prv(struct sk_buff *skb)
39 return (struct can_skb_priv *)(skb->head);
42 static inline void can_skb_reserve(struct sk_buff *skb)
44 skb_reserve(skb, sizeof(struct can_skb_priv));
47 static inline void can_skb_destructor(struct sk_buff *skb)
52 static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
56 skb->destructor = can_skb_destructor;
62 * returns an unshared skb owned by the original sock to be echo'ed back
64 static inline struct sk_buff *can_create_echo_skb(struct sk_buff *skb)
66 if (skb_shared(skb)) {
67 struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
70 can_skb_set_owner(nskb, skb->sk);
79 /* we can assume to have an unshared skb with proper owner */
83 #endif /* !_CAN_SKB_H */