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"
25 char* time_stamp(void)
28 gettimeofday(&curTime, NULL);
29 int milli = curTime.tv_usec / 1000;
32 strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", localtime(&curTime.tv_sec));
34 const int time_buffer_len = 84;
35 static char currentTime[time_buffer_len] = "";
36 snprintf(currentTime, time_buffer_len, "%s:%03d", buffer, milli);
41 options_t read_input_options_old(int argc, char* argv[])
45 options.server_ip = (char*)DEFAULT_SCTP_IP;
46 options.server_port = X2AP_SCTP_PORT;
48 // Parse command line options
49 static struct option long_options[] =
51 {"ipv4", required_argument, 0, 'i'},
52 {"ipv6", required_argument, 0, 'I'},
53 {"port", required_argument, 0, 'p'},
54 {"verbose", no_argument, 0, 'v'},
61 char c = getopt_long(argc, argv, "i:I:p:", long_options, &option_index);
69 options.server_ip = optarg;
74 options.server_port = atoi(optarg);
75 if(options.server_port < 1 || options.server_port > 65535)
77 LOG_E("Invalid port number (%d). Valid values are between 1 and 65535.\n",
84 LOG_E("Error: unknown input option: %c\n", optopt);
92 options_t read_input_options(int argc, char *argv[])
96 options.server_ip = (char*)DEFAULT_SCTP_IP;
97 options.server_port = X2AP_SCTP_PORT;
99 if(argc == 3) //user provided IP and PORT
101 options.server_ip = argv[1];
102 options.server_port = atoi(argv[2]);
103 if(options.server_port < 1 || options.server_port > 65535) {
104 LOG_E("Invalid port number (%d). Valid values are between 1 and 65535.\n",
105 options.server_port);
109 else if(argc == 2) //user provided only IP
111 options.server_ip = argv[1];
115 options.server_ip = (char*)DEFAULT_SCTP_IP;
119 LOG_I("Unrecognized option.\n");
120 LOG_I("Usage: %s [SERVER IP ADDRESS] [SERVER PORT]\n", argv[0]);