Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: 1.6.0 #3141

Open
wants to merge 236 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
236 commits
Select commit Hold shift + click to select a range
20043be
[core] Fixed a bug that responded a repeated conclusion HS with rejec…
Nov 9, 2020
b39fea8
Merge branch 'master' into dev-fix-repeated-hs
Nov 24, 2020
7126842
Minor comment update
Nov 24, 2020
6226f35
Fixed proper crafting of the repeated handshake response
Nov 24, 2020
f68578d
Completed doxygen changes
Nov 27, 2020
8e8cdac
Prepared changes for dispatch-to-acceptor (no build)
Nov 30, 2020
bf0cee8
Merge branch 'dev-fix-repeated-hs' into dev-fix-connection-dispatch-t…
Nov 30, 2020
84e37b6
Added crafting KMX response to call handshake
Nov 30, 2020
082734c
Merge branch 'master' into dev-fix-connection-dispatch-to-accepted
Dec 2, 2020
80a4cbf
Fixed HS ext for HSv5. Blocked testing stuff
Dec 2, 2020
12b7455
Fixed: rewritten negotiated values into the handshake and properly sent
Dec 3, 2020
50a0456
Updated and merged
Dec 3, 2020
6e2a193
Merge branch 'master' into dev-fix-connection-dispatch-to-accepted
Dec 3, 2020
f7950c5
Merged. Fixed saving permanent value for repeating needs
Dec 3, 2020
bb7b41c
Removed testing entry
Dec 3, 2020
abfbf44
Fixed: do not try accepted socket if wrong address
Dec 3, 2020
3f6e6ac
[core] Fixed: closing socket should mark and signal so that srt_conne…
Jun 1, 2021
7164030
Fixed problem: test if socket is in this blocking-connecting state be…
Jun 2, 2021
cdca85d
Added UT for the closing case
Jun 2, 2021
7923aae
Added a UT that confirms the bug. Added an option setter utility.
Aug 25, 2022
6cf64f5
Fixed clang errors. Added compiler flags to configure to prevent chan…
Aug 25, 2022
068e8a9
Added checking of accept candidates. In-group check disabled and left…
Aug 26, 2022
496e6a7
Exported fragment to a separate function
Sep 22, 2022
03214ff
Applied changes from PR 2467-before merging
Sep 30, 2022
96e92dd
Adjusted to the latest changes in the group branch, per changes in ma…
Oct 25, 2022
bdc6fff
Updated and post-fixed
Oct 25, 2022
a68d5cf
Updated for latest master
Oct 26, 2022
d2d1c90
Merge branch 'master' into dev-processdata-refax
Oct 26, 2022
89e927f
Added lacking fix for AEAD
Oct 26, 2022
a56c84d
Fixed: block static variable that might be unused when no logging (tr…
Oct 27, 2022
0168c5e
Fixed after PR comments
Nov 1, 2022
870509f
Renamed getPacketPTS. Moved call to obtain PTS under belated condition
Nov 3, 2022
9f5174c
Merge branch 'dev-processdata-refax' into dev-refax-buffer-tsbpd-trig…
Nov 7, 2022
652e35d
Applied changes for improved TSBPD and receiver buffer
Nov 7, 2022
6295cb9
Updated and fixed
Nov 8, 2022
36c1f67
Updated usage of shortcuts and new names
Nov 8, 2022
1fbd754
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Nov 9, 2022
478ca41
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Nov 10, 2022
8335cbe
Fixed some logs formatting
ethouris Nov 10, 2022
df46c57
Updated to latest upstream
Nov 23, 2022
1df7e40
Updated and fixed
Dec 6, 2022
2424c99
Fixing implicit integer and wrong use of SRT_ERROR and SRT_INVALID_SO…
Dec 22, 2022
6ad1041
[MAINT] Fixed example buildbreaks. Added examples for message mode tr…
ethouris Dec 22, 2022
340f0b5
Updated
ethouris Dec 22, 2022
29e8c19
Fixed wrong assertion for drop snd buf sequence check
Dec 23, 2022
31b3a78
Updated
Dec 23, 2022
ce98b8a
[MAINT] Refax for CSndBuffer::readData to make the call form clearer
Dec 23, 2022
333eaf2
[MAINT] Removed reference fields from CPacket pinned to the SRT header
Dec 23, 2022
43c0883
Updated and fixed
Dec 23, 2022
6e2280d
Updated with the fixes
Dec 23, 2022
0b515e8
Updated
Dec 23, 2022
124ec2b
[BUG] Fixed default reject reason for a listener callback
ethouris Jan 9, 2023
f14c349
Added extended reject reason string API
Jan 9, 2023
09d480d
Fixed testing app to set unauthorized rejection code for a better exa…
ethouris Jan 9, 2023
512e548
Merge branch 'master' into dev-fix-implicit-int
Jan 11, 2023
08d1e5c
Minor fixes
Jan 11, 2023
4888873
Merge branch 'master' into dev-refax-readdata-rexmit
Jan 11, 2023
b92e259
Merge branch 'master' into dev-add-rejectreasonx-str
ethouris Jan 12, 2023
dba39ef
Merge branch 'master' into dev-refax-readdata-rexmit
Jan 24, 2023
addefb3
Merge branch 'master' into dev-fix-implicit-int
Jan 25, 2023
03c19ac
Merge branch 'master' into dev-refax-readdata-rexmit
Feb 20, 2023
b0e681f
Updated and fixed
Feb 20, 2023
f636ce7
Updated and fixed
Feb 22, 2023
b53a091
[FIX] Calculate correctly max payload size per UDP packet
Mar 1, 2023
a8b9104
Applied verification of the payload size fit. Added tests. Updated do…
Mar 3, 2023
56fdfdb
Withdrawn quotes for option names
Mar 3, 2023
d7f32d0
Fixed links in the socket option table
Mar 3, 2023
70de763
Fixed minimum MSS to 116. Fixed some other bux
Mar 6, 2023
2eb1159
Replaced rand_r with std c++ random
Mar 6, 2023
9f48d3c
Fixed usage of C++14 literals in the test (build failures)
Mar 6, 2023
edbb608
[MAINT] Upgraded CI: ubuntu to version 20.04
Mar 6, 2023
26a7be6
Fixed test logics (printing after closing)
Mar 6, 2023
3d387a2
Attempted fix for a deadlock in test, added some tracking
Mar 6, 2023
03717f3
Merge branch 'dev-upgrade-ci-ubuntu' into dev-fix-ipv6-payloadsize
Mar 6, 2023
3eef592
Added expect and tracking to close socket in ReuseAddr test (Travis p…
Mar 6, 2023
e2ab5f6
Used relaxed signaling for the sake of Travis
Mar 6, 2023
d081e50
Lock debug fix for tests
ethouris Mar 7, 2023
ba5f962
Added timeout for lock-CV to avoid Travis problem
ethouris Mar 7, 2023
320a79b
Attempted more debug for test ipv6 for Travis
ethouris Mar 7, 2023
1b3ccd7
More debug for Travis
ethouris Mar 7, 2023
90b13b1
Fixed test ipv6 to use promise-future for synchronization
Mar 7, 2023
bc4059c
Fixed filtering-out IPv6 tests for Travis
Mar 7, 2023
11574a0
Fixed wrong comment
Mar 9, 2023
fabb85f
Updated with upstream and fixed
Apr 28, 2023
3781775
Merge branch 'master' into dev-refax-readdata-rexmit
May 4, 2023
d126e64
Merge branch 'master' into dev-refax-remove-cpacket-refs
May 8, 2023
380e12f
Updated to latest upstream through #2594
May 8, 2023
88b9f33
Fixed build break on Android
May 10, 2023
397dc7c
[core] Fixed overrideSndSeqNo() not clear buffer.
gou4shi1 Jun 15, 2023
7cc801f
Updated and fixed
Sep 8, 2023
7658145
Fixed a bug introduced during upstream merge
Sep 11, 2023
41a86bf
Fixed tests that should require IPv6 enabled
Sep 11, 2023
084c9c5
Merge branch 'master' into dev-refax-remove-cpacket-refs
Sep 14, 2023
185276c
Merged and fixed
Sep 14, 2023
45809bd
Pre-refax of change-independent parts for 2677
Sep 18, 2023
c782bf7
Merge branch 'dev-fix-ipv6-payloadsize-prefax' into dev-fix-ipv6-payl…
Sep 18, 2023
848857b
Merge branch 'master' into dev-fix-ipv6-payloadsize
Sep 18, 2023
0c3abe0
A fix from code review
Sep 18, 2023
ce2a043
Apply SOME suggestions from the doc review (others pending)
ethouris Sep 19, 2023
ae914e5
Merged and stabilized
Sep 19, 2023
519cb7e
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Sep 19, 2023
4bb7b47
Added mutex spec to a function
Sep 19, 2023
ccfb0b6
Updated and fixed
Sep 19, 2023
d179878
Added more thread check entries
Sep 19, 2023
422cbed
Merge branch 'master' into dev-fix-ipv6-payloadsize
Sep 19, 2023
fa40417
Some more explanatory comments to enforce checkin
Sep 19, 2023
5c2c876
Apply suggestions from doc review (still pending)
ethouris Sep 19, 2023
0403820
Update doc review (still pending)
ethouris Sep 19, 2023
e02d85a
Apply suggestions from doc review (complete)
ethouris Sep 19, 2023
6074f21
Added extra v6-to-v6 test to check correct payload size
Oct 2, 2023
200e3c5
Updated and fixed
Oct 9, 2023
1ffde27
Merge branch 'master' into dev-refax-readdata-rexmit
Oct 10, 2023
58fbf27
Updated and fixed
Oct 10, 2023
a0de6ff
Merge branch 'dev-refax-remove-cpacket-refs' into dev-fix-implicit-int
Oct 10, 2023
920969b
Synchronized and improved
Oct 10, 2023
7a4e00c
Fixed clang warnings (build break on some CI)
Oct 10, 2023
a1c4e70
Merge branch 'master' into dev-epoll-listener-init
Oct 10, 2023
6827df7
Added tests for more cases and fixed remaining failures. STILL mutex …
Oct 11, 2023
039291c
Fixed the problem with locking
Oct 11, 2023
bd9c4de
Fixed a problem: invalid per-listener report of member connections. A…
Oct 13, 2023
8d3c5ca
Updated documentation
Oct 13, 2023
ab96b4d
Weird warning/error on Mac
Oct 13, 2023
9b93a3a
Some cosmetic fixes. Fixes for CI build breaks
Oct 16, 2023
33de3eb
Fixed rejection code naming
Oct 16, 2023
6eafd0f
Updated
Oct 16, 2023
dc7f437
Added an API function to control the payload size
Oct 17, 2023
49346a2
Removed BytesPacketsCount. Shifted header size to a function parameter
Oct 18, 2023
7644107
Updated
Oct 18, 2023
f34776d
Remaining bugfix
Oct 19, 2023
e1262cc
Added documentation for srt_getmaxpayloadsize
Oct 19, 2023
f91f75a
Added group contents check and configurable sleep for group/listener …
Oct 30, 2023
8072420
Fixed warn-error build break on mac
Oct 30, 2023
188cbd1
Fixed build break on more pedantic compilers
Oct 30, 2023
cf3850c
Updated and postfixed
Jan 19, 2024
122d8a2
Merge branch 'master' into dev-epoll-listener-init
Jan 23, 2024
e8cd37d
Further fixes for OptionProxy. Some cosmetics in the docs
Jan 23, 2024
94fb676
Updated to latest upstream
Feb 15, 2024
8ad69ed
Fixed a suggested uninitialized variable
Feb 15, 2024
bbced79
Renamed eclipsed variable
Feb 16, 2024
5136ca2
Added doxy description for some functions. Applied NonOrder in names …
Feb 16, 2024
f6e0271
Removed wrong fix. Fixed C++11 style initialization of PacketInfo
Feb 16, 2024
072a8c4
Refax: CRcvBuffer extracted some parts of insert() to separate functions
Feb 16, 2024
8c0102a
Updated and fixed
Feb 19, 2024
d28e3b2
Introduced SRTRUNSTATUS to cover all cases of srt_startup(). Fixed do…
Feb 19, 2024
be302ca
Removed srt::isgroup. Reused CUDT::isgroup where applicable. Added mi…
Feb 20, 2024
1830e3a
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Feb 22, 2024
283021e
Apply suggestions from code review
ethouris Feb 28, 2024
b969a83
Remaining post-review fixes
Feb 28, 2024
df237d6
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Feb 29, 2024
6ebf94f
Withdrawn changes from #2858 as they break ABI compat
Mar 5, 2024
3601861
[core] Restored logger perf improvements that were blocked up to 1.6.0
Mar 5, 2024
d8f485a
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Mar 11, 2024
d9f079a
Turned integer-based values to strong types. CHECKPOINT: tests passed
Jun 3, 2024
ab469d6
Fixed previous problems with receiver buffer
Jun 10, 2024
a2b1b44
First working version with end/drop as offset
ethouris Jun 17, 2024
ff16e68
Blocked development support types and fixed the test
Jun 17, 2024
1f6ac3d
Updated to latest upstream
Jun 18, 2024
fa70fda
Merged changes
Jun 18, 2024
1bf93ff
Cleanup of the commented-out code
Jun 18, 2024
f4f22ba
Cleaning up other temporary development entries
Jun 18, 2024
9967d1d
Fixed the old test. Added one more test to close during connection
Jun 25, 2024
0a88fdf
Updated and fixed
Aug 14, 2024
db0d8a1
[core] Average values for sent/recv bitrate are now over last second.
npanhaleux Aug 19, 2024
5e98108
Auto stash before merge of "NPA" and "origin/NPA"
npanhaleux Aug 19, 2024
78b3412
[core] Adding packet header size in average measure
npanhaleux Aug 19, 2024
cd42a9b
[core] Fixing auto merge removed methode
npanhaleux Aug 19, 2024
ba41815
[core] Refactoring pull request
npanhaleux Aug 22, 2024
768db18
[core] Compiler warning fix
npanhaleux Aug 22, 2024
1d3e608
[core] Removing inheritance and fixing issue in rate compute
npanhaleux Aug 22, 2024
a3c8a82
[core] Changing stats var name
npanhaleux Aug 22, 2024
0eb1cf7
[core] Restoring CSndRateEstimator
npanhaleux Aug 22, 2024
85161cf
[core] Refactoring rate compute and variables name
npanhaleux Aug 26, 2024
ba78d54
Merge branch 'master' into dev-fix-2029
Aug 26, 2024
1fb7fab
[core] Fixing division by 0.
npanhaleux Aug 26, 2024
a46819b
[core] Removing unused variable (copy/paste from mother class)
npanhaleux Aug 26, 2024
cb44223
[core] Removing unused variable from c file too...
npanhaleux Aug 26, 2024
50da652
Fixed unnecessary condition. Added more atomics (data race fix)
Aug 26, 2024
0d78572
Fixes for atomic field
Aug 26, 2024
74a27ed
Updated and fixed
Aug 29, 2024
7aa87a5
Merge branch 'master' into dev-restore-logger-changes
Sep 2, 2024
fc9482b
Really restored changes
Sep 2, 2024
cb00cce
Added option to disable test discovery (off by default)
Sep 3, 2024
5bc71e9
BUGFIX: the buffer info extraction function wasn't mutex-protected
Sep 4, 2024
d1e2540
Updated and fixed
Sep 6, 2024
f26a087
Updated and fixed
Sep 6, 2024
291c6c2
Updated and fixed
Sep 9, 2024
97c96fa
Merge branch 'master' into dev-epoll-listener-init
Sep 10, 2024
90c2888
Updated. Added new test from #1891. Added doc info
Sep 10, 2024
a516140
Fixed right types for EXPECT_EQ calls in new tests
Sep 10, 2024
461def5
Added setting UPDATE event on group on new connection. Fixed test wit…
Sep 11, 2024
c18940b
Updated and fixed
Sep 24, 2024
51b2555
Fixed build break in log
Sep 24, 2024
739adf0
Changed blocked test code to conditionally-enabled
Sep 25, 2024
3376247
Updated and fixed
Sep 27, 2024
1e57db3
[BUG] Fixed desynch between deleted socket and unsubscribing from epo…
Dec 18, 2024
6bbd31d
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Dec 18, 2024
5cba144
Reworked attributes. Put inc() method of CSeqNo in use for clarity
Dec 19, 2024
89d008a
[API] Set up length limits for STREAMID and PACKETFILTER in the API
Jan 9, 2025
90b1876
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Mar 3, 2025
9c11019
Cosmetics. Added MSVC version of [[nodiscard]].
Mar 4, 2025
04e6e49
[MAINT] Added optional test discovery. Added improvements for attributes
Mar 4, 2025
7ed0cdb
Updated to latest upstream
Mar 11, 2025
f15beec
Updated to latest upstream
Mar 11, 2025
6875d7f
Merge branch 'master' into dev-restore-logger-changes
Mar 12, 2025
9982596
Merge branch 'master' into dev-add-rejectreasonx-str
Mar 12, 2025
e5c9b20
Merge branch 'master' into overrideSndSeqNo
ethouris Mar 12, 2025
1fe9a3f
Updated to latest upstream
Mar 12, 2025
f7e2706
Merge branch 'master' into dev-fix-2029
Mar 12, 2025
da0d2df
Minimized changes. Fixed incorrect test initialization
Mar 12, 2025
c8800a4
Fixed pedantic C++
Mar 12, 2025
ed4b6cf
Fixed pedantic C++ v2
Mar 12, 2025
e50864b
Merge branch 'master' into dev-fix-connection-dispatch-to-accepted
Mar 12, 2025
8cfd3de
Fixed pedantic error in a test
Mar 13, 2025
67ad151
Again
Mar 13, 2025
9190f11
Wrong fix
Mar 13, 2025
9e16dfc
Merge branch 'dev-fix-ipv6-payloadsize' into development
Mar 13, 2025
31b9a78
Fixed after merge dev-fix-implicit-int
Mar 13, 2025
f333e19
Merge branch 'dev-restore-logger-changes' into development
Mar 13, 2025
136ff1e
Fixed after merging dev-add-rejectreasonx-str
Mar 13, 2025
dbf9b1d
Merge branch 'dev-refax-buffer-tsbpd-triggers' into development
Mar 13, 2025
6b966f7
Fixed after merge dev-epoll-listener-init
Mar 13, 2025
bbd6dc3
Merge remote-tracking branch 'remotes/gou4shi1/overrideSndSeqNo' into…
Mar 13, 2025
ae19cbf
Merge remote-tracking branch 'npa/NPA' into development
Mar 13, 2025
f4613ab
Fixed after merge: dev-fix-connection-dispatch-to-accepted
Mar 13, 2025
f2fd31b
Fixed after merge dev-fix-unsubscribed-epoll
Mar 13, 2025
0179dc6
Merge branch 'dev-make-sid-len-in-api' into development
Mar 13, 2025
db5e967
Fixed after merge dev-update-build-and-attr
Mar 13, 2025
d8debf2
Removed unreachable code
Mar 13, 2025
2be1f03
Merge branch 'dev-fix-implicit-int' into development
Mar 13, 2025
5518f1d
Updated from master and fixed
Mar 14, 2025
79cd032
TESTING CI: ABI Checks with displayable HTML
Mar 14, 2025
912125e
Moved accept wait before epoll in ConnectNonBlocking
Mar 14, 2025
205bc94
Withdrawn HTML preview for ABI (doesn't work)
Mar 14, 2025
e017b14
TEST: Check if ConnectNonBlocking can prevent connection by delaying …
Mar 14, 2025
8fc42a6
Merged and fixed dev-fix-2980
Mar 14, 2025
0edccb3
Changed paths to checked code by Sonar
Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prepared changes for dispatch-to-acceptor (no build)
Mikołaj Małecki committed Nov 30, 2020
commit 8e8cdac4ac73d5f066405b052bcf6f56471e7160
17 changes: 13 additions & 4 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
@@ -5997,6 +5997,14 @@ void CUDT::acceptAndRespond(const sockaddr_any& agent, const sockaddr_any& peer,
m_pRNode->m_bOnList = true;
m_pRcvQueue->setNewEntry(this);

if (!createSendHSResponse(kmdata, kmdatasize, peer, (w_hs)))
{
throw CUDTException(MJ_SETUP, MN_REJECTED, 0);
}
}

bool CUDT::createSendHSResponse(uint32_t* kmdata, size_t kmdatasize, const sockaddr_any& peer, CHandShake& w_hs) ATR_NOTHROW
{
// send the response to the peer, see listen() for more discussions about this
// XXX Here create CONCLUSION RESPONSE with:
// - just the UDT handshake, if HS_VERSION_UDT4,
@@ -6010,11 +6018,11 @@ void CUDT::acceptAndRespond(const sockaddr_any& agent, const sockaddr_any& peer,

// This will serialize the handshake according to its current form.
HLOGC(cnlog.Debug,
log << "acceptAndRespond: creating CONCLUSION response (HSv5: with HSRSP/KMRSP) buffer size=" << size);
log << "createSendHSResponse: creating CONCLUSION response (HSv5: with HSRSP/KMRSP) buffer size=" << size);
if (!createSrtHandshake(SRT_CMD_HSRSP, SRT_CMD_KMRSP, kmdata, kmdatasize, (response), (w_hs)))
{
LOGC(cnlog.Error, log << "acceptAndRespond: error creating handshake response");
throw CUDTException(MJ_SETUP, MN_REJECTED, 0);
LOGC(cnlog.Error, log << "createSendHSResponse: error creating handshake response");
return false;
}

// Set target socket ID to the value from received handshake's source ID.
@@ -6027,7 +6035,7 @@ void CUDT::acceptAndRespond(const sockaddr_any& agent, const sockaddr_any& peer,
CHandShake debughs;
debughs.load_from(response.m_pcData, response.getLength());
HLOGC(cnlog.Debug,
log << CONID() << "acceptAndRespond: sending HS from agent @"
log << CONID() << "createSendHSResponse: sending HS from agent @"
<< debughs.m_iID << " to peer @" << response.m_iID
<< "HS:" << debughs.show());
}
@@ -6039,6 +6047,7 @@ void CUDT::acceptAndRespond(const sockaddr_any& agent, const sockaddr_any& peer,
// coming as connected, but continue repeated handshake until finally
// received the listener's handshake.
m_pSndQueue->sendto(peer, response);
return true;
}

// This function is required to be called when a caller receives an INDUCTION
2 changes: 2 additions & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
@@ -365,6 +365,7 @@ class CUDT
}

SRTSOCKET socketID() const { return m_SocketID; }
SRTSOCKET peerID() const { return m_PeerID; }

static CUDT* getUDTHandle(SRTSOCKET u);
static std::vector<SRTSOCKET> existingSockets();
@@ -599,6 +600,7 @@ class CUDT
/// @param hs [in/out] The handshake information sent by the peer side (in), negotiated value (out).

void acceptAndRespond(const sockaddr_any& agent, const sockaddr_any& peer, const CPacket& hspkt, CHandShake& hs);
bool createSendHSResponse(uint32_t* kmdata, size_t kmdatasize, const sockaddr_any& peer, CHandShake& w_hs) ATR_NOTHROW;
bool runAcceptHook(CUDT* acore, const sockaddr* peer, const CHandShake& hs, const CPacket& hspkt);

/// Close the opened UDT entity.
45 changes: 45 additions & 0 deletions srtcore/queue.cpp
Original file line number Diff line number Diff line change
@@ -773,16 +773,27 @@ CUDT *CHash::lookup(int32_t id)
return NULL;
}

CUDT* CHash::lookupPeer(int32_t peerid)
{
// Decode back the socket ID if it has that peer
int32_t id = map_get(m_RevPeerMap, peerid, -1);
if (id == -1)
return NULL; // no such peer id
return lookup(id);
}

void CHash::insert(int32_t id, CUDT *u)
{
CBucket *b = m_pBucket[id % m_iHashSize];

CBucket *n = new CBucket;
n->m_iID = id;
n->m_iPeerID = u->peerID();
n->m_pUDT = u;
n->m_pNext = b;

m_pBucket[id % m_iHashSize] = n;
m_RevPeerMap[u->peerID()] = id;
}

void CHash::remove(int32_t id)
@@ -799,6 +810,7 @@ void CHash::remove(int32_t id)
else
p->m_pNext = b->m_pNext;

m_RevPeerMap.erase(b->m_iPeerID);
delete b;

return;
@@ -1402,11 +1414,44 @@ EConnectStatus CRcvQueue::worker_ProcessConnectionRequest(CUnit* unit, const soc
<< " result:" << RequestTypeStr(UDTRequestType(listener_ret)));
return listener_ret == SRT_REJ_UNKNOWN ? CONN_CONTINUE : CONN_REJECT;
}
else
{
if (worker_TryAcceptedSocket(unit, addr))
return CONN_CONTINUE;
}

// If there's no listener waiting for the packet, just store it into the queue.
return worker_TryAsyncRend_OrStore(0, unit, addr); // 0 id because the packet came in with that very ID.
}

bool CRcvQueue::worker_TryAcceptedSocket(CUnit* unit, const sockaddr_any& addr)
{
// We are working with a possibly HS packet... check that.
CPacket& pkt = unit->m_Packet;

if (pkt.getLength() < CHandShake::m_iContentSize || !pkt.isControl(UMSG_HANDSHAKE))
return false;

CHandShake hs;
if (0 != hs.load_from(pkt.data(), pkt.size()))
return false;

if (hs.m_iReqType != URQ_CONCLUSION)
return false;

// Ok, at last we have a peer ID info
int32_t peerid = hs.m_iID;

// Now search for a socket that has this peer ID
CUDT* u = m_pHash->lookupPeer(peerid);
if (!u)
return false; // no socket has that peer in this multiplexer

// CRAFT KMX DATA FOR RESPONSE

return u->createSendHSResponse(kmdata, kmdatasize, (hs));
}

EConnectStatus CRcvQueue::worker_ProcessAddressedPacket(int32_t id, CUnit* unit, const sockaddr_any& addr)
{
CUDT *u = m_pHash->lookup(id);
10 changes: 10 additions & 0 deletions srtcore/queue.h
Original file line number Diff line number Diff line change
@@ -292,6 +292,12 @@ class CHash

CUDT* lookup(int32_t id);

/// Look for a UDT instance from the hash table by source ID
/// @param [in] peerid socket ID of the peer reported as source ID
/// @return Pointer to a UDT instance where m_PeerID == peerid, or NULL if not found

CUDT* lookupPeer(int32_t peerid);

/// Insert an entry to the hash table.
/// @param [in] id socket ID
/// @param [in] u pointer to the UDT instance
@@ -307,13 +313,16 @@ class CHash
struct CBucket
{
int32_t m_iID; // Socket ID
int32_t m_iPeerID; // Peer ID
CUDT* m_pUDT; // Socket instance

CBucket* m_pNext; // next bucket
} **m_pBucket; // list of buckets (the hash table)

int m_iHashSize; // size of hash table

std::map<int32_t, int32_t> m_RevPeerMap;

private:
CHash(const CHash&);
CHash& operator=(const CHash&);
@@ -489,6 +498,7 @@ friend class CUDTUnited;
EConnectStatus worker_ProcessConnectionRequest(CUnit* unit, const sockaddr_any& sa);
EConnectStatus worker_TryAsyncRend_OrStore(int32_t id, CUnit* unit, const sockaddr_any& sa);
EConnectStatus worker_ProcessAddressedPacket(int32_t id, CUnit* unit, const sockaddr_any& sa);
bool worker_TryAcceptedSocket(CUnit* unit, const sockaddr_any& addr);

private:
CUnitQueue m_UnitQueue; // The received packet queue