mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
expanded ZAM operations for bit-shifting to allow for int/count shift values
This commit is contained in:
parent
01fe72d9fc
commit
7d25835ca8
1 changed files with 13 additions and 9 deletions
|
@ -37,15 +37,19 @@ binary-expr-op Mask
|
||||||
# Signal that this expression only has mixed-type evaluation.
|
# Signal that this expression only has mixed-type evaluation.
|
||||||
op-type X
|
op-type X
|
||||||
explicit-result-type
|
explicit-result-type
|
||||||
eval-mixed A I auto mask = static_cast<uint32_t>($2);
|
eval-mixed A I DoMask($$, $1, static_cast<uint32_t>($2))
|
||||||
auto a = $1->AsAddr();
|
eval-mixed A U DoMask($$, $1, $2)
|
||||||
if ( a.GetFamily() == IPv4 && mask > 32 )
|
|
||||||
ERROR(util::fmt("bad IPv4 subnet prefix length: %" PRIu32, mask));
|
macro DoMask(lhs, op1, op2)
|
||||||
if ( a.GetFamily() == IPv6 && mask > 128 )
|
auto mask = static_cast<uint32_t>(op2);
|
||||||
ERROR(util::fmt("bad IPv6 subnet prefix length: %" PRIu32, mask));
|
auto a = op1->AsAddr();
|
||||||
auto v = make_intrusive<SubNetVal>(a, mask);
|
if ( a.GetFamily() == IPv4 && mask > 32 )
|
||||||
Unref($$.AsSubNet());
|
ERROR(util::fmt("bad IPv4 subnet prefix length: %" PRIu32, mask));
|
||||||
$$.AsSubNetRef() = v.release();
|
if ( a.GetFamily() == IPv6 && mask > 128 )
|
||||||
|
ERROR(util::fmt("bad IPv6 subnet prefix length: %" PRIu32, mask));
|
||||||
|
auto v = make_intrusive<SubNetVal>(a, mask);
|
||||||
|
Unref(lhs.AsSubNet());
|
||||||
|
lhs.AsSubNetRef() = v.release();
|
||||||
|
|
||||||
binary-expr-op Mod
|
binary-expr-op Mod
|
||||||
op-type I U
|
op-type I U
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue