if command.split(' ', 2)[0] in self.cmd_list:
if "pcap-file " in command:
try:
- parts = command.split(' ');
+ parts = command.split(' ')
except:
raise SuricataCommandException("Arguments to command '%s' is missing" % (command))
cmd, filename, output = parts[0], parts[1], parts[2]
tenant = None
if len(parts) > 3:
tenant = parts[3]
+ continuous = None
+ if len(parts) > 4:
+ continuous = parts[4]
if cmd != "pcap-file":
raise SuricataCommandException("Invalid command '%s'" % (command))
else:
arguments["output-dir"] = output
if tenant != None:
arguments["tenant"] = int(tenant)
+ if continuous != None:
+ arguments["continuous"] = continuous
elif "pcap-file-continuous " in command:
try:
- parts = command.split(' ');
+ parts = command.split(' ')
except:
raise SuricataCommandException("Arguments to command '%s' is missing" % (command))
cmd, filename, output = parts[0], parts[1], parts[2]
tenant = None
if len(parts) > 3:
tenant = parts[3]
- if cmd != "pcap-file":
+ if cmd != "pcap-file-continuous":
raise SuricataCommandException("Invalid command '%s'" % (command))
else:
arguments = {}
arguments["filename"] = filename
arguments["output-dir"] = output
- arguments["continuous"] = True
if tenant != None:
arguments["tenant"] = int(tenant)
elif "iface-stat" in command:
* \param cmd the content of command Arguments as a json_t object
* \param answer the json_t object that has to be used to answer
* \param data pointer to data defining the context here a PcapCommand::
+ * \param continuous If this should run in continuous mode
*/
-static TmEcode UnixSocketAddPcapFile(json_t *cmd, json_t* answer, void *data)
+static TmEcode UnixSocketAddPcapFileImpl(json_t *cmd, json_t* answer, void *data,
+ bool continuous)
{
PcapCommand *this = (PcapCommand *) data;
const char *filename;
const char *output_dir;
int tenant_id = 0;
- bool continuous = false;
time_t delay = 30;
time_t poll_interval = 5;
#ifdef OS_WIN32
tenant_id = json_number_value(targ);
}
- json_t *cont_arg = json_object_get(cmd, "continuous");
- if (cont_arg != NULL) {
- continuous = json_is_true(cont_arg);
- }
-
json_t *delay_arg = json_object_get(cmd, "delay");
if (delay_arg != NULL) {
if (!json_is_integer(delay_arg)) {
return TM_ECODE_OK;
}
+/**
+ * \brief Command to add a file to treatment list
+ *
+ * \param cmd the content of command Arguments as a json_t object
+ * \param answer the json_t object that has to be used to answer
+ * \param data pointer to data defining the context here a PcapCommand::
+ */
+static TmEcode UnixSocketAddPcapFile(json_t *cmd, json_t* answer, void *data)
+{
+ bool continuous = false;
+
+ json_t *cont_arg = json_object_get(cmd, "continuous");
+ if (cont_arg != NULL) {
+ continuous = json_is_true(cont_arg);
+ }
+
+ return UnixSocketAddPcapFileImpl(cmd, answer, data, continuous);
+}
+
+/**
+ * \brief Command to add a file to treatment list
+ *
+ * \param cmd the content of command Arguments as a json_t object
+ * \param answer the json_t object that has to be used to answer
+ * \param data pointer to data defining the context here a PcapCommand::
+ */
+static TmEcode UnixSocketAddPcapFileContinuous(json_t *cmd, json_t* answer, void *data)
+{
+ return UnixSocketAddPcapFileImpl(cmd, answer, data, true);
+}
+
/**
* \brief Handle the file queue
*
pcapcmd->current_file = NULL;
UnixManagerRegisterCommand("pcap-file", UnixSocketAddPcapFile, pcapcmd, UNIX_CMD_TAKE_ARGS);
+ UnixManagerRegisterCommand("pcap-file-continuous", UnixSocketAddPcapFileContinuous, pcapcmd, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("pcap-file-number", UnixSocketPcapFilesNumber, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-file-list", UnixSocketPcapFilesList, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-last-processed", UnixSocketPcapLastProcessed, pcapcmd, 0);