Add support for SGSN role via IFLA_GTP_ROLE
This patch corresponds to a Linux kernel patch extending the kernel GTP
to also cover the SGSN role, not just the GGSN role. In order to keep
the API/behavior compatible, gtp_dev_create() will continue to create
GGSN-side tunnels, while a new gtp_dev_create_sgsn() is introduced to
create SGSN-side tunnels.
Signed-off-by: Harald Welte <laforge@gnumonks.org>
diff --git a/tools/gtp-link.c b/tools/gtp-link.c
index 97dfa45..8367c6e 100644
--- a/tools/gtp-link.c
+++ b/tools/gtp-link.c
@@ -43,9 +43,9 @@
int main(int argc, char *argv[])
{
char buf[MNL_SOCKET_BUFFER_SIZE];
- int ret;
+ int ret, sgsn_mode = 0;
- if (argc != 3) {
+ if (argc < 3) {
printf("Usage: %s <add|del> <device>\n", argv[0]);
exit(EXIT_FAILURE);
}
@@ -58,6 +58,9 @@
return 0;
}
+ if (argc > 3 && !strcmp(argv[3], "--sgsn"))
+ sgsn_mode = 1;
+
int fd1 = socket(AF_INET, SOCK_DGRAM, 0);
int fd2 = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in sockaddr_fd1 = {
@@ -86,7 +89,10 @@
exit(EXIT_FAILURE);
}
- ret = gtp_dev_create(-1, argv[2], fd1, fd2);
+ if (sgsn_mode)
+ ret = gtp_dev_create_sgsn(-1, argv[2], fd1, fd2);
+ else
+ ret = gtp_dev_create(-1, argv[2], fd1, fd2);
if (ret < 0) {
perror("cannot create GTP device\n");
exit(EXIT_FAILURE);