aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2015-05-22 09:03:01 +0200
committerLuca Deri <deri@ntop.org>2015-05-22 09:03:01 +0200
commit43bf9df219c8208abadb144857ebe83fe80b517b (patch)
tree6a5b8c88fe2eaa4300ad9eada55eb45127cc9937
parentdcf9af732d2f474cf68c9127f3ba1ab10bda728b (diff)
Improved testing application
Removed warning from the quic dissector Travis now runs regression tests
-rw-r--r--.travis.yml4
-rw-r--r--src/lib/protocols/quic.c108
-rwxr-xr-xtests/do.sh8
3 files changed, 63 insertions, 57 deletions
diff --git a/.travis.yml b/.travis.yml
index 4f6b549e4..b3142db9a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,4 +15,8 @@ before_script:
script:
- ./configure
- make
+
+after_script:
+ - cd tests
+ - ./do.sh
\ No newline at end of file
diff --git a/src/lib/protocols/quic.c b/src/lib/protocols/quic.c
index d363760b7..ca4b12fab 100644
--- a/src/lib/protocols/quic.c
+++ b/src/lib/protocols/quic.c
@@ -46,111 +46,111 @@
static void ndpi_int_quic_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
- ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_QUIC, NDPI_REAL_PROTOCOL);
+ ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_QUIC, NDPI_REAL_PROTOCOL);
}
static int connect_id(const unsigned char pflags)
{
- u_int cid_len;
+ u_int cid_len;
- switch (pflags & QUIC_CID_MASK)
+ switch (pflags & QUIC_CID_MASK)
{
case CID_LEN_8: cid_len = 8; break;
case CID_LEN_4: cid_len = 4; break;
case CID_LEN_1: cid_len = 1; break;
case CID_LEN_0: cid_len = 0; break;
default:
- return -1;
+ return -1;
}
- return cid_len + 1;
+ return cid_len + 1;
}
static int sequence(const unsigned char *payload)
{
- unsigned char conv[6] = {0};
- u_int seq_value = -1;
- int seq_lens;
- int cid_offs;
- int i;
+ unsigned char conv[6] = {0};
+ u_int seq_value = -1;
+ int seq_lens;
+ int cid_offs;
+ int i;
- switch (payload[0] & QUIC_SEQ_MASK)
+ switch (payload[0] & QUIC_SEQ_MASK)
{
case SEQ_LEN_6: seq_lens = 6; break;
case SEQ_LEN_4: seq_lens = 4; break;
case SEQ_LEN_2: seq_lens = 2; break;
case SEQ_LEN_1: seq_lens = 1; break;
default:
- return -1;
+ return -1;
}
- cid_offs = connect_id(payload[0]);
+ cid_offs = connect_id(payload[0]);
- if (cid_offs != -1 && seq_lens > 0)
+ if (cid_offs != -1 && seq_lens > 0)
{
- for (i = 0; i < seq_lens; i++)
- conv[i] = payload[cid_offs + i];
+ for (i = 0; i < seq_lens; i++)
+ conv[i] = payload[cid_offs + i];
- seq_value = SEQ_CONV(conv);
+ seq_value = SEQ_CONV(conv);
}
- return seq_value;
+ return seq_value;
}
void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
- struct ndpi_packet_struct *packet = &flow->packet;
- unsigned char *vers;
- int ver_offs;
+ struct ndpi_packet_struct *packet = &flow->packet;
+ unsigned char *vers;
+ int ver_offs;
- if(packet->udp != NULL)
+ if(packet->udp != NULL)
{
- u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
+ u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
- NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "calculating quic over udp.\n");
+ NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "calculating quic over udp.\n");
- if(((packet->payload[0] & 0xC2) != 0) || (!(sport == 80 || dport == 80 || sport == 443 || dport == 443)))
- goto exclude_quic;
+ if(((packet->payload[0] & 0xC2) != 0) || (!(sport == 80 || dport == 80 || sport == 443 || dport == 443)))
+ goto exclude_quic;
- /* Quic without version. First check if PUBLIC FLAGS & SEQ bytes are 0x0, SEQ must be greater than zero */
- if (((packet->payload[0] == 0x00) && (packet->payload[1] != 0x00)) || ((packet->payload[0] & QUIC_NO_V_RES_RSV) == 0))
+ /* Quic without version. First check if PUBLIC FLAGS & SEQ bytes are 0x0, SEQ must be greater than zero */
+ if (((packet->payload[0] == 0x00) && (packet->payload[1] != 0x00)) || ((packet->payload[0] & QUIC_NO_V_RES_RSV) == 0))
{
- if (sequence(packet->payload) < 1)
+ if (sequence(packet->payload) < 1)
{
- NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "exclude quic.\n");
- NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_QUIC);
+ NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "exclude quic.\n");
+ NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_QUIC);
}
- NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "found quic.\n");
- ndpi_int_quic_add_connection(ndpi_struct, flow);
+ NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "found quic.\n");
+ ndpi_int_quic_add_connection(ndpi_struct, flow);
}
- else if (packet->payload[0] & QUIC_VER_MASK)
+ else if (packet->payload[0] & QUIC_VER_MASK)
{
- ver_offs = connect_id(packet->payload[0]);
-
- if (ver_offs != -1){
- vers = packet->payload + ver_offs;
-
- if ((vers[0] == 'Q' && vers[1] == '0') &&
- ((vers[2] == '2' && (vers[3] == '5' || vers[3] == '4' || vers[3] == '3' || vers[3] == '2' ||
- vers[3] == '1' || vers[3] == '0')) ||
- (vers[2] == '1' && (vers[3] == '9' || vers[3] == '8' || vers[3] == '7' || vers[3] == '6' ||
- vers[3] == '5' || vers[3] == '4' || vers[3] == '3' || vers[3] == '2' ||
- vers[3] == '1' || vers[3] == '0')) ||
- (vers[2] == '0' && vers[3] == '9')))
-
- {
- NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "found quic.\n");
- ndpi_int_quic_add_connection(ndpi_struct, flow);
- }
- }
+ ver_offs = connect_id(packet->payload[0]);
+
+ if (ver_offs != -1){
+ vers = (unsigned char*)(packet->payload + ver_offs);
+
+ if ((vers[0] == 'Q' && vers[1] == '0') &&
+ ((vers[2] == '2' && (vers[3] == '5' || vers[3] == '4' || vers[3] == '3' || vers[3] == '2' ||
+ vers[3] == '1' || vers[3] == '0')) ||
+ (vers[2] == '1' && (vers[3] == '9' || vers[3] == '8' || vers[3] == '7' || vers[3] == '6' ||
+ vers[3] == '5' || vers[3] == '4' || vers[3] == '3' || vers[3] == '2' ||
+ vers[3] == '1' || vers[3] == '0')) ||
+ (vers[2] == '0' && vers[3] == '9')))
+
+ {
+ NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "found quic.\n");
+ ndpi_int_quic_add_connection(ndpi_struct, flow);
+ }
+ }
} else
{
exclude_quic:
- NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "exclude quic.\n");
- NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_QUIC);
+ NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "exclude quic.\n");
+ NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_QUIC);
}
}
}
diff --git a/tests/do.sh b/tests/do.sh
index e7d28aa9c..2af667551 100755
--- a/tests/do.sh
+++ b/tests/do.sh
@@ -1,7 +1,7 @@
READER=../example/ndpiReader
-
+RC=0
PCAPS=`cd pcap; /bin/ls *.pcap`
build_results() {
@@ -25,6 +25,7 @@ check_results() {
echo "$f\t ERROR"
echo "$CMD"
diff result/$f.out /tmp/reader.out
+ RC=1
fi
/bin/rm /tmp/reader.out
@@ -32,6 +33,7 @@ check_results() {
done
}
-
build_results
-check_results \ No newline at end of file
+check_results
+
+exit $RC \ No newline at end of file