blob: c5e27162073f3e0ae18a8f779b48698f1d2c05ba [file] [log] [blame]
James Kuszmaul1ec74432020-07-30 20:26:45 -07001#include "absl/types/span.h"
Philipp Schrader790cb542023-07-05 21:06:52 -07002
Alex Perry5f474f22020-02-01 12:14:24 -08003#include "aos/events/event_loop.h"
James Kuszmaul1ec74432020-07-30 20:26:45 -07004#include "aos/flatbuffers.h"
Austin Schuh60e77942022-05-16 17:48:24 -07005#include "aos/network/web_proxy_generated.h"
Alex Perry5f474f22020-02-01 12:14:24 -08006
7namespace aos {
8namespace web_proxy {
9
10int GetPacketCount(const Context &context);
11
Austin Schuh52e5e3a2021-04-24 22:30:02 -070012// Packs a message embedded in context into a MessageHeader on fbb. Handles
13// multipart messages by use of the packet_index.
Alex Perry5f474f22020-02-01 12:14:24 -080014flatbuffers::Offset<MessageHeader> PackMessage(
15 flatbuffers::FlatBufferBuilder *fbb, const Context &context,
16 int channel_index, int packet_index);
17
Austin Schuhd16ef442021-04-25 14:44:42 -070018// Returns the size that the overall packed message packed by PackMessage will
19// be for the provided packet index.
20size_t PackedMessageSize(const Context &context, int packet_index);
21
James Kuszmaul1ec74432020-07-30 20:26:45 -070022// Packs the provided raw data into a series of MessageHeader's of the
23// appropriate length.
24std::vector<FlatbufferDetachedBuffer<MessageHeader>> PackBuffer(
25 absl::Span<const uint8_t> span);
Alex Perry5f474f22020-02-01 12:14:24 -080026
27} // namespace web_proxy
28} // namespace aos