Merge "update userguide alignment"
[samplevnf.git] / VNFs / vCGNAPT / main.c
1 /*
2 // Copyright (c) 2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #include "app.h"
18 #include "pipeline_cgnapt.h"
19
20 static struct app_params app;
21
22 int
23 main(int argc, char **argv)
24 {
25         struct mg_context *ctx = NULL;
26         rte_openlog_stream(stderr);
27
28         /* Config */
29         app_config_init(&app);
30
31         app_config_args(&app, argc, argv);
32
33         /* initialize the rest api */
34         if (is_rest_support()) {
35                 set_vnf_type("VCGNAPT");
36                 ctx = rest_api_init(&app);
37         }
38
39         app_config_preproc(&app);
40
41         app_config_parse(&app, app.parser_file);
42
43         app_config_check(&app);
44
45         /* Timer subsystem init*/
46         rte_timer_subsystem_init();
47
48         /* Init */
49         app_init(&app);
50
51         if (is_rest_support() && (ctx != NULL)) {
52                 /* rest api's for cgnapt */
53                 rest_api_cgnapt_init(ctx, &app);
54         }
55
56         /* Run-time */
57         rte_eal_mp_remote_launch(
58                 app_thread,
59                 (void *) &app,
60                 CALL_MASTER);
61
62         if (is_rest_support() && (ctx != NULL)) {
63                 mg_stop(ctx);
64                 printf("Civet server stopped.\n");
65         }
66
67         return 0;
68 }