[Bro] binPAC : more than one &require attribute on a field

Vlad Grigorescu vladg at illinois.edu
Mon Nov 21 08:12:21 PST 2016


Hi François,

Thanks for reporting this. I'll need to think through some of the
implications a bit more closely.

If you'd be willing to share your patch, I'd be happy to take a look.
Thanks,

  --Vlad




François Pennaneach <francois.pennaneach at free.fr> writes:

> Hi all,
>
>
> I'm a Bro beginner. I got a small problem when writing binPAC. See below.
>
> I'm using master branch of binPAC.
>
>
> In the binPAC grammar, nothing prevents from applying many &requires 
> attributes to the same field.
> However,  in such a case the generated C++ code is incorrect.
>
> type MyArray = record {
>      a: uint16 &requires(c) &requires(d);
>      b: uint16;
> } &let {
>      c : uint16 = b * 2;
>      d : uint16 = b * 3;
> };
>
> The generated code is :
>      // Parse "a"
>      // Parse "b"
>      b_ = FixByteOrder(t_byteorder, *((uint16 const *) ((t_begin_of_data 
> + 2))));
>      // Evaluate 'let' and 'withinput' fields
>      d_ = b() * 3;
>      a_ = FixByteOrder(t_byteorder, *((uint16 const *) (t_begin_of_data)));
>      // Evaluate 'let' and 'withinput' fields
>
>      // Evaluate 'let' and 'withinput' fields
>      c_ = b() * 2;
>
>
> In pac_types.cc, only the last &requires attribute is kept, the previous 
> ones are forgotten.
> Replacing attr_requires_ of type Expr with a ListExpr solves the problem 
> and produces the (expected) C++ code below :
>
>      // Parse "a"
>      // Parse "b"
>      b_ = FixByteOrder(t_byteorder, *((uint16 const *) ((t_begin_of_data 
> + 2))));
>      // Evaluate 'let' and 'withinput' fields
>      c_ = b() * 2;
>      d_ = b() * 3;
>      a_ = FixByteOrder(t_byteorder, *((uint16 const *) (t_begin_of_data)));
>
>
> I have written a small patch for this problem. I can submit it if you 
> agree with my changes.
>
>
> Thank you.
>
> _______________________________________________
> Bro mailing list
> bro at bro-ids.org
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/bro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
Url : http://mailman.ICSI.Berkeley.EDU/pipermail/bro/attachments/20161121/0f8de2f0/attachment.bin 


More information about the Bro mailing list