This source file includes following definitions.
- can_skb_prv
- can_skb_reserve
- can_skb_set_owner
- can_create_echo_skb
1
2
3
4
5
6
7
8
9
10
11 #ifndef _CAN_SKB_H
12 #define _CAN_SKB_H
13
14 #include <linux/types.h>
15 #include <linux/skbuff.h>
16 #include <linux/can.h>
17 #include <net/sock.h>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 struct can_skb_priv {
35 int ifindex;
36 int skbcnt;
37 struct can_frame cf[0];
38 };
39
40 static inline struct can_skb_priv *can_skb_prv(struct sk_buff *skb)
41 {
42 return (struct can_skb_priv *)(skb->head);
43 }
44
45 static inline void can_skb_reserve(struct sk_buff *skb)
46 {
47 skb_reserve(skb, sizeof(struct can_skb_priv));
48 }
49
50 static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
51 {
52 if (sk) {
53 sock_hold(sk);
54 skb->destructor = sock_efree;
55 skb->sk = sk;
56 }
57 }
58
59
60
61
62 static inline struct sk_buff *can_create_echo_skb(struct sk_buff *skb)
63 {
64 if (skb_shared(skb)) {
65 struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
66
67 if (likely(nskb)) {
68 can_skb_set_owner(nskb, skb->sk);
69 consume_skb(skb);
70 return nskb;
71 } else {
72 kfree_skb(skb);
73 return NULL;
74 }
75 }
76
77
78 return skb;
79 }
80
81 #endif