Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
secondary_tcp_server.h
1 #ifndef AKTUALIZR_SECONDARY_TCP_SERVER_H_
2 #define AKTUALIZR_SECONDARY_TCP_SERVER_H_
3 
4 #include "utilities/utils.h"
5 
6 #include <atomic>
7 
8 namespace Uptane {
10 } // namespace Uptane
11 /**
12  * Listens on a socket, decodes calls (ASN.1) and forwards them to an Uptane Secondary
13  * implementation
14  */
16  public:
17  enum class ExitReason {
18  kNotApplicable,
19  kRebootNeeded,
20  kUnkown,
21  };
22 
23  SecondaryTcpServer(Uptane::SecondaryInterface& secondary, const std::string& primary_ip, in_port_t primary_port,
24  in_port_t port = 0, bool reboot_after_install = false);
25 
26  SecondaryTcpServer(const SecondaryTcpServer&) = delete;
27  SecondaryTcpServer& operator=(const SecondaryTcpServer&) = delete;
28 
29  public:
30  /**
31  * Accept connections on the socket, decode requests and respond using the secondary implementation
32  */
33  void run();
34  void stop();
35 
36  in_port_t port() const;
37  ExitReason exit_reason() const;
38 
39  private:
40  bool HandleOneConnection(int socket);
41 
42  private:
44  ListenSocket listen_socket_;
45  std::atomic<bool> keep_running_;
46  bool reboot_after_install_;
47  ExitReason exit_reason_{ExitReason::kNotApplicable};
48 };
49 
50 #endif // AKTUALIZR_SECONDARY_TCP_SERVER_H_
SecondaryTcpServer
Listens on a socket, decodes calls (ASN.1) and forwards them to an Uptane Secondary implementation.
Definition: secondary_tcp_server.h:15
SecondaryTcpServer::run
void run()
Accept connections on the socket, decode requests and respond using the secondary implementation.
Definition: secondary_tcp_server.cc:27
Uptane
Base data types that are used in The Update Framework (TUF), part of Uptane.
Definition: secondary_tcp_server.h:8
Uptane::SecondaryInterface
Definition: secondaryinterface.h:12
ListenSocket
Definition: utils.h:158