1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _GTP_H_ |
3 | #define _GTP_H_ |
4 | |
5 | #include <linux/netdevice.h> |
6 | #include <linux/types.h> |
7 | #include <net/rtnetlink.h> |
8 | |
9 | /* General GTP protocol related definitions. */ |
10 | |
11 | #define GTP0_PORT 3386 |
12 | #define GTP1U_PORT 2152 |
13 | |
14 | /* GTP messages types */ |
15 | #define GTP_ECHO_REQ 1 /* Echo Request */ |
16 | #define GTP_ECHO_RSP 2 /* Echo Response */ |
17 | #define GTP_TPDU 255 |
18 | |
19 | #define GTPIE_RECOVERY 14 |
20 | |
21 | struct { /* According to GSM TS 09.60. */ |
22 | __u8 ; |
23 | __u8 ; |
24 | __be16 ; |
25 | __be16 ; |
26 | __be16 ; |
27 | __u8 ; |
28 | __u8 [3]; |
29 | __be64 ; |
30 | } __attribute__ ((packed)); |
31 | |
32 | struct { /* According to 3GPP TS 29.060. */ |
33 | __u8 ; |
34 | __u8 ; |
35 | __be16 ; |
36 | __be32 ; |
37 | } __attribute__ ((packed)); |
38 | |
39 | struct { /* According to 3GPP TS 29.060. */ |
40 | __u8 ; |
41 | __u8 ; |
42 | __be16 ; |
43 | __be32 ; |
44 | __be16 ; |
45 | __u8 ; |
46 | __u8 ; |
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 | |
65 | struct gtp_pdu_session_info { /* According to 3GPP TS 38.415. */ |
66 | u8 pdu_type; |
67 | u8 qfi; |
68 | }; |
69 | |
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 | |
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 |
82 | |