#ifdef DEBUG
StreamTcpSackPrintList(stream);
#endif
+
+ /* if to the left of last_ack then ignore */
+ if (SEQ_LT(re, stream->last_ack)) {
+ SCLogDebug("too far left. discarding");
+ goto end;
+ }
+ /* if to the right of the tcp window then ignore */
+ if (SEQ_GT(le, (stream->last_ack + stream->window))) {
+ SCLogDebug("too far right. discarding");
+ goto end;
+ }
if (stream->sack_head != NULL) {
StreamTcpSackRecord *rec;
stream->sack_tail = stsr;
}
+ StreamTcpSackPruneList(stream);
end:
SCReturnInt(0);
}
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 1, 10);
StreamTcpSackInsertRange(&stream, 10, 20);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 10, 20);
StreamTcpSackInsertRange(&stream, 1, 20);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 10, 20);
StreamTcpSackInsertRange(&stream, 5, 15);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 0, 20);
StreamTcpSackInsertRange(&stream, 30, 50);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 0, 20);
StreamTcpSackInsertRange(&stream, 30, 50);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 0, 9);
StreamTcpSackInsertRange(&stream, 11, 19);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 0, 9);
StreamTcpSackInsertRange(&stream, 11, 19);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 0, 9);
StreamTcpSackInsertRange(&stream, 11, 19);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 100;
StreamTcpSackInsertRange(&stream, 0, 9);
StreamTcpSackInsertRange(&stream, 11, 19);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 1000;
StreamTcpSackInsertRange(&stream, 100, 119);
StreamTcpSackInsertRange(&stream, 111, 119);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 1000;
StreamTcpSackInsertRange(&stream, 100, 119);
StreamTcpSackInsertRange(&stream, 111, 119);
int retval = 0;
memset(&stream, 0, sizeof(stream));
+ stream.window = 2000;
StreamTcpSackInsertRange(&stream, 800, 1000);
StreamTcpSackInsertRange(&stream, 700, 900);
SCReturnInt(retval);
}
+/**
+ * \test Test the insertion on out of window condition.
+ *
+ * \retval On success it returns 1 and on failure 0.
+ */
+
+static int StreamTcpSackTest13 (void) {
+ TcpStream stream;
+ int retval = 0;
+ int i;
+
+ memset(&stream, 0, sizeof(stream));
+ stream.last_ack = 10000;
+ stream.window = 2000;
+
+ for (i = 0; i < 10; i++) {
+ StreamTcpSackInsertRange(&stream, 100+(20*i), 110+(20*i));
+ }
+#ifdef DEBUG
+ StreamTcpSackPrintList(&stream);
+#endif /* DEBUG */
+
+ if (StreamTcpSackedSize(&stream) != 0) {
+ printf("Sacked size is %u: ", StreamTcpSackedSize(&stream));
+ goto end;
+ }
+
+ retval = 1;
+end:
+ SCReturnInt(retval);
+}
+
+/**
+ * \test Test the insertion of out of window condition.
+ *
+ * \retval On success it returns 1 and on failure 0.
+ */
+
+static int StreamTcpSackTest14 (void) {
+ TcpStream stream;
+ int retval = 0;
+ int i;
+
+ memset(&stream, 0, sizeof(stream));
+ stream.last_ack = 1000;
+ stream.window = 2000;
+
+ for (i = 0; i < 10; i++) {
+ StreamTcpSackInsertRange(&stream, 4000+(20*i), 4010+(20*i));
+ }
+#ifdef DEBUG
+ StreamTcpSackPrintList(&stream);
+#endif /* DEBUG */
+
+ if (StreamTcpSackedSize(&stream) != 0) {
+ printf("Sacked size is %u: ", StreamTcpSackedSize(&stream));
+ goto end;
+ }
+
+ retval = 1;
+end:
+ SCReturnInt(retval);
+}
+
#endif /* UNITTESTS */
void StreamTcpSackRegisterTests (void)
StreamTcpSackTest11, 1);
UtRegisterTest("StreamTcpSackTest12 -- Insertion && Pruning",
StreamTcpSackTest12, 1);
+ UtRegisterTest("StreamTcpSackTest13 -- Insertion out of window",
+ StreamTcpSackTest13, 1);
+ UtRegisterTest("StreamTcpSackTest14 -- Insertion out of window",
+ StreamTcpSackTest14, 1);
#endif
}