Skip to content

Commit d415daf

Browse files
WXbetatvcaptain
authored andcommitted
[cahandler] Skip CLIENT_INFO on reconnects for legacy softcams (#3700)
CLIENT_INFO was sent on every new connection to .listen.camd.socket, causing repeated "error in capmt length field read 4" in legacy softcam logs and risking disconnect loops with softcams that cannot parse Protocol-3 data. Track handshake state at eDVBCAHandler level: - First connection: send CLIENT_INFO to probe for Protocol-3 - If SERVER_INFO received: mark Protocol-3 established, always send CLIENT_INFO on reconnects - If no SERVER_INFO: legacy client detected, skip CLIENT_INFO on subsequent connections
1 parent e796bbf commit d415daf

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

lib/dvb/cahandler.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ bool ePMTClient::processServerInfoPacket()
210210
eDebug("[ePMTClient] ServerInfo: Protocol %u, Info: %s", serverProtocolVersion, receivedData + fixDataLength);
211211

212212
m_serverInfoReceived = true;
213+
if (parent) parent->m_protocol3_established = true;
213214
if (m_capmt_buffer_len > 0)
214215
{
215216
writeCAPMTObject(m_capmt_buffer, m_capmt_buffer_len);
@@ -345,6 +346,8 @@ eDVBCAHandler::eDVBCAHandler()
345346
: eServerSocket(PMT_SERVER_SOCKET, eApp), serviceLeft(eTimer::create(eApp))
346347
{
347348
serviceIdCounter = 1;
349+
m_protocol3_established = false;
350+
m_handshake_attempted = false;
348351
if (instance == NULL)
349352
{
350353
instance = this;
@@ -378,14 +381,23 @@ void eDVBCAHandler::newConnection(int socket)
378381
ePMTClient *client = new ePMTClient(this, client_fd);
379382
clients.push_back(client);
380383

381-
/* First distribute current CAPMTs in legacy format (works for all clients),
382-
* then send CLIENT_INFO to initiate Protocol-3 handshake.
383-
* - Protocol-3 softcams: receive legacy CAPMTs, then CLIENT_INFO,
384-
* respond with SERVER_INFO -> Protocol 3 for all subsequent CAPMTs.
385-
* - Legacy softcams: receive legacy CAPMTs (works!), then CLIENT_INFO
386-
* causes disconnect, but CAPMTs were already delivered. */
384+
/* Always distribute current CAPMTs first (legacy format, works for all clients) */
387385
distributeCAPMT();
388-
client->sendClientInfo();
386+
387+
/* Send CLIENT_INFO only when appropriate:
388+
* - Protocol-3 already established (OSCam reconnect): always send
389+
* - First connection ever: send to probe for Protocol-3 support
390+
* - Legacy client detected (no SERVER_INFO after first attempt): skip
391+
* to avoid unnecessary errors in legacy softcam logs */
392+
if (m_protocol3_established)
393+
{
394+
client->sendClientInfo();
395+
}
396+
else if (!m_handshake_attempted)
397+
{
398+
client->sendClientInfo();
399+
m_handshake_attempted = true;
400+
}
389401
}
390402

391403
void eDVBCAHandler::connectionLost(ePMTClient *client)

lib/dvb/cahandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ DECLARE_REF(eDVBCAHandler);
176176
std::map<eServiceReferenceDVB, ePtr<eTable<ProgramMapSection> > > pmtCache;
177177
std::map<uint32_t, uint16_t> m_service_caid; // serviceId -> CAID (from softcam ECM_INFO)
178178
uint32_t serviceIdCounter;
179+
bool m_protocol3_established; // SERVER_INFO received from at least one client
180+
bool m_handshake_attempted; // CLIENT_INFO sent at least once
179181

180182
void newConnection(int socket);
181183
void processPMTForService(eDVBCAService *service, eTable<ProgramMapSection> *ptr);

0 commit comments

Comments
 (0)