Lines Matching refs:pkt
17 #define PKT_ERROR(pkt, errmsg) \ argument
19 cfpkt_priv(pkt)->erronous = true; \
20 skb_reset_tail_pointer(&pkt->skb); \
45 static inline struct cfpkt_priv_data *cfpkt_priv(struct cfpkt *pkt) in cfpkt_priv() argument
47 return (struct cfpkt_priv_data *) pkt->skb.cb; in cfpkt_priv()
50 static inline bool is_erronous(struct cfpkt *pkt) in is_erronous() argument
52 return cfpkt_priv(pkt)->erronous; in is_erronous()
55 static inline struct sk_buff *pkt_to_skb(struct cfpkt *pkt) in pkt_to_skb() argument
57 return &pkt->skb; in pkt_to_skb()
67 struct cfpkt *pkt = skb_to_pkt(nativepkt); in cfpkt_fromnative() local
68 cfpkt_priv(pkt)->erronous = false; in cfpkt_fromnative()
69 return pkt; in cfpkt_fromnative()
73 void *cfpkt_tonative(struct cfpkt *pkt) in cfpkt_tonative() argument
75 return (void *) pkt; in cfpkt_tonative()
96 void cfpkt_destroy(struct cfpkt *pkt) in cfpkt_destroy() argument
98 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_destroy()
102 inline bool cfpkt_more(struct cfpkt *pkt) in cfpkt_more() argument
104 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_more()
108 int cfpkt_peek_head(struct cfpkt *pkt, void *data, u16 len) in cfpkt_peek_head() argument
110 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_peek_head()
115 return !cfpkt_extr_head(pkt, data, len) && in cfpkt_peek_head()
116 !cfpkt_add_head(pkt, data, len); in cfpkt_peek_head()
119 int cfpkt_extr_head(struct cfpkt *pkt, void *data, u16 len) in cfpkt_extr_head() argument
121 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_extr_head()
123 if (unlikely(is_erronous(pkt))) in cfpkt_extr_head()
127 PKT_ERROR(pkt, "read beyond end of packet\n"); in cfpkt_extr_head()
133 PKT_ERROR(pkt, "linearize failed\n"); in cfpkt_extr_head()
145 int cfpkt_extr_trail(struct cfpkt *pkt, void *dta, u16 len) in cfpkt_extr_trail() argument
147 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_extr_trail()
150 if (unlikely(is_erronous(pkt))) in cfpkt_extr_trail()
154 PKT_ERROR(pkt, "linearize failed\n"); in cfpkt_extr_trail()
158 PKT_ERROR(pkt, "read beyond end of packet\n"); in cfpkt_extr_trail()
167 int cfpkt_pad_trail(struct cfpkt *pkt, u16 len) in cfpkt_pad_trail() argument
169 return cfpkt_add_body(pkt, NULL, len); in cfpkt_pad_trail()
172 int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len) in cfpkt_add_body() argument
174 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_add_body()
180 if (unlikely(is_erronous(pkt))) in cfpkt_add_body()
198 PKT_ERROR(pkt, "cow failed\n"); in cfpkt_add_body()
210 inline int cfpkt_addbdy(struct cfpkt *pkt, u8 data) in cfpkt_addbdy() argument
212 return cfpkt_add_body(pkt, &data, 1); in cfpkt_addbdy()
215 int cfpkt_add_head(struct cfpkt *pkt, const void *data2, u16 len) in cfpkt_add_head() argument
217 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_add_head()
222 if (unlikely(is_erronous(pkt))) in cfpkt_add_head()
225 PKT_ERROR(pkt, "no headroom\n"); in cfpkt_add_head()
232 PKT_ERROR(pkt, "cow failed\n"); in cfpkt_add_head()
242 inline int cfpkt_add_trail(struct cfpkt *pkt, const void *data, u16 len) in cfpkt_add_trail() argument
244 return cfpkt_add_body(pkt, data, len); in cfpkt_add_trail()
247 inline u16 cfpkt_getlen(struct cfpkt *pkt) in cfpkt_getlen() argument
249 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_getlen()
253 int cfpkt_iterate(struct cfpkt *pkt, in cfpkt_iterate() argument
261 if (unlikely(is_erronous(pkt))) in cfpkt_iterate()
263 if (unlikely(skb_linearize(&pkt->skb) != 0)) { in cfpkt_iterate()
264 PKT_ERROR(pkt, "linearize failed\n"); in cfpkt_iterate()
267 return iter_func(data, pkt->skb.data, cfpkt_getlen(pkt)); in cfpkt_iterate()
270 int cfpkt_setlen(struct cfpkt *pkt, u16 len) in cfpkt_setlen() argument
272 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_setlen()
275 if (unlikely(is_erronous(pkt))) in cfpkt_setlen()
284 return cfpkt_getlen(pkt); in cfpkt_setlen()
288 if (unlikely(!cfpkt_pad_trail(pkt, len - skb->len))) in cfpkt_setlen()
289 PKT_ERROR(pkt, "skb_pad_trail failed\n"); in cfpkt_setlen()
291 return cfpkt_getlen(pkt); in cfpkt_setlen()
331 struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos) in cfpkt_split() argument
334 struct sk_buff *skb = pkt_to_skb(pkt); in cfpkt_split()
339 if (unlikely(is_erronous(pkt))) in cfpkt_split()
343 PKT_ERROR(pkt, "trying to split beyond end of packet\n"); in cfpkt_split()
367 bool cfpkt_erroneous(struct cfpkt *pkt) in cfpkt_erroneous() argument
369 return cfpkt_priv(pkt)->erronous; in cfpkt_erroneous()
372 struct caif_payload_info *cfpkt_info(struct cfpkt *pkt) in cfpkt_info() argument
374 return (struct caif_payload_info *)&pkt_to_skb(pkt)->cb; in cfpkt_info()
378 void cfpkt_set_prio(struct cfpkt *pkt, int prio) in cfpkt_set_prio() argument
380 pkt_to_skb(pkt)->priority = prio; in cfpkt_set_prio()