gtp.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _GTP_H_
  3. #define _GTP_H_
  4. #include <linux/netdevice.h>
  5. #include <linux/types.h>
  6. #include <net/rtnetlink.h>
  7. /* General GTP protocol related definitions. */
  8. #define GTP0_PORT 3386
  9. #define GTP1U_PORT 2152
  10. /* GTP messages types */
  11. #define GTP_ECHO_REQ 1 /* Echo Request */
  12. #define GTP_ECHO_RSP 2 /* Echo Response */
  13. #define GTP_TPDU 255
  14. #define GTPIE_RECOVERY 14
  15. struct gtp0_header { /* According to GSM TS 09.60. */
  16. __u8 flags;
  17. __u8 type;
  18. __be16 length;
  19. __be16 seq;
  20. __be16 flow;
  21. __u8 number;
  22. __u8 spare[3];
  23. __be64 tid;
  24. } __attribute__ ((packed));
  25. struct gtp1_header { /* According to 3GPP TS 29.060. */
  26. __u8 flags;
  27. __u8 type;
  28. __be16 length;
  29. __be32 tid;
  30. } __attribute__ ((packed));
  31. struct gtp1_header_long { /* According to 3GPP TS 29.060. */
  32. __u8 flags;
  33. __u8 type;
  34. __be16 length;
  35. __be32 tid;
  36. __be16 seq;
  37. __u8 npdu;
  38. __u8 next;
  39. } __packed;
  40. /* GTP Information Element */
  41. struct gtp_ie {
  42. __u8 tag;
  43. __u8 val;
  44. } __packed;
  45. struct gtp0_packet {
  46. struct gtp0_header gtp0_h;
  47. struct gtp_ie ie;
  48. } __packed;
  49. struct gtp1u_packet {
  50. struct gtp1_header_long gtp1u_h;
  51. struct gtp_ie ie;
  52. } __packed;
  53. struct gtp_pdu_session_info { /* According to 3GPP TS 38.415. */
  54. u8 pdu_type;
  55. u8 qfi;
  56. };
  57. static inline bool netif_is_gtp(const struct net_device *dev)
  58. {
  59. return dev->rtnl_link_ops &&
  60. !strcmp(dev->rtnl_link_ops->kind, "gtp");
  61. }
  62. #define GTP1_F_NPDU 0x01
  63. #define GTP1_F_SEQ 0x02
  64. #define GTP1_F_EXTHDR 0x04
  65. #define GTP1_F_MASK 0x07
  66. #endif