ROSE 0.11.145.250
VxworksTerminal.h
1#ifndef ROSE_BinaryAnalysis_VxworksTerminal_H
2#define ROSE_BinaryAnalysis_VxworksTerminal_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/AddressInterval.h>
7#include <Rose/BinaryAnalysis/MemoryMap.h>
8#include <Rose/Diagnostics.h>
9
10#include <Sawyer/PartialResult.h>
11#include <Sawyer/Result.h>
12
13#include <string>
14
15namespace Rose {
16namespace BinaryAnalysis {
17
20public:
23
25 class Settings {
26 public:
28 unsigned permissions = MemoryMap::READ_WRITE_EXECUTE;
29 std::string prompt = "/[_a-zA-Z0-9]+->|-> /";
30 double delaySeconds = 0.01;
31 double timeoutSeconds = 2.0;
32 size_t bytesPerRequest = 1024;
33 std::string host = "localhost";
34 uint16_t port = 23;
36 public:
37 void print(std::ostream&) const;
38 };
39
42 public:
43 enum class State {
44 NORMAL,
45 DRAIN,
47 };
48
49 public:
52 public:
53 virtual ~DataTransfer() = default;
54
58 virtual std::string handleInput(const std::string &line) = 0;
59
65 virtual std::string handlePrompt(const std::string &prompt) = 0;
66 };
67
68private:
69 Settings settings_;
70 int server_ = -1; // filedescriptor connected to the server if open, else -1
71
72public:
73 static Diagnostics::Facility mlog;
74
75public:
77protected:
79 explicit VxworksTerminal(const Settings&);
80 VxworksTerminal(const VxworksTerminal&) = delete;
81 VxworksTerminal& operator=(const VxworksTerminal&) = delete;
82
83public:
90 static Ptr instance();
91 static Ptr instance(const Settings&);
94public:
98 static void initDiagnostics();
99
103 const Settings& settings() const;
112 static std::string locatorStringDocumentation(const Settings&);
113
122
130
134 bool isOpen() const;
135
160 const std::string &name);
163private:
164
165 bool matchPrompt(const std::string&);
167};
168
169std::ostream& operator<<(std::ostream&, const VxworksTerminal::Settings&);
170
171} // namespace
172} // namespace
173
174#endif
175#endif
Handle data transfers to/from the VxWorks terminal.
@ TERMINATE
Terminate transfer at next opportunity.
@ NORMAL
Normal operational state transferring and handling data.
@ DRAIN
Terminate transfer when output to server becomes empty.
virtual std::string handleInput(const std::string &line)=0
Called for each line emitted by the VxWorks terminal.
virtual std::string handlePrompt(const std::string &prompt)=0
Called each time a prompt is detected from the VxWorks terminal.
Information about connecting to a VxWorks terminal.
double timeoutSeconds
Number of seconds before assuming a missed prompt.
std::string host
Telnet server host or IP.
AddressInterval where
Affected addresses.
size_t bytesPerRequest
Number of bytes to request per terminal command.
std::string prompt
VxWorks terminal prompt "literal" or "/regex/".
double delaySeconds
Number of seconds to delay before each command.
uint16_t port
TCP port at which the telnet server is listening.
Connection to a VxWorks terminal.
static std::string locatorStringDocumentation(const Settings &)
Generate locator string documentation.
const Settings & settings() const
Property: Configuration settings.
Sawyer::PartialResult< AddressInterval, std::string > download(const MemoryMapPtr &destination, const AddressInterval &, const std::string &name)
Download memory from an open connection into a map.
Settings & settings()
Property: Configuration settings.
static Ptr instance()
Allocating constructor.
static void initDiagnostics()
Initialize diagnostic streams.
Sawyer::PartialResult< AddressInterval, std::string > download(const MemoryMapPtr &destination, const std::string &name)
Download memory from an open connection into a map.
VxworksTerminalPtr Ptr
Shared-ownership pointer.
Sawyer::Optional< std::string > open()
Open a connection to the terminal.
Sawyer::PartialResult< std::vector< uint8_t >, std::string > download(const AddressInterval &)
Download memory from an open connection.
static Ptr instance(const Settings &)
Allocating constructor.
bool isOpen() const
Test whether the connection is open.
static Sawyer::Result< Settings, MemoryMap::LocatorError > parseLocatorString(const std::string &, const Settings &dflt)
Parse a VxWorks terminal locator string.
Sawyer::PartialResult< std::vector< uint8_t >, std::string > download()
Download memory from an open connection.
Collection of streams.
Definition Message.h:1606
Holds a value or nothing.
Definition Optional.h:56
Result containing a value and an error.
Result containing a value or an error.
Definition Result.h:315
std::shared_ptr< VxworksTerminal > VxworksTerminalPtr
Reference counting pointer.
The ROSE library.