FreeNOS
RecoveryClient.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <ChannelClient.h>
19 #include "RecoveryMessage.h"
20 #include "RecoveryClient.h"
21 
23  : m_pid(pid)
24 {
25 }
26 
28 {
29  if (ChannelClient::instance()->syncSendReceive(&msg, sizeof(msg), m_pid) == ChannelClient::Success)
30  {
31  return msg.result;
32  }
33  else
34  {
35  return Recovery::IpcError;
36  }
37 }
38 
40 {
41  RecoveryMessage msg;
44  msg.pid = pid;
45 
46  return request(msg);
47 }
ChannelClient.h
StrictSingleton< ChannelClient >::instance
static ChannelClient * instance()
Retrieve the instance.
Definition: Singleton.h:53
RecoveryClient::request
Recovery::Result request(RecoveryMessage &msg) const
Send an IPC request to the RecoveryServer.
Definition: RecoveryClient.cpp:27
RecoveryClient::restartProcess
Recovery::Result restartProcess(const ProcessID pid) const
Restart a process.
Definition: RecoveryClient.cpp:39
RecoveryClient::m_pid
const ProcessID m_pid
ProcessID of the RecoveryServer.
Definition: RecoveryClient.h:74
ChannelMessage::type
Type type
Message type is either a request or response.
Definition: ChannelMessage.h:48
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
ChannelClient::Success
@ Success
Definition: ChannelClient.h:83
RecoveryMessage
Recovery IPC message.
Definition: RecoveryMessage.h:36
Recovery::IpcError
@ IpcError
Definition: Recovery.h:48
RecoveryMessage.h
Recovery::RestartProcess
@ RestartProcess
Definition: Recovery.h:36
RecoveryClient::RecoveryClient
RecoveryClient(const ProcessID pid=RECOVERY_PID)
Class constructor function.
Definition: RecoveryClient.cpp:22
RecoveryMessage::pid
ProcessID pid
Process identifier of target process.
Definition: RecoveryMessage.h:41
RecoveryMessage::action
Recovery::Action action
Action to perform.
Definition: RecoveryMessage.h:39
Recovery::Result
Result
Result codes.
Definition: Recovery.h:42
RecoveryMessage::result
Recovery::Result result
Result of action.
Definition: RecoveryMessage.h:40
RecoveryClient.h
ChannelMessage::Request
@ Request
Definition: ChannelMessage.h:43