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