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
4ec402db
Commit
4ec402db
authored
Jan 24, 2021
by
HFJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logger partially enabled
parent
6c254e70
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
195 additions
and
32 deletions
+195
-32
CMakeLists.txt
CMakeLists.txt
+11
-4
common/comUt.hpp
common/comUt.hpp
+2
-2
common/logger.cpp
common/logger.cpp
+4
-4
common/options.cpp
common/options.cpp
+111
-0
common/options.hpp
common/options.hpp
+54
-0
main-api-server.cpp
main-api-server.cpp
+13
-22
No files found.
CMakeLists.txt
View file @
4ec402db
...
...
@@ -30,8 +30,7 @@ include_directories(5gaka)
include_directories
(
common
)
include_directories
(
libngap
)
##############################################
################### code frrom amf cmakelists###########################
find_package
(
PkgConfig REQUIRED
)
pkg_search_module
(
NETTLE nettle
)
...
...
@@ -63,6 +62,13 @@ add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}")
add_definitions
(
"-DNETTLE_VERSION_MINOR=
${
NETTLE_VERSION_MINOR
}
"
)
##############################################
### for log --- from amf code
add_library
(
LOG STATIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/common/logger.cpp
)
add_library
(
OPTIONS STATIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/common/options.cpp
)
###end for log
file
(
GLOB SRCS
${
CMAKE_CURRENT_SOURCE_DIR
}
/api/*.cpp
...
...
@@ -75,6 +81,7 @@ file(GLOB SRCS
)
add_executable
(
${
PROJECT_NAME
}
${
SRCS
}
)
add_executable
(
${
PROJECT_NAME
}
${
SRCS
}
)
add_dependencies
(
${
PROJECT_NAME
}
PISTACHE NLOHMANN
)
target_link_libraries
(
${
PROJECT_NAME
}
pistache pthread gmp
${
NETTLE_LIBRARIES
}
)
target_link_libraries
(
${
PROJECT_NAME
}
LOG OPTIONS pistache pthread gmp
${
NETTLE_LIBRARIES
}
)
common/comUt.hpp
View file @
4ec402db
#ifndef _PRINT_BUFFER_H
#define _PRINT_BUFFER_H
//
#include "logger.hpp"
#include "logger.hpp"
#include "iostream"
#include <string>
using
namespace
std
;
...
...
@@ -9,7 +9,7 @@ using namespace std;
void
print_buffer
(
const
string
app
,
const
string
commit
,
uint8_t
*
buf
,
int
len
){
if
(
!
app
.
compare
(
"ausf_server"
))
cout
<<
commit
.
c_str
()
<<
endl
;
//
Logger::ausf_server().debug(commit.c_str());
Logger
::
ausf_server
().
debug
(
commit
.
c_str
());
for
(
int
i
=
0
;
i
<
len
;
i
++
)
printf
(
"%x "
,
buf
[
i
]);
...
...
common/logger.cpp
View file @
4ec402db
...
...
@@ -89,22 +89,22 @@ void _Logger::trace( const std::string &format, ... )
void
_Logger
::
debug
(
const
char
*
format
,
...
)
{
#if DEBUG_IS_ON
//
#if DEBUG_IS_ON
va_list
args
;
va_start
(
args
,
format
);
log
(
_ltDebug
,
format
,
args
);
va_end
(
args
);
#endif
//
#endif
}
void
_Logger
::
debug
(
const
std
::
string
&
format
,
...
)
{
#if DEBUG_IS_ON
//
#if DEBUG_IS_ON
va_list
args
;
va_start
(
args
,
format
);
log
(
_ltDebug
,
format
.
c_str
(),
args
);
va_end
(
args
);
#endif
//
#endif
}
void
_Logger
::
info
(
const
char
*
format
,
...
)
...
...
common/options.cpp
0 → 100644
View file @
4ec402db
/*
* 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 <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include "options.hpp"
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
;
}
common/options.hpp
0 → 100644
View file @
4ec402db
/*
* 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
main-api-server.cpp
View file @
4ec402db
...
...
@@ -23,7 +23,11 @@
#include "AuthenticationResultDeletionApiImpl.h"
#include "DefaultApiImpl.h"
#include "authentication_algorithms_with_5gaka.hpp"
#include <iostream>
#include "logger.hpp"
#include "options.hpp"
using
namespace
std
;
#define PISTACHE_SERVER_THREADS 2
...
...
@@ -63,7 +67,7 @@ static void setUpUnixSignals(std::vector<int> quitSignals) {
using
namespace
org
::
openapitools
::
server
::
api
;
int
main
()
{
int
main
(
int
argc
,
char
**
argv
)
{
#ifdef __linux__
std
::
vector
<
int
>
sigs
{
SIGQUIT
,
SIGINT
,
SIGTERM
,
SIGHUP
};
setUpUnixSignals
(
sigs
);
...
...
@@ -80,26 +84,13 @@ int main() {
opts
.
maxResponseSize
(
PISTACHE_SERVER_MAX_RESPONSE_SIZE
);
httpEndpoint
->
init
(
opts
);
uint8_t
opc
[
16
]
=
{
0xcd
,
0x63
,
0xcb
,
0x71
,
0x95
,
0x4a
,
0x9f
,
0x4e
,
0x48
,
0xa5
,
0x99
,
0x4e
,
0x37
,
0xa0
,
0x2b
,
0xaf
};
uint8_t
rand
[
16
]
=
{
0x23
,
0x55
,
0x3c
,
0xbe
,
0x96
,
0x37
,
0xa8
,
0x9d
,
0x21
,
0x8a
,
0xe6
,
0x4d
,
0xae
,
0x47
,
0xbf
,
0x35
};
uint8_t
key
[
16
]
=
{
0x46
,
0x5b
,
0x5c
,
0xe8
,
0xb1
,
0x99
,
0xb4
,
0x9f
,
0xaa
,
0x5f
,
0x0a
,
0x2e
,
0xe2
,
0x38
,
0xa6
,
0xbc
};
uint8_t
sqn
[
6
]
=
{
0xff
,
0x9b
,
0xb4
,
0xd0
,
0xb6
,
0x07
};
uint8_t
amf
[
2
]
=
{
0xb9
,
0xb9
};
uint8_t
mac_a
[
8
],
mac_s
[
8
];
Authentication_5gaka
::
f1
(
opc
,
key
,
rand
,
sqn
,
amf
,
mac_a
);
Authentication_5gaka
::
f1star
(
opc
,
key
,
rand
,
sqn
,
amf
,
mac_s
);
printf
(
"testing f1...
\n
"
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
printf
(
"%x "
,
mac_a
[
i
]);
printf
(
"
\n
"
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
printf
(
"%x "
,
mac_s
[
i
]);
printf
(
"
\n
"
);
//AuthenticationResultDeletionApiImpl AuthenticationResultDeletionApiserver(router);
//AuthenticationResultDeletionApiserver.init();
// DefaultApiImpl DefaultApiserver(router);
// DefaultApiserver.init();
Logger
::
init
(
"ausf"
,
true
,
false
);
Logger
::
ausf_server
().
startup
(
"Entering main..."
);
AuthenticationResultDeletionApiImpl
AuthenticationResultDeletionApiserver
(
router
);
AuthenticationResultDeletionApiserver
.
init
();
DefaultApiImpl
DefaultApiserver
(
router
);
DefaultApiserver
.
init
();
httpEndpoint
->
setHandler
(
router
->
handler
());
httpEndpoint
->
serve
();
...
...
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