|
|
|
|
@ -4,22 +4,28 @@
|
|
|
|
|
#define STREAM_WIRE_H |
|
|
|
|
|
|
|
|
|
#include "stream_proto.h" |
|
|
|
|
#include "stream_metrics.h" |
|
|
|
|
|
|
|
|
|
#define STREAM_WIRE_VERSION 1 |
|
|
|
|
#define STREAM_WIRE_VERSION 2 |
|
|
|
|
#define STREAM_WIRE_HEADER 52 |
|
|
|
|
#define STREAM_PATH_MAX 32 |
|
|
|
|
#define STREAM_END_SIZE 106 |
|
|
|
|
#define STREAM_INFO_SIZE 29 /* actual:8, first:8, last:8, n:1, r:1, block_size:2, path_count:1 */ |
|
|
|
|
#define STREAM_METRIC_WIRE_SIZE 49 |
|
|
|
|
#define STREAM_INFO_METRIC_OFF 36 |
|
|
|
|
#define STREAM_INFO_PATH_OFF (STREAM_INFO_METRIC_OFF + STREAM_METRIC_WIRE_SIZE) |
|
|
|
|
#define STREAM_INFO_SIZE (STREAM_INFO_PATH_OFF + 1) /* probe:8, границы/FEC:28, метрики:49, count:1 */ |
|
|
|
|
#define STREAM_OVERLOAD_MAX 64 |
|
|
|
|
#define STREAM_OVERLOAD_HEADER 18 |
|
|
|
|
|
|
|
|
|
enum stream_command { |
|
|
|
|
STREAM_CMD_INFO_REQ = 1, STREAM_CMD_INFO_RESP, STREAM_CMD_SUBSCRIBE, STREAM_CMD_ACCEPT, |
|
|
|
|
STREAM_CMD_REJECT, STREAM_CMD_RENEW, STREAM_CMD_UNSUBSCRIBE, STREAM_CMD_CLOSED, |
|
|
|
|
STREAM_CMD_DATA, STREAM_CMD_GAP, STREAM_CMD_END, STREAM_CMD_REVERSE_REQ |
|
|
|
|
STREAM_CMD_DATA, STREAM_CMD_GAP, STREAM_CMD_END, STREAM_CMD_REVERSE_REQ, STREAM_CMD_OVERLOAD, STREAM_CMD_OVERLOAD_SELECT |
|
|
|
|
}; |
|
|
|
|
enum stream_reject { |
|
|
|
|
STREAM_REASON_STOPPED = 1, STREAM_REASON_POSITION, STREAM_REASON_EXPIRED, STREAM_REASON_STALE, |
|
|
|
|
STREAM_REASON_CONFLICT, STREAM_REASON_LIMIT, STREAM_REASON_LOOP, STREAM_REASON_TRANSPORT, |
|
|
|
|
STREAM_REASON_LEASE, STREAM_REASON_MEMBER, STREAM_REASON_PROTOCOL |
|
|
|
|
STREAM_REASON_LEASE, STREAM_REASON_MEMBER, STREAM_REASON_PROTOCOL, STREAM_REASON_OVERLOAD |
|
|
|
|
}; |
|
|
|
|
struct stream_path { uint64_t nodes[STREAM_PATH_MAX]; uint8_t count; }; |
|
|
|
|
struct stream_message { |
|
|
|
|
@ -37,6 +43,8 @@ void stream_wire_header(uint8_t *wire, const struct stream_message *message);
|
|
|
|
|
int stream_path_validate(const struct stream_path *path, uint64_t source, uint64_t sender, uint64_t forbidden); |
|
|
|
|
int stream_path_parse(const uint8_t *wire, size_t length, struct stream_path *path, size_t *used); |
|
|
|
|
size_t stream_path_write(uint8_t *wire, const struct stream_path *path); |
|
|
|
|
void stream_metric_write(uint8_t *wire, const struct stream_metric_snapshot *snapshot, int valid); |
|
|
|
|
int stream_metric_read(const uint8_t *wire, struct stream_metric_snapshot *snapshot, int *valid); |
|
|
|
|
int stream_end_sign(const struct stream_descriptor *descriptor, uint64_t last, const uint8_t key[32], uint8_t wire[STREAM_END_SIZE]); |
|
|
|
|
int stream_end_verify(const struct stream_descriptor *descriptor, const uint8_t key[32], const uint8_t *wire, size_t length, |
|
|
|
|
uint64_t *last); |
|
|
|
|
|