Lines Matching refs:pkt

17 #define PKT_ERROR(pkt, errmsg)		   \  argument
19 cfpkt_priv(pkt)->erronous = true; \
20 skb_reset_tail_pointer(&pkt->skb); \
38 static inline struct cfpkt_priv_data *cfpkt_priv(struct cfpkt *pkt) in cfpkt_priv() argument
40 return (struct cfpkt_priv_data *) pkt->skb.cb; in cfpkt_priv()
43 static inline bool is_erronous(struct cfpkt *pkt) in is_erronous() argument
45 return cfpkt_priv(pkt)->erronous; in is_erronous()
48 static inline struct sk_buff *pkt_to_skb(struct cfpkt *pkt) in pkt_to_skb() argument
50 return &pkt->skb; in pkt_to_skb()
60 struct cfpkt *pkt = skb_to_pkt(nativepkt); in cfpkt_fromnative() local
61 cfpkt_priv(pkt)->erronous = false; in cfpkt_fromnative()
62 return pkt; in cfpkt_fromnative()
66 void *cfpkt_tonative(struct cfpkt *pkt) in cfpkt_tonative() argument
68 return (void *) pkt; in cfpkt_tonative()
89 void cfpkt_destroy(struct cfpkt *pkt) in cfpkt_destroy() argument
91 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_destroy()
95 inline bool cfpkt_more(struct cfpkt *pkt) in cfpkt_more() argument
97 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_more()
101 int cfpkt_peek_head(struct cfpkt *pkt, void *data, u16 len) in cfpkt_peek_head() argument
103 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_peek_head()
108 return !cfpkt_extr_head(pkt, data, len) && in cfpkt_peek_head()
109 !cfpkt_add_head(pkt, data, len); in cfpkt_peek_head()
112 int cfpkt_extr_head(struct cfpkt *pkt, void *data, u16 len) in cfpkt_extr_head() argument
114 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_extr_head()
116 if (unlikely(is_erronous(pkt))) in cfpkt_extr_head()
120 PKT_ERROR(pkt, "read beyond end of packet\n"); in cfpkt_extr_head()
126 PKT_ERROR(pkt, "linearize failed\n"); in cfpkt_extr_head()
138 int cfpkt_extr_trail(struct cfpkt *pkt, void *dta, u16 len) in cfpkt_extr_trail() argument
140 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_extr_trail()
143 if (unlikely(is_erronous(pkt))) in cfpkt_extr_trail()
147 PKT_ERROR(pkt, "linearize failed\n"); in cfpkt_extr_trail()
151 PKT_ERROR(pkt, "read beyond end of packet\n"); in cfpkt_extr_trail()
160 int cfpkt_pad_trail(struct cfpkt *pkt, u16 len) in cfpkt_pad_trail() argument
162 return cfpkt_add_body(pkt, NULL, len); in cfpkt_pad_trail()
165 int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len) in cfpkt_add_body() argument
167 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_add_body()
173 if (unlikely(is_erronous(pkt))) in cfpkt_add_body()
191 PKT_ERROR(pkt, "cow failed\n"); in cfpkt_add_body()
203 inline int cfpkt_addbdy(struct cfpkt *pkt, u8 data) in cfpkt_addbdy() argument
205 return cfpkt_add_body(pkt, &data, 1); in cfpkt_addbdy()
208 int cfpkt_add_head(struct cfpkt *pkt, const void *data2, u16 len) in cfpkt_add_head() argument
210 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_add_head()
215 if (unlikely(is_erronous(pkt))) in cfpkt_add_head()
218 PKT_ERROR(pkt, "no headroom\n"); in cfpkt_add_head()
225 PKT_ERROR(pkt, "cow failed\n"); in cfpkt_add_head()
235 inline int cfpkt_add_trail(struct cfpkt *pkt, const void *data, u16 len) in cfpkt_add_trail() argument
237 return cfpkt_add_body(pkt, data, len); in cfpkt_add_trail()
240 inline u16 cfpkt_getlen(struct cfpkt *pkt) in cfpkt_getlen() argument
242 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_getlen()
246 int cfpkt_iterate(struct cfpkt *pkt, in cfpkt_iterate() argument
254 if (unlikely(is_erronous(pkt))) in cfpkt_iterate()
256 if (unlikely(skb_linearize(&pkt->skb) != 0)) { in cfpkt_iterate()
257 PKT_ERROR(pkt, "linearize failed\n"); in cfpkt_iterate()
260 return iter_func(data, pkt->skb.data, cfpkt_getlen(pkt)); in cfpkt_iterate()
263 int cfpkt_setlen(struct cfpkt *pkt, u16 len) in cfpkt_setlen() argument
265 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_setlen()
268 if (unlikely(is_erronous(pkt))) in cfpkt_setlen()
277 return cfpkt_getlen(pkt); in cfpkt_setlen()
281 if (unlikely(!cfpkt_pad_trail(pkt, len - skb->len))) in cfpkt_setlen()
282 PKT_ERROR(pkt, "skb_pad_trail failed\n"); in cfpkt_setlen()
284 return cfpkt_getlen(pkt); in cfpkt_setlen()
322 struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos) in cfpkt_split() argument
325 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_split()
330 if (unlikely(is_erronous(pkt))) in cfpkt_split()
334 PKT_ERROR(pkt, "trying to split beyond end of packet\n"); in cfpkt_split()
358 bool cfpkt_erroneous(struct cfpkt *pkt) in cfpkt_erroneous() argument
360 return cfpkt_priv(pkt)->erronous; in cfpkt_erroneous()
363 struct caif_payload_info *cfpkt_info(struct cfpkt *pkt) in cfpkt_info() argument
365 return (struct caif_payload_info *)&pkt_to_skb(pkt)->cb; in cfpkt_info()
369 void cfpkt_set_prio(struct cfpkt *pkt, int prio) in cfpkt_set_prio() argument
371 pkt_to_skb(pkt)->priority = prio; in cfpkt_set_prio()