Added version argument to spdylay_frame_*_init. Added version member to
spdylay_session.
This commit is contained in:
parent
7652d3f4ca
commit
995ccbc8e5
|
@ -39,7 +39,9 @@ struct spdylay_session;
|
||||||
typedef struct spdylay_session spdylay_session;
|
typedef struct spdylay_session spdylay_session;
|
||||||
|
|
||||||
/* SPDY protocol version 2 */
|
/* SPDY protocol version 2 */
|
||||||
#define SPDYLAY_PROTO_VERSION 2
|
#define SPDYLAY_PROTO_SPDY2 2
|
||||||
|
/* SPDY protocol version 3 */
|
||||||
|
#define SPDYLAY_PROTO_SPDY3 3
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SPDYLAY_ERR_INVALID_ARGUMENT = -501,
|
SPDYLAY_ERR_INVALID_ARGUMENT = -501,
|
||||||
|
@ -122,6 +124,9 @@ typedef enum {
|
||||||
SPDYLAY_FLOW_CONTROL_ERROR = 7
|
SPDYLAY_FLOW_CONTROL_ERROR = 7
|
||||||
} spdylay_status_code;
|
} spdylay_status_code;
|
||||||
|
|
||||||
|
#define SPDYLAY_SPDY2_LOWEST_PRI 3
|
||||||
|
#define SPDYLAY_SPDY3_LOWEST_PRI 7
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t version;
|
uint16_t version;
|
||||||
uint16_t type;
|
uint16_t type;
|
||||||
|
@ -133,8 +138,12 @@ typedef struct {
|
||||||
spdylay_ctrl_hd hd;
|
spdylay_ctrl_hd hd;
|
||||||
int32_t stream_id;
|
int32_t stream_id;
|
||||||
int32_t assoc_stream_id;
|
int32_t assoc_stream_id;
|
||||||
/* 0 (Highest) to 3 (Lowest). Looks like spdy/2 spec is wrong. */
|
/* 0 (Highest) to SPDYLAY_SPDY2_LOWEST_PRI or
|
||||||
|
SPDYLAY_SPDY3_LOWEST_PRI (loweset), depending on the protocol
|
||||||
|
version. */
|
||||||
uint8_t pri;
|
uint8_t pri;
|
||||||
|
/* Use in spdy/3 only */
|
||||||
|
uint8_t slot;
|
||||||
char **nv;
|
char **nv;
|
||||||
} spdylay_syn_stream;
|
} spdylay_syn_stream;
|
||||||
|
|
||||||
|
@ -177,6 +186,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
spdylay_ctrl_hd hd;
|
spdylay_ctrl_hd hd;
|
||||||
int32_t last_good_stream_id;
|
int32_t last_good_stream_id;
|
||||||
|
/* spdy/3 only */
|
||||||
uint32_t status_code;
|
uint32_t status_code;
|
||||||
} spdylay_goaway;
|
} spdylay_goaway;
|
||||||
|
|
||||||
|
|
|
@ -382,12 +382,13 @@ void spdylay_frame_nv_downcase(char **nv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void spdylay_frame_syn_stream_init(spdylay_syn_stream *frame, uint8_t flags,
|
void spdylay_frame_syn_stream_init(spdylay_syn_stream *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
int32_t stream_id, int32_t assoc_stream_id,
|
int32_t stream_id, int32_t assoc_stream_id,
|
||||||
uint8_t pri, char **nv)
|
uint8_t pri, char **nv)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_syn_stream));
|
memset(frame, 0, sizeof(spdylay_syn_stream));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_SYN_STREAM;
|
frame->hd.type = SPDYLAY_SYN_STREAM;
|
||||||
frame->hd.flags = flags;
|
frame->hd.flags = flags;
|
||||||
frame->stream_id = stream_id;
|
frame->stream_id = stream_id;
|
||||||
|
@ -401,11 +402,12 @@ void spdylay_frame_syn_stream_free(spdylay_syn_stream *frame)
|
||||||
spdylay_frame_nv_del(frame->nv);
|
spdylay_frame_nv_del(frame->nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spdylay_frame_syn_reply_init(spdylay_syn_reply *frame, uint8_t flags,
|
void spdylay_frame_syn_reply_init(spdylay_syn_reply *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
int32_t stream_id, char **nv)
|
int32_t stream_id, char **nv)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_syn_reply));
|
memset(frame, 0, sizeof(spdylay_syn_reply));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_SYN_REPLY;
|
frame->hd.type = SPDYLAY_SYN_REPLY;
|
||||||
frame->hd.flags = flags;
|
frame->hd.flags = flags;
|
||||||
frame->stream_id = stream_id;
|
frame->stream_id = stream_id;
|
||||||
|
@ -417,10 +419,11 @@ void spdylay_frame_syn_reply_free(spdylay_syn_reply *frame)
|
||||||
spdylay_frame_nv_del(frame->nv);
|
spdylay_frame_nv_del(frame->nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spdylay_frame_ping_init(spdylay_ping *frame, uint32_t unique_id)
|
void spdylay_frame_ping_init(spdylay_ping *frame,
|
||||||
|
uint16_t version, uint32_t unique_id)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_ping));
|
memset(frame, 0, sizeof(spdylay_ping));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_PING;
|
frame->hd.type = SPDYLAY_PING;
|
||||||
frame->hd.flags = SPDYLAY_CTRL_FLAG_NONE;
|
frame->hd.flags = SPDYLAY_CTRL_FLAG_NONE;
|
||||||
frame->hd.length = 4;
|
frame->hd.length = 4;
|
||||||
|
@ -431,10 +434,10 @@ void spdylay_frame_ping_free(spdylay_ping *frame)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void spdylay_frame_goaway_init(spdylay_goaway *frame,
|
void spdylay_frame_goaway_init(spdylay_goaway *frame,
|
||||||
int32_t last_good_stream_id)
|
uint16_t version, int32_t last_good_stream_id)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_goaway));
|
memset(frame, 0, sizeof(spdylay_goaway));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_GOAWAY;
|
frame->hd.type = SPDYLAY_GOAWAY;
|
||||||
frame->hd.length = 4;
|
frame->hd.length = 4;
|
||||||
frame->last_good_stream_id = last_good_stream_id;
|
frame->last_good_stream_id = last_good_stream_id;
|
||||||
|
@ -443,11 +446,12 @@ void spdylay_frame_goaway_init(spdylay_goaway *frame,
|
||||||
void spdylay_frame_goaway_free(spdylay_goaway *frame)
|
void spdylay_frame_goaway_free(spdylay_goaway *frame)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void spdylay_frame_headers_init(spdylay_headers *frame, uint8_t flags,
|
void spdylay_frame_headers_init(spdylay_headers *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
int32_t stream_id, char **nv)
|
int32_t stream_id, char **nv)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_headers));
|
memset(frame, 0, sizeof(spdylay_headers));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_HEADERS;
|
frame->hd.type = SPDYLAY_HEADERS;
|
||||||
frame->hd.flags = flags;
|
frame->hd.flags = flags;
|
||||||
frame->stream_id = stream_id;
|
frame->stream_id = stream_id;
|
||||||
|
@ -460,10 +464,11 @@ void spdylay_frame_headers_free(spdylay_headers *frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
void spdylay_frame_rst_stream_init(spdylay_rst_stream *frame,
|
void spdylay_frame_rst_stream_init(spdylay_rst_stream *frame,
|
||||||
|
uint16_t version,
|
||||||
int32_t stream_id, uint32_t status_code)
|
int32_t stream_id, uint32_t status_code)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_rst_stream));
|
memset(frame, 0, sizeof(spdylay_rst_stream));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_RST_STREAM;
|
frame->hd.type = SPDYLAY_RST_STREAM;
|
||||||
frame->hd.flags = 0;
|
frame->hd.flags = 0;
|
||||||
frame->hd.length = 8;
|
frame->hd.length = 8;
|
||||||
|
@ -474,11 +479,12 @@ void spdylay_frame_rst_stream_init(spdylay_rst_stream *frame,
|
||||||
void spdylay_frame_rst_stream_free(spdylay_rst_stream *frame)
|
void spdylay_frame_rst_stream_free(spdylay_rst_stream *frame)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void spdylay_frame_settings_init(spdylay_settings *frame, uint8_t flags,
|
void spdylay_frame_settings_init(spdylay_settings *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
spdylay_settings_entry *iv, size_t niv)
|
spdylay_settings_entry *iv, size_t niv)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_settings));
|
memset(frame, 0, sizeof(spdylay_settings));
|
||||||
frame->hd.version = SPDYLAY_PROTO_VERSION;
|
frame->hd.version = version;
|
||||||
frame->hd.type = SPDYLAY_SETTINGS;
|
frame->hd.type = SPDYLAY_SETTINGS;
|
||||||
frame->hd.flags = flags;
|
frame->hd.flags = flags;
|
||||||
frame->hd.length = 4+niv*8;
|
frame->hd.length = 4+niv*8;
|
||||||
|
|
|
@ -397,32 +397,37 @@ int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
|
||||||
* takes ownership of |nv|, so caller must not free it. If stream_id
|
* takes ownership of |nv|, so caller must not free it. If stream_id
|
||||||
* is not assigned yet, it must be 0.
|
* is not assigned yet, it must be 0.
|
||||||
*/
|
*/
|
||||||
void spdylay_frame_syn_stream_init(spdylay_syn_stream *frame, uint8_t flags,
|
void spdylay_frame_syn_stream_init(spdylay_syn_stream *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
int32_t stream_id, int32_t assoc_stream_id,
|
int32_t stream_id, int32_t assoc_stream_id,
|
||||||
uint8_t pri, char **nv);
|
uint8_t pri, char **nv);
|
||||||
|
|
||||||
void spdylay_frame_syn_stream_free(spdylay_syn_stream *frame);
|
void spdylay_frame_syn_stream_free(spdylay_syn_stream *frame);
|
||||||
|
|
||||||
void spdylay_frame_syn_reply_init(spdylay_syn_reply *frame, uint8_t flags,
|
void spdylay_frame_syn_reply_init(spdylay_syn_reply *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
int32_t stream_id, char **nv);
|
int32_t stream_id, char **nv);
|
||||||
|
|
||||||
void spdylay_frame_syn_reply_free(spdylay_syn_reply *frame);
|
void spdylay_frame_syn_reply_free(spdylay_syn_reply *frame);
|
||||||
|
|
||||||
void spdylay_frame_ping_init(spdylay_ping *frame, uint32_t unique_id);
|
void spdylay_frame_ping_init(spdylay_ping *frame, uint16_t version,
|
||||||
|
uint32_t unique_id);
|
||||||
|
|
||||||
void spdylay_frame_ping_free(spdylay_ping *frame);
|
void spdylay_frame_ping_free(spdylay_ping *frame);
|
||||||
|
|
||||||
void spdylay_frame_goaway_init(spdylay_goaway *frame,
|
void spdylay_frame_goaway_init(spdylay_goaway *frame, uint16_t version,
|
||||||
int32_t last_good_stream_id);
|
int32_t last_good_stream_id);
|
||||||
|
|
||||||
void spdylay_frame_goaway_free(spdylay_goaway *frame);
|
void spdylay_frame_goaway_free(spdylay_goaway *frame);
|
||||||
|
|
||||||
void spdylay_frame_headers_init(spdylay_headers *frame, uint8_t flags,
|
void spdylay_frame_headers_init(spdylay_headers *frame, uint16_t version,
|
||||||
|
uint8_t flags,
|
||||||
int32_t stream_id, char **nv);
|
int32_t stream_id, char **nv);
|
||||||
|
|
||||||
void spdylay_frame_headers_free(spdylay_headers *frame);
|
void spdylay_frame_headers_free(spdylay_headers *frame);
|
||||||
|
|
||||||
void spdylay_frame_rst_stream_init(spdylay_rst_stream *frame,
|
void spdylay_frame_rst_stream_init(spdylay_rst_stream *frame,
|
||||||
|
uint16_t version,
|
||||||
int32_t stream_id, uint32_t status_code);
|
int32_t stream_id, uint32_t status_code);
|
||||||
|
|
||||||
void spdylay_frame_rst_stream_free(spdylay_rst_stream *frame);
|
void spdylay_frame_rst_stream_free(spdylay_rst_stream *frame);
|
||||||
|
@ -431,7 +436,8 @@ void spdylay_frame_rst_stream_free(spdylay_rst_stream *frame);
|
||||||
* Initializes SETTINGS frame |frame| with given values. |frame| takes
|
* Initializes SETTINGS frame |frame| with given values. |frame| takes
|
||||||
* ownership of |iv|, so caller must not free it.
|
* ownership of |iv|, so caller must not free it.
|
||||||
*/
|
*/
|
||||||
void spdylay_frame_settings_init(spdylay_settings *frame, uint8_t flags,
|
void spdylay_frame_settings_init(spdylay_settings *frame,
|
||||||
|
uint16_t version, uint8_t flags,
|
||||||
spdylay_settings_entry *iv, size_t niv);
|
spdylay_settings_entry *iv, size_t niv);
|
||||||
|
|
||||||
void spdylay_frame_settings_free(spdylay_settings *frame);
|
void spdylay_frame_settings_free(spdylay_settings *frame);
|
||||||
|
|
|
@ -87,6 +87,7 @@ static int spdylay_session_new(spdylay_session **session_ptr,
|
||||||
initialized in either spdylay_session_client_new or
|
initialized in either spdylay_session_client_new or
|
||||||
spdylay_session_server_new */
|
spdylay_session_server_new */
|
||||||
|
|
||||||
|
(*session_ptr)->version = SPDYLAY_PROTO_SPDY2;
|
||||||
(*session_ptr)->last_ping_unique_id = 0;
|
(*session_ptr)->last_ping_unique_id = 0;
|
||||||
|
|
||||||
(*session_ptr)->next_seq = 0;
|
(*session_ptr)->next_seq = 0;
|
||||||
|
@ -331,7 +332,8 @@ int spdylay_session_add_rst_stream(spdylay_session *session,
|
||||||
if(frame == NULL) {
|
if(frame == NULL) {
|
||||||
return SPDYLAY_ERR_NOMEM;
|
return SPDYLAY_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
spdylay_frame_rst_stream_init(&frame->rst_stream, stream_id, status_code);
|
spdylay_frame_rst_stream_init(&frame->rst_stream, session->version,
|
||||||
|
stream_id, status_code);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_RST_STREAM, frame, NULL);
|
r = spdylay_session_add_frame(session, SPDYLAY_RST_STREAM, frame, NULL);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
spdylay_frame_rst_stream_free(&frame->rst_stream);
|
spdylay_frame_rst_stream_free(&frame->rst_stream);
|
||||||
|
@ -1028,11 +1030,12 @@ static int spdylay_session_is_new_peer_stream_id(spdylay_session *session,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns non-zero iff version == SPDYLAY_PROTO_VERSION
|
* Returns non-zero iff version == session->version
|
||||||
*/
|
*/
|
||||||
static int spdylay_session_check_version(uint16_t version)
|
static int spdylay_session_check_version(spdylay_session *session,
|
||||||
|
uint16_t version)
|
||||||
{
|
{
|
||||||
return version == SPDYLAY_PROTO_VERSION;
|
return session->version == version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1064,7 +1067,7 @@ static int spdylay_session_validate_syn_stream(spdylay_session *session,
|
||||||
if(!spdylay_session_is_new_peer_stream_id(session, frame->stream_id)) {
|
if(!spdylay_session_is_new_peer_stream_id(session, frame->stream_id)) {
|
||||||
return SPDYLAY_PROTOCOL_ERROR;
|
return SPDYLAY_PROTOCOL_ERROR;
|
||||||
}
|
}
|
||||||
if(!spdylay_session_check_version(frame->hd.version)) {
|
if(!spdylay_session_check_version(session, frame->hd.version)) {
|
||||||
return SPDYLAY_UNSUPPORTED_VERSION;
|
return SPDYLAY_UNSUPPORTED_VERSION;
|
||||||
}
|
}
|
||||||
if(session->server) {
|
if(session->server) {
|
||||||
|
@ -1187,7 +1190,7 @@ int spdylay_session_on_syn_reply_received(spdylay_session *session,
|
||||||
int r = 0;
|
int r = 0;
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
spdylay_stream *stream;
|
spdylay_stream *stream;
|
||||||
if(!spdylay_session_check_version(frame->syn_reply.hd.version)) {
|
if(!spdylay_session_check_version(session, frame->syn_reply.hd.version)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if((stream = spdylay_session_get_stream(session,
|
if((stream = spdylay_session_get_stream(session,
|
||||||
|
@ -1225,7 +1228,7 @@ int spdylay_session_on_syn_reply_received(spdylay_session *session,
|
||||||
int spdylay_session_on_rst_stream_received(spdylay_session *session,
|
int spdylay_session_on_rst_stream_received(spdylay_session *session,
|
||||||
spdylay_frame *frame)
|
spdylay_frame *frame)
|
||||||
{
|
{
|
||||||
if(!spdylay_session_check_version(frame->rst_stream.hd.version)) {
|
if(!spdylay_session_check_version(session, frame->rst_stream.hd.version)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(session->server &&
|
if(session->server &&
|
||||||
|
@ -1242,7 +1245,7 @@ int spdylay_session_on_rst_stream_received(spdylay_session *session,
|
||||||
int spdylay_session_on_settings_received(spdylay_session *session,
|
int spdylay_session_on_settings_received(spdylay_session *session,
|
||||||
spdylay_frame *frame)
|
spdylay_frame *frame)
|
||||||
{
|
{
|
||||||
if(!spdylay_session_check_version(frame->settings.hd.version)) {
|
if(!spdylay_session_check_version(session, frame->settings.hd.version)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* TODO Check ID/value pairs and persist them if necessary. */
|
/* TODO Check ID/value pairs and persist them if necessary. */
|
||||||
|
@ -1254,7 +1257,7 @@ int spdylay_session_on_ping_received(spdylay_session *session,
|
||||||
spdylay_frame *frame)
|
spdylay_frame *frame)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
if(!spdylay_session_check_version(frame->ping.hd.version)) {
|
if(!spdylay_session_check_version(session, frame->ping.hd.version)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(frame->ping.unique_id != 0) {
|
if(frame->ping.unique_id != 0) {
|
||||||
|
@ -1277,7 +1280,7 @@ int spdylay_session_on_ping_received(spdylay_session *session,
|
||||||
int spdylay_session_on_goaway_received(spdylay_session *session,
|
int spdylay_session_on_goaway_received(spdylay_session *session,
|
||||||
spdylay_frame *frame)
|
spdylay_frame *frame)
|
||||||
{
|
{
|
||||||
if(!spdylay_session_check_version(frame->goaway.hd.version)) {
|
if(!spdylay_session_check_version(session, frame->goaway.hd.version)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
session->last_good_stream_id = frame->goaway.last_good_stream_id;
|
session->last_good_stream_id = frame->goaway.last_good_stream_id;
|
||||||
|
@ -1292,7 +1295,7 @@ int spdylay_session_on_headers_received(spdylay_session *session,
|
||||||
int r = 0;
|
int r = 0;
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
spdylay_stream *stream;
|
spdylay_stream *stream;
|
||||||
if(!spdylay_session_check_version(frame->headers.hd.version)) {
|
if(!spdylay_session_check_version(session, frame->headers.hd.version)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if((stream = spdylay_session_get_stream(session,
|
if((stream = spdylay_session_get_stream(session,
|
||||||
|
@ -1701,7 +1704,7 @@ int spdylay_session_add_ping(spdylay_session *session, uint32_t unique_id)
|
||||||
if(frame == NULL) {
|
if(frame == NULL) {
|
||||||
return SPDYLAY_ERR_NOMEM;
|
return SPDYLAY_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
spdylay_frame_ping_init(&frame->ping, unique_id);
|
spdylay_frame_ping_init(&frame->ping, session->version, unique_id);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_PING, frame, NULL);
|
r = spdylay_session_add_frame(session, SPDYLAY_PING, frame, NULL);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
spdylay_frame_ping_free(&frame->ping);
|
spdylay_frame_ping_free(&frame->ping);
|
||||||
|
@ -1719,7 +1722,8 @@ int spdylay_session_add_goaway(spdylay_session *session,
|
||||||
if(frame == NULL) {
|
if(frame == NULL) {
|
||||||
return SPDYLAY_ERR_NOMEM;
|
return SPDYLAY_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
spdylay_frame_goaway_init(&frame->goaway, last_good_stream_id);
|
spdylay_frame_goaway_init(&frame->goaway, session->version,
|
||||||
|
last_good_stream_id);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_GOAWAY, frame, NULL);
|
r = spdylay_session_add_frame(session, SPDYLAY_GOAWAY, frame, NULL);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
spdylay_frame_goaway_free(&frame->goaway);
|
spdylay_frame_goaway_free(&frame->goaway);
|
||||||
|
|
|
@ -103,6 +103,9 @@ typedef enum {
|
||||||
} spdylay_goaway_flag;
|
} spdylay_goaway_flag;
|
||||||
|
|
||||||
struct spdylay_session {
|
struct spdylay_session {
|
||||||
|
/* The protocol version: either SPDYLAY_PROTO_SPDY2 or
|
||||||
|
SPDYLAY_PROTO_SPDY3 */
|
||||||
|
uint16_t version;
|
||||||
uint8_t server;
|
uint8_t server;
|
||||||
int32_t next_stream_id;
|
int32_t next_stream_id;
|
||||||
int32_t last_recv_stream_id;
|
int32_t last_recv_stream_id;
|
||||||
|
|
|
@ -85,7 +85,8 @@ static int spdylay_submit_syn_stream_shared
|
||||||
if(flags & SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL) {
|
if(flags & SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL) {
|
||||||
flags_copy |= SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL;
|
flags_copy |= SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL;
|
||||||
}
|
}
|
||||||
spdylay_frame_syn_stream_init(&frame->syn_stream, flags_copy,
|
spdylay_frame_syn_stream_init(&frame->syn_stream,
|
||||||
|
session->version, flags_copy,
|
||||||
0, assoc_stream_id, pri, nv_copy);
|
0, assoc_stream_id, pri, nv_copy);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame,
|
r = spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame,
|
||||||
aux_data);
|
aux_data);
|
||||||
|
@ -128,7 +129,8 @@ int spdylay_submit_headers(spdylay_session *session, uint8_t flags,
|
||||||
if(flags & SPDYLAY_CTRL_FLAG_FIN) {
|
if(flags & SPDYLAY_CTRL_FLAG_FIN) {
|
||||||
flags_copy |= SPDYLAY_CTRL_FLAG_FIN;
|
flags_copy |= SPDYLAY_CTRL_FLAG_FIN;
|
||||||
}
|
}
|
||||||
spdylay_frame_headers_init(&frame->headers, flags_copy, stream_id, nv_copy);
|
spdylay_frame_headers_init(&frame->headers, session->version, flags_copy,
|
||||||
|
stream_id, nv_copy);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_HEADERS, frame, NULL);
|
r = spdylay_session_add_frame(session, SPDYLAY_HEADERS, frame, NULL);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
spdylay_frame_headers_free(&frame->headers);
|
spdylay_frame_headers_free(&frame->headers);
|
||||||
|
@ -200,8 +202,8 @@ int spdylay_submit_response(spdylay_session *session,
|
||||||
if(data_prd_copy == NULL) {
|
if(data_prd_copy == NULL) {
|
||||||
flags |= SPDYLAY_CTRL_FLAG_FIN;
|
flags |= SPDYLAY_CTRL_FLAG_FIN;
|
||||||
}
|
}
|
||||||
spdylay_frame_syn_reply_init(&frame->syn_reply, flags, stream_id,
|
spdylay_frame_syn_reply_init(&frame->syn_reply, session->version, flags,
|
||||||
nv_copy);
|
stream_id, nv_copy);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_SYN_REPLY, frame,
|
r = spdylay_session_add_frame(session, SPDYLAY_SYN_REPLY, frame,
|
||||||
data_prd_copy);
|
data_prd_copy);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
|
|
|
@ -196,7 +196,7 @@ void test_spdylay_frame_pack_ping()
|
||||||
uint8_t *buf = NULL;
|
uint8_t *buf = NULL;
|
||||||
size_t buflen = 0;
|
size_t buflen = 0;
|
||||||
ssize_t framelen;
|
ssize_t framelen;
|
||||||
spdylay_frame_ping_init(&frame.ping, 1);
|
spdylay_frame_ping_init(&frame.ping, SPDYLAY_PROTO_SPDY2, 1);
|
||||||
framelen = spdylay_frame_pack_ping(&buf, &buflen, &frame.ping);
|
framelen = spdylay_frame_pack_ping(&buf, &buflen, &frame.ping);
|
||||||
CU_ASSERT(0 == spdylay_frame_unpack_ping
|
CU_ASSERT(0 == spdylay_frame_unpack_ping
|
||||||
(&oframe.ping,
|
(&oframe.ping,
|
||||||
|
@ -215,7 +215,7 @@ void test_spdylay_frame_pack_goaway()
|
||||||
uint8_t *buf = NULL;
|
uint8_t *buf = NULL;
|
||||||
size_t buflen = 0;
|
size_t buflen = 0;
|
||||||
ssize_t framelen;
|
ssize_t framelen;
|
||||||
spdylay_frame_goaway_init(&frame.goaway, 1000000007);
|
spdylay_frame_goaway_init(&frame.goaway, SPDYLAY_PROTO_SPDY2, 1000000007);
|
||||||
framelen = spdylay_frame_pack_goaway(&buf, &buflen, &frame.goaway);
|
framelen = spdylay_frame_pack_goaway(&buf, &buflen, &frame.goaway);
|
||||||
CU_ASSERT(0 == spdylay_frame_unpack_goaway
|
CU_ASSERT(0 == spdylay_frame_unpack_goaway
|
||||||
(&oframe.goaway,
|
(&oframe.goaway,
|
||||||
|
@ -223,7 +223,7 @@ void test_spdylay_frame_pack_goaway()
|
||||||
&buf[SPDYLAY_FRAME_HEAD_LENGTH],
|
&buf[SPDYLAY_FRAME_HEAD_LENGTH],
|
||||||
framelen-SPDYLAY_FRAME_HEAD_LENGTH));
|
framelen-SPDYLAY_FRAME_HEAD_LENGTH));
|
||||||
CU_ASSERT(1000000007 == oframe.goaway.last_good_stream_id);
|
CU_ASSERT(1000000007 == oframe.goaway.last_good_stream_id);
|
||||||
CU_ASSERT(SPDYLAY_PROTO_VERSION == oframe.headers.hd.version);
|
CU_ASSERT(SPDYLAY_PROTO_SPDY2 == oframe.headers.hd.version);
|
||||||
CU_ASSERT(SPDYLAY_GOAWAY == oframe.headers.hd.type);
|
CU_ASSERT(SPDYLAY_GOAWAY == oframe.headers.hd.type);
|
||||||
CU_ASSERT(SPDYLAY_CTRL_FLAG_NONE == oframe.headers.hd.flags);
|
CU_ASSERT(SPDYLAY_CTRL_FLAG_NONE == oframe.headers.hd.flags);
|
||||||
CU_ASSERT(framelen-SPDYLAY_FRAME_HEAD_LENGTH == oframe.ping.hd.length);
|
CU_ASSERT(framelen-SPDYLAY_FRAME_HEAD_LENGTH == oframe.ping.hd.length);
|
||||||
|
@ -243,7 +243,8 @@ void test_spdylay_frame_pack_headers()
|
||||||
spdylay_buffer_init(&inflatebuf, 4096);
|
spdylay_buffer_init(&inflatebuf, 4096);
|
||||||
spdylay_zlib_deflate_hd_init(&deflater);
|
spdylay_zlib_deflate_hd_init(&deflater);
|
||||||
spdylay_zlib_inflate_hd_init(&inflater);
|
spdylay_zlib_inflate_hd_init(&inflater);
|
||||||
spdylay_frame_headers_init(&frame.headers, SPDYLAY_CTRL_FLAG_FIN, 3,
|
spdylay_frame_headers_init(&frame.headers, SPDYLAY_PROTO_SPDY2,
|
||||||
|
SPDYLAY_CTRL_FLAG_FIN, 3,
|
||||||
spdylay_frame_nv_copy(headers));
|
spdylay_frame_nv_copy(headers));
|
||||||
framelen = spdylay_frame_pack_headers(&buf, &buflen,
|
framelen = spdylay_frame_pack_headers(&buf, &buflen,
|
||||||
&nvbuf, &nvbuflen,
|
&nvbuf, &nvbuflen,
|
||||||
|
@ -257,7 +258,7 @@ void test_spdylay_frame_pack_headers()
|
||||||
framelen-SPDYLAY_FRAME_HEAD_LENGTH,
|
framelen-SPDYLAY_FRAME_HEAD_LENGTH,
|
||||||
&inflater));
|
&inflater));
|
||||||
CU_ASSERT(3 == oframe.headers.stream_id);
|
CU_ASSERT(3 == oframe.headers.stream_id);
|
||||||
CU_ASSERT(SPDYLAY_PROTO_VERSION == oframe.headers.hd.version);
|
CU_ASSERT(SPDYLAY_PROTO_SPDY2 == oframe.headers.hd.version);
|
||||||
CU_ASSERT(SPDYLAY_HEADERS == oframe.headers.hd.type);
|
CU_ASSERT(SPDYLAY_HEADERS == oframe.headers.hd.type);
|
||||||
CU_ASSERT(SPDYLAY_CTRL_FLAG_FIN == oframe.headers.hd.flags);
|
CU_ASSERT(SPDYLAY_CTRL_FLAG_FIN == oframe.headers.hd.flags);
|
||||||
CU_ASSERT(framelen-SPDYLAY_FRAME_HEAD_LENGTH == oframe.ping.hd.length);
|
CU_ASSERT(framelen-SPDYLAY_FRAME_HEAD_LENGTH == oframe.ping.hd.length);
|
||||||
|
@ -292,7 +293,7 @@ void test_spdylay_frame_pack_settings()
|
||||||
iv[2].value = 65536;
|
iv[2].value = 65536;
|
||||||
|
|
||||||
spdylay_frame_settings_init
|
spdylay_frame_settings_init
|
||||||
(&frame.settings,
|
(&frame.settings, SPDYLAY_PROTO_SPDY2,
|
||||||
SPDYLAY_FLAG_SETTINGS_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS,
|
SPDYLAY_FLAG_SETTINGS_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS,
|
||||||
spdylay_frame_iv_copy(iv, 3), 3);
|
spdylay_frame_iv_copy(iv, 3), 3);
|
||||||
framelen = spdylay_frame_pack_settings(&buf, &buflen, &frame.settings);
|
framelen = spdylay_frame_pack_settings(&buf, &buflen, &frame.settings);
|
||||||
|
@ -304,7 +305,7 @@ void test_spdylay_frame_pack_settings()
|
||||||
&buf[SPDYLAY_FRAME_HEAD_LENGTH],
|
&buf[SPDYLAY_FRAME_HEAD_LENGTH],
|
||||||
framelen-SPDYLAY_FRAME_HEAD_LENGTH));
|
framelen-SPDYLAY_FRAME_HEAD_LENGTH));
|
||||||
|
|
||||||
CU_ASSERT(SPDYLAY_PROTO_VERSION == oframe.settings.hd.version);
|
CU_ASSERT(SPDYLAY_PROTO_SPDY2 == oframe.settings.hd.version);
|
||||||
CU_ASSERT(SPDYLAY_SETTINGS == oframe.settings.hd.type);
|
CU_ASSERT(SPDYLAY_SETTINGS == oframe.settings.hd.type);
|
||||||
CU_ASSERT(SPDYLAY_FLAG_SETTINGS_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS ==
|
CU_ASSERT(SPDYLAY_FLAG_SETTINGS_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS ==
|
||||||
oframe.settings.hd.flags);
|
oframe.settings.hd.flags);
|
||||||
|
|
|
@ -199,7 +199,8 @@ void test_spdylay_session_recv()
|
||||||
callbacks.on_ctrl_recv_callback = on_ctrl_recv_callback;
|
callbacks.on_ctrl_recv_callback = on_ctrl_recv_callback;
|
||||||
user_data.df = &df;
|
user_data.df = &df;
|
||||||
spdylay_session_server_new(&session, &callbacks, &user_data);
|
spdylay_session_server_new(&session, &callbacks, &user_data);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
|
SPDYLAY_CTRL_FLAG_NONE,
|
||||||
1, 0, 3, dup_nv(nv));
|
1, 0, 3, dup_nv(nv));
|
||||||
framelen = spdylay_frame_pack_syn_stream(&framedata, &framedatalen,
|
framelen = spdylay_frame_pack_syn_stream(&framedata, &framedatalen,
|
||||||
&nvbuf, &nvbuflen,
|
&nvbuf, &nvbuflen,
|
||||||
|
@ -251,8 +252,8 @@ void test_spdylay_session_add_frame()
|
||||||
CU_ASSERT(0 == spdylay_session_client_new(&session, &callbacks, &user_data));
|
CU_ASSERT(0 == spdylay_session_client_new(&session, &callbacks, &user_data));
|
||||||
|
|
||||||
frame = malloc(sizeof(spdylay_frame));
|
frame = malloc(sizeof(spdylay_frame));
|
||||||
spdylay_frame_syn_stream_init(&frame->syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame->syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
0, 0, 3, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 0, 0, 3, dup_nv(nv));
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame,
|
CU_ASSERT(0 == spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame,
|
||||||
aux_data));
|
aux_data));
|
||||||
|
@ -294,8 +295,8 @@ void test_spdylay_session_recv_invalid_stream_id()
|
||||||
user_data.df = &df;
|
user_data.df = &df;
|
||||||
user_data.invalid_ctrl_recv_cb_called = 0;
|
user_data.invalid_ctrl_recv_cb_called = 0;
|
||||||
spdylay_session_client_new(&session, &callbacks, &user_data);
|
spdylay_session_client_new(&session, &callbacks, &user_data);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
1, 0, 3, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 1, 0, 3, dup_nv(nv));
|
||||||
framelen = spdylay_frame_pack_syn_stream(&framedata, &framedatalen,
|
framelen = spdylay_frame_pack_syn_stream(&framedata, &framedatalen,
|
||||||
&nvbuf, &nvbuflen,
|
&nvbuf, &nvbuflen,
|
||||||
&frame.syn_stream,
|
&frame.syn_stream,
|
||||||
|
@ -306,8 +307,8 @@ void test_spdylay_session_recv_invalid_stream_id()
|
||||||
CU_ASSERT(0 == spdylay_session_recv(session));
|
CU_ASSERT(0 == spdylay_session_recv(session));
|
||||||
CU_ASSERT(1 == user_data.invalid_ctrl_recv_cb_called);
|
CU_ASSERT(1 == user_data.invalid_ctrl_recv_cb_called);
|
||||||
|
|
||||||
spdylay_frame_syn_reply_init(&frame.syn_reply, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_reply_init(&frame.syn_reply, SPDYLAY_PROTO_SPDY2,
|
||||||
100, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 100, dup_nv(nv));
|
||||||
framelen = spdylay_frame_pack_syn_reply(&framedata, &framedatalen,
|
framelen = spdylay_frame_pack_syn_reply(&framedata, &framedatalen,
|
||||||
&nvbuf, &nvbuflen,
|
&nvbuf, &nvbuflen,
|
||||||
&frame.syn_reply,
|
&frame.syn_reply,
|
||||||
|
@ -341,7 +342,8 @@ void test_spdylay_session_on_syn_stream_received()
|
||||||
user_data.invalid_ctrl_recv_cb_called = 0;
|
user_data.invalid_ctrl_recv_cb_called = 0;
|
||||||
|
|
||||||
spdylay_session_server_new(&session, &callbacks, &user_data);
|
spdylay_session_server_new(&session, &callbacks, &user_data);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
|
SPDYLAY_CTRL_FLAG_NONE,
|
||||||
stream_id, 0, pri, dup_nv(nv));
|
stream_id, 0, pri, dup_nv(nv));
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
||||||
|
@ -364,7 +366,8 @@ void test_spdylay_session_on_syn_stream_received()
|
||||||
spdylay_frame_syn_stream_free(&frame.syn_stream);
|
spdylay_frame_syn_stream_free(&frame.syn_stream);
|
||||||
|
|
||||||
/* Upper cased name/value pairs */
|
/* Upper cased name/value pairs */
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
|
SPDYLAY_CTRL_FLAG_NONE,
|
||||||
3, 0, 3, dup_nv(upcase_nv));
|
3, 0, 3, dup_nv(upcase_nv));
|
||||||
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
||||||
CU_ASSERT(3 == user_data.invalid_ctrl_recv_cb_called);
|
CU_ASSERT(3 == user_data.invalid_ctrl_recv_cb_called);
|
||||||
|
@ -393,7 +396,7 @@ void test_spdylay_session_on_syn_stream_received_with_push()
|
||||||
spdylay_session_client_new(&session, &callbacks, &user_data);
|
spdylay_session_client_new(&session, &callbacks, &user_data);
|
||||||
spdylay_session_open_stream(session, assoc_stream_id, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_session_open_stream(session, assoc_stream_id, SPDYLAY_CTRL_FLAG_NONE,
|
||||||
pri, SPDYLAY_STREAM_OPENED, NULL);
|
pri, SPDYLAY_STREAM_OPENED, NULL);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL,
|
SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL,
|
||||||
stream_id, assoc_stream_id, pri, dup_nv(nv));
|
stream_id, assoc_stream_id, pri, dup_nv(nv));
|
||||||
|
|
||||||
|
@ -446,8 +449,8 @@ void test_spdylay_session_on_syn_reply_received()
|
||||||
spdylay_session_client_new(&session, &callbacks, &user_data);
|
spdylay_session_client_new(&session, &callbacks, &user_data);
|
||||||
spdylay_session_open_stream(session, 1, SPDYLAY_CTRL_FLAG_NONE, 0,
|
spdylay_session_open_stream(session, 1, SPDYLAY_CTRL_FLAG_NONE, 0,
|
||||||
SPDYLAY_STREAM_OPENING, NULL);
|
SPDYLAY_STREAM_OPENING, NULL);
|
||||||
spdylay_frame_syn_reply_init(&frame.syn_reply, SPDYLAY_CTRL_FLAG_NONE, 1,
|
spdylay_frame_syn_reply_init(&frame.syn_reply, SPDYLAY_PROTO_SPDY2,
|
||||||
dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 1, dup_nv(nv));
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_syn_reply_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_syn_reply_received(session, &frame));
|
||||||
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
||||||
|
@ -474,8 +477,8 @@ void test_spdylay_session_on_syn_reply_received()
|
||||||
/* Upper cased name/value pairs */
|
/* Upper cased name/value pairs */
|
||||||
spdylay_session_open_stream(session, 5, SPDYLAY_CTRL_FLAG_NONE, 0,
|
spdylay_session_open_stream(session, 5, SPDYLAY_CTRL_FLAG_NONE, 0,
|
||||||
SPDYLAY_STREAM_OPENING, NULL);
|
SPDYLAY_STREAM_OPENING, NULL);
|
||||||
spdylay_frame_syn_reply_init(&frame.syn_reply, SPDYLAY_CTRL_FLAG_NONE, 5,
|
spdylay_frame_syn_reply_init(&frame.syn_reply, SPDYLAY_PROTO_SPDY2,
|
||||||
dup_nv(upcase_nv));
|
SPDYLAY_CTRL_FLAG_NONE, 5, dup_nv(upcase_nv));
|
||||||
CU_ASSERT(0 == spdylay_session_on_syn_reply_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_syn_reply_received(session, &frame));
|
||||||
CU_ASSERT(3 == user_data.invalid_ctrl_recv_cb_called);
|
CU_ASSERT(3 == user_data.invalid_ctrl_recv_cb_called);
|
||||||
|
|
||||||
|
@ -501,8 +504,8 @@ void test_spdylay_session_send_syn_stream()
|
||||||
memset(aux_data, 0, sizeof(spdylay_syn_stream_aux_data));
|
memset(aux_data, 0, sizeof(spdylay_syn_stream_aux_data));
|
||||||
|
|
||||||
spdylay_session_client_new(&session, &callbacks, NULL);
|
spdylay_session_client_new(&session, &callbacks, NULL);
|
||||||
spdylay_frame_syn_stream_init(&frame->syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame->syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
0, 0, 3, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 0, 0, 3, dup_nv(nv));
|
||||||
spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame, aux_data);
|
spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame, aux_data);
|
||||||
CU_ASSERT(0 == spdylay_session_send(session));
|
CU_ASSERT(0 == spdylay_session_send(session));
|
||||||
stream = spdylay_session_get_stream(session, 1);
|
stream = spdylay_session_get_stream(session, 1);
|
||||||
|
@ -527,8 +530,8 @@ void test_spdylay_session_send_syn_reply()
|
||||||
CU_ASSERT(0 == spdylay_session_client_new(&session, &callbacks, NULL));
|
CU_ASSERT(0 == spdylay_session_client_new(&session, &callbacks, NULL));
|
||||||
spdylay_session_open_stream(session, 2, SPDYLAY_CTRL_FLAG_NONE, 3,
|
spdylay_session_open_stream(session, 2, SPDYLAY_CTRL_FLAG_NONE, 3,
|
||||||
SPDYLAY_STREAM_OPENING, NULL);
|
SPDYLAY_STREAM_OPENING, NULL);
|
||||||
spdylay_frame_syn_reply_init(&frame->syn_reply, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_reply_init(&frame->syn_reply, SPDYLAY_PROTO_SPDY2,
|
||||||
2, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 2, dup_nv(nv));
|
||||||
spdylay_session_add_frame(session, SPDYLAY_SYN_REPLY, frame, NULL);
|
spdylay_session_add_frame(session, SPDYLAY_SYN_REPLY, frame, NULL);
|
||||||
CU_ASSERT(0 == spdylay_session_send(session));
|
CU_ASSERT(0 == spdylay_session_send(session));
|
||||||
stream = spdylay_session_get_stream(session, 2);
|
stream = spdylay_session_get_stream(session, 2);
|
||||||
|
@ -742,8 +745,8 @@ void test_spdylay_session_on_headers_received()
|
||||||
SPDYLAY_STREAM_OPENED, NULL);
|
SPDYLAY_STREAM_OPENED, NULL);
|
||||||
spdylay_stream_shutdown(spdylay_session_get_stream(session, 1),
|
spdylay_stream_shutdown(spdylay_session_get_stream(session, 1),
|
||||||
SPDYLAY_SHUT_WR);
|
SPDYLAY_SHUT_WR);
|
||||||
spdylay_frame_headers_init(&frame.headers, SPDYLAY_CTRL_FLAG_NONE, 1,
|
spdylay_frame_headers_init(&frame.headers, SPDYLAY_PROTO_SPDY2,
|
||||||
dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 1, dup_nv(nv));
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_headers_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_headers_received(session, &frame));
|
||||||
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
||||||
|
@ -791,8 +794,8 @@ void test_spdylay_session_on_headers_received()
|
||||||
/* Upper cased name/value pairs */
|
/* Upper cased name/value pairs */
|
||||||
spdylay_session_open_stream(session, 5, SPDYLAY_CTRL_FLAG_NONE, 0,
|
spdylay_session_open_stream(session, 5, SPDYLAY_CTRL_FLAG_NONE, 0,
|
||||||
SPDYLAY_STREAM_OPENED, NULL);
|
SPDYLAY_STREAM_OPENED, NULL);
|
||||||
spdylay_frame_headers_init(&frame.headers, SPDYLAY_CTRL_FLAG_NONE, 5,
|
spdylay_frame_headers_init(&frame.headers, SPDYLAY_PROTO_SPDY2,
|
||||||
dup_nv(upcase_nv));
|
SPDYLAY_CTRL_FLAG_NONE, 5, dup_nv(upcase_nv));
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_headers_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_headers_received(session, &frame));
|
||||||
CU_ASSERT(3 == user_data.invalid_ctrl_recv_cb_called);
|
CU_ASSERT(3 == user_data.invalid_ctrl_recv_cb_called);
|
||||||
|
@ -820,7 +823,7 @@ void test_spdylay_session_on_ping_received()
|
||||||
|
|
||||||
spdylay_session_client_new(&session, &callbacks, &user_data);
|
spdylay_session_client_new(&session, &callbacks, &user_data);
|
||||||
unique_id = 2;
|
unique_id = 2;
|
||||||
spdylay_frame_ping_init(&frame.ping, unique_id);
|
spdylay_frame_ping_init(&frame.ping, SPDYLAY_PROTO_SPDY2, unique_id);
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_ping_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_ping_received(session, &frame));
|
||||||
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
||||||
|
@ -854,7 +857,7 @@ void test_spdylay_session_on_goaway_received()
|
||||||
user_data.invalid_ctrl_recv_cb_called = 0;
|
user_data.invalid_ctrl_recv_cb_called = 0;
|
||||||
|
|
||||||
spdylay_session_client_new(&session, &callbacks, &user_data);
|
spdylay_session_client_new(&session, &callbacks, &user_data);
|
||||||
spdylay_frame_goaway_init(&frame.goaway, stream_id);
|
spdylay_frame_goaway_init(&frame.goaway, SPDYLAY_PROTO_SPDY2, stream_id);
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_goaway_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_goaway_received(session, &frame));
|
||||||
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
CU_ASSERT(1 == user_data.ctrl_recv_cb_called);
|
||||||
|
@ -953,7 +956,8 @@ void test_spdylay_session_on_rst_received()
|
||||||
3, SPDYLAY_STREAM_OPENING, NULL);
|
3, SPDYLAY_STREAM_OPENING, NULL);
|
||||||
spdylay_stream_add_pushed_stream(stream, 4);
|
spdylay_stream_add_pushed_stream(stream, 4);
|
||||||
|
|
||||||
spdylay_frame_rst_stream_init(&frame.rst_stream, 1, SPDYLAY_CANCEL);
|
spdylay_frame_rst_stream_init(&frame.rst_stream, SPDYLAY_PROTO_SPDY2, 1,
|
||||||
|
SPDYLAY_CANCEL);
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_rst_stream_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_rst_stream_received(session, &frame));
|
||||||
|
|
||||||
|
@ -986,7 +990,8 @@ void test_spdylay_session_send_rst_stream()
|
||||||
spdylay_stream_add_pushed_stream(stream, 4);
|
spdylay_stream_add_pushed_stream(stream, 4);
|
||||||
|
|
||||||
frame = malloc(sizeof(spdylay_frame));
|
frame = malloc(sizeof(spdylay_frame));
|
||||||
spdylay_frame_rst_stream_init(&frame->rst_stream, 1, SPDYLAY_CANCEL);
|
spdylay_frame_rst_stream_init(&frame->rst_stream, SPDYLAY_PROTO_SPDY2, 1,
|
||||||
|
SPDYLAY_CANCEL);
|
||||||
spdylay_session_add_frame(session, SPDYLAY_RST_STREAM, frame, NULL);
|
spdylay_session_add_frame(session, SPDYLAY_RST_STREAM, frame, NULL);
|
||||||
CU_ASSERT(0 == spdylay_session_send(session));
|
CU_ASSERT(0 == spdylay_session_send(session));
|
||||||
|
|
||||||
|
@ -1102,8 +1107,8 @@ void test_spdylay_session_on_request_recv_callback()
|
||||||
user_data.stream_id = 0;
|
user_data.stream_id = 0;
|
||||||
|
|
||||||
spdylay_session_server_new(&session, &callbacks, &user_data);
|
spdylay_session_server_new(&session, &callbacks, &user_data);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
1, 0, 3, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 1, 0, 3, dup_nv(nv));
|
||||||
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
||||||
CU_ASSERT(0 == user_data.stream_id);
|
CU_ASSERT(0 == user_data.stream_id);
|
||||||
|
|
||||||
|
@ -1126,8 +1131,8 @@ void test_spdylay_session_on_request_recv_callback()
|
||||||
|
|
||||||
spdylay_session_open_stream(session, 5, SPDYLAY_CTRL_FLAG_NONE, 0,
|
spdylay_session_open_stream(session, 5, SPDYLAY_CTRL_FLAG_NONE, 0,
|
||||||
SPDYLAY_STREAM_OPENING, NULL);
|
SPDYLAY_STREAM_OPENING, NULL);
|
||||||
spdylay_frame_headers_init(&frame.headers, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_headers_init(&frame.headers, SPDYLAY_PROTO_SPDY2,
|
||||||
5, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 5, dup_nv(nv));
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_headers_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_headers_received(session, &frame));
|
||||||
CU_ASSERT(0 == user_data.stream_id);
|
CU_ASSERT(0 == user_data.stream_id);
|
||||||
|
@ -1191,8 +1196,8 @@ void test_spdylay_session_max_concurrent_streams()
|
||||||
spdylay_session_server_new(&session, &callbacks, NULL);
|
spdylay_session_server_new(&session, &callbacks, NULL);
|
||||||
spdylay_session_open_stream(session, 1, SPDYLAY_CTRL_FLAG_NONE, 3,
|
spdylay_session_open_stream(session, 1, SPDYLAY_CTRL_FLAG_NONE, 3,
|
||||||
SPDYLAY_STREAM_OPENED, NULL);
|
SPDYLAY_STREAM_OPENED, NULL);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_CTRL_FLAG_NONE,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
3, 0, 3, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 3, 0, 3, dup_nv(nv));
|
||||||
session->settings[SPDYLAY_SETTINGS_MAX_CONCURRENT_STREAMS] = 1;
|
session->settings[SPDYLAY_SETTINGS_MAX_CONCURRENT_STREAMS] = 1;
|
||||||
|
|
||||||
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_syn_stream_received(session, &frame));
|
||||||
|
@ -1296,7 +1301,8 @@ void test_spdylay_session_stop_data_with_rst_stream()
|
||||||
/* data for DATA[1] is read from data_prd but it is not sent */
|
/* data for DATA[1] is read from data_prd but it is not sent */
|
||||||
CU_ASSERT(ud.data_source_length == 8*1024);
|
CU_ASSERT(ud.data_source_length == 8*1024);
|
||||||
|
|
||||||
spdylay_frame_rst_stream_init(&frame.rst_stream, 1, SPDYLAY_CANCEL);
|
spdylay_frame_rst_stream_init(&frame.rst_stream, SPDYLAY_PROTO_SPDY2, 1,
|
||||||
|
SPDYLAY_CANCEL);
|
||||||
CU_ASSERT(0 == spdylay_session_on_rst_stream_received(session, &frame));
|
CU_ASSERT(0 == spdylay_session_on_rst_stream_received(session, &frame));
|
||||||
spdylay_frame_rst_stream_free(&frame.rst_stream);
|
spdylay_frame_rst_stream_free(&frame.rst_stream);
|
||||||
|
|
||||||
|
@ -1333,7 +1339,7 @@ void test_spdylay_session_stream_close_on_syn_stream()
|
||||||
spdylay_session_client_new(&session, &callbacks, &ud);
|
spdylay_session_client_new(&session, &callbacks, &ud);
|
||||||
spdylay_session_open_stream(session, 1, SPDYLAY_CTRL_FLAG_NONE, 3,
|
spdylay_session_open_stream(session, 1, SPDYLAY_CTRL_FLAG_NONE, 3,
|
||||||
SPDYLAY_STREAM_OPENING, NULL);
|
SPDYLAY_STREAM_OPENING, NULL);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
SPDYLAY_CTRL_FLAG_FIN |
|
SPDYLAY_CTRL_FLAG_FIN |
|
||||||
SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL,
|
SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL,
|
||||||
2, 1, 3, dup_nv(nv));
|
2, 1, 3, dup_nv(nv));
|
||||||
|
@ -1366,7 +1372,7 @@ void test_spdylay_session_recv_invalid_frame()
|
||||||
user_data.df = &df;
|
user_data.df = &df;
|
||||||
user_data.ctrl_send_cb_called = 0;
|
user_data.ctrl_send_cb_called = 0;
|
||||||
spdylay_session_server_new(&session, &callbacks, &user_data);
|
spdylay_session_server_new(&session, &callbacks, &user_data);
|
||||||
spdylay_frame_syn_stream_init(&frame.syn_stream,
|
spdylay_frame_syn_stream_init(&frame.syn_stream, SPDYLAY_PROTO_SPDY2,
|
||||||
SPDYLAY_CTRL_FLAG_NONE, 1, 0, 3, dup_nv(nv));
|
SPDYLAY_CTRL_FLAG_NONE, 1, 0, 3, dup_nv(nv));
|
||||||
framelen = spdylay_frame_pack_syn_stream(&framedata, &framedatalen,
|
framelen = spdylay_frame_pack_syn_stream(&framedata, &framedatalen,
|
||||||
&nvbuf, &nvbuflen,
|
&nvbuf, &nvbuflen,
|
||||||
|
|
Loading…
Reference in New Issue