/**< Minimum log file limit in MB. */
#define MIN_LIMIT 1 * 1024 * 1024
+/* Default Sensor ID value */
+static uint32_t sensor_id = 0;
+
/**
* Unified2 file header struct
*
hdr->type = htonl(UNIFIED2_PACKET_TYPE);
aun->hdr = hdr;
- phdr->sensor_id = 0;
+ phdr->sensor_id = htonl(sensor_id);
phdr->linktype = htonl(datalink);
phdr->event_id = aun->event_id;
phdr->event_second = phdr->packet_second = htonl(p->ts.tv_sec);
hdr->type = htonl(UNIFIED2_PACKET_TYPE);
aun->hdr = hdr;
- phdr->sensor_id = 0;
+ phdr->sensor_id = htonl(sensor_id);
phdr->linktype = htonl(datalink);
phdr->event_id = event_id;
phdr->event_second = phdr->packet_second = htonl(p->ts.tv_sec);
/* fill the gphdr structure with the data of the packet */
memset(&gphdr, 0, sizeof(gphdr));
/* FIXME this need to be copied for each alert */
- gphdr.sensor_id = 0;
+ gphdr.sensor_id = htonl(sensor_id);
gphdr.event_second = htonl(p->ts.tv_sec);
gphdr.event_microsecond = htonl(p->ts.tv_usec);
gphdr.src_ip = *(struct in6_addr*)GET_IPV6_SRC_ADDR(p);
/* fill the gphdr structure with the data of the packet */
memset(&gphdr, 0, sizeof(gphdr));
- gphdr.sensor_id = 0;
+ gphdr.sensor_id = htonl(sensor_id);
gphdr.event_id = 0;
gphdr.event_second = htonl(p->ts.tv_sec);
gphdr.event_microsecond = htonl(p->ts.tv_usec);
}
}
+ if (conf != NULL) {
+ const char *sensor_id_s = NULL;
+ sensor_id_s = ConfNodeLookupChildValue(conf, "sensor-id");
+ if (sensor_id_s != NULL) {
+ if (ByteExtractStringUint32(&sensor_id, 10, 0, sensor_id_s) == -1) {
+ SCLogError(SC_ERR_INVALID_ARGUMENT, "Failed to initialize unified2 output, invalid sensor-id: %s", sensor_id_s);
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+
ret = Unified2AlertOpenFileCtx(file_ctx, filename);
if (ret < 0)
goto error;