diff options
author | Andreas Lindhé <andreas@lindhe.io> | 2017-10-12 09:22:25 +0200 |
---|---|---|
committer | Andreas Lindhé <andreas@lindhe.io> | 2017-10-12 09:22:25 +0200 |
commit | 51048c85dd437d501ca82cdc7bb4edc4bb686100 (patch) | |
tree | 620d5a949d7df3145b74ad684aecd20ad4fd004a /broccoli/script | |
parent | 5ee780a929580db881467bb13ff9ad804cb4f1e9 (diff) | |
download | midbro-51048c85dd437d501ca82cdc7bb4edc4bb686100.tar.gz midbro-51048c85dd437d501ca82cdc7bb4edc4bb686100.tar.bz2 |
Make it possible to print less debug info
Diffstat (limited to 'broccoli/script')
-rw-r--r-- | broccoli/script/modbus.bro | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/broccoli/script/modbus.bro b/broccoli/script/modbus.bro index 33e87e6..0ed9de5 100644 --- a/broccoli/script/modbus.bro +++ b/broccoli/script/modbus.bro @@ -7,6 +7,9 @@ redef Communication::listen_port = 47760/tcp; redef Communication::listen_ssl = F; +## Global variables +global verbose=T; + ## DATA STRUCTURES export { @@ -48,11 +51,13 @@ redef Communication::nodes += { event pasad_register_received(data: RegisterData) { Log::write(Pasad::LOG, data); - print fmt("Received address=%d, register=%d", data$address, data$register); + if(verbose) + print fmt("Received address=%d, register=%d", data$address, data$register); } event pasad_unmatched_response(tid: count) { - print fmt("Unmatched response: tid=%d", tid); + if(verbose) + print fmt("Unmatched response: tid=%d", tid); } ## CUSTOM FUNCTIONS @@ -87,7 +92,8 @@ function pasad_generate_events(transaction: Transaction, c: connection, headers: ModbusHeaders, registers: ModbusRegisters, regtype: string) { # TODO: check registers size if (enable_filtering) { - print fmt("%d %d %d", filter_mem_addr, transaction$start_address, transaction$quantity); + if(verbose) + print fmt("%d %d %d", filter_mem_addr, transaction$start_address, transaction$quantity); pasad_generate_event(transaction, c, headers, registers, regtype, filter_mem_addr - transaction$start_address); } else { @@ -108,7 +114,8 @@ event bro_init() &priority=5 { event modbus_read_holding_registers_request(c: connection, headers: ModbusHeaders, start_address: count, quantity: count) { if (!pasad_check_filter(c$id$resp_h, start_address, quantity)) { - print fmt("Filtered %s/%d/%d", c$id$resp_h, start_address, quantity); + if(verbose) + print fmt("Filtered %s/%d/%d", c$id$resp_h, start_address, quantity); return; } @@ -123,7 +130,8 @@ event modbus_read_holding_registers_request(c: connection, event modbus_read_holding_registers_response(c: connection, headers: ModbusHeaders, registers: ModbusRegisters) { if (!pasad_check_filter(c$id$resp_h, 0, 0)) { - print fmt("Filtered %s", c$id$resp_h); + if(verbose) + print fmt("Filtered %s", c$id$resp_h); return; } |