Lines Matching refs:hdr
47 ieee802154_hdr_push_sechdr(u8 *buf, const struct ieee802154_sechdr *hdr) in ieee802154_hdr_push_sechdr() argument
51 memcpy(buf, hdr, 1); in ieee802154_hdr_push_sechdr()
52 memcpy(buf + 1, &hdr->frame_counter, 4); in ieee802154_hdr_push_sechdr()
54 switch (hdr->key_id_mode) { in ieee802154_hdr_push_sechdr()
62 memcpy(buf + pos, &hdr->short_src, 4); in ieee802154_hdr_push_sechdr()
67 memcpy(buf + pos, &hdr->extended_src, IEEE802154_ADDR_LEN); in ieee802154_hdr_push_sechdr()
72 buf[pos++] = hdr->key_id; in ieee802154_hdr_push_sechdr()
78 ieee802154_hdr_push(struct sk_buff *skb, struct ieee802154_hdr *hdr) in ieee802154_hdr_push() argument
83 struct ieee802154_hdr_fc *fc = &hdr->fc; in ieee802154_hdr_push()
85 buf[pos++] = hdr->seq; in ieee802154_hdr_push()
87 fc->dest_addr_mode = hdr->dest.mode; in ieee802154_hdr_push()
89 rc = ieee802154_hdr_push_addr(buf + pos, &hdr->dest, false); in ieee802154_hdr_push()
94 fc->source_addr_mode = hdr->source.mode; in ieee802154_hdr_push()
96 if (hdr->source.pan_id == hdr->dest.pan_id && in ieee802154_hdr_push()
97 hdr->dest.mode != IEEE802154_ADDR_NONE) in ieee802154_hdr_push()
100 rc = ieee802154_hdr_push_addr(buf + pos, &hdr->source, fc->intra_pan); in ieee802154_hdr_push()
108 rc = ieee802154_hdr_push_sechdr(buf + pos, &hdr->sec); in ieee802154_hdr_push()
161 ieee802154_hdr_get_sechdr(const u8 *buf, struct ieee802154_sechdr *hdr) in ieee802154_hdr_get_sechdr() argument
165 memcpy(hdr, buf, 1); in ieee802154_hdr_get_sechdr()
166 memcpy(&hdr->frame_counter, buf + 1, 4); in ieee802154_hdr_get_sechdr()
168 switch (hdr->key_id_mode) { in ieee802154_hdr_get_sechdr()
176 memcpy(&hdr->short_src, buf + pos, 4); in ieee802154_hdr_get_sechdr()
181 memcpy(&hdr->extended_src, buf + pos, IEEE802154_ADDR_LEN); in ieee802154_hdr_get_sechdr()
186 hdr->key_id = buf[pos++]; in ieee802154_hdr_get_sechdr()
203 static int ieee802154_hdr_minlen(const struct ieee802154_hdr *hdr) in ieee802154_hdr_minlen() argument
207 dlen = ieee802154_hdr_addr_len(hdr->fc.dest_addr_mode, false); in ieee802154_hdr_minlen()
208 slen = ieee802154_hdr_addr_len(hdr->fc.source_addr_mode, in ieee802154_hdr_minlen()
209 hdr->fc.intra_pan); in ieee802154_hdr_minlen()
214 return 3 + dlen + slen + hdr->fc.security_enabled; in ieee802154_hdr_minlen()
218 ieee802154_hdr_get_addrs(const u8 *buf, struct ieee802154_hdr *hdr) in ieee802154_hdr_get_addrs() argument
222 pos += ieee802154_hdr_get_addr(buf + pos, hdr->fc.dest_addr_mode, in ieee802154_hdr_get_addrs()
223 false, &hdr->dest); in ieee802154_hdr_get_addrs()
224 pos += ieee802154_hdr_get_addr(buf + pos, hdr->fc.source_addr_mode, in ieee802154_hdr_get_addrs()
225 hdr->fc.intra_pan, &hdr->source); in ieee802154_hdr_get_addrs()
227 if (hdr->fc.intra_pan) in ieee802154_hdr_get_addrs()
228 hdr->source.pan_id = hdr->dest.pan_id; in ieee802154_hdr_get_addrs()
234 ieee802154_hdr_pull(struct sk_buff *skb, struct ieee802154_hdr *hdr) in ieee802154_hdr_pull() argument
241 memcpy(hdr, skb->data, 3); in ieee802154_hdr_pull()
243 rc = ieee802154_hdr_minlen(hdr); in ieee802154_hdr_pull()
247 pos += ieee802154_hdr_get_addrs(skb->data + pos, hdr); in ieee802154_hdr_pull()
249 if (hdr->fc.security_enabled) { in ieee802154_hdr_pull()
255 pos += ieee802154_hdr_get_sechdr(skb->data + pos, &hdr->sec); in ieee802154_hdr_pull()
264 ieee802154_hdr_peek_addrs(const struct sk_buff *skb, struct ieee802154_hdr *hdr) in ieee802154_hdr_peek_addrs() argument
272 memcpy(hdr, buf, 3); in ieee802154_hdr_peek_addrs()
274 rc = ieee802154_hdr_minlen(hdr); in ieee802154_hdr_peek_addrs()
278 pos += ieee802154_hdr_get_addrs(buf + pos, hdr); in ieee802154_hdr_peek_addrs()
284 ieee802154_hdr_peek(const struct sk_buff *skb, struct ieee802154_hdr *hdr) in ieee802154_hdr_peek() argument
289 pos = ieee802154_hdr_peek_addrs(skb, hdr); in ieee802154_hdr_peek()
293 if (hdr->fc.security_enabled) { in ieee802154_hdr_peek()
300 pos += ieee802154_hdr_get_sechdr(buf + pos, &hdr->sec); in ieee802154_hdr_peek()
307 int ieee802154_max_payload(const struct ieee802154_hdr *hdr) in ieee802154_max_payload() argument
309 int hlen = ieee802154_hdr_minlen(hdr); in ieee802154_max_payload()
311 if (hdr->fc.security_enabled) { in ieee802154_max_payload()
312 hlen += ieee802154_sechdr_lengths[hdr->sec.key_id_mode] - 1; in ieee802154_max_payload()
313 hlen += ieee802154_sechdr_authtag_len(&hdr->sec); in ieee802154_max_payload()