52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
typedef uint8_t yamux_version ;
|
|
typedef uint32_t yamux_streamid;
|
|
|
|
#define YAMUX_VERSION (0x00)
|
|
#define YAMUX_STREAMID_SESSION (0)
|
|
|
|
enum yamux_frame_type
|
|
{
|
|
yamux_frame_data = 0x00,
|
|
yamux_frame_window_update = 0x01,
|
|
yamux_frame_ping = 0x02,
|
|
yamux_frame_go_away = 0x03
|
|
};
|
|
enum yamux_frame_flags
|
|
{
|
|
yamux_frame_nil = 0x0000,
|
|
|
|
yamux_frame_syn = 0x0001,
|
|
yamux_frame_ack = 0x0002,
|
|
yamux_frame_fin = 0x0004,
|
|
yamux_frame_rst = 0x0008
|
|
};
|
|
|
|
#pragma pack(push,1)
|
|
struct yamux_frame
|
|
{
|
|
yamux_version version ;
|
|
uint8_t type ;
|
|
uint16_t flags ;
|
|
yamux_streamid streamid;
|
|
uint32_t length ;
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
/***
|
|
* convert the frame so it can be sent over the network (makes the endienness correct)
|
|
* @param frame the frame to encode
|
|
*/
|
|
void encode_frame(struct yamux_frame* frame);
|
|
|
|
/***
|
|
* Convert the frame from the network format to the local format (corrects endienness)
|
|
* @param frame the frame to decode
|
|
*/
|
|
void decode_frame(struct yamux_frame* frame);
|
|
|
|
|