Android-cuttlefish cvd tool
Namespaces | Functions
packet.h File Reference

lowest-level packet for communication between host & guest More...

#include <algorithm>
#include <cstdint>
#include <optional>
#include <string>
#include <tuple>
#include <type_traits>
#include <vector>
#include <android-base/logging.h>
#include <android-base/strings.h>
#include "cuttlefish/common/libs/confui/packet_types.h"
#include "cuttlefish/common/libs/confui/utils.h"
#include "cuttlefish/common/libs/fs/shared_buf.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
Include dependency graph for packet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  cuttlefish
 
namespace  cuttlefish::confui
 
namespace  cuttlefish::confui::packet
 
namespace  cuttlefish::confui::packet::impl
 

Functions

template<typename Buffer , typename... Args>
void cuttlefish::confui::packet::impl::AppendToBuffer (Buffer &buffer, Args &&... args)
 
template<typename... Args>
std::vector< int > cuttlefish::confui::packet::impl::MakeSizeHeader (Args &&... args)
 
template<typename... Args>
Payload cuttlefish::confui::packet::impl::ToPayload (const std::string &cmd_str, const std::string &session_id, Args &&... args)
 
std::optional< ParsedPacket > cuttlefish::confui::packet::ReadPayload (SharedFD s)
 
template<typename... Args>
bool cuttlefish::confui::packet::WritePayload (SharedFD d, const std::string &cmd_str, const std::string &session_id, Args &&... args)
 

Detailed Description

lowest-level packet for communication between host & guest

Each packet has three fields

  1. session_id_: the name of the currently active confirmation UI session
  2. type_: the type of command/response. E.g. start, stop, ack, abort, etc
  3. additional_info_: all the other additional information

The binary representation of each packet is as follows: n:L[1]:L[2]:...:L[n]:data[1]data[2]data[3]...data[n]

The additional_info_ is in general a variable number of items, each is either a byte vector (e.g. std::vector<uint8_t>) or a string.

n is the number of items. L[i] is the length of i th item. data[i] is the binary representation of the i th item