gre.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef __LINUX_GRE_H
  2. #define __LINUX_GRE_H
  3. #include <linux/skbuff.h>
  4. #include <net/ip_tunnels.h>
  5. #define GREPROTO_CISCO 0
  6. #define GREPROTO_PPTP 1
  7. #define GREPROTO_MAX 2
  8. struct gre_protocol {
  9. int (*handler)(struct sk_buff *skb);
  10. void (*err_handler)(struct sk_buff *skb, u32 info);
  11. };
  12. struct gre_base_hdr {
  13. __be16 flags;
  14. __be16 protocol;
  15. };
  16. #define GRE_HEADER_SECTION 4
  17. int gre_add_protocol(const struct gre_protocol *proto, u8 version);
  18. int gre_del_protocol(const struct gre_protocol *proto, u8 version);
  19. static inline __be16 gre_flags_to_tnl_flags(__be16 flags)
  20. {
  21. __be16 tflags = 0;
  22. if (flags & GRE_CSUM)
  23. tflags |= TUNNEL_CSUM;
  24. if (flags & GRE_ROUTING)
  25. tflags |= TUNNEL_ROUTING;
  26. if (flags & GRE_KEY)
  27. tflags |= TUNNEL_KEY;
  28. if (flags & GRE_SEQ)
  29. tflags |= TUNNEL_SEQ;
  30. if (flags & GRE_STRICT)
  31. tflags |= TUNNEL_STRICT;
  32. if (flags & GRE_REC)
  33. tflags |= TUNNEL_REC;
  34. if (flags & GRE_VERSION)
  35. tflags |= TUNNEL_VERSION;
  36. return tflags;
  37. }
  38. static inline __be16 tnl_flags_to_gre_flags(__be16 tflags)
  39. {
  40. __be16 flags = 0;
  41. if (tflags & TUNNEL_CSUM)
  42. flags |= GRE_CSUM;
  43. if (tflags & TUNNEL_ROUTING)
  44. flags |= GRE_ROUTING;
  45. if (tflags & TUNNEL_KEY)
  46. flags |= GRE_KEY;
  47. if (tflags & TUNNEL_SEQ)
  48. flags |= GRE_SEQ;
  49. if (tflags & TUNNEL_STRICT)
  50. flags |= GRE_STRICT;
  51. if (tflags & TUNNEL_REC)
  52. flags |= GRE_REC;
  53. if (tflags & TUNNEL_VERSION)
  54. flags |= GRE_VERSION;
  55. return flags;
  56. }
  57. #endif