gtp.h 1.51 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2
#ifndef _GTP_H_
3
#define _GTP_H_
4

5 6 7 8
#include <linux/netdevice.h>
#include <linux/types.h>
#include <net/rtnetlink.h>

9 10 11 12 13
/* General GTP protocol related definitions. */

#define GTP0_PORT	3386
#define GTP1U_PORT	2152

14 15 16
/* GTP messages types */
#define GTP_ECHO_REQ	1	/* Echo Request */
#define GTP_ECHO_RSP	2	/* Echo Response */
17 18
#define GTP_TPDU	255

19 20
#define GTPIE_RECOVERY	14

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
struct gtp0_header {	/* According to GSM TS 09.60. */
	__u8	flags;
	__u8	type;
	__be16	length;
	__be16	seq;
	__be16	flow;
	__u8	number;
	__u8	spare[3];
	__be64	tid;
} __attribute__ ((packed));

struct gtp1_header {	/* According to 3GPP TS 29.060. */
	__u8	flags;
	__u8	type;
	__be16	length;
	__be32	tid;
} __attribute__ ((packed));

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
struct gtp1_header_long {	/* According to 3GPP TS 29.060. */
	__u8	flags;
	__u8	type;
	__be16	length;
	__be32	tid;
	__be16	seq;
	__u8	npdu;
	__u8	next;
} __packed;

/* GTP Information Element */
struct gtp_ie {
	__u8	tag;
	__u8	val;
} __packed;

struct gtp0_packet {
	struct gtp0_header gtp0_h;
	struct gtp_ie ie;
} __packed;

struct gtp1u_packet {
	struct gtp1_header_long gtp1u_h;
	struct gtp_ie ie;
} __packed;

65 66 67 68 69
struct gtp_pdu_session_info {	/* According to 3GPP TS 38.415. */
	u8	pdu_type;
	u8	qfi;
};

70 71 72 73 74 75
static inline bool netif_is_gtp(const struct net_device *dev)
{
	return dev->rtnl_link_ops &&
		!strcmp(dev->rtnl_link_ops->kind, "gtp");
}

76 77 78 79 80
#define GTP1_F_NPDU	0x01
#define GTP1_F_SEQ	0x02
#define GTP1_F_EXTHDR	0x04
#define GTP1_F_MASK	0x07

81 82 83 84 85
struct gtp_ext_hdr {
	__u8	len;
	__u8	data[];
};

86
#endif