-
Notifications
You must be signed in to change notification settings - Fork 14
/
MatterMessageTracker.h
74 lines (61 loc) · 3.14 KB
/
MatterMessageTracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 2023 Project CHIP Authors.
*
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file or at
* https://opensource.org/license/bsd-3-clause
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MATTERMESSAGETRACKER_H_
#define MATTERMESSAGETRACKER_H_
class CASEExchangeRecord;
class MatterMessageRecord
{
public:
uint32_t frameNum;
uint32_t fingerprint;
uint64_t imSubscription;
MatterMessageRecord *ackedByMsgRec;
MatterMessageRecord *nextByMsgCntr;
MatterMessageRecord *prevByMsgCntr;
MatterMessageRecord *nextByExchange;
MatterMessageRecord *prevByExchange;
CASEExchangeRecord *caseExchangeRec;
};
class MatterMessageTracker
{
public:
static MatterMessageRecord *FindMessageRecord(packet_info *pinfo);
static MatterMessageRecord *FindOrCreateMessageRecord(tvbuff_t *tvb, packet_info *pinfo, MatterMessageInfo& msgInfo);
static void FindRetransmissions(packet_info *pinfo, MatterMessageRecord *msgRec, MatterMessageInfo& msgInfo);
static void FindReusedMessageIds(packet_info *pinfo, MatterMessageRecord *msgRec, MatterMessageInfo& msgInfo);
static void FindAckedMessages(packet_info *pinfo, MatterMessageRecord *msgRec, MatterMessageInfo& msgInfo);
static MatterMessageRecord *FindStartOfExchange(MatterMessageRecord *msgRec);
private:
static wmem_tree_t *gMessageIdTable_UnencryptedUDP;
static wmem_tree_t *gMessageIdTable_SessionEncryptedUDP;
static wmem_tree_t *gMessageIdTable_GroupEncryptedUDP;
static wmem_tree_t *gMessageIdTable_UnencryptedTCP;
static wmem_tree_t *gMessageIdTable_SessionEncryptedTCP;
static wmem_tree_t *gMessageIdTable_GroupEncryptedTCP;
static wmem_tree_t *gExchangeTable;
MatterMessageTracker(); // Not defined
~MatterMessageTracker(); // Not defined
static void InitTables();
static MatterMessageRecord *GetMessagesByMessageId(uint64_t srcNodeId, uint32_t msgId,
uint8_t msgEncType, uint32_t msgSessionId,
bool isTCP, uint32_t tcpStreamId);
static void AddMessageToMessageIdTable(uint64_t srcNodeId, uint32_t msgId,
uint8_t msgEncType, uint32_t msgSessionId,
bool isTCP, uint32_t tcpStreamId,
MatterMessageRecord *msgRec);
static MatterMessageRecord *GetMessagesByExchange(uint64_t initiatorNodeId, uint64_t respNodeId, uint32_t exchangeId);
static void AddMessageToExchangeTable(uint64_t initiatorNodeId, uint64_t respNodeId, uint32_t exchangeId, MatterMessageRecord *msgRec);
static void GetMessageIdTableAndKey(uint64_t& srcNodeId, uint32_t& msgId,
uint8_t msgEncType, uint32_t& msgSessionId,
bool isTCP, uint32_t& tcpStreamId,
wmem_tree_t *& msgIdTable, wmem_tree_key_t msgIdKey[5]);
static uint32_t ComputeMessageFingerprint(tvbuff_t* tvb, MatterMessageInfo& msgInfo);
};
#endif /* MATTERMESSAGETRACKER_H_ */