gtp-kernel: Remove dependency to cmdline.[ch]
Change-Id: I760f25df609c309eba4d5716f3e23b49320449bf
This commit is contained in:
parent
e57cbe2e74
commit
8ffd7fc782
|
@ -710,8 +710,12 @@ int main(int argc, char **argv)
|
||||||
maxfd = gsn->fd1u;
|
maxfd = gsn->fd1u;
|
||||||
|
|
||||||
/* use GTP kernel module for data packet encapsulation */
|
/* use GTP kernel module for data packet encapsulation */
|
||||||
if (gtp_kernel_init(gsn, &net.v4, prefixlen, &args_info) < 0)
|
if (args_info.gtp_linux_given) {
|
||||||
goto err;
|
if (gtp_kernel_init(gsn, &net.v4, prefixlen, args_info.net_arg) < 0) {
|
||||||
|
SYS_ERR(DGGSN, LOGL_ERROR, 0, "Failed to initialize kernel GTP\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gtp_set_cb_data_ind(gsn, encaps_tun);
|
gtp_set_cb_data_ind(gsn, encaps_tun);
|
||||||
gtp_set_cb_delete_context(gsn, delete_context);
|
gtp_set_cb_delete_context(gsn, delete_context);
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "../lib/syserr.h"
|
#include "../lib/syserr.h"
|
||||||
#include "../gtp/pdp.h"
|
#include "../gtp/pdp.h"
|
||||||
#include "../gtp/gtp.h"
|
#include "../gtp/gtp.h"
|
||||||
#include "cmdline.h"
|
|
||||||
|
|
||||||
#include <libgtpnl/gtp.h>
|
#include <libgtpnl/gtp.h>
|
||||||
#include <libgtpnl/gtpnl.h>
|
#include <libgtpnl/gtpnl.h>
|
||||||
|
@ -80,12 +79,8 @@ static struct {
|
||||||
#define GTP_DEVNAME "gtp0"
|
#define GTP_DEVNAME "gtp0"
|
||||||
|
|
||||||
int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
||||||
size_t prefixlen,
|
size_t prefixlen, const char *net_arg)
|
||||||
struct gengetopt_args_info *args_info)
|
|
||||||
{
|
{
|
||||||
if (!args_info->gtp_linux_given)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (gtp_dev_create(-1, GTP_DEVNAME, gsn->fd0, gsn->fd1u) < 0) {
|
if (gtp_dev_create(-1, GTP_DEVNAME, gsn->fd0, gsn->fd1u) < 0) {
|
||||||
SYS_ERR(DGGSN, LOGL_ERROR, 0,
|
SYS_ERR(DGGSN, LOGL_ERROR, 0,
|
||||||
"cannot create GTP tunnel device: %s\n",
|
"cannot create GTP tunnel device: %s\n",
|
||||||
|
@ -113,12 +108,12 @@ int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGP(DGGSN, "Setting route to reach %s via %s\n",
|
DEBUGP(DGGSN, "Setting route to reach %s via %s\n",
|
||||||
args_info->net_arg, GTP_DEVNAME);
|
net_arg, GTP_DEVNAME);
|
||||||
|
|
||||||
if (gtp_dev_config(GTP_DEVNAME, net, prefixlen) < 0) {
|
if (gtp_dev_config(GTP_DEVNAME, net, prefixlen) < 0) {
|
||||||
SYS_ERR(DGGSN, LOGL_ERROR, 0,
|
SYS_ERR(DGGSN, LOGL_ERROR, 0,
|
||||||
"Cannot add route to reach network %s\n",
|
"Cannot add route to reach network %s\n",
|
||||||
args_info->net_arg);
|
net_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* launch script if it is set to bring up the route to reach
|
/* launch script if it is set to bring up the route to reach
|
||||||
|
@ -132,7 +127,7 @@ int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
||||||
|
|
||||||
/* eg. /home/ggsn/ipup gtp0 10.0.0.0/8 */
|
/* eg. /home/ggsn/ipup gtp0 10.0.0.0/8 */
|
||||||
snprintf(cmd, sizeof(cmd), "%s %s %s",
|
snprintf(cmd, sizeof(cmd), "%s %s %s",
|
||||||
ipup, GTP_DEVNAME, args_info->net_arg);
|
ipup, GTP_DEVNAME, net_arg);
|
||||||
cmd[sizeof(cmd)-1] = '\0';
|
cmd[sizeof(cmd)-1] = '\0';
|
||||||
|
|
||||||
err = system(cmd);
|
err = system(cmd);
|
||||||
|
|
|
@ -8,8 +8,7 @@ extern char *ipup;
|
||||||
|
|
||||||
#ifdef GTP_KERNEL
|
#ifdef GTP_KERNEL
|
||||||
int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
||||||
size_t prefixlen,
|
size_t prefixlen, const char *net_arg);
|
||||||
struct gengetopt_args_info *args_info);
|
|
||||||
void gtp_kernel_stop(void);
|
void gtp_kernel_stop(void);
|
||||||
|
|
||||||
int gtp_kernel_tunnel_add(struct pdp_t *pdp);
|
int gtp_kernel_tunnel_add(struct pdp_t *pdp);
|
||||||
|
@ -19,15 +18,10 @@ int gtp_kernel_enabled(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static inline int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
static inline int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
|
||||||
size_t prefixlen,
|
size_t prefixlen, const char *net_arg)
|
||||||
struct gengetopt_args_info *args_info)
|
|
||||||
{
|
{
|
||||||
if (args_info->gtp_linux_given) {
|
SYS_ERR(DGGSN, LOGL_ERROR, 0, "ggsn compiled without GTP kernel support!\n");
|
||||||
SYS_ERR(DGGSN, LOGL_ERROR, 0,
|
return -1;
|
||||||
"ggsn compiled without GTP kernel support!\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gtp_kernel_stop(void) {}
|
static inline void gtp_kernel_stop(void) {}
|
||||||
|
|
Reference in New Issue