Barrelfish
Functions
vm.c File Reference

Implements a virtual machine for executing compiled intermediate language byte code. More...

Functions

err_t calc (uint8_t *filter_code, int filter_len, uint8_t *packet_data, int packet_len, uint64_t *result_value, size_t *result_offset)
 Performs recursive execution of a subtree of the filter code. More...
 
bool execute_filter (uint8_t *filter_code, int filter_len, uint8_t *packet_data, int packet_len, int *error_out)
 Executes the specified filter on the given packet. More...
 

Detailed Description

Implements a virtual machine for executing compiled intermediate language byte code.

Function Documentation

err_t calc ( uint8_t *  filter_code,
int  filter_len,
uint8_t *  packet_data,
int  packet_len,
uint64_t *  result_value,
size_t *  result_offset 
)

Performs recursive execution of a subtree of the filter code.

Parameters
filter_codePoints to the begining of the filter code
filter_lenSpecifies the length of the filter code in bytes
packet_dataPoints to the packet data to run the filter on
packet_lenSpecifies the length of the packet data in bytes
[out]result_valueReturn value of the subtree execution
[in]result_offsetInitially specifies the offset of the next byte to be executed in the filter code
[out]result_offsetSpecifies the next code byte to be executed, after the entire subtree code was executed
Returns
ERR_OK on success, other error values on failure; see header file for error types.
bool execute_filter ( uint8_t *  filter_code,
int  filter_len,
uint8_t *  packet_data,
int  packet_len,
int *  error_out 
)

Executes the specified filter on the given packet.

Parameters
filter_codePoints to the filters byte code
filter_lenLength of the byte code
packet_dataPoints to the packet data to run the filter on
packet_lenLength of packet data in bytes
[out]error_outError information upon failure during execution
Returns
true, if the filter executed successfully and the result was not zero. false otherwise.