Change in ...osmo-ggsn[master]: ggsn: Split application lifecycle related code into ggsn_main.c

2019-08-28 Thread laforge
laforge has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/15249 )

Change subject: ggsn: Split application lifecycle related code into ggsn_main.c
..

ggsn: Split application lifecycle related code into ggsn_main.c

This way we further shrink ggsn.c and leave there GGSN related code.

Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
---
M ggsn/Makefile.am
M ggsn/ggsn.c
M ggsn/ggsn.h
A ggsn/ggsn_main.c
4 files changed, 214 insertions(+), 176 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve



diff --git a/ggsn/Makefile.am b/ggsn/Makefile.am
index 022cdef..a8ddf1e 100644
--- a/ggsn/Makefile.am
+++ b/ggsn/Makefile.am
@@ -12,4 +12,4 @@
 endif

 osmo_ggsn_DEPENDENCIES = ../gtp/libgtp.la ../lib/libmisc.a
-osmo_ggsn_SOURCES = ggsn_vty.c ggsn.c ggsn.h icmpv6.c icmpv6.h checksum.c 
checksum.h pco.c pco.h
+osmo_ggsn_SOURCES = ggsn_main.c ggsn_vty.c ggsn.c ggsn.h icmpv6.c icmpv6.h 
checksum.c checksum.h pco.c pco.h
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 3c702c2..c7756d9 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -42,22 +42,8 @@
 #include 
 #include 

-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 

 #include "../lib/tun.h"
@@ -71,19 +57,9 @@
 #include "pco.h"
 #include "ggsn.h"

-void *tall_ggsn_ctx;
-
-static int end = 0;
-static int daemonize = 0;
-static struct ctrl_handle *g_ctrlh;
-
-struct ul255_t qos;
-struct ul255_t apn;
-
 static int ggsn_tun_fd_cb(struct osmo_fd *fd, unsigned int what);
 static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len);

-
 static void pool_close_all_pdp(struct ippool_t *pool)
 {
unsigned int i;
@@ -690,8 +666,6 @@
return tun_encaps((struct tun_t *)pdp->ipif, pack, len);
 }

-static char *config_file = "osmo-ggsn.cfg";
-
 /* callback for tun device osmocom select loop integration */
 static int ggsn_tun_fd_cb(struct osmo_fd *fd, unsigned int what)
 {
@@ -749,29 +723,6 @@
ggsn_gtp_tmr_start(ggsn);
 }

-/* To exit gracefully. Used with GCC compilation flag -pg and gprof */
-static void signal_handler(int s)
-{
-   LOGP(DGGSN, LOGL_NOTICE, "signal %d received\n", s);
-   switch (s) {
-   case SIGINT:
-   case SIGTERM:
-   LOGP(DGGSN, LOGL_NOTICE, "SIGINT received, shutting down\n");
-   end = 1;
-   break;
-   case SIGABRT:
-   case SIGUSR1:
-   talloc_report(tall_vty_ctx, stderr);
-   talloc_report_full(tall_ggsn_ctx, stderr);
-   break;
-   case SIGUSR2:
-   talloc_report_full(tall_vty_ctx, stderr);
-   break;
-   default:
-   break;
-   }
-}
-
 /* libgtp callback for confirmations */
 static int cb_conf(int type, int cause, struct pdp_t *pdp, void *cbp)
 {
@@ -882,128 +833,3 @@
ggsn->started = false;
return 0;
 }
-
-static void print_usage()
-{
-   printf("Usage: osmo-ggsn [-h] [-D] [-c configfile] [-V]\n");
-}
-
-static void print_help()
-{
-   printf( "  Some useful help...\n"
-   "  -h --helpThis help text\n"
-   "  -D --daemonize   Fork the process into a background 
daemon\n"
-   "  -c --config-file filename The config file to use\n"
-   "  -V --version Print the version of OsmoGGSN\n"
-   );
-}
-
-static void handle_options(int argc, char **argv)
-{
-   while (1) {
-   int option_index = 0, c;
-   static struct option long_options[] = {
-   { "help", 0, 0, 'h' },
-   { "daemonize", 0, 0, 'D' },
-   { "config-file", 1, 0, 'c' },
-   { "version", 0, 0, 'V' },
-   { 0, 0, 0, 0 }
-   };
-
-   c = getopt_long(argc, argv, "hdc:V", long_options, 
_index);
-   if (c == -1)
-   break;
-
-   switch (c) {
-   case 'h':
-   print_usage();
-   print_help();
-   exit(0);
-   case 'D':
-   daemonize = 1;
-   break;
-   case 'c':
-   config_file = optarg;
-   break;
-   case 'V':
-   print_version(1);
-   exit(0);
-   break;
-   }
-   }
-}
-
-int main(int argc, char **argv)
-{
-   struct ggsn_ctx *ggsn;
-   int rc;
-
-   tall_ggsn_ctx = talloc_named_const(NULL, 0, "OsmoGGSN");
-   msgb_talloc_ctx_init(tall_ggsn_ctx, 0);
-   g_vty_info.tall_ctx = tall_ggsn_ctx;
-
-   /* Handle 

Change in ...osmo-ggsn[master]: ggsn: Split application lifecycle related code into ggsn_main.c

2019-08-28 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/15249 )

Change subject: ggsn: Split application lifecycle related code into ggsn_main.c
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/15249
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
Gerrit-Change-Number: 15249
Gerrit-PatchSet: 3
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Thu, 29 Aug 2019 05:26:57 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...osmo-ggsn[master]: ggsn: Split application lifecycle related code into ggsn_main.c

2019-08-28 Thread osmith
osmith has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/15249 )

Change subject: ggsn: Split application lifecycle related code into ggsn_main.c
..


Patch Set 2: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/15249
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
Gerrit-Change-Number: 15249
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-CC: laforge 
Gerrit-Comment-Date: Wed, 28 Aug 2019 06:04:30 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...osmo-ggsn[master]: ggsn: Split application lifecycle related code into ggsn_main.c

2019-08-23 Thread pespin
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-ggsn/+/15249

to look at the new patch set (#2).

Change subject: ggsn: Split application lifecycle related code into ggsn_main.c
..

ggsn: Split application lifecycle related code into ggsn_main.c

This way we further shrink ggsn.c and leave there GGSN related code.

Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
---
M ggsn/Makefile.am
M ggsn/ggsn.c
M ggsn/ggsn.h
A ggsn/ggsn_main.c
4 files changed, 214 insertions(+), 176 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/49/15249/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/15249
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
Gerrit-Change-Number: 15249
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-MessageType: newpatchset


Change in ...osmo-ggsn[master]: ggsn: Split application lifecycle related code into ggsn_main.c

2019-08-22 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/15249 )

Change subject: ggsn: Split application lifecycle related code into ggsn_main.c
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/15249/1/ggsn/ggsn_main.c
File ggsn/ggsn_main.c:

https://gerrit.osmocom.org/#/c/15249/1/ggsn/ggsn_main.c@3
PS1, Line 3:  * Copyright 2019 sysmocom - s.f.m.c. GmbH 
same here, I would be very careful about putting this copyright statement with 
only sysmocom here, unless you have actually checked in detail that all commits 
leading to the lines you're moving actually have been written by sysmocom 
employees.



--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/15249
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
Gerrit-Change-Number: 15249
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-Comment-Date: Thu, 22 Aug 2019 21:13:58 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in ...osmo-ggsn[master]: ggsn: Split application lifecycle related code into ggsn_main.c

2019-08-20 Thread pespin
pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/15249


Change subject: ggsn: Split application lifecycle related code into ggsn_main.c
..

ggsn: Split application lifecycle related code into ggsn_main.c

This way we further shrink ggsn.c and leave there GGSN related code.

Change-Id: I9e6a3beac7657f0a8c02d514b54c6f1caa93bba7
---
M ggsn/Makefile.am
M ggsn/ggsn.c
M ggsn/ggsn.h
A ggsn/ggsn_main.c
4 files changed, 212 insertions(+), 176 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/49/15249/1

diff --git a/ggsn/Makefile.am b/ggsn/Makefile.am
index 022cdef..a8ddf1e 100644
--- a/ggsn/Makefile.am
+++ b/ggsn/Makefile.am
@@ -12,4 +12,4 @@
 endif

 osmo_ggsn_DEPENDENCIES = ../gtp/libgtp.la ../lib/libmisc.a
-osmo_ggsn_SOURCES = ggsn_vty.c ggsn.c ggsn.h icmpv6.c icmpv6.h checksum.c 
checksum.h pco.c pco.h
+osmo_ggsn_SOURCES = ggsn_main.c ggsn_vty.c ggsn.c ggsn.h icmpv6.c icmpv6.h 
checksum.c checksum.h pco.c pco.h
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 7832338..d519621 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -42,22 +42,8 @@
 #include 
 #include 

-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 

 #include "../lib/tun.h"
@@ -71,19 +57,9 @@
 #include "pco.h"
 #include "ggsn.h"

-void *tall_ggsn_ctx;
-
-static int end = 0;
-static int daemonize = 0;
-static struct ctrl_handle *g_ctrlh;
-
-struct ul255_t qos;
-struct ul255_t apn;
-
 static int ggsn_tun_fd_cb(struct osmo_fd *fd, unsigned int what);
 static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len);

-
 static void pool_close_all_pdp(struct ippool_t *pool)
 {
unsigned int i;
@@ -690,8 +666,6 @@
return tun_encaps((struct tun_t *)pdp->ipif, pack, len);
 }

-static char *config_file = "osmo-ggsn.cfg";
-
 /* callback for tun device osmocom select loop integration */
 static int ggsn_tun_fd_cb(struct osmo_fd *fd, unsigned int what)
 {
@@ -749,29 +723,6 @@
ggsn_gtp_tmr_start(ggsn);
 }

-/* To exit gracefully. Used with GCC compilation flag -pg and gprof */
-static void signal_handler(int s)
-{
-   LOGP(DGGSN, LOGL_NOTICE, "signal %d received\n", s);
-   switch (s) {
-   case SIGINT:
-   case SIGTERM:
-   LOGP(DGGSN, LOGL_NOTICE, "SIGINT received, shutting down\n");
-   end = 1;
-   break;
-   case SIGABRT:
-   case SIGUSR1:
-   talloc_report(tall_vty_ctx, stderr);
-   talloc_report_full(tall_ggsn_ctx, stderr);
-   break;
-   case SIGUSR2:
-   talloc_report_full(tall_vty_ctx, stderr);
-   break;
-   default:
-   break;
-   }
-}
-
 /* libgtp callback for confirmations */
 static int cb_conf(int type, int cause, struct pdp_t *pdp, void *cbp)
 {
@@ -882,128 +833,3 @@
ggsn->started = false;
return 0;
 }
-
-static void print_usage()
-{
-   printf("Usage: osmo-ggsn [-h] [-D] [-c configfile] [-V]\n");
-}
-
-static void print_help()
-{
-   printf( "  Some useful help...\n"
-   "  -h --helpThis help text\n"
-   "  -D --daemonize   Fork the process into a background 
daemon\n"
-   "  -c --config-file filename The config file to use\n"
-   "  -V --version Print the version of OsmoGGSN\n"
-   );
-}
-
-static void handle_options(int argc, char **argv)
-{
-   while (1) {
-   int option_index = 0, c;
-   static struct option long_options[] = {
-   { "help", 0, 0, 'h' },
-   { "daemonize", 0, 0, 'D' },
-   { "config-file", 1, 0, 'c' },
-   { "version", 0, 0, 'V' },
-   { 0, 0, 0, 0 }
-   };
-
-   c = getopt_long(argc, argv, "hdc:V", long_options, 
_index);
-   if (c == -1)
-   break;
-
-   switch (c) {
-   case 'h':
-   print_usage();
-   print_help();
-   exit(0);
-   case 'D':
-   daemonize = 1;
-   break;
-   case 'c':
-   config_file = optarg;
-   break;
-   case 'V':
-   print_version(1);
-   exit(0);
-   break;
-   }
-   }
-}
-
-int main(int argc, char **argv)
-{
-   struct ggsn_ctx *ggsn;
-   int rc;
-
-   tall_ggsn_ctx = talloc_named_const(NULL, 0, "OsmoGGSN");
-   msgb_talloc_ctx_init(tall_ggsn_ctx, 0);
-   g_vty_info.tall_ctx = tall_ggsn_ctx;
-
-   /* Handle keyboard interrupt SIGINT */
-   signal(SIGINT, _handler);
-