Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Pablo Neira | 459aa66 | 2016-05-09 00:55:48 +0200 | [diff] [blame] | 2 | #ifndef _GTP_H_ |
Colin Ian King | 9b8ac4f | 2016-07-24 19:24:09 +0100 | [diff] [blame] | 3 | #define _GTP_H_ |
Pablo Neira | 459aa66 | 2016-05-09 00:55:48 +0200 | [diff] [blame] | 4 | |
Jakub Kicinski | 949d6b4 | 2022-07-20 16:57:58 -0700 | [diff] [blame] | 5 | #include <linux/netdevice.h> |
| 6 | #include <linux/types.h> |
| 7 | #include <net/rtnetlink.h> |
| 8 | |
Pablo Neira | 459aa66 | 2016-05-09 00:55:48 +0200 | [diff] [blame] | 9 | /* General GTP protocol related definitions. */ |
| 10 | |
| 11 | #define GTP0_PORT 3386 |
| 12 | #define GTP1U_PORT 2152 |
| 13 | |
Wojciech Drewek | 9af41cc | 2022-03-04 17:40:43 +0100 | [diff] [blame] | 14 | /* GTP messages types */ |
| 15 | #define GTP_ECHO_REQ 1 /* Echo Request */ |
| 16 | #define GTP_ECHO_RSP 2 /* Echo Response */ |
Pablo Neira | 459aa66 | 2016-05-09 00:55:48 +0200 | [diff] [blame] | 17 | #define GTP_TPDU 255 |
| 18 | |
Wojciech Drewek | 9af41cc | 2022-03-04 17:40:43 +0100 | [diff] [blame] | 19 | #define GTPIE_RECOVERY 14 |
| 20 | |
Pablo Neira | 459aa66 | 2016-05-09 00:55:48 +0200 | [diff] [blame] | 21 | struct gtp0_header { /* According to GSM TS 09.60. */ |
| 22 | __u8 flags; |
| 23 | __u8 type; |
| 24 | __be16 length; |
| 25 | __be16 seq; |
| 26 | __be16 flow; |
| 27 | __u8 number; |
| 28 | __u8 spare[3]; |
| 29 | __be64 tid; |
| 30 | } __attribute__ ((packed)); |
| 31 | |
| 32 | struct gtp1_header { /* According to 3GPP TS 29.060. */ |
| 33 | __u8 flags; |
| 34 | __u8 type; |
| 35 | __be16 length; |
| 36 | __be32 tid; |
| 37 | } __attribute__ ((packed)); |
| 38 | |
Wojciech Drewek | 9af41cc | 2022-03-04 17:40:43 +0100 | [diff] [blame] | 39 | struct gtp1_header_long { /* According to 3GPP TS 29.060. */ |
| 40 | __u8 flags; |
| 41 | __u8 type; |
| 42 | __be16 length; |
| 43 | __be32 tid; |
| 44 | __be16 seq; |
| 45 | __u8 npdu; |
| 46 | __u8 next; |
| 47 | } __packed; |
| 48 | |
| 49 | /* GTP Information Element */ |
| 50 | struct gtp_ie { |
| 51 | __u8 tag; |
| 52 | __u8 val; |
| 53 | } __packed; |
| 54 | |
| 55 | struct gtp0_packet { |
| 56 | struct gtp0_header gtp0_h; |
| 57 | struct gtp_ie ie; |
| 58 | } __packed; |
| 59 | |
| 60 | struct gtp1u_packet { |
| 61 | struct gtp1_header_long gtp1u_h; |
| 62 | struct gtp_ie ie; |
| 63 | } __packed; |
| 64 | |
Wojciech Drewek | e3acda7ad | 2022-03-04 17:40:45 +0100 | [diff] [blame] | 65 | struct gtp_pdu_session_info { /* According to 3GPP TS 38.415. */ |
| 66 | u8 pdu_type; |
| 67 | u8 qfi; |
| 68 | }; |
| 69 | |
Wojciech Drewek | 81dd984 | 2022-03-04 17:40:46 +0100 | [diff] [blame] | 70 | static inline bool netif_is_gtp(const struct net_device *dev) |
| 71 | { |
| 72 | return dev->rtnl_link_ops && |
| 73 | !strcmp(dev->rtnl_link_ops->kind, "gtp"); |
| 74 | } |
| 75 | |
Pablo Neira | 459aa66 | 2016-05-09 00:55:48 +0200 | [diff] [blame] | 76 | #define GTP1_F_NPDU 0x01 |
| 77 | #define GTP1_F_SEQ 0x02 |
| 78 | #define GTP1_F_EXTHDR 0x04 |
| 79 | #define GTP1_F_MASK 0x07 |
| 80 | |
| 81 | #endif |