Update INFO.yaml to add David Liu from Wind River as a committer
[it/test.git] / simulators / workload_generators / e2e_testing / src / wg_defs.cpp
1 /*****************************************************************************
2 #                                                                            *
3 # Copyright 2020 AT&T Intellectual Property                                  *
4 # Copyright 2020 Nokia                                                       *
5 #                                                                            *
6 # Licensed under the Apache License, Version 2.0 (the "License");            *
7 # you may not use this file except in compliance with the License.           *
8 # You may obtain a copy of the License at                                    *
9 #                                                                            *
10 #      http://www.apache.org/licenses/LICENSE-2.0                            *
11 #                                                                            *
12 # Unless required by applicable law or agreed to in writing, software        *
13 # distributed under the License is distributed on an "AS IS" BASIS,          *
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
15 # See the License for the specific language governing permissions and        *
16 # limitations under the License.                                             *
17 #                                                                            *
18 ******************************************************************************/
19
20 #include "wg_defs.h"
21 #include "e2sim_defs.h"
22 #include <getopt.h>
23 #include <iostream>
24
25 using namespace std;
26
27 wg_options_t wg_input_options(int argc, char *argv[]) {
28   wg_options_t options;
29   options.server_ip = (char*)DEFAULT_SCTP_IP;
30   options.server_port = X2AP_SCTP_PORT;
31   options.rate = 1;
32   if (argc == 4) {
33     options.server_ip = argv[1];
34     options.server_port = atoi(argv[2]);
35     options.rate = atoi(argv[3]);
36   } else if (argc == 3) {
37     options.server_ip = argv[1];
38     options.server_port = atoi(argv[2]);
39     if (options.server_port < 1 || options.server_port > 65535) {
40       LOG_E("Invalid port number (%d). Valid values are between 1 and 65535.\n",
41             options.server_port);
42       exit(1);
43     }
44   } else if (argc == 2) {
45     options.server_ip = argv[1];
46   } else if (argc == 1) {
47     options.server_ip = (char*)DEFAULT_SCTP_IP;
48   } else {
49     LOG_I("Unrecognized option.\n");
50     LOG_I("Usage: %s [SERVER IP ADDRESS] [SERVER PORT] [RATE]\n", argv[0]);
51     exit(1);
52   }
53   return options;
54 }