Commit 7ff3ec37 authored by aligungr's avatar aligungr

Narrowing conversion fixes

parent d5546ecd
...@@ -243,7 +243,7 @@ GtpMessage *DecodeGtpMessage(const OctetView &stream) ...@@ -243,7 +243,7 @@ GtpMessage *DecodeGtpMessage(const OctetView &stream)
std::unique_ptr<PduSessionInformation> PduSessionInformation::Decode(const OctetView &stream) std::unique_ptr<PduSessionInformation> PduSessionInformation::Decode(const OctetView &stream)
{ {
int startIndex = stream.currentIndex(); size_t startIndex = stream.currentIndex();
uint8_t octet = stream.read(); uint8_t octet = stream.read();
......
...@@ -139,10 +139,10 @@ void GtpTask::handleSessionRelease(int ueId, int psi) ...@@ -139,10 +139,10 @@ void GtpTask::handleSessionRelease(int ueId, int psi)
// Remove all session information from rate limiter // Remove all session information from rate limiter
m_rateLimiter->updateSessionUplinkLimit(sessionInd, 0); m_rateLimiter->updateSessionUplinkLimit(sessionInd, 0);
m_rateLimiter->updateUeDownlinkLimit(sessionInd, 0); m_rateLimiter->updateUeDownlinkLimit(ueId, 0);
// And remove from PDU session table // And remove from PDU session table
int teid = m_pduSessions[sessionInd]->downTunnel.teid; uint32_t teid = m_pduSessions[sessionInd]->downTunnel.teid;
m_pduSessions.erase(sessionInd); m_pduSessions.erase(sessionInd);
// And remove from the tree // And remove from the tree
...@@ -159,10 +159,10 @@ void GtpTask::handleUeContextDelete(int ueId) ...@@ -159,10 +159,10 @@ void GtpTask::handleUeContextDelete(int ueId)
{ {
// Remove all session information from rate limiter // Remove all session information from rate limiter
m_rateLimiter->updateSessionUplinkLimit(session, 0); m_rateLimiter->updateSessionUplinkLimit(session, 0);
m_rateLimiter->updateUeDownlinkLimit(session, 0); m_rateLimiter->updateUeDownlinkLimit(ueId, 0);
// And remove from PDU session table // And remove from PDU session table
int teid = m_pduSessions[session]->downTunnel.teid; uint32_t teid = m_pduSessions[session]->downTunnel.teid;
m_pduSessions.erase(session); m_pduSessions.erase(session);
// And remove from the tree // And remove from the tree
......
...@@ -22,14 +22,14 @@ inline uint64_t MakeSessionResInd(int ueId, int psi) ...@@ -22,14 +22,14 @@ inline uint64_t MakeSessionResInd(int ueId, int psi)
return (static_cast<int64_t>(ueId) << 32LL) | static_cast<int64_t>(psi); return (static_cast<int64_t>(ueId) << 32LL) | static_cast<int64_t>(psi);
} }
inline int GetUeId(int64_t sessionResInd) inline int GetUeId(uint64_t sessionResInd)
{ {
return static_cast<int>((sessionResInd >> 32LL) & 0xFFFFFFFFLL); return static_cast<int>((sessionResInd >> 32uLL) & 0xFFFFFFFFuLL);
} }
inline int GetPsi(int64_t sessionResInd) inline int GetPsi(uint64_t sessionResInd)
{ {
return static_cast<int>(sessionResInd & 0xFFFFFFFFLL); return static_cast<int>(sessionResInd & 0xFFFFFFFFuLL);
} }
class IRateLimiter class IRateLimiter
......
...@@ -57,10 +57,10 @@ void CliServer::sendMessage(const CliMessage &msg) ...@@ -57,10 +57,10 @@ void CliServer::sendMessage(const CliMessage &msg)
stream.appendOctet(cons::Minor); stream.appendOctet(cons::Minor);
stream.appendOctet(cons::Patch); stream.appendOctet(cons::Patch);
stream.appendOctet(static_cast<int>(msg.type)); stream.appendOctet(static_cast<int>(msg.type));
stream.appendOctet4(static_cast<size_t>(msg.nodeName.size())); stream.appendOctet4(static_cast<int>(msg.nodeName.size()));
for (char c : msg.nodeName) for (char c : msg.nodeName)
stream.appendOctet(static_cast<uint8_t>(c)); stream.appendOctet(static_cast<uint8_t>(c));
stream.appendOctet4(static_cast<size_t>(msg.value.size())); stream.appendOctet4(static_cast<int>(msg.value.size()));
for (char c : msg.value) for (char c : msg.value)
stream.appendOctet(static_cast<uint8_t>(c)); stream.appendOctet(static_cast<uint8_t>(c));
......
...@@ -95,6 +95,11 @@ void OctetString::appendOctet4(int v) ...@@ -95,6 +95,11 @@ void OctetString::appendOctet4(int v)
appendOctet4(octet4{v}); appendOctet4(octet4{v});
} }
void OctetString::appendOctet4(uint32_t v)
{
appendOctet4(octet4{v});
}
int OctetString::length() const int OctetString::length() const
{ {
return static_cast<int>(m_data.size()); return static_cast<int>(m_data.size());
......
...@@ -47,6 +47,7 @@ class OctetString ...@@ -47,6 +47,7 @@ class OctetString
void appendOctet3(int v); void appendOctet3(int v);
void appendOctet4(octet4 v); void appendOctet4(octet4 v);
void appendOctet4(int v); void appendOctet4(int v);
void appendOctet4(uint32_t v);
void appendOctet8(octet8 v); void appendOctet8(octet8 v);
void appendOctet8(int64_t v); void appendOctet8(int64_t v);
void appendOctet8(uint64_t v); void appendOctet8(uint64_t v);
......
...@@ -24,6 +24,11 @@ OctetString OctetView::readOctetString(int length) const ...@@ -24,6 +24,11 @@ OctetString OctetView::readOctetString(int length) const
return OctetString(std::move(v)); return OctetString(std::move(v));
} }
OctetString OctetView::readOctetString(size_t length) const
{
return readOctetString(static_cast<int>(length));
}
OctetString OctetView::readOctetString() const OctetString OctetView::readOctetString() const
{ {
return readOctetString(static_cast<int>(size - index)); return readOctetString(static_cast<int>(size - index));
...@@ -35,3 +40,8 @@ std::string OctetView::readUtf8String(int length) const ...@@ -35,3 +40,8 @@ std::string OctetView::readUtf8String(int length) const
index += length; index += length;
return res; return res;
} }
std::string OctetView::readUtf8String(size_t length) const
{
return readUtf8String(static_cast<int>(length));
}
...@@ -124,6 +124,8 @@ class OctetView ...@@ -124,6 +124,8 @@ class OctetView
} }
OctetString readOctetString(int length) const; OctetString readOctetString(int length) const;
OctetString readOctetString(size_t length) const;
OctetString readOctetString() const; OctetString readOctetString() const;
std::string readUtf8String(int length) const; std::string readUtf8String(int length) const;
std::string readUtf8String(size_t length) const;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment