return NULL;
memset(ra_ctx, 0x00, sizeof(TcpReassemblyThreadCtx));
- ra_ctx->stream_q = StreamMsgQueueGetNew();
ra_ctx->app_tctx = AppLayerGetCtxThread();
void StreamTcpReassembleFreeThreadCtx(TcpReassemblyThreadCtx *ra_ctx)
{
SCEnter();
- if (ra_ctx->stream_q != NULL) {
- StreamMsg *smsg;
- while ((smsg = StreamMsgGetFromQueue(ra_ctx->stream_q)) != NULL) {
- StreamMsgReturnToPool(smsg);
- }
-
- StreamMsgQueueFree(ra_ctx->stream_q);
- }
-
- ra_ctx->stream_q = NULL;
AppLayerDestroyCtxThread(ra_ctx->app_tctx);
SCFree(ra_ctx);
SCReturn;
SCReturnUInt(0);
}
+static void StreamTcpStoreStreamChunk(TcpSession *ssn, StreamMsg *smsg, const Packet *p, int streaminline) {
+ uint8_t direction = 0;
+
+ if ((!streaminline && (p->flowflags & FLOW_PKT_TOSERVER)) ||
+ ( streaminline && (p->flowflags & FLOW_PKT_TOCLIENT)))
+ {
+ direction = STREAM_TOCLIENT;
+ SCLogDebug("stream chunk is to_client");
+ } else {
+ direction = STREAM_TOSERVER;
+ SCLogDebug("stream chunk is to_server");
+ }
+
+ /* store the smsg in the tcp stream */
+ if (direction == STREAM_TOSERVER) {
+ SCLogDebug("storing smsg in the to_server");
+
+ /* put the smsg in the stream list */
+ if (ssn->toserver_smsg_head == NULL) {
+ ssn->toserver_smsg_head = smsg;
+ ssn->toserver_smsg_tail = smsg;
+ smsg->next = NULL;
+ smsg->prev = NULL;
+ } else {
+ StreamMsg *cur = ssn->toserver_smsg_tail;
+ cur->next = smsg;
+ smsg->prev = cur;
+ smsg->next = NULL;
+ ssn->toserver_smsg_tail = smsg;
+ }
+ } else {
+ SCLogDebug("storing smsg in the to_client");
+
+ /* put the smsg in the stream list */
+ if (ssn->toclient_smsg_head == NULL) {
+ ssn->toclient_smsg_head = smsg;
+ ssn->toclient_smsg_tail = smsg;
+ smsg->next = NULL;
+ smsg->prev = NULL;
+ } else {
+ StreamMsg *cur = ssn->toclient_smsg_tail;
+ cur->next = smsg;
+ smsg->prev = cur;
+ smsg->next = NULL;
+ ssn->toclient_smsg_tail = smsg;
+ }
+ }
+}
+
/**
* \brief Insert a packets TCP data into the stream reassembly engine.
*
SCLogDebug("setting STREAM_EOF");
smsg->flags |= STREAM_EOF;
}
-
- if ((!StreamTcpInlineMode() && (p->flowflags & FLOW_PKT_TOSERVER)) ||
- ( StreamTcpInlineMode() && (p->flowflags & FLOW_PKT_TOCLIENT)))
- {
- smsg->flags |= STREAM_TOCLIENT;
- SCLogDebug("stream mesage is to_client");
- } else {
- smsg->flags |= STREAM_TOSERVER;
- SCLogDebug("stream mesage is to_server");
- }
-
smsg->data_len = 0;
SCLogDebug("smsg %p", smsg);
if (SEQ_GT(seg->seq, next_seq)) {
/* pass on pre existing smsg (if any) */
if (smsg != NULL && smsg->data_len > 0) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 1);
stream->ra_raw_base_seq = ra_base_seq;
smsg = NULL;
}
/* queue the smsg if it's full */
if (smsg->data_len == sizeof (smsg->data)) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 1);
stream->ra_raw_base_seq = ra_base_seq;
smsg = NULL;
}
"smsg_offset %" PRIu32 ", copy_size %" PRIu32 "",
payload_offset, smsg_offset, copy_size);
if (smsg->data_len == sizeof (smsg->data)) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 1);
stream->ra_raw_base_seq = ra_base_seq;
smsg = NULL;
}
/* put the partly filled smsg in the queue */
if (smsg != NULL) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 1);
smsg = NULL;
stream->ra_raw_base_seq = ra_base_seq;
}
SCReturnInt(-1);
}
StreamTcpSetupMsg(ssn, stream, p, smsg);
- StreamMsgPutInQueue(ra_ctx->stream_q,smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 0);
} else {
SCLogDebug("no segments in the list to reassemble");
or not. If not then sent the message and set flag that first
message has been sent. No more data till proto has not
been detected */
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 0);
stream->ra_raw_base_seq = ra_base_seq;
smsg = NULL;
}
/* queue the smsg if it's full */
if (smsg->data_len == sizeof (smsg->data)) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 0);
stream->ra_raw_base_seq = ra_base_seq;
smsg = NULL;
}
"smsg_offset %" PRIu32 ", copy_size %" PRIu32 "",
payload_offset, smsg_offset, copy_size);
if (smsg->data_len == sizeof (smsg->data)) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 0);
stream->ra_raw_base_seq = ra_base_seq;
smsg = NULL;
}
/* put the partly filled smsg in the queue to the l7 handler */
if (smsg != NULL) {
- StreamMsgPutInQueue(ra_ctx->stream_q, smsg);
+ StreamTcpStoreStreamChunk(ssn, smsg, p, 0);
smsg = NULL;
stream->ra_raw_base_seq = ra_base_seq;
}
SCReturnInt(r);
}
-/** \brief Handle the queue'd smsgs containing reassembled app layer data when
- * we're running the app layer handling as part of the stream threads.
- *
- * \param ra_ctx Reassembly thread ctx, contains the queue with stream msgs
- *
- * \todo Currently we process all msgs even if we encounter an error in one
- * of them. We do this to make sure the thread ctx's queue is emptied.
- * Maybe we should just clear & return the msgs in case of error.
- *
- * \retval 0 ok
- * \retval -1 error
- */
-int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *ra_ctx, TcpSession *ssn)
-{
- SCEnter();
-
- int r = 0;
- if (ra_ctx != NULL && ra_ctx->stream_q && ra_ctx->stream_q->len > 0) {
- StreamMsg *smsg = NULL;
- do {
- smsg = StreamMsgGetFromQueue(ra_ctx->stream_q);
- if (smsg != NULL) {
- SCLogDebug("smsg %p, next %p, prev %p, q->len %u, "
- "smsg->datalen %u, direction %s%s",
- smsg, smsg->next, smsg->prev,
- ra_ctx->stream_q->len, smsg->data_len,
- smsg->flags & STREAM_TOSERVER ? "toserver":"",
- smsg->flags & STREAM_TOCLIENT ? "toclient":"");
-
- //PrintRawDataFp(stderr, smsg->data, smsg->data_len);
-
- /* Handle the stream msg. No need to use locking, flow is
- * already locked at this point. Don't break out of the
- * loop if we encounter an error. */
- if (AppLayerHandleTCPMsg(smsg, ssn) != 0)
- r = -1;
- }
-
- } while (ra_ctx->stream_q->len > 0);
- }
-
- SCReturnInt(r);
-}
-
int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
TcpSession *ssn, TcpStream *stream,
Packet *p, PacketQueue *pq)
#ifdef UNITTESTS
/** unit tests and it's support functions below */
+static uint32_t UtSsnSmsgCnt(TcpSession *ssn, uint8_t direction) {
+ uint32_t cnt = 0;
+ StreamMsg *smsg = (direction == STREAM_TOSERVER) ?
+ ssn->toserver_smsg_head :
+ ssn->toclient_smsg_head;
+ while (smsg) {
+ cnt++;
+ smsg = smsg->next;
+ }
+ return cnt;
+}
+
/** \brief The Function tests the reassembly engine working for different
* OSes supported. It includes all the OS cases and send
* crafted packets to test the reassembly.
*
* \retval On success the function returns 1, on failure 0.
*/
-static int StreamTcpCheckQueue (uint8_t *stream_contents, StreamMsgQueue *q) {
+static int StreamTcpCheckChunks (TcpSession *ssn, uint8_t *stream_contents) {
SCEnter();
StreamMsg *msg;
uint8_t j;
uint8_t cnt = 0;
- if (q == NULL) {
- printf("q == NULL, ");
+ if (ssn == NULL) {
+ printf("ssn == NULL, ");
SCReturnInt(0);
}
- if (q->len == 0) {
- printf("q->len == 0, ");
+ if (ssn->toserver_smsg_head == NULL) {
+ printf("ssn->toserver_smsg_head == NULL, ");
SCReturnInt(0);
}
- msg = StreamMsgGetFromQueue(q);
+ msg = ssn->toserver_smsg_head;
while(msg != NULL) {
cnt++;
j = 0;
SCReturnInt(0);
}
}
- if (q->len > 0) {
- msg = StreamMsgGetFromQueue(q);
- } else {
- SCReturnInt(1);
- }
+ msg = msg->next;
}
SCReturnInt(1);
}
TcpSession ssn;
memset(&ssn, 0, sizeof (TcpSession));
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx();
- StreamMsgQueue *q = ra_ctx->stream_q;
StreamTcpInitConfig(TRUE);
StreamMsgQueueSetMinChunkLen(FLOW_PKT_TOSERVER, 4096);
goto end;
}
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (3): ");
- goto end;
- }
-
flowflags = FLOW_PKT_TOSERVER;
StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/
seq = 12;
goto end;
}
- if (StreamTcpCheckQueue(check_contents, q) == 0) {
+ if (StreamTcpCheckChunks(&ssn, check_contents) == 0) {
printf("failed in stream matching (6): ");
goto end;
}
uint8_t flowflags;
uint8_t check_contents[5] = {0x41, 0x41, 0x42, 0x42, 0x42};
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx();
- StreamMsgQueue *q = ra_ctx->stream_q;
TcpSession ssn;
memset(&ssn, 0, sizeof (TcpSession));
goto end;
}
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs\n");
- goto end;
- }
-
flowflags = FLOW_PKT_TOSERVER;
StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/
seq = 15;
goto end;
}
- if (StreamTcpCheckQueue(check_contents, q) == 0) {
+ if (StreamTcpCheckChunks(&ssn, check_contents) == 0) {
printf("failed in stream matching: ");
goto end;
}
memset(&ssn, 0, sizeof (TcpSession));
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx();
- StreamMsgQueue *q = ra_ctx->stream_q;
flowflags = FLOW_PKT_TOSERVER;
th_flag = TH_ACK|TH_PUSH;
goto end;
}
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs\n");
- goto end;
- }
-
flowflags = FLOW_PKT_TOSERVER;
StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/
seq = 12;
goto end;
}
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs\n");
- goto end;
- }
-
th_flag = TH_FIN|TH_ACK;
seq = 18;
ack = 20;
goto end;
}
- if (StreamTcpCheckQueue(check_contents, q) == 0) {
+ if (StreamTcpCheckChunks(&ssn, check_contents) == 0) {
printf("failed in stream matching: ");
goto end;
}
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len > 0) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) > 0) {
printf("there shouldn't be any stream smsgs in the queue (2): ");
goto end;
}
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len != 1) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
printf("there should one stream smsg in the queue (6): ");
goto end;
}
FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) ||
ssn->client.seg_list != NULL ||
ssn->server.seg_list != NULL ||
- stt->ra_ctx->stream_q->len != 0 ||
+ ssn->toserver_smsg_head != NULL ||
+ ssn->toclient_smsg_head != NULL ||
ssn->data_first_seen_dir != 0) {
printf("failure 1\n");
goto end;
FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) ||
ssn->client.seg_list != NULL ||
ssn->server.seg_list != NULL ||
- stt->ra_ctx->stream_q->len != 0 ||
+ ssn->toserver_smsg_head != NULL ||
+ ssn->toclient_smsg_head != NULL ||
ssn->data_first_seen_dir != 0) {
printf("failure 2\n");
goto end;
FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) ||
ssn->client.seg_list != NULL ||
ssn->server.seg_list != NULL ||
- stt->ra_ctx->stream_q->len != 0 ||
+ ssn->toserver_smsg_head != NULL ||
+ ssn->toclient_smsg_head != NULL ||
ssn->data_first_seen_dir != 0) {
printf("failure 3\n");
goto end;
ssn->client.seg_list == NULL ||
ssn->client.seg_list->next != NULL ||
ssn->server.seg_list != NULL ||
- stt->ra_ctx->stream_q->len != 0 ||
+ ssn->toserver_smsg_head != NULL ||
+ ssn->toclient_smsg_head != NULL ||
ssn->data_first_seen_dir != STREAM_TOSERVER) {
printf("failure 4\n");
goto end;
ssn->client.seg_list == NULL ||
ssn->client.seg_list->next != NULL ||
ssn->server.seg_list != NULL ||
- stt->ra_ctx->stream_q->len != 0 ||
+ ssn->toserver_smsg_head != NULL ||
+ ssn->toclient_smsg_head != NULL ||
ssn->data_first_seen_dir != STREAM_TOSERVER) {
printf("failure 5\n");
goto end;
ssn->client.seg_list->next == NULL ||
ssn->client.seg_list->next->next != NULL ||
ssn->server.seg_list != NULL ||
- stt->ra_ctx->stream_q->len != 0 ||
+ ssn->toserver_smsg_head != NULL ||
+ ssn->toclient_smsg_head != NULL ||
ssn->data_first_seen_dir != STREAM_TOSERVER) {
printf("failure 6\n");
goto end;
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len > 0) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOCLIENT) > 0) {
printf("there shouldn't be any stream smsgs in the queue, as we didn't"
" processed any smsg from toserver side till yet (2): ");
goto end;
goto end;
}
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (4): ");
- goto end;
- }
-
p->flowflags = FLOW_PKT_TOSERVER;
p->payload = httpbuf3;
p->payload_len = httplen3;
goto end;
}
- /* Check if we have stream smsgs in queue */
-#if 0
- if (ra_ctx->stream_q->len == 0) {
- printf("there should be a stream smsgs in the queue, as we have detected"
- " the app layer protocol and one smsg from toserver side has "
- "been sent (8): ");
- goto end;
- /* Process stream smsgs we may have in queue */
- } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (9): ");
- goto end;
- }
-#endif
p->flowflags = FLOW_PKT_TOSERVER;
p->payload = httpbuf4;
p->payload_len = httplen4;
goto end;
}
- /* Check if we have stream smsgs in queue */
-#if 0
- if (ra_ctx->stream_q->len == 0) {
- printf("there should be a stream smsgs in the queue, as we have detected"
- " the app layer protocol and one smsg from toserver side has "
- "been sent (12): ");
- goto end;
- /* Process stream smsgs we may have in queue */
- } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (13): ");
- goto end;
- }
-#endif
p->flowflags = FLOW_PKT_TOSERVER;
p->payload = httpbuf5;
p->payload_len = httplen5;
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len == 0) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) == 0) {
printf("there should be a stream smsgs in the queue, as we have detected"
" the app layer protocol and one smsg from toserver side has "
"been sent (16): ");
goto end;
- /* Process stream smsgs we may have in queue */
- }
-
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (17): ");
- goto end;
}
if (f->alproto != ALPROTO_HTTP) {
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len > 0) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) > 0) {
printf("there shouldn't be any stream smsgs in the queue (2): ");
goto end;
}
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len > 0) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOCLIENT) > 0) {
printf("there shouldn't be any stream smsgs in the queue, as we didn't"
" processed any smsg from toserver side till yet (4): ");
goto end;
printf("failed in segments reassembly, while processing toserver packet (5): ");
goto end;
}
-#if 0
- /* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len == 0) {
- printf("there should be a stream smsgs in the queue (6): ");
- goto end;
- /* Process stream smsgs we may have in queue */
- } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (7): ");
- goto end;
- }
-#endif
if (!StreamTcpIsSetStreamFlagAppProtoDetectionCompleted(&ssn.client)) {
printf("app layer detected flag isn't set, it should be (8): ");
goto end;
}
/* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len > 0) {
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOCLIENT) > 0) {
printf("there shouldn't be any stream smsgs in the queue, as we didn't"
" detected the app layer protocol till yet (10): ");
goto end;
printf("failed in segments reassembly, while processing toserver packet (11): ");
goto end;
}
-#if 0
- /* Check if we have stream smsgs in queue */
- if (ra_ctx->stream_q->len == 0) {
- printf("there should be a stream smsgs in the queue, as reassembling has"
- " been unpaused now (12): ");
- goto end;
- /* Process stream smsgs we may have in queue */
- } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs (13): ");
- goto end;
- }
-#endif
/* the flag should be set, as the smsg scanned size has crossed the max.
signature size for app proto detection */
if (!StreamTcpIsSetStreamFlagAppProtoDetectionCompleted(&ssn.client)) {
"packet\n");
goto end;
}
-
- /* Process stream smsgs we may have in queue */
- if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
- printf("failed in processing stream smsgs\n");
- goto end;
- }
}
if (f->alproto != ALPROTO_HTTP) {
goto end;
}
- if (ra_ctx->stream_q->len != 1) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
+ printf("expected a single stream message: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 1) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
+ printf("expected a single stream message: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected a single stream message: ");
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 20) {
printf("expected data length to be 20, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 1) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
+ printf("expected a single stream message 1: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected two stream messages: ");
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 1) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
+ printf("expected a single stream message: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected a single stream message: ");
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 16) {
printf("expected data length to be 16, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected a single stream message: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top->next;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 10) {
printf("expected data length to be 10, got %u: ", smsg->data_len);
goto end;
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 5) {
printf("expected data length to be 5, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected two stream messages: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top->next;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 10) {
printf("expected data length to be 10, got %u: ", smsg->data_len);
goto end;
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 5) {
printf("expected data length to be 5, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 3) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 3) {
+ printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER));
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next->next;
if (smsg->data_len != 20) {
printf("expected data length to be 20, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER));
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top->next;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 6) {
printf("expected data length to be 6, got %u: ", smsg->data_len);
goto end;
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 5) {
printf("expected data length to be 5, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 3) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 3) {
+ printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER));
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next->next;
if (smsg->data_len != 16) {
printf("expected data length to be 16, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 1) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
+ printf("expected a single stream message: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER));
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 15) {
printf("expected data length to be 15, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 2) {
- printf("expected 2 stream message2, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) {
+ printf("expected 2 stream message2, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER));
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->bot;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 10) {
printf("expected data length to be 10, got %u (bot): ", smsg->data_len);
goto end;
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next;
if (smsg->data_len != 5) {
printf("expected data length to be 5, got %u (top): ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 3) {
- printf("expected 3 stream messages, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 3) {
+ printf("expected 3 stream messages: ");
goto end;
}
- smsg = ra_ctx->stream_q->top;
+ smsg = ssn.toserver_smsg_head->next->next;
if (smsg->data_len != 20) {
printf("expected data length to be 20, got %u: ", smsg->data_len);
goto end;
goto end;
}
- if (ra_ctx->stream_q->len != 1) {
- printf("expected a single stream message, got %u: ", ra_ctx->stream_q->len);
+ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) {
+ printf("expected a single stream message: ");
goto end;
}
- StreamMsg *smsg = ra_ctx->stream_q->top;
+ StreamMsg *smsg = ssn.toserver_smsg_head;
if (smsg->data_len != 20) {
printf("expected data length to be 20, got %u: ", smsg->data_len);
goto end;