This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OTA-4174: IP Secondary TCP server refactoring
- improve the TCP server implementation - add tests for the TCP server and the RPC (serialization/deserialization) Signed-off-by: Mike Sul <ext-mykhaylo.sul@here.com>
- Loading branch information
Mike Sul
committed
Jan 15, 2020
1 parent
4fd855c
commit 770e25d
Showing
17 changed files
with
321 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef AKTUALIZR_SECONDARY_TCP_SERVER_H_ | ||
#define AKTUALIZR_SECONDARY_TCP_SERVER_H_ | ||
|
||
#include "utilities/utils.h" | ||
|
||
#include <atomic> | ||
|
||
namespace Uptane { | ||
class SecondaryInterface; | ||
} // namespace Uptane | ||
/** | ||
* Listens on a socket, decodes calls (ASN.1) and forwards them to an Uptane Secondary | ||
* implementation | ||
*/ | ||
class SecondaryTcpServer { | ||
public: | ||
SecondaryTcpServer(Uptane::SecondaryInterface& secondary, const std::string& primary_ip, in_port_t primary_port, | ||
in_port_t port = 0); | ||
|
||
SecondaryTcpServer(Uptane::SecondaryInterface& secondary, in_port_t port = 0) | ||
: keep_running_(true), impl_(secondary), listen_socket_(port) {} | ||
|
||
SecondaryTcpServer(const SecondaryTcpServer&) = delete; | ||
SecondaryTcpServer& operator=(const SecondaryTcpServer&) = delete; | ||
|
||
public: | ||
/** | ||
* Accept connections on the socket, decode requests and respond using the secondary implementation | ||
*/ | ||
void run(); | ||
void stop(); | ||
|
||
in_port_t port() const; | ||
|
||
private: | ||
void HandleOneConnection(int socket); | ||
|
||
private: | ||
std::atomic<bool> keep_running_; | ||
Uptane::SecondaryInterface& impl_; | ||
ListenSocket listen_socket_; | ||
}; | ||
|
||
#endif // AKTUALIZR_SECONDARY_TCP_SERVER_H_ |
Oops, something went wrong.