aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2014-02-20 18:43:15 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2014-02-20 19:41:29 +0100
commit14506665d982862e82b15d5f0b9578c213390515 (patch)
treebb8388e0bd4f755a4e1cf81da6e84bd6bef88ab4 /include
add libgtpnl
This patch adds the libgtpnl library. Harald mentioned that he wanted that the specific code that is added is well encapsulated, so let's start a small library to interact with the GTP kernel module via netlink interface. This was done a bit while in the rush, so the interfaces are not nice at all and the tools need to be ported on top of this library. This library will be used to integrate openggsn with the GTP kernel module.
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am1
-rw-r--r--include/libgtpnl/Makefile.am1
-rw-r--r--include/libgtpnl/gtpnl.h26
-rw-r--r--include/linux/Makefile.am1
-rw-r--r--include/linux/gtp_nl.h45
5 files changed, 74 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..bafe5e3
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = libgtpnl linux
diff --git a/include/libgtpnl/Makefile.am b/include/libgtpnl/Makefile.am
new file mode 100644
index 0000000..b1c2bee
--- /dev/null
+++ b/include/libgtpnl/Makefile.am
@@ -0,0 +1 @@
+pkginclude_HEADERS = gtpnl.h
diff --git a/include/libgtpnl/gtpnl.h b/include/libgtpnl/gtpnl.h
new file mode 100644
index 0000000..00a60d8
--- /dev/null
+++ b/include/libgtpnl/gtpnl.h
@@ -0,0 +1,26 @@
+#ifndef _LIBGTPNL_H_
+#define _LIBGTPNL_H_
+
+#include <stdint.h>
+
+struct mnl_socket;
+struct nlmsghdr;
+
+struct mnl_socket *genl_socket_open(void);
+struct nlmsghdr *genl_nlmsg_build_hdr(char *buf, uint16_t type, uint16_t flags,
+ uint32_t seq, uint8_t cmd);
+int genl_socket_talk(struct mnl_socket *nl, struct nlmsghdr *nlh, uint32_t seq,
+ int (*cb)(const struct nlmsghdr *nlh, void *data),
+ void *data);
+int genl_lookup_family(struct mnl_socket *nl, const char *family);
+
+int gtp_dev_create(const char *ifname);
+
+int gtp_add_tunnel(int genl_id, struct mnl_socket *nl, const char *ifname,
+ const char *ms_addr, const char *sgsn_addr, uint64_t tid,
+ int gtp_version);
+int gtp_del_tunnel(int genl_id, struct mnl_socket *nl, const char *ifname,
+ uint64_t tid, uint32_t gtp_version);
+int gtp_list_tunnel(int genl_id, struct mnl_socket *nl);
+
+#endif
diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
new file mode 100644
index 0000000..082198e
--- /dev/null
+++ b/include/linux/Makefile.am
@@ -0,0 +1 @@
+noinst_HEADERS = gtp_nl.h
diff --git a/include/linux/gtp_nl.h b/include/linux/gtp_nl.h
new file mode 100644
index 0000000..968824c
--- /dev/null
+++ b/include/linux/gtp_nl.h
@@ -0,0 +1,45 @@
+#ifndef _UAPI_LINUX_GTP_H_
+#define _UAPI_LINUX_GTP_H__
+
+enum {
+ IFLA_GTP_UNSPEC,
+ IFLA_GTP_LOCAL_ADDR_IPV4,
+ IFLA_GTP_HASHSIZE,
+ __IFLA_GTP_MAX,
+};
+#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
+
+enum gtp_genl_cmds {
+ GTP_CMD_TUNNEL_NEW,
+ GTP_CMD_TUNNEL_DELETE,
+ GTP_CMD_TUNNEL_GET,
+
+ GTP_CMD_TUNNEL_MAX,
+};
+
+enum gtp_version {
+ GTP_V0 = 0,
+ GTP_V1,
+};
+
+enum gtp_cfg_attrs {
+ GTPA_CFG_UNSPEC = 0,
+ GTPA_CFG_LINK,
+ GTPA_CFG_LOCAL_ADDR_IPV4,
+ GTPA_CFG_HSIZE,
+ __GTPA_CFG_MAX,
+};
+#define GTPA_CFG_MAX (__GTPA_CFG_MAX + 1)
+
+enum gtp_attrs {
+ GTPA_UNSPEC = 0,
+ GTPA_LINK,
+ GTPA_VERSION,
+ GTPA_TID, /* 64 bits for GTPv1 */
+ GTPA_SGSN_ADDRESS,
+ GTPA_MS_ADDRESS,
+ __GTPA_MAX,
+};
+#define GTPA_MAX (__GTPA_MAX + 1)
+
+#endif /* _UAPI_LINUX_GTP_H_ */