]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Fix configure.ac compiler search order for OSX. Add Piglet tests for codecs and...
authorVictor Roemer <viroemer@cisco.com>
Tue, 8 Sep 2015 22:46:58 +0000 (18:46 -0400)
committerVictor Roemer <viroemer@cisco.com>
Thu, 10 Sep 2015 19:47:44 +0000 (15:47 -0400)
Updated documentation to reflect compiler search order.

Added piglet test for icmp and udp.

14 files changed:
configure.ac
doc/bugs.txt
doc/start.txt
piglet/tests/instance/codec_icmp.lua [new file with mode: 0644]
piglet/tests/instance/codec_icmp6.lua [new file with mode: 0644]
piglet/tests/instance/codec_ipv4.lua [moved from piglet/tests/instance/codec.lua with 100% similarity]
piglet/tests/instance/codec_ipv6.lua [new file with mode: 0644]
piglet/tests/instance/codec_tcp.lua [new file with mode: 0644]
piglet/tests/instance/codec_udp.lua [new file with mode: 0644]
piglet/tests/instance/logger_csv.lua [new file with mode: 0644]
piglet/tests/instance/logger_fast.lua [new file with mode: 0644]
piglet/tests/instance/logger_full.lua [new file with mode: 0644]
src/codecs/ip/cd_tcp.cc
src/codecs/ip/cd_udp.cc

index a15b8e5f5a7ea329e8d987b6c5188fd9e7096b16..3c7f9b82742ef5b8307d304a428a2e3a36a676b8 100644 (file)
@@ -37,7 +37,7 @@ AM_INIT_AUTOMAKE(foreign nostdinc)
 
 LT_INIT
 
-AC_PROG_CXX
+AC_PROG_CXX([clang++ g++])
 AC_PROG_AWK
 AC_PROG_CC
 AC_PROG_CPP
index 30b866ad5b4b4c8ef454f77904d7169395a3037d..95fdf2203e9b05a8b3cefd9d9a05a17160d10fb1 100644 (file)
@@ -1,11 +1,11 @@
 ==== Build
 
-* configure bombs on OSX with g\++ wrapper to clang because g++ version < 4.8
-(compare g\++ -dumpversion and g++ --version)
+* configure will use clang++ by default if it is installed. 
+To compile with g++ instead:
 
-    workaround:  export CXX=clang++
+      export CXX=g++
 
-* export CXX=clang++ to build with clang; coughs up these warnings:
+* clang; coughs up these warnings:
 
     Wunused-but-set-variable is not understood by clang
     clang: warning: argument unused during compilation: '-pthread'
index 609022495b5d338a590c28f10ab6241f4fa9d5b6..5ecb5cc5c61c3e27f3a6d2da352e99b30a665136 100644 (file)
@@ -88,9 +88,9 @@ d. Or use ccmake directly to configure and generate from an arbitrary build
     ccmake -G "Eclipse CDT4 - Unix Makefiles" /path/to/Snort++/tree
     run eclipse and do File > Import > Existing Eclipse Project
 
-* To build with clang++ on OS X with gcc installed, do this first:
+* To build with g++ on OS X where clang is installed, do this first:
 
-    export CXX=clang++
+    export CXX=g++
 
 
 === Run
diff --git a/piglet/tests/instance/codec_icmp.lua b/piglet/tests/instance/codec_icmp.lua
new file mode 100644 (file)
index 0000000..7bf2a36
--- /dev/null
@@ -0,0 +1,63 @@
+plugin =
+{
+    type = "piglet",
+    name = "codec::icmp4",
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+        return run_tests(tests)
+    end
+}
+
+PROTOCOL_IDS = { 1 }
+
+tests =
+{
+    initialize = function()
+        assert(Codec)
+    end,
+
+    get_protocol_ids = function()
+        local rv = Codec.get_protocol_ids()
+        check.arrays_equal(PROTOCOL_IDS, rv)
+    end,
+
+    decode = function()
+        local daq = DAQHeader.new()
+        local rb = RawBuffer.new("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
+        local cd = CodecData.new()
+        local dd = DecodeData.new()
+
+        local rv = Codec.decode(daq, rb, cd, dd)
+        assert(not rv)
+    end,
+
+    log = function()
+        local rb = RawBuffer.new()
+        Codec.log(rb)
+        Codec.log(rb, 0)
+        print()
+    end,
+
+    encode = function()
+        local rb = RawBuffer.new()
+        local es = EncState.new()
+        local rb_buf = RawBuffer.new(128)
+        local buf = Buffer.new(rb_buf)
+
+        local rv = Codec.encode(rb, es, buf)
+        assert(rv)
+    end,
+
+    update = function()
+        local rb = RawBuffer.new(64)
+        assert(1)
+    end,
+
+    format = function()
+        local rb = RawBuffer.new()
+        local dd = DecodeData.new()
+
+        Codec.format(true, rb, dd)
+        Codec.format(false, rb, dd)
+    end
+}
diff --git a/piglet/tests/instance/codec_icmp6.lua b/piglet/tests/instance/codec_icmp6.lua
new file mode 100644 (file)
index 0000000..24571e0
--- /dev/null
@@ -0,0 +1,63 @@
+plugin =
+{
+    type = "piglet",
+    name = "codec::icmp6",
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+        return run_tests(tests)
+    end
+}
+
+PROTOCOL_IDS = { 58 }
+
+tests =
+{
+    initialize = function()
+        assert(Codec)
+    end,
+
+    get_protocol_ids = function()
+        local rv = Codec.get_protocol_ids()
+        check.arrays_equal(PROTOCOL_IDS, rv)
+    end,
+
+    decode = function()
+        local daq = DAQHeader.new()
+        local rb = RawBuffer.new("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
+        local cd = CodecData.new()
+        local dd = DecodeData.new()
+
+        local rv = Codec.decode(daq, rb, cd, dd)
+        assert(not rv)
+    end,
+
+    log = function()
+        local rb = RawBuffer.new()
+        Codec.log(rb)
+        Codec.log(rb, 0)
+        print()
+    end,
+
+    encode = function()
+        local rb = RawBuffer.new()
+        local es = EncState.new()
+        local rb_buf = RawBuffer.new(128)
+        local buf = Buffer.new(rb_buf)
+
+        local rv = Codec.encode(rb, es, buf)
+        assert(rv)
+    end,
+
+    update = function()
+        local rb = RawBuffer.new(64)
+        assert(1)
+    end,
+
+    format = function()
+        local rb = RawBuffer.new()
+        local dd = DecodeData.new()
+
+        Codec.format(true, rb, dd)
+        Codec.format(false, rb, dd)
+    end
+}
diff --git a/piglet/tests/instance/codec_ipv6.lua b/piglet/tests/instance/codec_ipv6.lua
new file mode 100644 (file)
index 0000000..59353fa
--- /dev/null
@@ -0,0 +1,77 @@
+plugin =
+{
+    type = "piglet",
+    name = "codec::ipv6",
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+        return run_tests(tests)
+    end
+}
+
+DATA_LINK_TYPES = { }
+PROTOCOL_IDS = { 0x86dd, 41 }
+
+tests =
+{
+    initialize = function()
+        assert(Codec)
+    end,
+
+    get_data_link_type = function()
+        local rv = Codec.get_data_link_type()
+        check.arrays_equal(DATA_LINK_TYPES, rv)
+    end,
+
+    get_protocol_ids = function()
+        local rv = Codec.get_protocol_ids()
+        check.arrays_equal(PROTOCOL_IDS, rv)
+    end,
+
+    decode = function()
+        local daq = DAQHeader.new()
+        local rb = RawBuffer.new("foobar")
+        local cd = CodecData.new()
+        local dd = DecodeData.new()
+
+        local rv = Codec.decode(daq, rb, cd, dd)
+        assert(not rv)
+    end,
+
+    log = function()
+        local rb = RawBuffer.new()
+        Codec.log(rb)
+        Codec.log(rb, 0)
+        print()
+    end,
+
+    encode = function()
+        local rb = RawBuffer.new()
+        local es = EncState.new()
+        local rb_buf = RawBuffer.new(128)
+        local buf = Buffer.new(rb_buf)
+
+        local rv = Codec.encode(rb, es, buf)
+        assert(rv)
+    end,
+
+    update = function()
+        local rb = RawBuffer.new(64)
+        assert(1)
+
+        -- FIXIT-H: checksum calculation is failing (temporarily set UPD_COOKED (0x1))
+        --local rv = Codec.update(0, 1, rb)
+        --assert(rv == 0)
+
+        -- FIXIT-H: checksum calculation is failing (temporarily set UPD_COOKED (0x1))
+        --local rv = Codec.update(0, 1, rb, 64)
+        --assert(rv == 0)
+    end,
+
+    format = function()
+        local rb = RawBuffer.new()
+        local dd = DecodeData.new()
+
+        Codec.format(true, rb, dd)
+        Codec.format(false, rb, dd)
+    end
+}
diff --git a/piglet/tests/instance/codec_tcp.lua b/piglet/tests/instance/codec_tcp.lua
new file mode 100644 (file)
index 0000000..201dd4b
--- /dev/null
@@ -0,0 +1,63 @@
+plugin =
+{
+    type = "piglet",
+    name = "codec::tcp",
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+        return run_tests(tests)
+    end
+}
+
+PROTOCOL_IDS = { 6 }
+
+tests =
+{
+    initialize = function()
+        assert(Codec)
+    end,
+
+    get_protocol_ids = function()
+        local rv = Codec.get_protocol_ids()
+        check.arrays_equal(PROTOCOL_IDS, rv)
+    end,
+
+    decode = function()
+        local daq = DAQHeader.new()
+        local rb = RawBuffer.new("foobar")
+        local cd = CodecData.new()
+        local dd = DecodeData.new()
+
+        local rv = Codec.decode(daq, rb, cd, dd)
+        assert(not rv)
+    end,
+
+    log = function()
+        local rb = RawBuffer.new()
+        Codec.log(rb)
+        Codec.log(rb, 0)
+        print()
+    end,
+
+    encode = function()
+        local rb = RawBuffer.new()
+        local es = EncState.new()
+        local rb_buf = RawBuffer.new(128)
+        local buf = Buffer.new(rb_buf)
+
+        local rv = Codec.encode(rb, es, buf)
+        assert(rv)
+    end,
+
+    update = function()
+        local rb = RawBuffer.new(64)
+        assert(1)
+    end,
+
+    format = function()
+        local rb = RawBuffer.new()
+        local dd = DecodeData.new()
+
+        Codec.format(true, rb, dd)
+        Codec.format(false, rb, dd)
+    end
+}
diff --git a/piglet/tests/instance/codec_udp.lua b/piglet/tests/instance/codec_udp.lua
new file mode 100644 (file)
index 0000000..cd33b7f
--- /dev/null
@@ -0,0 +1,63 @@
+plugin =
+{
+    type = "piglet",
+    name = "codec::udp",
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+        return run_tests(tests)
+    end
+}
+
+PROTOCOL_IDS = { 17 }
+
+tests =
+{
+    initialize = function()
+        assert(Codec)
+    end,
+
+    get_protocol_ids = function()
+        local rv = Codec.get_protocol_ids()
+        check.arrays_equal(PROTOCOL_IDS, rv)
+    end,
+
+    decode = function()
+        local daq = DAQHeader.new()
+        local rb = RawBuffer.new("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
+        local cd = CodecData.new()
+        local dd = DecodeData.new()
+
+        local rv = Codec.decode(daq, rb, cd, dd)
+        assert(not rv)
+    end,
+
+    log = function()
+        local rb = RawBuffer.new()
+        Codec.log(rb)
+        Codec.log(rb, 0)
+        print()
+    end,
+
+    encode = function()
+        local rb = RawBuffer.new()
+        local es = EncState.new()
+        local rb_buf = RawBuffer.new(128)
+        local buf = Buffer.new(rb_buf)
+
+        local rv = Codec.encode(rb, es, buf)
+        assert(rv)
+    end,
+
+    update = function()
+        local rb = RawBuffer.new(64)
+        assert(1)
+    end,
+
+    format = function()
+        local rb = RawBuffer.new()
+        local dd = DecodeData.new()
+
+        Codec.format(true, rb, dd)
+        Codec.format(false, rb, dd)
+    end
+}
diff --git a/piglet/tests/instance/logger_csv.lua b/piglet/tests/instance/logger_csv.lua
new file mode 100644 (file)
index 0000000..177f463
--- /dev/null
@@ -0,0 +1,53 @@
+plugin =
+{
+    type = "piglet",
+    name = "logger::alert_csv",
+    use_defaults = true,
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+
+        Logger.open()
+        local rv = run_tests(tests)
+        Logger.close()
+        return rv
+    end
+}
+
+IP4 = [[
+45  | 00  | 00  46 | 00 00 | 00 00 | 01 | 06
+00 00 | 00 00 00 01 | 00 00 00 02
+
+00 00 | 00 00 | 00 00 00 00 | 00 00 00 00 | 06 02
+00 00 ff ff | 00 00 | 00 00 | 00 00
+]]
+
+DATA = "abcdefghijklmnopqrstuvwxyz"
+
+tests =
+{
+    exists = function()
+        assert(Logger)
+    end,
+
+    reset = function()
+        Logger.reset()
+    end,
+
+    alert = function()
+        local p = packet.construct_ip4(IP4:encode_hex(), DATA)
+        local e = Event.new()
+
+        e:set { generator = 135, id = 2 }
+
+        Logger.alert(p, "foo", e)
+    end,
+    
+    log = function()
+        local p = packet.construct_ip4(IP4:encode_hex(), DATA)
+        local e = Event.new()
+
+        e:set { generator = 135, id = 2 }
+
+        Logger.log(p, "foo", e)
+    end
+}
diff --git a/piglet/tests/instance/logger_fast.lua b/piglet/tests/instance/logger_fast.lua
new file mode 100644 (file)
index 0000000..204117b
--- /dev/null
@@ -0,0 +1,53 @@
+plugin =
+{
+    type = "piglet",
+    name = "logger::alert_fast",
+    use_defaults = true,
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+
+        Logger.open()
+        local rv = run_tests(tests)
+        Logger.close()
+        return rv
+    end
+}
+
+IP4 = [[
+45  | 00  | 00  46 | 00 00 | 00 00 | 01 | 06
+00 00 | 00 00 00 01 | 00 00 00 02
+
+00 00 | 00 00 | 00 00 00 00 | 00 00 00 00 | 06 02
+00 00 ff ff | 00 00 | 00 00 | 00 00
+]]
+
+DATA = "abcdefghijklmnopqrstuvwxyz"
+
+tests =
+{
+    exists = function()
+        assert(Logger)
+    end,
+
+    reset = function()
+        Logger.reset()
+    end,
+
+    alert = function()
+        local p = packet.construct_ip4(IP4:encode_hex(), DATA)
+        local e = Event.new()
+
+        e:set { generator = 135, id = 2 }
+
+        Logger.alert(p, "foo", e)
+    end,
+    
+    log = function()
+        local p = packet.construct_ip4(IP4:encode_hex(), DATA)
+        local e = Event.new()
+
+        e:set { generator = 135, id = 2 }
+
+        Logger.log(p, "foo", e)
+    end
+}
diff --git a/piglet/tests/instance/logger_full.lua b/piglet/tests/instance/logger_full.lua
new file mode 100644 (file)
index 0000000..5fbe9a1
--- /dev/null
@@ -0,0 +1,53 @@
+plugin =
+{
+    type = "piglet",
+    name = "logger::alert_full",
+    use_defaults = true,
+    test = function()
+        dofile(SCRIPT_DIR .. "/../common.lua")
+
+        Logger.open()
+        local rv = run_tests(tests)
+        Logger.close()
+        return rv
+    end
+}
+
+IP4 = [[
+45  | 00  | 00  46 | 00 00 | 00 00 | 01 | 06
+00 00 | 00 00 00 01 | 00 00 00 02
+
+00 00 | 00 00 | 00 00 00 00 | 00 00 00 00 | 06 02
+00 00 ff ff | 00 00 | 00 00 | 00 00
+]]
+
+DATA = "abcdefghijklmnopqrstuvwxyz"
+
+tests =
+{
+    exists = function()
+        assert(Logger)
+    end,
+
+    reset = function()
+        Logger.reset()
+    end,
+
+    alert = function()
+        local p = packet.construct_ip4(IP4:encode_hex(), DATA)
+        local e = Event.new()
+
+        e:set { generator = 135, id = 2 }
+
+        Logger.alert(p, "foo", e)
+    end,
+    
+    log = function()
+        local p = packet.construct_ip4(IP4:encode_hex(), DATA)
+        local e = Event.new()
+
+        e:set { generator = 135, id = 2 }
+
+        Logger.log(p, "foo", e)
+    end
+}
index 9e3727b50088f1562e8d27ac191ddbae4d7e28cf..b3579ef43e04606205ae720a658ae72a01977365 100644 (file)
@@ -659,7 +659,7 @@ bool TcpCodec::encode(const uint8_t* const raw_in, const uint16_t /*raw_len*/,
         ps.len = htons((uint16_t)len);
         tcph_out->th_sum = checksum::tcp_cksum((uint16_t*)tcph_out, len, &ps);
     }
-    else
+    else if (ip_api.is_ip6())
     {
         checksum::Pseudoheader6 ps6;
         int len = buf.size();
index 434438aa2c5547c13eb660543715f4f625ebdf3f..5f71acca2221e9c72b2d398c932c7ae1ab00b400 100644 (file)
@@ -383,7 +383,7 @@ bool UdpCodec::encode(const uint8_t* const raw_in, const uint16_t /*raw_len*/,
         ps.len = udph_out->uh_len;
         udph_out->uh_chk = checksum::udp_cksum((uint16_t*)udph_out, len, &ps);
     }
-    else
+    else if (ip_api.is_ip6())
     {
         checksum::Pseudoheader6 ps6;
         const ip::IP6Hdr* const ip6h = ip_api.get_ip6h();