Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AUSF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-AUSF
Commits
cea0923b
Commit
cea0923b
authored
May 10, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
fb148318
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1 addition
and
362 deletions
+1
-362
src/common/CMakeLists.txt
src/common/CMakeLists.txt
+1
-2
src/common/ausf.h
src/common/ausf.h
+0
-9
src/common/dynamic_memory_check.c
src/common/dynamic_memory_check.c
+0
-43
src/common/dynamic_memory_check.h
src/common/dynamic_memory_check.h
+0
-34
src/common/endpoint.hpp
src/common/endpoint.hpp
+0
-90
src/common/options.cpp
src/common/options.cpp
+0
-133
src/common/options.hpp
src/common/options.hpp
+0
-51
No files found.
src/common/CMakeLists.txt
View file @
cea0923b
...
...
@@ -27,8 +27,7 @@ include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
add_library
(
3GPP_COMMON_TYPES STATIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/logger.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/conversions.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/options.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/conversions.cpp
)
src/common/ausf.h
View file @
cea0923b
...
...
@@ -69,15 +69,6 @@ typedef enum patch_op_type_s {
static
const
std
::
vector
<
std
::
string
>
patch_op_type_e2str
=
{
"ADD"
,
"REMOVE"
,
"REPLACE"
,
"MOVE"
,
"COPY"
,
"TEST"
,
"UNKNOWN"
};
// Event Subscription IDs)
typedef
uint32_t
evsub_id_t
;
#define EVSUB_ID_FMT "0x%" PRIx32
#define EVSUB_ID_SCAN_FMT SCNx32
#define INVALID_EVSUB_ID ((evsub_id_t) 0x00000000)
#define UNASSIGNED_EVSUB_ID ((evsub_id_t) 0x00000000)
#define NAUSF_NFM_NF_INSTANCE "/nf-instances/"
#define NF_CURL_TIMEOUT_MS 1000L
#define MAX_WAIT_MSECS 20000 // 1 second
...
...
src/common/dynamic_memory_check.c
deleted
100644 → 0
View file @
fb148318
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the FreeBSD Project.
*/
#include <stdlib.h>
#include "dynamic_memory_check.h"
#include "assertions.h"
//------------------------------------------------------------------------------
void
free_wrapper
(
void
**
ptr
)
{
// for debug only
AssertFatal
(
ptr
,
"Trying to free NULL ptr"
);
if
(
ptr
)
{
free
(
*
ptr
);
*
ptr
=
NULL
;
}
}
src/common/dynamic_memory_check.h
deleted
100644 → 0
View file @
fb148318
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file dynamic_memory_check.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_DYNAMIC_MEMORY_CHECK_SEEN
#define FILE_DYNAMIC_MEMORY_CHECK_SEEN
void
free_wrapper
(
void
**
ptr
)
__attribute__
((
hot
));
#endif
/* FILE_DYNAMIC_MEMORY_CHECK_SEEN */
src/common/endpoint.hpp
deleted
100644 → 0
View file @
fb148318
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file endpoint.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_ENDPOINT_HPP_SEEN
#define FILE_ENDPOINT_HPP_SEEN
#include <arpa/inet.h>
#include <inttypes.h>
#include <string.h>
#include <sys/socket.h>
#include "conversions.hpp"
class
endpoint
{
public:
struct
sockaddr_storage
addr_storage
;
socklen_t
addr_storage_len
;
endpoint
()
:
addr_storage
(),
addr_storage_len
(
sizeof
(
struct
sockaddr_storage
)){};
endpoint
(
const
endpoint
&
e
)
:
addr_storage
(
e
.
addr_storage
),
addr_storage_len
(
e
.
addr_storage_len
){};
endpoint
(
const
struct
sockaddr_storage
&
addr
,
const
socklen_t
len
)
:
addr_storage
(
addr
),
addr_storage_len
(
len
){};
endpoint
(
const
struct
in_addr
&
addr
,
const
uint16_t
port
)
{
struct
sockaddr_in
*
addr_in
=
(
struct
sockaddr_in
*
)
&
addr_storage
;
addr_in
->
sin_family
=
AF_INET
;
addr_in
->
sin_port
=
htons
(
port
);
addr_in
->
sin_addr
.
s_addr
=
addr
.
s_addr
;
addr_storage_len
=
sizeof
(
struct
sockaddr_in
);
};
endpoint
(
const
struct
in6_addr
&
addr6
,
const
uint16_t
port
)
{
struct
sockaddr_in6
*
addr_in6
=
(
struct
sockaddr_in6
*
)
&
addr_storage
;
addr_in6
->
sin6_family
=
AF_INET6
;
addr_in6
->
sin6_port
=
htons
(
port
);
addr_in6
->
sin6_flowinfo
=
0
;
memcpy
(
&
addr_in6
->
sin6_addr
,
&
addr6
,
sizeof
(
struct
in6_addr
));
addr_in6
->
sin6_scope_id
=
0
;
addr_storage_len
=
sizeof
(
struct
sockaddr_in6
);
};
uint16_t
port
()
const
{
return
ntohs
(((
struct
sockaddr_in
*
)
&
addr_storage
)
->
sin_port
);
}
sa_family_t
family
()
const
{
return
addr_storage
.
ss_family
;
}
std
::
string
toString
()
const
{
std
::
string
str
;
if
(
addr_storage
.
ss_family
==
AF_INET
)
{
struct
sockaddr_in
*
addr_in
=
(
struct
sockaddr_in
*
)
&
addr_storage
;
str
.
append
(
conv
::
toString
(
addr_in
->
sin_addr
));
str
.
append
(
":"
).
append
(
std
::
to_string
(
ntohs
(
addr_in
->
sin_port
)));
}
else
if
(
addr_storage
.
ss_family
==
AF_INET6
)
{
struct
sockaddr_in6
*
addr_in6
=
(
struct
sockaddr_in6
*
)
&
addr_storage
;
str
.
append
(
conv
::
toString
(
addr_in6
->
sin6_addr
));
str
.
append
(
":"
).
append
(
std
::
to_string
(
ntohs
(
addr_in6
->
sin6_port
)));
}
return
str
;
}
};
#endif
src/common/options.cpp
deleted
100644 → 0
View file @
fb148318
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "options.hpp"
#include <getopt.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
int
Options
::
options
;
std
::
string
Options
::
m_libconfigcfg
;
bool
Options
::
m_log_rot_file_log
;
bool
Options
::
m_log_stdout
;
void
Options
::
help
()
{
std
::
cout
<<
std
::
endl
<<
"Usage: smf [OPTIONS]..."
<<
std
::
endl
<<
" -h, --help Print help and exit"
<<
std
::
endl
<<
" -c, --libconfigcfg filename Read the application "
"configuration from this file."
<<
std
::
endl
<<
" -o, --stdoutlog Send the application logs to "
"STDOUT fd."
<<
std
::
endl
<<
" -r, --rotatelog Send the application logs to "
"local file (in current working directory)."
<<
std
::
endl
;
}
bool
Options
::
parse
(
int
argc
,
char
**
argv
)
{
bool
ret
=
true
;
ret
=
parseInputOptions
(
argc
,
argv
);
ret
&=
validateOptions
();
return
ret
;
}
bool
Options
::
validateOptions
()
{
return
((
options
&
libconfigcfg
));
}
bool
Options
::
parseInputOptions
(
int
argc
,
char
**
argv
)
{
int
c
;
int
option_index
=
0
;
bool
result
=
true
;
struct
option
long_options
[]
=
{
{
"help"
,
no_argument
,
NULL
,
'h'
},
{
"libconfigcfg"
,
required_argument
,
NULL
,
'f'
},
{
"stdoutlog"
,
no_argument
,
NULL
,
'o'
},
{
"rotatelog"
,
no_argument
,
NULL
,
'r'
},
{
NULL
,
0
,
NULL
,
0
}};
// Loop on arguments
while
(
1
)
{
c
=
getopt_long
(
argc
,
argv
,
"horc:"
,
long_options
,
&
option_index
);
if
(
c
==
-
1
)
break
;
// Exit from the loop.
switch
(
c
)
{
case
'h'
:
{
help
();
exit
(
0
);
break
;
}
case
'c'
:
{
m_libconfigcfg
=
optarg
;
options
|=
libconfigcfg
;
break
;
}
case
'o'
:
{
m_log_stdout
=
true
;
options
|=
log_stdout
;
break
;
}
case
'r'
:
{
m_log_rot_file_log
=
true
;
options
|=
log_rot_file_log
;
break
;
}
case
'?'
:
{
switch
(
optopt
)
{
case
'c'
:
{
std
::
cout
<<
"Option -l (libconfig config) requires an argument"
<<
std
::
endl
;
break
;
}
case
'o'
:
{
std
::
cout
<<
"Option -o do not requires an argument, can be also set "
"with option -r."
<<
std
::
endl
;
break
;
}
case
'r'
:
{
std
::
cout
<<
"Option -r do not requires an argument, can be also set "
"with option -o."
<<
std
::
endl
;
break
;
}
default:
{
std
::
cout
<<
"Unrecognized option ["
<<
c
<<
"]"
<<
std
::
endl
;
break
;
}
}
result
=
false
;
break
;
}
default:
{
std
::
cout
<<
"Unrecognized option ["
<<
c
<<
"]"
<<
std
::
endl
;
result
=
false
;
}
}
}
return
result
;
}
src/common/options.hpp
deleted
100644 → 0
View file @
fb148318
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OPTIONS_H
#define __OPTIONS_H
#include <stdint.h>
#include <string>
class
Options
{
public:
static
bool
parse
(
int
argc
,
char
**
argv
);
static
bool
parseInputOptions
(
int
argc
,
char
**
argv
);
static
bool
parseJson
();
static
bool
validateOptions
();
static
const
std
::
string
&
getlibconfigConfig
()
{
return
m_libconfigcfg
;
}
static
const
bool
&
getlogRotFilelog
()
{
return
m_log_rot_file_log
;
}
static
const
bool
&
getlogStdout
()
{
return
m_log_stdout
;
}
private:
enum
OptionsSelected
{
libconfigcfg
=
0x01
,
log_stdout
=
0x02
,
log_rot_file_log
=
0x04
};
static
void
help
();
static
int
options
;
static
bool
m_log_rot_file_log
;
static
bool
m_log_stdout
;
static
std
::
string
m_libconfigcfg
;
};
#endif // #define __OPTIONS_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment