diff options
author | Franois Gaffie <francois.gaffie@renault.com> | 2019-10-10 09:14:39 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-10-10 09:14:39 -0700 |
commit | 25c8b9753088ced295613dbc89a9cd00540af2e2 (patch) | |
tree | 54ac9b5279bb6eca4b7fdaee920de10d0ebd5dfb | |
parent | 5228e04162ed2e1977befb8acaf93ee167fe45c6 (diff) | |
parent | f7edd16e37b5be23ec0873d77a25846f7c54fbdb (diff) | |
download | parameter-framework-25c8b9753088ced295613dbc89a9cd00540af2e2.tar.gz |
follow-up: AF_UNIX socket enablement: allow path URI to bind address am: 639e5c89e5 am: a2a0e22c12 am: 3a315514d1
am: f7edd16e37
Change-Id: If254c064f9f4283ca45fa2e92ce95c738c5bbabe
-rw-r--r-- | upstream/remote-process/README.md | 4 | ||||
-rw-r--r-- | upstream/remote-process/main.cpp | 19 | ||||
-rw-r--r-- | upstream/remote-processor/RemoteProcessorServer.cpp | 16 |
3 files changed, 18 insertions, 21 deletions
diff --git a/upstream/remote-process/README.md b/upstream/remote-process/README.md index 7341552..768db57 100644 --- a/upstream/remote-process/README.md +++ b/upstream/remote-process/README.md @@ -18,6 +18,6 @@ parameter-framework client. ## Syntax - remote-process <host> <port> <command> + remote-process <hostname port|tcp://[host]:port|unix://path> <command> -You can get all available commands with the `help` command.
\ No newline at end of file +You can get all available commands with the `help` command. diff --git a/upstream/remote-process/main.cpp b/upstream/remote-process/main.cpp index ad94dc3..c0d8f51 100644 --- a/upstream/remote-process/main.cpp +++ b/upstream/remote-process/main.cpp @@ -77,19 +77,16 @@ bool sendAndDisplayCommand(asio::generic::stream_protocol::socket &socket, int usage(const std::string &command, const std::string &error) { if (not error.empty()) { - cerr << error << endl; + cerr << error << endl; } cerr << "Usage: " << endl; cerr << "Send a single command:" << endl; cerr << "\t" << command - << " <hostname port|<protocol>://<host:port|port_name>> <command> [argument[s]]" << endl; + << " <hostname port|tcp://[host]:port|unix://path> <command> [argument[s]]" << endl; return 1; } -// <hostname port|path> command [argument[s]] -// or -// <hostname port|path> < commands int main(int argc, char *argv[]) { int commandPos; @@ -122,24 +119,24 @@ int main(int argc, char *argv[]) const std::string tcpProtocol{"tcp"}; const std::string unixProtocol{"unix"}; - const std::vector<std::string> supportedProtocols{ tcpProtocol, unixProtocol }; + const std::vector<std::string> supportedProtocols{tcpProtocol, unixProtocol}; const std::string protocolDelimiter{"://"}; size_t protocolDelPos = endPortArg.find(protocolDelimiter); if (protocolDelPos == std::string::npos) { - return usage(argv[0], "Invalid socket endpoint, missing " + protocolDelimiter); + return usage(argv[0], "Invalid endpoint " + endPortArg); } protocol = endPortArg.substr(0, protocolDelPos); if (std::find(begin(supportedProtocols), end(supportedProtocols), protocol) == - end(supportedProtocols)) { - return usage(argv[0], "Invalid socket protocol " + protocol); + end(supportedProtocols)) { + return usage(argv[0], "Invalid endpoint " + endPortArg); } isInet = (endPortArg.find(tcpProtocol) != std::string::npos); if (isInet) { - size_t portDelPos = endPortArg.find(':', protocolDelPos + protocolDelimiter.size()); + size_t portDelPos = endPortArg.rfind(':'); if (portDelPos == std::string::npos) { - return usage(argv[0], "Invalid tcp endpoint" + endPortArg); + return usage(argv[0], "Invalid endpoint " + endPortArg); } host = endPortArg.substr(protocolDelPos + protocolDelimiter.size(), portDelPos - (protocolDelPos + protocolDelimiter.size())); diff --git a/upstream/remote-processor/RemoteProcessorServer.cpp b/upstream/remote-processor/RemoteProcessorServer.cpp index de7447e..8eb709d 100644 --- a/upstream/remote-processor/RemoteProcessorServer.cpp +++ b/upstream/remote-processor/RemoteProcessorServer.cpp @@ -61,39 +61,39 @@ bool CRemoteProcessorServer::start(string &error) uint16_t port; std::string endpointName; bool isInet; + const std::string expectedForm{"Required: <hostname port|tcp://[host]:port|unix://path>"}; // For backward compatibility, tcp port referred by its value only if (convertTo(_bindAddress, port)) { isInet = true; } else { - // required form is <protocol>://<host:port|port_name> const std::string tcpProtocol{"tcp"}; const std::string unixProtocol{"unix"}; - const std::vector<std::string> supportedProtocols{ tcpProtocol, unixProtocol }; + const std::vector<std::string> supportedProtocols{tcpProtocol, unixProtocol}; const std::string protocolDel{"://"}; size_t protocolDelPos = _bindAddress.find(protocolDel); if (protocolDelPos == std::string::npos) { - error = "bindaddress " + _bindAddress + " ill formed, missing " + protocolDel; + error = "bindaddress " + _bindAddress + " invalid, " + expectedForm; return false; } std::string protocol = _bindAddress.substr(0, protocolDelPos); if (std::find(begin(supportedProtocols), end(supportedProtocols), protocol) == - end(supportedProtocols)) { - error = "bindaddress " + _bindAddress + " has invalid protocol " + protocol; + end(supportedProtocols)) { + error = "bindaddress " + _bindAddress + " invalid, " + expectedForm; return false; } isInet = (_bindAddress.find(tcpProtocol) != std::string::npos); if (isInet) { - size_t portDelPos = _bindAddress.find(':', protocolDelPos + protocolDel.size()); + size_t portDelPos = _bindAddress.rfind(':'); if (portDelPos == std::string::npos) { - error = "bindaddress " + _bindAddress + " ill formed, missing " + ":"; + error = "bindaddress " + _bindAddress + " invalid, " + expectedForm; return false; } std::string portLiteral{_bindAddress.substr(portDelPos + 1)}; if (!convertTo(portLiteral, port)) { - error = "bindaddress " + _bindAddress + " port " + portLiteral + " ill formed"; + error = "bindaddress " + _bindAddress + " invalid" + expectedForm; return false; } } else { |