Commit graph

17750 commits

Author SHA1 Message Date
Gregor Maier
a9f28fab74 Minor tweaks for bif language.
* Bif language: Can now specify hex constants as explicit enumerators.
* Bifcl output files new also depend on the bifcl binary.
2011-02-10 13:14:24 -08:00
Gregor Maier
fdaeea0ea9 enum type: don't allow mixing of explicit value and auto-increment.
Updated enum type. New description:

Enum's are supported in .bif and .bro scripts.
An enum in a bif will become available in the event engine and
the policy layer.

It is possible to assign an explicit value to an enum enumerator
element, or the enum type can automatically assign values. However,
the styles cannot be mixed. If automatic assignement is used, the first
element will have a value of 0, the next will have a value of 1, etc.

Enum type variables and identifiers can be formated using the "%s"
format specifier, in which case the symbolic name will be printed.
If the "%d" format specifier is used, the numerical value is
printed.

Example automatic assignment:
    type foo: enum {
        BAR_A,      # value will be 0
        BAR_B,      # value will be 1
        BAR_C,      # value will be 2
    };

Example with explicit assignment:
    type foobar: enum {
        BAR_X = 10,      # value will be 10
        BAR_Y = 23,      # value will be 23
        BAR_Z = 42,      # value will be 42
    };

Enumerator values can only by positive integer literals.
The literals can be specified in (0x....), but not in octal (bro policy
layer limitation). So, do not use 0123 as value in bifs!

Each enumerator value can only be used once per enum (C allows
to use the same value multiple times).

All these restrictions are enforced by the policy script layer and not
the bif compiler!

Enums can be redef'ed, i.e., extended. If the enum is automatic
increment assignment, then the value will continue to increment.
If the enum uses explicit assignment, then the redef need to use
explicit assignments as well.

Example 1::
    redef enum foo += {
        BAR_D,    # value will be 3
        BAR_E,    # value will be 4
        BAR_F,    # value will be 5
    };

Example 2::
    redef enum foobar += {
        BAR_W = 100,
    };
2011-02-10 13:14:24 -08:00
Gregor Maier
72454c230b Add support for enum with explicit enumerator values.
* Adding support for enums with explicit enumerator values (see doc
  below) to bifcl and policy layer.

* Bifcl: remove (partially written) output files on error and
  do a nice exit(1) instead of harsh abort() on parse errors.

* CMakeText: if bifcl fails, remove output files (failsafe,
  in case bifcl fails to clean up after itself).

Enum description
----------------

Enum's are supported in .bif and .bro scripts.
An enum in a bif will become available in the event engine and
the policy layer.

Enums are "C-style". The first element in an enum will have a
value of 0, the next value will be 1, etc.
It is possible to assign an enumerator value to an element. If
next element does not have an explicit value, its values will be
the value of the last element + 1

Example::
    type foo: enum {
        BAR_A,      # value will be  0
        BAR_B,      # value will be  1
        BAR_C = 10, # value will be 10
        BAR_D,      # value will be 11
    };

Enumerator values can only by positive integer literals.
The literals can be specified in (0x....), but not in octal (bro policy
layer limitation). So, do not use 0123 as value in bifs!

Each enumerator value can only be used once per enum (C allows
to use the same value multiple times). This makes reverse mapping from
value to name (e.g., in %s format strings) unambigious. This is enforced
in by the policy script.

Enums can be redef'ed, i.e., extended. Enumerator values will continue
to increment. If there are multiple redefs in different policy scripts,
then name <-> value mappings will obviously depend on the order in
which scripts are loaded (which might not be obvious).

Example::

    redef enum foo += {
        BAR_E,      # value will be 12
        BAR_F = 5,  # value will be  5
        BAR_G,      # value will be  6
    };
2011-02-10 13:14:24 -08:00
Gregor Maier
d6e6d6b650 Fixing endianess error in XDR when data is not 4-byte aligned. 2011-02-09 16:10:59 -08:00
Gregor Maier
2ced4839e9 Fix for Val constructor with new int64 typedefs.
Val::Val had prototypes for int, long, int64, etc. But depending on the
architecture some of those might be the same (int64 and long) thus
yielding a compile error.
Fix: only use int32, int64, etc. for prototype. ints and longs can still
be passed, since they will match one of these fixed-width types
regardless of platform.

Also fix some more compiler warnings with format strings.
2011-02-09 15:53:49 -08:00
Gregor Maier
2aae4eaf91 New fix for OS X 10.5 compile error wrt llabs() 2011-02-09 15:52:32 -08:00
Gregor Maier
104c7da205 Revert "Fix for OS X 10.5 compile error wrt llabs()"
This reverts commit 3f6aa735e9.

Using abs() does not work if the integer is >2^32 (or <2^32).
Will add a new fix in next commit.
2011-02-09 15:40:36 -08:00
Seth Hall
ffa494e428 Fixed an off-by-one error in join_string_vec 2011-02-09 15:18:12 -05:00
Seth Hall
e0c65cc8f9 Initial functional implementation of logging framework.
The policy/test-logging.bro script has the first usage
of the logging code and is commented to indicate
current problems and limitations.
2011-02-09 12:22:26 -05:00
Robin Sommer
2f7fa3470b Merge remote branch 'origin/topic/seth/fix-compiler-warnings'
* origin/topic/seth/fix-compiler-warnings:
  Fixed problem with PRI macros.
  PRI macros are currently not working for some reason.
  Two more small compile time error fixes.
  Cleaned up the output from running binpac.
  Added line to expect shift/reduce errors in parse.in
  Cleaned up g++ warnings.

Addition: I fixed a few more warnings I was getting, and tweaked some
of the existing changes slightly.
2011-02-09 08:10:41 -08:00
Robin Sommer
bf76811776 Merge remote branch 'remotes/origin/topic/robin/work'
* remotes/origin/topic/robin/work:
  *Now* this passes the test suite.
  Fixes to SSL/TLS analyzer
  Added new TLS ciphers
  Removing some apparently unnecessary lines.
  A few smaller tweaks.
  Prepared the old analyzer for extracting SSL extensions.
  Fixed bug in do_split implementation.
  Removed an accidental debugging printf.
  Readded the other changes to remove CheckString calls from strings.bif.
  Fixed the problem with do_split function which caused it to bail 1 separator early.
  Modification from rmkml to support SSL extensions.
  Updated SSL analyzer and Bro script with lots of new ciphers.
2011-02-08 20:25:13 -08:00
Robin Sommer
53940f0a1c Merge remote branch 'remotes/origin/topic/seth/strings-without-checkstring' into topic/robin/work
* remotes/origin/topic/seth/strings-without-checkstring:
  *Now* this passes the test suite.
  Removing some apparently unnecessary lines.
  A few smaller tweaks.
  Fixed bug in do_split implementation.
  Removed an accidental debugging printf.
  Readded the other changes to remove CheckString calls from strings.bif.
  Fixed the problem with do_split function which caused it to bail 1 separator early.
2011-02-08 19:36:32 -08:00
Seth Hall
b54445b725 Fixed problem with PRI macros.
Thanks Gregor!
2011-02-08 20:28:56 -05:00
Robin Sommer
337379c1b2 Merge remote branch 'origin/topic/seth/ssl-analyzer-work' into topic/robin/work
* origin/topic/seth/ssl-analyzer-work:
  Fixes to SSL/TLS analyzer
  Added new TLS ciphers
  Prepared the old analyzer for extracting SSL extensions.
  Modification from rmkml to support SSL extensions.
  Updated SSL analyzer and Bro script with lots of new ciphers.
2011-02-08 16:26:01 -08:00
Robin Sommer
888719e922 Adding new aux/btest submodule. 2011-02-08 14:28:15 -08:00
Robin Sommer
0240715821 Adding new aux/btest submodule. 2011-02-08 14:22:23 -08:00
Seth Hall
c985aa9d82 Merge remote branch 'origin/topic/robin/optional-fields' into topic/logging-framework 2011-02-08 16:18:26 -05:00
Seth Hall
9c62052953 Merge branch 'topic/logging-framework' of ssh://git.icir.org/bro into topic/logging-framework 2011-02-08 16:15:01 -05:00
Seth Hall
d7786a6576 Checkpoint 2011-02-08 15:49:06 -05:00
Seth Hall
275c6e64cc PRI macros are currently not working for some reason. 2011-02-08 12:47:10 -05:00
Robin Sommer
7f4e13248d Fixing crashes when SSL is not configured correctly. 2011-02-07 22:13:29 -08:00
Robin Sommer
4854ff60e5 A quick hack switching Bro back to 32-bit ints so that Broccoli works. 2011-02-07 22:13:01 -08:00
Robin Sommer
3942b253cc Adding a test for SSL-based communciation to the istate testsuite. 2011-02-07 21:47:29 -08:00
Robin Sommer
2f30c3d245 Adding some tests for the record-extension feature.
These will go somewhere else eventually, just making sure they don't
get lost.
2011-02-07 16:10:09 -08:00
Robin Sommer
95069f0993 Implementing += operator for record types.
This is per #375.

Record types can now get additional fields later via '+='. The added
fields must however either be &optional or have a &default value.

Example:

    type Foo: record {
        a: count;
        b: count &optional;
    };

    redef record Foo += {
        c: count &default=42;
        d: count &optional;
    };

    global f: Foo = [$a=21];

    print f;

Output:

    [a=21, b=<uninitialized>, c=42, d=<uninitialized>]
2011-02-07 16:06:27 -08:00
Robin Sommer
cdb20e61b7 Teaching bifcl to accept scoped IDs. 2011-02-07 15:00:19 -08:00
Robin Sommer
f43766650f Fixing hashing records with optional strings. 2011-02-07 14:46:49 -08:00
Robin Sommer
0dbbee46ae Teaching bifcl to accept scoped IDs. 2011-02-07 14:46:28 -08:00
Robin Sommer
0d9de7d719 Updating submodule(s). 2011-02-07 14:07:29 -08:00
Robin Sommer
abc365e38f Merge remote branch 'origin/topic/robin/work'
* origin/topic/robin/work:
  Smarter way to increase the parent/child pipe's socket buffer. (Craig Leres).
  Fixing bug with defining bro_int_t and bro_uint_t as 64-bit in some platforms.
2011-02-07 13:44:45 -08:00
Seth Hall
205d84b651 Merge remote branch 'origin/topic/robin/optional-fields' into topic/logging-framework 2011-02-06 00:24:11 -05:00
Robin Sommer
4d12ac861d Smarter way to increase the parent/child pipe's socket buffer. (Craig
Leres).

This is from #383.
2011-02-04 17:58:19 -08:00
Robin Sommer
51b3efbb1a Fixing bug with defining bro_int_t and bro_uint_t as 64-bit in some
platforms.
2011-02-04 17:39:38 -08:00
Robin Sommer
ee6abcba72 Updating submodule(s). 2011-02-03 21:57:11 -08:00
Robin Sommer
7abd8f177f Fixing a problem with records having optional fields when used as
table/set indices.

This addresses #367. In principle, the fix is quite straightford.
However, it turns out that sometimes record fields lost their
attributes on assignment, and then the hashing can't decide anymore
whether a field is optional or not. So that needed to be fixed as
well.
2011-02-02 18:06:02 -08:00
Robin Sommer
e00acaddd8 Login's confused messages now go through weird.bro. 2011-01-31 16:42:36 -08:00
Robin Sommer
88b31a04d0 Updating submodule(s). 2011-01-31 15:36:01 -08:00
Seth Hall
65687d86d8 *Now* this passes the test suite.
I got the last fix wrong and I was still misunderstanding
one behavior of the existing do_split function.  When a
separator match goes to the last character of the string,
a blank string element should be appended to the
string_array to indicate that a successful split occurred.
2011-01-31 12:19:11 -05:00
Robin Sommer
7432761558 Updating submodule(s). 2011-01-31 08:48:41 -08:00
Robin Sommer
7de348da11 Merge remote branch 'origin/topic/jsiwek/missing-config-options'
* origin/topic/jsiwek/missing-config-options:
  Adding more configure options for finding dependencies

Conflicts:
	aux/binpac
2011-01-31 08:48:12 -08:00
Seth Hall
1ccfca09ac Fixes to SSL/TLS analyzer
Analyzer can cope with zero length client and server
certificates.  It does still generate a weird though.
Extended cipherspec_size weirds are not thrown anymore,
they are incredibly overwhelming and should be handled
completely at the scripting in my opinion.

Integrated and expanded on patch Rmkml from ticket #209
that fixes problem with not parsing or expecting SSL
extensions.  SSL extensions still are not extracted
and passed to script land, but the analyzer doesn't
fail anymore.
2011-01-28 16:24:07 -05:00
Seth Hall
c8076619ce Added new TLS ciphers 2011-01-28 16:18:57 -05:00
Robin Sommer
4b77164e04 Merge remote branch 'origin/fastpath'
* origin/fastpath:
  Fix typo in PCAPTests.cmake
2011-01-28 08:14:34 -08:00
Jon Siwek
da3fb85e5c Adding more configure options for finding dependencies 2011-01-28 10:10:16 -06:00
Jon Siwek
a19391b94b Fix typo in PCAPTests.cmake
With this correction, the configure tests should now be pulling
in the correct user-specified libpcap headers
2011-01-27 11:35:35 -06:00
Seth Hall
d2628d30fa Logging framework core functionality now implemented. 2011-01-26 15:29:20 -05:00
Robin Sommer
91d7c48ced Updating submodule(s). 2011-01-25 17:58:09 -08:00
Robin Sommer
50181edd84 Significant edit pass over ICMPv6 code.
Matti, more per mail.
2011-01-25 17:57:34 -08:00
Robin Sommer
8974265d39 Fixing bug in SMB analyzer. 2011-01-24 15:29:40 -08:00
Robin Sommer
2bf7461d9c Updating submodule(s). 2011-01-24 15:21:39 -08:00