35 #include <sys/types.h> 40 #include <netinet/in.h> 42 #include <openssl/crypto.h> 84 #define BRO_TYPE_UNKNOWN 0 85 #define BRO_TYPE_BOOL 1 86 #define BRO_TYPE_INT 2 87 #define BRO_TYPE_COUNT 3 88 #define BRO_TYPE_COUNTER 4 89 #define BRO_TYPE_DOUBLE 5 90 #define BRO_TYPE_TIME 6 91 #define BRO_TYPE_INTERVAL 7 92 #define BRO_TYPE_STRING 8 93 #define BRO_TYPE_PATTERN 9 94 #define BRO_TYPE_ENUM 10 95 #define BRO_TYPE_TIMER 11 96 #define BRO_TYPE_PORT 12 97 #define BRO_TYPE_IPADDR 13 98 #define BRO_TYPE_SUBNET 14 99 #define BRO_TYPE_ANY 15 100 #define BRO_TYPE_TABLE 16 101 #define BRO_TYPE_UNION 17 102 #define BRO_TYPE_RECORD 18 103 #define BRO_TYPE_LIST 19 104 #define BRO_TYPE_FUNC 20 105 #define BRO_TYPE_FILE 21 106 #define BRO_TYPE_VECTOR 22 107 #define BRO_TYPE_ERROR 23 108 #define BRO_TYPE_PACKET 24 109 #define BRO_TYPE_SET 25 110 #define BRO_TYPE_MAX 26 115 #define BRO_CFLAG_NONE 0 116 #define BRO_CFLAG_RECONNECT (1 << 0) 117 #define BRO_CFLAG_ALWAYS_QUEUE (1 << 1) 118 #define BRO_CFLAG_SHAREABLE (1 << 2) 119 #define BRO_CFLAG_DONTCACHE (1 << 3) 120 #define BRO_CFLAG_YIELD (1 << 4) 121 #define BRO_CFLAG_CACHE (1 << 5) 210 typedef struct CRYPTO_dynlock_value* (*OpenSSL_dynlock_create_func) (
const char *file,
int line);
223 const char *file,
int line);
235 const char *file,
int line);
310 #define BRO_PCAP_SUPPORT 311 #ifdef BRO_PCAP_SUPPORT 648 const char *type_name,
const void *val);
669 int type,
const char *type_name,
765 const char *event_name,
784 const char *event_name,
1208 int type,
const char *type_name,
1280 int type,
const char *type_name,
1301 int type,
const char *type_name,
1325 int key_type,
const void *key,
1326 int val_type,
const void *val);
1336 int *key_type,
int *val_type);
1415 int type,
const char *type_name,
1459 int type,
const char *type_name,
1464 #ifdef BRO_PCAP_SUPPORT void(* BroCompactEventFunc)(BroConn *bc, void *user_data, BroEvMeta *meta)
BroCompactEventFunc - The signature of compact event callbacks.
Definition: broccoli.h:167
Initialization context for the Broccoli library.
Definition: broccoli.h:242
OpenSSL_dynlock_lock_func dl_lock_func
Definition: broccoli.h:246
uint64_t uint64
Definition: broccoli.h:127
void * bro_table_find(BroTable *tbl, const void *key)
int(* BroSetCallback)(void *val, void *user_data)
BroTableCallback - The signature of callbacks for iterating over sets.
Definition: broccoli.h:1349
unsigned long(* OpenSSL_thread_id_func)(void)
OpenSSL_thread_id_func - thread ID function for OpenSSL thread safeness.
Definition: broccoli.h:199
uint32 addr[4]
IP address in network byte order.
Definition: broccoli.h:277
IP addresses are 16-bytes in network byte order.
Definition: broccoli.h:275
Statistical properties of a given connection.
Definition: broccoli.h:251
void * bro_conn_data_del(BroConn *bc, const char *key)
bro_conn_data_del - Removes a data item.
unsigned char uchar
Definition: broccoli.h:131
uchar * bro_buf_get_end(BroBuf *buf)
bro_buf_get_end - Returns pointer to the end of the buffer.
int bro_debug_calltrace
bro_debug_calltrace - Debugging output switch for call tracing.
void bro_table_free(BroTable *tbl)
uchar * bro_buf_ptr_get(BroBuf *buf)
bro_buf_ptr_get - Returns current buffer content pointer.
BroStrings are used to access string parameters in received events.
Definition: broccoli.h:258
int bro_conf_get_int(const char *val_name, int *val)
bro_conf_get_int - Retrieves an integer from the configuration.
int bro_record_set_nth_val(BroRecord *rec, int num, int type, const char *type_name, const void *val)
bro_record_set_nth_val - Replaces a value in a record, identified by field index. ...
double pkt_time
Definition: broccoli.h:319
uint8_t uint8
Definition: broccoli.h:130
BroConn * bro_conn_new(struct in_addr *ip_addr, uint16 port, int flags)
bro_conn_new - Creates and returns a handle for a connection to a remote Bro.
struct bro_event BroEvent
Definition: broccoli.h:134
struct bro_addr BroAddr
IP addresses are 16-bytes in network byte order.
struct bro_subnet BroSubnet
Subnets are a 16-byte address with a prefix width in bits.
int bro_string_set(BroString *bs, const char *s)
bro_string_set - Sets a BroString's contents.
Encapsulation of arguments passed to an event callback, for the compact style of argument passing...
Definition: broccoli.h:291
struct bro_string BroString
BroStrings are used to access string parameters in received events.
BroConn * bro_conn_new_str(const char *hostname, int flags)
bro_conn_new_str - Same as bro_conn_new(), but accepts strings for hostname and port.
struct bro_vector BroVector
Definition: broccoli.h:139
int bro_conn_alive(const BroConn *bc)
bro_conn_alive - Reports whether a connection is currently alive or has died.
uint bro_buf_get_used_size(BroBuf *buf)
bro_buf_get_used_size - Returns number of bytes currently used.
int bro_vector_get_length(BroVector *vec)
bro_vector_get_length - Returns number of elements in vector.
int bro_conn_reconnect(BroConn *bc)
bro_conn_reconnect - Drop the current connection and reconnect, reusing all settings.
int bro_event_send_raw(BroConn *bc, const uchar *data, int data_len)
bro_event_send_raw - Enqueues a serialized event directly into a connection's send buffer...
OpenSSL_dynlock_create_func dl_create_func
Definition: broccoli.h:245
void(* OpenSSL_dynlock_free_func)(struct CRYPTO_dynlock_value *mutex, const char *file, int line)
OpenSSL_dynlock_free_func - dynamic lock deallocator, for OpenSSL thread safeness.
Definition: broccoli.h:234
void bro_conn_get_packet_ctxt(BroConn *bc, int *link_type)
bro_conn_get_packet_ctxt - Gets current packet context for connection.
void bro_packet_free(BroPacket *packet)
bro_packet_free - Releases a packet.
uint bro_buf_get_size(BroBuf *buf)
bro_buf_get_size - Returns number of bytes allocated for buffer.
BroTable * bro_table_new(void)
void bro_string_free(BroString *bs)
bro_string_free - Cleans up dynamically allocated BroString.
int bro_debug_messages
bro_debug_messages - Output switch for debugging messages.
uint32 pkt_link_type
Definition: broccoli.h:321
int bro_conn_get_fd(BroConn *bc)
bro_conn_get_fd - Returns file descriptor of a Bro connection.
void bro_conn_adopt_events(BroConn *src, BroConn *dst)
bro_conn_adopt_events - Makes one connection send out the same events as another. ...
int bro_record_set_named_val(BroRecord *rec, const char *name, int type, const char *type_name, const void *val)
bro_record_set_named_val - Replaces a value in a record, identified by name.
int bro_buf_ptr_write(BroBuf *buf, void *data, int size)
bro_buf_ptr_write - Writes a number of bytes into buffer.
int tx_buflen
Number of bytes to process in output buffer.
Definition: broccoli.h:252
uchar * bro_buf_get(BroBuf *buf)
bro_buf_get - Returns pointer to actual start of buffer.
void bro_record_free(BroRecord *rec)
bro_record_free - Releases a record.
int bro_buf_append(BroBuf *buf, void *data, int data_len)
bro_buf_append - appends data to the end of the buffer.
void bro_buf_free(BroBuf *buf)
bro_buf_free - Releases a dynamically allocated buffer object.
struct pcap_pkthdr pkt_pcap_hdr
Definition: broccoli.h:323
void bro_event_registry_add_compact(BroConn *bc, const char *event_name, BroCompactEventFunc func, void *user_data)
bro_event_registry_add_compact - Adds a compact-argument event callback to the event registry...
BroString * bro_string_copy(BroString *bs)
bro_string_copy - Duplicates a BroString.
void bro_conn_get_connstats(const BroConn *bc, BroConnStats *cs)
bro_conn_get_connstats - Reports connection properties.
int bro_event_queue_length(BroConn *bc)
bro_event_queue_length - Returns current queue length.
void bro_conn_data_set(BroConn *bc, const char *key, void *val)
bro_conn_data_set - Puts a data item into the registry.
int bro_buf_ptr_read(BroBuf *buf, void *data, int size)
bro_buf_ptr_read - Extracts a number of bytes from buffer.
void bro_buf_consume(BroBuf *buf)
bro_buf_consume - shrinks the buffer.
int bro_set_insert(BroSet *set, int type, const void *val)
const char * pkt_tag
Definition: broccoli.h:325
int bro_vector_set_nth_val(BroVector *vec, int num, int type, const char *type_name, const void *val)
bro_vector_set_nth_val - Replaces a value in a vector, identified by index.
BroBuf * bro_buf_new(void)
bro_buf_new - Creates a new buffer object.
uint32 bro_string_get_length(const BroString *bs)
bro_string_get_length - Returns string's length.
int bro_conn_connect(BroConn *bc)
bro_conn_connect - Establish connection to peer.
void * bro_conn_data_get(BroConn *bc, const char *key)
bro_conn_data_get - Looks up a data item.
struct bro_table BroTable
Definition: broccoli.h:137
int arg_type
A BRO_TYPE_xxx constant.
Definition: broccoli.h:294
BroSet * bro_set_new(void)
const u_char * pkt_data
Definition: broccoli.h:324
void bro_conf_set_domain(const char *domain)
bro_conf_set_domain - Sets the current domain to use in a config file.
BroPacket * bro_packet_new(const struct pcap_pkthdr *hdr, const u_char *data, const char *tag)
bro_packet_new - Creates a new packet.
int bro_record_get_length(BroRecord *rec)
bro_record_get_length - Returns number of fields in record.
Subnets are a 16-byte address with a prefix width in bits.
Definition: broccoli.h:282
uint32 bro_buf_ptr_tell(BroBuf *buf)
bro_buf_ptr_tell - Returns current offset of buffer content pointer.
uint16_t uint16
Definition: broccoli.h:129
double bro_util_current_time(void)
bro_util_current_time - Gets current time.
uint32_t uint32
Definition: broccoli.h:128
struct CRYPTO_dynlock_value *(* OpenSSL_dynlock_create_func)(const char *file, int line)
OpenSSL_dynlock_create_func - allocator for dynamic locks, for OpenSSL thread safeness.
Definition: broccoli.h:210
void(* OpenSSL_dynlock_lock_func)(int mode, struct CRYPTO_dynlock_value *mutex, const char *file, int line)
OpenSSL_dynlock_lock_func - lock/unlock dynamic locks, for OpenSSL thread safeness.
Definition: broccoli.h:222
BroConn * bro_conn_new6(struct in6_addr *ip_addr, uint16 port, int flags)
bro_conn_new6 - Creates and returns a handle for a connection to a remote Bro.
uint32 str_len
Definition: broccoli.h:259
void bro_event_registry_add(BroConn *bc, const char *event_name, BroEventFunc func, void *user_data)
bro_event_registry_add - Adds an expanded-argument event callback to the event registry.
struct bro_record BroRecord
Definition: broccoli.h:136
OpenSSL_lock_func lock_func
Definition: broccoli.h:243
int bro_event_add_val(BroEvent *be, int type, const char *type_name, const void *val)
bro_event_add_val - Adds a parameter to an event.
struct bro_table BroSet
Definition: broccoli.h:138
BroPacket * bro_packet_clone(const BroPacket *packet)
bro_packet_clone - Clones a packet.
struct bro_ev_arg BroEvArg
Encapsulation of arguments passed to an event callback, for the compact style of argument passing...
int port_proto
IPPROTO_xxx.
Definition: broccoli.h:268
Broccoli can send and receive pcap-captured packets, wrapped into the following structure: ...
Definition: broccoli.h:317
struct bro_port BroPort
Ports in Broccoli do not only consist of a number but also indicate whether they are TCP or UDP...
void(* BroPacketFunc)(BroConn *bc, void *user_data, const BroPacket *packet)
Definition: broccoli.h:169
OpenSSL_thread_id_func id_func
Definition: broccoli.h:244
void bro_string_cleanup(BroString *bs)
bro_string_cleanup - Cleans up existing BroString.
int bro_event_send(BroConn *bc, BroEvent *be)
bro_event_send - Tries to send an event to a Bro agent.
uint32 sn_width
Length of prefix to consider.
Definition: broccoli.h:285
int bro_table_get_size(BroTable *tbl)
int rx_buflen
Number of bytes to process in input buffer.
Definition: broccoli.h:253
int bro_set_get_size(BroSet *set)
void * arg_data
Pointer to the actual event argument.
Definition: broccoli.h:293
BroRecord * bro_record_new(void)
bro_record_new - Creates a new record.
BroVector * bro_vector_new(void)
bro_vector_new - Creates a new vector.
void * bro_record_get_named_val(BroRecord *rec, const char *name, int *type)
bro_record_get_named_val - Retrieves a value from a record by field name.
void * bro_vector_get_nth_val(BroVector *vec, int num, int *type)
bro_vector_get_nth_val - Retrieves a value from a vector by index.
uint32 pkt_hdr_size
Definition: broccoli.h:320
void bro_set_get_type(BroSet *set, int *type)
struct bro_buf BroBuf
Definition: broccoli.h:135
void bro_event_registry_remove(BroConn *bc, const char *event_name)
bro_event_registry_remove - Removes an event handler.
uint64 port_num
Port number in host byte order.
Definition: broccoli.h:267
const uchar * bro_string_get_data(const BroString *bs)
bro_string_get_data - Returns pointer to the string data.
void bro_buf_reset(BroBuf *buf)
bro_buf_reset - resets the buffer.
Ports in Broccoli do not only consist of a number but also indicate whether they are TCP or UDP...
Definition: broccoli.h:266
int bro_event_set_val(BroEvent *be, int val_num, int type, const char *type_name, const void *val)
bro_event_set_val - Replace a value in an event.
void bro_event_registry_request(BroConn *bc)
bro_event_registry_request - Notifies peering Bro to send events.
void bro_conn_set_packet_ctxt(BroConn *bc, int link_type)
bro_conn_set_packet_ctxt - Sets current packet context for connection.
const char * bro_record_get_nth_name(BroRecord *rec, int num)
bro_record_get_nth_name - Retrieves a name from a record by field index.
int bro_event_queue_flush(BroConn *bc)
bro_event_queue_flush - Tries to flush the send queue of a connection.
int bro_record_add_val(BroRecord *rec, const char *name, int type, const char *type_name, const void *val)
bro_record_add_val - Adds a value to a record.
const char * bro_conf_get_str(const char *val_name)
bro_conf_get_str - Retrieves an integer from the configuration.
void bro_event_free(BroEvent *be)
bro_event_free - Releases all memory associated with an event.
void bro_set_free(BroSet *set)
void bro_table_get_types(BroTable *tbl, int *key_type, int *val_type)
int bro_string_set_data(BroString *bs, const uchar *data, int data_len)
bro_string_set_data - Sets a BroString's contents.
void bro_ctx_init(BroCtx *ctx)
bro_ctx_init - Initializes initialization context to default values.
int bro_set_find(BroSet *set, const void *key)
int bro_conn_process_input(BroConn *bc)
bro_conn_process_input - Processes input sent to the sensor by Bro.
int bro_event_queue_length_max(BroConn *bc)
bro_event_queue_length_max - Returns maximum queue length.
void(* OpenSSL_lock_func)(int mode, int n, const char *file, int line)
OpenSSL_lockfunc - locking function for OpenSSL thread safeness.
Definition: broccoli.h:190
int bro_init(const BroCtx *ctx)
bro_init - Initializes the library.
double bro_util_timeval_to_double(const struct timeval *tv)
bro_util_timeval_to_double - Converts timeval struct to double.
struct bro_conn_stats BroConnStats
Statistical properties of a given connection.
int bro_util_is_v4_addr(const BroAddr *a)
bro_util_is_v4_addr - Checks if an address is IPv4.
const uint8 BRO_IPV4_MAPPED_PREFIX[12]
The standard 12-byte prefix of a 16-byte IPv6 address that indicates it's a mapped IPv4 address...
const char * bro_conn_get_peer_class(const BroConn *bc)
bro_conn_get_peer_class - Reports connection class indicated by peer.
struct bro_ctx BroCtx
Initialization context for the Broccoli library.
void bro_string_assign(BroString *src, BroString *dst)
bro_string_assign - Duplicates a BroString's content, assigning it to an existing one...
struct bro_conn BroConn
Definition: broccoli.h:133
void bro_table_foreach(BroTable *tbl, BroTableCallback cb, void *user_data)
void bro_conn_set_class(BroConn *bc, const char *classname)
bro_conn_set_class - Sets a connection's class identifier.
int(* BroTableCallback)(void *key, void *val, void *user_data)
BroTableCallback - The signature of callbacks for iterating over tables.
Definition: broccoli.h:1318
int bro_vector_add_val(BroVector *vec, int type, const char *type_name, const void *val)
bro_vector_add_val - Adds a value to a vector.
void bro_set_foreach(BroSet *set, BroSetCallback cb, void *user_data)
void bro_string_init(BroString *bs)
bro_string_init - Initializes an existing string structure.
int bro_table_insert(BroTable *tbl, int key_type, const void *key, int val_type, const void *val)
int bro_packet_send(BroConn *bc, BroPacket *packet)
bro_packet_send - Sends a packet over a given connection.
void(* BroEventFunc)(BroConn *bc, void *user_data,...)
BroEventFunc - The signature of expanded event callbacks.
Definition: broccoli.h:155
int bro_conf_get_dbl(const char *val_name, double *val)
bro_conf_get_dbl - Retrieves a double float from the configuration.
void * bro_record_get_nth_val(BroRecord *rec, int num, int *type)
bro_record_get_nth_val - Retrieves a value from a record by field index.
BroEvent * bro_event_new(const char *event_name)
bro_event_new - Creates a new empty event with a given name.
BroConn * bro_conn_new_socket(int socket, int flags)
bro_conn_new_socket - Same as bro_conn_new(), but uses existing socket.
int bro_buf_ptr_seek(BroBuf *buf, int offset, int whence)
bro_buf_ptr_seek - Adjusts buffer content pointer.
int bro_conn_delete(BroConn *bc)
bro_conn_delete - terminates and releases connection.
BroAddr sn_net
IP address in network byte order.
Definition: broccoli.h:284
void bro_vector_free(BroVector *vec)
bro_vector_free - Releases a vector.
int bro_buf_ptr_check(BroBuf *buf, int size)
bro_buf_ptr_check - Checks whether a number of bytes can be read.
uchar * str_val
Definition: broccoli.h:260
OpenSSL_dynlock_free_func dl_free_func
Definition: broccoli.h:247