blob: 29d5d2d63059f1928083aa40c43d0dd7fcfa541d (
plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
* Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
/*
* @file thread-service.cpp
* @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
* @version 1.0
*/
#include <thread-service.h>
#include <dpl/log/log.h>
namespace CKM {
ThreadService::ThreadService() : m_connectionInfoMap()
{
}
ThreadService::~ThreadService()
{
}
void ThreadService::Handle(const AcceptEvent &event)
{
LogDebug("Accept event");
auto &info = m_connectionInfoMap[event.connectionID.counter];
info.interfaceID = event.interfaceID;
info.credentials = event.credentials;
}
void ThreadService::Handle(const WriteEvent &event)
{
LogDebug("Write event (" << event.size << " bytes )");
}
void ThreadService::Handle(const ReadEvent &event)
{
LogDebug("Read event");
auto &info = m_connectionInfoMap[event.connectionID.counter];
info.buffer.Push(event.rawBuffer);
if (!info.buffer.Ready())
return;
if (info.checkInProgress)
return;
info.checkInProgress = true;
m_serviceManager->SecurityCheck(event.connectionID);
}
void ThreadService::Handle(const CloseEvent &event)
{
LogDebug("Close event");
m_connectionInfoMap.erase(event.connectionID.counter);
}
void ThreadService::Handle(const SecurityEvent &event)
{
LogDebug("Security event");
auto it = m_connectionInfoMap.find(event.connectionID.counter);
if (it == m_connectionInfoMap.end()) {
LogDebug("Connection has been closed already");
return;
}
auto &info = it->second;
if (!info.checkInProgress) {
LogDebug("Wrong status in info.checkInProgress. Expected: true.");
return;
}
ProcessOne(event.connectionID, info, event.allowed);
if (info.buffer.Ready())
m_serviceManager->SecurityCheck(event.connectionID);
else
info.checkInProgress = false;
}
} /* namespace CKM */
|