On this page
math.bit_or
Bitwise OR of two values as unsigned 32-bit integers.
Syntax
Atlas Script
math.bit_or(value, operand)Parameters
value- Value written, converted, or evaluated by this method. Its required type and range are described in Remarks.
operand- Second operand of the bitwise operation, treated as an unsigned 32-bit integer.
Return value
See the remarks for the returned value and runtime behavior.
Remarks
Bitwise OR of two values as unsigned 32-bit integers. Each value is truncated toward zero and wrapped, so -1 is 0xFFFFFFFF.
Examples
Decode a payload into a struct.atlas
struct Message {
var kind;
var sequence;
var flags;
};
const string LAYOUT = "u8 kind; u16be sequence; u16be flags";
Message message;
event on_start() {
if (!network.capture("udp and udp.DstPort == 9000")) {
system.log("Network capture could not start");
}
}
event on_network_send() {
if (packet.copy_to(message, LAYOUT) && message.kind == 0x02) {
message.flags = math.bit_or(message.flags, 0x0004);
if (!packet.copy_from(message, LAYOUT)) {
system.log("The payload no longer fits the layout");
}
}
}