Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
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
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
Libraries
UERANSIM
Commits
4dc22ffc
Commit
4dc22ffc
authored
Feb 14, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSON utility improvement
parent
8c217ae8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
93 additions
and
10 deletions
+93
-10
src/gnb/types.cpp
src/gnb/types.cpp
+23
-1
src/gnb/types.hpp
src/gnb/types.hpp
+1
-0
src/ue/types.cpp
src/ue/types.cpp
+4
-4
src/ue/types.hpp
src/ue/types.hpp
+4
-4
src/utils/common_types.cpp
src/utils/common_types.cpp
+8
-0
src/utils/common_types.hpp
src/utils/common_types.hpp
+1
-0
src/utils/json.hpp
src/utils/json.hpp
+10
-0
src/utils/octet.cpp
src/utils/octet.cpp
+29
-0
src/utils/octet.hpp
src/utils/octet.hpp
+13
-1
No files found.
src/gnb/types.cpp
View file @
4dc22ffc
...
@@ -22,10 +22,15 @@ Json ToJson(const GnbStatusInfo &v)
...
@@ -22,10 +22,15 @@ Json ToJson(const GnbStatusInfo &v)
Json
ToJson
(
const
GnbConfig
&
v
)
Json
ToJson
(
const
GnbConfig
&
v
)
{
{
return
Json
::
Obj
({
return
Json
::
Obj
({
{
"name"
,
v
.
name
},
{
"nci"
,
v
.
nci
},
{
"nci"
,
v
.
nci
},
{
"plmn"
,
ToJson
(
v
.
plmn
)},
{
"plmn"
,
ToJson
(
v
.
plmn
)},
{
"tac"
,
v
.
tac
},
{
"tac"
,
v
.
tac
},
{
"name"
,
v
.
name
},
{
"nssai"
,
ToJson
(
v
.
nssais
)},
{
"ngap-ip"
,
v
.
ngapIp
},
{
"gtp-ip"
,
v
.
gtpIp
},
{
"paging-drx"
,
ToJson
(
v
.
pagingDrx
)},
{
"ignore-sctp-id"
,
v
.
ignoreStreamIds
},
});
});
}
}
...
@@ -54,4 +59,21 @@ Json ToJson(const EAmfState &v)
...
@@ -54,4 +59,21 @@ Json ToJson(const EAmfState &v)
}
}
}
}
Json
ToJson
(
const
EPagingDrx
&
v
)
{
switch
(
v
)
{
case
EPagingDrx
:
:
V32
:
return
"v32"
;
case
EPagingDrx
:
:
V64
:
return
"v64"
;
case
EPagingDrx
:
:
V128
:
return
"v128"
;
case
EPagingDrx
:
:
V256
:
return
"v256"
;
default:
return
"?"
;
}
}
}
// namespace nr::gnb
}
// namespace nr::gnb
src/gnb/types.hpp
View file @
4dc22ffc
...
@@ -302,5 +302,6 @@ Json ToJson(const GnbStatusInfo &v);
...
@@ -302,5 +302,6 @@ Json ToJson(const GnbStatusInfo &v);
Json
ToJson
(
const
GnbConfig
&
v
);
Json
ToJson
(
const
GnbConfig
&
v
);
Json
ToJson
(
const
NgapAmfContext
&
v
);
Json
ToJson
(
const
NgapAmfContext
&
v
);
Json
ToJson
(
const
EAmfState
&
v
);
Json
ToJson
(
const
EAmfState
&
v
);
Json
ToJson
(
const
EPagingDrx
&
v
);
}
// namespace nr::gnb
}
// namespace nr::gnb
\ No newline at end of file
src/ue/types.cpp
View file @
4dc22ffc
...
@@ -22,7 +22,7 @@ UeTimers::UeTimers()
...
@@ -22,7 +22,7 @@ UeTimers::UeTimers()
{
{
}
}
Json
ToJson
(
ECmState
state
)
Json
ToJson
(
const
ECmState
&
state
)
{
{
switch
(
state
)
switch
(
state
)
{
{
...
@@ -35,7 +35,7 @@ Json ToJson(ECmState state)
...
@@ -35,7 +35,7 @@ Json ToJson(ECmState state)
}
}
}
}
Json
ToJson
(
ERmState
state
)
Json
ToJson
(
const
ERmState
&
state
)
{
{
switch
(
state
)
switch
(
state
)
{
{
...
@@ -48,7 +48,7 @@ Json ToJson(ERmState state)
...
@@ -48,7 +48,7 @@ Json ToJson(ERmState state)
}
}
}
}
Json
ToJson
(
EMmState
state
)
Json
ToJson
(
const
EMmState
&
state
)
{
{
switch
(
state
)
switch
(
state
)
{
{
...
@@ -69,7 +69,7 @@ Json ToJson(EMmState state)
...
@@ -69,7 +69,7 @@ Json ToJson(EMmState state)
}
}
}
}
Json
ToJson
(
EMmSubState
state
)
Json
ToJson
(
const
EMmSubState
&
state
)
{
{
switch
(
state
)
switch
(
state
)
{
{
...
...
src/ue/types.hpp
View file @
4dc22ffc
...
@@ -359,9 +359,9 @@ struct UeStatusInfo
...
@@ -359,9 +359,9 @@ struct UeStatusInfo
std
::
optional
<
UePduSessionInfo
>
pduSessions
[
16
]{};
std
::
optional
<
UePduSessionInfo
>
pduSessions
[
16
]{};
};
};
Json
ToJson
(
ECmState
state
);
Json
ToJson
(
const
ECmState
&
state
);
Json
ToJson
(
ERmState
state
);
Json
ToJson
(
const
ERmState
&
state
);
Json
ToJson
(
EMmState
state
);
Json
ToJson
(
const
EMmState
&
state
);
Json
ToJson
(
EMmSubState
state
);
Json
ToJson
(
const
EMmSubState
&
state
);
}
// namespace nr::ue
}
// namespace nr::ue
src/utils/common_types.cpp
View file @
4dc22ffc
...
@@ -37,3 +37,11 @@ Json ToJson(const Plmn &v)
...
@@ -37,3 +37,11 @@ Json ToJson(const Plmn &v)
ss
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
v
.
isLongMnc
?
3
:
2
)
<<
v
.
mnc
;
ss
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
v
.
isLongMnc
?
3
:
2
)
<<
v
.
mnc
;
return
ss
.
str
();
return
ss
.
str
();
}
}
Json
ToJson
(
const
SliceSupport
&
v
)
{
return
Json
::
Obj
({
{
"sst"
,
ToJson
(
v
.
sst
)},
{
"sd"
,
ToJson
(
v
.
sd
)}
});
}
src/utils/common_types.hpp
View file @
4dc22ffc
...
@@ -120,3 +120,4 @@ struct Supi
...
@@ -120,3 +120,4 @@ struct Supi
Json
ToJson
(
const
Supi
&
v
);
Json
ToJson
(
const
Supi
&
v
);
Json
ToJson
(
const
Plmn
&
v
);
Json
ToJson
(
const
Plmn
&
v
);
Json
ToJson
(
const
SliceSupport
&
v
);
src/utils/json.hpp
View file @
4dc22ffc
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <optional>
#include <optional>
#include <string>
#include <string>
#include <utility>
#include <utility>
#include <vector>
class
Json
class
Json
{
{
...
@@ -107,3 +108,12 @@ inline Json ToJson(const std::optional<T> &v)
...
@@ -107,3 +108,12 @@ inline Json ToJson(const std::optional<T> &v)
{
{
return
v
.
has_value
()
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
return
v
.
has_value
()
?
ToJson
(
*
v
)
:
Json
{
nullptr
};
}
}
template
<
typename
T
>
inline
Json
ToJson
(
const
std
::
vector
<
T
>
&
v
)
{
Json
j
=
Json
::
Arr
({});
for
(
auto
&
item
:
v
)
j
.
push
(
ToJson
(
item
));
return
j
;
}
src/utils/octet.cpp
View file @
4dc22ffc
...
@@ -7,3 +7,32 @@
...
@@ -7,3 +7,32 @@
//
//
#include "octet.hpp"
#include "octet.hpp"
#include "common.hpp"
#include <sstream>
Json
ToJson
(
const
octet
&
v
)
{
return
"0x"
+
utils
::
IntToHex
((
uint8_t
)
v
);
}
Json
ToJson
(
const
octet2
&
v
)
{
return
"0x"
+
utils
::
IntToHex
((
uint16_t
)
v
);
}
Json
ToJson
(
const
octet3
&
v
)
{
std
::
stringstream
stream
;
stream
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
6
)
<<
std
::
hex
<<
(
uint32_t
)
v
;
return
"0x"
+
stream
.
str
();
}
Json
ToJson
(
const
octet4
&
v
)
{
return
"0x"
+
utils
::
IntToHex
((
uint32_t
)
v
);
}
Json
ToJson
(
const
octet8
&
v
)
{
return
"0x"
+
utils
::
IntToHex
((
uint64_t
)
v
);
}
\ No newline at end of file
src/utils/octet.hpp
View file @
4dc22ffc
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#pragma once
#pragma once
#include "json.hpp"
#include <bitset>
#include <bitset>
#include <cassert>
#include <cassert>
#include <cstdint>
#include <cstdint>
...
@@ -133,6 +134,11 @@ struct octet3
...
@@ -133,6 +134,11 @@ struct octet3
{
{
return
static_cast
<
int32_t
>
(
value
);
return
static_cast
<
int32_t
>
(
value
);
}
}
explicit
constexpr
operator
uint32_t
()
const
{
return
value
;
}
};
};
struct
octet4
struct
octet4
...
@@ -218,4 +224,10 @@ struct octet8
...
@@ -218,4 +224,10 @@ struct octet8
{
{
return
value
;
return
value
;
}
}
};
};
\ No newline at end of file
Json
ToJson
(
const
octet
&
v
);
Json
ToJson
(
const
octet2
&
v
);
Json
ToJson
(
const
octet3
&
v
);
Json
ToJson
(
const
octet4
&
v
);
Json
ToJson
(
const
octet8
&
v
);
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