1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
4 # Copyright 2019 Nokia *
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 *
10 # http://www.apache.org/licenses/LICENSE-2.0 *
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. *
18 ******************************************************************************/
20 #include "e2sim_defs.h"
23 options_t read_input_options_old(int argc, char* argv[])
27 options.server_ip = (char*)DEFAULT_SCTP_IP;
28 options.server_port = X2AP_SCTP_PORT;
30 // Parse command line options
31 static struct option long_options[] =
33 {"ipv4", required_argument, 0, 'i'},
34 {"ipv6", required_argument, 0, 'I'},
35 {"port", required_argument, 0, 'p'},
36 {"verbose", no_argument, 0, 'v'},
43 char c = getopt_long(argc, argv, "i:I:p:", long_options, &option_index);
51 options.server_ip = optarg;
56 options.server_port = atoi(optarg);
57 if(options.server_port < 1 || options.server_port > 65535)
59 LOG_E("Invalid port number (%d). Valid values are between 1 and 65535.\n",
66 LOG_E("Error: unknown input option: %c\n", optopt);
74 options_t read_input_options(int argc, char *argv[])
78 options.server_ip = (char*)DEFAULT_SCTP_IP;
79 options.server_port = X2AP_SCTP_PORT;
81 if(argc == 3) //user provided IP and PORT
83 options.server_ip = argv[1];
84 options.server_port = atoi(argv[2]);
85 if(options.server_port < 1 || options.server_port > 65535) {
86 LOG_E("Invalid port number (%d). Valid values are between 1 and 65535.\n",
91 else if(argc == 2) //user provided only IP
93 options.server_ip = argv[1];
97 options.server_ip = (char*)DEFAULT_SCTP_IP;
101 LOG_I("Unrecognized option.\n");
102 LOG_I("Usage: %s [SERVER IP ADDRESS] [SERVER PORT]\n", argv[0]);