Go to the source code of this file.
Classes | |
struct | alts_frame_reader |
struct | alts_frame_writer |
Typedefs | |
typedef struct alts_frame_reader | alts_frame_reader |
typedef struct alts_frame_writer | alts_frame_writer |
Variables | |
const size_t | kFrameHeaderSize |
const size_t | kFrameLengthFieldSize = 4 |
const size_t | kFrameMaxSize = 1024 * 1024 |
const size_t | kFrameMessageType = 0x06 |
const size_t | kFrameMessageTypeFieldSize = 4 |
typedef struct alts_frame_reader alts_frame_reader |
Main struct for a frame reader. It reads raw bytes and puts the framed result into an output buffer. It does not own the output buffer.
typedef struct alts_frame_writer alts_frame_writer |
Implementation of frame reader and frame writer. All APIs in the header are thread-compatible. Main struct for a frame writer. It reads frames from an input buffer, and writes the contents as raw bytes. It does not own the input buffer.
alts_frame_reader* alts_create_frame_reader | ( | ) |
This method creates a frame reader instance and initializes its internal states.
Definition at line 122 of file frame_handler.cc.
alts_frame_writer* alts_create_frame_writer | ( | ) |
This method creates a frame writer instance and initializes its internal states.
Definition at line 51 of file frame_handler.cc.
void alts_destroy_frame_reader | ( | alts_frame_reader * | reader | ) |
This method destroys a frame reader instance.
Definition at line 219 of file frame_handler.cc.
void alts_destroy_frame_writer | ( | alts_frame_writer * | writer | ) |
This method destroys a frame writer instance.
Definition at line 119 of file frame_handler.cc.
size_t alts_get_num_writer_bytes_remaining | ( | alts_frame_writer * | writer | ) |
This method returns the number of bytes left to write before a complete frame is formed.
Definition at line 114 of file frame_handler.cc.
unsigned char* alts_get_output_buffer | ( | alts_frame_reader * | reader | ) |
This method returns output_buffer of a frame reader instance.
Definition at line 215 of file frame_handler.cc.
size_t alts_get_output_bytes_read | ( | alts_frame_reader * | reader | ) |
This method returns output_bytes_read of a frame reader instance.
Definition at line 211 of file frame_handler.cc.
size_t alts_get_reader_bytes_remaining | ( | alts_frame_reader * | reader | ) |
This method returns the number of bytes the frame reader intends to write. It may only be called if alts_has_read_frame_length() returns true.
Definition at line 137 of file frame_handler.cc.
bool alts_has_read_frame_length | ( | alts_frame_reader * | reader | ) |
This method checks if a frame length has been read.
The method returns true if a frame length has been read and false otherwise.
Definition at line 133 of file frame_handler.cc.
bool alts_is_frame_reader_done | ( | alts_frame_reader * | reader | ) |
This method checks if reset can be called to start processing a new frame. If true and reset was previously called, a full frame has been processed and the content of the frame is available in output_buffer.
Definition at line 127 of file frame_handler.cc.
bool alts_is_frame_writer_done | ( | alts_frame_writer * | writer | ) |
This method checks if a reset can be called to write a new frame. It returns true if it's the first time to frame a payload, or the current frame has been finished processing. It returns false if it's not ready yet to start a new frame (e.g., more payload data needs to be accumulated to process the current frame).
if (alts_is_frame_writer_done(writer)) { // a new frame can be written, call reset. alts_reset_frame_writer(writer, payload_buffer, payload_size); } else { // accumulate more payload data until a full frame can be written. }
Definition at line 109 of file frame_handler.cc.
bool alts_read_frame_bytes | ( | alts_frame_reader * | reader, |
const unsigned char * | bytes, | ||
size_t * | bytes_size | ||
) |
This method processes up to the number of bytes given in bytes_size. It may choose not to process all the bytes, if, for instance, more bytes are given to the method than required to complete the current frame.
The method returns true on success and false otherwise.
Definition at line 155 of file frame_handler.cc.
bool alts_reset_frame_reader | ( | alts_frame_reader * | reader, |
unsigned char * | buffer | ||
) |
This method resets internal states of a frame reader (including setting its output_buffer with buffer), and prepares to write processed bytes to an output_buffer. It does not take ownership of buffer. The buffer must outlive reader.
The method returns true on success and false otherwise.
Definition at line 146 of file frame_handler.cc.
bool alts_reset_frame_writer | ( | alts_frame_writer * | writer, |
const unsigned char * | buffer, | ||
size_t | length | ||
) |
This method resets internal states of a frame writer and prepares to write a single frame. It does not take ownership of payload_buffer. The payload_buffer must outlive the writer.
The method returns true on success and false otherwise.
Definition at line 55 of file frame_handler.cc.
void alts_reset_reader_output_buffer | ( | alts_frame_reader * | reader, |
unsigned char * | buffer | ||
) |
This method resets output_buffer but does not otherwise modify other internal states of a frame reader instance. After being set, the new output_buffer will hold the deframed payload held by the original output_buffer. It does not take ownership of buffer. The buffer must outlive the reader. To distinguish between two reset methods on a frame reader,
if (alts_fh_is_frame_reader_done(reader)) { // if buffer contains a full payload to be deframed, call reset. alts_reset_frame_reader(reader, buffer); }
// if remaining buffer space is not enough to hold a full payload if (buffer_space_remaining < alts_get_reader_bytes_remaining(reader)) { // allocate enough space for a new buffer, copy back data processed so far, // and call reset. alts_reset_reader_output_buffer(reader, new_buffer). }
Definition at line 141 of file frame_handler.cc.
bool alts_write_frame_bytes | ( | alts_frame_writer * | writer, |
unsigned char * | output, | ||
size_t * | bytes_size | ||
) |
This method writes up to bytes_size bytes of a frame to output.
The method returns true on success and false otherwise.
Definition at line 74 of file frame_handler.cc.
const size_t kFrameHeaderSize |
Definition at line 31 of file frame_handler.h.
const size_t kFrameLengthFieldSize = 4 |
Definition at line 28 of file frame_handler.h.
const size_t kFrameMaxSize = 1024 * 1024 |
Definition at line 30 of file frame_handler.h.
const size_t kFrameMessageType = 0x06 |
Definition at line 27 of file frame_handler.h.
const size_t kFrameMessageTypeFieldSize = 4 |
Definition at line 29 of file frame_handler.h.