esp.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _NET_ESP_H
  3. #define _NET_ESP_H
  4. #include <linux/skbuff.h>
  5. struct ip_esp_hdr;
  6. struct xfrm_state;
  7. static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
  8. {
  9. return (struct ip_esp_hdr *)skb_transport_header(skb);
  10. }
  11. static inline void esp_output_fill_trailer(u8 *tail, int tfclen, int plen, __u8 proto)
  12. {
  13. /* Fill padding... */
  14. if (tfclen) {
  15. memset(tail, 0, tfclen);
  16. tail += tfclen;
  17. }
  18. do {
  19. int i;
  20. for (i = 0; i < plen - 2; i++)
  21. tail[i] = i + 1;
  22. } while (0);
  23. tail[plen - 2] = plen - 2;
  24. tail[plen - 1] = proto;
  25. }
  26. struct esp_info {
  27. struct ip_esp_hdr *esph;
  28. __be64 seqno;
  29. int tfclen;
  30. int tailen;
  31. int plen;
  32. int clen;
  33. int len;
  34. int nfrags;
  35. __u8 proto;
  36. bool inplace;
  37. };
  38. int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
  39. int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
  40. int esp_input_done2(struct sk_buff *skb, int err);
  41. int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
  42. int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
  43. int esp6_input_done2(struct sk_buff *skb, int err);
  44. #endif