Project

General

Profile

pdp_idle_timer.diff

pespin, 08/20/2019 06:28 PM

View differences:

ggsn/ggsn.h
7 7
#include <osmocom/core/select.h>
8 8
#include <osmocom/core/timer.h>
9 9
#include <osmocom/ctrl/control_if.h>
10
#include <osmocom/core/tdef.h>
10 11

  
11 12
#include "../lib/tun.h"
12 13
#include "../lib/ippool.h"
......
67 68
		bool shutdown;
68 69
		/* transmit G-PDU sequeence numbers (true) or not (false) */
69 70
		bool tx_gpdu_seq;
71
		/* Timer defintions */
72
		struct osmo_tdef *T_defs;
70 73
	} cfg;
71 74

  
72 75
	/* corresponding tun device */
ggsn/ggsn_vty.c
26 26
#include <osmocom/core/talloc.h>
27 27
#include <osmocom/core/utils.h>
28 28
#include <osmocom/core/rate_ctr.h>
29
#include <osmocom/core/tdef.h>
29 30
#include <osmocom/gsm/apn.h>
30 31
#include <osmocom/gsm/gsm48_ie.h>
31 32
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
......
33 34
#include <osmocom/vty/command.h>
34 35
#include <osmocom/vty/vty.h>
35 36
#include <osmocom/vty/misc.h>
37
#include <osmocom/vty/tdef_vty.h>
36 38

  
37 39
#include "../gtp/gtp.h"
38 40
#include "../gtp/pdp.h"
......
47 49

  
48 50
LLIST_HEAD(g_ggsn_list);
49 51

  
52
#define PDP_IDLE_SECS	(72*60*60)
53
static struct osmo_tdef ggsn_apn_T_defs[] = {
54
	{ .T=-1713, .default_val=PDP_IDLE_SECS, .desc="PDP context idle timer (s)" },
55
	{}
56
};
57

  
50 58
enum ggsn_vty_node {
51 59
	GGSN_NODE = _LAST_OSMOVTY_NODE + 1,
52 60
	APN_NODE,
......
110 118
	apn->cfg.tx_gpdu_seq = true;
111 119
	INIT_LLIST_HEAD(&apn->cfg.name_list);
112 120

  
121
	apn->cfg.T_defs = talloc_size(apn, sizeof(ggsn_apn_T_defs));
122
	memcpy(apn->cfg.T_defs, ggsn_apn_T_defs, sizeof(ggsn_apn_T_defs));
123
	osmo_tdefs_reset(apn->cfg.T_defs);
124

  
113 125
	llist_add_tail(&apn->list, &ggsn->apn_list);
114 126
	return apn;
115 127
}
......
349 361
	{ 0, NULL }
350 362
};
351 363

  
352

  
353 364
#define V4V6V46_STRING	"IPv4(-only) PDP Type\n"	\
354 365
			"IPv6(-only) PDP Type\n"	\
355 366
			"IPv4v6 (dual-stack) PDP Type\n"
......
633 644
	return CMD_SUCCESS;
634 645
}
635 646

  
647
DEFUN(cfg_apn_show_timer, cfg_apn_show_timer_cmd,
648
      "show timer " OSMO_TDEF_VTY_ARG_T_OPTIONAL,
649
      SHOW_STR "Show APN timers\n"
650
      OSMO_TDEF_VTY_DOC_T)
651
{
652
	struct apn_ctx *apn = (struct apn_ctx *) vty->index;
653
	const char *T_arg = argc > 0 ? argv[0] : NULL;
654
	return osmo_tdef_vty_show_cmd(vty, apn->cfg.T_defs, T_arg, NULL);
655
}
656

  
657
DEFUN(cfg_apn_timer, cfg_apn_timer_cmd,
658
      "timer " OSMO_TDEF_VTY_ARG_SET_OPTIONAL,
659
      "Configure or show APN timers\n"
660
      OSMO_TDEF_VTY_DOC_SET)
661
{
662
	struct apn_ctx *apn = (struct apn_ctx *) vty->index;
663
	/* If any arguments are missing, redirect to 'show' */
664
	if (argc < 2)
665
		return cfg_apn_show_timer(self, vty, argc, argv);
666
	return osmo_tdef_vty_set_cmd(vty, apn->cfg.T_defs, argv);
667
}
668

  
669

  
670

  
636 671

  
637 672
static void vty_dump_prefix(struct vty *vty, const char *pre, const struct in46_prefix *pfx)
638 673
{
......
693 728
	if (apn->v6.cfg.ll_prefix.addr.len)
694 729
		vty_dump_prefix(vty, "  ipv6 link-local", &apn->v6.cfg.ll_prefix);
695 730

  
731
	osmo_tdef_vty_write(vty, apn->cfg.T_defs, " timer ");
732

  
696 733
	/* must be last */
697 734
	vty_out(vty, "  %sshutdown%s", apn->cfg.shutdown ? "" : "no ", VTY_NEWLINE);
698 735
}
......
1043 1080
	install_element(APN_NODE, &cfg_apn_no_ipv6_linklocal_cmd);
1044 1081
	install_element(APN_NODE, &cfg_apn_gpdu_seq_cmd);
1045 1082
	install_element(APN_NODE, &cfg_apn_no_gpdu_seq_cmd);
1083
	install_element(APN_NODE, &cfg_apn_timer_cmd);
1084
	install_element(APN_NODE, &cfg_apn_show_timer_cmd);
1046 1085

  
1047 1086
	return 0;
1048 1087
}
Add picture from clipboard (Maximum size: 48.8 MB)