/* Almost like ModbusInit, but not quite. */ static void ModbusReload(char *args) { modbus_config_t *modbus_policy = NULL; if (modbus_swap_context_id == NULL) { modbus_swap_context_id = sfPolicyConfigCreate(); if (modbus_swap_context_id == NULL) { _dpd.fatalMsg("Failed to allocate memory " "for Modbus config.\n"); } if (_dpd.streamAPI == NULL) { _dpd.fatalMsg("SetupModbus(): The Stream preprocessor " "must be enabled.\n"); } } modbus_policy = ModbusPerPolicyInit(modbus_swap_context_id); ParseModbusArgs(modbus_policy, args); /* Can't add ports until they've been parsed... */ ModbusAddPortsToPaf(modbus_policy, _dpd.getParserPolicy()); ModbusPrintConfig(modbus_policy); _dpd.addPreprocReloadVerify(ModbusReloadVerify); }
/* Almost like ModbusInit, but not quite. */ static void ModbusReload(struct _SnortConfig *sc, char *args, void **new_config) { tSfPolicyUserContextId modbus_swap_context_id = (tSfPolicyUserContextId)*new_config; modbus_config_t *modbus_policy = NULL; if (modbus_swap_context_id == NULL) { modbus_swap_context_id = sfPolicyConfigCreate(); if (modbus_swap_context_id == NULL) { _dpd.fatalMsg("Failed to allocate memory " "for Modbus config.\n"); } if (_dpd.streamAPI == NULL) { _dpd.fatalMsg("SetupModbus(): The Stream preprocessor " "must be enabled.\n"); } *new_config = (void *)modbus_swap_context_id; } modbus_policy = ModbusPerPolicyInit(sc, modbus_swap_context_id); ParseModbusArgs(modbus_policy, args); /* Can't add ports until they've been parsed... */ ModbusAddPortsToPaf(sc, modbus_policy, _dpd.getParserPolicy(sc)); ModbusPrintConfig(modbus_policy); }
/* Allocate memory for preprocessor config, parse the args, set up callbacks */ static void ModbusInit(char *argp) { modbus_config_t *modbus_policy = NULL; if (modbus_context_id == NULL) { ModbusOneTimeInit(); } modbus_policy = ModbusPerPolicyInit(modbus_context_id); ParseModbusArgs(modbus_policy, argp); /* Can't add ports until they've been parsed... */ ModbusAddPortsToPaf(modbus_policy, _dpd.getParserPolicy()); ModbusPrintConfig(modbus_policy); }
/* Allocate memory for preprocessor config, parse the args, set up callbacks */ static void ModbusInit(struct _SnortConfig *sc, char *argp) { modbus_config_t *modbus_policy = NULL; if (modbus_context_id == NULL) { ModbusOneTimeInit(sc); } modbus_policy = ModbusPerPolicyInit(sc, modbus_context_id); ParseModbusArgs(modbus_policy, argp); /* Can't add ports until they've been parsed... */ ModbusAddPortsToPaf(sc, modbus_policy, _dpd.getParserPolicy(sc)); #ifdef TARGET_BASED ModbusAddServiceToPaf(sc, modbus_app_id, _dpd.getParserPolicy(sc)); #endif // register ports with session and stream registerPortsForDispatch( sc, modbus_policy ); registerPortsForReassembly( modbus_policy, SSN_DIR_FROM_SERVER | SSN_DIR_FROM_CLIENT ); ModbusPrintConfig(modbus_policy); }