mirror of
https://github.com/open5gs/open5gs.git
synced 2026-04-28 11:29:32 +00:00
[SBI,NAS] Fix conversion of bitrate between OpenAPI/NAS and internal representation
From the OpenAPI document,TS29571_CommonData.yaml : BitRate String representing a bit rate; the prefixes follow the standard symbols from The International System of Units, and represent x1000 multipliers, with the exception that prefix "K" is used to represent the standard symbol "k".
This commit is contained in:
parent
2152d67480
commit
bbc397013b
2 changed files with 34 additions and 34 deletions
|
|
@ -516,16 +516,16 @@ char *ogs_sbi_bitrate_to_string(uint64_t bitrate, int unit)
|
|||
{
|
||||
if (unit == OGS_SBI_BITRATE_KBPS) {
|
||||
return ogs_msprintf("%lld Kbps",
|
||||
(long long)bitrate / 1024);
|
||||
(long long)bitrate / 1000);
|
||||
} else if (unit == OGS_SBI_BITRATE_MBPS) {
|
||||
return ogs_msprintf("%lld Mbps",
|
||||
(long long)bitrate / 1024 / 1024);
|
||||
(long long)bitrate / 1000 / 1000);
|
||||
} else if (unit == OGS_SBI_BITRATE_GBPS) {
|
||||
return ogs_msprintf("%lld Gbps",
|
||||
(long long)bitrate / 1024 / 1024 / 1024);
|
||||
(long long)bitrate / 1000 / 1000 / 1000);
|
||||
} else if (unit == OGS_SBI_BITRATE_TBPS) {
|
||||
return ogs_msprintf("%lld Tbps",
|
||||
(long long)bitrate / 1024 / 1024 / 1024 / 1024);
|
||||
(long long)bitrate / 1000 / 1000 / 1000 / 1000);
|
||||
}
|
||||
|
||||
return ogs_msprintf("%lld bps", (long long)bitrate);
|
||||
|
|
@ -547,13 +547,13 @@ uint64_t ogs_sbi_bitrate_from_string(char *str)
|
|||
|
||||
SWITCH(unit+1)
|
||||
CASE("Kbps")
|
||||
return bitrate * 1024;
|
||||
return bitrate * 1000;
|
||||
CASE("Mbps")
|
||||
return bitrate * 1024 * 1024;
|
||||
return bitrate * 1000 * 1000;
|
||||
CASE("Gbps")
|
||||
return bitrate * 1024 * 1024 * 1024;
|
||||
return bitrate * 1000 * 1000 * 1000;
|
||||
CASE("Tbps")
|
||||
return bitrate * 1024 * 1024 * 1024 * 1024;
|
||||
return bitrate * 1000 * 1000 * 1000 * 1000;
|
||||
DEFAULT
|
||||
END
|
||||
return bitrate;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue