Commit eef0e88e authored by aligungr's avatar aligungr

SCTP connection reset handling

parent f92bafb8
......@@ -11,6 +11,7 @@
#include <gnb/gtp/task.hpp>
#include <gnb/rrc/task.hpp>
#include <utils/common.hpp>
#include <utils/random.hpp>
namespace nr::gnb
{
......@@ -18,7 +19,7 @@ namespace nr::gnb
GnbRlsTask::GnbRlsTask(TaskBase *base) : m_base{base}
{
m_logger = m_base->logBase->makeUniqueLogger("rls");
m_sti = utils::Random64();
m_sti = Random::Mixed(base->config->name).nextUL();
m_udpTask = new RlsUdpTask(base, m_sti, base->config->phyLocation);
m_ctlTask = new RlsControlTask(base, m_sti);
......
......@@ -88,6 +88,13 @@ class SctpHandler : public sctp::ISctpHandler
w->clientId = clientId;
sctpTask->push(w);
}
void onConnectionReset() override
{
auto *w = new NmGnbSctp(NmGnbSctp::UNHANDLED_NOTIFICATION);
w->clientId = clientId;
sctpTask->push(w);
}
};
[[noreturn]] static void ReceiverThread(std::pair<sctp::SctpClient *, sctp::ISctpHandler *> *args)
......
......@@ -173,7 +173,15 @@ void ReceiveMessage(int sd, uint32_t ppid, ISctpHandler *handler)
int r = sctp_recvmsg(sd, (void *)buffer, RECEIVE_BUFFER_SIZE, (sockaddr *)&addr, &fromLen, &info, &flags);
if (r < 0)
{
if (errno == ECONNRESET)
{
if (handler)
handler->onConnectionReset();
return;
}
ThrowError("SCTP receive message failure: ", errno);
}
if (r == 0)
return; // no data
......
......@@ -40,6 +40,7 @@ class ISctpHandler
virtual void onAssociationSetup(int associationId, int inStreams, int outStreams) = 0;
virtual void onAssociationShutdown() = 0;
virtual void onConnectionReset() = 0;
virtual void onMessage(const uint8_t *buffer, size_t length, uint16_t stream) = 0;
virtual void onUnhandledNotification() = 0;
};
......
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