pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39191?usp=email )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pcap-server: Move struct osmo_pcap_server alloc to its own helper function ......................................................................
pcap-server: Move struct osmo_pcap_server alloc to its own helper function
Change-Id: Ie3b96ed6f47c966e2e12ab99710ac6af1468f963 --- M src/osmo_server_main.c 1 file changed, 23 insertions(+), 21 deletions(-)
Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c index a04de9b..74d2727 100644 --- a/src/osmo_server_main.c +++ b/src/osmo_server_main.c @@ -204,6 +204,28 @@ msgb_talloc_ctx_init(tall_srv_ctx, 0); }
+static struct osmo_pcap_server *osmo_pcap_server_alloc(void *ctx) +{ + struct osmo_pcap_server *psrv = talloc_zero(ctx, struct osmo_pcap_server); + OSMO_ASSERT(psrv); + + psrv->ctrg = rate_ctr_group_alloc(psrv, &pcap_server_group_desc, 0); + OSMO_ASSERT(psrv->ctrg); + + INIT_LLIST_HEAD(&psrv->conn); + psrv->base_path = talloc_strdup(psrv, "./"); + OSMO_ASSERT(psrv->base_path); + psrv->permission_mask = 0440; + psrv->max_size = 1073741824; /* 1024^3, 1GB **/ + psrv->max_size_enabled = true; + psrv->max_snaplen = DEFAULT_SNAPLEN; + /* By default rotate daily: */ + psrv->rotate_localtime.enabled = true; + psrv->rotate_localtime.intv = TIME_INTERVAL_DAY; + psrv->rotate_localtime.modulus = 1; + return psrv; +} + int main(int argc, char **argv) { int rc; @@ -236,27 +258,7 @@
osmo_tls_init();
- pcap_server = talloc_zero(tall_srv_ctx, struct osmo_pcap_server); - if (!pcap_server) { - LOGP(DSERVER, LOGL_ERROR, "Failed to allocate osmo_pcap_server.\n"); - exit(1); - } - pcap_server->ctrg = rate_ctr_group_alloc(pcap_server, &pcap_server_group_desc, 0); - if (!pcap_server->ctrg) { - LOGP(DSERVER, LOGL_ERROR, "Failed to allocate rate counter.\n"); - exit(1); - } - - INIT_LLIST_HEAD(&pcap_server->conn); - pcap_server->base_path = talloc_strdup(pcap_server, "./"); - pcap_server->permission_mask = 0440; - pcap_server->max_size = 1073741824; /* 1024^3, 1GB **/ - pcap_server->max_size_enabled = true; - pcap_server->max_snaplen = DEFAULT_SNAPLEN; - /* By default rotate daily: */ - pcap_server->rotate_localtime.enabled = true; - pcap_server->rotate_localtime.intv = TIME_INTERVAL_DAY; - pcap_server->rotate_localtime.modulus = 1; + pcap_server = osmo_pcap_server_alloc(tall_srv_ctx);
if (vty_read_config_file(config_file, NULL) < 0) { LOGP(DSERVER, LOGL_ERROR,