1cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao/* 2cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * Copyright (C) 2016 The Android Open Source Project 3cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * 4cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * Licensed under the Apache License, Version 2.0 (the "License"); 5cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * you may not use this file except in compliance with the License. 6cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * You may obtain a copy of the License at 7cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * 8cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * http://www.apache.org/licenses/LICENSE-2.0 9cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * 10cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * Unless required by applicable law or agreed to in writing, software 11cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * distributed under the License is distributed on an "AS IS" BASIS, 12cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * See the License for the specific language governing permissions and 14cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao * limitations under the License. 15cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao */ 16cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao 17cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao#pragma once 18cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao 19cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao#include <string> 20cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao 21cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao// Returns true if the argument starts with a plausible socket prefix. 22cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gaobool is_socket_spec(const std::string& spec); 239c869b58a8cf4f7c3bc88931fbd27d3f5187b2dbJosh Gaobool is_local_socket_spec(const std::string& spec); 24cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao 25cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gaoint socket_spec_connect(const std::string& spec, std::string* error); 26cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gaoint socket_spec_listen(const std::string& spec, std::string* error, 27cfb21412e5e3a716fc45601f35d3b58ce5f78f46Josh Gao int* resolved_tcp_port = nullptr); 281099215e30c3b09dfa390c638a45487c43b2b1e1Josh Gao 291099215e30c3b09dfa390c638a45487c43b2b1e1Josh Gao// Exposed for testing. 301099215e30c3b09dfa390c638a45487c43b2b1e1Josh Gaobool parse_tcp_socket_spec(const std::string& spec, std::string* hostname, int* port, 311099215e30c3b09dfa390c638a45487c43b2b1e1Josh Gao std::string* error); 32