Android-cuttlefish cvd tool
proxy_common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef ANDROID_DEVICE_GOOGLE_CUTTLEFISH_HOST_COMMANDS_SANDBOX_PROCESS_PROXY_COMMON_H
17#define ANDROID_DEVICE_GOOGLE_CUTTLEFISH_HOST_COMMANDS_SANDBOX_PROCESS_PROXY_COMMON_H
18
19#include <sys/socket.h>
20#include <sys/un.h>
21
22#include <optional>
23#include <string>
24#include <string_view>
25
26#include "absl/status/statusor.h"
27
29
30static const constexpr std::string_view kHandshakeBegin = "hello";
31static const constexpr std::string_view kManagerSocketPath = "/manager.sock";
32
33class Message {
34 public:
35 static absl::StatusOr<Message> RecvFrom(int sock);
36
37 const std::string& Data() const;
38 absl::StatusOr<int> DataAsInt() const;
39
40 const std::optional<ucred>& Credentials() const;
41
42 std::string StrError() const;
43
44 private:
45 Message() = default;
46
47 std::string data_;
48 std::optional<ucred> credentials_;
49};
50
51absl::StatusOr<size_t> SendStringMsg(int sock, std::string_view msg);
52
53} // namespace cuttlefish::process_sandboxer
54#endif
Definition: proxy_common.h:33
std::optional< ucred > credentials_
Definition: proxy_common.h:48
const std::string & Data() const
Definition: proxy_common.cpp:76
const std::optional< ucred > & Credentials() const
Definition: proxy_common.cpp:78
absl::StatusOr< int > DataAsInt() const
std::string data_
Definition: proxy_common.h:47
static absl::StatusOr< Message > RecvFrom(int sock)
Definition: proxy_common.cpp:33
Definition: credentialed_unix_server.cpp:30
absl::StatusOr< size_t > SendStringMsg(int sock, std::string_view msg)
Definition: proxy_common.cpp:82
static const constexpr std::string_view kManagerSocketPath
Definition: proxy_common.h:31
static const constexpr std::string_view kHandshakeBegin
Definition: proxy_common.h:30