Just use LOG_* instead of MSG_*
Just a used grep/sed to replace them. The order of MSG_ levels was just weird.master
parent
065b3f5bb5
commit
ca8539500a
|
@ -36,7 +36,7 @@ class ConcurrentQueue
|
|||
~ConcurrentQueue()
|
||||
{
|
||||
if(count != 0) {
|
||||
msg(MSG_DEBUG, "WARNING: freeing non-empty queue - got count: %d", count);
|
||||
msg(LOG_INFO, "WARNING: freeing non-empty queue - got count: %d", count);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -47,12 +47,12 @@ class ConcurrentQueue
|
|||
|
||||
inline void push(T t)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) trying to push element (%d elements in queue)", ownerName.c_str(), count);
|
||||
DPRINTFL(LOG_DEBUG, "(%s) trying to push element (%d elements in queue)", ownerName.c_str(), count);
|
||||
#if defined(DEBUG)
|
||||
bool waiting = false;
|
||||
if (pushSemaphore.getCount() == 0) {
|
||||
waiting = true;
|
||||
DPRINTFL(MSG_DEBUG, "(%s) queue is full with %d elements, waiting ...", ownerName.c_str(), count);
|
||||
DPRINTFL(LOG_INFO, "(%s) queue is full with %d elements, waiting ...", ownerName.c_str(), count);
|
||||
}
|
||||
#endif
|
||||
if (!pushSemaphore.wait()) {
|
||||
|
@ -70,12 +70,12 @@ class ConcurrentQueue
|
|||
lock.unlock();
|
||||
|
||||
popSemaphore.post();
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) element pushed (%d elements in queue)", ownerName.c_str(), maxEntries-pushSemaphore.getCount(), pushSemaphore.getCount(), maxEntries);
|
||||
DPRINTFL(LOG_DEBUG, "(%s) element pushed (%d elements in queue)", ownerName.c_str(), maxEntries-pushSemaphore.getCount(), pushSemaphore.getCount(), maxEntries);
|
||||
};
|
||||
|
||||
inline bool pop(T* res)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) trying to pop element (%d elements in queue)",
|
||||
DPRINTFL(LOG_DEBUG, "(%s) trying to pop element (%d elements in queue)",
|
||||
(ownerName.empty() ? "<owner not set>" : ownerName.c_str()),
|
||||
maxEntries-pushSemaphore.getCount());
|
||||
if (!popSemaphore.wait()) {
|
||||
|
@ -92,7 +92,7 @@ class ConcurrentQueue
|
|||
|
||||
pushSemaphore.post();
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) element popped", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) element popped", ownerName.c_str());
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -102,11 +102,11 @@ class ConcurrentQueue
|
|||
// of the timeout has been reached, res will be set to NULL and false will be returned
|
||||
inline bool pop(long timeout_ms, T *res)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) trying to pop element (%d elements in queue)", ownerName.c_str(), count);
|
||||
DPRINTFL(LOG_DEBUG, "(%s) trying to pop element (%d elements in queue)", ownerName.c_str(), count);
|
||||
// try to get an item from the queue
|
||||
if(!popSemaphore.wait(timeout_ms)) {
|
||||
// timeout occured
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) timeout", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) timeout", ownerName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class ConcurrentQueue
|
|||
|
||||
pushSemaphore.post();
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) element popped", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) element popped", ownerName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class ConcurrentQueue
|
|||
// use this instead of the above, makes things easier!
|
||||
inline bool popAbs(const struct timeval &timeout, T *res)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) trying to pop element (%d elements in queue)", ownerName.c_str(), count);
|
||||
DPRINTFL(LOG_DEBUG, "(%s) trying to pop element (%d elements in queue)", ownerName.c_str(), count);
|
||||
|
||||
if (popSemaphore.waitAbs(timeout)) {
|
||||
// popSemaphore.wait() succeeded, now pop the frontmost element
|
||||
|
@ -142,12 +142,12 @@ class ConcurrentQueue
|
|||
|
||||
pushSemaphore.post();
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) element popped", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) element popped", ownerName.c_str());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// timeout occured
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) timeout or program shutdown", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) timeout or program shutdown", ownerName.c_str());
|
||||
*res = 0;
|
||||
|
||||
return false;
|
||||
|
@ -158,7 +158,7 @@ class ConcurrentQueue
|
|||
// use this instead of the above, makes things easier!
|
||||
inline bool popAbs(const struct timespec& timeout, T *res)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) trying to pop element (%d elements in queue)", ownerName.c_str(), count);
|
||||
DPRINTFL(LOG_DEBUG, "(%s) trying to pop element (%d elements in queue)", ownerName.c_str(), count);
|
||||
|
||||
if (popSemaphore.waitAbs(timeout)) {
|
||||
// popSemaphore.wait() succeeded, now pop the frontmost element
|
||||
|
@ -171,13 +171,13 @@ class ConcurrentQueue
|
|||
|
||||
pushSemaphore.post();
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) element popped", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) element popped", ownerName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// timeout occured
|
||||
DPRINTFL(MSG_VDEBUG, "(%s) timeout or program shutdown", ownerName.c_str());
|
||||
DPRINTFL(LOG_DEBUG, "(%s) timeout or program shutdown", ownerName.c_str());
|
||||
*res = 0;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -108,7 +108,7 @@ void SignalHandler::handleSignal(int sig)
|
|||
(*jt)->handleSigUsr2(sig);
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "No signal handler available for signal with number %d", sig);
|
||||
msg(LOG_ERR, "No signal handler available for signal with number %d", sig);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class Thread
|
|||
size_t threadNameLen = strlen(threadName);
|
||||
// truncate to 15 chars + NULL byte
|
||||
if (threadNameLen > MAX_THREAD_NAME_LEN) {
|
||||
msg(MSG_ERROR, "truncating thread name %s to %d characters", threadName, MAX_THREAD_NAME_LEN);
|
||||
msg(LOG_ERR, "truncating thread name %s to %d characters", threadName, MAX_THREAD_NAME_LEN);
|
||||
threadNameLen = MAX_THREAD_NAME_LEN;
|
||||
}
|
||||
memcpy(name, threadName, threadNameLen);
|
||||
|
@ -41,7 +41,7 @@ class Thread
|
|||
thread_created = true;
|
||||
|
||||
//data = threadData;
|
||||
msg(MSG_DEBUG, "creating new thread: %s", name);
|
||||
msg(LOG_INFO, "creating new thread: %s", name);
|
||||
if (pthread_create(&thread, NULL, f, threadData) != 0) {
|
||||
THROWEXCEPTION("failed to create new thread");
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class Thread
|
|||
|
||||
void *result=NULL;
|
||||
if(!thread || pthread_join(thread, &result)) {
|
||||
msg(MSG_ERROR, "joining failed");
|
||||
msg(LOG_ERR, "joining failed");
|
||||
}
|
||||
thread_created = false;
|
||||
|
||||
|
|
|
@ -168,9 +168,9 @@ inline ntp64 ntp64time(timeval tv)
|
|||
{
|
||||
ntp64 n;
|
||||
n.upper = (uint32_t)tv.tv_sec + GETTIMEOFDAY_TO_NTP_OFFSET;
|
||||
//msg(MSG_ERROR, "upper: %u", n.upper);
|
||||
//msg(LOG_ERR, "upper: %u", n.upper);
|
||||
n.lower = usec2ntp((uint32_t)tv.tv_usec);
|
||||
//msg(MSG_ERROR, "lower: %u", n.lower);
|
||||
//msg(LOG_ERR, "lower: %u", n.lower);
|
||||
return (n);
|
||||
}
|
||||
|
||||
|
@ -180,9 +180,9 @@ inline uint64_t ntp64timegcc(timeval tv)
|
|||
{
|
||||
uint64_t n;
|
||||
n = ((uint64_t)tv.tv_sec + GETTIMEOFDAY_TO_NTP_OFFSET) << 32;
|
||||
//msg(MSG_ERROR, "upper: %u", n.upper);
|
||||
//msg(LOG_ERR, "upper: %u", n.upper);
|
||||
n |= usec2ntp((uint32_t)tv.tv_usec);
|
||||
//msg(MSG_ERROR, "lower: %u", n.lower);
|
||||
//msg(LOG_ERR, "lower: %u", n.lower);
|
||||
return (n);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ inline timeval timentp64(ntp64 n)
|
|||
timeval tv;
|
||||
tv.tv_sec = n.upper-GETTIMEOFDAY_TO_NTP_OFFSET;
|
||||
tv.tv_usec = n.lower/4294;
|
||||
//msg(MSG_ERROR, "sec: %u, usec: %u", tv.tv_sec, tv.tv_usec);
|
||||
//msg(LOG_ERR, "sec: %u, usec: %u", tv.tv_sec, tv.tv_usec);
|
||||
return tv;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
break;
|
||||
default:
|
||||
// semaphore could not be aquired because of several reasons, but none are fatal
|
||||
DPRINTFL(MSG_VDEBUG, "timedwait (<0) returned with %d (%s)", errno, strerror(errno));
|
||||
DPRINTFL(LOG_DEBUG, "timedwait (<0) returned with %d (%s)", errno, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
retval = sem_timedwait(sem, &timeout);
|
||||
#endif
|
||||
if (retval != 0 && errno != ETIMEDOUT) {
|
||||
DPRINTFL(MSG_VDEBUG, "timedwait (>=0) returned with %d: %s", errno, strerror(errno));
|
||||
DPRINTFL(LOG_DEBUG, "timedwait (>=0) returned with %d: %s", errno, strerror(errno));
|
||||
switch (errno) {
|
||||
case EINVAL:
|
||||
/*
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
break;
|
||||
default:
|
||||
// semaphore could not be aquired because of several reasons, but none are fatal
|
||||
DPRINTFL(MSG_VDEBUG, "timedwait (>=0) returned with %d", errno);
|
||||
DPRINTFL(LOG_DEBUG, "timedwait (>=0) returned with %d", errno);
|
||||
}
|
||||
}
|
||||
if (errno == ETIMEDOUT) {
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
|
||||
// if program was shutdown, exit without success
|
||||
if (exitFlag) {
|
||||
DPRINTFL(MSG_VDEBUG, "exitFlag is set", errno);
|
||||
DPRINTFL(LOG_DEBUG, "exitFlag is set", errno);
|
||||
return false;
|
||||
}
|
||||
} while (retval != 0);
|
||||
|
@ -216,7 +216,7 @@ public:
|
|||
break;
|
||||
default:
|
||||
// semaphore not acquired for non-fatal reasons
|
||||
DPRINTFL(MSG_VDEBUG, "timedwait returned with %s",
|
||||
DPRINTFL(LOG_DEBUG, "timedwait returned with %s",
|
||||
strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ AnonPrimitive* AnonModule::createPrimitive(AnonMethod::Method m, const std::stri
|
|||
ret = new AnonCryptoPanPrefix(buffer, mapping);
|
||||
break;
|
||||
default:
|
||||
msg(MSG_FATAL, "AnonPrimitive number %i is unknown", m);
|
||||
msg(LOG_CRIT, "AnonPrimitive number %i is unknown", m);
|
||||
THROWEXCEPTION("AnonPrimitive number %i is unknown", m);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ void AnonModule::addAnonymization(InformationElement::IeInfo id, int len, AnonMe
|
|||
AnonIE ie;
|
||||
if (len == -1) {
|
||||
if (!(ident = ipfix_id_lookup(id.id, id.enterprise))) {
|
||||
msg(MSG_ERROR, "Unknown or unsupported id %s detected.", id.toString().c_str());
|
||||
msg(LOG_ERR, "Unknown or unsupported id %s detected.", id.toString().c_str());
|
||||
return;
|
||||
}
|
||||
len = ident->length;
|
||||
|
|
|
@ -35,14 +35,14 @@ void CountArray::set(size_t index, ValueType value)
|
|||
{
|
||||
if(index < array_size) {
|
||||
array[index] += value;
|
||||
//msg(MSG_DEBUG, "array[%u] == %u", index, array[index]);
|
||||
//msg(LOG_INFO, "array[%u] == %u", index, array[index]);
|
||||
}
|
||||
}
|
||||
|
||||
CountArray::ValueType CountArray::get(size_t index) const
|
||||
{
|
||||
if(index < array_size) {
|
||||
//msg(MSG_DEBUG, "get: array[%u] == %u", index, array[index]);
|
||||
//msg(LOG_INFO, "get: array[%u] == %u", index, array[index]);
|
||||
return array[index];
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
@ -54,12 +54,12 @@ class MinBloomFilter : public BloomFilterBase<T>
|
|||
if (current < ret)
|
||||
ret = current;
|
||||
}
|
||||
//msg(MSG_DEBUG, "MinBloomFilter.get(): %i", ret);
|
||||
//msg(LOG_INFO, "MinBloomFilter.get(): %i", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual void set(const uint8_t* input, size_t len, typename T::ValueType v) {
|
||||
//msg(MSG_DEBUG, "MinBloomFilter.set(): %i", v);
|
||||
//msg(LOG_INFO, "MinBloomFilter.set(): %i", v);
|
||||
for(unsigned i=0; i != BloomFilterBase<T>::hfList->len; i++) {
|
||||
if (BloomFilterBase<T>::CMS_) {
|
||||
BloomFilterBase<T>::filter_[0].set(BloomFilterBase<T>::hashU(input, len,
|
||||
|
|
|
@ -75,7 +75,7 @@ uint64_t ntohll(uint64_t number)
|
|||
int write_octet ( char** p_pos, char* p_end, uint8_t n)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint8_t) ) ) {
|
||||
msg(MSG_ERROR, "error in write_octet: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_octet: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
uint8_t uint8 = n;
|
||||
|
@ -98,7 +98,7 @@ int write_unsigned16 ( char** p_pos, char* p_end, uint16_t n)
|
|||
{
|
||||
|
||||
if (p_end < ( *p_pos + sizeof(uint16_t) ) ) {
|
||||
msg(MSG_ERROR, "error in write_unsigned16: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_unsigned16: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
uint16_t uint16=htons(n);
|
||||
|
@ -120,7 +120,7 @@ int write_unsigned16 ( char** p_pos, char* p_end, uint16_t n)
|
|||
int write_unsigned32 ( char** p_pos, char* p_end, uint32_t n)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint32_t) ) ) {
|
||||
msg(MSG_ERROR, "error in write_unsigned32: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_unsigned32: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
uint32_t uint32 = htonl (n);
|
||||
|
@ -156,7 +156,7 @@ int write_ipv4Address ( char** p_pos, char* p_end, uint32_t n)
|
|||
int write_unsigned64 ( char** p_pos, char* p_end, uint64_t n)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint64_t) ) ) {
|
||||
msg(MSG_ERROR, "error in write_unsigned64: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_unsigned64: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
uint64_t uint64 = htonll (n);
|
||||
|
@ -178,7 +178,7 @@ int write_unsigned64 ( char** p_pos, char* p_end, uint64_t n)
|
|||
int write_float32 ( char** p_base, char* p_end, float f)
|
||||
{
|
||||
if (p_end < ( *p_base + sizeof(float) ) ) {
|
||||
msg(MSG_ERROR, "error in write_float32: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_float32: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ int write_boolean(char **p_pos, char *p_end, char b)
|
|||
uint8_t read_octet(char **p_pos, char *p_end)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint8_t) ) ) {
|
||||
msg(MSG_ERROR, "error in read_octet: buffer too small!");
|
||||
msg(LOG_ERR, "error in read_octet: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ uint8_t read_octet(char **p_pos, char *p_end)
|
|||
uint16_t read_unsigned16(char **p_pos, char *p_end)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint16_t) ) ) {
|
||||
msg(MSG_ERROR, "error in read_unsigned16: buffer too small!");
|
||||
msg(LOG_ERR, "error in read_unsigned16: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
// **p_pos is a pointer pointer.
|
||||
|
@ -278,7 +278,7 @@ uint16_t read_unsigned16(char **p_pos, char *p_end)
|
|||
uint32_t read_unsigned32(char **p_pos, char *p_end)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint32_t) ) ) {
|
||||
msg(MSG_ERROR, "error in read_unsigned32: buffer too small!");
|
||||
msg(LOG_ERR, "error in read_unsigned32: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
// **p_pos is a pointer pointer.
|
||||
|
@ -319,7 +319,7 @@ float read_float32(char **p_base, char *p_end)
|
|||
{
|
||||
// we assume, all we need is to convert the float to network-byte-order
|
||||
if (p_end < ( *p_base + sizeof(float) ) ) {
|
||||
msg(MSG_ERROR, "error in read_float32: buffer too small!");
|
||||
msg(LOG_ERR, "error in read_float32: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
float f = 2.1; // initialize the float to some dummy value.
|
||||
|
@ -350,7 +350,7 @@ float read_float32(char **p_base, char *p_end)
|
|||
uint64_t read_unsigned64 ( char** p_pos, char* p_end)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint64_t) ) ) {
|
||||
msg(MSG_ERROR, "error in read_unsigned64: buffer too small!");
|
||||
msg(LOG_ERR, "error in read_unsigned64: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
// **p_pos is a pointer pointer.
|
||||
|
@ -388,7 +388,7 @@ int read_octet_array(char **p_pos, char *p_end, char *p_output)
|
|||
first_len=read_octet(p_pos, p_end);
|
||||
// simply must work!
|
||||
/* if (first_len == -1) { */
|
||||
/* msg(MSG_ERROR, "error in read_octet_array: reading first length byte failed!"); */
|
||||
/* msg(LOG_ERR, "error in read_octet_array: reading first length byte failed!"); */
|
||||
/* return -1; */
|
||||
/* } */
|
||||
|
||||
|
@ -398,7 +398,7 @@ int read_octet_array(char **p_pos, char *p_end, char *p_output)
|
|||
// read another 2 bytes
|
||||
data_length = read_unsigned16 (p_pos, p_end);
|
||||
if (data_length < 255 ) {
|
||||
msg(MSG_ERROR, "malformed array of octets");
|
||||
msg(LOG_ERR, "malformed array of octets");
|
||||
}
|
||||
}
|
||||
memcpy (p_output, *p_pos, data_length);
|
||||
|
@ -425,7 +425,7 @@ int write_extension_and_fieldID(char** p_pos, char* p_end, uint16_t fieldID)
|
|||
//uint16_t leading_bit = 1 << 15;
|
||||
|
||||
if (p_end < ( *p_pos + sizeof(uint16_t) ) ) {
|
||||
msg(MSG_ERROR, "error in write_unsigned16: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_unsigned16: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ int read_extension_bit(char **p_pos, char *p_end)
|
|||
uint16_t n = *( (uint16_t*) *p_pos);
|
||||
|
||||
if (p_end < ( *p_pos + sizeof(uint16_t) ) ) {
|
||||
msg(MSG_ERROR, "error in write_unsigned16: buffer too small!");
|
||||
msg(LOG_ERR, "error in write_unsigned16: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ int read_extension_bit(char **p_pos, char *p_end)
|
|||
uint16_t read_fieldID(char **p_pos, char *p_end)
|
||||
{
|
||||
if (p_end < ( *p_pos + sizeof(uint16_t) ) ) {
|
||||
msg(MSG_ERROR, "error in read_unsigned16: buffer too small!");
|
||||
msg(LOG_ERR, "error in read_unsigned16: buffer too small!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ static int init_vrf(int socket, char *vrf_name, char *vrf_log_buffer) {
|
|||
if (setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, vrf_name,
|
||||
strlen(vrf_name))) {
|
||||
if (errno == ENOPROTOOPT) {
|
||||
msg(MSG_ERROR, "VRF not implemented in local kernel");
|
||||
msg(LOG_ERR, "VRF not implemented in local kernel");
|
||||
} else {
|
||||
msg(MSG_FATAL, "%ssetsockopt VRF %s failed, %s",
|
||||
msg(LOG_CRIT, "%ssetsockopt VRF %s failed, %s",
|
||||
vrf_log_buffer, vrf_name,
|
||||
strerror(errno));
|
||||
close(socket);
|
||||
|
@ -135,7 +135,7 @@ static int init_vrf(int socket, char *vrf_name, char *vrf_log_buffer) {
|
|||
return 0;
|
||||
#else
|
||||
(void)vrf_log_buffer; // unused variable warning
|
||||
msg(MSG_FATAL, "Cannot setsockopt to VRF %s, missing kernel support", vrf_name);
|
||||
msg(LOG_CRIT, "Cannot setsockopt to VRF %s, missing kernel support", vrf_name);
|
||||
close(socket);
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -154,7 +154,7 @@ static int init_send_udp_socket(struct sockaddr_storage serv_addr,
|
|||
int s;
|
||||
// create socket
|
||||
if((s = socket(serv_addr.ss_family, SOCK_DGRAM, 0)) < 0 ) {
|
||||
msg(MSG_FATAL, "error opening socket, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "error opening socket, %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ static int init_send_udp_socket(struct sockaddr_storage serv_addr,
|
|||
#ifndef DISABLE_UDP_CONNECT
|
||||
// connect to server
|
||||
if(connect(s, (struct sockaddr*)&serv_addr, sizeof(serv_addr) ) < 0) {
|
||||
msg(MSG_FATAL, "%sconnect failed, %s", vrf_log,
|
||||
msg(LOG_CRIT, "%sconnect failed, %s", vrf_log,
|
||||
strerror(errno));
|
||||
/* clean up */
|
||||
close(s);
|
||||
|
@ -187,14 +187,14 @@ int enable_pmtu_discovery(int s) {
|
|||
// Linux
|
||||
const int optval = IP_PMTUDISC_DO;
|
||||
if (setsockopt(s,IPPROTO_IP,IP_MTU_DISCOVER,&optval,sizeof(optval))) {
|
||||
msg(MSG_FATAL, "setsockopt(...,IP_MTU_DISCOVER,...) failed, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "setsockopt(...,IP_MTU_DISCOVER,...) failed, %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#elif IP_DONTFRAG
|
||||
// FreeBSD
|
||||
const int optval = 1;
|
||||
if (setsockopt(s,IPPROTO_IP,IP_DONTFRAG,&optval,sizeof(optval))) {
|
||||
msg(MSG_FATAL, "setsockopt(...,IP_DONTFRAG,...) failed, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "setsockopt(...,IP_DONTFRAG,...) failed, %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -206,7 +206,7 @@ static int get_mtu(const int s) {
|
|||
int optval = 0;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
if (getsockopt(s,IPPROTO_IP,IP_MTU,&optval,&optlen)) {
|
||||
msg(MSG_FATAL, "getsockopt(...,IP_MTU,...) failed, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "getsockopt(...,IP_MTU,...) failed, %s", strerror(errno));
|
||||
return -1;
|
||||
} else
|
||||
return optval;
|
||||
|
@ -234,9 +234,9 @@ static int init_send_sctp_socket(struct sockaddr_storage serv_addr,
|
|||
int s;
|
||||
|
||||
//create socket:
|
||||
DPRINTFL(MSG_VDEBUG, "Creating SCTP Socket ...");
|
||||
DPRINTFL(LOG_DEBUG, "Creating SCTP Socket ...");
|
||||
if((s = socket(serv_addr.ss_family, SOCK_STREAM, IPPROTO_SCTP)) < 0 ) {
|
||||
msg(MSG_FATAL, "error opening SCTP socket, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "error opening SCTP socket, %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
// set non-blocking
|
||||
|
@ -244,7 +244,7 @@ static int init_send_sctp_socket(struct sockaddr_storage serv_addr,
|
|||
flags = fcntl(s, F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
if(fcntl(s, F_SETFL, flags) == -1) {
|
||||
msg(MSG_FATAL, "could not set socket non-blocking");
|
||||
msg(LOG_CRIT, "could not set socket non-blocking");
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ static int init_send_sctp_socket(struct sockaddr_storage serv_addr,
|
|||
memset(&event, 0, sizeof(event));
|
||||
event.sctp_association_event = 1;
|
||||
if (setsockopt(s, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
|
||||
msg(MSG_ERROR, "SCTP: setsockopt() failed to enable sctp_data_io_event, %s", strerror(errno));
|
||||
msg(LOG_ERR, "SCTP: setsockopt() failed to enable sctp_data_io_event, %s", strerror(errno));
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
|
@ -265,11 +265,11 @@ static int init_send_sctp_socket(struct sockaddr_storage serv_addr,
|
|||
|
||||
// connect (non-blocking, i.e. handshake is initiated, not terminated)
|
||||
if((connect(s, (struct sockaddr*)&serv_addr, sizeof(serv_addr) ) == -1) && (errno != EINPROGRESS)) {
|
||||
msg(MSG_ERROR, "%sSCTP connect failed, %s", vrf_log, strerror(errno));
|
||||
msg(LOG_ERR, "%sSCTP connect failed, %s", vrf_log, strerror(errno));
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
DPRINTFL(MSG_DEBUG, "%sSCTP Socket created", vrf_log);
|
||||
DPRINTFL(LOG_INFO, "%sSCTP Socket created", vrf_log);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ static int sctp_sendmsgv(int s, struct iovec *vector, int v_len, struct sockaddr
|
|||
/* Collect data form iovecs */
|
||||
for (i=0;i<v_len;i++) {
|
||||
if (sendbufcur + vector[i].iov_len > sendbuf + maxsendbuflen) {
|
||||
msg(MSG_FATAL, "sendbuffer too small.");
|
||||
msg(LOG_CRIT, "sendbuffer too small.");
|
||||
return -1;
|
||||
}
|
||||
memcpy(sendbufcur,vector[i].iov_base,vector[i].iov_len);
|
||||
|
@ -382,7 +382,7 @@ int ipfix_init_exporter(export_protocol_version export_protocol, uint32_t observ
|
|||
case IPFIX_PROTOCOL:
|
||||
break;
|
||||
default:
|
||||
msg(MSG_FATAL, "Unknown protocol");
|
||||
msg(LOG_CRIT, "Unknown protocol");
|
||||
goto out;
|
||||
break;
|
||||
}
|
||||
|
@ -404,26 +404,26 @@ int ipfix_init_exporter(export_protocol_version export_protocol, uint32_t observ
|
|||
// initialize the sendbuffers
|
||||
ret=ipfix_init_sendbuffer(export_protocol, &(tmp->data_sendbuffer));
|
||||
if (ret != 0) {
|
||||
msg(MSG_FATAL, "initializing data sendbuffer failed");
|
||||
msg(LOG_CRIT, "initializing data sendbuffer failed");
|
||||
goto out1;
|
||||
}
|
||||
|
||||
ret=ipfix_init_sendbuffer(export_protocol, &(tmp->template_sendbuffer));
|
||||
if (ret != 0) {
|
||||
msg(MSG_FATAL, "initializing template sendbuffer failed");
|
||||
msg(LOG_CRIT, "initializing template sendbuffer failed");
|
||||
goto out2;
|
||||
}
|
||||
|
||||
ret=ipfix_init_sendbuffer(export_protocol, &(tmp->sctp_template_sendbuffer));
|
||||
if (ret != 0) {
|
||||
msg(MSG_FATAL, "initializing sctp template sendbuffer failed");
|
||||
msg(LOG_CRIT, "initializing sctp template sendbuffer failed");
|
||||
goto out5;
|
||||
}
|
||||
|
||||
// initialize the collectors to zero
|
||||
ret=ipfix_init_collector_array( &(tmp->collector_arr), IPFIX_MAX_COLLECTORS);
|
||||
if (ret !=0) {
|
||||
msg(MSG_FATAL, "initializing collectors failed");
|
||||
msg(LOG_CRIT, "initializing collectors failed");
|
||||
goto out3;
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ static int add_collector_remaining_protocols(
|
|||
col->vrf_name);
|
||||
// error handling, in case we were unable to open the port:
|
||||
if(col->data_socket < 0 ) {
|
||||
msg(MSG_ERROR, "add collector, initializing socket failed");
|
||||
msg(LOG_ERR, "add collector, initializing socket failed");
|
||||
return -1;
|
||||
}
|
||||
// now, we may set the collector to valid;
|
||||
|
@ -711,21 +711,21 @@ static int valid_transport_protocol(enum ipfix_transport_protocol p) {
|
|||
#ifdef SUPPORT_DTLS
|
||||
return 1;
|
||||
#else
|
||||
msg(MSG_FATAL, "Library compiled without DTLS support.");
|
||||
msg(LOG_CRIT, "Library compiled without DTLS support.");
|
||||
return 0;
|
||||
#endif
|
||||
case DTLS_OVER_SCTP:
|
||||
#ifdef SUPPORT_DTLS_OVER_SCTP
|
||||
return 1;
|
||||
#else
|
||||
msg(MSG_FATAL, "Library compiled without DTLS over SCTP support.");
|
||||
msg(LOG_CRIT, "Library compiled without DTLS over SCTP support.");
|
||||
return 0;
|
||||
#endif
|
||||
case SCTP:
|
||||
#ifdef SUPPORT_SCTP
|
||||
return 1;
|
||||
#else
|
||||
msg(MSG_FATAL, "Library compiled without SCTP support.");
|
||||
msg(LOG_CRIT, "Library compiled without SCTP support.");
|
||||
return 0;
|
||||
#endif
|
||||
#ifdef IPFIXLOLIB_RAWDIR_SUPPORT
|
||||
|
@ -734,13 +734,13 @@ static int valid_transport_protocol(enum ipfix_transport_protocol p) {
|
|||
#endif
|
||||
|
||||
case TCP:
|
||||
msg(MSG_FATAL, "Transport Protocol TCP not implemented");
|
||||
msg(LOG_CRIT, "Transport Protocol TCP not implemented");
|
||||
return 0;
|
||||
case UDP:
|
||||
case DATAFILE:
|
||||
return 1;
|
||||
default:
|
||||
msg(MSG_FATAL, "Transport Protocol not supported");
|
||||
msg(LOG_CRIT, "Transport Protocol not supported");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ int ipfix_add_collector(ipfix_exporter *exporter, const char *coll_ip_addr,
|
|||
{
|
||||
// check, if exporter is valid
|
||||
if(exporter == NULL) {
|
||||
msg(MSG_FATAL, "add_collector, exporter is NULL");
|
||||
msg(LOG_CRIT, "add_collector, exporter is NULL");
|
||||
return -1;
|
||||
}
|
||||
if ( ! valid_transport_protocol(proto)) return -1;
|
||||
|
@ -800,7 +800,7 @@ int ipfix_add_collector(ipfix_exporter *exporter, const char *coll_ip_addr,
|
|||
// get free slot
|
||||
ipfix_receiving_collector *collector = get_free_collector_slot(exporter);
|
||||
if( ! collector) {
|
||||
msg(MSG_FATAL, "no more free slots for new collectors available, limit %d reached",
|
||||
msg(LOG_CRIT, "no more free slots for new collectors available, limit %d reached",
|
||||
exporter->collector_max_num
|
||||
);
|
||||
return -1;
|
||||
|
@ -829,7 +829,7 @@ int ipfix_add_collector(ipfix_exporter *exporter, const char *coll_ip_addr,
|
|||
sa->sin6_family = AF_INET6;
|
||||
sa->sin6_port = htons(coll_port);
|
||||
if (inet_pton(AF_INET6, coll_ip_addr, &sa->sin6_addr) != 1) {
|
||||
msg(MSG_FATAL, "%s was not a valid IPv6 address", coll_ip_addr);
|
||||
msg(LOG_CRIT, "%s was not a valid IPv6 address", coll_ip_addr);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -837,7 +837,7 @@ int ipfix_add_collector(ipfix_exporter *exporter, const char *coll_ip_addr,
|
|||
sa->sin_family = AF_INET;
|
||||
sa->sin_port = htons(coll_port);
|
||||
if (inet_pton(AF_INET, coll_ip_addr, &sa->sin_addr) != 1) {
|
||||
msg(MSG_FATAL, "%s was not a valid IPv4 address", coll_ip_addr);
|
||||
msg(LOG_CRIT, "%s was not a valid IPv4 address", coll_ip_addr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -906,7 +906,7 @@ int ipfix_remove_collector(ipfix_exporter *exporter, const char *coll_ip_addr, u
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
msg(MSG_ERROR, "remove_collector, exporter %s not found", coll_ip_addr);
|
||||
msg(LOG_ERR, "remove_collector, exporter %s not found", coll_ip_addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -928,13 +928,13 @@ static int ipfix_find_template(
|
|||
ipfix_exporter *exporter,
|
||||
uint16_t template_id) {
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "ipfix_find_template with ID: %d",template_id);
|
||||
DPRINTFL(LOG_DEBUG, "ipfix_find_template with ID: %d",template_id);
|
||||
|
||||
int i=0;
|
||||
for (;i<exporter->ipfix_lo_template_maxsize;i++) {
|
||||
if(exporter->template_arr[i].state != T_UNUSED &&
|
||||
exporter->template_arr[i].template_id == template_id) {
|
||||
DPRINTFL(MSG_VDEBUG,
|
||||
DPRINTFL(LOG_DEBUG,
|
||||
"ipfix_find_template with ID: %d, validity %d found at %d",
|
||||
template_id, exporter->template_arr[i].state, i);
|
||||
return i;
|
||||
|
@ -944,16 +944,16 @@ static int ipfix_find_template(
|
|||
}
|
||||
|
||||
static int ipfix_get_free_template_slot(ipfix_exporter *exporter) {
|
||||
DPRINTFL(MSG_VDEBUG, "ipfix_get_free_template_slot");
|
||||
DPRINTFL(LOG_DEBUG, "ipfix_get_free_template_slot");
|
||||
|
||||
int i=0;
|
||||
for (;i<exporter->ipfix_lo_template_maxsize;i++) {
|
||||
if(exporter->template_arr[i].state == T_UNUSED) {
|
||||
DPRINTFL(MSG_VDEBUG, "ipfix_get_free_template_slot found at %d",i);
|
||||
DPRINTFL(LOG_DEBUG, "ipfix_get_free_template_slot found at %d",i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
DPRINTFL(MSG_DEBUG, "ipfix_get_free_template_slot failed.");
|
||||
DPRINTFL(LOG_INFO, "ipfix_get_free_template_slot failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -972,11 +972,11 @@ static int ipfix_get_free_template_slot(ipfix_exporter *exporter) {
|
|||
int ipfix_remove_template(ipfix_exporter *exporter, uint16_t template_id) {
|
||||
int found_index = ipfix_find_template(exporter,template_id);
|
||||
if (found_index < 0) {
|
||||
msg(MSG_ERROR, "remove_template ID %u not found", template_id);
|
||||
msg(LOG_ERR, "remove_template ID %u not found", template_id);
|
||||
return -1;
|
||||
}
|
||||
if(exporter->template_arr[found_index].state == T_SENT){
|
||||
DPRINTFL(MSG_VDEBUG,
|
||||
DPRINTFL(LOG_DEBUG,
|
||||
"creating withdrawal msg for ID: %d, validity %d",
|
||||
template_id, exporter->template_arr[found_index].state);
|
||||
char *p_pos;
|
||||
|
@ -1001,7 +1001,7 @@ int ipfix_remove_template(ipfix_exporter *exporter, uint16_t template_id) {
|
|||
exporter->template_arr[found_index].field_count = 0;
|
||||
exporter->template_arr[found_index].fields_added = 0;
|
||||
exporter->template_arr[found_index].state = T_WITHDRAWN;
|
||||
DPRINTFL(MSG_VDEBUG, "... Withdrawn");
|
||||
DPRINTFL(LOG_DEBUG, "... Withdrawn");
|
||||
} else {
|
||||
ipfix_deinit_template(&(exporter->template_arr[found_index]) );
|
||||
}
|
||||
|
@ -1031,7 +1031,7 @@ void ipfix_update_header(ipfix_exporter *p_exporter, ipfix_receiving_collector *
|
|||
if (gettimeofday(&now, NULL)) {
|
||||
now.tv_sec = 0;
|
||||
now.tv_usec= 0;
|
||||
msg(MSG_ERROR,"update_header, gettimeofday() failed. Set current time to 0");
|
||||
msg(LOG_ERR,"update_header, gettimeofday() failed. Set current time to 0");
|
||||
}
|
||||
|
||||
switch(p_exporter->export_protocol) {
|
||||
|
@ -1083,7 +1083,7 @@ void ipfix_update_header(ipfix_exporter *p_exporter, ipfix_receiving_collector *
|
|||
break;
|
||||
|
||||
default:
|
||||
msg(MSG_ERROR, "Cannot update a header for unknown protocol");
|
||||
msg(LOG_ERR, "Cannot update a header for unknown protocol");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ static int ipfix_new_file(ipfix_receiving_collector* recvcoll){
|
|||
/*11 == maximum length of uint32_t including terminating \0*/
|
||||
char *filename = malloc(sizeof(char)*(strlen(recvcoll->basename)+11));
|
||||
if(! filename){
|
||||
msg(MSG_ERROR, "could not malloc filename\n");
|
||||
msg(LOG_ERR, "could not malloc filename\n");
|
||||
goto out;
|
||||
}
|
||||
sprintf(filename, "%s%010d", recvcoll->basename, recvcoll->filenum);
|
||||
|
@ -1112,17 +1112,17 @@ static int ipfix_new_file(ipfix_receiving_collector* recvcoll){
|
|||
if (f<0) {
|
||||
if (errno == EEXIST){ //increase the filenumber and try again
|
||||
recvcoll->filenum++; //if the current file already exists
|
||||
msg(MSG_VDEBUG, "Skipping %s", filename);
|
||||
msg(LOG_DEBUG, "Skipping %s", filename);
|
||||
sprintf(filename, "%s%010d", recvcoll->basename, recvcoll->filenum);
|
||||
continue;
|
||||
}
|
||||
msg(MSG_ERROR, "could not open DATAFILE file %s", filename);
|
||||
msg(LOG_ERR, "could not open DATAFILE file %s", filename);
|
||||
f = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
}
|
||||
msg(MSG_INFO, "Created new file: %s", filename);
|
||||
msg(LOG_NOTICE, "Created new file: %s", filename);
|
||||
out:
|
||||
free(filename);
|
||||
recvcoll->fh = f;
|
||||
|
@ -1357,7 +1357,7 @@ static int ipfix_deinit_template_array(ipfix_exporter *exporter)
|
|||
// try to free all templates:
|
||||
|
||||
if (&exporter->template_arr[i] != NULL && exporter->template_arr[i].state != T_UNUSED && ipfix_deinit_template(&(exporter->template_arr[i]) )) {
|
||||
msg(MSG_ERROR, "failed to deinitialize template %i", i);
|
||||
msg(LOG_ERR, "failed to deinitialize template %i", i);
|
||||
}
|
||||
}
|
||||
free(exporter->template_arr);
|
||||
|
@ -1405,11 +1405,11 @@ static int ipfix_update_template_sendbuffer (ipfix_exporter *exporter)
|
|||
break;
|
||||
case (T_COMMITED): // send to SCTP and UDP collectors and mark as T_SENT
|
||||
if (sctp_sendbuf->current >= IPFIX_MAX_SENDBUFSIZE-2 ) {
|
||||
msg(MSG_ERROR, "SCTP template sendbuffer too small to handle more than %i entries", sctp_sendbuf->current);
|
||||
msg(LOG_ERR, "SCTP template sendbuffer too small to handle more than %i entries", sctp_sendbuf->current);
|
||||
return -1;
|
||||
}
|
||||
if (t_sendbuf->current >= IPFIX_MAX_SENDBUFSIZE-2 ) {
|
||||
msg(MSG_ERROR, "UDP template sendbuffer too small to handle more than %i entries", t_sendbuf->current);
|
||||
msg(LOG_ERR, "UDP template sendbuffer too small to handle more than %i entries", t_sendbuf->current);
|
||||
return -1;
|
||||
}
|
||||
sctp_sendbuf->entries[ sctp_sendbuf->current ].iov_base = exporter->template_arr[i].template_fields;
|
||||
|
@ -1428,7 +1428,7 @@ static int ipfix_update_template_sendbuffer (ipfix_exporter *exporter)
|
|||
break;
|
||||
case (T_SENT): // only to UDP collectors
|
||||
if (t_sendbuf->current >= IPFIX_MAX_SENDBUFSIZE-2 ) {
|
||||
msg(MSG_ERROR, "UDP template sendbuffer too small to handle more than %i entries", t_sendbuf->current);
|
||||
msg(LOG_ERR, "UDP template sendbuffer too small to handle more than %i entries", t_sendbuf->current);
|
||||
return -1;
|
||||
}
|
||||
t_sendbuf->entries[ t_sendbuf->current ].iov_base = exporter->template_arr[i].template_fields;
|
||||
|
@ -1439,7 +1439,7 @@ static int ipfix_update_template_sendbuffer (ipfix_exporter *exporter)
|
|||
break;
|
||||
case (T_WITHDRAWN): // put the SCTP withdrawal message and mark T_TOBEDELETED
|
||||
if (sctp_sendbuf->current >= IPFIX_MAX_SENDBUFSIZE-2 ) {
|
||||
msg(MSG_ERROR, "SCTP template sendbuffer too small to handle more than %i entries", sctp_sendbuf->current);
|
||||
msg(LOG_ERR, "SCTP template sendbuffer too small to handle more than %i entries", sctp_sendbuf->current);
|
||||
return -1;
|
||||
}
|
||||
sctp_sendbuf->entries[ sctp_sendbuf->current ].iov_base = exporter->template_arr[i].template_fields;
|
||||
|
@ -1450,7 +1450,7 @@ static int ipfix_update_template_sendbuffer (ipfix_exporter *exporter)
|
|||
|
||||
/* ASK: Why don't we just delete the template? */
|
||||
exporter->template_arr[i].state = T_TOBEDELETED;
|
||||
DPRINTFL(MSG_VDEBUG, "Withdrawal for template ID: %d added to sctp_sendbuffer", exporter->template_arr[i].template_id);
|
||||
DPRINTFL(LOG_DEBUG, "Withdrawal for template ID: %d added to sctp_sendbuffer", exporter->template_arr[i].template_id);
|
||||
break;
|
||||
default : // Do nothing : T_UNUSED or T_UNCLEAN
|
||||
break;
|
||||
|
@ -1497,7 +1497,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
collector->data_socket = init_send_sctp_socket( collector->addr,
|
||||
collector->vrf_name);
|
||||
if( collector->data_socket < 0) {
|
||||
msg(MSG_ERROR, "%sSCTP socket creation in reconnect failed, %s", vrf_log, strerror(errno));
|
||||
msg(LOG_ERR, "%sSCTP socket creation in reconnect failed, %s", vrf_log, strerror(errno));
|
||||
collector->state = C_DISCONNECTED;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1519,15 +1519,15 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
ret = select(collector->data_socket + 1,&readfds,NULL,NULL,&timeout);
|
||||
if (ret == 0) {
|
||||
// connection attempt not yet finished
|
||||
msg(MSG_DEBUG, "%swaiting for socket to become readable...", vrf_log);
|
||||
msg(LOG_INFO, "%swaiting for socket to become readable...", vrf_log);
|
||||
collector->state = C_NEW;
|
||||
return -1;
|
||||
} else if (ret>0) {
|
||||
// connected or connection setup failed.
|
||||
msg(MSG_DEBUG, "%ssocket is readable.", vrf_log);
|
||||
msg(LOG_INFO, "%ssocket is readable.", vrf_log);
|
||||
} else {
|
||||
// error
|
||||
msg(MSG_ERROR, "%sselect() failed: %s", vrf_log, strerror(errno));
|
||||
msg(LOG_ERR, "%sselect() failed: %s", vrf_log, strerror(errno));
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
collector->state = C_DISCONNECTED;
|
||||
|
@ -1538,7 +1538,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
len = sizeof error;
|
||||
if (getsockopt(collector->data_socket, SOL_SOCKET,
|
||||
SO_ERROR, &error, &len) != 0) {
|
||||
msg(MSG_ERROR, "%sgetsockopt(fd,SOL_SOCKET,SO_ERROR,...) failed: %s",
|
||||
msg(LOG_ERR, "%sgetsockopt(fd,SOL_SOCKET,SO_ERROR,...) failed: %s",
|
||||
vrf_log, strerror(errno));
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
|
@ -1546,7 +1546,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
return -1;
|
||||
}
|
||||
if (error) {
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed: %s", vrf_log,
|
||||
msg(LOG_ERR, "%sSCTP connection setup failed: %s", vrf_log,
|
||||
strerror(error));
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
|
@ -1564,7 +1564,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
msg.msg_iov = &iv;
|
||||
msg.msg_iovlen = 1;
|
||||
if ((r = recvmsg(collector->data_socket, &msg, 0))<0) {
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed. recvmsg returned: %s",
|
||||
msg(LOG_ERR, "%sSCTP connection setup failed. recvmsg returned: %s",
|
||||
vrf_log, strerror(error));
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
|
@ -1572,14 +1572,14 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
return -1;
|
||||
}
|
||||
if (r==0) {
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed. recvmsg returned 0", vrf_log);
|
||||
msg(LOG_ERR, "%sSCTP connection setup failed. recvmsg returned 0", vrf_log);
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
collector->state = C_DISCONNECTED;
|
||||
return -1;
|
||||
}
|
||||
if (!(msg.msg_flags & MSG_NOTIFICATION)) {
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed. recvmsg unexpected user data.", vrf_log);
|
||||
msg(LOG_ERR, "%sSCTP connection setup failed. recvmsg unexpected user data.", vrf_log);
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
collector->state = C_DISCONNECTED;
|
||||
|
@ -1589,7 +1589,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
case SCTP_ASSOC_CHANGE:
|
||||
sac = &snp.sn_assoc_change;
|
||||
if (sac->sac_state!=SCTP_COMM_UP) {
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed. "
|
||||
msg(LOG_ERR, "%sSCTP connection setup failed. "
|
||||
"Received unexpected SCTP_ASSOC_CHANGE notification with state %d",
|
||||
vrf_log, sac->sac_state);
|
||||
close(collector->data_socket);
|
||||
|
@ -1597,10 +1597,10 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
collector->state = C_DISCONNECTED;
|
||||
return -1;
|
||||
}
|
||||
msg(MSG_DEBUG,"%sReceived SCTP_COMM_UP event.", vrf_log);
|
||||
msg(LOG_INFO,"%sReceived SCTP_COMM_UP event.", vrf_log);
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed. "
|
||||
msg(LOG_ERR, "%sSCTP connection setup failed. "
|
||||
"Received unexpected notification of type %d", vrf_log,
|
||||
snp.sn_header.sn_type);
|
||||
close(collector->data_socket);
|
||||
|
@ -1613,7 +1613,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
len = sizeof ss;
|
||||
if (getsockopt(collector->data_socket, IPPROTO_SCTP,
|
||||
SCTP_STATUS, &ss, &len) != 0) {
|
||||
msg(MSG_ERROR, "%sgetsockopt(fd,IPPROTO_SCTP,SCTP_STATUS,...) failed: %s",
|
||||
msg(LOG_ERR, "%sgetsockopt(fd,IPPROTO_SCTP,SCTP_STATUS,...) failed: %s",
|
||||
vrf_log, strerror(errno));
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
|
@ -1622,14 +1622,14 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
}
|
||||
/* Make sure SCTP connection is in state ESTABLISHED */
|
||||
if (ss.sstat_state != SCTP_ESTABLISHED) {
|
||||
msg(MSG_ERROR, "%sSCTP socket not in state ESTABLISHED", vrf_log);
|
||||
msg(LOG_ERR, "%sSCTP socket not in state ESTABLISHED", vrf_log);
|
||||
close(collector->data_socket);
|
||||
collector->data_socket = -1;
|
||||
collector->state = C_DISCONNECTED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "%sSuccessfully (re)connected to SCTP collector.", vrf_log);
|
||||
msg(LOG_NOTICE, "%sSuccessfully (re)connected to SCTP collector.", vrf_log);
|
||||
collector->state = C_CONNECTED;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1650,11 +1650,11 @@ static bool ipfix_write_sendbuffer_to_datafile(ipfix_sendbuffer *sendbuffer, ipf
|
|||
}
|
||||
|
||||
if (col->fh < 0) {
|
||||
msg(MSG_ERROR, "invalid file handle for DATAFILE file (==0!)");
|
||||
msg(LOG_ERR, "invalid file handle for DATAFILE file (==0!)");
|
||||
return false;
|
||||
}
|
||||
if (sendbuffer->ipfix_message_header.length == 0) {
|
||||
msg(MSG_ERROR, "packet size == 0!");
|
||||
msg(LOG_ERR, "packet size == 0!");
|
||||
return false;
|
||||
}
|
||||
if (col->protocol == UDP) {
|
||||
|
@ -1672,11 +1672,11 @@ static bool ipfix_write_sendbuffer_to_datafile(ipfix_sendbuffer *sendbuffer, ipf
|
|||
nwritten = writev(col->fh, sendbuffer->entries, sendbuffer->current);
|
||||
}
|
||||
if (nwritten < 0) {
|
||||
msg(MSG_ERROR, "could not write to DATAFILE file");
|
||||
msg(LOG_ERR, "could not write to DATAFILE file");
|
||||
return false;
|
||||
}
|
||||
col->bytes_written += nwritten;
|
||||
msg(MSG_DEBUG, "bytes_written: %zd \t Total: %" PRIu64, nwritten, col->bytes_written);
|
||||
msg(LOG_INFO, "bytes_written: %zd \t Total: %" PRIu64, nwritten, col->bytes_written);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1687,9 +1687,9 @@ static void ipfix_write_sendbuffer_to_rawdir(ipfix_sendbuffer *sendbuffer, ipfix
|
|||
sprintf(fnamebuf, "%s/%08d", col->packet_directory_path, col->messages_sent);
|
||||
int f = creat(fnamebuf, S_IRWXU | S_IRWXG);
|
||||
if(f<0) {
|
||||
msg(MSG_ERROR, "could not open RAWDIR file %s", fnamebuf);
|
||||
msg(LOG_ERR, "could not open RAWDIR file %s", fnamebuf);
|
||||
} else if(writev(f, sendbuffer->entries, sendbuffer->current)<0) {
|
||||
msg(MSG_ERROR, "could not write to RAWDIR file %s", fnamebuf);
|
||||
msg(LOG_ERR, "could not write to RAWDIR file %s", fnamebuf);
|
||||
}
|
||||
close(f);
|
||||
}
|
||||
|
@ -1786,13 +1786,13 @@ static int ipfix_send_templates(ipfix_exporter* exporter)
|
|||
|
||||
if((bytes_sent = sendmsg(col->data_socket, &header, 0)) == -1){
|
||||
if (errno == EMSGSIZE) {
|
||||
msg(MSG_ERROR,
|
||||
msg(LOG_ERR,
|
||||
"%sUnable to send templates to %s:%d b/c message is bigger than MTU. That is a severe problem.",
|
||||
vrf_log,
|
||||
col->ipaddress,
|
||||
col->port_number);
|
||||
} else {
|
||||
msg(MSG_ERROR,
|
||||
msg(LOG_ERR,
|
||||
"%scould not send templates to %s:%d errno: %s (UDP)",
|
||||
vrf_log,
|
||||
col->ipaddress,
|
||||
|
@ -1800,7 +1800,7 @@ static int ipfix_send_templates(ipfix_exporter* exporter)
|
|||
strerror(errno));
|
||||
}
|
||||
} else {
|
||||
msg(MSG_VDEBUG, "%s%d Template Bytes sent to UDP collector %s:%d",
|
||||
msg(LOG_DEBUG, "%s%d Template Bytes sent to UDP collector %s:%d",
|
||||
vrf_log, bytes_sent, col->ipaddress, col->port_number);
|
||||
}
|
||||
col->messages_sent++;
|
||||
|
@ -1812,7 +1812,7 @@ static int ipfix_send_templates(ipfix_exporter* exporter)
|
|||
switch (col->state){
|
||||
case C_DISCONNECTED:
|
||||
if(exporter->sctp_reconnect_timer == 0) { // 0 = no more reconnection attempts
|
||||
msg(MSG_ERROR, "%sreconnect failed, removing collector %s:%d (SCTP)", vrf_log, col->ipaddress, col->port_number);
|
||||
msg(LOG_ERR, "%sreconnect failed, removing collector %s:%d (SCTP)", vrf_log, col->ipaddress, col->port_number);
|
||||
remove_collector(col);
|
||||
break;
|
||||
}
|
||||
|
@ -1839,13 +1839,13 @@ static int ipfix_send_templates(ipfix_exporter* exporter)
|
|||
0 // context
|
||||
)) == -1) {
|
||||
// send failed
|
||||
msg(MSG_ERROR, "%scould not send templates to %s:%d errno: %s (SCTP)", vrf_log, col->ipaddress, col->port_number, strerror(errno));
|
||||
msg(LOG_ERR, "%scould not send templates to %s:%d errno: %s (SCTP)", vrf_log, col->ipaddress, col->port_number, strerror(errno));
|
||||
sctp_reconnect(col); //1st reconnect attempt
|
||||
// if result is C_DISCONNECTED and sctp_reconnect_timer == 0, collector will
|
||||
// be removed on the next call of ipfix_send_templates()
|
||||
} else {
|
||||
// send was successful
|
||||
msg(MSG_VDEBUG, "%s%d template bytes sent to SCTP collector %s:%d",
|
||||
msg(LOG_DEBUG, "%s%d template bytes sent to SCTP collector %s:%d",
|
||||
vrf_log, bytes_sent, col->ipaddress, col->port_number);
|
||||
}
|
||||
} else {
|
||||
|
@ -1854,7 +1854,7 @@ static int ipfix_send_templates(ipfix_exporter* exporter)
|
|||
col->messages_sent++;
|
||||
break;
|
||||
default:
|
||||
msg(MSG_FATAL, "%sUnknown collector socket state", vrf_log);
|
||||
msg(LOG_CRIT, "%sUnknown collector socket state", vrf_log);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -1889,8 +1889,8 @@ static int ipfix_send_templates(ipfix_exporter* exporter)
|
|||
static void ipfix_sendbuffer_debug(ipfix_sendbuffer *sendbuffer)
|
||||
{
|
||||
// debugging output of data buffer:
|
||||
DPRINTFL(MSG_VDEBUG, "Sendbuffer contains %u bytes (Set headers + records)", sendbuffer->committed_data_length );
|
||||
DPRINTFL(MSG_VDEBUG, "Sendbuffer contains %u fields (IPFIX Message header + set headers + records)", sendbuffer->committed );
|
||||
DPRINTFL(LOG_DEBUG, "Sendbuffer contains %u bytes (Set headers + records)", sendbuffer->committed_data_length );
|
||||
DPRINTFL(LOG_DEBUG, "Sendbuffer contains %u fields (IPFIX Message header + set headers + records)", sendbuffer->committed );
|
||||
int tested_length = 0;
|
||||
for (unsigned int j =0; j < sendbuffer->committed; j++) {
|
||||
if(sendbuffer->entries[j].iov_len > 0 ) {
|
||||
|
@ -1900,7 +1900,7 @@ static void ipfix_sendbuffer_debug(ipfix_sendbuffer *sendbuffer)
|
|||
/* Keep in mind that the IPFIX message header (16 bytes) is not included
|
||||
in committed_data_length. So there should be a difference of 16 bytes
|
||||
between tested_length and committed_data_length */
|
||||
DPRINTFL(MSG_VDEBUG, "Total length of sendbuffer: %u bytes (IPFIX Message header + set headers + records)", tested_length );
|
||||
DPRINTFL(LOG_DEBUG, "Total length of sendbuffer: %u bytes (IPFIX Message header + set headers + records)", tested_length );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1935,7 +1935,7 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
snprintf(vrf_log, VRF_LOG_LEN, "[%.*s] ", IFNAMSIZ, col->vrf_name);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
DPRINTFL(MSG_VDEBUG, "%sSending to exporter %s", vrf_log, col->ipaddress);
|
||||
DPRINTFL(LOG_DEBUG, "%sSending to exporter %s", vrf_log, col->ipaddress);
|
||||
ipfix_sendbuffer_debug(exporter->data_sendbuffer);
|
||||
#endif
|
||||
switch(col->protocol){
|
||||
|
@ -1948,9 +1948,9 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
header.msg_controllen = 0;
|
||||
|
||||
if((bytes_sent = sendmsg(col->data_socket, &header, 0)) == -1) {
|
||||
msg(MSG_ERROR, "%scould not send data to %s:%d errno: %s (UDP)", vrf_log, col->ipaddress, col->port_number, strerror(errno));
|
||||
msg(LOG_ERR, "%scould not send data to %s:%d errno: %s (UDP)", vrf_log, col->ipaddress, col->port_number, strerror(errno));
|
||||
if (errno == EMSGSIZE) {
|
||||
msg(MSG_ERROR, "%sUpdating MTU estimate for collector %s:%d",
|
||||
msg(LOG_ERR, "%sUpdating MTU estimate for collector %s:%d",
|
||||
vrf_log,
|
||||
col->ipaddress,
|
||||
col->port_number);
|
||||
|
@ -1962,7 +1962,7 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
}
|
||||
}else{
|
||||
|
||||
msg(MSG_VDEBUG, "%s%d data bytes sent to UDP collector %s:%d",
|
||||
msg(LOG_DEBUG, "%s%d data bytes sent to UDP collector %s:%d",
|
||||
vrf_log, bytes_sent, col->ipaddress, col->port_number);
|
||||
}
|
||||
break;
|
||||
|
@ -1973,9 +1973,9 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
exporter->data_sendbuffer->committed,
|
||||
exporter->sctp_lifetime
|
||||
)) == -1){
|
||||
msg(MSG_VDEBUG, "%scould not send data to %s:%d (DTLS over SCTP)", vrf_log, col->ipaddress, col->port_number);
|
||||
msg(LOG_DEBUG, "%scould not send data to %s:%d (DTLS over SCTP)", vrf_log, col->ipaddress, col->port_number);
|
||||
}else{
|
||||
msg(MSG_VDEBUG, "%s%d data bytes sent to DTLS over SCTP collector %s:%d",
|
||||
msg(LOG_DEBUG, "%s%d data bytes sent to DTLS over SCTP collector %s:%d",
|
||||
vrf_log, bytes_sent, col->ipaddress, col->port_number);
|
||||
}
|
||||
break;
|
||||
|
@ -1994,13 +1994,13 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
0 // context
|
||||
)) == -1) {
|
||||
// send failed
|
||||
msg(MSG_ERROR, "%scould not send data to %s:%d errno: %s (SCTP)", vrf_log, col->ipaddress, col->port_number, strerror(errno));
|
||||
msg(LOG_ERR, "%scould not send data to %s:%d errno: %s (SCTP)", vrf_log, col->ipaddress, col->port_number, strerror(errno));
|
||||
// drop data and call sctp_reconnect
|
||||
sctp_reconnect(col);
|
||||
// if result is C_DISCONNECTED and sctp_reconnect_timer == 0, collector will
|
||||
// be removed on the next call of ipfix_send_templates()
|
||||
}
|
||||
msg(MSG_VDEBUG, "%s%d data bytes sent to SCTP collector %s:%d",
|
||||
msg(LOG_DEBUG, "%s%d data bytes sent to SCTP collector %s:%d",
|
||||
vrf_log, bytes_sent, col->ipaddress, col->port_number);
|
||||
break;
|
||||
#endif
|
||||
|
@ -2010,9 +2010,9 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
exporter->data_sendbuffer->entries,
|
||||
exporter->data_sendbuffer->committed
|
||||
)) == -1){
|
||||
msg(MSG_VDEBUG, "%scould not send data to %s:%d (DTLS over UDP)", vrf_log, col->ipaddress, col->port_number);
|
||||
msg(LOG_DEBUG, "%scould not send data to %s:%d (DTLS over UDP)", vrf_log, col->ipaddress, col->port_number);
|
||||
}else{
|
||||
msg(MSG_VDEBUG, "%s%d data bytes sent to DTLS over UDP collector %s:%d",
|
||||
msg(LOG_DEBUG, "%s%d data bytes sent to DTLS over UDP collector %s:%d",
|
||||
vrf_log, bytes_sent, col->ipaddress, col->port_number);
|
||||
}
|
||||
break;
|
||||
|
@ -2028,7 +2028,7 @@ static int ipfix_send_data(ipfix_exporter* exporter)
|
|||
break;
|
||||
|
||||
default:
|
||||
msg(MSG_FATAL, "%sTransport Protocol not supported", vrf_log);
|
||||
msg(LOG_CRIT, "%sTransport Protocol not supported", vrf_log);
|
||||
break; /* Should not occur since we check the transport
|
||||
protocol in valid_transport_protocol()*/
|
||||
}
|
||||
|
@ -2063,11 +2063,11 @@ int ipfix_send(ipfix_exporter *exporter)
|
|||
int ret = 0;
|
||||
|
||||
if(ipfix_send_templates(exporter) < 0) {
|
||||
msg(MSG_ERROR, "sending templates failed");
|
||||
msg(LOG_ERR, "sending templates failed");
|
||||
ret = -1;
|
||||
}
|
||||
if(ipfix_send_data(exporter) < 0) {
|
||||
msg(MSG_ERROR, "sending data failed");
|
||||
msg(LOG_ERR, "sending data failed");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
@ -2114,14 +2114,14 @@ int ipfix_start_data_set(ipfix_exporter *exporter, uint16_t template_id)
|
|||
|
||||
// security check
|
||||
if(exporter->data_sendbuffer->current != exporter->data_sendbuffer->committed) {
|
||||
msg(MSG_ERROR, "start_data_set called twice.");
|
||||
msg(LOG_ERR, "start_data_set called twice.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// check, if there is enough space in the data set buffer
|
||||
// the -1 is because, we expect, we want to add at least one data field.
|
||||
if(exporter->data_sendbuffer->current >= IPFIX_MAX_SENDBUFSIZE-1 ) {
|
||||
msg(MSG_ERROR, "start_data_set sendbuffer too small to handle more than %i entries",
|
||||
msg(LOG_ERR, "start_data_set sendbuffer too small to handle more than %i entries",
|
||||
exporter->data_sendbuffer->current
|
||||
);
|
||||
return -1;
|
||||
|
@ -2129,7 +2129,7 @@ int ipfix_start_data_set(ipfix_exporter *exporter, uint16_t template_id)
|
|||
|
||||
// check if we do have space for another set header
|
||||
if((current + 1) >= IPFIX_MAX_SETS_PER_PACKET ) {
|
||||
msg(MSG_ERROR, "start_data_set set_header_store too small to handle more than %i entries",
|
||||
msg(LOG_ERR, "start_data_set set_header_store too small to handle more than %i entries",
|
||||
current + 1
|
||||
);
|
||||
return -1;
|
||||
|
@ -2233,11 +2233,11 @@ uint16_t ipfix_get_remaining_space(ipfix_exporter *exporter) {
|
|||
int ipfix_put_data_field(ipfix_exporter *exporter,void *data, unsigned length) {
|
||||
ipfix_sendbuffer *dsb = exporter->data_sendbuffer;
|
||||
if(exporter->data_sendbuffer->current == exporter->data_sendbuffer->committed) {
|
||||
msg(MSG_ERROR, "ipfix_put_data_field called but there is no started set.");
|
||||
msg(LOG_ERR, "ipfix_put_data_field called but there is no started set.");
|
||||
return -1;
|
||||
}
|
||||
if (dsb->current >= IPFIX_MAX_SENDBUFSIZE) {
|
||||
msg(MSG_ERROR, "Sendbuffer too small to handle %i entries!\n", dsb->current );
|
||||
msg(LOG_ERR, "Sendbuffer too small to handle %i entries!\n", dsb->current );
|
||||
return -1;
|
||||
}
|
||||
dsb->entries[ dsb->current ].iov_base = data;
|
||||
|
@ -2265,11 +2265,11 @@ int ipfix_end_data_set(ipfix_exporter *exporter, uint16_t number_of_records)
|
|||
uint16_t record_length;
|
||||
|
||||
if(exporter->data_sendbuffer->current == exporter->data_sendbuffer->committed) {
|
||||
msg(MSG_ERROR, "ipfix_end_data_set called but there is no started set to end.");
|
||||
msg(LOG_ERR, "ipfix_end_data_set called but there is no started set to end.");
|
||||
return -1;
|
||||
}
|
||||
if((current + 1) >= IPFIX_MAX_SETS_PER_PACKET ) {
|
||||
msg(MSG_ERROR, "ipfix_end_data_set set_header_store too small to handle more than %i entries", current + 1);
|
||||
msg(LOG_ERR, "ipfix_end_data_set set_header_store too small to handle more than %i entries", current + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2318,11 +2318,11 @@ int ipfix_cancel_data_set(ipfix_exporter *exporter)
|
|||
|
||||
// security check
|
||||
if(exporter->data_sendbuffer->current == exporter->data_sendbuffer->committed) {
|
||||
msg(MSG_ERROR, "cancel_data_set called but there is no set to cancel.");
|
||||
msg(LOG_ERR, "cancel_data_set called but there is no set to cancel.");
|
||||
return -1;
|
||||
}
|
||||
if((current + 1) >= IPFIX_MAX_SETS_PER_PACKET ) {
|
||||
msg(MSG_ERROR, "ipfix_cancel_data_set set_header_store too small to handle more than %i entries", current + 1);
|
||||
msg(LOG_ERR, "ipfix_cancel_data_set set_header_store too small to handle more than %i entries", current + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2371,7 +2371,7 @@ int ipfix_delete_data_fields_upto_marker(ipfix_exporter *exporter)
|
|||
|
||||
// security check
|
||||
if(exporter->data_sendbuffer->current == exporter->data_sendbuffer->committed) {
|
||||
msg(MSG_ERROR, "delete_data_fields_upto_marker called but there is no set.");
|
||||
msg(LOG_ERR, "delete_data_fields_upto_marker called but there is no set.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -2422,7 +2422,7 @@ out:
|
|||
int ipfix_start_template (ipfix_exporter *exporter, uint16_t template_id, uint16_t field_count) {
|
||||
/* Make sure that template_id is > 255 */
|
||||
if (!(template_id > 255)) {
|
||||
msg(MSG_ERROR, "Template id has to be > 255. Start of template cancelled.");
|
||||
msg(LOG_ERR, "Template id has to be > 255. Start of template cancelled.");
|
||||
return -1;
|
||||
}
|
||||
int found_index = ipfix_find_template(exporter, template_id);
|
||||
|
@ -2447,14 +2447,14 @@ int ipfix_start_template (ipfix_exporter *exporter, uint16_t template_id, uint1
|
|||
ipfix_deinit_template(&(exporter->template_arr[found_index]));
|
||||
break;
|
||||
default:
|
||||
DPRINTFL(MSG_VDEBUG, "template valid flag is T_UNUSED or invalid\n");
|
||||
DPRINTFL(LOG_DEBUG, "template valid flag is T_UNUSED or invalid\n");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* allocate a new, free slot */
|
||||
found_index = ipfix_get_free_template_slot(exporter);
|
||||
if (found_index < 0) {
|
||||
msg(MSG_ERROR,"Unable to find free template slot.");
|
||||
msg(LOG_ERR,"Unable to find free template slot.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -2497,7 +2497,7 @@ int ipfix_start_template (ipfix_exporter *exporter, uint16_t template_id, uint1
|
|||
write_unsigned16 (&p_pos, p_end, 2);
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "Cannot write Template Set ID for unknown protocol");
|
||||
msg(LOG_ERR, "Cannot write Template Set ID for unknown protocol");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2528,7 +2528,7 @@ int ipfix_start_template (ipfix_exporter *exporter, uint16_t template_id, uint1
|
|||
int ipfix_start_optionstemplate(ipfix_exporter *exporter,
|
||||
uint16_t template_id, uint16_t scope_length, uint16_t option_length)
|
||||
{
|
||||
msg(MSG_FATAL, "start_optionstemplate() not implemented");
|
||||
msg(LOG_CRIT, "start_optionstemplate() not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2570,12 +2570,12 @@ int ipfix_put_template_field(ipfix_exporter *exporter, uint16_t template_id,
|
|||
|
||||
/* test for a valid slot */
|
||||
if(found_index < 0) {
|
||||
msg(MSG_VDEBUG, "template ID %u not found", template_id);
|
||||
msg(LOG_DEBUG, "template ID %u not found", template_id);
|
||||
return -1;
|
||||
}
|
||||
if (exporter->template_arr[found_index].fields_added >=
|
||||
exporter->template_arr[found_index].field_count) {
|
||||
msg(MSG_ERROR, "Cannot add more template fields.");
|
||||
msg(LOG_ERR, "Cannot add more template fields.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2584,18 +2584,18 @@ int ipfix_put_template_field(ipfix_exporter *exporter, uint16_t template_id,
|
|||
// end of the buffer
|
||||
p_end = p_pos + exporter->template_arr[found_index].max_fields_length;
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "template found at %d", found_index);
|
||||
DPRINTFL(MSG_VDEBUG, "A p_pos %p, p_end %p", p_pos, p_end);
|
||||
DPRINTFL(MSG_VDEBUG, "max_fields_length %d", exporter->template_arr[found_index].max_fields_length);
|
||||
DPRINTFL(MSG_VDEBUG, "fields_length %d", exporter->template_arr[found_index].fields_length);
|
||||
DPRINTFL(LOG_DEBUG, "template found at %d", found_index);
|
||||
DPRINTFL(LOG_DEBUG, "A p_pos %p, p_end %p", p_pos, p_end);
|
||||
DPRINTFL(LOG_DEBUG, "max_fields_length %d", exporter->template_arr[found_index].max_fields_length);
|
||||
DPRINTFL(LOG_DEBUG, "fields_length %d", exporter->template_arr[found_index].fields_length);
|
||||
|
||||
// add offset to the buffer's beginning: this is, where we will write to.
|
||||
p_pos += exporter->template_arr[found_index].fields_length;
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "B p_pos %p, p_end %p", p_pos, p_end);
|
||||
DPRINTFL(LOG_DEBUG, "B p_pos %p, p_end %p", p_pos, p_end);
|
||||
|
||||
if(enterprise_specific) {
|
||||
DPRINTFL(MSG_VDEBUG, "Notice: using enterprise ID %d with data %d", template_id, enterprise_id);
|
||||
DPRINTFL(LOG_DEBUG, "Notice: using enterprise ID %d with data %d", template_id, enterprise_id);
|
||||
}
|
||||
|
||||
// now write the field to the buffer:
|
||||
|
@ -2635,12 +2635,12 @@ int ipfix_end_template(ipfix_exporter *exporter, uint16_t template_id)
|
|||
|
||||
// test for a valid slot:
|
||||
if (found_index < 0) {
|
||||
msg(MSG_ERROR, "template %u not found", template_id);
|
||||
msg(LOG_ERR, "template %u not found", template_id);
|
||||
return -1;
|
||||
}
|
||||
ipfix_lo_template *templ=(&exporter->template_arr[found_index]);
|
||||
if (templ->fields_added != templ->field_count) {
|
||||
msg(MSG_ERROR, "Number of added template fields does not match number passed to ipfix_start_template");
|
||||
msg(LOG_ERR, "Number of added template fields does not match number passed to ipfix_start_template");
|
||||
ipfix_deinit_template(templ);
|
||||
return -1;
|
||||
}
|
||||
|
@ -2688,7 +2688,7 @@ static int ipfix_deinit_template(ipfix_lo_template *templ) {
|
|||
// first test, if we can free this template
|
||||
if (templ->state == T_UNUSED)
|
||||
return -1;
|
||||
DPRINTFL(MSG_VDEBUG, "deleting Template ID: %d validity: %d", templ->template_id, templ->state);
|
||||
DPRINTFL(LOG_DEBUG, "deleting Template ID: %d validity: %d", templ->template_id, templ->state);
|
||||
templ->state = T_UNUSED;
|
||||
free(templ->template_fields);
|
||||
templ->template_fields = 0;
|
||||
|
|
|
@ -31,13 +31,13 @@ static void
|
|||
switch (snp->sn_header.sn_type) {
|
||||
case SCTP_ASSOC_CHANGE:
|
||||
sac = &snp->sn_assoc_change;
|
||||
msg(MSG_DEBUG,"SCTP Event: assoc_change: state=%hu, error=%hu, instr=%hu "
|
||||
msg(LOG_INFO,"SCTP Event: assoc_change: state=%hu, error=%hu, instr=%hu "
|
||||
"outstr=%hu\n", sac->sac_state, sac->sac_error,
|
||||
sac->sac_inbound_streams, sac->sac_outbound_streams);
|
||||
break;
|
||||
case SCTP_SEND_FAILED:
|
||||
ssf = &snp->sn_send_failed;
|
||||
msg(MSG_DEBUG,"SCTP Event: sendfailed: len=%hu err=%d\n", ssf->ssf_length,
|
||||
msg(LOG_INFO,"SCTP Event: sendfailed: len=%hu err=%d\n", ssf->ssf_length,
|
||||
ssf->ssf_error);
|
||||
break;
|
||||
|
||||
|
@ -52,26 +52,26 @@ static void
|
|||
ap = inet_ntop(AF_INET6, &sin6->sin6_addr,
|
||||
addrbuf, INET6_ADDRSTRLEN);
|
||||
}
|
||||
msg(MSG_DEBUG,"SCTP Event: intf_change: %s state=%d, error=%d\n", ap,
|
||||
msg(LOG_INFO,"SCTP Event: intf_change: %s state=%d, error=%d\n", ap,
|
||||
spc->spc_state, spc->spc_error);
|
||||
break;
|
||||
case SCTP_REMOTE_ERROR:
|
||||
sre = &snp->sn_remote_error;
|
||||
msg(MSG_DEBUG,"SCTP Event: remote_error: err=%hu len=%hu\n",
|
||||
msg(LOG_INFO,"SCTP Event: remote_error: err=%hu len=%hu\n",
|
||||
ntohs(sre->sre_error), ntohs(sre->sre_length));
|
||||
break;
|
||||
case SCTP_SHUTDOWN_EVENT:
|
||||
msg(MSG_DEBUG,"SCTP Event: shutdown event\n");
|
||||
msg(LOG_INFO,"SCTP Event: shutdown event\n");
|
||||
break;
|
||||
case SCTP_SENDER_DRY_EVENT:
|
||||
ssde = &snp->sn_sender_dry_event;
|
||||
msg(MSG_DEBUG,"SCTP Event: sender dry event\n");
|
||||
msg(LOG_INFO,"SCTP Event: sender dry event\n");
|
||||
break;
|
||||
case SCTP_AUTHENTICATION_EVENT:
|
||||
msg(MSG_DEBUG,"SCTP Event: authentication event\n");
|
||||
msg(LOG_INFO,"SCTP Event: authentication event\n");
|
||||
break;
|
||||
default:
|
||||
msg(MSG_DEBUG,"SCTP Event: unknown type: %hu\n", snp->sn_header.sn_type);
|
||||
msg(LOG_INFO,"SCTP Event: unknown type: %hu\n", snp->sn_header.sn_type);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ static int ensure_exporter_set_up_for_dtls(ipfix_exporter_certificate *c) {
|
|||
|
||||
/* This SSL_CTX object will be freed in deinit_openssl_ctx() */
|
||||
if ( ! (c->ssl_ctx=SSL_CTX_new(DTLSv1_client_method())) ) {
|
||||
msg(MSG_FATAL, "Failed to create SSL context");
|
||||
msg(LOG_CRIT, "Failed to create SSL context");
|
||||
msg_openssl_errors();
|
||||
return -1;
|
||||
}
|
||||
|
@ -96,24 +96,24 @@ static int ensure_exporter_set_up_for_dtls(ipfix_exporter_certificate *c) {
|
|||
|
||||
if ( (c->ca_file || c->ca_path) &&
|
||||
! SSL_CTX_load_verify_locations(c->ssl_ctx,c->ca_file,c->ca_path) ) {
|
||||
msg(MSG_FATAL,"SSL_CTX_load_verify_locations() failed.");
|
||||
msg(LOG_CRIT,"SSL_CTX_load_verify_locations() failed.");
|
||||
msg_openssl_errors();
|
||||
return -1;
|
||||
}
|
||||
/* Load our own certificate */
|
||||
if (c->certificate_chain_file) {
|
||||
if (!SSL_CTX_use_certificate_chain_file(c->ssl_ctx, c->certificate_chain_file)) {
|
||||
msg(MSG_FATAL,"Unable to load certificate chain file %s",c->certificate_chain_file);
|
||||
msg(LOG_CRIT,"Unable to load certificate chain file %s",c->certificate_chain_file);
|
||||
msg_openssl_errors();
|
||||
return -1;
|
||||
}
|
||||
if (!SSL_CTX_use_PrivateKey_file(c->ssl_ctx, c->private_key_file, SSL_FILETYPE_PEM)) {
|
||||
msg(MSG_FATAL,"Unable to load private key file %s",c->private_key_file);
|
||||
msg(LOG_CRIT,"Unable to load private key file %s",c->private_key_file);
|
||||
msg_openssl_errors();
|
||||
return -1;
|
||||
}
|
||||
if (!SSL_CTX_check_private_key(c->ssl_ctx)) {
|
||||
msg(MSG_FATAL,"Private key and certificate do not match");
|
||||
msg(LOG_CRIT,"Private key and certificate do not match");
|
||||
msg_openssl_errors();
|
||||
return -1;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ static int create_dtls_socket(ipfix_receiving_collector *col) {
|
|||
protocol = 0;
|
||||
}
|
||||
if((s = socket(PF_INET, type, protocol)) < 0 ) {
|
||||
msg(MSG_FATAL, "error opening socket, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "error opening socket, %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ static int create_dtls_socket(ipfix_receiving_collector *col) {
|
|||
flags = fcntl(s, F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
if(fcntl(s, F_SETFL, flags) == -1) {
|
||||
msg(MSG_FATAL, "could not set socket non-blocking");
|
||||
msg(LOG_CRIT, "could not set socket non-blocking");
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ static int create_dtls_socket(ipfix_receiving_collector *col) {
|
|||
memset(&event, 0, sizeof(event));
|
||||
event.sctp_data_io_event = 1;
|
||||
if (setsockopt(s, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
|
||||
msg(MSG_ERROR, "SCTP: setsockopt() failed to enable sctp_data_io_event, %s", strerror(errno));
|
||||
msg(LOG_ERR, "SCTP: setsockopt() failed to enable sctp_data_io_event, %s", strerror(errno));
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ int setup_dtls_connection(ipfix_exporter *exporter, ipfix_receiving_collector *c
|
|||
|
||||
#ifdef DEBUG
|
||||
if (con->socket!=-1) {
|
||||
msg(MSG_FATAL,"socket != -1");
|
||||
msg(LOG_CRIT,"socket != -1");
|
||||
close(con->socket);
|
||||
con->socket = -1;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ int setup_dtls_connection(ipfix_exporter *exporter, ipfix_receiving_collector *c
|
|||
}
|
||||
/* create SSL object */
|
||||
if ( ! (con->ssl = SSL_new(exporter->certificate.ssl_ctx))) {
|
||||
msg(MSG_FATAL, "Failed to create SSL object.");
|
||||
msg(LOG_CRIT, "Failed to create SSL object.");
|
||||
msg_openssl_errors();
|
||||
close(con->socket);con->socket = -1;
|
||||
return -1;
|
||||
|
@ -226,7 +226,7 @@ int setup_dtls_connection(ipfix_exporter *exporter, ipfix_receiving_collector *c
|
|||
} else {
|
||||
if ( ! ((exporter->certificate.ca_file || exporter->certificate.ca_path) &&
|
||||
exporter->certificate.certificate_chain_file) ) {
|
||||
msg(MSG_ERROR,"Cannot verify certificates of collectors because prerequisites not met. "
|
||||
msg(LOG_ERR,"Cannot verify certificates of collectors because prerequisites not met. "
|
||||
"Prerequisites are: 1. CApath or CAfile or both set, "
|
||||
"2. We have a certificate including the private key");
|
||||
SSL_free(con->ssl);con->ssl = NULL;
|
||||
|
@ -252,7 +252,7 @@ int setup_dtls_connection(ipfix_exporter *exporter, ipfix_receiving_collector *c
|
|||
bio = BIO_new_dgram(con->socket,BIO_NOCLOSE);
|
||||
|
||||
if ( ! bio) {
|
||||
msg(MSG_FATAL,"Failed to create datagram BIO.");
|
||||
msg(LOG_CRIT,"Failed to create datagram BIO.");
|
||||
msg_openssl_errors();
|
||||
SSL_free(con->ssl);con->ssl = NULL;
|
||||
close(con->socket);con->socket = -1;
|
||||
|
@ -266,7 +266,7 @@ int setup_dtls_connection(ipfix_exporter *exporter, ipfix_receiving_collector *c
|
|||
SSL_set_bio(con->ssl,bio,bio);
|
||||
// connect (non-blocking, i.e. handshake is initiated, not terminated)
|
||||
if((connect(con->socket, (struct sockaddr*)&col->addr, sizeof(col->addr) ) == -1) && (errno != EINPROGRESS)) {
|
||||
msg(MSG_FATAL, "connect failed, %s", strerror(errno));
|
||||
msg(LOG_CRIT, "connect failed, %s", strerror(errno));
|
||||
SSL_free(con->ssl);con->ssl = NULL;
|
||||
close(con->socket);con->socket = -1;
|
||||
return -1;
|
||||
|
@ -300,25 +300,25 @@ static int dtls_connect(ipfix_receiving_collector *col, ipfix_dtls_connection *c
|
|||
ret = SSL_connect(con->ssl);
|
||||
error = SSL_get_error(con->ssl,ret);
|
||||
if (error == SSL_ERROR_NONE) {
|
||||
msg_openssl_return_code(MSG_DEBUG,"SSL_connect()",ret,error);
|
||||
msg(MSG_INFO, "Successfully (re)connected to %s-over-DTLS collector.", col->protocol == DTLS_OVER_SCTP ? "SCTP" : "UDP");
|
||||
msg(MSG_INFO,"TLS Cipher: %s",SSL_get_cipher_name(con->ssl));
|
||||
msg_openssl_return_code(LOG_INFO,"SSL_connect()",ret,error);
|
||||
msg(LOG_NOTICE, "Successfully (re)connected to %s-over-DTLS collector.", col->protocol == DTLS_OVER_SCTP ? "SCTP" : "UDP");
|
||||
msg(LOG_NOTICE,"TLS Cipher: %s",SSL_get_cipher_name(con->ssl));
|
||||
DPRINTF("DTLS handshake succeeded. We are now connected.");
|
||||
if (col->dtls_connection.peer_fqdn) { /* We need to verify the identity of our peer */
|
||||
if (verify_ssl_peer(con->ssl,&dtls_verify_peer_cb,col)) {
|
||||
DPRINTF("Peer authentication successful.");
|
||||
} else {
|
||||
msg(MSG_ERROR,"Peer authentication failed. Shutting down connection.");
|
||||
msg(LOG_ERR,"Peer authentication failed. Shutting down connection.");
|
||||
dtls_fail_connection(con);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} else if (error == SSL_ERROR_WANT_READ) {
|
||||
msg_openssl_return_code(MSG_DEBUG,"SSL_connect()",ret,error);
|
||||
msg_openssl_return_code(LOG_INFO,"SSL_connect()",ret,error);
|
||||
return 0;
|
||||
} else {
|
||||
msg_openssl_return_code(MSG_ERROR,"SSL_connect()",ret,error);
|
||||
msg_openssl_return_code(LOG_ERR,"SSL_connect()",ret,error);
|
||||
dtls_fail_connection(con);
|
||||
return -1;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ static int dtls_get_replacement_connection_ready(
|
|||
if (col->dtls_connection.dtls_connect_timeout &&
|
||||
(time(NULL) - col->dtls_connection.dtls_replacement.last_reconnect_attempt_time >
|
||||
col->dtls_connection.dtls_connect_timeout)) {
|
||||
msg(MSG_ERROR,"DTLS replacement connection setup taking too long.");
|
||||
msg(LOG_ERR,"DTLS replacement connection setup taking too long.");
|
||||
dtls_fail_connection(&col->dtls_connection.dtls_replacement);
|
||||
} else {
|
||||
DPRINTF("Replacement connection setup still ongoing.");
|
||||
|
@ -369,7 +369,7 @@ void dtls_shutdown_and_cleanup(ipfix_dtls_connection *con) {
|
|||
ret = SSL_shutdown(con->ssl);
|
||||
error = SSL_get_error(con->ssl,ret);
|
||||
#ifdef DEBUG
|
||||
msg_openssl_return_code(MSG_DEBUG,"SSL_shutdown()",ret,error);
|
||||
msg_openssl_return_code(LOG_INFO,"SSL_shutdown()",ret,error);
|
||||
#endif
|
||||
/* TODO: loop only if ret==-1 and error==WANT_READ or WANT_WRITE */
|
||||
int i = 0;
|
||||
|
@ -387,9 +387,9 @@ void dtls_shutdown_and_cleanup(ipfix_dtls_connection *con) {
|
|||
DPRINTF("Calling SSL_shutdown()");
|
||||
ret = SSL_shutdown(con->ssl);
|
||||
error = SSL_get_error(con->ssl,ret);
|
||||
msg_openssl_return_code(MSG_DEBUG,"SSL_shutdown()",ret,error);
|
||||
msg_openssl_return_code(LOG_INFO,"SSL_shutdown()",ret,error);
|
||||
if (i++ == 3) {
|
||||
msg(MSG_ERROR,"Too many calls to select(). Breaking out.");
|
||||
msg(LOG_ERR,"Too many calls to select(). Breaking out.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ static int dtls_send_helper( ipfix_dtls_connection *con,
|
|||
/* Collect data form iovecs */
|
||||
for (i=0;i<iovcnt;i++) {
|
||||
if (sendbufcur + iov[i].iov_len > sendbuf + maxsendbuflen) {
|
||||
msg(MSG_FATAL, "sendbuffer for dtls_send too small.");
|
||||
msg(LOG_CRIT, "sendbuffer for dtls_send too small.");
|
||||
return -1;
|
||||
}
|
||||
memcpy(sendbufcur,iov[i].iov_base,iov[i].iov_len);
|
||||
|
@ -526,12 +526,12 @@ static int dtls_send_helper( ipfix_dtls_connection *con,
|
|||
#ifdef DEBUG
|
||||
char buf[32];
|
||||
snprintf(buf,sizeof(buf),"SSL_write(%d bytes of data)",(int) (sendbufcur - sendbuf) );
|
||||
msg_openssl_return_code(MSG_DEBUG,buf,len,error);
|
||||
msg_openssl_return_code(LOG_INFO,buf,len,error);
|
||||
#endif
|
||||
switch (error) {
|
||||
case SSL_ERROR_NONE:
|
||||
if (len!=sendbufcur - sendbuf) {
|
||||
msg(MSG_FATAL, "len!=sendbuflen when calling SSL_write()");
|
||||
msg(LOG_CRIT, "len!=sendbuflen when calling SSL_write()");
|
||||
return -1;
|
||||
}
|
||||
return sendbufcur - sendbuf; /* SUCCESS */
|
||||
|
@ -543,7 +543,7 @@ static int dtls_send_helper( ipfix_dtls_connection *con,
|
|||
}
|
||||
__FALLTHROUGH__;
|
||||
default:
|
||||
msg_openssl_return_code(MSG_ERROR,"SSL_write()",len,error);
|
||||
msg_openssl_return_code(LOG_ERR,"SSL_write()",len,error);
|
||||
dtls_fail_connection(con);
|
||||
return -2;
|
||||
}
|
||||
|
@ -691,15 +691,15 @@ void ipfix_clear_dtls_certificate(ipfix_exporter_certificate *certificate) {
|
|||
int ipfix_set_dtls_certificate(ipfix_exporter_certificate *certificate,
|
||||
const char *certificate_chain_file, const char *private_key_file) {
|
||||
if (certificate->ssl_ctx) {
|
||||
msg(MSG_ERROR, "Too late to set certificate. SSL context already created.");
|
||||
msg(LOG_ERR, "Too late to set certificate. SSL context already created.");
|
||||
return -1;
|
||||
}
|
||||
if (certificate->certificate_chain_file) {
|
||||
msg(MSG_ERROR, "Certificate can not be reset.");
|
||||
msg(LOG_ERR, "Certificate can not be reset.");
|
||||
return -1;
|
||||
}
|
||||
if ( ! certificate_chain_file) {
|
||||
msg(MSG_ERROR, "ipfix_set_dtls_certificate called with bad parameters.");
|
||||
msg(LOG_ERR, "ipfix_set_dtls_certificate called with bad parameters.");
|
||||
return -1;
|
||||
}
|
||||
certificate->certificate_chain_file = strdup(certificate_chain_file);
|
||||
|
@ -729,11 +729,11 @@ int ipfix_set_dtls_certificate(ipfix_exporter_certificate *certificate,
|
|||
*/
|
||||
int ipfix_set_ca_locations(ipfix_exporter_certificate *certificate, const char *ca_file, const char *ca_path) {
|
||||
if (certificate->ssl_ctx) {
|
||||
msg(MSG_ERROR, "Too late to set CA locations. SSL context already created.");
|
||||
msg(LOG_ERR, "Too late to set CA locations. SSL context already created.");
|
||||
return -1;
|
||||
}
|
||||
if (certificate->ca_file || certificate->ca_path) {
|
||||
msg(MSG_ERROR, "CA locations can not be reset.");
|
||||
msg(LOG_ERR, "CA locations can not be reset.");
|
||||
return -1;
|
||||
}
|
||||
if (ca_file) certificate->ca_file = strdup(ca_file);
|
||||
|
|
|
@ -317,10 +317,10 @@ extern "C" {
|
|||
|
||||
void vermont_assert(const char* expr, const char* description, int line, const char* filename, const char* prettyfuncname, const char* funcname)
|
||||
{
|
||||
msg_normal(MSG_ERROR, "Assertion: %s", expr);
|
||||
msg_normal(MSG_ERROR, "Message: %s", description);
|
||||
msg_normal(MSG_ERROR, "---------------------------------------------------------------");
|
||||
msg_normal(MSG_ERROR, "filename: %s:%d, function: %s (%s)", filename, line, funcname, prettyfuncname);
|
||||
msg_normal(LOG_ERR, "Assertion: %s", expr);
|
||||
msg_normal(LOG_ERR, "Message: %s", description);
|
||||
msg_normal(LOG_ERR, "---------------------------------------------------------------");
|
||||
msg_normal(LOG_ERR, "filename: %s:%d, function: %s (%s)", filename, line, funcname, prettyfuncname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ extern "C" {
|
|||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
msg_expand(text, line, filename, funcname, simplefunc, MSG_FATAL, fmt, &args);
|
||||
msg_expand(text, line, filename, funcname, simplefunc, LOG_CRIT, fmt, &args);
|
||||
va_end(args);
|
||||
|
||||
throw std::runtime_error(text);
|
||||
|
|
|
@ -40,18 +40,6 @@ typedef void (*LOGFUNCTION)(void *);
|
|||
//#define PRINT_WHOLEFUNCTIONNAME
|
||||
#endif
|
||||
|
||||
/* defines for the message system */
|
||||
#define MSG_VDEBUG LOG_DEBUG // mostly for ipfix byte-level messages
|
||||
#define MSG_DEBUG LOG_INFO // debugging messages, for example used by DPRINTF
|
||||
#define MSG_INFO LOG_NOTICE // informational messages, shown without debug-mode but only with verbose logging enabled
|
||||
#define MSG_DIALOG LOG_WARNING // error or warning messages which are shown during default execution
|
||||
#define MSG_ERROR LOG_ERR // messages which are shown during default execution
|
||||
#define MSG_FATAL LOG_CRIT // fatal messages which are shown every time
|
||||
#define MSG_ALERT LOG_ALERT // not used
|
||||
#define MSG_EMERG LOG_EMERG // not used
|
||||
//#define MSG_DEFAULT MSG_ERROR
|
||||
|
||||
|
||||
void msg_init(void);
|
||||
void msg_shutdown(void);
|
||||
void msg2(const int, const char*, const char*, const char*, const int, const char *, ...);
|
||||
|
@ -80,12 +68,12 @@ void vermont_exception(const int, const char*, const char*, const char*, const c
|
|||
#define THROWEXCEPTION(...) \
|
||||
__extension__ \
|
||||
({ \
|
||||
if (msg_getlevel() & LOG_MASK(MSG_FATAL)) { \
|
||||
if (msg_getlevel() & LOG_MASK(LOG_CRIT)) { \
|
||||
if (msg_get_syslog()) { \
|
||||
syslog(MSG_FATAL, __VA_ARGS__); \
|
||||
syslog(LOG_CRIT, __VA_ARGS__); \
|
||||
} \
|
||||
if (msg_get_journald()) { \
|
||||
sd_journal_print(MSG_FATAL, __VA_ARGS__); \
|
||||
sd_journal_print(LOG_CRIT, __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
vermont_exception(__LINE__, __FILE__, __PRETTY_FUNCTION__, __func__, __VA_ARGS__); \
|
||||
|
@ -113,19 +101,19 @@ void vermont_exception(const int, const char*, const char*, const char*, const c
|
|||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define DPRINTF(...) msg(MSG_DEBUG, ##__VA_ARGS__)
|
||||
#define DPRINTF(...) msg(LOG_INFO, ##__VA_ARGS__)
|
||||
#define DPRINTFL(lvl, ...) msg(lvl, ##__VA_ARGS__)
|
||||
|
||||
#define ASSERT(exp, description) \
|
||||
__extension__ \
|
||||
({ \
|
||||
if (!(exp)) { \
|
||||
if (msg_getlevel() & LOG_MASK(MSG_ERROR)) { \
|
||||
if (msg_getlevel() & LOG_MASK(LOG_ERR)) { \
|
||||
if (msg_get_syslog()) { \
|
||||
syslog(MSG_ERROR, description); \
|
||||
syslog(LOG_ERR, description); \
|
||||
} \
|
||||
if (msg_get_journald()) { \
|
||||
sd_journal_print(MSG_ERROR, description); \
|
||||
sd_journal_print(LOG_ERR, description); \
|
||||
} \
|
||||
} \
|
||||
vermont_assert(#exp, (description), __LINE__, __FILE__, __PRETTY_FUNCTION__, __func__); \
|
||||
|
|
|
@ -42,7 +42,7 @@ void ensure_openssl_init(void) {
|
|||
|
||||
#if 0
|
||||
if (SSL_COMP_add_compression_method(0, COMP_zlib())) {
|
||||
msg(MSG_ERROR, "OpenSSL: SSL_COMP_add_compression_method() failed.");
|
||||
msg(LOG_ERR, "OpenSSL: SSL_COMP_add_compression_method() failed.");
|
||||
msg_openssl_errors();
|
||||
};
|
||||
#endif
|
||||
|
@ -63,7 +63,7 @@ void msg_openssl_errors(void) {
|
|||
ERR_error_string_n(e,errbuf,sizeof errbuf);
|
||||
snprintf(buf, sizeof buf, "%s:%s:%d:%s", errbuf,
|
||||
file, line, (flags & ERR_TXT_STRING) ? data : "");
|
||||
msg(MSG_ERROR, "OpenSSL: %s",buf);
|
||||
msg(LOG_ERR, "OpenSSL: %s",buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,13 +141,13 @@ int verify_ssl_peer(SSL *ssl, int (*cb)(void *context, const char *dnsname), voi
|
|||
verify_result = SSL_get_verify_result(ssl);
|
||||
DPRINTF("SSL_get_verify_result() returned: %s",X509_verify_cert_error_string(verify_result));
|
||||
if(verify_result!=X509_V_OK) {
|
||||
msg(MSG_ERROR,"Certificate doesn't verify: %s", X509_verify_cert_error_string(verify_result));
|
||||
msg(LOG_ERR,"Certificate doesn't verify: %s", X509_verify_cert_error_string(verify_result));
|
||||
return 0;
|
||||
}
|
||||
|
||||
X509 *peer = SSL_get_peer_certificate(ssl);
|
||||
if (! peer) {
|
||||
msg(MSG_ERROR,"No peer certificate");
|
||||
msg(LOG_ERR,"No peer certificate");
|
||||
return 0;
|
||||
}
|
||||
int ret = check_x509_cert(peer, cb, context);
|
||||
|
@ -163,12 +163,12 @@ int verify_peer_cert_callback(int preverify_ok, X509_STORE_CTX *ctx) {
|
|||
int depth = X509_STORE_CTX_get_error_depth(ctx);
|
||||
int err = X509_STORE_CTX_get_error(ctx);
|
||||
if(!preverify_ok) {
|
||||
msg(MSG_ERROR,"Error with certificate at depth: %i",depth);
|
||||
msg(LOG_ERR,"Error with certificate at depth: %i",depth);
|
||||
X509_NAME_oneline(X509_get_issuer_name(cert),buf,sizeof(buf));
|
||||
msg(MSG_ERROR," issuer = %s",buf);
|
||||
msg(LOG_ERR," issuer = %s",buf);
|
||||
X509_NAME_oneline(X509_get_subject_name(cert),buf,sizeof(buf));
|
||||
msg(MSG_ERROR," subject = %s",buf);
|
||||
msg(MSG_ERROR," err %i:%s", err, X509_verify_cert_error_string(err));
|
||||
msg(LOG_ERR," subject = %s",buf);
|
||||
msg(LOG_ERR," err %i:%s", err, X509_verify_cert_error_string(err));
|
||||
}
|
||||
if (depth == 0) {
|
||||
ssl = (SSL*) X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
|
||||
|
@ -207,7 +207,7 @@ int check_x509_cert(X509 *peer, int (*cb)(void *context, const char *dnsname), v
|
|||
if (gn->type != GEN_DNS)
|
||||
continue;
|
||||
if (ASN1_STRING_type(gn->d.ia5) != V_ASN1_IA5STRING) {
|
||||
msg(MSG_ERROR, "malformed X509 cert: Type of ASN.1 string not IA5");
|
||||
msg(LOG_ERR, "malformed X509 cert: Type of ASN.1 string not IA5");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ int check_x509_cert(X509 *peer, int (*cb)(void *context, const char *dnsname), v
|
|||
while(len>0 && dnsname[len-1] == 0) --len;
|
||||
|
||||
if (len != strlen(dnsname)) {
|
||||
msg(MSG_ERROR, "malformed X509 cert");
|
||||
msg(LOG_ERR, "malformed X509 cert");
|
||||
return 0;
|
||||
}
|
||||
DPRINTF("Subject Alternative Name: DNS:%s",dnsname);
|
||||
|
@ -234,7 +234,7 @@ int check_x509_cert(X509 *peer, int (*cb)(void *context, const char *dnsname), v
|
|||
DPRINTF("CN not part of certificate");
|
||||
} else {
|
||||
if (len != strlen(buf)) {
|
||||
msg(MSG_ERROR,"malformed X509 cert: CN invalid");
|
||||
msg(LOG_ERR,"malformed X509 cert: CN invalid");
|
||||
return 0;
|
||||
}
|
||||
DPRINTF("most specific (1st) Common Name: %s",buf);
|
||||
|
@ -244,7 +244,7 @@ int check_x509_cert(X509 *peer, int (*cb)(void *context, const char *dnsname), v
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
msg(MSG_ERROR,"Neither any of the Subject Alternative Names nor the Common Name "
|
||||
msg(LOG_ERR,"Neither any of the Subject Alternative Names nor the Common Name "
|
||||
"matched one of the permitted FQDNs");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ SSL_CTX_wrapper::SSL_CTX_wrapper(
|
|||
"the peerFqdn option is NOT set.");
|
||||
} else {
|
||||
if ( ! (have_CAs && have_cert) ) {
|
||||
msg(MSG_ERROR,"Can not verify certificates of exporters because prerequesites not met. "
|
||||
msg(LOG_ERR,"Can not verify certificates of exporters because prerequesites not met. "
|
||||
"Prerequesites are: 1. CApath or CAfile or both set, "
|
||||
"2. We have a certificate including the private key");
|
||||
THROWEXCEPTION("Cannot verify DTLS peers.");
|
||||
|
@ -143,7 +143,7 @@ bool SSL_CTX_wrapper::loadVerifyLocations(
|
|||
if ( SSL_CTX_load_verify_locations(ctx,CAfile,CApath) ) {
|
||||
return true;
|
||||
} else {
|
||||
msg(MSG_ERROR,"SSL_CTX_load_verify_locations() failed.");
|
||||
msg(LOG_ERR,"SSL_CTX_load_verify_locations() failed.");
|
||||
msg_openssl_errors();
|
||||
THROWEXCEPTION("Failed to open CA file / CA directory.");
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ public:
|
|||
ConnectionQueue<typename InstanceType::dst_value_type>* getQueueInstance()
|
||||
{
|
||||
if (!queue) {
|
||||
msg(MSG_DIALOG, "queue is required by module id=%u but is not configured. Inserting a default queue with max size 1 (attention: this is inefficient!)", getID());
|
||||
msg(LOG_WARNING, "queue is required by module id=%u but is not configured. Inserting a default queue with max size 1 (attention: this is inefficient!)", getID());
|
||||
queue = new ConnectionQueue<typename InstanceType::dst_value_type>(1);
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ public:
|
|||
virtual void setupWithoutSuccessors()
|
||||
{
|
||||
if (typeid(typename InstanceType::src_value_type)!=typeid(NullEmitable*)) {
|
||||
msg(MSG_INFO, "module %s (id=%u) is source for data elements, but has no successor", getName().c_str(), getID());
|
||||
msg(LOG_NOTICE, "module %s (id=%u) is source for data elements, but has no successor", getName().c_str(), getID());
|
||||
getInstance()->connectToNothing();
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ public:
|
|||
dest = dynamic_cast<Destination< typename InstanceType::src_value_type>* >
|
||||
(other->getInstance());
|
||||
if (!dest) {
|
||||
msg(MSG_FATAL, "Trying to connect incompatible types: %s -> %s! Check your configuration for incompabible connections!", this->getName().c_str(), other->getName().c_str());
|
||||
msg(LOG_CRIT, "Trying to connect incompatible types: %s -> %s! Check your configuration for incompabible connections!", this->getName().c_str(), other->getName().c_str());
|
||||
THROWEXCEPTION("Unexpected error: can't cast %s to matching Destination<>",
|
||||
other->getName().c_str());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ Graph* Connector::connect(Graph* g)
|
|||
if (connectNodes) // insert the connection in the graph
|
||||
g->addEdge(fromNode, toNode);
|
||||
|
||||
msg(MSG_INFO, "Connecting module %s[Id = %u] -> %s[Id = %u]",
|
||||
msg(LOG_NOTICE, "Connecting module %s[Id = %u] -> %s[Id = %u]",
|
||||
cfg->getName().c_str(), cfg->getID(),
|
||||
id2node[nexts[j]]->getCfg()->getName().c_str(),
|
||||
id2node[nexts[j]]->getCfg()->getID());
|
||||
|
|
|
@ -225,14 +225,14 @@ std::vector<CfgNode*> Graph::getSources(Node* n) {
|
|||
|
||||
void Graph::depthSearch(Node* v)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "called (%u)", v->getID());
|
||||
DPRINTFL(LOG_DEBUG, "called (%u)", v->getID());
|
||||
preOrder[v->getID()] = cnt++;
|
||||
|
||||
std::vector<CfgNode*> outNodes = getDestinations(v);
|
||||
for (std::vector<CfgNode*>::const_iterator it = outNodes.begin();
|
||||
it != outNodes.end();
|
||||
it++) {
|
||||
DPRINTFL(MSG_VDEBUG, "module %u -> module %u", v->getID(), (*it)->getID());
|
||||
DPRINTFL(LOG_DEBUG, "module %u -> module %u", v->getID(), (*it)->getID());
|
||||
Node* other = *it;
|
||||
if (preOrder[other->getID()] == -1)
|
||||
depthSearch(other);
|
||||
|
@ -240,7 +240,7 @@ void Graph::depthSearch(Node* v)
|
|||
}
|
||||
|
||||
postOrder[v->getID()] = topoCnt;
|
||||
msg(MSG_VDEBUG, "postI[%u] = %u", topoCnt, v->getID());
|
||||
msg(LOG_DEBUG, "postI[%u] = %u", topoCnt, v->getID());
|
||||
postI[topoCnt++] = v->getID();
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ std::vector<CfgNode*> Graph::topoSort()
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < nodes.size(); i++) {
|
||||
DPRINTFL(MSG_VDEBUG, "NodeID=%u, Modulename=%s", nodes[i]->getID(), nodes[i]->getCfg()->getName().c_str());
|
||||
DPRINTFL(LOG_DEBUG, "NodeID=%u, Modulename=%s", nodes[i]->getID(), nodes[i]->getCfg()->getName().c_str());
|
||||
if (preOrder[i] == -1)
|
||||
depthSearch(nodes[i]);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ std::vector<CfgNode*> Graph::topoSort()
|
|||
result[nz-1-i] = nodes[postI[i]];
|
||||
}
|
||||
for (size_t i = 0; i < nz; i++) {
|
||||
msg(MSG_DEBUG, "topological sort #%zu: %s[%u]", i, result[i]->getCfg()->getName().c_str(), result[i]->getCfg()->getID());
|
||||
msg(LOG_INFO, "topological sort #%zu: %s[%u]", i, result[i]->getCfg()->getName().c_str(), result[i]->getCfg()->getID());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
}
|
||||
knownIE = true;
|
||||
} else {
|
||||
msg(MSG_INFO, "InfoElementCfg: unknown information element id %u, try to continue anyway.", ieId);
|
||||
msg(LOG_NOTICE, "InfoElementCfg: unknown information element id %u, try to continue anyway.", ieId);
|
||||
}
|
||||
} else if (ieName.size()>0) {
|
||||
// get ieId and enterpriseNumber from ieName
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
if (enterpriseNumber == 0 && ipfixid->pen != 0) {
|
||||
// enterprise number is missing in configuration
|
||||
enterpriseNumber = ipfixid->pen;
|
||||
msg(MSG_DIALOG, "InfoElementCfg: %s configured without enterprise number, continue with enterprise number %u.", ieName.c_str(), enterpriseNumber);
|
||||
msg(LOG_WARNING, "InfoElementCfg: %s configured without enterprise number, continue with enterprise number %u.", ieName.c_str(), enterpriseNumber);
|
||||
} else if (enterpriseNumber != ipfixid->pen) {
|
||||
// enterprise numbers do not match
|
||||
THROWEXCEPTION("InfoElementCfg: %s is configured with enterprise number %u, but %u is expected.", ieName.c_str(), enterpriseNumber, ipfixid->pen);
|
||||
|
|
|
@ -35,7 +35,7 @@ void SensorManager::setParameters(uint32_t checkInterval = SM_DEFAULT_CHECK_INTE
|
|||
GraphInstanceSupplier* gis = NULL)
|
||||
{
|
||||
#if !defined(__linux__)
|
||||
msg(MSG_DIALOG, "WARNING: this instance of vermont is *not* compiled for linux, support for CPU sensors is disabled");
|
||||
msg(LOG_WARNING, "WARNING: this instance of vermont is *not* compiled for linux, support for CPU sensors is disabled");
|
||||
hertzValue = 0;
|
||||
#else
|
||||
hertzValue = ThreadCPUInterface::getHertzValue();
|
||||
|
@ -43,13 +43,13 @@ void SensorManager::setParameters(uint32_t checkInterval = SM_DEFAULT_CHECK_INTE
|
|||
#endif
|
||||
if (gethostname(hostname, 100) != 0)
|
||||
THROWEXCEPTION("failed to get hostname by gethostname()!");
|
||||
msg(MSG_INFO, "SensorManager: hertz jiffy value=%lu, hostname=%s", hertzValue, hostname);
|
||||
msg(LOG_NOTICE, "SensorManager: hertz jiffy value=%lu, hostname=%s", hertzValue, hostname);
|
||||
|
||||
msg(MSG_INFO, "SensorManager started with following parameters:");
|
||||
msg(MSG_INFO, " - outputfilename=%s", outputfilename.c_str());
|
||||
msg(MSG_INFO, " - clearfilename=%s", clearFilename.c_str());
|
||||
msg(MSG_INFO, " - checkInterval=%d seconds", checkInterval);
|
||||
msg(MSG_INFO, " - append=%d", append);
|
||||
msg(LOG_NOTICE, "SensorManager started with following parameters:");
|
||||
msg(LOG_NOTICE, " - outputfilename=%s", outputfilename.c_str());
|
||||
msg(LOG_NOTICE, " - clearfilename=%s", clearFilename.c_str());
|
||||
msg(LOG_NOTICE, " - checkInterval=%d seconds", checkInterval);
|
||||
msg(LOG_NOTICE, " - append=%d", append);
|
||||
this->checkInterval = checkInterval;
|
||||
this->outputFilename = outputfilename;
|
||||
this->clearFilename = clearfilename;
|
||||
|
@ -65,7 +65,7 @@ void SensorManager::setGraphIS(GraphInstanceSupplier* gis)
|
|||
|
||||
void SensorManager::performStart()
|
||||
{
|
||||
msg(MSG_DIALOG, "starting sensor check thread");
|
||||
msg(LOG_WARNING, "starting sensor check thread");
|
||||
|
||||
thread.run(this);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void SensorManager::retrieveStatistics(bool ignoreshutdown)
|
|||
if (!ignoreshutdown && smExitFlag) return;
|
||||
|
||||
if ((clearFlag = checkClear())) {
|
||||
msg(MSG_DIALOG, "Clearing sensor statistics");
|
||||
msg(LOG_WARNING, "Clearing sensor statistics");
|
||||
}
|
||||
|
||||
const char* openflags = (append ? "a" : "w");
|
||||
|
@ -218,7 +218,7 @@ void SensorManager::retrieveStatistics(bool ignoreshutdown)
|
|||
mutex.lock();
|
||||
list<SensorEntry>::const_iterator siter = sensors.begin();
|
||||
while (siter != sensors.end()) {
|
||||
//DPRINTFL(MSG_ERROR, "non-module cfg->getName()=%s, s=%u", siter->name.c_str(), siter->sensor);
|
||||
//DPRINTFL(LOG_ERR, "non-module cfg->getName()=%s, s=%u", siter->name.c_str(), siter->sensor);
|
||||
Sensor* s = siter->sensor;
|
||||
if (clearFlag) s->clearStatistics();
|
||||
writeSensorXML(file, s, siter->name.c_str(), siter->id, false, curtime, lasttime, NULL);
|
||||
|
@ -242,7 +242,7 @@ void SensorManager::collectDataWorker()
|
|||
|
||||
registerCurrentThread();
|
||||
|
||||
msg(MSG_DIALOG, "SensorManager: checking sensor values every %u seconds", checkInterval);
|
||||
msg(LOG_WARNING, "SensorManager: checking sensor values every %u seconds", checkInterval);
|
||||
while (!smExitFlag) {
|
||||
uint32_t sleepcount = checkInterval*2;
|
||||
uint32_t i = 0;
|
||||
|
|
|
@ -134,7 +134,7 @@ void AnonymizerCfg::initInstance(CfgBase* c, AnonModule* module, XMLNode::XMLSet
|
|||
}
|
||||
|
||||
} else {
|
||||
msg(MSG_ERROR, "Unknown field in anonField");
|
||||
msg(LOG_ERR, "Unknown field in anonField");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -147,12 +147,12 @@ void AnonymizerCfg::initInstance(CfgBase* c, AnonModule* module, XMLNode::XMLSet
|
|||
if (cfg->getIeLength()==0) THROWEXCEPTION("Information element specified in anonField, but length==0");
|
||||
module->addAnonymization(InformationElement::IeInfo(cfg->getIeId(), cfg->getEnterpriseNumber()), cfg->getIeLength(), AnonMethod::stringToMethod(method), mapping, method_parameter);
|
||||
const ipfix_identifier* id = ipfix_id_lookup(cfg->getIeId(), cfg->getEnterpriseNumber());
|
||||
msg(MSG_INFO, "Added anonymization %s for field %i (%s) with length %i", method.c_str(), cfg->getIeId(), id->name, cfg->getIeLength());
|
||||
msg(LOG_NOTICE, "Added anonymization %s for field %i (%s) with length %i", method.c_str(), cfg->getIeId(), id->name, cfg->getIeLength());
|
||||
delete cfg;
|
||||
} else if (e->matches("next") || e->matches("copyMode")) {
|
||||
// ignore next and copyMode (see createInstance)
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unkown anonymization field %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unkown anonymization field %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ void ConfigManager::parseConfig(std::string fileName)
|
|||
}
|
||||
|
||||
if (!found) {
|
||||
msg(MSG_ERROR, "Unknown cfg entry %s found", (*it)->getName().c_str());
|
||||
msg(LOG_ERR, "Unknown cfg entry %s found", (*it)->getName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ void ConfigManager::parseConfig(std::string fileName)
|
|||
|
||||
for (size_t i = 0; i < topoNodes.size(); i++) {
|
||||
Cfg* cfg = topoNodes[topoNodes.size() -1 -i]->getCfg();
|
||||
msg(MSG_INFO, "Starting module %s", cfg->getName().c_str());
|
||||
msg(LOG_NOTICE, "Starting module %s", cfg->getName().c_str());
|
||||
cfg->start(false);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ void ConfigManager::shutdown()
|
|||
// shutdown modules
|
||||
for (size_t i = 0; i < topoNodes.size(); i++) {
|
||||
Cfg* cfg = topoNodes[i]->getCfg();
|
||||
msg(MSG_INFO, "shutting down module %s (id=%u)", cfg->getName().c_str(), cfg->getID());
|
||||
msg(LOG_NOTICE, "shutting down module %s (id=%u)", cfg->getName().c_str(), cfg->getID());
|
||||
cfg->shutdown(true, true);
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ void ConfigManager::shutdown()
|
|||
|
||||
// disconnect the module from its sources ..
|
||||
vector<CfgNode*> sources = graph->getSources(n);
|
||||
msg(MSG_INFO, "disconnecting module %s (id=%u)", cfg->getName().c_str(), cfg->getID());
|
||||
msg(LOG_NOTICE, "disconnecting module %s (id=%u)", cfg->getName().c_str(), cfg->getID());
|
||||
for (size_t k = 0; k < sources.size(); k++) {
|
||||
sources[k]->getCfg()->disconnectInstances();
|
||||
}
|
||||
|
@ -247,18 +247,18 @@ Graph* ConfigManager::getGraph()
|
|||
|
||||
void ConfigManager::onTimeout2()
|
||||
{
|
||||
//msg(MSG_VDEBUG, "Called deleter");
|
||||
//msg(LOG_DEBUG, "Called deleter");
|
||||
|
||||
for (std::list<deleter_list_item>::iterator it = deleter_list.begin(); it != deleter_list.end(); it++) {
|
||||
if (time(NULL) > it->delete_after) {
|
||||
msg(MSG_DEBUG, "Removing node: %s", (it->c)->getName().c_str());
|
||||
msg(LOG_INFO, "Removing node: %s", (it->c)->getName().c_str());
|
||||
(it->c)->shutdown(true, true);
|
||||
it->c->disconnectInstances();
|
||||
delete ((it->c));
|
||||
it = deleter_list.erase(it);
|
||||
it--;
|
||||
} else {
|
||||
msg(MSG_DEBUG, "Timeout for node %s not yet reached.", (it->c)->getName().c_str());
|
||||
msg(LOG_INFO, "Timeout for node %s not yet reached.", (it->c)->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ Graph* ConfigManager::reconnect(Graph* g, Graph *old)
|
|||
for (size_t i = 0; i < topoOld.size(); i++) {
|
||||
topoOld[i]->getCfg()->getInstance()->preReconfiguration();
|
||||
topoOld[i]->getCfg()->disconnectInstances();
|
||||
msg(MSG_INFO, "Disconnecting instance: %s", topoOld[i]->getCfg()->getName().c_str());
|
||||
msg(LOG_NOTICE, "Disconnecting instance: %s", topoOld[i]->getCfg()->getName().c_str());
|
||||
}
|
||||
|
||||
/* call onReconfiguration1 on all modules */
|
||||
|
@ -298,13 +298,13 @@ Graph* ConfigManager::reconnect(Graph* g, Graph *old)
|
|||
for (size_t j = 0; j < topoNew.size(); j++) {
|
||||
Cfg* newCfg = topoNew[j]->getCfg();
|
||||
if (oldCfg->getID() == newCfg->getID()) { // possible match
|
||||
msg(MSG_INFO, "found a match between %s(id=%u) -> %s(id=%u)",
|
||||
msg(LOG_NOTICE, "found a match between %s(id=%u) -> %s(id=%u)",
|
||||
oldCfg->getName().c_str(), oldCfg->getID(),
|
||||
newCfg->getName().c_str(), newCfg->getID());
|
||||
|
||||
// check if we could use the same module instance in the new config
|
||||
if (newCfg->deriveFrom(oldCfg)) {
|
||||
msg(MSG_INFO, "reusing %s(id=%u)",
|
||||
msg(LOG_NOTICE, "reusing %s(id=%u)",
|
||||
oldCfg->getName().c_str(), oldCfg->getID());
|
||||
newCfg->transferInstance(oldCfg);
|
||||
} else {
|
||||
|
@ -312,7 +312,7 @@ Graph* ConfigManager::reconnect(Graph* g, Graph *old)
|
|||
delme.c = oldCfg;
|
||||
delme.delete_after = time(NULL) + DELETER_DELAY; // current time + 20 seconds
|
||||
deleter_list.push_back(delme);
|
||||
msg(MSG_INFO, "can't reuse %s(id=%u)",
|
||||
msg(LOG_NOTICE, "can't reuse %s(id=%u)",
|
||||
oldCfg->getName().c_str(), oldCfg->getID());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ SensorManagerCfg::SensorManagerCfg(XMLElement* elem)
|
|||
} else if (e->matches("append")) {
|
||||
append = getInt("append")>0;
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown sensor manager config statement: %s", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown sensor manager config statement: %s", e->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
listIPRecords = new list<IPRecord*>[hashSize];
|
||||
initiateRecord(m_treeCount % numTrees);
|
||||
msg(MSG_INFO,"AutoFocus started");
|
||||
msg(LOG_NOTICE,"AutoFocus started");
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,7 +90,7 @@ AutoFocus::~AutoFocus()
|
|||
deleteRecord(i);
|
||||
|
||||
}
|
||||
msg(MSG_FATAL,"Autofocus is done");
|
||||
msg(LOG_CRIT,"Autofocus is done");
|
||||
}
|
||||
|
||||
void AutoFocus::onDataRecord(IpfixDataRecord* record)
|
||||
|
@ -274,7 +274,7 @@ void AutoFocus::metalist()
|
|||
// First tree, we need at least two trees to compare data
|
||||
if (m_treeCount-1 < 1)
|
||||
{
|
||||
msg(MSG_INFO,"meta list skipped, waiting for valuable data");
|
||||
msg(LOG_NOTICE,"meta list skipped, waiting for valuable data");
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ AutoFocusCfg::AutoFocusCfg(XMLElement* elem)
|
|||
reportfile = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown AutoFocus config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown AutoFocus config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ FlowLenAnalyzer::FlowLenAnalyzer(std::string& fFile, std::string& bFile, std::ve
|
|||
FlowLenAnalyzer::~FlowLenAnalyzer()
|
||||
{
|
||||
flowOutstream.close();
|
||||
msg(MSG_INFO, "Writing bins information");
|
||||
msg(LOG_NOTICE, "Writing bins information");
|
||||
for (std::map<uint64_t, uint64_t>::const_iterator i = binStats.begin(); i != binStats.end(); ++i) {
|
||||
binsOutstream << i->first << " " << i->second << std::endl;
|
||||
}
|
||||
|
|
|
@ -55,14 +55,14 @@ FlowLenAnalyzerCfg::FlowLenAnalyzerCfg(XMLElement* elem)
|
|||
ss.ignore();
|
||||
}
|
||||
}
|
||||
msg(MSG_INFO, "FlowLenAnalyzer: Using bins: ");
|
||||
msg(LOG_NOTICE, "FlowLenAnalyzer: Using bins: ");
|
||||
for (std::vector<uint64_t>::const_iterator j = bins.begin(); j != bins.end(); ++j) {
|
||||
msg(MSG_INFO, "%lu", *j);
|
||||
msg(LOG_NOTICE, "%lu", *j);
|
||||
}
|
||||
} else if (e->matches("next")) {
|
||||
// ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown FlowLenAnalyzer config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown FlowLenAnalyzer config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ FrontPayloadSigMatcher::FrontPayloadSigMatcher(string sigdir)
|
|||
: signatureDir(sigdir),
|
||||
sigmatcher(NULL)
|
||||
{
|
||||
msg(MSG_INFO, "FrontPayloadSigMatcher started with following parameters:");
|
||||
msg(MSG_INFO, " - signature directory=%s", sigdir.c_str());
|
||||
msg(LOG_NOTICE, "FrontPayloadSigMatcher started with following parameters:");
|
||||
msg(LOG_NOTICE, " - signature directory=%s", sigdir.c_str());
|
||||
|
||||
sigmatcher = new_matcher(sigdir.c_str());
|
||||
|
||||
msg(MSG_INFO, "Loaded %d signature classes", sigmatcher->numOfClasses);
|
||||
msg(LOG_NOTICE, "Loaded %d signature classes", sigmatcher->numOfClasses);
|
||||
}
|
||||
|
||||
FrontPayloadSigMatcher::~FrontPayloadSigMatcher()
|
||||
|
@ -47,8 +47,8 @@ void FrontPayloadSigMatcher::matchConnection(Connection* conn)
|
|||
|
||||
for (int32_t j=0; j<sigmatcher->numOfClasses; j++) {
|
||||
if (results[j]==1) {
|
||||
msg(MSG_DIALOG, "SIGMATCHER: front payload matches signature '%s'", sigmatcher->signatures[j]->id);
|
||||
msg(MSG_DIALOG, "%s", conn->toString().c_str());
|
||||
msg(LOG_WARNING, "SIGMATCHER: front payload matches signature '%s'", sigmatcher->signatures[j]->id);
|
||||
msg(LOG_WARNING, "%s", conn->toString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ FrontPayloadSigMatcherCfg::FrontPayloadSigMatcherCfg(XMLElement* elem)
|
|||
signatureDir = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown FrontPayloadSigMatcher config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown FrontPayloadSigMatcher config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ Host::~Host()
|
|||
void Host::addConnection(Connection* c)
|
||||
{
|
||||
if (c->srcIP != ip && c->dstIP != ip) {
|
||||
msg(MSG_ERROR, "Host: Received a connection that from %u to %u. However, my IP address is %u", c->srcIP, c->dstIP, ip);
|
||||
msg(LOG_ERR, "Host: Received a connection that from %u to %u. However, my IP address is %u", c->srcIP, c->dstIP, ip);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -245,8 +245,8 @@ void P2PDetector::onTimeout(void* dataPtr)
|
|||
//host is a p2p client
|
||||
if(points > 6){
|
||||
//send Message
|
||||
msg(MSG_INFO, "P2P client detected:");
|
||||
msg(MSG_INFO, "IP: %s, dstSubnet: %s, dstSubMask: %s", IPToString(iter->first).c_str(),
|
||||
msg(LOG_NOTICE, "P2P client detected:");
|
||||
msg(LOG_NOTICE, "IP: %s, dstSubnet: %s, dstSubMask: %s", IPToString(iter->first).c_str(),
|
||||
IPToString(subnet).c_str(), IPToString(subnetmask).c_str());
|
||||
|
||||
IDMEFMessage* msg = idmefManager.getNewInstance();
|
||||
|
|
|
@ -61,7 +61,7 @@ P2PDetectorCfg::P2PDetectorCfg(XMLElement* elem)
|
|||
tcpFailedVarianceThreshold = getDouble("tcpFailedVarianceThreshold");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown P2PDetector config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown P2PDetector config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ RBSWormDetector::RBSWormDetector(uint32_t hashbits, uint32_t texppend,
|
|||
statCurBenign = 0;
|
||||
|
||||
rbsEntries = new list<RBSEntry*>[hashSize];
|
||||
msg(MSG_INFO,"RBSWormDetector started");
|
||||
msg(LOG_NOTICE,"RBSWormDetector started");
|
||||
}
|
||||
/*
|
||||
* Destructor frees memory
|
||||
|
@ -205,9 +205,9 @@ void RBSWormDetector::addConnection(Connection* conn)
|
|||
te->decision = WORM;
|
||||
statNumWorms++;
|
||||
te->timeExpire = time(0)+timeExpireWorm;
|
||||
msg(MSG_DEBUG, "Worm detected:");
|
||||
msg(MSG_DEBUG, "srcIP: %s", IPToString(te->srcIP).c_str());
|
||||
msg(MSG_DEBUG, "numFanOut: %d, totalTime: %f",te->numFanouts, trace_ela);
|
||||
msg(LOG_INFO, "Worm detected:");
|
||||
msg(LOG_INFO, "srcIP: %s", IPToString(te->srcIP).c_str());
|
||||
msg(LOG_INFO, "numFanOut: %d, totalTime: %f",te->numFanouts, trace_ela);
|
||||
|
||||
IDMEFMessage* msg = idmefManager.getNewInstance();
|
||||
msg->init(idmefTemplate, analyzerId);
|
||||
|
@ -356,7 +356,7 @@ void RBSWormDetector::adaptFrequencies ()
|
|||
//sort list to cut off top and bottom 10 percent
|
||||
adaptList.sort(RBSWormDetector::comp_entries);
|
||||
|
||||
msg(MSG_FATAL,"meta list size %zu",adaptList.size());
|
||||
msg(LOG_CRIT,"meta list size %zu",adaptList.size());
|
||||
uint32_t num10 = adaptList.size()/10;
|
||||
|
||||
list<RBSEntry*>::iterator iter = adaptList.begin();
|
||||
|
@ -396,11 +396,11 @@ void RBSWormDetector::adaptFrequencies ()
|
|||
slope_0b = logeta_0/temp_n;
|
||||
slope_1a = temp_z/temp_n;
|
||||
slope_1b = logeta_1/temp_n;
|
||||
msg(MSG_FATAL,"Adapted Frequencies, lambda_0=%f with hosts=%d",lambda_0,valid++);
|
||||
msg(LOG_CRIT,"Adapted Frequencies, lambda_0=%f with hosts=%d",lambda_0,valid++);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(MSG_ERROR,"Too little traffic for adaption");
|
||||
msg(LOG_ERR,"Too little traffic for adaption");
|
||||
}
|
||||
|
||||
if (!first) return;
|
||||
|
|
|
@ -62,7 +62,7 @@ lambda_ratio(5)
|
|||
idmefTemplate = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown RBSWormDetector config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown RBSWormDetector config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ TRWPortscanDetector::TRWPortscanDetector(uint32_t hashbits, uint32_t texppend,
|
|||
logeta_1 = logf(eta_1);
|
||||
X_0 = logf(theta_1/theta_0);
|
||||
X_1 = logf((1-theta_1)/(1-theta_0));
|
||||
msg(MSG_INFO, "TRW variables: logeta_0: %f, logeta_1: %f, X_0: %f, X_1: %f", logeta_0, logeta_1, X_0, X_1);
|
||||
msg(LOG_NOTICE, "TRW variables: logeta_0: %f, logeta_1: %f, X_0: %f, X_1: %f", logeta_0, logeta_1, X_0, X_1);
|
||||
lastCleanup = time(0);
|
||||
|
||||
trwEntries = new list<TRWEntry*>[hashSize];
|
||||
|
@ -219,10 +219,10 @@ void TRWPortscanDetector::addConnection(Connection* conn)
|
|||
te->decision = SCANNER;
|
||||
statNumScanners++;
|
||||
te->timeExpire = time(0)+timeExpireScanner;
|
||||
msg(MSG_DEBUG, "portscanner detected:");
|
||||
msg(MSG_DEBUG, "srcIP: %s, dstSubnet: %s, dstSubMask: %s", IPToString(te->srcIP).c_str(),
|
||||
msg(LOG_INFO, "portscanner detected:");
|
||||
msg(LOG_INFO, "srcIP: %s, dstSubnet: %s, dstSubMask: %s", IPToString(te->srcIP).c_str(),
|
||||
IPToString(te->dstSubnet).c_str(), IPToString(te->dstSubnetMask).c_str());
|
||||
msg(MSG_DEBUG, "numFailedConns: %d, numSuccConns: %d", te->numFailedConns, te->numSuccConns);
|
||||
msg(LOG_INFO, "numFailedConns: %d, numSuccConns: %d", te->numFailedConns, te->numSuccConns);
|
||||
|
||||
IDMEFMessage* msg = idmefManager.getNewInstance();
|
||||
msg->init(idmefTemplate, analyzerId);
|
||||
|
|
|
@ -40,7 +40,7 @@ TRWPortscanDetectorCfg::TRWPortscanDetectorCfg(XMLElement* elem)
|
|||
idmefTemplate = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown TRWPortscanDetector config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown TRWPortscanDetector config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,16 +162,16 @@ void report::f_post(vector<treeRecord*>& p_treeRecords,uint32_t index,report_enu
|
|||
if (p_treeRecords[lastindex] != NULL)
|
||||
{
|
||||
change_global = (double) (numTotal * 100) / (double) p_treeRecords[lastindex]->root->data.m_attributes[attribute]->numCount - 100.0;
|
||||
// msg(MSG_FATAL,"Total %s %03llu CHANGE: %01.2f%%",global.c_str(),numTotal,change_global);
|
||||
// msg(LOG_CRIT,"Total %s %03llu CHANGE: %01.2f%%",global.c_str(),numTotal,change_global);
|
||||
}
|
||||
else {
|
||||
// msg(MSG_FATAL,"Total %s %d",global.c_str(),numTotal);
|
||||
// msg(LOG_CRIT,"Total %s %d",global.c_str(),numTotal);
|
||||
}
|
||||
|
||||
while (iter != specNodes.end())
|
||||
{
|
||||
|
||||
//msg(MSG_FATAL,"SUBNET: %s/%d\t\t %s\t",IPToString((*iter)->data.subnetIP).c_str(),(*iter)->data.subnetBits, global.c_str());
|
||||
//msg(LOG_CRIT,"SUBNET: %s/%d\t\t %s\t",IPToString((*iter)->data.subnetIP).c_str(),(*iter)->data.subnetBits, global.c_str());
|
||||
|
||||
if ((*iter)->data.subnetBits < minSubbits)
|
||||
{
|
||||
|
@ -195,12 +195,12 @@ void report::f_post(vector<treeRecord*>& p_treeRecords,uint32_t index,report_enu
|
|||
}
|
||||
|
||||
(*iter)->prio += abs((int)change);
|
||||
//msg(MSG_FATAL,"prio SUBNET: %s/%d\t\t %s\t %d",IPToString(before->data.subnetIP).c_str(),before->data.subnetBits,local.c_str(),abs((int)change));
|
||||
// msg(MSG_FATAL,"SUBNET: %s/%d\t\t %s\t %03llu (%03llu)\t\t %01.2f%% (%01.2f%%)\t",IPToString(before->data.subnetIP).c_str(),before->data.subnetBits,local.c_str(),data,before->data.m_attributes[attribute]->numCount,percentage,change);
|
||||
//msg(LOG_CRIT,"prio SUBNET: %s/%d\t\t %s\t %d",IPToString(before->data.subnetIP).c_str(),before->data.subnetBits,local.c_str(),abs((int)change));
|
||||
// msg(LOG_CRIT,"SUBNET: %s/%d\t\t %s\t %03llu (%03llu)\t\t %01.2f%% (%01.2f%%)\t",IPToString(before->data.subnetIP).c_str(),before->data.subnetBits,local.c_str(),data,before->data.m_attributes[attribute]->numCount,percentage,change);
|
||||
}
|
||||
else
|
||||
{
|
||||
// msg(MSG_FATAL,"SUBNET: %s/%d\t %s: %03llu (%01.2f%%)\t", IPToString((*iter)->data.subnetIP).c_str(),(*iter)->data.subnetBits, local.c_str(),data,percentage);
|
||||
// msg(LOG_CRIT,"SUBNET: %s/%d\t %s: %03llu (%01.2f%%)\t", IPToString((*iter)->data.subnetIP).c_str(),(*iter)->data.subnetBits, local.c_str(),data,percentage);
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ treeNode* report::getComparismValue(treeNode* match,vector<treeRecord*>& m_treeR
|
|||
treeNode* current = m_treeRecords[lastindex]->root;
|
||||
treeNode* before = current;
|
||||
|
||||
// msg(MSG_FATAL,"Searching predecessor of %s/%d",IPToString(ntohl(sip)).c_str(),sbits);
|
||||
// msg(LOG_CRIT,"Searching predecessor of %s/%d",IPToString(ntohl(sip)).c_str(),sbits);
|
||||
while (current != NULL)
|
||||
{
|
||||
|
||||
|
@ -238,11 +238,11 @@ treeNode* report::getComparismValue(treeNode* match,vector<treeRecord*>& m_treeR
|
|||
|
||||
//check if our subnet is included in one of the child subnets
|
||||
|
||||
// msg(MSG_FATAL,"Checking left node %s/%d",IPToString(current->left->data.subnetIP).c_str(),current->left->data.subnetBits);
|
||||
// msg(LOG_CRIT,"Checking left node %s/%d",IPToString(current->left->data.subnetIP).c_str(),current->left->data.subnetBits);
|
||||
|
||||
if (current->left->data.subnetBits <= 32- (uint32_t) (round(log(a)/log(2)+0.5)) && current->left->data.subnetBits <= sbits)
|
||||
{
|
||||
// msg(MSG_FATAL,"Subnet is included in left");
|
||||
// msg(LOG_CRIT,"Subnet is included in left");
|
||||
current = current->left;
|
||||
continue;
|
||||
|
||||
|
@ -250,18 +250,18 @@ treeNode* report::getComparismValue(treeNode* match,vector<treeRecord*>& m_treeR
|
|||
|
||||
uint32_t b = distance(match,current->right);
|
||||
|
||||
// msg(MSG_FATAL,"Checking right node %s/%d",IPToString(current->right->data.subnetIP).c_str(),current->right->data.subnetBits);
|
||||
// msg(LOG_CRIT,"Checking right node %s/%d",IPToString(current->right->data.subnetIP).c_str(),current->right->data.subnetBits);
|
||||
|
||||
if (current->right->data.subnetBits <= 32- (uint32_t) (round(log(b)/log(2)+0.5)) && current->right->data.subnetBits <= sbits)
|
||||
{
|
||||
|
||||
// msg(MSG_FATAL,"Subnet is included in right");
|
||||
// msg(LOG_CRIT,"Subnet is included in right");
|
||||
current = current->right;
|
||||
continue;
|
||||
}
|
||||
|
||||
//our subnet is not included in one of the child subnets, so there are 3 possible matches, left,right and current
|
||||
// msg(MSG_FATAL,"its not included in any node");
|
||||
// msg(LOG_CRIT,"its not included in any node");
|
||||
|
||||
//now check if one of the child subnets is included in ours
|
||||
|
||||
|
@ -270,12 +270,12 @@ treeNode* report::getComparismValue(treeNode* match,vector<treeRecord*>& m_treeR
|
|||
if ( sbits <= 32- (uint32_t) (round(log(a)/log(2)+0.5)) && sbits <= current->left->data.subnetBits )
|
||||
{
|
||||
left = true;
|
||||
// msg(MSG_FATAL,"left subnet is included");
|
||||
// msg(LOG_CRIT,"left subnet is included");
|
||||
}
|
||||
|
||||
if ( sbits <= 32- (uint32_t) (round(log(b)/log(2)+0.5)) && sbits <= current->right->data.subnetBits )
|
||||
{
|
||||
// msg(MSG_FATAL,"right subnet is included");
|
||||
// msg(LOG_CRIT,"right subnet is included");
|
||||
right = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ string IDMEFExporter::getFilename()
|
|||
uint32_t counter = 0;
|
||||
while (stat(filename.c_str(), &s) == 0) {
|
||||
if (!filewarningIssued) {
|
||||
msg(MSG_ERROR, "files in IDMEF destination directory are already present, either two processes are writing there simultaneously (VERY BAD, may result in lost or corrupt events), or files from previous run have not been processed yet (ALSO BAD)");
|
||||
msg(LOG_ERR, "files in IDMEF destination directory are already present, either two processes are writing there simultaneously (VERY BAD, may result in lost or corrupt events), or files from previous run have not been processed yet (ALSO BAD)");
|
||||
filewarningIssued = true;
|
||||
}
|
||||
if (counter == 0xFFFFFFFF) {
|
||||
|
|
|
@ -26,7 +26,7 @@ IDMEFExporterCfg::IDMEFExporterCfg(XMLElement* elem)
|
|||
} else if (e->matches("sendurl")) {
|
||||
sendURL = e->getFirstText();
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IDMEFExporter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IDMEFExporter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ void IDMEFMessage::init(const string tmplfilename, string analyzerid)
|
|||
|
||||
this->hostname = string(hostname) + "." + string(domainname);
|
||||
ipAddress = inet_ntoa(*((struct in_addr *)he->h_addr));
|
||||
msg(MSG_DIALOG, "using hostname %s and ip address %s", this->hostname.c_str(), ipAddress.c_str());
|
||||
msg(LOG_WARNING, "using hostname %s and ip address %s", this->hostname.c_str(), ipAddress.c_str());
|
||||
}
|
||||
|
||||
readTemplate(tmplfilename);
|
||||
|
|
|
@ -30,7 +30,7 @@ PacketIDMEFReporterCfg::PacketIDMEFReporterCfg(XMLElement* elem)
|
|||
idmefTemplate = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown PacketIDMEFReporter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown PacketIDMEFReporter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
} else if (e->matches("zmqPollTimeout")) {
|
||||
zmqPollTimeout = atoi(e->getContent().c_str());
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown collector config statement %s", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown collector config statement %s", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -162,11 +162,11 @@ public:
|
|||
THROWEXCEPTION("Could not create IpfixReceiver");
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Created an IpfixReceiver for protocol %d", protocol);
|
||||
msg(LOG_NOTICE, "Created an IpfixReceiver for protocol %d", protocol);
|
||||
|
||||
for (std::vector<std::string>::iterator i = authorizedHosts.begin(); i != authorizedHosts.end(); i++) {
|
||||
if (ipfixReceiver->addAuthorizedHost((*i).c_str()) != 0)
|
||||
msg(MSG_ERROR, "CollectorCfg: Invalid authorized host %s", (*i).c_str());
|
||||
msg(LOG_ERR, "CollectorCfg: Invalid authorized host %s", (*i).c_str());
|
||||
}
|
||||
return ipfixReceiver;
|
||||
}
|
||||
|
|
|
@ -49,35 +49,35 @@ Connection::Connection(IpfixDataRecord* record)
|
|||
if (fi != 0) {
|
||||
srcIP = *(uint32_t*)(record->data + fi->offset);
|
||||
} else {
|
||||
msg(MSG_INFO, "failed to determine source ip for record, assuming 0.0.0.0");
|
||||
msg(LOG_NOTICE, "failed to determine source ip for record, assuming 0.0.0.0");
|
||||
srcIP = 0;
|
||||
}
|
||||
fi = record->templateInfo->getFieldInfo(IPFIX_TYPEID_destinationIPv4Address, 0);
|
||||
if (fi != 0) {
|
||||
dstIP = *(uint32_t*)(record->data + fi->offset);
|
||||
} else {
|
||||
msg(MSG_INFO, "failed to determine destination ip for record, assuming 0.0.0.0");
|
||||
msg(LOG_NOTICE, "failed to determine destination ip for record, assuming 0.0.0.0");
|
||||
dstIP = 0;
|
||||
}
|
||||
fi = record->templateInfo->getFieldInfo(IPFIX_TYPEID_sourceTransportPort, 0);
|
||||
if (fi != 0) {
|
||||
srcPort = *(uint16_t*)(record->data + fi->offset);
|
||||
} else {
|
||||
msg(MSG_INFO, "failed to determine source port for record, assuming 0");
|
||||
msg(LOG_NOTICE, "failed to determine source port for record, assuming 0");
|
||||
srcPort = 0;
|
||||
}
|
||||
fi = record->templateInfo->getFieldInfo(IPFIX_TYPEID_destinationTransportPort, 0);
|
||||
if (fi != 0) {
|
||||
dstPort = *(uint16_t*)(record->data + fi->offset);
|
||||
} else {
|
||||
msg(MSG_INFO, "failed to determine destination port for record, assuming 0");
|
||||
msg(LOG_NOTICE, "failed to determine destination port for record, assuming 0");
|
||||
srcPort = 0;
|
||||
}
|
||||
fi = record->templateInfo->getFieldInfo(IPFIX_TYPEID_protocolIdentifier, 0);
|
||||
if (fi != 0) {
|
||||
protocol = *(uint8_t*)(record->data + fi->offset);
|
||||
} else {
|
||||
msg(MSG_INFO, "failed to determine protocol for record, using 0");
|
||||
msg(LOG_NOTICE, "failed to determine protocol for record, using 0");
|
||||
protocol = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,5 +116,5 @@ void IpfixCollector::setTemplateLifetime(uint16_t time)
|
|||
if(ipfixPacketProcessor && dynamic_cast<IpfixParser*>(ipfixPacketProcessor))
|
||||
dynamic_cast<IpfixParser*>(ipfixPacketProcessor)->setTemplateLifetime(time);
|
||||
else
|
||||
msg(MSG_ERROR, "IpfixCollector: Cannot set template lifetime, ipfixPacketProcessor is NULL");
|
||||
msg(LOG_ERR, "IpfixCollector: Cannot set template lifetime, ipfixPacketProcessor is NULL");
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ IpfixCollectorCfg::IpfixCollectorCfg(XMLElement* elem)
|
|||
if (!elem)
|
||||
return;
|
||||
|
||||
msg(MSG_INFO, "IpfixCollectorCfg: Start reading ipfixCollector section");
|
||||
msg(LOG_NOTICE, "IpfixCollectorCfg: Start reading ipfixCollector section");
|
||||
udpTemplateLifetime = getInt("udpTemplateLifetime", -1);
|
||||
|
||||
// Config for DTLS
|
||||
|
@ -63,7 +63,7 @@ IpfixCollectorCfg::IpfixCollectorCfg(XMLElement* elem)
|
|||
e->matches("CAfile") || e->matches("CApath")) {
|
||||
// already done!
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unkown collector config statement %s", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unkown collector config statement %s", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ IpfixCollectorCfg::IpfixCollectorCfg(XMLElement* elem)
|
|||
THROWEXCEPTION("collectingProcess can handle only UDP, TCP, or SCTP!");
|
||||
#endif
|
||||
|
||||
msg(MSG_INFO, "IpfixCollectorCfg: Successfully parsed collectingProcess section");
|
||||
msg(LOG_NOTICE, "IpfixCollectorCfg: Successfully parsed collectingProcess section");
|
||||
}
|
||||
|
||||
IpfixCollectorCfg::~IpfixCollectorCfg()
|
||||
{
|
||||
msg(MSG_INFO, "Deleting collectingProcess listener");
|
||||
msg(LOG_NOTICE, "Deleting collectingProcess listener");
|
||||
delete listener;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,16 +52,16 @@ IpfixCsExporter::IpfixCsExporter(std::string filenamePrefix,
|
|||
CS_IPFIX_MAGIC[0] = 0xCA;
|
||||
memcpy(&CS_IPFIX_MAGIC[1], "CSIPFIX", 7);
|
||||
|
||||
msg(MSG_INFO, "IpfixCsExporter initialized with the following parameters");
|
||||
msg(MSG_INFO, " - filenamePrefix = %s" , filenamePrefix.c_str());
|
||||
msg(MSG_INFO, " - destinationPath = %s", destinationPath.c_str());
|
||||
msg(MSG_INFO, " - maxFileSize = %d KiB" , maxFileSize);
|
||||
msg(MSG_INFO, " - maxChunkBufferTime = %d seconds" , maxChunkBufferTime);
|
||||
msg(MSG_INFO, " - maxChunkBufferRecords = %d seconds" , maxChunkBufferRecords);
|
||||
msg(MSG_INFO, " - maxFileCreationInterval = %d seconds" , maxFileCreationInterval);
|
||||
msg(MSG_INFO, " - exportMode = %d" , exportMode);
|
||||
msg(MSG_INFO, " - export struct sizes = %lu(Ipfix_basic_flow_sequence_chunk_header), %lu(Ipfix_basic_flow)", sizeof(Ipfix_basic_flow_sequence_chunk_header), sizeof(Ipfix_basic_flow));
|
||||
msg(MSG_INFO, "IpfixCsExporter: running");
|
||||
msg(LOG_NOTICE, "IpfixCsExporter initialized with the following parameters");
|
||||
msg(LOG_NOTICE, " - filenamePrefix = %s" , filenamePrefix.c_str());
|
||||
msg(LOG_NOTICE, " - destinationPath = %s", destinationPath.c_str());
|
||||
msg(LOG_NOTICE, " - maxFileSize = %d KiB" , maxFileSize);
|
||||
msg(LOG_NOTICE, " - maxChunkBufferTime = %d seconds" , maxChunkBufferTime);
|
||||
msg(LOG_NOTICE, " - maxChunkBufferRecords = %d seconds" , maxChunkBufferRecords);
|
||||
msg(LOG_NOTICE, " - maxFileCreationInterval = %d seconds" , maxFileCreationInterval);
|
||||
msg(LOG_NOTICE, " - exportMode = %d" , exportMode);
|
||||
msg(LOG_NOTICE, " - export struct sizes = %lu(Ipfix_basic_flow_sequence_chunk_header), %lu(Ipfix_basic_flow)", sizeof(Ipfix_basic_flow_sequence_chunk_header), sizeof(Ipfix_basic_flow));
|
||||
msg(LOG_NOTICE, "IpfixCsExporter: running");
|
||||
}
|
||||
|
||||
IpfixCsExporter::~IpfixCsExporter()
|
||||
|
@ -126,7 +126,7 @@ void IpfixCsExporter::onDataRecord(IpfixDataRecord* record)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
msg(MSG_DEBUG, "failed to determine source ip for record, assuming 0.0.0.0");
|
||||
msg(LOG_INFO, "failed to determine source ip for record, assuming 0.0.0.0");
|
||||
csRecord->source_ipv4_address = 0;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ void IpfixCsExporter::onDataRecord(IpfixDataRecord* record)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
msg(MSG_DEBUG, "failed to determine destination ip for record, assuming 0.0.0.0");
|
||||
msg(LOG_INFO, "failed to determine destination ip for record, assuming 0.0.0.0");
|
||||
csRecord->destination_ipv4_address = 0;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void IpfixCsExporter::onDataRecord(IpfixDataRecord* record)
|
|||
if (fi != 0) {
|
||||
csRecord->protocol_identifier = *(uint8_t*)(record->data + fi->offset);
|
||||
} else {
|
||||
msg(MSG_DEBUG, "failed to determine protocol for record, using 0");
|
||||
msg(LOG_INFO, "failed to determine protocol for record, using 0");
|
||||
csRecord->protocol_identifier = 0;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ void IpfixCsExporter::onDataRecord(IpfixDataRecord* record)
|
|||
if (fi != 0) {
|
||||
csRecord->source_transport_port = *(uint16_t*)(record->data + fi->offset);/* encode udp/tcp ports here */
|
||||
} else {
|
||||
msg(MSG_DEBUG, "failed to determine source port for record, assuming 0");
|
||||
msg(LOG_INFO, "failed to determine source port for record, assuming 0");
|
||||
csRecord->source_transport_port = 0;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ void IpfixCsExporter::onDataRecord(IpfixDataRecord* record)
|
|||
if (fi != 0) {
|
||||
csRecord->destination_transport_port = *(uint16_t*)(record->data + fi->offset);/* encode udp/tcp ports here */
|
||||
} else {
|
||||
msg(MSG_DEBUG, "failed to determine destination port for record, assuming 0");
|
||||
msg(LOG_INFO, "failed to determine destination port for record, assuming 0");
|
||||
csRecord->destination_transport_port = 0;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ void IpfixCsExporter::writeFileHeader()
|
|||
if (stat(currentFilename,&sta) != 0) {
|
||||
if (errno != 2) {
|
||||
//check error code
|
||||
msg(MSG_ERROR, "IpfixCsExporter: stat() on filename %s returned with error %i (%s)", currentFilename, errno, strerror(errno));
|
||||
msg(LOG_ERR, "IpfixCsExporter: stat() on filename %s returned with error %i (%s)", currentFilename, errno, strerror(errno));
|
||||
} else {
|
||||
// errno==2 means there is no file present
|
||||
break;
|
||||
|
@ -374,7 +374,7 @@ void IpfixCsExporter::writeChunkList()
|
|||
THROWEXCEPTION("Could not chunk header. Check disk space.");
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixCsExporter: writing %u records to disk", chunkListSize);
|
||||
msg(LOG_INFO, "IpfixCsExporter: writing %u records to disk", chunkListSize);
|
||||
|
||||
while (!chunkList.empty()){
|
||||
Ipfix_basic_flow* flow = chunkList.front();
|
||||
|
@ -403,11 +403,11 @@ void IpfixCsExporter::registerTimeout()
|
|||
if (nextChunkTimeout.tv_sec <= nextFileTimeout.tv_sec){
|
||||
// Register a chunk timeout
|
||||
timer->addTimeout(this, nextChunkTimeout, NULL);
|
||||
msg(MSG_DEBUG, "next timeout: %ld", nextChunkTimeout.tv_sec);
|
||||
msg(LOG_INFO, "next timeout: %ld", nextChunkTimeout.tv_sec);
|
||||
} else {
|
||||
// register a file timeout
|
||||
timer->addTimeout(this, nextFileTimeout, NULL);
|
||||
msg(MSG_DEBUG, "next timeout: %ld", nextFileTimeout.tv_sec);
|
||||
msg(LOG_INFO, "next timeout: %ld", nextFileTimeout.tv_sec);
|
||||
}
|
||||
|
||||
timeoutRegistered = true;
|
||||
|
|
|
@ -68,11 +68,11 @@ IpfixCsExporterCfg::IpfixCsExporterCfg(XMLElement* elem)
|
|||
} else if (e->matches("exportMode")){
|
||||
exportMode = atoi(e->getFirstText().c_str());
|
||||
if(exportMode != 0 && exportMode != 1 && exportMode != 2) {
|
||||
msg(MSG_FATAL, "Unknown ipfixCsExporter-exportMode config value %i\n",exportMode);
|
||||
msg(LOG_CRIT, "Unknown ipfixCsExporter-exportMode config value %i\n",exportMode);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown ipfixCsExporter config statement %s\n",
|
||||
msg(LOG_CRIT, "Unknown ipfixCsExporter config statement %s\n",
|
||||
e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ IpfixExporterCfg::IpfixExporterCfg(XMLElement* elem)
|
|||
}
|
||||
|
||||
recordRateLimit = getInt("maxRecordRate", IS_DEFAULT_MAXRECORDRATE);
|
||||
msg(MSG_INFO, "Exporter: using maximum rate of %d records/second", recordRateLimit);
|
||||
msg(LOG_NOTICE, "Exporter: using maximum rate of %d records/second", recordRateLimit);
|
||||
observationDomainId = getInt("observationDomainId", 0);
|
||||
sctpDataLifetime = getTimeInUnit("sctpDataLifetime", mSEC, IS_DEFAULT_SCTP_DATALIFETIME);
|
||||
sctpReconnectInterval = getTimeInUnit("sctpReconnectInterval", SEC, IS_DEFAULT_SCTP_RECONNECTINTERVAL);
|
||||
|
@ -122,7 +122,7 @@ IpfixSender* IpfixExporterCfg::createInstance()
|
|||
default:
|
||||
protocol = "unknown protocol"; break;
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixExporter: adding collector %s://%s:%d",
|
||||
msg(LOG_INFO, "IpfixExporter: adding collector %s://%s:%d",
|
||||
protocol,
|
||||
p->getIpAddress().c_str(),
|
||||
p->getPort());
|
||||
|
|
|
@ -58,7 +58,7 @@ IpfixFileWriter::IpfixFileWriter(uint16_t observationDomainId, std::string filen
|
|||
THROWEXCEPTION("IpfixFileWriter: no filename prefix given. Prefix is required though!");
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixFileWriter: running");
|
||||
msg(LOG_INFO, "IpfixFileWriter: running");
|
||||
}
|
||||
|
||||
IpfixFileWriter::~IpfixFileWriter() {
|
||||
|
@ -78,18 +78,18 @@ int IpfixFileWriter::addCollector(uint16_t observationDomainId, std::string file
|
|||
std::string my_filename = destinationPath + filenamePrefix;
|
||||
if (maximumFilesize <= 0) maximumFilesize = DEFAULTFILESIZE;
|
||||
if(maximumFilesize < 64)
|
||||
msg(MSG_ERROR,
|
||||
msg(LOG_ERR,
|
||||
"maximum filsize < maximum message length - this could lead to serious problems");
|
||||
|
||||
if(ipfix_add_collector(ex, my_filename.c_str(), maximumFilesize, DATAFILE, NULL, "") != 0) {
|
||||
msg(MSG_FATAL, "IpfixFileWriter: ipfix_add_collector of %s failed", my_filename.c_str());
|
||||
msg(LOG_CRIT, "IpfixFileWriter: ipfix_add_collector of %s failed", my_filename.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "IpfixFileWriter: adding %s to exporter", my_filename.c_str());
|
||||
msg(MSG_INFO, "IpfixFileWriter initialized with the following parameters");
|
||||
msg(MSG_INFO, " - Basename = %s", my_filename.c_str());
|
||||
msg(MSG_INFO, " - maximumFilesize = %d KiB" , maximumFilesize);
|
||||
msg(LOG_NOTICE, "IpfixFileWriter: adding %s to exporter", my_filename.c_str());
|
||||
msg(LOG_NOTICE, "IpfixFileWriter initialized with the following parameters");
|
||||
msg(LOG_NOTICE, " - Basename = %s", my_filename.c_str());
|
||||
msg(LOG_NOTICE, " - maximumFilesize = %d KiB" , maximumFilesize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ IpfixFileWriterCfg::IpfixFileWriterCfg(XMLElement* elem)
|
|||
observationDomainId = getInt("observationDomainId");
|
||||
}
|
||||
else {
|
||||
msg(MSG_FATAL, "Unknown ipfixFileWriter config statement %s\n",
|
||||
msg(LOG_CRIT, "Unknown ipfixFileWriter config statement %s\n",
|
||||
e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ void IpfixNetflowExporter::sendPacket()
|
|||
record->removeReference();
|
||||
count++;
|
||||
}
|
||||
msg(MSG_DEBUG, "sending Netflow.v5 packet, flow count: %u", count);
|
||||
msg(LOG_INFO, "sending Netflow.v5 packet, flow count: %u", count);
|
||||
packet.header.count = htons(count);
|
||||
packet.header.unixSec = htonl(tv.tv_sec);
|
||||
packet.header.unixNanoSec = htonl(tv.tv_usec*1000);
|
||||
|
@ -187,7 +187,7 @@ void IpfixNetflowExporter::sendPacket()
|
|||
|
||||
uint16_t packetsize = sizeof(NetflowV5Header)+count*sizeof(NetflowV5DataRecord);
|
||||
if (sendto(sockfd, &packet, packetsize, 0, (struct sockaddr*)(&siDest), sizeof(siDest))==-1) {
|
||||
msg(MSG_ERROR, "IpfixNetflowExporter: WARNING, failed to send UDP packet (%s)", strerror(errno));
|
||||
msg(LOG_ERR, "IpfixNetflowExporter: WARNING, failed to send UDP packet (%s)", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ uint32_t IpfixParser::processTemplateSet(boost::shared_ptr<IpfixRecord::SourceID
|
|||
|
||||
/* check if set length lies within message boundaries */
|
||||
if (endOfSet > endOfMessage) {
|
||||
msg(MSG_ERROR, "IpfixParser: Template set exceeds message boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Template set exceeds message boundary!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ uint32_t IpfixParser::processTemplateSet(boost::shared_ptr<IpfixRecord::SourceID
|
|||
for (fieldNo = 0; fieldNo < ti->fieldCount; fieldNo++) {
|
||||
/* check if there are at least 4 bytes for this field */
|
||||
if (record+4 > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Template record (id=%u) exceeds set boundary!", bt->templateInfo->templateId);
|
||||
msg(LOG_ERR, "IpfixParser: Template record (id=%u) exceeds set boundary!", bt->templateInfo->templateId);
|
||||
delete bt;
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ uint32_t IpfixParser::processTemplateSet(boost::shared_ptr<IpfixRecord::SourceID
|
|||
if ((ti->fieldInfo[fieldNo].type.id & IPFIX_ENTERPRISE_TYPE) && setId == TemplateInfo::IpfixTemplate) {
|
||||
/* check if there are 8 bytes for this field */
|
||||
if (record+8 > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Template record (id=%u) exceeds set boundary!", bt->templateInfo->templateId);
|
||||
msg(LOG_ERR, "IpfixParser: Template record (id=%u) exceeds set boundary!", bt->templateInfo->templateId);
|
||||
delete bt;
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ uint32_t IpfixParser::processOptionsTemplateSet(boost::shared_ptr<IpfixRecord::S
|
|||
|
||||
/* check if set length lies within message boundaries */
|
||||
if (endOfSet > endOfMessage) {
|
||||
msg(MSG_ERROR, "IpfixParser: Options Template set exceeds message boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Options Template set exceeds message boundary!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ uint32_t IpfixParser::processOptionsTemplateSet(boost::shared_ptr<IpfixRecord::S
|
|||
|
||||
/* Non-withdrawal options template records are >= 6 byte */
|
||||
if (record > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Strange long padding in Options Template");
|
||||
msg(LOG_ERR, "IpfixParser: Strange long padding in Options Template");
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ uint32_t IpfixParser::processOptionsTemplateSet(boost::shared_ptr<IpfixRecord::S
|
|||
for (scopeNo = 0; scopeNo < ti->scopeCount; scopeNo++) {
|
||||
/* check if there are at least 4 bytes for this field */
|
||||
if (record+4 > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Options Template record exceeds set boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Options Template record exceeds set boundary!");
|
||||
delete bt;
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ uint32_t IpfixParser::processOptionsTemplateSet(boost::shared_ptr<IpfixRecord::S
|
|||
if ((ti->scopeInfo[scopeNo].type.id & IPFIX_ENTERPRISE_TYPE) && setId == TemplateInfo::IpfixOptionsTemplate) {
|
||||
/* check if there are 8 bytes for this field */
|
||||
if (record+8 > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Options Template record exceeds set boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Options Template record exceeds set boundary!");
|
||||
delete bt;
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ uint32_t IpfixParser::processOptionsTemplateSet(boost::shared_ptr<IpfixRecord::S
|
|||
for (fieldNo = 0; fieldNo < ti->fieldCount; fieldNo++) {
|
||||
/* check if there are at least 4 bytes for this field */
|
||||
if (record+4 > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Template record exceeds set boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Template record exceeds set boundary!");
|
||||
delete bt;
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ uint32_t IpfixParser::processOptionsTemplateSet(boost::shared_ptr<IpfixRecord::S
|
|||
if ((ti->fieldInfo[fieldNo].type.id & IPFIX_ENTERPRISE_TYPE) && setId == TemplateInfo::IpfixOptionsTemplate) {
|
||||
/* check if there are 8 bytes for this field */
|
||||
if (record+8 > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Template record exceeds set boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Template record exceeds set boundary!");
|
||||
delete bt;
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -310,10 +310,10 @@ uint32_t IpfixParser::processDataSet(boost::shared_ptr<IpfixRecord::SourceID> so
|
|||
if (bt == 0) {
|
||||
/* this error may come in rapid succession; I hope I don't regret it */
|
||||
if(sourceId->exporterAddress.len == 4) {
|
||||
msg(MSG_INFO, "Template %d from %s unknown to collecting process",
|
||||
msg(LOG_NOTICE, "Template %d from %s unknown to collecting process",
|
||||
ntohs(set->id), (sourceId->toString()).c_str());
|
||||
} else {
|
||||
msg(MSG_INFO, "Template %d from non-IPv4 unknown to collecting process", ntohs(set->id));
|
||||
msg(LOG_NOTICE, "Template %d from non-IPv4 unknown to collecting process", ntohs(set->id));
|
||||
}
|
||||
DPRINTF("Protocol: %u Remote Port: %u", sourceId->protocol, sourceId->exporterPort);
|
||||
return 0;
|
||||
|
@ -324,7 +324,7 @@ uint32_t IpfixParser::processDataSet(boost::shared_ptr<IpfixRecord::SourceID> so
|
|||
|
||||
/* check if set length lies within message boundaries */
|
||||
if (endOfSet > endOfMessage) {
|
||||
msg(MSG_ERROR, "IpfixParser: Data set exceeds message boundary!");
|
||||
msg(LOG_ERR, "IpfixParser: Data set exceeds message boundary!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ uint32_t IpfixParser::processDataSet(boost::shared_ptr<IpfixRecord::SourceID> so
|
|||
|
||||
if (bt->recordLength < 65535) {
|
||||
if (record + bt->recordLength > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Got a Data Set that contained not a single full record");
|
||||
msg(LOG_ERR, "IpfixParser: Got a Data Set that contained not a single full record");
|
||||
}
|
||||
else
|
||||
/* We stop processing when no full record is left */
|
||||
|
@ -358,7 +358,7 @@ uint32_t IpfixParser::processDataSet(boost::shared_ptr<IpfixRecord::SourceID> so
|
|||
/* We assume that each field is at least 1 byte */
|
||||
/* scopeCount is zero for all Templates except Options Templates */
|
||||
if (record + ti->fieldCount + ti->scopeCount > endOfSet) {
|
||||
msg(MSG_ERROR, "IpfixParser: Got a Data Set that contained not a single full record");
|
||||
msg(LOG_ERR, "IpfixParser: Got a Data Set that contained not a single full record");
|
||||
}
|
||||
else while (record < endOfSet) {
|
||||
int recordLength=0;
|
||||
|
@ -447,7 +447,7 @@ uint32_t IpfixParser::processDataSet(boost::shared_ptr<IpfixRecord::SourceID> so
|
|||
}
|
||||
}
|
||||
} else {
|
||||
msg(MSG_FATAL, "Data Set based on known but unhandled Template type %d", bt->templateInfo->setId);
|
||||
msg(LOG_CRIT, "Data Set based on known but unhandled Template type %d", bt->templateInfo->setId);
|
||||
}
|
||||
return numberOfRecords;
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ uint32_t IpfixParser::processDataSet(boost::shared_ptr<IpfixRecord::SourceID> so
|
|||
int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, uint16_t length, boost::shared_ptr<IpfixRecord::SourceID> sourceId)
|
||||
{
|
||||
if (length < sizeof(NetflowV9Header)) {
|
||||
msg(MSG_ERROR, "IpfixParser: Invalid NetFlowV9 message - message too short to contain header!");
|
||||
msg(LOG_ERR, "IpfixParser: Invalid NetFlowV9 message - message too short to contain header!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
|
|||
while (((numberOfDataRecords + numberOfTemplateRecords) <= expectedNumberOfRecords) && (((uint8_t*)(set) + 4) <= endOfMessage)) {
|
||||
/* check set length */
|
||||
if (ntohs(set->length) < 3) {
|
||||
msg(MSG_ERROR, "IpfixParser: Invalid set length %u, must be >= 4", ntohs(set->length));
|
||||
msg(LOG_ERR, "IpfixParser: Invalid set length %u, must be >= 4", ntohs(set->length));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
|
|||
if(tmpid >= IPFIX_SetId_Data_Start) {
|
||||
numberOfDataRecords += processDataSet(sourceId, message, set, endOfMessage);
|
||||
} else {
|
||||
msg(MSG_ERROR, "processNetflowV9Packet: Unsupported Set ID - expected 0/1/256+, got %d", tmpid);
|
||||
msg(LOG_ERR, "processNetflowV9Packet: Unsupported Set ID - expected 0/1/256+, got %d", tmpid);
|
||||
}
|
||||
}
|
||||
set = (IpfixSetHeader*)((uint8_t*)set + ntohs(set->length));
|
||||
|
@ -509,11 +509,11 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
|
|||
|
||||
/* check if there are trailing bytes */
|
||||
if ((uint8_t*)(set) != endOfMessage) {
|
||||
msg(MSG_ERROR, "IpfixParser: NetFlowV9 message contains %ld trailing bytes!", endOfMessage - (uint8_t*)(set));
|
||||
msg(LOG_ERR, "IpfixParser: NetFlowV9 message contains %ld trailing bytes!", endOfMessage - (uint8_t*)(set));
|
||||
}
|
||||
/* check if we got all records */
|
||||
if ((numberOfDataRecords + numberOfTemplateRecords) != expectedNumberOfRecords) {
|
||||
msg(MSG_INFO, "IpfixParser: NetFlowV9 message header indicates %u records, but there were only %u records! Maybe the Template is unknown.", expectedNumberOfRecords, numberOfDataRecords+numberOfTemplateRecords);
|
||||
msg(LOG_NOTICE, "IpfixParser: NetFlowV9 message header indicates %u records, but there were only %u records! Maybe the Template is unknown.", expectedNumberOfRecords, numberOfDataRecords+numberOfTemplateRecords);
|
||||
}
|
||||
|
||||
// detect and count data record losses
|
||||
|
@ -523,11 +523,11 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
|
|||
if(iter != snInfoMap.end()) {
|
||||
int64_t difference = (int64_t)sequenceNumber - (int64_t)iter->second.expectedSN;
|
||||
if(difference > 0) {
|
||||
msg(MSG_INFO, "IpfixParser: Loss of %ld NetflowV9 messages from %s detected (SN=%u, expected=%u).",
|
||||
msg(LOG_NOTICE, "IpfixParser: Loss of %ld NetflowV9 messages from %s detected (SN=%u, expected=%u).",
|
||||
difference, (sourceId->toString()).c_str(), sequenceNumber, iter->second.expectedSN);
|
||||
iter->second.lostMessages += difference;
|
||||
} else if (difference < 0) {
|
||||
msg(MSG_INFO, "IpfixParser: Out-of-order or repeated NetflowV9 message detected from %s (SN=%u, expected=%u).",
|
||||
msg(LOG_NOTICE, "IpfixParser: Out-of-order or repeated NetflowV9 message detected from %s (SN=%u, expected=%u).",
|
||||
(sourceId->toString()).c_str(), sequenceNumber, iter->second.expectedSN);
|
||||
iter->second.outOfOrderMessages++;
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
|
|||
}
|
||||
}
|
||||
|
||||
msg(MSG_VDEBUG, "NetflowV9 message from %s contained %u Data Records and %u Template Records. Sequence number was %lu.",
|
||||
msg(LOG_DEBUG, "NetflowV9 message from %s contained %u Data Records and %u Template Records. Sequence number was %lu.",
|
||||
(sourceId->toString()).c_str(), numberOfDataRecords, numberOfTemplateRecords, (unsigned long) sequenceNumber);
|
||||
|
||||
// Update statistics
|
||||
|
@ -563,7 +563,7 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
|
|||
int IpfixParser::processIpfixPacket(boost::shared_array<uint8_t> message, uint16_t length, boost::shared_ptr<IpfixRecord::SourceID> sourceId)
|
||||
{
|
||||
if (length < sizeof(IpfixHeader)) {
|
||||
msg(MSG_ERROR, "IpfixParser: Invalide IPFIX message - message too short to contain header!");
|
||||
msg(LOG_ERR, "IpfixParser: Invalide IPFIX message - message too short to contain header!");
|
||||
return -1;
|
||||
}
|
||||
IpfixHeader* header = (IpfixHeader*)message.get();
|
||||
|
@ -571,7 +571,7 @@ int IpfixParser::processIpfixPacket(boost::shared_array<uint8_t> message, uint16
|
|||
sourceId->exportTime = ntohl(header->exportTime);
|
||||
|
||||
if (ntohs(header->length) != length) {
|
||||
msg(MSG_ERROR, "IpfixParser: Bad message length - packet length is %#06x, header length field is %#06x\n", length, ntohs(header->length));
|
||||
msg(LOG_ERR, "IpfixParser: Bad message length - packet length is %#06x, header length field is %#06x\n", length, ntohs(header->length));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ int IpfixParser::processIpfixPacket(boost::shared_array<uint8_t> message, uint16
|
|||
while((uint8_t*)(set) + 4 <= endOfMessage) {
|
||||
/* check set length */
|
||||
if (ntohs(set->length) < 3) {
|
||||
msg(MSG_ERROR, "IpfixParser: Invalid set length %u, must be >= 4", ntohs(set->length));
|
||||
msg(LOG_ERR, "IpfixParser: Invalid set length %u, must be >= 4", ntohs(set->length));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -607,7 +607,7 @@ int IpfixParser::processIpfixPacket(boost::shared_array<uint8_t> message, uint16
|
|||
if(tmpid >= IPFIX_SetId_Data_Start) {
|
||||
numberOfDataRecords += processDataSet(sourceId, message, set, endOfMessage);
|
||||
} else {
|
||||
msg(MSG_ERROR, "processIpfixPacket: Unsupported Set ID - expected 2/3/4/256+, got %d", tmpid);
|
||||
msg(LOG_ERR, "processIpfixPacket: Unsupported Set ID - expected 2/3/4/256+, got %d", tmpid);
|
||||
}
|
||||
}
|
||||
set = (IpfixSetHeader*)((uint8_t*)set + ntohs(set->length));
|
||||
|
@ -620,11 +620,11 @@ int IpfixParser::processIpfixPacket(boost::shared_array<uint8_t> message, uint16
|
|||
if(iter != snInfoMap.end()) {
|
||||
int64_t difference = (int64_t)sequenceNumber - (int64_t)iter->second.expectedSN;
|
||||
if(difference > 0) {
|
||||
msg(MSG_INFO, "IpfixParser: Loss of %ld IPFIX Data Records from %s detected (SN=%u, expected=%u).",
|
||||
msg(LOG_NOTICE, "IpfixParser: Loss of %ld IPFIX Data Records from %s detected (SN=%u, expected=%u).",
|
||||
difference, (sourceId->toString()).c_str(), sequenceNumber, iter->second.expectedSN);
|
||||
iter->second.lostDataRecords += difference;
|
||||
} else if (difference < 0) {
|
||||
msg(MSG_INFO, "IpfixParser: Out-of-order or repeated IPFIX message detected from %s (SN=%u, expected=%u).",
|
||||
msg(LOG_NOTICE, "IpfixParser: Out-of-order or repeated IPFIX message detected from %s (SN=%u, expected=%u).",
|
||||
(sourceId->toString()).c_str(), sequenceNumber, iter->second.expectedSN);
|
||||
iter->second.outOfOrderMessages ++;
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ int IpfixParser::processIpfixPacket(boost::shared_array<uint8_t> message, uint16
|
|||
}
|
||||
}
|
||||
|
||||
msg(MSG_VDEBUG, "IPFIX message from %s contained %u Data Records and %u Template Records. Sequence number was %lu.",
|
||||
msg(LOG_DEBUG, "IPFIX message from %s contained %u Data Records and %u Template Records. Sequence number was %lu.",
|
||||
(sourceId->toString()).c_str(), numberOfDataRecords, numberOfTemplateRecords, (unsigned long) sequenceNumber);
|
||||
|
||||
// Update statistics
|
||||
|
@ -669,7 +669,7 @@ int IpfixParser::processPacket(boost::shared_array<uint8_t> message, uint16_t le
|
|||
if (ntohs(header->version) == 0x000a) {
|
||||
if (!isWithinTimeBoundary(ntohl(header->exportTime))) {
|
||||
uint32_t currentTime = static_cast<uint32_t>(time(NULL));
|
||||
msg(MSG_ERROR, "Received old message. Current time is %u. Message time is %u", currentTime, ntohl(header->exportTime));
|
||||
msg(LOG_ERR, "Received old message. Current time is %u. Message time is %u", currentTime, ntohl(header->exportTime));
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return -1;
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ int IpfixParser::processPacket(boost::shared_array<uint8_t> message, uint16_t le
|
|||
NetflowV9Header* nfHeader = (NetflowV9Header*)message.get();
|
||||
if (!isWithinTimeBoundary(ntohl(nfHeader->exportTime))) {
|
||||
uint32_t currentTime = static_cast<uint32_t>(time(NULL));
|
||||
msg(MSG_ERROR, "Received old message. Current time is %u. Message time is %u", currentTime, ntohl(nfHeader->exportTime));
|
||||
msg(LOG_ERR, "Received old message. Current time is %u. Message time is %u", currentTime, ntohl(nfHeader->exportTime));
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return -1;
|
||||
}
|
||||
|
@ -690,11 +690,11 @@ int IpfixParser::processPacket(boost::shared_array<uint8_t> message, uint16_t le
|
|||
pthread_mutex_unlock(&mutex);
|
||||
return r;
|
||||
}
|
||||
msg(MSG_ERROR, "Bad message version - expected 0x009 or 0x000a, got %#06x\n", ntohs(header->version));
|
||||
msg(LOG_ERR, "Bad message version - expected 0x009 or 0x000a, got %#06x\n", ntohs(header->version));
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return -1;
|
||||
#else
|
||||
msg(MSG_ERROR, "Bad message version - expected 0x000a, got %#06x\n", ntohs(header->version));
|
||||
msg(LOG_ERR, "Bad message version - expected 0x000a, got %#06x\n", ntohs(header->version));
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -713,7 +713,7 @@ IpfixParser::IpfixParser(IpfixRecordSender* sender)
|
|||
{
|
||||
|
||||
if (pthread_mutex_init(&mutex, NULL) != 0) {
|
||||
msg(MSG_FATAL, "Could not init mutex");
|
||||
msg(LOG_CRIT, "Could not init mutex");
|
||||
THROWEXCEPTION("IpfixParser creation failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -46,13 +46,13 @@ IpfixPayloadWriter::IpfixPayloadWriter(string path, string prefix, uint32_t noco
|
|||
statEmptyPayloadDropped(0),
|
||||
statIncompleteTCPDropped(0)
|
||||
{
|
||||
msg(MSG_INFO, "IpfixPayloadWriter started with following parameters:");
|
||||
msg(MSG_INFO, " - path=%s", path.c_str());
|
||||
msg(MSG_INFO, " - filenamePrefix=%s", filenamePrefix.c_str());
|
||||
msg(MSG_INFO, " - noConnections=%u", noConnections);
|
||||
msg(MSG_INFO, " - startIndex=%lu", connectionID);
|
||||
msg(MSG_INFO, " - ignoreEmptyPayload=%u", ignoreEmptyPayload);
|
||||
msg(MSG_INFO, " - ignoreIncompleteTCP=%u", ignoreIncompleteTCP);
|
||||
msg(LOG_NOTICE, "IpfixPayloadWriter started with following parameters:");
|
||||
msg(LOG_NOTICE, " - path=%s", path.c_str());
|
||||
msg(LOG_NOTICE, " - filenamePrefix=%s", filenamePrefix.c_str());
|
||||
msg(LOG_NOTICE, " - noConnections=%u", noConnections);
|
||||
msg(LOG_NOTICE, " - startIndex=%lu", connectionID);
|
||||
msg(LOG_NOTICE, " - ignoreEmptyPayload=%u", ignoreEmptyPayload);
|
||||
msg(LOG_NOTICE, " - ignoreIncompleteTCP=%u", ignoreIncompleteTCP);
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,10 +143,10 @@ void IpfixPayloadWriter::dumpEntry(Connection* conn)
|
|||
string filepayload[2] = { mkpath + string(filename[0]) + ".payload", mkpath + string(filename[1]) + ".payload" };
|
||||
string fileinfo = mkpath + string(filename[0]) + ".info";
|
||||
|
||||
msg(MSG_VDEBUG, "writing files for connection %s", filename[0]);
|
||||
msg(LOG_DEBUG, "writing files for connection %s", filename[0]);
|
||||
|
||||
if (stat(filepayload[0].c_str(), &s) == 0 && !filewarningIssued) {
|
||||
msg(MSG_DIALOG, "files in IpfixPayloadWriter destination directory already present, overwriting ...");
|
||||
msg(LOG_WARNING, "files in IpfixPayloadWriter destination directory already present, overwriting ...");
|
||||
filewarningIssued = true;
|
||||
}
|
||||
// save payload in two files
|
||||
|
|
|
@ -63,7 +63,7 @@ IpfixPayloadWriterCfg::IpfixPayloadWriterCfg(XMLElement* elem)
|
|||
startIdx = getInt64("startIndex");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixPayloadWriter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixPayloadWriter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ void PrintHelpers::printUint(InformationElement::IeInfo type, IpfixRecord::Data*
|
|||
fprintf(fh, "%02hhX",*(uint8_t*)(data+i));
|
||||
}
|
||||
fprintf(fh, " (%u bytes)", type.length);
|
||||
//msg(MSG_ERROR, "Uint with length %u unparseable", type.length);
|
||||
//msg(LOG_ERR, "Uint with length %u unparseable", type.length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ void PrintHelpers::printLocaltime(InformationElement::IeInfo type, IpfixRecord::
|
|||
fprintf(fh, "%02hhX",*(uint8_t*)(data+i));
|
||||
}
|
||||
fprintf(fh, " (%u bytes)", type.length);
|
||||
//msg(MSG_ERROR, "Uint with length %u unparseable", type.length);
|
||||
//msg(LOG_ERR, "Uint with length %u unparseable", type.length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void PrintHelpers::printUint(char* buf, InformationElement::IeInfo type, IpfixRe
|
|||
sprintf(buf, "%llu",(long long unsigned)ntohll(*(uint64_t*)data));
|
||||
return;
|
||||
default:
|
||||
msg(MSG_ERROR, "Uint with length %u unparseable", type.length);
|
||||
msg(LOG_ERR, "Uint with length %u unparseable", type.length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ IpfixPrinter::IpfixPrinter(OutputType outputtype, string filename)
|
|||
{
|
||||
lastTemplate = 0;
|
||||
|
||||
msg(MSG_INFO, "IpfixPrinter started with following parameters:");
|
||||
msg(LOG_NOTICE, "IpfixPrinter started with following parameters:");
|
||||
string type;
|
||||
switch (outputtype) {
|
||||
case TREE: type = "tree"; break;
|
||||
|
@ -376,10 +376,10 @@ IpfixPrinter::IpfixPrinter(OutputType outputtype, string filename)
|
|||
case TABLE: type = "table"; break;
|
||||
case NONE: type = "no output"; break;
|
||||
}
|
||||
msg(MSG_INFO, " - outputType=%s", type.c_str());
|
||||
msg(LOG_NOTICE, " - outputType=%s", type.c_str());
|
||||
string file = "standard output";
|
||||
if (filename!="") file = "in file '" + filename + "'";
|
||||
msg(MSG_INFO, " - output=%s", file.c_str());
|
||||
msg(LOG_NOTICE, " - output=%s", file.c_str());
|
||||
|
||||
fh = stdout;
|
||||
if (filename != "") {
|
||||
|
@ -400,7 +400,7 @@ IpfixPrinter::~IpfixPrinter()
|
|||
if (filename != "") {
|
||||
int ret = fclose(fh);
|
||||
if (ret)
|
||||
msg(MSG_ERROR, "IpfixPrinter: error closing file '%s': %s (%u)", filename.c_str(), strerror(errno), errno);
|
||||
msg(LOG_ERR, "IpfixPrinter: error closing file '%s': %s (%u)", filename.c_str(), strerror(errno), errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ void IpfixPrinter::onTemplate(IpfixTemplateRecord* record)
|
|||
fprintf(fh, "\n-+--- Ipfix Options Template (id=%u, uniqueId=%u) from ", templateInfo->templateId, templateInfo->getUniqueId());
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "IpfixPrinter: Template with unknown setId=%u, uniqueId=%u", templateInfo->setId, templateInfo->getUniqueId());
|
||||
msg(LOG_ERR, "IpfixPrinter: Template with unknown setId=%u, uniqueId=%u", templateInfo->setId, templateInfo->getUniqueId());
|
||||
|
||||
}
|
||||
if (record->sourceID) {
|
||||
|
@ -487,7 +487,7 @@ void IpfixPrinter::onTemplateDestruction(IpfixTemplateDestructionRecord* record)
|
|||
fprintf(fh, "\n-+--- Destroyed Ipfix Options Template (id=%u, uniqueId=%u) from ", templateInfo->templateId, templateInfo->getUniqueId());
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "IpfixPrinter: Template destruction recordwith unknown setId=%u, uniqueId=%u", templateInfo->setId, templateInfo->getUniqueId());
|
||||
msg(LOG_ERR, "IpfixPrinter: Template destruction recordwith unknown setId=%u, uniqueId=%u", templateInfo->setId, templateInfo->getUniqueId());
|
||||
|
||||
}
|
||||
if (record->sourceID) {
|
||||
|
@ -678,7 +678,7 @@ void IpfixPrinter::printTreeRecord(IpfixDataRecord* record)
|
|||
fprintf(fh, "\n-+--- Ipfix Options Data Record (id=%u) from ", record->templateInfo->templateId);
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "IpfixPrinter: Template with unknown setid=%u", record->templateInfo->setId);
|
||||
msg(LOG_ERR, "IpfixPrinter: Template with unknown setid=%u", record->templateInfo->setId);
|
||||
|
||||
}
|
||||
if (record->sourceID) {
|
||||
|
|
|
@ -27,7 +27,7 @@ IpfixPrinterCfg::IpfixPrinterCfg(XMLElement* elem)
|
|||
if (!elem)
|
||||
return;
|
||||
|
||||
msg(MSG_INFO, "ParserCfg: Start reading ipfixPrinter section");
|
||||
msg(LOG_NOTICE, "ParserCfg: Start reading ipfixPrinter section");
|
||||
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
|
||||
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin(); it != set.end(); it++) {
|
||||
XMLElement* e = *it;
|
||||
|
@ -48,7 +48,7 @@ IpfixPrinterCfg::IpfixPrinterCfg(XMLElement* elem)
|
|||
} else if (e->matches("filename")) {
|
||||
filename = e->getFirstText();
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixPrinter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixPrinter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ void IpfixRawdirReader::run() {
|
|||
while(!exitFlag) {
|
||||
|
||||
if (dir_iterator == end_iterator) {
|
||||
msg(MSG_DEBUG, "No more packets in packet directory path, terminating listener thread");
|
||||
msg(LOG_INFO, "No more packets in packet directory path, terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -78,14 +78,14 @@ void IpfixRawdirReader::run() {
|
|||
std::string fname = packet_directory_path+"/"+dir_iterator->path().filename();
|
||||
#endif
|
||||
if (boost::filesystem::is_directory(*dir_iterator)) {
|
||||
msg(MSG_DEBUG, "Skipping directory \"%s\"", fname.c_str());
|
||||
msg(LOG_INFO, "Skipping directory \"%s\"", fname.c_str());
|
||||
dir_iterator++;
|
||||
continue;
|
||||
}
|
||||
|
||||
dir_iterator++;
|
||||
|
||||
msg(MSG_DEBUG, "Trying to read packet from file \"%s\"", fname.c_str());
|
||||
msg(LOG_INFO, "Trying to read packet from file \"%s\"", fname.c_str());
|
||||
std::ifstream packetFile(fname.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
packetFile.seekg(0, std::ios::end);
|
||||
|
@ -93,7 +93,7 @@ void IpfixRawdirReader::run() {
|
|||
packetFile.seekg(0, std::ios::beg);
|
||||
|
||||
if (n > MAX_MSG_LEN) {
|
||||
msg(MSG_DEBUG, "File too big \"%s\"", fname.c_str());
|
||||
msg(LOG_INFO, "File too big \"%s\"", fname.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ void IpfixRawdirReader::run() {
|
|||
packetFile.read(reinterpret_cast<char*>(data.get()), n);
|
||||
|
||||
if (packetFile.bad()) {
|
||||
msg(MSG_DEBUG, "could not read from packet file, terminating listener thread");
|
||||
msg(LOG_INFO, "could not read from packet file, terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ void IpfixRawdirReader::run() {
|
|||
sourceID->exporterAddress.len = 4;
|
||||
|
||||
for (std::list<IpfixPacketProcessor*>::iterator i = packetProcessors.begin(); i != packetProcessors.end(); ++i) {
|
||||
msg(MSG_DEBUG, "Data block starts with: %x %x %x %x", data[0], data[1], data[2], data[3]);
|
||||
msg(LOG_INFO, "Data block starts with: %x %x %x %x", data[0], data[1], data[2], data[3]);
|
||||
(*i)->processPacket(data, n, sourceID);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ IpfixRawdirWriter::IpfixRawdirWriter(uint32_t observationDomainId, std::string p
|
|||
}
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixRawdirWriter: running");
|
||||
msg(LOG_INFO, "IpfixRawdirWriter: running");
|
||||
}
|
||||
|
||||
IpfixRawdirWriter::~IpfixRawdirWriter() {
|
||||
|
@ -63,11 +63,11 @@ int IpfixRawdirWriter::addCollector(std::string packetDirectoryName) {
|
|||
ipfix_exporter *ex = (ipfix_exporter *)ipfixExporter;
|
||||
|
||||
if(ipfix_add_collector(ex, packetDirectoryName.c_str(), 0, RAWDIR, NULL) != 0) {
|
||||
msg(MSG_FATAL, "IpfixRawdirWriter: ipfix_add_collector of %s failed", packetDirectoryName.c_str());
|
||||
msg(LOG_CRIT, "IpfixRawdirWriter: ipfix_add_collector of %s failed", packetDirectoryName.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "IpfixRawdirWriter: adding %s to exporter", packetDirectoryName.c_str());
|
||||
msg(LOG_NOTICE, "IpfixRawdirWriter: adding %s to exporter", packetDirectoryName.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ int IpfixReceiver::addAuthorizedHost(const char* host)
|
|||
struct in_addr inaddr;
|
||||
|
||||
if (inet_aton(host, &inaddr) == 0) {
|
||||
msg(MSG_ERROR, "Invalid host address: %s", host);
|
||||
msg(LOG_ERR, "Invalid host address: %s", host);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -190,11 +190,11 @@ void IpfixReceiver::setBufferSize(const int sockfd, const uint32_t buffer)
|
|||
{
|
||||
if (buffer != 0) {
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &buffer, sizeof(uint32_t)) == -1) {
|
||||
msg(MSG_ERROR, "Error setting socket buffer size: %s", strerror(errno));
|
||||
msg(LOG_ERR, "Error setting socket buffer size: %s", strerror(errno));
|
||||
}
|
||||
uint32_t temp;
|
||||
socklen_t len = sizeof(temp);
|
||||
getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &temp, &len);
|
||||
msg(MSG_INFO, "Socket buffer size set to %" PRIu32 " bytes", temp);
|
||||
msg(LOG_NOTICE, "Socket buffer size set to %" PRIu32 " bytes", temp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ IpfixReceiverDtlsSctpIpV4::IpfixReceiverDtlsSctpIpV4(int port, const std::string
|
|||
listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
|
||||
if(listen_socket < 0) {
|
||||
/* FIXME: should we use strerror_r? */
|
||||
msg(MSG_FATAL, "socket creation failed: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "socket creation failed: %s", strerror(errno));
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverDtlsSctpIpV4, socket creation failed: %s", strerror(errno));
|
||||
}
|
||||
/* set socket to non-blocking i/o */
|
||||
|
@ -88,21 +88,21 @@ IpfixReceiverDtlsSctpIpV4::IpfixReceiverDtlsSctpIpV4(int port, const std::string
|
|||
serverAddress.sin_port = htons(port);
|
||||
if(bind(listen_socket, (struct sockaddr*)&serverAddress,
|
||||
sizeof(struct sockaddr_in)) < 0) {
|
||||
msg(MSG_FATAL, "Cannot bind socket: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "Cannot bind socket: %s", strerror(errno));
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverDtlsSctpIpV4 %s:%d",ipAddr.c_str(), port );
|
||||
}
|
||||
if(listen(listen_socket, SCTP_MAX_BACKLOG) < 0 ) {
|
||||
msg(MSG_FATAL, "Can not listen socket: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "Can not listen socket: %s", strerror(errno));
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverDtlsSctpIpV4 %s:%d",ipAddr.c_str(), port );
|
||||
}
|
||||
msg(MSG_INFO, "SCTP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
msg(LOG_NOTICE, "SCTP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
port,
|
||||
listen_socket);
|
||||
|
||||
memset(&ses, 0, sizeof(ses));
|
||||
ses.sctp_data_io_event = 1;
|
||||
if ( setsockopt(listen_socket, IPPROTO_SCTP, SCTP_EVENTS, &ses, sizeof(ses))) {
|
||||
msg(MSG_FATAL, "setsockopt() failed: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "setsockopt() failed: %s", strerror(errno));
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverDtlsSctpIpV4 %s:%d",ipAddr.c_str(), port );
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ IpfixReceiverDtlsSctpIpV4::IpfixReceiverDtlsSctpIpV4(int port, const std::string
|
|||
SensorManager::getInstance().addSensor(this, "IpfixReceiverDtlsSctpIpV4",
|
||||
moduleId);
|
||||
|
||||
msg(MSG_INFO, "DTLS over SCTP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
msg(LOG_NOTICE, "DTLS over SCTP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
port,
|
||||
listen_socket);
|
||||
} catch(...) {
|
||||
|
@ -184,7 +184,7 @@ void IpfixReceiverDtlsSctpIpV4::run() {
|
|||
continue;
|
||||
}
|
||||
if (ret < 0) {
|
||||
msg(MSG_ERROR ,"select() returned with an error: %s",strerror(errno));
|
||||
msg(LOG_ERR ,"select() returned with an error: %s",strerror(errno));
|
||||
THROWEXCEPTION("IpfixReceiverDtlsSctpIpV4: terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
@ -199,13 +199,13 @@ void IpfixReceiverDtlsSctpIpV4::run() {
|
|||
/* Do not accept connections from unauthorized hosts. */
|
||||
close(rfd);
|
||||
} else {
|
||||
msg(MSG_DEBUG, "IpfixReceiverDtlsSctpIpV4: Client connected from %s:%d, FD=%d", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
msg(LOG_INFO, "IpfixReceiverDtlsSctpIpV4: Client connected from %s:%d, FD=%d", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
DtlsConnectionPtr conn = DtlsConnectionPtr( new DtlsConnection(*this,&clientAddress,rfd));
|
||||
connections.insert(make_pair(rfd,conn));
|
||||
update_maxfd();
|
||||
}
|
||||
}else{
|
||||
msg(MSG_ERROR ,"accept() in ipfixReceiver failed");
|
||||
msg(LOG_ERR ,"accept() in ipfixReceiver failed");
|
||||
/* TODO: Don't throw an exception here. */
|
||||
THROWEXCEPTION("IpfixReceiverDtlsSctpIpV4: unable to accept new connection");
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ void IpfixReceiverDtlsSctpIpV4::run() {
|
|||
connections_map::iterator it = connections.find(rfd);
|
||||
if (it == connections.end()) {
|
||||
/* This should not happend. */
|
||||
msg(MSG_ERROR,"Can't find connection for file descriptor.");
|
||||
msg(LOG_ERR,"Can't find connection for file descriptor.");
|
||||
FD_CLR(rfd,&readfds);
|
||||
FD_CLR(rfd,&writefds);
|
||||
continue;
|
||||
|
@ -233,7 +233,7 @@ void IpfixReceiverDtlsSctpIpV4::run() {
|
|||
}
|
||||
}
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixReceiverDtlsSctpIpV4: Exiting");
|
||||
msg(LOG_INFO, "IpfixReceiverDtlsSctpIpV4: Exiting");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -303,7 +303,7 @@ int IpfixReceiverDtlsSctpIpV4::DtlsConnection::fdready() {
|
|||
ret = SSL_read(ssl,data.get(),MAX_MSG_LEN);
|
||||
error = SSL_get_error(ssl,ret);
|
||||
#ifdef DEBUG
|
||||
msg_openssl_return_code(MSG_DEBUG,"SSL_read()",ret,error);
|
||||
msg_openssl_return_code(LOG_INFO,"SSL_read()",ret,error);
|
||||
DPRINTF("Error: %s",strerror(errno));
|
||||
DPRINTF("Received shutdown: %s",SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN ? "yes":"no");
|
||||
#endif
|
||||
|
@ -317,7 +317,7 @@ int IpfixReceiverDtlsSctpIpV4::DtlsConnection::fdready() {
|
|||
FD_CLR(socket,&parent.readfds);
|
||||
return 1;
|
||||
}
|
||||
msg_openssl_return_code(MSG_ERROR,"SSL_read()",ret,error);
|
||||
msg_openssl_return_code(LOG_ERR,"SSL_read()",ret,error);
|
||||
msg_openssl_errors();
|
||||
shutdown();
|
||||
return 0;
|
||||
|
@ -326,7 +326,7 @@ int IpfixReceiverDtlsSctpIpV4::DtlsConnection::fdready() {
|
|||
// remote side closed connection
|
||||
DPRINTF("remote side closed connection.");
|
||||
} else {
|
||||
msg_openssl_return_code(MSG_ERROR,"SSL_read()",ret,error);
|
||||
msg_openssl_return_code(LOG_ERR,"SSL_read()",ret,error);
|
||||
msg_openssl_errors();
|
||||
}
|
||||
shutdown();
|
||||
|
@ -363,7 +363,7 @@ void IpfixReceiverDtlsSctpIpV4::DtlsConnection::shutdown() {
|
|||
}
|
||||
error = SSL_get_error(ssl,ret);
|
||||
#if DEBUG
|
||||
msg_openssl_return_code(MSG_DEBUG,"SSL_shutdown()",ret,error);
|
||||
msg_openssl_return_code(LOG_INFO,"SSL_shutdown()",ret,error);
|
||||
#endif
|
||||
DPRINTF("SSL_free(ssl)");
|
||||
parent.ssl_ctx.SSL_free(ssl);
|
||||
|
|
|
@ -71,7 +71,7 @@ IpfixReceiverDtlsUdpIpV4::IpfixReceiverDtlsUdpIpV4(int port, const std::string i
|
|||
listen_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(listen_socket < 0) {
|
||||
/* FIXME: should we use strerror_r? */
|
||||
msg(MSG_FATAL, "Could not create socket: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "Could not create socket: %s", strerror(errno));
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverDtlsUdpIpV4, socket creation failed");
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ IpfixReceiverDtlsUdpIpV4::IpfixReceiverDtlsUdpIpV4(int port, const std::string i
|
|||
serverAddress.sin_port = htons(port);
|
||||
if(bind(listen_socket, (struct sockaddr*)&serverAddress,
|
||||
sizeof(struct sockaddr_in)) < 0) {
|
||||
msg(MSG_FATAL, "Could not bind socket: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "Could not bind socket: %s", strerror(errno));
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverDtlsUdpIpV4 %s:%d",ipAddr.c_str(), port );
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ IpfixReceiverDtlsUdpIpV4::IpfixReceiverDtlsUdpIpV4(int port, const std::string i
|
|||
SensorManager::getInstance().addSensor(this, "IpfixReceiverDtlsUdpIpV4",
|
||||
moduleId);
|
||||
|
||||
msg(MSG_INFO, "DTLS over UDP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
msg(LOG_NOTICE, "DTLS over UDP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
port,
|
||||
listen_socket);
|
||||
} catch(...) {
|
||||
|
@ -196,7 +196,7 @@ void IpfixReceiverDtlsUdpIpV4::run() {
|
|||
continue;
|
||||
}
|
||||
if (ret < 0) {
|
||||
msg(MSG_ERROR ,"select() returned with an error");
|
||||
msg(LOG_ERR ,"select() returned with an error");
|
||||
THROWEXCEPTION("IpfixReceiverDtlsUdpIpV4: terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
@ -208,11 +208,11 @@ void IpfixReceiverDtlsUdpIpV4::run() {
|
|||
ret = recvfrom(listen_socket, secured_data.get(), MAX_MSG_LEN,
|
||||
0, (struct sockaddr*)&clientAddress, &clientAddressLen);
|
||||
if (ret < 0) {
|
||||
msg(MSG_FATAL, "recvfrom returned without data, terminating listener thread");
|
||||
msg(LOG_CRIT, "recvfrom returned without data, terminating listener thread");
|
||||
break;
|
||||
}
|
||||
if ( ! isHostAuthorized(&clientAddress.sin_addr, sizeof(clientAddress.sin_addr))) {
|
||||
msg(MSG_FATAL, "packet from unauthorized host %s discarded", inet_ntoa(clientAddress.sin_addr));
|
||||
msg(LOG_CRIT, "packet from unauthorized host %s discarded", inet_ntoa(clientAddress.sin_addr));
|
||||
continue;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
@ -234,7 +234,7 @@ void IpfixReceiverDtlsUdpIpV4::run() {
|
|||
/* create a new connection if we did not find any. */
|
||||
DPRINTF("New connection");
|
||||
if (connections.size() >= DTLS_MAX_CONCURRENT_CONNECTIONS) {
|
||||
msg(MSG_ERROR,"Maximum number (%d) of concurrent "
|
||||
msg(LOG_ERR,"Maximum number (%d) of concurrent "
|
||||
"connections reached. Ignoring new connection "
|
||||
"attempt.",DTLS_MAX_CONCURRENT_CONNECTIONS);
|
||||
continue;
|
||||
|
@ -251,7 +251,7 @@ void IpfixReceiverDtlsUdpIpV4::run() {
|
|||
dumpConnections();
|
||||
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixReceiverDtlsUdpIpV4: Exiting");
|
||||
msg(LOG_INFO, "IpfixReceiverDtlsUdpIpV4: Exiting");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,7 +331,7 @@ int IpfixReceiverDtlsUdpIpV4::DtlsConnection::accept() {
|
|||
if (verify_peer()) {
|
||||
DPRINTF("Peer authentication successful.");
|
||||
} else {
|
||||
msg(MSG_ERROR,"Peer authentication failed. Shutting down connection.");
|
||||
msg(LOG_ERR,"Peer authentication failed. Shutting down connection.");
|
||||
shutdown();
|
||||
return -1;
|
||||
}
|
||||
|
@ -344,10 +344,10 @@ int IpfixReceiverDtlsUdpIpV4::DtlsConnection::accept() {
|
|||
DPRINTF("SSL_accept() returned SSL_ERROR_WANT_READ");
|
||||
return 0;
|
||||
}
|
||||
msg(MSG_ERROR,"SSL_accept() failed.");
|
||||
msg(LOG_ERR,"SSL_accept() failed.");
|
||||
long verify_result = SSL_get_verify_result(ssl);
|
||||
if(SSL_get_verify_result(ssl)!=X509_V_OK) {
|
||||
msg(MSG_ERROR,"Last verification error: %s", X509_verify_cert_error_string(verify_result));
|
||||
msg(LOG_ERR,"Last verification error: %s", X509_verify_cert_error_string(verify_result));
|
||||
}
|
||||
state = SHUTDOWN;
|
||||
msg_openssl_errors();
|
||||
|
@ -390,7 +390,7 @@ int IpfixReceiverDtlsUdpIpV4::DtlsConnection::consumeDatagram(
|
|||
}
|
||||
#ifdef DEBUG
|
||||
if ( ! BIO_eof(ssl->rbio)) {
|
||||
msg(MSG_ERROR,"EOF *not* reached on BIO. This should not happen.");
|
||||
msg(LOG_ERR,"EOF *not* reached on BIO. This should not happen.");
|
||||
}
|
||||
#endif
|
||||
BIO_free(ssl->rbio);
|
||||
|
@ -402,7 +402,7 @@ int IpfixReceiverDtlsUdpIpV4::DtlsConnection::consumeDatagram(
|
|||
if (ret == -1) return 0;
|
||||
#ifdef DEBUG
|
||||
if ( ! BIO_eof(ssl->rbio)) {
|
||||
msg(MSG_ERROR,"EOF *not* reached on BIO. This should not happen.");
|
||||
msg(LOG_ERR,"EOF *not* reached on BIO. This should not happen.");
|
||||
}
|
||||
#endif
|
||||
if (BIO_eof(ssl->rbio)) return 1; /* This should always be the case */
|
||||
|
@ -414,7 +414,7 @@ int IpfixReceiverDtlsUdpIpV4::DtlsConnection::consumeDatagram(
|
|||
if (ret<0) {
|
||||
if (error == SSL_ERROR_WANT_READ)
|
||||
return 1;
|
||||
msg(MSG_ERROR,"SSL_read() failed. SSL_get_error() returned: %d",error);
|
||||
msg(LOG_ERR,"SSL_read() failed. SSL_get_error() returned: %d",error);
|
||||
msg_openssl_errors();
|
||||
shutdown();
|
||||
return 0;
|
||||
|
@ -423,7 +423,7 @@ int IpfixReceiverDtlsUdpIpV4::DtlsConnection::consumeDatagram(
|
|||
// remote side closed connection
|
||||
DPRINTF("remote side closed connection.");
|
||||
} else {
|
||||
msg(MSG_ERROR,"SSL_read() returned 0. SSL_get_error() returned: %d",error);
|
||||
msg(LOG_ERR,"SSL_read() returned 0. SSL_get_error() returned: %d",error);
|
||||
msg_openssl_errors();
|
||||
}
|
||||
shutdown();
|
||||
|
|
|
@ -67,7 +67,7 @@ IpfixReceiverFile::IpfixReceiverFile(std::string packetFileBasename,
|
|||
if((1-stretchTimeInt*m) > 0.1)
|
||||
stretchTimeInt = 0; //use float
|
||||
else
|
||||
msg(MSG_INFO, "IpfixReceiverFile: speed multiplier set to %f "
|
||||
msg(LOG_NOTICE, "IpfixReceiverFile: speed multiplier set to %f "
|
||||
"in order to allow integer multiplication", 1.0/stretchTimeInt);
|
||||
}
|
||||
else
|
||||
|
@ -125,13 +125,13 @@ IpfixReceiverFile::IpfixReceiverFile(std::string packetFileBasename,
|
|||
}
|
||||
to = maxnum;
|
||||
}
|
||||
msg(MSG_INFO, "IpfixReceiverFile initialized with the following parameters:");
|
||||
msg(MSG_INFO, " - packet_file_directory = %s", packet_file_directory.c_str());
|
||||
msg(MSG_INFO, " - packet_file_basename = %s", packet_file_basename.c_str());
|
||||
msg(MSG_INFO, " - Start (from) = %d" , from);
|
||||
msg(MSG_INFO, " - End (to) = %d" , to);
|
||||
msg(MSG_INFO, " - ignoreTimestamps = %s" , (ignore_timestamps) ? "true" : "false");
|
||||
if(! ignore_timestamps) msg(MSG_INFO, " - stretchTime = %f", stretchTime);
|
||||
msg(LOG_NOTICE, "IpfixReceiverFile initialized with the following parameters:");
|
||||
msg(LOG_NOTICE, " - packet_file_directory = %s", packet_file_directory.c_str());
|
||||
msg(LOG_NOTICE, " - packet_file_basename = %s", packet_file_basename.c_str());
|
||||
msg(LOG_NOTICE, " - Start (from) = %d" , from);
|
||||
msg(LOG_NOTICE, " - End (to) = %d" , to);
|
||||
msg(LOG_NOTICE, " - ignoreTimestamps = %s" , (ignore_timestamps) ? "true" : "false");
|
||||
if(! ignore_timestamps) msg(LOG_NOTICE, " - stretchTime = %f", stretchTime);
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,14 +170,14 @@ void IpfixReceiverFile::run()
|
|||
std::string packet_file_path = packet_file_directory + packet_file_basename
|
||||
+ numberformat.str();
|
||||
|
||||
msg(MSG_DEBUG, "IpfixReceiverFile: Trying to read message from file \"%s\"",
|
||||
msg(LOG_INFO, "IpfixReceiverFile: Trying to read message from file \"%s\"",
|
||||
packet_file_path.c_str());
|
||||
|
||||
packetFile.open(packet_file_path.c_str(), std::ios::in | std::ios::binary);
|
||||
if (packetFile.fail()){
|
||||
msg(MSG_FATAL, "Couldn't open inputfile %s", packet_file_path.c_str());
|
||||
msg(LOG_CRIT, "Couldn't open inputfile %s", packet_file_path.c_str());
|
||||
if (++missing > MAXMISSINGFILES){
|
||||
msg(MSG_FATAL, "Couldn't open %d files in a row...terminating", MAXMISSINGFILES);
|
||||
msg(LOG_CRIT, "Couldn't open %d files in a row...terminating", MAXMISSINGFILES);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
|
@ -199,7 +199,7 @@ void IpfixReceiverFile::run()
|
|||
|
||||
/** @todo uint_16 can never be > 65536
|
||||
if (n > MAX_MSG_LEN) {
|
||||
msg(MSG_ERROR, "IpfixReceiverFile: packet at idx=%u too big with n=%u in file \"%s\"",
|
||||
msg(LOG_ERR, "IpfixReceiverFile: packet at idx=%u too big with n=%u in file \"%s\"",
|
||||
idx, n, packet_file_path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ void IpfixReceiverFile::run()
|
|||
idx += n;
|
||||
|
||||
if (packetFile.bad()) {
|
||||
msg(MSG_ERROR, "IpfixReceiverFile: bad packet_file: %s", packet_file_path.c_str());
|
||||
msg(LOG_ERR, "IpfixReceiverFile: bad packet_file: %s", packet_file_path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -225,8 +225,8 @@ void IpfixReceiverFile::run()
|
|||
(uint32_t)(0xff & data[6])<<8 | (uint32_t)(0xff & data[7]));
|
||||
|
||||
if(gettimeofday(&real_now, NULL) != 0){
|
||||
msg(MSG_FATAL, "Error gettimeofday: %s", strerror(errno));
|
||||
msg(MSG_FATAL, "Ignoring timestamps!");
|
||||
msg(LOG_CRIT, "Error gettimeofday: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "Ignoring timestamps!");
|
||||
ignore_timestamps = true;
|
||||
first = true;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ void IpfixReceiverFile::run()
|
|||
}
|
||||
else{
|
||||
msg_now.tv_sec = (time_t)exporttime;
|
||||
msg(MSG_DEBUG, "Exporttime: %u", exporttime);
|
||||
msg(LOG_INFO, "Exporttime: %u", exporttime);
|
||||
//msg_delta.tv_sec = msg_now.tv_sec - msg_first.tv_sec;
|
||||
timersub(&msg_now, &msg_first, &msg_delta);
|
||||
//real_delta.tv_sec = real_now.tv_sec - real_start.tv_sec;
|
||||
|
@ -260,7 +260,7 @@ void IpfixReceiverFile::run()
|
|||
//sleep_time.tv_sec = msg_delta.tv_sec - real_delta.tv_sec;
|
||||
timersub(&tmp_delta, &real_delta, &sleep_time);
|
||||
|
||||
msg(MSG_DEBUG, "msg_delta: %06us %06uus | tmp_delta: %06us %06uus | "
|
||||
msg(LOG_INFO, "msg_delta: %06us %06uus | tmp_delta: %06us %06uus | "
|
||||
"real_delta: %06us %06uus | sleep_time: %06us %06uus",
|
||||
(uint32_t) msg_delta.tv_sec, (uint32_t) msg_delta.tv_usec,
|
||||
(uint32_t) tmp_delta.tv_sec, (uint32_t) tmp_delta.tv_usec,
|
||||
|
@ -269,14 +269,14 @@ void IpfixReceiverFile::run()
|
|||
|
||||
wait_spec.tv_sec = sleep_time.tv_sec;
|
||||
wait_spec.tv_nsec = sleep_time.tv_usec*1000;
|
||||
msg(MSG_DEBUG, "sleeping for: %06us %06uus",
|
||||
msg(LOG_INFO, "sleeping for: %06us %06uus",
|
||||
(uint32_t)sleep_time.tv_sec, (uint32_t)sleep_time.tv_usec);
|
||||
if(nanosleep(&wait_spec, NULL)){
|
||||
msg(MSG_ERROR, "nanosleep returned non-zero value: %s", strerror(errno));
|
||||
msg(LOG_ERR, "nanosleep returned non-zero value: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
else{
|
||||
msg(MSG_DEBUG, "Not sleeping");
|
||||
msg(LOG_INFO, "Not sleeping");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,15 +289,15 @@ void IpfixReceiverFile::run()
|
|||
}
|
||||
packetFile.close();
|
||||
|
||||
msg(MSG_INFO, "IpfixReceiverFile: File %s ended after %lu bytes.",
|
||||
msg(LOG_NOTICE, "IpfixReceiverFile: File %s ended after %lu bytes.",
|
||||
packet_file_path.c_str(), idx);
|
||||
}
|
||||
msg(MSG_DEBUG, "real_start: %lu msg_start: %lu real_now: %lu msg_now: %lu",
|
||||
msg(LOG_INFO, "real_start: %lu msg_start: %lu real_now: %lu msg_now: %lu",
|
||||
real_start.tv_sec, msg_first.tv_sec, real_now.tv_sec, msg_now.tv_sec);
|
||||
if (vmodule) {
|
||||
vmodule->shutdownVermont();
|
||||
} else {
|
||||
msg(MSG_ERROR, "IpfixReceiverFile: failed to shut down Vermont, internal error!");
|
||||
msg(LOG_ERR, "IpfixReceiverFile: failed to shut down Vermont, internal error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,12 +63,12 @@ IpfixReceiverFileCfg::IpfixReceiverFileCfg(XMLElement* elem)
|
|||
//ignore <next>
|
||||
}
|
||||
else {
|
||||
msg(MSG_FATAL, "Unkown ReceiverFile config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unkown ReceiverFile config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "CollectorConfiguration: Successfully parsed collectingProcess section");
|
||||
msg(LOG_NOTICE, "CollectorConfiguration: Successfully parsed collectingProcess section");
|
||||
}
|
||||
|
||||
IpfixReceiverFileCfg::~IpfixReceiverFileCfg()
|
||||
|
|
|
@ -71,10 +71,10 @@ IpfixReceiverSctpIpV4::IpfixReceiverSctpIpV4(int port, std::string ipAddr, uint3
|
|||
THROWEXCEPTION("Cannot create IpfixReceiverSctpIpV4 %s:%d",ipAddr.c_str(), port );
|
||||
}
|
||||
if(listen(listen_socket, SCTP_MAX_BACKLOG) < 0 ) {
|
||||
msg(MSG_ERROR ,"Could not listen on SCTP socket %i", listen_socket);
|
||||
msg(LOG_ERR ,"Could not listen on SCTP socket %i", listen_socket);
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverSctpIpV4");
|
||||
}
|
||||
msg(MSG_INFO, "SCTP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
msg(LOG_NOTICE, "SCTP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
port,
|
||||
listen_socket);
|
||||
return;
|
||||
|
@ -126,7 +126,7 @@ void IpfixReceiverSctpIpV4::run() {
|
|||
continue;
|
||||
}
|
||||
if (ret < 0) {
|
||||
msg(MSG_ERROR ,"select() returned with an error");
|
||||
msg(LOG_ERR ,"select() returned with an error");
|
||||
THROWEXCEPTION("IpfixReceiverSctpIpV4: terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
@ -137,16 +137,16 @@ void IpfixReceiverSctpIpV4::run() {
|
|||
if (rfd >= 0){
|
||||
if (isHostAuthorized(&clientAddress.sin_addr, sizeof(clientAddress.sin_addr))) {
|
||||
FD_SET(rfd, &fd_array); // add new client to fd_array
|
||||
msg(MSG_DEBUG, "IpfixReceiverSctpIpV4: Client connected from %s:%d, FD=%d", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
msg(LOG_INFO, "IpfixReceiverSctpIpV4: Client connected from %s:%d, FD=%d", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
if (rfd > maxfd){
|
||||
maxfd = rfd;
|
||||
}
|
||||
} else {
|
||||
msg(MSG_DEBUG, "IpfixReceiverSctpIpV4: Connection from unwanted client %s:%d, FD=%d rejected.", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
msg(LOG_INFO, "IpfixReceiverSctpIpV4: Connection from unwanted client %s:%d, FD=%d rejected.", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
close(rfd);
|
||||
}
|
||||
}else{
|
||||
msg(MSG_ERROR ,"accept() in ipfixReceiver failed");
|
||||
msg(LOG_ERR ,"accept() in ipfixReceiver failed");
|
||||
THROWEXCEPTION("IpfixReceiverSctpIpV4: unable to accept new connection");
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void IpfixReceiverSctpIpV4::run() {
|
|||
boost::shared_array<uint8_t> data(new uint8_t[MAX_MSG_LEN]);
|
||||
ret = recvfrom(rfd, data.get(), MAX_MSG_LEN, 0, (struct sockaddr*)&clientAddress, &clientAddressLen);
|
||||
if (ret < 0) { // error
|
||||
msg(MSG_ERROR, "IpfixReceiverSctpIpV4: Client error (%s), close connection.", inet_ntoa(clientAddress.sin_addr));
|
||||
msg(LOG_ERR, "IpfixReceiverSctpIpV4: Client error (%s), close connection.", inet_ntoa(clientAddress.sin_addr));
|
||||
close(rfd);
|
||||
// we treat an error like a shut down, so overwrite return value to zero
|
||||
ret = 0;
|
||||
|
@ -177,12 +177,12 @@ void IpfixReceiverSctpIpV4::run() {
|
|||
mutex.unlock();
|
||||
if (ret == 0) { // this was a shut down (or error)
|
||||
FD_CLR(rfd, &fd_array); // delete dead client
|
||||
msg(MSG_DEBUG, "IpfixReceiverSctpIpV4: Client %s disconnected", inet_ntoa(clientAddress.sin_addr));
|
||||
msg(LOG_INFO, "IpfixReceiverSctpIpV4: Client %s disconnected", inet_ntoa(clientAddress.sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixReceiverSctpIpV4: Exiting");
|
||||
msg(LOG_INFO, "IpfixReceiverSctpIpV4: Exiting");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,14 +72,14 @@ IpfixReceiverTcpIpV4::IpfixReceiverTcpIpV4(int port, std::string ipAddr,
|
|||
THROWEXCEPTION("Cannot create IpfixReceiverTcpIpV4 %s:%d",ipAddr.c_str(), port );
|
||||
}
|
||||
if(listen(listen_socket, TCP_MAX_BACKLOG) < 0 ) {
|
||||
msg(MSG_ERROR ,"Could not listen on TCP socket %i", listen_socket);
|
||||
msg(LOG_ERR ,"Could not listen on TCP socket %i", listen_socket);
|
||||
THROWEXCEPTION("Cannot create IpfixReceiverTcpIpV4");
|
||||
}
|
||||
|
||||
SensorManager::getInstance().addSensor(this, "IpfixReceiverTCPIpV4",
|
||||
moduleId);
|
||||
|
||||
msg(MSG_INFO, "TCP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
msg(LOG_NOTICE, "TCP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
port,
|
||||
listen_socket);
|
||||
return;
|
||||
|
@ -131,7 +131,7 @@ void IpfixReceiverTcpIpV4::run() {
|
|||
continue;
|
||||
}
|
||||
if (ret < 0) {
|
||||
msg(MSG_ERROR ,"select() returned with an error");
|
||||
msg(LOG_ERR ,"select() returned with an error");
|
||||
THROWEXCEPTION("IpfixReceiverTcpIpV4: terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
@ -142,16 +142,16 @@ void IpfixReceiverTcpIpV4::run() {
|
|||
if (rfd >= 0){
|
||||
if (isHostAuthorized(&clientAddress.sin_addr, sizeof(clientAddress.sin_addr))) {
|
||||
FD_SET(rfd, &fd_array); // add new client to fd_array
|
||||
msg(MSG_DEBUG, "IpfixReceiverTcpIpV4: Client connected from %s:%d, FD=%d", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
msg(LOG_INFO, "IpfixReceiverTcpIpV4: Client connected from %s:%d, FD=%d", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
if (rfd > maxfd){
|
||||
maxfd = rfd;
|
||||
}
|
||||
} else {
|
||||
msg(MSG_DEBUG, "IpfixReceiverTcpIpV4: Connection from unwanted client %s:%d, FD=%d rejected.", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
msg(LOG_INFO, "IpfixReceiverTcpIpV4: Connection from unwanted client %s:%d, FD=%d rejected.", inet_ntoa(clientAddress.sin_addr), ntohs(clientAddress.sin_port), rfd);
|
||||
close(rfd);
|
||||
}
|
||||
}else{
|
||||
msg(MSG_ERROR ,"accept() in IpfixReceiverTcpIpV4 failed");
|
||||
msg(LOG_ERR ,"accept() in IpfixReceiverTcpIpV4 failed");
|
||||
THROWEXCEPTION("IpfixReceiverTcpIpV4: unable to accept new connection");
|
||||
}
|
||||
}
|
||||
|
@ -165,24 +165,24 @@ void IpfixReceiverTcpIpV4::run() {
|
|||
while (read_so_far < expected_read && ret > 0) {
|
||||
ret = recvfrom(rfd, data.get() + read_so_far, expected_read - read_so_far, 0, (struct sockaddr*)&clientAddress, &clientAddressLen);
|
||||
if (ret < 0) { // error
|
||||
msg(MSG_ERROR, "IpfixReceiverTcpIpV4: Client error (%s), close connection.", inet_ntoa(clientAddress.sin_addr));
|
||||
msg(LOG_ERR, "IpfixReceiverTcpIpV4: Client error (%s), close connection.", inet_ntoa(clientAddress.sin_addr));
|
||||
close(rfd);
|
||||
// we treat an error like a shut down, so overwrite return value to zero
|
||||
ret = 0;
|
||||
} else if (ret == 0) {
|
||||
msg(MSG_DEBUG, "IpfixReceiverTcpIpV4: Client closed connection");
|
||||
msg(LOG_INFO, "IpfixReceiverTcpIpV4: Client closed connection");
|
||||
}
|
||||
read_so_far += ret;
|
||||
|
||||
}
|
||||
if (expected_read != read_so_far && ret > 0) {
|
||||
msg(MSG_ERROR, "IpfixReceiverTcpIpV4: Damn it. TCP didn't read enough. And we did not handle that in the code!");
|
||||
msg(LOG_ERR, "IpfixReceiverTcpIpV4: Damn it. TCP didn't read enough. And we did not handle that in the code!");
|
||||
close(rfd);
|
||||
ret = 0;
|
||||
}
|
||||
IpfixParser::IpfixHeader* header = (IpfixParser::IpfixHeader*)data.get();
|
||||
if (ret > 0 && ntohs(header->version) != 0x000a) {
|
||||
msg(MSG_ERROR, "IpfixReceiverTcpIpV4: We do not support anything but IPFIX in TCPReceiver");
|
||||
msg(LOG_ERR, "IpfixReceiverTcpIpV4: We do not support anything but IPFIX in TCPReceiver");
|
||||
close(rfd);
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -191,17 +191,17 @@ void IpfixReceiverTcpIpV4::run() {
|
|||
while (ret > 0 && read_so_far < expected_read) {
|
||||
ret = recvfrom(rfd, data.get() + read_so_far, expected_read - read_so_far, 0, (struct sockaddr*)&clientAddress, &clientAddressLen);
|
||||
if (ret + read_so_far > expected_read) {
|
||||
msg(MSG_ERROR,"IpfixReceiverTcpIpV4: This is way to much content!");
|
||||
msg(LOG_ERR,"IpfixReceiverTcpIpV4: This is way to much content!");
|
||||
close(rfd);
|
||||
ret = 0;
|
||||
} else if (ret == 0) {
|
||||
msg(MSG_ERROR, "IpfixReceiverTcpIpV4: Client closed connection after sending the IPFIX message header!");
|
||||
msg(LOG_ERR, "IpfixReceiverTcpIpV4: Client closed connection after sending the IPFIX message header!");
|
||||
}
|
||||
|
||||
read_so_far += ret;
|
||||
}
|
||||
if (ret > 0 && read_so_far != expected_read) {
|
||||
msg(MSG_ERROR, "IpfixReceiverTcpIpV4: This is weird. We have read more than we excpected!");
|
||||
msg(LOG_ERR, "IpfixReceiverTcpIpV4: This is weird. We have read more than we excpected!");
|
||||
close(rfd);
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -226,12 +226,12 @@ void IpfixReceiverTcpIpV4::run() {
|
|||
}
|
||||
if (ret == 0) { // this was a shut down (or error)
|
||||
FD_CLR(rfd, &fd_array); // delete dead client
|
||||
msg(MSG_DEBUG, "IpfixReceiverTcpIpV4: Client %s disconnected", inet_ntoa(clientAddress.sin_addr));
|
||||
msg(LOG_INFO, "IpfixReceiverTcpIpV4: Client %s disconnected", inet_ntoa(clientAddress.sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixReceiverTcpIpV4: Exiting");
|
||||
msg(LOG_INFO, "IpfixReceiverTcpIpV4: Exiting");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,7 +79,7 @@ IpfixReceiverUdpIpV4::IpfixReceiverUdpIpV4(int port, std::string ipAddr,
|
|||
|
||||
SensorManager::getInstance().addSensor(this, "IpfixReceiverUdpIpV4", moduleId);
|
||||
|
||||
msg(MSG_INFO, "UDP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
msg(LOG_NOTICE, "UDP Receiver listening on %s:%d, FD=%d", (ipAddr == "")?std::string("ALL").c_str() : ipAddr.c_str(),
|
||||
port,
|
||||
listen_socket);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void IpfixReceiverUdpIpV4::run() {
|
|||
continue;
|
||||
}
|
||||
if (ret < 0) {
|
||||
msg(MSG_ERROR ,"select() returned with an error");
|
||||
msg(LOG_ERR ,"select() returned with an error");
|
||||
THROWEXCEPTION("IpfixReceiverUdpIpV4: terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ void IpfixReceiverUdpIpV4::run() {
|
|||
ret = recvfrom(listen_socket, data.get(), MAX_MSG_LEN,
|
||||
0, (struct sockaddr*)&clientAddress, &clientAddressLen);
|
||||
if (ret < 0) {
|
||||
msg(MSG_FATAL, "recvfrom returned without data, terminating listener thread");
|
||||
msg(LOG_CRIT, "recvfrom returned without data, terminating listener thread");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -157,10 +157,10 @@ void IpfixReceiverUdpIpV4::run() {
|
|||
}
|
||||
mutex.unlock();
|
||||
} else {
|
||||
msg(MSG_VDEBUG, "IpfixReceiverUdpIpv4: packet from unauthorized host %s discarded", inet_ntoa(clientAddress.sin_addr));
|
||||
msg(LOG_DEBUG, "IpfixReceiverUdpIpv4: packet from unauthorized host %s discarded", inet_ntoa(clientAddress.sin_addr));
|
||||
}
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixReceiverUdpIpV4: Exiting");
|
||||
msg(LOG_INFO, "IpfixReceiverUdpIpV4: Exiting");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,7 +75,7 @@ IpfixReceiverZmq::IpfixReceiverZmq(std::vector<std::string> endpoints,
|
|||
|
||||
zmq_sockets.push_back(sock);
|
||||
|
||||
msg(MSG_INFO, "ZMQ Receiver listening on %s", (*i).c_str());
|
||||
msg(LOG_NOTICE, "ZMQ Receiver listening on %s", (*i).c_str());
|
||||
}
|
||||
|
||||
SensorManager::getInstance().addSensor(this, "IpfixReceiverZMQ", moduleId);
|
||||
|
@ -92,7 +92,7 @@ IpfixReceiverZmq::~IpfixReceiverZmq()
|
|||
zsock_destroy(&(*i));
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Ipfix Receiver ZMQ poller and sockets destroyed");
|
||||
msg(LOG_NOTICE, "Ipfix Receiver ZMQ poller and sockets destroyed");
|
||||
|
||||
SensorManager::getInstance().removeSensor(this);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void IpfixReceiverZmq::run()
|
|||
void *sock = zpoller_wait(zpoller, zmq_poll_timeout);
|
||||
if (!sock) {
|
||||
if (zpoller_terminated(zpoller)) {
|
||||
msg(MSG_DEBUG, "ZMQ Receiver: ZMQ termination signal received");
|
||||
msg(LOG_INFO, "ZMQ Receiver: ZMQ termination signal received");
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
|
@ -124,7 +124,7 @@ void IpfixReceiverZmq::run()
|
|||
|
||||
zmsg_t *msg = zmsg_recv(sock);
|
||||
if (msg == NULL) {
|
||||
msg(MSG_ERROR, "Empty ZMQ message");
|
||||
msg(LOG_ERR, "Empty ZMQ message");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace InformationElement {
|
|||
if (ipfixid) {
|
||||
this->length = ipfixid->length;
|
||||
} else {
|
||||
msg(MSG_INFO, "WARNING: received unknown IE type id: %s", toString().c_str());
|
||||
msg(LOG_NOTICE, "WARNING: received unknown IE type id: %s", toString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ IpfixSampler::IpfixSampler(double flowrate)
|
|||
{
|
||||
modulo = (uint64_t)round(1.0/flowRate);
|
||||
|
||||
msg(MSG_INFO, "IpfixSampler started with following parameters:");
|
||||
msg(MSG_INFO, " - flowRate=%f", flowRate);
|
||||
msg(MSG_INFO, " - resulting modulo: %lu", modulo);
|
||||
msg(LOG_NOTICE, "IpfixSampler started with following parameters:");
|
||||
msg(LOG_NOTICE, " - flowRate=%f", flowRate);
|
||||
msg(LOG_NOTICE, " - resulting modulo: %lu", modulo);
|
||||
}
|
||||
|
||||
IpfixSampler::~IpfixSampler()
|
||||
|
|
|
@ -44,7 +44,7 @@ IpfixSamplerCfg::IpfixSamplerCfg(XMLElement* elem)
|
|||
flowRate = getDouble("flowrate");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixSampler config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixSampler config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ IpfixSender::IpfixSender(uint32_t observationDomainId, uint32_t maxRecordRate,
|
|||
curTimeStep.tv_usec = 0;
|
||||
|
||||
if(ipfix_init_exporter(export_protocol, observationDomainId, exporterP) != 0) {
|
||||
msg(MSG_FATAL, "IpfixSender: ipfix_init_exporter failed");
|
||||
msg(LOG_CRIT, "IpfixSender: ipfix_init_exporter failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ IpfixSender::IpfixSender(uint32_t observationDomainId, uint32_t maxRecordRate,
|
|||
ipfix_set_ca_locations(&ipfixExporter->certificate, ca_file, ca_path);
|
||||
#endif
|
||||
|
||||
msg(MSG_DEBUG, "IpfixSender: running");
|
||||
msg(LOG_INFO, "IpfixSender: running");
|
||||
return;
|
||||
|
||||
out:
|
||||
|
@ -138,14 +138,14 @@ IpfixSender::IpfixSender(uint32_t observationDomainId, uint32_t maxRecordRate)
|
|||
curTimeStep.tv_usec = 0;
|
||||
|
||||
if(ipfix_init_exporter(export_protocol, observationDomainId, exporterP) != 0) {
|
||||
msg(MSG_FATAL, "IpfixSender: ipfix_init_exporter failed");
|
||||
msg(LOG_CRIT, "IpfixSender: ipfix_init_exporter failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ipfix_set_template_transmission_timer(ipfixExporter, IS_DEFAULT_TEMPLATE_TIMEINTERVAL);
|
||||
|
||||
|
||||
msg(MSG_DEBUG, "IpfixSender: running");
|
||||
msg(LOG_INFO, "IpfixSender: running");
|
||||
return;
|
||||
|
||||
out:
|
||||
|
@ -187,35 +187,35 @@ void IpfixSender::addCollector(const char *ip, uint16_t port,
|
|||
|
||||
switch(proto) {
|
||||
case UDP:
|
||||
msg(MSG_INFO, "%sIpfixSender: adding UDP://%s:%d to exporter",
|
||||
msg(LOG_NOTICE, "%sIpfixSender: adding UDP://%s:%d to exporter",
|
||||
vrf_log, ip, port);
|
||||
break;
|
||||
case SCTP:
|
||||
msg(MSG_INFO, "%sIpfixSender: adding SCTP://%s:%d to exporter",
|
||||
msg(LOG_NOTICE, "%sIpfixSender: adding SCTP://%s:%d to exporter",
|
||||
vrf_log, ip, port);
|
||||
break;
|
||||
#ifdef IPFIXLOLIB_RAWDIR_SUPPORT
|
||||
case RAWDIR:
|
||||
msg(MSG_INFO, "%sIpfixSender: adding RAWDIR://%s to exporter",
|
||||
msg(LOG_NOTICE, "%sIpfixSender: adding RAWDIR://%s to exporter",
|
||||
vrf_log, ip);
|
||||
break;
|
||||
#endif
|
||||
#ifdef SUPPORT_DTLS
|
||||
case DTLS_OVER_UDP:
|
||||
msg(MSG_INFO,
|
||||
msg(LOG_NOTICE,
|
||||
"%sIpfixSender: adding DTLS over UDP://%s:%d to exporter",
|
||||
vrf_log, ip, port);
|
||||
break;
|
||||
#endif
|
||||
#ifdef SUPPORT_DTLS_OVER_SCTP
|
||||
case DTLS_OVER_SCTP:
|
||||
msg(MSG_INFO,
|
||||
msg(LOG_NOTICE,
|
||||
"%sIpfixSender: adding DTLS over SCTP://%s:%d to exporter",
|
||||
vrf_log, ip, port);
|
||||
break;
|
||||
#endif
|
||||
case TCP:
|
||||
msg(MSG_INFO, "%sIpfixSender: adding TCP://%s:%d to exporter",
|
||||
msg(LOG_NOTICE, "%sIpfixSender: adding TCP://%s:%d to exporter",
|
||||
vrf_log, ip, port);
|
||||
__FALLTHROUGH__;
|
||||
default:
|
||||
|
@ -225,7 +225,7 @@ void IpfixSender::addCollector(const char *ip, uint16_t port,
|
|||
|
||||
if(ipfix_add_collector(ex, ip, port, proto, aux_config,
|
||||
vrf_name) != 0) {
|
||||
msg(MSG_FATAL,
|
||||
msg(LOG_CRIT,
|
||||
"%sIpfixSender: ipfix_add_collector of %s:%d to exporter",
|
||||
vrf_log, ip, port);
|
||||
return;
|
||||
|
@ -257,7 +257,7 @@ void IpfixSender::onTemplate(IpfixTemplateRecord* record)
|
|||
// TODO: Implement Options Template handling
|
||||
if ((dataTemplateInfo->setId != TemplateInfo::IpfixTemplate))
|
||||
{
|
||||
msg(MSG_ERROR, "IpfixSender: Don't know how to handle Template (setId=%u)", dataTemplateInfo->setId);
|
||||
msg(LOG_ERR, "IpfixSender: Don't know how to handle Template (setId=%u)", dataTemplateInfo->setId);
|
||||
record->removeReference();
|
||||
return;
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ void IpfixSender::onTemplate(IpfixTemplateRecord* record)
|
|||
THROWEXCEPTION("IpfixSender: Exporter not set");
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixSender: Template received (setid=%u, id=%u)", (uint16_t)(dataTemplateInfo->setId), dataTemplateInfo->templateId);
|
||||
msg(LOG_INFO, "IpfixSender: Template received (setid=%u, id=%u)", (uint16_t)(dataTemplateInfo->setId), dataTemplateInfo->templateId);
|
||||
|
||||
// get message lock
|
||||
ipfixMessageLock.lock();
|
||||
|
@ -280,7 +280,7 @@ void IpfixSender::onTemplate(IpfixTemplateRecord* record)
|
|||
|
||||
// check if this is a known template
|
||||
if(uniqueIdToTemplateId.find(dataTemplateInfo->getUniqueId()) != uniqueIdToTemplateId.end()) {
|
||||
msg(MSG_ERROR, "IpfixSender: Received known Template (id=%u) again, which should not happen.", dataTemplateInfo->templateId);
|
||||
msg(LOG_ERR, "IpfixSender: Received known Template (id=%u) again, which should not happen.", dataTemplateInfo->templateId);
|
||||
record->removeReference();
|
||||
ipfixMessageLock.unlock();
|
||||
return;
|
||||
|
@ -294,22 +294,22 @@ void IpfixSender::onTemplate(IpfixTemplateRecord* record)
|
|||
if(templateIdToUniqueId.find(dataTemplateInfo->templateId) == templateIdToUniqueId.end()) {
|
||||
my_template_id = dataTemplateInfo->templateId;
|
||||
} else {
|
||||
msg(MSG_DEBUG, "IpfixSender: Template ID conflict, %u is already in use.", dataTemplateInfo->templateId);
|
||||
msg(LOG_INFO, "IpfixSender: Template ID conflict, %u is already in use.", dataTemplateInfo->templateId);
|
||||
}
|
||||
}
|
||||
|
||||
// generate new Template ID if necessary
|
||||
if(my_template_id == 0) {
|
||||
my_template_id = getUnusedTemplateId();
|
||||
msg(MSG_DEBUG, "IpfixSender: Use Template ID %u instead of %u.", my_template_id, dataTemplateInfo->templateId);
|
||||
msg(LOG_INFO, "IpfixSender: Use Template ID %u instead of %u.", my_template_id, dataTemplateInfo->templateId);
|
||||
}
|
||||
|
||||
// Update maps
|
||||
templateIdToUniqueId[my_template_id] = dataTemplateInfo->getUniqueId();
|
||||
uniqueIdToTemplateId[dataTemplateInfo->getUniqueId()] = my_template_id;
|
||||
|
||||
//for(map<TemplateInfo::TemplateId, uint16_t>::iterator iter = templateIdToUniqueId.begin(); iter != templateIdToUniqueId.end(); iter++) msg(MSG_FATAL, "template id %u -> unique id %u", iter->first, iter->second);
|
||||
//for(map<uint16_t, TemplateInfo::TemplateId>::iterator iter = uniqueIdToTemplateId.begin(); iter != uniqueIdToTemplateId.end(); iter++) msg(MSG_FATAL, "unique id %u -> template id %u", iter->first, iter->second);
|
||||
//for(map<TemplateInfo::TemplateId, uint16_t>::iterator iter = templateIdToUniqueId.begin(); iter != templateIdToUniqueId.end(); iter++) msg(LOG_CRIT, "template id %u -> unique id %u", iter->first, iter->second);
|
||||
//for(map<uint16_t, TemplateInfo::TemplateId>::iterator iter = uniqueIdToTemplateId.begin(); iter != uniqueIdToTemplateId.end(); iter++) msg(LOG_CRIT, "unique id %u -> template id %u", iter->first, iter->second);
|
||||
|
||||
int i;
|
||||
|
||||
|
@ -355,7 +355,7 @@ void IpfixSender::onTemplate(IpfixTemplateRecord* record)
|
|||
THROWEXCEPTION("IpfixSender: ipfix_end_template failed");
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixSender: created template with ID %u", my_template_id);
|
||||
msg(LOG_INFO, "IpfixSender: created template with ID %u", my_template_id);
|
||||
|
||||
// release message lock
|
||||
ipfixMessageLock.unlock();
|
||||
|
@ -380,7 +380,7 @@ void IpfixSender::onTemplateDestruction(IpfixTemplateDestructionRecord* record)
|
|||
// TODO: Implement Options Template handling
|
||||
if ((dataTemplateInfo->setId != TemplateInfo::IpfixTemplate))
|
||||
{
|
||||
msg(MSG_ERROR, "IpfixSender: Don't know how to handle Template (setId=%u)", dataTemplateInfo->setId);
|
||||
msg(LOG_ERR, "IpfixSender: Don't know how to handle Template (setId=%u)", dataTemplateInfo->setId);
|
||||
record->removeReference();
|
||||
return;
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ void IpfixSender::onTemplateDestruction(IpfixTemplateDestructionRecord* record)
|
|||
// send remaining records first
|
||||
sendRecords(IfNotEmpty);
|
||||
|
||||
msg(MSG_DEBUG, "IpfixSender: Template destruction received (setid=%u, id=%u)", (uint16_t)(dataTemplateInfo->setId), dataTemplateInfo->templateId);
|
||||
msg(LOG_INFO, "IpfixSender: Template destruction received (setid=%u, id=%u)", (uint16_t)(dataTemplateInfo->setId), dataTemplateInfo->templateId);
|
||||
|
||||
// get message lock
|
||||
ipfixMessageLock.lock();
|
||||
|
@ -405,7 +405,7 @@ void IpfixSender::onTemplateDestruction(IpfixTemplateDestructionRecord* record)
|
|||
|
||||
map<uint16_t, TemplateInfo::TemplateId>::iterator iter = uniqueIdToTemplateId.find(dataTemplateInfo->getUniqueId());
|
||||
if(iter == uniqueIdToTemplateId.end()) {
|
||||
msg(MSG_ERROR, "IpfixSender: Template (id=%u) to be destroyed does not exist.", dataTemplateInfo->templateId);
|
||||
msg(LOG_ERR, "IpfixSender: Template (id=%u) to be destroyed does not exist.", dataTemplateInfo->templateId);
|
||||
record->removeReference();
|
||||
ipfixMessageLock.unlock();
|
||||
return;
|
||||
|
@ -419,18 +419,18 @@ void IpfixSender::onTemplateDestruction(IpfixTemplateDestructionRecord* record)
|
|||
|
||||
/* Remove template from ipfixlolib */
|
||||
if (0 != ipfix_remove_template(ipfixExporter, my_template_id)) {
|
||||
msg(MSG_FATAL, "IpfixSender: ipfix_remove_template failed");
|
||||
msg(LOG_CRIT, "IpfixSender: ipfix_remove_template failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(MSG_DEBUG, "IpfixSender: removed template with ID %u", my_template_id);
|
||||
msg(LOG_INFO, "IpfixSender: removed template with ID %u", my_template_id);
|
||||
}
|
||||
|
||||
// enforce sending the withdrawal message
|
||||
if (ipfix_send(ipfixExporter) != 0) {
|
||||
THROWEXCEPTION("IpfixSender: ipfix_send failed");
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixSender: destroyed template with ID %u", my_template_id);
|
||||
msg(LOG_INFO, "IpfixSender: destroyed template with ID %u", my_template_id);
|
||||
|
||||
// release message lock
|
||||
ipfixMessageLock.unlock();
|
||||
|
@ -536,7 +536,7 @@ void IpfixSender::onDataRecord(IpfixDataRecord* record)
|
|||
// TODO: Implement Options Data Record handling
|
||||
if ((dataTemplateInfo->setId != TemplateInfo::IpfixTemplate))
|
||||
{
|
||||
msg(MSG_ERROR, "IpfixSender: Don't know how to handle Template (setId=%u)", dataTemplateInfo->setId);
|
||||
msg(LOG_ERR, "IpfixSender: Don't know how to handle Template (setId=%u)", dataTemplateInfo->setId);
|
||||
record->removeReference();
|
||||
return;
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ void IpfixSender::onDataRecord(IpfixDataRecord* record)
|
|||
// check if we know the Template
|
||||
map<uint16_t, TemplateInfo::TemplateId>::iterator iter = uniqueIdToTemplateId.find(dataTemplateInfo->getUniqueId());
|
||||
if(iter == uniqueIdToTemplateId.end()) {
|
||||
msg(MSG_ERROR, "IpfixSender: Discard Data Record because Template (id=%u) does not exist (this may happen during reconfiguration).", dataTemplateInfo->templateId);
|
||||
msg(LOG_ERR, "IpfixSender: Discard Data Record because Template (id=%u) does not exist (this may happen during reconfiguration).", dataTemplateInfo->templateId);
|
||||
record->removeReference();
|
||||
ipfixMessageLock.unlock();
|
||||
return;
|
||||
|
@ -666,7 +666,7 @@ void IpfixSender::addDataRecordValue(TemplateInfo::FieldInfo* fi, IpfixRecord::D
|
|||
// Need to allocate memory to store length etc. as they are not immediately sent over the wire
|
||||
// Is deallocated in IpfixRecord destructor
|
||||
if (record->variableLenData == NULL) {
|
||||
msg(MSG_ERROR, "Variable length data present but variableLenData not allocated.");
|
||||
msg(LOG_ERR, "Variable length data present but variableLenData not allocated.");
|
||||
}
|
||||
|
||||
// Semantic (1B) + Field ID (2B) + Element Length (2B) + (optional: Enterprise Number (3B)) + basicList Content (variable)
|
||||
|
@ -726,11 +726,11 @@ void IpfixSender::onReconfiguration2()
|
|||
for(map<TemplateInfo::TemplateId, uint16_t>::iterator iter = templateIdToUniqueId.begin(); iter != templateIdToUniqueId.end(); iter++) {
|
||||
/* Remove template from ipfixlolib */
|
||||
if (0 != ipfix_remove_template(ipfixExporter, iter->first)) {
|
||||
msg(MSG_FATAL, "IpfixSender: ipfix_remove_template failed");
|
||||
msg(LOG_CRIT, "IpfixSender: ipfix_remove_template failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(MSG_DEBUG, "IpfixSender: removed template with ID %u", iter->first);
|
||||
msg(LOG_INFO, "IpfixSender: removed template with ID %u", iter->first);
|
||||
}
|
||||
}
|
||||
// clear maps
|
||||
|
|
|
@ -38,7 +38,7 @@ void NetflowV9Converter::onTemplate(IpfixTemplateRecord* record)
|
|||
//if (true) {
|
||||
// This should be a new Template for us
|
||||
if(uniqueIdToConvInfo.find(templateInfo->getUniqueId()) != uniqueIdToConvInfo.end()) {
|
||||
msg(MSG_ERROR, "NetflowV9Converter: Received known Template (id=%u) again, which should not happen.", templateInfo->templateId);
|
||||
msg(LOG_ERR, "NetflowV9Converter: Received known Template (id=%u) again, which should not happen.", templateInfo->templateId);
|
||||
record->removeReference();
|
||||
return;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void NetflowV9Converter::onTemplate(IpfixTemplateRecord* record)
|
|||
// Save field index for future reference
|
||||
myConvInfo.fieldIndexes.push_back(i);
|
||||
} else
|
||||
msg(MSG_ERROR, "NetflowV9Converter: flowStartSysUpTime has expected length 4, got %u", fi->type.length);
|
||||
msg(LOG_ERR, "NetflowV9Converter: flowStartSysUpTime has expected length 4, got %u", fi->type.length);
|
||||
} else if (fi->type.id == IPFIX_TYPEID_flowEndSysUpTime) {
|
||||
// length should be 4 octets
|
||||
if(fi->type.length == 4) {
|
||||
|
@ -106,10 +106,10 @@ void NetflowV9Converter::onTemplate(IpfixTemplateRecord* record)
|
|||
// Save field index
|
||||
myConvInfo.fieldIndexes.push_back(i);
|
||||
} else
|
||||
msg(MSG_ERROR, "NetflowV9Converter: flowStartSysUpTime has expected length 4, got %u", fi->type.length);
|
||||
msg(LOG_ERR, "NetflowV9Converter: flowStartSysUpTime has expected length 4, got %u", fi->type.length);
|
||||
}
|
||||
} else {
|
||||
msg(MSG_ERROR, "NetflowV9Converter: Got enterprise specific IE (id=%u, enterprise=%u, length=%u) in Netflow Template, which should not happen", fi->type.id, fi->type.enterprise, fi->type.length);
|
||||
msg(LOG_ERR, "NetflowV9Converter: Got enterprise specific IE (id=%u, enterprise=%u, length=%u) in Netflow Template, which should not happen", fi->type.id, fi->type.enterprise, fi->type.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ void NetflowV9Converter::onTemplateDestruction(IpfixTemplateDestructionRecord* r
|
|||
// This should be a known Template for us
|
||||
map<uint16_t, ConvInfo>::iterator iter = uniqueIdToConvInfo.find(templateInfo->getUniqueId());
|
||||
if(iter == uniqueIdToConvInfo.end()) {
|
||||
msg(MSG_ERROR, "NetflowV9Converter: Received unknown Template (id=%u), which should not happen.", templateInfo->templateId);
|
||||
msg(LOG_ERR, "NetflowV9Converter: Received unknown Template (id=%u), which should not happen.", templateInfo->templateId);
|
||||
record->removeReference();
|
||||
return;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ void NetflowV9Converter::onDataRecord(IpfixDataRecord* record)
|
|||
// This should be a known Template for us
|
||||
map<uint16_t, ConvInfo>::iterator iter = uniqueIdToConvInfo.find(templateInfo->getUniqueId());
|
||||
if(iter == uniqueIdToConvInfo.end()) {
|
||||
msg(MSG_ERROR, "NetflowV9Converter: Received Data Record associated to unknown Template (id=%u), which should not happen.", templateInfo->templateId);
|
||||
msg(LOG_ERR, "NetflowV9Converter: Received Data Record associated to unknown Template (id=%u), which should not happen.", templateInfo->templateId);
|
||||
record->removeReference();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ NetflowV9ConverterCfg::NetflowV9ConverterCfg(XMLElement* elem)
|
|||
keepFlowSysUpTime = getBool("keepFlowSysUpTime");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown NetflowV9Converter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown NetflowV9Converter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ AggregatorBaseCfg::AggregatorBaseCfg(XMLElement* elem)
|
|||
if (rules->count < MAX_RULES) {
|
||||
rules->rule[rules->count++] = r;
|
||||
} else {
|
||||
msg(MSG_FATAL, "Too many rules: %ul\n", MAX_RULES);
|
||||
msg(LOG_CRIT, "Too many rules: %ul\n", MAX_RULES);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ AggregatorBaseCfg::AggregatorBaseCfg(XMLElement* elem)
|
|||
htableBits = getInt("hashtableBits", HT_DEFAULT_BITSIZE);
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unkown Aggregator config entry %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unkown Aggregator config entry %s\n", e->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ Rule* AggregatorBaseCfg::readRule(XMLElement* elem) {
|
|||
if(rule->biflowAggregation) {
|
||||
for(int i=0; i < rule->fieldCount; i++) {
|
||||
if(rule->field[i]->pattern) {
|
||||
msg(MSG_ERROR, "AggregatorBaseCfg: Match pattern for id=%d ignored because biflow aggregation is enabled.", rule->field[i]->type.id);
|
||||
msg(LOG_ERR, "AggregatorBaseCfg: Match pattern for id=%d ignored because biflow aggregation is enabled.", rule->field[i]->type.id);
|
||||
free(rule->field[i]->pattern);
|
||||
rule->field[i]->pattern = NULL;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ Rule::Field* AggregatorBaseCfg::readFlowKeyRule(XMLElement* e) {
|
|||
switch (ruleField->type.id) {
|
||||
case IPFIX_TYPEID_protocolIdentifier:
|
||||
if (parseProtoPattern(tmp, &ruleField->pattern, &ruleField->type.length) != 0) {
|
||||
msg(MSG_ERROR, "Bad protocol pattern \"%s\"", tmp);
|
||||
msg(LOG_ERR, "Bad protocol pattern \"%s\"", tmp);
|
||||
delete [] tmp;
|
||||
throw std::exception();
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ Rule::Field* AggregatorBaseCfg::readFlowKeyRule(XMLElement* e) {
|
|||
case IPFIX_TYPEID_sourceIPv4Address:
|
||||
case IPFIX_TYPEID_destinationIPv4Address:
|
||||
if (parseIPv4Pattern(tmp, &ruleField->pattern, &ruleField->type.length) != 0) {
|
||||
msg(MSG_ERROR, "Bad IPv4 pattern \"%s\"", tmp);
|
||||
msg(LOG_ERR, "Bad IPv4 pattern \"%s\"", tmp);
|
||||
delete [] tmp;
|
||||
throw std::exception();
|
||||
}
|
||||
|
@ -213,21 +213,21 @@ Rule::Field* AggregatorBaseCfg::readFlowKeyRule(XMLElement* e) {
|
|||
case IPFIX_TYPEID_udpDestinationPort:
|
||||
case IPFIX_TYPEID_tcpDestinationPort:
|
||||
if (parsePortPattern(tmp, &ruleField->pattern, &ruleField->type.length) != 0) {
|
||||
msg(MSG_ERROR, "Bad PortRanges pattern \"%s\"", tmp);
|
||||
msg(LOG_ERR, "Bad PortRanges pattern \"%s\"", tmp);
|
||||
delete [] tmp;
|
||||
throw std::exception();
|
||||
}
|
||||
break;
|
||||
case IPFIX_TYPEID_tcpControlBits:
|
||||
if (parseTcpFlags(tmp, &ruleField->pattern, &ruleField->type.length) != 0) {
|
||||
msg(MSG_ERROR, "Bad TCP flags pattern \"%s\"", tmp);
|
||||
msg(LOG_ERR, "Bad TCP flags pattern \"%s\"", tmp);
|
||||
delete [] tmp;
|
||||
throw std::exception();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
msg(MSG_ERROR, "Fields of type \"%s\" cannot be matched against a pattern %s", "", tmp);
|
||||
msg(LOG_ERR, "Fields of type \"%s\" cannot be matched against a pattern %s", "", tmp);
|
||||
delete [] tmp;
|
||||
throw std::exception();
|
||||
break;
|
||||
|
|
|
@ -132,7 +132,7 @@ void BaseAggregator::buildAggregator(Rules* rules, uint16_t inactiveTimeout, uin
|
|||
rules->rule[i]->hashtable = createHashtable(rules->rule[i], inactiveTimeout, activeTimeout, hashbits);
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Done. Parsed %zu rules; inactiveTimeout %d, activeTimeout %d", rules->count, inactiveTimeout, activeTimeout);
|
||||
msg(LOG_NOTICE, "Done. Parsed %zu rules; inactiveTimeout %d, activeTimeout %d", rules->count, inactiveTimeout, activeTimeout);
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@ void BaseAggregator::exporterThread()
|
|||
|
||||
registerCurrentThread();
|
||||
|
||||
msg(MSG_INFO, "Polling aggregator each %u msec", pollInterval);
|
||||
msg(LOG_NOTICE, "Polling aggregator each %u msec", pollInterval);
|
||||
while (!exitFlag) {
|
||||
addToCurTime(&inttimer, pollInterval);
|
||||
|
||||
|
@ -171,7 +171,7 @@ void BaseAggregator::exporterThread()
|
|||
}
|
||||
|
||||
gettimeofday(&curtime, 0);
|
||||
DPRINTFL(MSG_VDEBUG,"Aggregator: starting Export");
|
||||
DPRINTFL(LOG_DEBUG,"Aggregator: starting Export");
|
||||
for (size_t i = 0; i < rules->count; i++) {
|
||||
rules->rule[i]->hashtable->expireFlows();
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ void BaseAggregator::exporterThread()
|
|||
gettimeofday(&endtime, 0);
|
||||
timeval_subtract(&difftime, &endtime, &curtime);
|
||||
|
||||
DPRINTFL(MSG_VDEBUG,"Aggregator: export took %.03f secs", (float)difftime.tv_usec/1000000+difftime.tv_sec);
|
||||
DPRINTFL(LOG_DEBUG,"Aggregator: export took %.03f secs", (float)difftime.tv_usec/1000000+difftime.tv_sec);
|
||||
}
|
||||
|
||||
if (getShutdownProperly()) {
|
||||
|
|
|
@ -56,10 +56,10 @@ BaseHashtable::BaseHashtable(Source<IpfixRecord*>* recordsource, Rule* rule,
|
|||
hbucketIM("BucketListElement", 0),
|
||||
aggInProgress(false)
|
||||
{
|
||||
msg(MSG_INFO, "Hashtable initialized with following parameters:");
|
||||
msg(MSG_INFO, " - inactiveTimeout=%d", inactiveTimeout);
|
||||
msg(MSG_INFO, " - activeTimeout=%d", activeTimeout);
|
||||
msg(MSG_INFO, " - htableBits=%d", hashbits);
|
||||
msg(LOG_NOTICE, "Hashtable initialized with following parameters:");
|
||||
msg(LOG_NOTICE, " - inactiveTimeout=%d", inactiveTimeout);
|
||||
msg(LOG_NOTICE, " - activeTimeout=%d", activeTimeout);
|
||||
msg(LOG_NOTICE, " - htableBits=%d", hashbits);
|
||||
|
||||
buckets = new HashtableBucket*[htableSize];
|
||||
for (uint32_t i = 0; i < htableSize; i++)
|
||||
|
@ -444,7 +444,7 @@ void BaseHashtable::performShutdown()
|
|||
|
||||
void BaseHashtable::preReconfiguration()
|
||||
{
|
||||
msg(MSG_INFO, "BaseHashtable: Forcing export for flows, then destroy Template.");
|
||||
msg(LOG_NOTICE, "BaseHashtable: Forcing export for flows, then destroy Template.");
|
||||
expireFlows(true);
|
||||
// we do not need to destroy the template since every module should delete stored templates during reconfiguration
|
||||
// sendTemplateDestructionRecord();
|
||||
|
@ -635,12 +635,12 @@ void BaseHashtable::reverseFlowBucket(HashtableBucket* bucket)
|
|||
TemplateInfo::FieldInfo* fi2 = &dataTemplate->fieldInfo[flowReverseMapper[i]];
|
||||
|
||||
if (fi != fi2) {
|
||||
//msg(MSG_ERROR, "mapping idx %d to idx %d", i, flowReverseMapper[i]);
|
||||
//msg(MSG_ERROR, "mapping IE %s to IE %s", fi->type.toString().c_str(), fi2->type.toString().c_str());
|
||||
//msg(LOG_ERR, "mapping idx %d to idx %d", i, flowReverseMapper[i]);
|
||||
//msg(LOG_ERR, "mapping IE %s to IE %s", fi->type.toString().c_str(), fi2->type.toString().c_str());
|
||||
//if (fi->type.id == 152) {
|
||||
// uint64_t oldStart = ntohll(*((uint64_t*)(bucket->data.get() + fi->offset)));
|
||||
// uint64_t newStart = ntohll(*((uint64_t*)(bucket->data.get() + fi2->offset)));
|
||||
// msg(MSG_ERROR, "old: %lu / new: %lu compare: %d", oldStart, newStart, oldStart < newStart);
|
||||
// msg(LOG_ERR, "old: %lu / new: %lu compare: %d", oldStart, newStart, oldStart < newStart);
|
||||
//}
|
||||
IpfixRecord::Data* src = bucket->data.get()+fi->offset;
|
||||
IpfixRecord::Data* dst = bucket->data.get()+fi2->offset;
|
||||
|
|
|
@ -456,7 +456,7 @@ void FlowHashtable::bufferDataBlock(boost::shared_array<IpfixRecord::Data> data)
|
|||
statRecordsReceived++;
|
||||
|
||||
uint32_t nhash = getHash(data.get(), false);
|
||||
DPRINTFL(MSG_VDEBUG, "nhash=%u", nhash);
|
||||
DPRINTFL(LOG_DEBUG, "nhash=%u", nhash);
|
||||
HashtableBucket* prevbucket;
|
||||
HashtableBucket* bucket = lookupBucket(nhash, data.get(), false, &prevbucket);
|
||||
|
||||
|
@ -465,7 +465,7 @@ void FlowHashtable::bufferDataBlock(boost::shared_array<IpfixRecord::Data> data)
|
|||
timeval unix_now = unixtime();
|
||||
|
||||
if (bucket != NULL) {
|
||||
DPRINTFL(MSG_VDEBUG, "aggregating flow");
|
||||
DPRINTFL(LOG_DEBUG, "aggregating flow");
|
||||
// check if we need to expire the flow. we use a simple
|
||||
// distribution scheme to distribute flow counters among
|
||||
// flows that overlap with the active timeouts:
|
||||
|
@ -490,7 +490,7 @@ void FlowHashtable::bufferDataBlock(boost::shared_array<IpfixRecord::Data> data)
|
|||
if (biflowAggregation && !flowfound && !expiryforced) {
|
||||
// try reverse flow
|
||||
uint32_t rhash = getHash(data.get(), true);
|
||||
DPRINTFL(MSG_VDEBUG, "rhash=%u", rhash);
|
||||
DPRINTFL(LOG_DEBUG, "rhash=%u", rhash);
|
||||
bucket = lookupBucket(rhash, data.get(), true, &prevbucket);
|
||||
if (bucket != NULL) {
|
||||
if (unix_now.tv_sec > bucket->inactiveExpireTime || unix_now.tv_sec > bucket->activeExpireTime) {
|
||||
|
@ -499,12 +499,12 @@ void FlowHashtable::bufferDataBlock(boost::shared_array<IpfixRecord::Data> data)
|
|||
removeBucket(bucket);
|
||||
} else {
|
||||
flowfound = true;
|
||||
DPRINTFL(MSG_VDEBUG, "aggregating reverse flow");
|
||||
DPRINTFL(LOG_DEBUG, "aggregating reverse flow");
|
||||
int must_reverse = aggregateFlow(bucket->data.get(), data.get(), true);
|
||||
if (must_reverse == 1) {
|
||||
DPRINTFL(MSG_VDEBUG, "reversing whole flow");
|
||||
DPRINTFL(LOG_DEBUG, "reversing whole flow");
|
||||
// reverse flow
|
||||
//msg(MSG_ERROR, "Reversing flow");
|
||||
//msg(LOG_ERR, "Reversing flow");
|
||||
reverseFlowBucket(bucket);
|
||||
// delete reference from hash table
|
||||
if (prevbucket==NULL)
|
||||
|
@ -516,7 +516,7 @@ void FlowHashtable::bufferDataBlock(boost::shared_array<IpfixRecord::Data> data)
|
|||
bucket->next->prev = prevbucket;
|
||||
// insert into hash table again
|
||||
nhash = getHash(bucket->data.get(), false);
|
||||
DPRINTFL(MSG_VDEBUG, "nhash=%u", nhash);
|
||||
DPRINTFL(LOG_DEBUG, "nhash=%u", nhash);
|
||||
bucket->next = buckets[nhash];
|
||||
bucket->hash = nhash;
|
||||
buckets[nhash] = bucket;
|
||||
|
@ -533,7 +533,7 @@ void FlowHashtable::bufferDataBlock(boost::shared_array<IpfixRecord::Data> data)
|
|||
}
|
||||
}
|
||||
if (!flowfound || expiryforced) {
|
||||
DPRINTFL(MSG_VDEBUG, "creating new bucket");
|
||||
DPRINTFL(LOG_DEBUG, "creating new bucket");
|
||||
statTotalEntries++;
|
||||
HashtableBucket* n = buckets[nhash];
|
||||
buckets[nhash] = createBucket(data, 0, n, 0, nhash, unix_now.tv_sec); // FIXME: insert observationDomainID!
|
||||
|
|
|
@ -117,12 +117,12 @@ void PacketHashtable::copyDataNanoseconds(CopyFuncParameters* cfp)
|
|||
uint64_t ntptime;
|
||||
ntptime = ntp64timegcc(*reinterpret_cast<const struct timeval*>(cfp->src));
|
||||
uint64_t ntp2 = htonll(ntptime);
|
||||
DPRINTFL(MSG_VDEBUG, "ntp2: %llu, ntptime/ntp2 %llX/%llX", ntp2, ntptime, ntp2);
|
||||
DPRINTFL(LOG_DEBUG, "ntp2: %llu, ntptime/ntp2 %llX/%llX", ntp2, ntptime, ntp2);
|
||||
memcpy(cfp->dst+efd->dstIndex, &ntp2, sizeof(ntp2));
|
||||
#ifdef DEBUG
|
||||
if (ntohll(*(uint64_t*)(cfp->dst+efd->dstIndex))<(1000000000ULL+(2208988800ULL<<32)) || ntohll(*(uint64_t*)(cfp->dst+efd->dstIndex))>(1300000000ULL+(2208988800ULL<<32))) {
|
||||
DPRINTFL(MSG_VDEBUG, "time before: %ds", reinterpret_cast<const struct timeval*>(cfp->src)->tv_sec);
|
||||
DPRINTFL(MSG_VDEBUG, "copy invalid end nano seconds: %lld s (%llX)", (ntohll(*(uint64_t*)(cfp->dst+efd->dstIndex))>>32)-2208988800U, *(uint64_t*)(cfp->dst+efd->dstIndex));
|
||||
DPRINTFL(LOG_DEBUG, "time before: %ds", reinterpret_cast<const struct timeval*>(cfp->src)->tv_sec);
|
||||
DPRINTFL(LOG_DEBUG, "copy invalid end nano seconds: %lld s (%llX)", (ntohll(*(uint64_t*)(cfp->dst+efd->dstIndex))>>32)-2208988800U, *(uint64_t*)(cfp->dst+efd->dstIndex));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ void PacketHashtable::copyDataTransportOctets(CopyFuncParameters* cfp)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
DPRINTFL(MSG_VDEBUG, "%s=%llu, ppd->seq=%u", cfp->efd->typeId.toString().c_str(), ntohll(*reinterpret_cast<uint64_t*>(cfp->dst+cfp->efd->dstIndex)), ntohl(ppd->seq));
|
||||
DPRINTFL(LOG_DEBUG, "%s=%llu, ppd->seq=%u", cfp->efd->typeId.toString().c_str(), ntohll(*reinterpret_cast<uint64_t*>(cfp->dst+cfp->efd->dstIndex)), ntohl(ppd->seq));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +179,7 @@ void PacketHashtable::copyDataTransportOctets(CopyFuncParameters* cfp)
|
|||
void PacketHashtable::aggregateFrontPayload(IpfixRecord::Data* bucket, HashtableBucket* hbucket, const Packet* src,
|
||||
const ExpFieldData* efd, bool firstpacket, bool onlyinit)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "called (%s, %hhu, %hhu)", efd->typeId.toString().c_str(), firstpacket, onlyinit);
|
||||
DPRINTFL(LOG_DEBUG, "called (%s, %hhu, %hhu)", efd->typeId.toString().c_str(), firstpacket, onlyinit);
|
||||
PayloadPrivateData* ppd = reinterpret_cast<PayloadPrivateData*>(bucket+efd->privDataOffset);
|
||||
|
||||
if (onlyinit) {
|
||||
|
@ -195,28 +195,28 @@ void PacketHashtable::aggregateFrontPayload(IpfixRecord::Data* bucket, Hashtable
|
|||
if (efd->typeSpecData.frontPayload.dpa && plen>0) {
|
||||
DpaPrivateData* dpd = reinterpret_cast<DpaPrivateData*>(bucket+efd->typeSpecData.frontPayload.dpaPrivDataOffset);
|
||||
bool revdir = efd->typeId.isReverseField();
|
||||
DPRINTFL(MSG_VDEBUG, "pkt revdir=%hhu, plen=%u, datarecv=%hhu, dpd=%u, buckdata=%X, dparevstartoffset=%u\n", revdir, plen, dpd->datarecv, dpd, bucket, efd->typeSpecData.frontPayload.dpaRevStartOffset);
|
||||
DPRINTFL(LOG_DEBUG, "pkt revdir=%hhu, plen=%u, datarecv=%hhu, dpd=%u, buckdata=%X, dparevstartoffset=%u\n", revdir, plen, dpd->datarecv, dpd, bucket, efd->typeSpecData.frontPayload.dpaRevStartOffset);
|
||||
if (!dpd->datarecv) {
|
||||
// first time we receive data!
|
||||
dpd->revstart = revdir;
|
||||
if (efd->typeSpecData.frontPayload.dpaRevStartOffset != ExpHelperTable::UNUSED)
|
||||
*reinterpret_cast<uint8_t*>(bucket+efd->typeSpecData.frontPayload.dpaRevStartOffset) = revdir;
|
||||
dpd->datarecv = true;
|
||||
DPRINTFL(MSG_DEBUG, "1. revstart=%hhu\n", revdir);
|
||||
DPRINTFL(LOG_INFO, "1. revstart=%hhu\n", revdir);
|
||||
} else if ((revdir && !dpd->revstart) || (!revdir && dpd->revstart)) {
|
||||
// we are now in other direction
|
||||
dpd->revdata = true;
|
||||
DPRINTFL(MSG_DEBUG, "2. revdata=%hhu\n", dpd->revdata);
|
||||
DPRINTFL(LOG_INFO, "2. revdata=%hhu\n", dpd->revdata);
|
||||
} else if (dpd->revdata && ((dpd->revstart && revdir) || (!dpd->revstart && !revdir))) {
|
||||
// this flow *must* be exported!
|
||||
DPRINTFL(MSG_DEBUG, "3. export");
|
||||
DPRINTFL(LOG_INFO, "3. export");
|
||||
if (efd->typeSpecData.frontPayload.dpaForcedExportOffset != ExpHelperTable::UNUSED)
|
||||
*reinterpret_cast<uint8_t*>(bucket+efd->typeSpecData.frontPayload.dpaForcedExportOffset) = 1;
|
||||
assert(hbucket!=NULL);
|
||||
hbucket->forceExpiry = true;
|
||||
return;
|
||||
} else {
|
||||
DPRINTFL(MSG_DEBUG, "4. okdata");
|
||||
DPRINTFL(LOG_INFO, "4. okdata");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ void PacketHashtable::aggregateFrontPayload(IpfixRecord::Data* bucket, Hashtable
|
|||
if (src->ipProtocolType==Packet::TCP) {
|
||||
memcpy(&seq, src->data.netHeader+src->transportHeaderOffset+4, sizeof(uint32_t));
|
||||
}
|
||||
DPRINTFL(MSG_VDEBUG, "seq:%u, len:%u, udp:%u", seq, ppd->byteCount, src->ipProtocolType==Packet::UDP);
|
||||
DPRINTFL(LOG_DEBUG, "seq:%u, len:%u, udp:%u", seq, ppd->byteCount, src->ipProtocolType==Packet::UDP);
|
||||
|
||||
if (firstpacket || !ppd->initialized) {
|
||||
if (src->ipProtocolType==Packet::TCP && src->data.netHeader[src->transportHeaderOffset+13] & 0x02) {
|
||||
|
@ -246,13 +246,13 @@ void PacketHashtable::aggregateFrontPayload(IpfixRecord::Data* bucket, Hashtable
|
|||
uint32_t fseq = ppd->seq;
|
||||
uint32_t fpos = ppd->byteCount;
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "plen:%u, fseq:%u, seq:%u, dstleng:%u", plen, fseq, seq, efd->dstLength);
|
||||
DPRINTFL(LOG_DEBUG, "plen:%u, fseq:%u, seq:%u, dstleng:%u", plen, fseq, seq, efd->dstLength);
|
||||
|
||||
if (seq-fseq<efd->dstLength) {
|
||||
uint32_t pos = (seq!=0 ? seq-fseq : fpos);
|
||||
uint32_t len = efd->dstLength-pos;
|
||||
if (plen<len) len = plen;
|
||||
DPRINTFL(MSG_VDEBUG, "inserting payload data at %u with length %u", pos, len);
|
||||
DPRINTFL(LOG_DEBUG, "inserting payload data at %u with length %u", pos, len);
|
||||
memcpy(dst+pos, src->data.netHeader+src->payloadOffset, len);
|
||||
uint32_t maxpos = pos+len;
|
||||
if (*pfplen<maxpos) *pfplen = maxpos;
|
||||
|
@ -269,7 +269,7 @@ void PacketHashtable::aggregateFrontPayload(IpfixRecord::Data* bucket, Hashtable
|
|||
if (*pfplen<efd->dstLength) {
|
||||
uint32_t len = efd->dstLength-*pfplen;
|
||||
if (plen<len) len = plen;
|
||||
DPRINTFL(MSG_VDEBUG, "inserting payload data at %u with length %u", *pfplen, len);
|
||||
DPRINTFL(LOG_DEBUG, "inserting payload data at %u with length %u", *pfplen, len);
|
||||
memcpy(dst+(*pfplen), src->data.netHeader+src->payloadOffset, len);
|
||||
*pfplen += len;
|
||||
|
||||
|
@ -283,7 +283,7 @@ void PacketHashtable::aggregateFrontPayload(IpfixRecord::Data* bucket, Hashtable
|
|||
}
|
||||
}
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "new fplength: %u", *reinterpret_cast<uint32_t*>(bucket+efd->privDataOffset+4));
|
||||
DPRINTFL(LOG_DEBUG, "new fplength: %u", *reinterpret_cast<uint32_t*>(bucket+efd->privDataOffset+4));
|
||||
}
|
||||
|
||||
|
||||
|
@ -628,14 +628,14 @@ int32_t PacketHashtable::getRawPacketFieldOffset(const IeInfo& type, const Packe
|
|||
if(p->ipProtocolType == Packet::ICMP) {
|
||||
return p->transportHeader + 0 - p->data.netHeader;
|
||||
} else {
|
||||
DPRINTFL(MSG_VDEBUG, "given id is %s, protocol is %d, but expected was %d", type.toString().c_str(), p->ipProtocolType, Packet::ICMP);
|
||||
DPRINTFL(LOG_DEBUG, "given id is %s, protocol is %d, but expected was %d", type.toString().c_str(), p->ipProtocolType, Packet::ICMP);
|
||||
}
|
||||
break;
|
||||
case IPFIX_TYPEID_sourceTransportPort:
|
||||
if((p->ipProtocolType == Packet::TCP) || (p->ipProtocolType == Packet::UDP)) {
|
||||
return p->transportHeader + 0 - p->data.netHeader;
|
||||
} else {
|
||||
DPRINTFL(MSG_VDEBUG, "given id is %s, protocol is %d, but expected was %d or %d", type.toString().c_str(), p->ipProtocolType, Packet::UDP, Packet::TCP);
|
||||
DPRINTFL(LOG_DEBUG, "given id is %s, protocol is %d, but expected was %d or %d", type.toString().c_str(), p->ipProtocolType, Packet::UDP, Packet::TCP);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -643,7 +643,7 @@ int32_t PacketHashtable::getRawPacketFieldOffset(const IeInfo& type, const Packe
|
|||
if((p->ipProtocolType == Packet::TCP) || (p->ipProtocolType == Packet::UDP)) {
|
||||
return p->transportHeader + 2 - p->data.netHeader;
|
||||
} else {
|
||||
DPRINTFL(MSG_VDEBUG, "given id is %s, protocol is %d, but expected was %d or %d", type.toString().c_str(), p->ipProtocolType, Packet::UDP, Packet::TCP);
|
||||
DPRINTFL(LOG_DEBUG, "given id is %s, protocol is %d, but expected was %d or %d", type.toString().c_str(), p->ipProtocolType, Packet::UDP, Packet::TCP);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -657,7 +657,7 @@ int32_t PacketHashtable::getRawPacketFieldOffset(const IeInfo& type, const Packe
|
|||
THROWEXCEPTION("unsupported length %d for type %d", type.length, type.id);
|
||||
}
|
||||
} else {
|
||||
DPRINTFL(MSG_VDEBUG, "given id is %s, protocol is %d, but expected was %d", type.toString().c_str(), p->ipProtocolType, Packet::TCP);
|
||||
DPRINTFL(LOG_DEBUG, "given id is %s, protocol is %d, but expected was %d", type.toString().c_str(), p->ipProtocolType, Packet::TCP);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -754,7 +754,7 @@ bool PacketHashtable::isRawPacketPtrVariable(const IeInfo& type)
|
|||
*/
|
||||
void PacketHashtable::fillExpFieldData(ExpFieldData* efd, TemplateInfo::FieldInfo* hfi, Rule::Field::Modifier fieldModifier, uint16_t index)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "called for type id %s", hfi->type.toString().c_str());
|
||||
DPRINTFL(LOG_DEBUG, "called for type id %s", hfi->type.toString().c_str());
|
||||
efd->typeId = hfi->type;
|
||||
efd->dstIndex = hfi->offset;
|
||||
efd->modifier = fieldModifier;
|
||||
|
@ -948,7 +948,7 @@ void PacketHashtable::buildExpHelperTable()
|
|||
ExpFieldData* efd = &expHelperTable.aggFields[expHelperTable.noAggFields++];
|
||||
fillExpFieldData(efd, hfi, fieldModifier[i], expHelperTable.noAggFields-1);
|
||||
if (hfi->type==IeInfo(IPFIX_ETYPEID_dpaForcedExport, IPFIX_PEN_vermont)) {
|
||||
msg(MSG_INFO, "activated dialog-based payload aggregation");
|
||||
msg(LOG_NOTICE, "activated dialog-based payload aggregation");
|
||||
expHelperTable.useDPA = true;
|
||||
}
|
||||
}
|
||||
|
@ -1069,7 +1069,7 @@ uint32_t PacketHashtable::calculateHash(const IpfixRecord::Data* data)
|
|||
uint32_t hash = 0xAAAAAAAA;
|
||||
for (int i=0; i<expHelperTable.noKeyFields; i++) {
|
||||
ExpFieldData* efd = &expHelperTable.keyFields[i];
|
||||
DPRINTFL(MSG_VDEBUG, "hash for i=%u, typeid=%s, srcpointer=%X", i, efd->typeId.toString().c_str(),
|
||||
DPRINTFL(LOG_DEBUG, "hash for i=%u, typeid=%s, srcpointer=%X", i, efd->typeId.toString().c_str(),
|
||||
efd->srcLength, reinterpret_cast<const char*>(data)+efd->srcIndex);
|
||||
hash = crc32(hash, efd->srcLength, reinterpret_cast<const char*>(data)+efd->srcIndex);
|
||||
}
|
||||
|
@ -1084,7 +1084,7 @@ uint32_t PacketHashtable::calculateHashRev(const IpfixRecord::Data* data)
|
|||
uint32_t hash = 0xAAAAAAAA;
|
||||
for (int i=0; i<expHelperTable.noKeyFields; i++) {
|
||||
ExpFieldData* efd = expHelperTable.revKeyFieldMapper[i];
|
||||
DPRINTFL(MSG_VDEBUG, "hashrev for i=%u, typeid=%s, length=%u, srcpointer=%X", i,
|
||||
DPRINTFL(LOG_DEBUG, "hashrev for i=%u, typeid=%s, length=%u, srcpointer=%X", i,
|
||||
efd->typeId.toString().c_str(), efd->srcLength, reinterpret_cast<const char*>(data)+efd->srcIndex);
|
||||
hash = crc32(hash, efd->srcLength, reinterpret_cast<const char*>(data)+efd->srcIndex);
|
||||
}
|
||||
|
@ -1100,7 +1100,7 @@ boost::shared_array<IpfixRecord::Data> PacketHashtable::buildBucketData(Packet*
|
|||
// new field for insertion into hashtable
|
||||
boost::shared_array<IpfixRecord::Data> htdata(new IpfixRecord::Data[fieldLength+privDataLength]);
|
||||
IpfixRecord::Data* data = htdata.get();
|
||||
//msg(MSG_INFO, "fieldLength=%u, privDataLength=%u, bucketdata=%X\n", fieldLength, privDataLength, data);
|
||||
//msg(LOG_NOTICE, "fieldLength=%u, privDataLength=%u, bucketdata=%X\n", fieldLength, privDataLength, data);
|
||||
bzero(data, fieldLength+privDataLength);
|
||||
CopyFuncParameters cfp;
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ void PacketHashtable::aggregateField(const ExpFieldData* efd, HashtableBucket* h
|
|||
*reinterpret_cast<uint64_t*>(baseData) = htonll(0x100000000LL+seq-ppd->seq+plen+ntohll(*reinterpret_cast<uint64_t*>(baseData)));
|
||||
ppd->seq = seq+plen;
|
||||
}
|
||||
DPRINTFL(MSG_VDEBUG, "%s=%llu, ppd->seq=%u", efd->typeId.toString().c_str(), ntohll(*reinterpret_cast<uint64_t*>(baseData)), ntohl(ppd->seq));
|
||||
DPRINTFL(LOG_DEBUG, "%s=%llu, ppd->seq=%u", efd->typeId.toString().c_str(), ntohll(*reinterpret_cast<uint64_t*>(baseData)), ntohl(ppd->seq));
|
||||
break;
|
||||
|
||||
case Packet::UDP:
|
||||
|
@ -1189,13 +1189,13 @@ void PacketHashtable::aggregateField(const ExpFieldData* efd, HashtableBucket* h
|
|||
case IPFIX_TYPEID_flowStartNanoseconds:
|
||||
ntptime = ntp64timegcc(*reinterpret_cast<const struct timeval*>(deltaData));
|
||||
ntp2 = htonll(ntptime);
|
||||
DPRINTFL(MSG_VDEBUG, "base: %lu s, delta: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U, ntohll(ntp2));
|
||||
DPRINTFL(MSG_VDEBUG, "base: %llX , delta: %llX", ntohll(*(uint64_t*)baseData), ntohll(ntp2));
|
||||
DPRINTFL(LOG_DEBUG, "base: %lu s, delta: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U, ntohll(ntp2));
|
||||
DPRINTFL(LOG_DEBUG, "base: %llX , delta: %llX", ntohll(*(uint64_t*)baseData), ntohll(ntp2));
|
||||
*(uint64_t*)baseData = lesserUint64Nbo(*(uint64_t*)baseData, ntp2);
|
||||
#ifdef DEBUG
|
||||
if (ntohll(*(uint64_t*)baseData)<(1000000000ULL+(2208988800ULL<<32)) || ntohll(*(uint64_t*)baseData)>(1300000000ULL+(2208988800ULL<<32))) {
|
||||
DPRINTFL(MSG_VDEBUG, "invalid start nano seconds: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U);
|
||||
DPRINTFL(MSG_VDEBUG, "base: %llX , delta: %llX", *(uint64_t*)baseData, *(uint64_t*)deltaData);
|
||||
DPRINTFL(LOG_DEBUG, "invalid start nano seconds: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U);
|
||||
DPRINTFL(LOG_DEBUG, "base: %llX , delta: %llX", *(uint64_t*)baseData, *(uint64_t*)deltaData);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -1214,7 +1214,7 @@ void PacketHashtable::aggregateField(const ExpFieldData* efd, HashtableBucket* h
|
|||
*(uint64_t*)baseData = greaterUint64Nbo(*(uint64_t*)baseData, ntp2);
|
||||
#ifdef DEBUG
|
||||
if (ntohll(*(uint64_t*)baseData)<(1000000000ULL+(2208988800ULL<<32)) || ntohll(*(uint64_t*)baseData)>(1300000000ULL+(2208988800ULL<<32)))
|
||||
DPRINTFL(MSG_VDEBUG, "invalid end nano seconds: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U);
|
||||
DPRINTFL(LOG_DEBUG, "invalid end nano seconds: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U);
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
@ -1304,7 +1304,7 @@ void PacketHashtable::aggregateField(const ExpFieldData* efd, HashtableBucket* h
|
|||
*(uint64_t*)baseData = greaterUint64Nbo(*(uint64_t*)baseData, ntp2);
|
||||
#ifdef DEBUG
|
||||
if (ntohll(*(uint64_t*)baseData)<(1000000000ULL+(2208988800ULL<<32)) || ntohll(*(uint64_t*)baseData)>(1300000000ULL+(2208988800ULL<<32)))
|
||||
DPRINTFL(MSG_VDEBUG, "invalid end nano seconds: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U);
|
||||
DPRINTFL(LOG_DEBUG, "invalid end nano seconds: %lu s", (ntohll(*(uint64_t*)baseData)>>32)-2208988800U);
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
@ -1347,7 +1347,7 @@ void PacketHashtable::aggregateField(const ExpFieldData* efd, HashtableBucket* h
|
|||
case IPFIX_ETYPEID_maxPacketGap:
|
||||
gap = (int64_t)ntohll(*(int64_t*)deltaData)-(int64_t)ntohll(*reinterpret_cast<const uint64_t*>(data+efd->privDataOffset));
|
||||
if (gap<0) gap = -gap;
|
||||
DPRINTFL(MSG_VDEBUG, "gap: %u, oldgap: %u", gap, ntohl(*(uint32_t*)baseData));
|
||||
DPRINTFL(LOG_DEBUG, "gap: %u, oldgap: %u", gap, ntohl(*(uint32_t*)baseData));
|
||||
|
||||
if ((uint32_t)gap > ntohl(*(uint32_t*)baseData)) *(uint32_t*)baseData = htonl(gap);
|
||||
*reinterpret_cast<uint64_t*>(data+efd->privDataOffset) = *(uint64_t*)deltaData;
|
||||
|
@ -1372,7 +1372,7 @@ void PacketHashtable::aggregateField(const ExpFieldData* efd, HashtableBucket* h
|
|||
case IPFIX_ETYPEID_maxPacketGap:
|
||||
gap = (int64_t)ntohll(*(int64_t*)deltaData)-(int64_t)ntohll(*reinterpret_cast<const uint64_t*>(data+efd->privDataOffset));
|
||||
if (gap<0) gap = -gap;
|
||||
DPRINTFL(MSG_VDEBUG, "gap: %u, oldgap: %u", gap, ntohl(*(uint32_t*)baseData));
|
||||
DPRINTFL(LOG_DEBUG, "gap: %u, oldgap: %u", gap, ntohl(*(uint32_t*)baseData));
|
||||
|
||||
if ((uint32_t)gap > ntohl(*(uint32_t*)baseData)) *(uint32_t*)baseData = htonl(gap);
|
||||
*reinterpret_cast<uint64_t*>(data+efd->privDataOffset) = *(uint64_t*)deltaData;
|
||||
|
@ -1431,7 +1431,7 @@ bool PacketHashtable::equalFlow(IpfixRecord::Data* bucket, const Packet* p)
|
|||
for (int i=0; i<expHelperTable.noKeyFields; i++) {
|
||||
ExpFieldData* efd = &expHelperTable.keyFields[i];
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "equal for i=%u, typeid=%s, length=%u, srcpointer=%X", i, efd->typeId.toString().c_str(), efd->srcLength, p->data.netHeader+efd->srcIndex);
|
||||
DPRINTFL(LOG_DEBUG, "equal for i=%u, typeid=%s, length=%u, srcpointer=%X", i, efd->typeId.toString().c_str(), efd->srcLength, p->data.netHeader+efd->srcIndex);
|
||||
// just compare srcLength bytes, as we still have our original packet data
|
||||
if (memcmp(bucket+efd->dstIndex, p->data.netHeader+efd->srcIndex, efd->srcLength)!=0)
|
||||
return false;
|
||||
|
@ -1450,7 +1450,7 @@ bool PacketHashtable::equalFlowRev(IpfixRecord::Data* bucket, const Packet* p)
|
|||
ExpFieldData* efdsrc = &expHelperTable.keyFields[i];
|
||||
ExpFieldData* efddst = expHelperTable.revKeyFieldMapper[i];
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "equalrev for i=%u, typeid=%s, length=%u, srcpointer=%X", i, efdsrc->typeId.toString().c_str(), efdsrc->srcLength, p->data.netHeader+efdsrc->srcIndex);
|
||||
DPRINTFL(LOG_DEBUG, "equalrev for i=%u, typeid=%s, length=%u, srcpointer=%X", i, efdsrc->typeId.toString().c_str(), efdsrc->srcLength, p->data.netHeader+efdsrc->srcIndex);
|
||||
// just compare srcLength bytes, as we still have our original packet data
|
||||
if (memcmp(bucket+efddst->dstIndex, p->data.netHeader+efdsrc->srcIndex, efdsrc->srcLength)!=0)
|
||||
return false;
|
||||
|
@ -1597,7 +1597,7 @@ void PacketHashtable::aggregatePacket(Packet* p)
|
|||
createMaskedFields(p);
|
||||
|
||||
uint32_t hash = calculateHash(p->data.netHeader);
|
||||
DPRINTFL(MSG_VDEBUG, "packet hash=%u", hash);
|
||||
DPRINTFL(LOG_DEBUG, "packet hash=%u", hash);
|
||||
|
||||
// search bucket inside hashtable
|
||||
HashtableBucket* bucket = buckets[hash];
|
||||
|
@ -1620,7 +1620,7 @@ void PacketHashtable::aggregatePacket(Packet* p)
|
|||
if (!bucket->forceExpiry) {
|
||||
flowfound = true;
|
||||
} else {
|
||||
DPRINTFL(MSG_VDEBUG, "forced expiry of bucket");
|
||||
DPRINTFL(LOG_DEBUG, "forced expiry of bucket");
|
||||
removeBucket(bucket);
|
||||
expiryforced = true;
|
||||
if (expHelperTable.dpaFlowCountOffset != ExpHelperTable::UNUSED)
|
||||
|
@ -1640,7 +1640,7 @@ void PacketHashtable::aggregatePacket(Packet* p)
|
|||
if (biflowAggregation && !flowfound && !expiryforced) {
|
||||
// search for reverse direction
|
||||
uint32_t rhash = calculateHashRev(p->data.netHeader);
|
||||
DPRINTFL(MSG_VDEBUG, "rev packet hash=%u", rhash);
|
||||
DPRINTFL(LOG_DEBUG, "rev packet hash=%u", rhash);
|
||||
HashtableBucket* bucket = buckets[rhash];
|
||||
|
||||
while (bucket!=0) {
|
||||
|
@ -1657,7 +1657,7 @@ void PacketHashtable::aggregatePacket(Packet* p)
|
|||
if (!bucket->forceExpiry) {
|
||||
flowfound = true;
|
||||
} else {
|
||||
DPRINTFL(MSG_VDEBUG, "forced expiry of bucket");
|
||||
DPRINTFL(LOG_DEBUG, "forced expiry of bucket");
|
||||
removeBucket(bucket);
|
||||
expiryforced = true;
|
||||
if (expHelperTable.dpaFlowCountOffset != ExpHelperTable::UNUSED)
|
||||
|
@ -1685,7 +1685,7 @@ void PacketHashtable::aggregatePacket(Packet* p)
|
|||
buckets[hash]->inTable = true;
|
||||
|
||||
if (oldflowcount) {
|
||||
DPRINTFL(MSG_VDEBUG, "oldflowcount: %u", ntohl(*oldflowcount));
|
||||
DPRINTFL(LOG_DEBUG, "oldflowcount: %u", ntohl(*oldflowcount));
|
||||
*reinterpret_cast<uint32_t*>(buckets[hash]->data.get()+expHelperTable.dpaFlowCountOffset) = htonl(ntohl(*oldflowcount)+1);
|
||||
}
|
||||
updateBucketData(buckets[hash]);
|
||||
|
|
|
@ -71,7 +71,7 @@ void Rule::initialize()
|
|||
if (f->type.enterprise == 0 && f->type.id == IPFIX_TYPEID_protocolIdentifier) {
|
||||
// small exception: if protocol id is inside the template, we assume that all types of protocols are valid
|
||||
validProtocols = Packet::ALL;
|
||||
msg(MSG_INFO, "IPFIX IE protocolIdentifier is contained in template %hu, accepting all protocol types for this template", id);
|
||||
msg(LOG_NOTICE, "IPFIX IE protocolIdentifier is contained in template %hu, accepting all protocol types for this template", id);
|
||||
}
|
||||
validProtocols = Packet::IPProtocolType(validProtocols | f->type.getValidProtocols());
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ uint8_t getIPv4IMask(const InformationElement::IeInfo* type, const IpfixRecord::
|
|||
if (type->length == 1) return 24;
|
||||
if (type->length == 0) return 32;
|
||||
|
||||
msg(MSG_FATAL, "Invalid IPv4 address length: %d", type->length);
|
||||
msg(LOG_CRIT, "Invalid IPv4 address length: %d", type->length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ int matchesPortPattern(const InformationElement::IeInfo* dataType, const IpfixRe
|
|||
return 1;
|
||||
}
|
||||
|
||||
msg(MSG_FATAL, "matching port of length %d with pattern of length %d not supported",
|
||||
msg(LOG_CRIT, "matching port of length %d with pattern of length %d not supported",
|
||||
dataType->length, patternType->length);
|
||||
return 0;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ int Rule::dataRecordMatches(IpfixDataRecord* record) {
|
|||
*/
|
||||
|
||||
/* no corresponding data field or fixed data field found, this flow cannot match */
|
||||
msg(MSG_VDEBUG, "No corresponding DataDataRecord field for RuleField of type %s", ruleField->type.toString().c_str());
|
||||
msg(LOG_DEBUG, "No corresponding DataDataRecord field for RuleField of type %s", ruleField->type.toString().c_str());
|
||||
return 0;
|
||||
}
|
||||
/* if a non-discarding rule field specifies no pattern, check at least if the data field exists */
|
||||
|
@ -454,7 +454,7 @@ int Rule::dataRecordMatches(IpfixDataRecord* record) {
|
|||
if (ruleField->type==InformationElement::IeInfo(IPFIX_ETYPEID_anonymisationType, IPFIX_PEN_vermont))
|
||||
continue;
|
||||
|
||||
msg(MSG_INFO, "No corresponding DataRecord field for RuleField of type %s", ruleField->type.toString().c_str());
|
||||
msg(LOG_NOTICE, "No corresponding DataRecord field for RuleField of type %s", ruleField->type.toString().c_str());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void IpfixDbReaderCommonCfg::readConfigSection(XMLElement* elem)
|
|||
observationDomainId = getInt("observationDomainId");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixDbReader config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixDbReader config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,17 +54,17 @@ void* IpfixDbReader::readFromDB(void* ipfixDbReader_)
|
|||
|
||||
/** get tables of the database*/
|
||||
if(ipfixDbReader->getTables() != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbReader: Error in function getTables");
|
||||
msg(LOG_ERR,"IpfixDbReader: Error in function getTables");
|
||||
THROWEXCEPTION("IpfixDbReader creation failed");
|
||||
}
|
||||
|
||||
msg(MSG_DIALOG, "IpfixDbReader: Start sending tables");
|
||||
msg(LOG_WARNING, "IpfixDbReader: Start sending tables");
|
||||
for(vector<string>::iterator i = ipfixDbReader->tables.begin(); i != ipfixDbReader->tables.end() && !ipfixDbReader->exitFlag; i++) {
|
||||
boost::shared_ptr<TemplateInfo> templateInfo(new TemplateInfo);
|
||||
templateInfo->setId = TemplateInfo::IpfixTemplate;
|
||||
if(ipfixDbReader->dbReaderSendNewTemplate(templateInfo, *i) != 0)
|
||||
{
|
||||
msg(MSG_ERROR, "IpfixDbReader: Template error, skip table");
|
||||
msg(LOG_ERR, "IpfixDbReader: Template error, skip table");
|
||||
continue;
|
||||
}
|
||||
ipfixDbReader->dbReaderSendTable(templateInfo, *i);
|
||||
|
@ -74,7 +74,7 @@ void* IpfixDbReader::readFromDB(void* ipfixDbReader_)
|
|||
|
||||
ipfixDbReader->unregisterCurrentThread();
|
||||
|
||||
msg(MSG_DIALOG,"IpfixDbReader: Sending from database is done");
|
||||
msg(LOG_WARNING,"IpfixDbReader: Sending from database is done");
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ int IpfixDbReader::dbReaderSendNewTemplate(boost::shared_ptr<TemplateInfo> templ
|
|||
|
||||
/**get columnsname of the table*/
|
||||
if(getColumns(tableName) != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbReader: Could not get columns for template");
|
||||
msg(LOG_ERR,"IpfixDbReader: Could not get columns for template");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ int IpfixDbReader::dbReaderSendNewTemplate(boost::shared_ptr<TemplateInfo> templ
|
|||
ipfixRecord->sourceID = srcId;
|
||||
ipfixRecord->templateInfo = templateInfo;
|
||||
send(ipfixRecord);
|
||||
msg(MSG_DEBUG,"IpfixDbReader: sent template for table %s", tableName.c_str());
|
||||
msg(LOG_INFO,"IpfixDbReader: sent template for table %s", tableName.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ void IpfixDbReader::copyUintNetByteOrder(IpfixRecord::Data* dest, char* src, Inf
|
|||
*(uint64_t*)dest = htonll(*(uint64_t*)src);
|
||||
return;
|
||||
default:
|
||||
msg(MSG_ERROR, "IpfixDbReader: Uint with length %d unparseable", type.length);
|
||||
msg(LOG_ERR, "IpfixDbReader: Uint with length %d unparseable", type.length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ int IpfixDbReader::dbReaderDestroyTemplate(boost::shared_ptr<TemplateInfo> templ
|
|||
ipfixRecord->sourceID = srcId;
|
||||
ipfixRecord->templateInfo = templateInfo;
|
||||
send(ipfixRecord);
|
||||
msg(MSG_DEBUG,"IpfixDbReader: Template destroyed");
|
||||
msg(LOG_INFO,"IpfixDbReader: Template destroyed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ IpfixDbReaderCfg::IpfixDbReaderCfg(XMLElement* elem)
|
|||
observationDomainId = getInt("observationDomainId");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixDbReader config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixDbReader config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,15 +52,15 @@ int IpfixDbReaderMySQL::dbReaderSendTable(boost::shared_ptr<TemplateInfo> templa
|
|||
|
||||
string query = "SELECT " + columnNames + " FROM " + tableName;
|
||||
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderMySQL: SQL query: %s", query.c_str());
|
||||
msg(LOG_DEBUG, "IpfixDbReaderMySQL: SQL query: %s", query.c_str());
|
||||
if(mysql_query(conn, query.c_str()) != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbReaderMySQL: Select on table failed. Error: %s",
|
||||
msg(LOG_ERR,"IpfixDbReaderMySQL: Select on table failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
return 1;
|
||||
}
|
||||
|
||||
dbResult = mysql_store_result(conn);
|
||||
msg(MSG_INFO,"IpfixDbReaderMySQL: Start sending records from table %s", tableName.c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbReaderMySQL: Start sending records from table %s", tableName.c_str());
|
||||
|
||||
while((dbRow = mysql_fetch_row(dbResult)) && !exitFlag) {
|
||||
// build new record
|
||||
|
@ -83,14 +83,14 @@ int IpfixDbReaderMySQL::dbReaderSendTable(boost::shared_ptr<TemplateInfo> templa
|
|||
ipfixRecord->message = data;
|
||||
ipfixRecord->data = data.get();
|
||||
send(ipfixRecord);
|
||||
msg(MSG_VDEBUG,"IpfixDbReaderMySQL: Record sent");
|
||||
msg(LOG_DEBUG,"IpfixDbReaderMySQL: Record sent");
|
||||
}
|
||||
mysql_free_result(dbResult);
|
||||
|
||||
if(!exitFlag)
|
||||
msg(MSG_INFO,"IpfixDbReaderMySQL: Sending from table %s done", tableName.c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbReaderMySQL: Sending from table %s done", tableName.c_str());
|
||||
else
|
||||
msg(MSG_INFO,"IpfixDbReaderMySQL: Sending from table %s aborted", tableName.c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbReaderMySQL: Sending from table %s aborted", tableName.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ int IpfixDbReaderMySQL::getTables()
|
|||
|
||||
dbResult = mysql_list_tables(conn, wild);
|
||||
if(dbResult == 0) {
|
||||
msg(MSG_FATAL,"IpfixDbReaderMySQL: There are no flow tables in database");
|
||||
msg(LOG_CRIT,"IpfixDbReaderMySQL: There are no flow tables in database");
|
||||
} else {
|
||||
while((dbRow = mysql_fetch_row(dbResult))) {
|
||||
tables.push_back(string(dbRow[0]));
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderMySQL: table %s", tables.back().c_str());
|
||||
msg(LOG_DEBUG, "IpfixDbReaderMySQL: table %s", tables.back().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,9 +129,9 @@ int IpfixDbReaderMySQL::getColumns(const string& tableName)
|
|||
MYSQL_ROW dbRow = NULL;
|
||||
|
||||
string query = "SHOW COLUMNS FROM " + tableName;
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderMySQL: SQL query: %s", query.c_str());
|
||||
msg(LOG_DEBUG, "IpfixDbReaderMySQL: SQL query: %s", query.c_str());
|
||||
if(mysql_query(conn, query.c_str()) != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbReaderMySQL: Show columns on table %s failed. Error: %s",
|
||||
msg(LOG_ERR,"IpfixDbReaderMySQL: Show columns on table %s failed. Error: %s",
|
||||
tableName.c_str(), mysql_error(conn));
|
||||
return 1;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ int IpfixDbReaderMySQL::getColumns(const string& tableName)
|
|||
dbResult = mysql_store_result(conn);
|
||||
|
||||
if(dbResult == 0) {
|
||||
msg(MSG_FATAL,"IpfixDbReaderMySQL: There are no Columns in the table");
|
||||
msg(LOG_CRIT,"IpfixDbReaderMySQL: There are no Columns in the table");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -151,11 +151,11 @@ int IpfixDbReaderMySQL::getColumns(const string& tableName)
|
|||
bool found = true;
|
||||
const struct ipfix_identifier* id = ipfix_name_lookup(dbRow[0]);
|
||||
if (id == NULL) {
|
||||
msg(MSG_INFO, "IpfixDbReaderMySQL: Unsupported column: %s", dbRow[0]);
|
||||
msg(LOG_NOTICE, "IpfixDbReaderMySQL: Unsupported column: %s", dbRow[0]);
|
||||
} else {
|
||||
columnNames = columnNames + "," + dbRow[0];
|
||||
columns.push_back(*id);
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderMySQL: column %s (ID: %d, PEN: %u)", dbRow[0], columns.back().id, columns.back().pen);
|
||||
msg(LOG_DEBUG, "IpfixDbReaderMySQL: column %s (ID: %d, PEN: %u)", dbRow[0], columns.back().id, columns.back().pen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,29 +174,29 @@ int IpfixDbReaderMySQL::connectToDb()
|
|||
/** get the mysl init handle*/
|
||||
conn = mysql_init(0);
|
||||
if(conn == 0) {
|
||||
msg(MSG_FATAL,"IpfixDbReaderMySQL: Get connect handle failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbReaderMySQL: Get connect handle failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
return 1;
|
||||
} else {
|
||||
msg(MSG_DEBUG,"IpfixDbReaderMySQL: mysql init successful");
|
||||
msg(LOG_INFO,"IpfixDbReaderMySQL: mysql init successful");
|
||||
}
|
||||
|
||||
/**Connect to Database*/
|
||||
if (!mysql_real_connect(conn, hostname.c_str(), username.c_str(),password.c_str(),
|
||||
0, port, 0, 0)) {
|
||||
msg(MSG_FATAL,"IpfixDbReaderMySQL: Connection to database failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbReaderMySQL: Connection to database failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
return 1;
|
||||
} else {
|
||||
msg(MSG_DEBUG,"IpfixDbReaderMySQL: successfully connected to database");
|
||||
msg(LOG_INFO,"IpfixDbReaderMySQL: successfully connected to database");
|
||||
}
|
||||
|
||||
/** use database with dbName **/
|
||||
if(mysql_select_db(conn, dbname.c_str()) !=0) {
|
||||
msg(MSG_FATAL,"IpfixDbReaderMySQL: Database %s not selectable", dbname.c_str());
|
||||
msg(LOG_CRIT,"IpfixDbReaderMySQL: Database %s not selectable", dbname.c_str());
|
||||
return 1;
|
||||
} else {
|
||||
msg(MSG_DEBUG,"IpfixDbReaderMySQL: Database %s selected", dbname.c_str());
|
||||
msg(LOG_INFO,"IpfixDbReaderMySQL: Database %s selected", dbname.c_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -44,7 +44,7 @@ int IpfixDbReaderOracle::dbReaderSendTable(boost::shared_ptr<TemplateInfo> templ
|
|||
unsigned offset = 0;
|
||||
unsigned j = 0;
|
||||
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderOracle: Sending table %s", tableName.c_str());
|
||||
msg(LOG_DEBUG, "IpfixDbReaderOracle: Sending table %s", tableName.c_str());
|
||||
|
||||
sql << "SELECT " << columnNames << " FROM "<< tableName;
|
||||
|
||||
|
@ -52,7 +52,7 @@ int IpfixDbReaderOracle::dbReaderSendTable(boost::shared_ptr<TemplateInfo> templ
|
|||
try {
|
||||
stmt = con->createStatement(sql.str());
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL, "IpfixDbReaderOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT, "IpfixDbReaderOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -60,16 +60,16 @@ int IpfixDbReaderOracle::dbReaderSendTable(boost::shared_ptr<TemplateInfo> templ
|
|||
stmt->setPrefetchRowCount(1);
|
||||
rs = stmt->executeQuery();
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL,"IpfixDbReaderOracle: Error executing statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbReaderOracle: Error executing statement: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
|
||||
if (!rs) {
|
||||
msg(MSG_ERROR, "IpfixDbReaderOracle: Table %s was empty!", tableName.c_str());
|
||||
msg(LOG_ERR, "IpfixDbReaderOracle: Table %s was empty!", tableName.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
msg(MSG_INFO,"IpfixDbReaderOracle: Start sending records from table %s", tableName.c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbReaderOracle: Start sending records from table %s", tableName.c_str());
|
||||
|
||||
try {
|
||||
while((rs->next()) && !exitFlag) {
|
||||
|
@ -99,14 +99,14 @@ int IpfixDbReaderOracle::dbReaderSendTable(boost::shared_ptr<TemplateInfo> templ
|
|||
con->terminateStatement(stmt);
|
||||
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_ERROR, "Caught SQL exception while getting flows from table: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR, "Caught SQL exception while getting flows from table: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!exitFlag)
|
||||
msg(MSG_INFO,"IpfixDbReaderOracle: Sending from table %s done", tableName.c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbReaderOracle: Sending from table %s done", tableName.c_str());
|
||||
else
|
||||
msg(MSG_INFO,"IpfixDbReaderOracle: Sending from table %s aborted", tableName.c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbReaderOracle: Sending from table %s aborted", tableName.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -126,35 +126,35 @@ int IpfixDbReaderOracle::getTables()
|
|||
try {
|
||||
stmt = con->createStatement(sql.str());
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL, "IpfixDbReaderOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT, "IpfixDbReaderOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
//msg(MSG_VDEBUG, "IpfixDbReaderOracle: SQL query: %s", query.c_str());
|
||||
//msg(LOG_DEBUG, "IpfixDbReaderOracle: SQL query: %s", query.c_str());
|
||||
try {
|
||||
stmt->setPrefetchRowCount(1);
|
||||
rs = stmt->executeQuery();
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error executing statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error executing statement: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
|
||||
if (!rs) {
|
||||
msg(MSG_ERROR, "IpfixDbWriterOracle: Found no flow tables!");
|
||||
msg(LOG_ERR, "IpfixDbWriterOracle: Found no flow tables!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
while((rs->next()) && !exitFlag) {
|
||||
tables.push_back(rs->getString(1));
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderOracle: table %s", tables.back().c_str());
|
||||
msg(LOG_DEBUG, "IpfixDbReaderOracle: table %s", tables.back().c_str());
|
||||
}
|
||||
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_ERROR, "Caught SQL exception: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR, "Caught SQL exception: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -175,21 +175,21 @@ int IpfixDbReaderOracle::getColumns(const string& tableName)
|
|||
try {
|
||||
stmt = con->createStatement(query);
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL, "IpfixDbReaderOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT, "IpfixDbReaderOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
//msg(MSG_VDEBUG, "IpfixDbReaderOracle: SQL query: %s", query.c_str());
|
||||
//msg(LOG_DEBUG, "IpfixDbReaderOracle: SQL query: %s", query.c_str());
|
||||
try {
|
||||
stmt->setPrefetchRowCount(1);
|
||||
rs = stmt->executeQuery();
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error executing statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error executing statement: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
|
||||
if (!rs) {
|
||||
msg(MSG_ERROR, "IpfixDbWriterOracle: Flow tables do not have columns??");
|
||||
msg(LOG_ERR, "IpfixDbWriterOracle: Flow tables do not have columns??");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -201,14 +201,14 @@ int IpfixDbReaderOracle::getColumns(const string& tableName)
|
|||
bool found = true;
|
||||
const struct ipfix_identifier* id = ipfix_name_lookup(rs->getString(1).c_str());
|
||||
if (id == NULL) {
|
||||
msg(MSG_INFO, "IpfixDbReaderMySQL: Unsupported column: %s", rs->getString(1).c_str());
|
||||
msg(LOG_NOTICE, "IpfixDbReaderMySQL: Unsupported column: %s", rs->getString(1).c_str());
|
||||
} else {
|
||||
columnNames = columnNames + "," + rs->getString(1).c_str();
|
||||
columns.push_back(*id);
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderMySQL: column %s (%d)", rs->getString(1).c_str(), columns.back().id);
|
||||
msg(LOG_DEBUG, "IpfixDbReaderMySQL: column %s (%d)", rs->getString(1).c_str(), columns.back().id);
|
||||
}
|
||||
if(found)
|
||||
msg(MSG_VDEBUG, "IpfixDbReaderOracle: column %s (%d)", rs->getString(1).c_str(), columns.back().id);
|
||||
msg(LOG_DEBUG, "IpfixDbReaderOracle: column %s (%d)", rs->getString(1).c_str(), columns.back().id);
|
||||
}
|
||||
|
||||
if(columnNames != "")
|
||||
|
@ -217,7 +217,7 @@ int IpfixDbReaderOracle::getColumns(const string& tableName)
|
|||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_ERROR, "Caught SQL exception: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR, "Caught SQL exception: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -235,15 +235,15 @@ int IpfixDbReaderOracle::connectToDb()
|
|||
env->terminateConnection(con);
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixDbReaderOracle: Creating environment.");
|
||||
msg(LOG_INFO, "IpfixDbReaderOracle: Creating environment.");
|
||||
try {
|
||||
env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL, "IpfixDbReaderOracle: Error while creating environment: %s.", ex.getMessage().c_str());
|
||||
msg(MSG_FATAL, "IpfixDbReaderOracle: Did you configure your Oracle environment?");
|
||||
msg(LOG_CRIT, "IpfixDbReaderOracle: Error while creating environment: %s.", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT, "IpfixDbReaderOracle: Did you configure your Oracle environment?");
|
||||
return -1;
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixDbReaderOracle: Trying to connect to database ...");
|
||||
msg(LOG_INFO, "IpfixDbReaderOracle: Trying to connect to database ...");
|
||||
try
|
||||
{
|
||||
char dbLogon[256];
|
||||
|
@ -251,10 +251,10 @@ int IpfixDbReaderOracle::connectToDb()
|
|||
con = env->createConnection(username, password, dbLogon);
|
||||
} catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbReaderOracle: Oracle connect failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbReaderOracle: Oracle connect failed. Error: %s", ex.getMessage().c_str());
|
||||
return 1;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbReaderOracle: Successfully connected to Oracle DB");
|
||||
msg(LOG_INFO,"IpfixDbReaderOracle: Successfully connected to Oracle DB");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ IpfixDbWriterCfg::IpfixDbWriterCfg(XMLElement* elem)
|
|||
tablePrefix = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixDbWriter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixDbWriter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ void IpfixDbWriterCfg::readColumns(XMLElement* elem) {
|
|||
if (e->matches("name")) {
|
||||
colNames.push_back(e->getFirstText());
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixDbWriter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixDbWriter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,10 +81,10 @@ int IpfixDbWriterMongo::connectToDB()
|
|||
string err;
|
||||
mongo::HostAndPort dbLogon;
|
||||
dbLogon = mongo::HostAndPort(dbHost, dbPort);
|
||||
msg(MSG_INFO,"IpfixDbWriterMongo: Connection details: %s", dbLogon.toString().c_str());
|
||||
msg(LOG_NOTICE,"IpfixDbWriterMongo: Connection details: %s", dbLogon.toString().c_str());
|
||||
if(!con.connect(dbLogon, err))
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterMongo: Mongo connect failed. Error: %s", err.c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterMongo: Mongo connect failed. Error: %s", err.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ int IpfixDbWriterMongo::connectToDB()
|
|||
// we need to authenticate
|
||||
if(!con.auth(dbName, dbUser, dbPassword, err))
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterMongo: Mongo authentication failed. Error: %s", err.c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterMongo: Mongo authentication failed. Error: %s", err.c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ int IpfixDbWriterMongo::connectToDB()
|
|||
con.insert(dbCollectionCounters, obj);
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG,"IpfixDbWriterMongo: Mongo connection successful");
|
||||
msg(LOG_INFO,"IpfixDbWriterMongo: Mongo connection successful");
|
||||
dbError = false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -120,10 +120,10 @@ void IpfixDbWriterMongo::processDataDataRecord(const IpfixRecord::SourceID& sour
|
|||
IpfixRecord::Data* data)
|
||||
{
|
||||
mongo::BSONObj obj;
|
||||
msg(MSG_DEBUG, "IpfixDbWriter: Processing data record");
|
||||
msg(LOG_INFO, "IpfixDbWriter: Processing data record");
|
||||
|
||||
if (dbError) {
|
||||
msg(MSG_DEBUG, "IpfixDbWriter: reconnecting to DB");
|
||||
msg(LOG_INFO, "IpfixDbWriter: reconnecting to DB");
|
||||
connectToDB();
|
||||
if (dbError) return;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ void IpfixDbWriterMongo::processDataDataRecord(const IpfixRecord::SourceID& sour
|
|||
|
||||
// write to db if maxInserts is reached
|
||||
if(numberOfInserts == maxInserts) {
|
||||
msg(MSG_DEBUG, "IpfixDbWriter: Writing buffered records to database");
|
||||
msg(LOG_INFO, "IpfixDbWriter: Writing buffered records to database");
|
||||
writeToDb();
|
||||
numberOfInserts = 0;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ mongo::BSONObj IpfixDbWriterMongo::getInsertObj(const IpfixRecord::SourceID& sou
|
|||
break;
|
||||
}
|
||||
}
|
||||
msg(MSG_DEBUG, "saw ipfix id %s (element ID %d) in packet with intdata %llX", prop->propertyName,
|
||||
msg(LOG_INFO, "saw ipfix id %s (element ID %d) in packet with intdata %llX", prop->propertyName,
|
||||
prop->ipfixId, static_cast<int64_t>(intdata));
|
||||
if (beautyProp)
|
||||
obj << prop->propertyName << static_cast<long long int>(intdata);
|
||||
|
@ -337,7 +337,7 @@ mongo::BSONObj IpfixDbWriterMongo::getInsertObj(const IpfixRecord::SourceID& sou
|
|||
obj << boost::lexical_cast<std::string>(prop->ipfixId).c_str() << static_cast<long long int>(intdata);
|
||||
|
||||
if (flowstartsec == 0) {
|
||||
msg(MSG_ERROR, "IpfixDbWriterMongo: Failed to get timing data from record. Will be saved in default table.");
|
||||
msg(LOG_ERR, "IpfixDbWriterMongo: Failed to get timing data from record. Will be saved in default table.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -372,7 +372,7 @@ int IpfixDbWriterMongo::writeToDb()
|
|||
{
|
||||
con.insert(dbCollectionFlows, bufferedObjects);
|
||||
if(con.getLastError() != ""){
|
||||
msg(MSG_FATAL, "IpfixDbWriterMongo: Failed to write to DB.");
|
||||
msg(LOG_CRIT, "IpfixDbWriterMongo: Failed to write to DB.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -409,7 +409,7 @@ int IpfixDbWriterMongo::getExporterID(const IpfixRecord::SourceID& sourceID)
|
|||
mongo::BSONObj exporterCounter;
|
||||
mongo::BSONObj cmd;
|
||||
cmd = BSON( "findAndModify" << "counters" << "query" << BSON("_id" << "exporterCounter") << "update" << BSON("$inc" << BSON("c" << 1)));
|
||||
msg(MSG_DEBUG, "FIND AND MODIFY: %s", cmd.toString().c_str());
|
||||
msg(LOG_INFO, "FIND AND MODIFY: %s", cmd.toString().c_str());
|
||||
con.runCommand(dbName, cmd, exporterCounter);
|
||||
mongo::BSONObjBuilder b;
|
||||
id = exporterCounter.getObjectField("value").getIntField("c");
|
||||
|
@ -486,7 +486,7 @@ void IpfixDbWriterMongo::onDataRecord(IpfixDataRecord* record)
|
|||
return;
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixDbWriterMongo: Data record received will be passed for processing");
|
||||
msg(LOG_INFO, "IpfixDbWriterMongo: Data record received will be passed for processing");
|
||||
processDataDataRecord(*record->sourceID.get(), *record->templateInfo.get(),
|
||||
record->dataLength, record->data);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ IpfixDbWriterMongoCfg::IpfixDbWriterMongoCfg(XMLElement* elem)
|
|||
beautifyProperties = true;
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixDbWriterMongo config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixDbWriterMongo config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void IpfixDbWriterMongoCfg::readProperties(XMLElement* elem) {
|
|||
properties.clear();
|
||||
allProperties = true;
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixDbWriterMongo config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixDbWriterMongo config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ IpfixDbWriterMongoCfg::~IpfixDbWriterMongoCfg()
|
|||
IpfixDbWriterMongo* IpfixDbWriterMongoCfg::createInstance()
|
||||
{
|
||||
instance = new IpfixDbWriterMongo(hostname, database, user, password, port, observationDomainId, bufferObjects, properties, beautifyProperties, allProperties);
|
||||
msg(MSG_DEBUG, "IpfixDbWriterMongo configuration host %s collection %s user %s password %s port %i observationDomainId %i bufferRecords %i\n",
|
||||
msg(LOG_INFO, "IpfixDbWriterMongo configuration host %s collection %s user %s password %s port %i observationDomainId %i bufferRecords %i\n",
|
||||
hostname.c_str(), database.c_str(), user.c_str(), password.c_str(), port, observationDomainId, bufferObjects);
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -49,20 +49,20 @@ void IpfixDbWriterMySQL::connectToDB()
|
|||
/** get the mysl init handle*/
|
||||
conn = mysql_init(0);
|
||||
if(conn == 0) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterMySQL: Get MySQL connect handle failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbWriterMySQL: Get MySQL connect handle failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
return;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterMySQL: mysql init successful");
|
||||
msg(LOG_INFO,"IpfixDbWriterMySQL: mysql init successful");
|
||||
|
||||
/**Connect to Database*/
|
||||
if (!mysql_real_connect(conn, hostName, userName, password,
|
||||
0, portNum, 0, 0)) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterMySQL: Connection to database failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbWriterMySQL: Connection to database failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
return;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterMySQL: succesfully connected to database");
|
||||
msg(LOG_INFO,"IpfixDbWriterMySQL: succesfully connected to database");
|
||||
|
||||
/** make query string to create database**/
|
||||
statement << "CREATE DATABASE IF NOT EXISTS " << dbName;
|
||||
|
@ -70,19 +70,19 @@ void IpfixDbWriterMySQL::connectToDB()
|
|||
|
||||
/**create database*/
|
||||
if(mysql_query(conn, statement.str().c_str()) != 0 ) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterMySQL: Creation of database %s failed. Error: %s",
|
||||
msg(LOG_CRIT, "IpfixDbWriterMySQL: Creation of database %s failed. Error: %s",
|
||||
dbName, mysql_error(conn));
|
||||
return;
|
||||
}
|
||||
msg(MSG_INFO,"IpfixDbWriterMySQL: Database %s created", dbName);
|
||||
msg(LOG_NOTICE,"IpfixDbWriterMySQL: Database %s created", dbName);
|
||||
|
||||
/** use database with dbName**/
|
||||
if(mysql_select_db(conn, dbName) !=0) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterMySQL: Database %s not selectable. Error: %s",
|
||||
msg(LOG_CRIT, "IpfixDbWriterMySQL: Database %s not selectable. Error: %s",
|
||||
dbName, mysql_error(conn));
|
||||
return ;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterMySQL: Database %s selected", dbName);
|
||||
msg(LOG_INFO,"IpfixDbWriterMySQL: Database %s selected", dbName);
|
||||
if (createExporterTable() != 0) return;
|
||||
|
||||
dbError = false;
|
||||
|
@ -102,11 +102,11 @@ int IpfixDbWriterMySQL::createExporterTable()
|
|||
statement << "CREATE TABLE IF NOT EXISTS exporter (id SMALLINT(5) NOT NULL AUTO_INCREMENT, sourceID INTEGER(10) UNSIGNED DEFAULT NULL, srcIP INTEGER(10) UNSIGNED DEFAULT NULL, PRIMARY KEY(id))";
|
||||
DPRINTF("SQL Query: %s", statement.str().c_str());
|
||||
if(mysql_query(conn, statement.str().c_str()) != 0) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterMySQL: Creation of exporter table failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbWriterMySQL: Creation of exporter table failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
return 1;
|
||||
}
|
||||
msg(MSG_INFO,"IpfixDbWriterMySQL: Exporter table created");
|
||||
msg(LOG_NOTICE,"IpfixDbWriterMySQL: Exporter table created");
|
||||
|
||||
dbError = false;
|
||||
|
||||
|
@ -139,16 +139,16 @@ bool IpfixDbWriterMySQL::createDBTable(const char* partitionname, uint64_t start
|
|||
}
|
||||
ctsql << ")";
|
||||
|
||||
msg(MSG_INFO, "SQL Query: %s", ctsql.str().c_str());
|
||||
msg(LOG_NOTICE, "SQL Query: %s", ctsql.str().c_str());
|
||||
|
||||
if(mysql_query(conn, ctsql.str().c_str()) != 0) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterMySQL: Creation of flow table failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbWriterMySQL: Creation of flow table failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Partition %s created ", partitionname);
|
||||
msg(LOG_NOTICE, "Partition %s created ", partitionname);
|
||||
usedPartitions.push_back(partitionname);
|
||||
if (usedPartitions.size()>MAX_USEDTABLES) usedPartitions.pop_front();
|
||||
|
||||
|
@ -171,7 +171,7 @@ bool IpfixDbWriterMySQL::writeToDb()
|
|||
DPRINTF("SQL Query: %s", insertBuffer.sql);
|
||||
|
||||
if(mysql_query(conn, insertBuffer.sql) != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbWriterMySQL: Insert of records failed. Error: %s", mysql_error(conn));
|
||||
msg(LOG_ERR,"IpfixDbWriterMySQL: Insert of records failed. Error: %s", mysql_error(conn));
|
||||
goto dbwriteerror;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ bool IpfixDbWriterMySQL::writeToDb()
|
|||
insertBuffer.appendPtr = insertBuffer.bodyPtr;
|
||||
*insertBuffer.appendPtr = 0;
|
||||
|
||||
msg(MSG_DEBUG,"IpfixDbWriterMySQL: Write to database is complete");
|
||||
msg(LOG_INFO,"IpfixDbWriterMySQL: Write to database is complete");
|
||||
return true;
|
||||
|
||||
dbwriteerror:
|
||||
|
@ -222,7 +222,7 @@ int IpfixDbWriterMySQL::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
sprintf(statementStr, "SELECT id FROM exporter WHERE sourceID=%u AND srcIp='%s'", sourceID->observationDomainId, IPToString(expIp).c_str());
|
||||
|
||||
if(mysql_query(conn, statementStr) != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbWriterMySQL: Select on exporter table failed. Error: %s",
|
||||
msg(LOG_ERR,"IpfixDbWriterMySQL: Select on exporter table failed. Error: %s",
|
||||
mysql_error(conn));
|
||||
dbError = true;
|
||||
return 0;// If a failure occurs, return 0
|
||||
|
@ -243,19 +243,19 @@ int IpfixDbWriterMySQL::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
sourceID->observationDomainId, IPToString(expIp).c_str());
|
||||
|
||||
if(mysql_query(conn, statementStr) != 0) {
|
||||
msg(MSG_ERROR,"IpfixDbWriterMySQL: Insert in exporter table failed. Error: %s", mysql_error(conn));
|
||||
msg(LOG_ERR,"IpfixDbWriterMySQL: Insert in exporter table failed. Error: %s", mysql_error(conn));
|
||||
dbError = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
exporterID = mysql_insert_id(conn);
|
||||
msg(MSG_INFO,"IpfixDbWriterMySQL: new exporter (ODID=%d, id=%d) inserted in exporter table", sourceID->observationDomainId, exporterID);
|
||||
msg(LOG_NOTICE,"IpfixDbWriterMySQL: new exporter (ODID=%d, id=%d) inserted in exporter table", sourceID->observationDomainId, exporterID);
|
||||
}
|
||||
|
||||
if (curExporterEntries==MAX_EXP_TABLE-1) {
|
||||
// maybe here we should check how often this happens and display a severe warning if too
|
||||
// many parallel streams are received at once
|
||||
msg(MSG_INFO, "IpfixDbWriterPg: turnover for exporter cache occurred.");
|
||||
msg(LOG_NOTICE, "IpfixDbWriterPg: turnover for exporter cache occurred.");
|
||||
curExporterEntries = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,15 +38,15 @@ void IpfixDbWriterOracle::connectToDB()
|
|||
if (con) env->terminateConnection(con);
|
||||
|
||||
/** get the initial environment and connect */
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: Creating environment.");
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: Creating environment.");
|
||||
try {
|
||||
env = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterOracle: Error while creating environment: %s.", ex.getMessage().c_str());
|
||||
msg(MSG_FATAL, "IpfixDbWriterOracle: Did you configure your Oracle environment?");
|
||||
msg(LOG_CRIT, "IpfixDbWriterOracle: Error while creating environment: %s.", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT, "IpfixDbWriterOracle: Did you configure your Oracle environment?");
|
||||
return ;
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: Trying to connect to database ...");
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: Trying to connect to database ...");
|
||||
try
|
||||
{
|
||||
char dbLogon[256];
|
||||
|
@ -54,10 +54,10 @@ void IpfixDbWriterOracle::connectToDB()
|
|||
con = env->createConnection(userName, password, dbLogon);
|
||||
} catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Oracle connect failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Oracle connect failed. Error: %s", ex.getMessage().c_str());
|
||||
return ;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: Oracle connection successful");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: Oracle connection successful");
|
||||
|
||||
if (createExporterTable()!=0) return ;
|
||||
|
||||
|
@ -90,7 +90,7 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error executing create exporter table: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error executing create exporter table: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
dbError = true;
|
||||
return 1;
|
||||
|
@ -114,7 +114,7 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
{
|
||||
if (rs->getInt(1)!= 0)
|
||||
{
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: exporter table does exist");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: exporter table does exist");
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
return 0;
|
||||
|
@ -134,7 +134,7 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating exporter table statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating exporter table statement: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
@ -147,12 +147,12 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating exporter table: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating exporter table: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: exporter table created");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: exporter table created");
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating sequence counter statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating sequence counter statement: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
@ -180,12 +180,12 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating squence counter table: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating squence counter table: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: exporter table counter created");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: exporter table counter created");
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
|
@ -193,14 +193,14 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
// create trigger
|
||||
sql.str("");
|
||||
sql << "CREATE OR REPLACE TRIGGER trigger_for_id_exporter BEFORE INSERT ON exporter REFERENCING NEW AS new FOR EACH ROW Begin SELECT counter_for_exporter.NEXTVAL INTO :new.id FROM DUAL; End;";
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
try
|
||||
{
|
||||
stmt = con->createStatement(sql.str());
|
||||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
@ -213,16 +213,16 @@ int IpfixDbWriterOracle::createExporterTable()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error executing trigger creation \"%s\": %s", sql.str().c_str(), ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error executing trigger creation \"%s\": %s", sql.str().c_str(), ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
con->terminateStatement(stmt);
|
||||
return 1;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: exporter table insert trigger created");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: exporter table insert trigger created");
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
msg(MSG_DEBUG, "Exporter table creation done");
|
||||
msg(LOG_INFO, "Exporter table creation done");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ bool IpfixDbWriterOracle::writeToDb()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error creating statement: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 0;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ bool IpfixDbWriterOracle::writeToDb()
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Error executing flow db insert \"%s\": %s", insertBuffer.sql, ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Error executing flow db insert \"%s\": %s", insertBuffer.sql, ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
con->terminateStatement(stmt);
|
||||
return 0;
|
||||
|
@ -288,7 +288,7 @@ bool IpfixDbWriterOracle::writeToDb()
|
|||
con->commit();
|
||||
} catch (oracle::occi::SQLException& ex) {
|
||||
dbError = true;
|
||||
msg(MSG_FATAL, "IpfixDbWriterOracle: Received exception during commit: \"%s\"", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT, "IpfixDbWriterOracle: Received exception during commit: \"%s\"", ex.getMessage().c_str());
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -310,14 +310,14 @@ bool IpfixDbWriterOracle::createDBTable(const char* partitionname, uint64_t star
|
|||
oracle::occi::Statement *stmt = NULL;
|
||||
oracle::occi::ResultSet *rs = NULL;
|
||||
sql << "SELECT COUNT(table_name) FROM user_tables WHERE table_name='" << partitionname<< "'";
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
try
|
||||
{
|
||||
stmt = con->createStatement(sql.str());
|
||||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ bool IpfixDbWriterOracle::createDBTable(const char* partitionname, uint64_t star
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
dbError = true;
|
||||
return 1;
|
||||
|
@ -341,7 +341,7 @@ bool IpfixDbWriterOracle::createDBTable(const char* partitionname, uint64_t star
|
|||
{
|
||||
if (rs->getInt(1)!= 0)
|
||||
{
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: table does exist");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: table does exist");
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
return 0;
|
||||
|
@ -355,14 +355,14 @@ bool IpfixDbWriterOracle::createDBTable(const char* partitionname, uint64_t star
|
|||
// create table
|
||||
sql.str("");
|
||||
sql << "CREATE TABLE " << partitionname<< " ( " << tableColumnsCreateString << ")";
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
try
|
||||
{
|
||||
stmt = con->createStatement(sql.str());
|
||||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Failed to prepare CREATE flow table statement \"%s: %s", sql.str().c_str(), ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Failed to prepare CREATE flow table statement \"%s: %s", sql.str().c_str(), ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
|
@ -375,16 +375,16 @@ bool IpfixDbWriterOracle::createDBTable(const char* partitionname, uint64_t star
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Failed to execute CREATE flow statement \"%s\": %s", sql.str().c_str(), ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Failed to execute CREATE flow statement \"%s\": %s", sql.str().c_str(), ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
dbError = true;
|
||||
return 1;
|
||||
}
|
||||
msg(MSG_DEBUG,"IpfixDbWriterOracle: exporter table created");
|
||||
msg(LOG_INFO,"IpfixDbWriterOracle: exporter table created");
|
||||
stmt->closeResultSet(rs);
|
||||
con->terminateStatement(stmt);
|
||||
}
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: Table %s created ", partitionname);
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: Table %s created ", partitionname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -423,14 +423,14 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
|
||||
// search exporter table
|
||||
sql << "SELECT id FROM exporter WHERE sourceID=" << sourceID->observationDomainId << " AND srcIp=" << expIp;
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
try
|
||||
{
|
||||
stmt = con->createStatement(sql.str());
|
||||
}
|
||||
catch (oracle::occi::SQLException &ex)
|
||||
{
|
||||
msg(MSG_ERROR,"IpfixDbWriterOracle: Select on exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR,"IpfixDbWriterOracle: Select on exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
return 0;// If a failure occurs, return 0
|
||||
}
|
||||
if(stmt)
|
||||
|
@ -444,7 +444,7 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
while(rs->next())
|
||||
{
|
||||
exporterID = rs->getInt(1);
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: ExporterID %d is in exporter table", exporterID);
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: ExporterID %d is in exporter table", exporterID);
|
||||
}
|
||||
stmt->closeResultSet(rs);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
}
|
||||
catch (oracle::occi::SQLException &ex)
|
||||
{
|
||||
msg(MSG_ERROR,"IpfixDbWriterOracle: Select on exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR,"IpfixDbWriterOracle: Select on exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
con->terminateStatement(stmt);
|
||||
dbError = true;
|
||||
return 0;// If a failure occurs, return 0
|
||||
|
@ -463,14 +463,14 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
{
|
||||
sql.str("");
|
||||
sql << "INSERT INTO exporter (sourceID,srcIP) VALUES ('" << sourceID->observationDomainId << "','" << expIp << "')";
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
try
|
||||
{
|
||||
stmt = con->createStatement(sql.str());
|
||||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_ERROR,"IpfixDbWriterOracle: Insert in exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR,"IpfixDbWriterOracle: Insert in exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 0;
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
}
|
||||
catch (oracle::occi::SQLException& ex)
|
||||
{
|
||||
msg(MSG_FATAL,"IpfixDbWriterOracle: Insert in exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_CRIT,"IpfixDbWriterOracle: Insert in exporter table failed. Error: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
con->terminateStatement(stmt);
|
||||
return 0;
|
||||
|
@ -494,14 +494,14 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
|
||||
sql.str("");
|
||||
sql << "SELECT counter_for_exporter.CURRVAL FROM DUAL";
|
||||
msg(MSG_DEBUG, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
msg(LOG_INFO, "IpfixDbWriterOracle: SQL Query: %s", sql.str().c_str());
|
||||
try
|
||||
{
|
||||
stmt = con->createStatement(sql.str());
|
||||
}
|
||||
catch (oracle::occi::SQLException &ex)
|
||||
{
|
||||
msg(MSG_ERROR,"IpfixDbWriterOracle: Select on counter_for_exporter sequence failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR,"IpfixDbWriterOracle: Select on counter_for_exporter sequence failed. Error: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
return 0;// If a failure occurs, return 0
|
||||
}
|
||||
|
@ -524,12 +524,12 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
}
|
||||
catch (oracle::occi::SQLException &ex)
|
||||
{
|
||||
msg(MSG_ERROR,"IpfixDbWriterOracle: Select on counter_for_exporter sequence failed. Error: %s", ex.getMessage().c_str());
|
||||
msg(LOG_ERR,"IpfixDbWriterOracle: Select on counter_for_exporter sequence failed. Error: %s", ex.getMessage().c_str());
|
||||
dbError = true;
|
||||
con->terminateStatement(stmt);
|
||||
return 0;// If a failure occurs, return 0
|
||||
}
|
||||
msg(MSG_INFO,"IpfixDbWriterOracle: new exporter (ODID=%d, id=%d) inserted in exporter table", sourceID->observationDomainId, exporterID);
|
||||
msg(LOG_NOTICE,"IpfixDbWriterOracle: new exporter (ODID=%d, id=%d) inserted in exporter table", sourceID->observationDomainId, exporterID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ int IpfixDbWriterOracle::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
if (curExporterEntries==MAX_EXP_TABLE-1) {
|
||||
// maybe here we should check how often this happens and display a severe warning if too
|
||||
// many parallel streams are received at once
|
||||
msg(MSG_INFO, "IpfixDbWriterPg: turnover for exporter cache occurred.");
|
||||
msg(LOG_NOTICE, "IpfixDbWriterPg: turnover for exporter cache occurred.");
|
||||
curExporterEntries = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void IpfixDbWriterPg::connectToDB()
|
|||
DPRINTF("using connection string '%s'", conninfo.str().c_str());
|
||||
conn = PQconnectdb(conninfo.str().c_str());
|
||||
if (PQstatus(conn) != CONNECTION_OK) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterPg: Connection to database failed, error: %s", PQerrorMessage(conn));
|
||||
msg(LOG_CRIT, "IpfixDbWriterPg: Connection to database failed, error: %s", PQerrorMessage(conn));
|
||||
return;
|
||||
}
|
||||
/**create table exporter*/
|
||||
|
@ -87,7 +87,7 @@ int IpfixDbWriterPg::createExporterTable()
|
|||
PGresult* res = PQexec(conn, oss.str().c_str());
|
||||
DPRINTF("PQntuples: %d", PQntuples(res));
|
||||
if((PQresultStatus(res) != PGRES_TUPLES_OK) || (PQntuples(res)==0)) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterPg: Failed to check if table 'exporter' exists. Error: %s",
|
||||
msg(LOG_CRIT, "IpfixDbWriterPg: Failed to check if table 'exporter' exists. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
dbError = true;
|
||||
|
@ -99,14 +99,14 @@ int IpfixDbWriterPg::createExporterTable()
|
|||
"srcIP inet)";
|
||||
res = PQexec(conn, ctexporter.c_str());
|
||||
if(PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterPg: Creation of table Exporter failed. Error: %s",
|
||||
msg(LOG_CRIT, "IpfixDbWriterPg: Creation of table Exporter failed. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
dbError = true;
|
||||
return 1;
|
||||
} else {
|
||||
PQclear(res);
|
||||
msg(MSG_DEBUG, "Exporter table created");
|
||||
msg(LOG_INFO, "Exporter table created");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,14 +144,14 @@ bool IpfixDbWriterPg::createDBTable(const char* partitionname, uint64_t starttim
|
|||
/** create table*/
|
||||
PGresult* res = PQexec(conn, ctsql.str().c_str());
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterPg: Creation of table failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbWriterPg: Creation of table failed. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
dbError = true;
|
||||
PQclear(res);
|
||||
return false;
|
||||
} else {
|
||||
PQclear(res);
|
||||
msg(MSG_INFO, "Table %s created ", tablePrefix.c_str());
|
||||
msg(LOG_NOTICE, "Table %s created ", tablePrefix.c_str());
|
||||
}
|
||||
}
|
||||
if (!checkRelationExists(partitionname)) {
|
||||
|
@ -163,14 +163,14 @@ bool IpfixDbWriterPg::createDBTable(const char* partitionname, uint64_t starttim
|
|||
|
||||
PGresult* res = PQexec(conn, cpsql.str().c_str());
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
msg(MSG_FATAL,"IpfixDbWriterPg: Creation of partition failed. Error: %s",
|
||||
msg(LOG_CRIT,"IpfixDbWriterPg: Creation of partition failed. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
dbError = true;
|
||||
PQclear(res);
|
||||
return false;
|
||||
} else {
|
||||
PQclear(res);
|
||||
msg(MSG_INFO, "Partition %s created ", partitionname);
|
||||
msg(LOG_NOTICE, "Partition %s created ", partitionname);
|
||||
usedPartitions.push_back(partitionname);
|
||||
if (usedPartitions.size()>MAX_USEDTABLES) usedPartitions.pop_front();
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ bool IpfixDbWriterPg::writeToDb()
|
|||
// Write rows to database
|
||||
PGresult* res = PQexec(conn, insertBuffer.sql);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
msg(MSG_ERROR,"IpfixDbWriterPg: Insert of records failed. Error: %s",
|
||||
msg(LOG_ERR,"IpfixDbWriterPg: Insert of records failed. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
goto dbwriteerror;
|
||||
|
@ -202,7 +202,7 @@ bool IpfixDbWriterPg::writeToDb()
|
|||
insertBuffer.appendPtr = insertBuffer.bodyPtr;
|
||||
*insertBuffer.appendPtr = 0;
|
||||
|
||||
msg(MSG_DEBUG,"Write to database is complete");
|
||||
msg(LOG_INFO,"Write to database is complete");
|
||||
return true;
|
||||
|
||||
dbwriteerror:
|
||||
|
@ -244,7 +244,7 @@ int IpfixDbWriterPg::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
|
||||
PGresult* res = PQexec(conn, statementStr);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
msg(MSG_ERROR,"IpfixDbWriterPg: Select on exporter table failed. Error: %s",
|
||||
msg(LOG_ERR,"IpfixDbWriterPg: Select on exporter table failed. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
dbError = true;
|
||||
return 0;// If a failure occurs, return exporterID = 0
|
||||
|
@ -266,21 +266,21 @@ int IpfixDbWriterPg::getExporterID(IpfixRecord::SourceID* sourceID)
|
|||
|
||||
res = PQexec(conn, statementStr);
|
||||
if(PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
msg(MSG_ERROR,"IpfixDbWriterPg: Insert in exporter table failed. Error: %s",
|
||||
msg(LOG_ERR,"IpfixDbWriterPg: Insert in exporter table failed. Error: %s",
|
||||
PQerrorMessage(conn));
|
||||
dbError = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
exporterID = atoi(PQgetvalue(res, 0, 0));
|
||||
msg(MSG_INFO,"ExporterID %d inserted in exporter table", exporterID);
|
||||
msg(LOG_NOTICE,"ExporterID %d inserted in exporter table", exporterID);
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
if (curExporterEntries==MAX_EXP_TABLE-1) {
|
||||
// maybe here we should check how often this happens and display a severe warning if too
|
||||
// many parallel streams are received at once
|
||||
msg(MSG_INFO, "IpfixDbWriterPg: turnover for exporter cache occurred.");
|
||||
msg(LOG_NOTICE, "IpfixDbWriterPg: turnover for exporter cache occurred.");
|
||||
curExporterEntries = 0;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ bool IpfixDbWriterPg::checkRelationExists(const char* relname)
|
|||
oss << "SELECT COUNT(*) FROM pg_class where relname='" << relname << "'";
|
||||
PGresult* res = PQexec(conn, oss.str().c_str());
|
||||
if((PQresultStatus(res) != PGRES_TUPLES_OK) || (PQntuples(res)==0)) {
|
||||
msg(MSG_FATAL, "IpfixDbWriterPg: Failed to check if relation '%s' exists. Error: %s",
|
||||
msg(LOG_CRIT, "IpfixDbWriterPg: Failed to check if relation '%s' exists. Error: %s",
|
||||
relname, PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
dbError = true;
|
||||
|
|
|
@ -272,9 +272,9 @@ void IpfixDbWriterSQL::processDataDataRecord(IpfixRecord::SourceID* sourceID,
|
|||
|
||||
/** check if statement buffer is not full*/
|
||||
if(insertBuffer.curRows==insertBuffer.maxRows) {
|
||||
msg(MSG_ERROR, "failed to write data to database, trying again ...");
|
||||
msg(LOG_ERR, "failed to write data to database, trying again ...");
|
||||
if (!writeToDb()) {
|
||||
msg(MSG_ERROR, "dropping record");
|
||||
msg(LOG_ERR, "dropping record");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ void IpfixDbWriterSQL::processDataDataRecord(IpfixRecord::SourceID* sourceID,
|
|||
|
||||
// statemBuffer is filled -> insert in table
|
||||
if(insertBuffer.curRows==insertBuffer.maxRows) {
|
||||
msg(MSG_INFO, "Writing buffered records to database");
|
||||
msg(LOG_NOTICE, "Writing buffered records to database");
|
||||
writeToDb();
|
||||
}
|
||||
}
|
||||
|
@ -464,11 +464,11 @@ void IpfixDbWriterSQL::fillInsertRow(IpfixRecord::SourceID* sourceID,
|
|||
// and get new table
|
||||
if (!checkCurrentTable(flowstart)) {
|
||||
if (insertBuffer.curRows != 0 && !writeToDb()) {
|
||||
msg(MSG_ERROR, "failed to flush table, dropping record");
|
||||
msg(LOG_ERR, "failed to flush table, dropping record");
|
||||
return;
|
||||
}
|
||||
if (!setCurrentTable(flowstart)) {
|
||||
msg(MSG_ERROR, "failed to change table, dropping record");
|
||||
msg(LOG_ERR, "failed to change table, dropping record");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ void IpfixDbWriterSQL::parseIpfixData(InformationElement::IeInfo type, IpfixReco
|
|||
case IPFIX_TYPE_subTemplateList:
|
||||
case IPFIX_TYPE_subTemplateMultiList:
|
||||
default:
|
||||
msg(MSG_ERROR, "failed to parse record data of type %hu", ipfix_id_lookup(type.id, type.enterprise)->type);
|
||||
msg(LOG_ERR, "failed to parse record data of type %hu", ipfix_id_lookup(type.id, type.enterprise)->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ void IpfixDbWriterSQL::parseIpfixFloat(IpfixRecord::Data* data, uint16_t length,
|
|||
*parsedData = boost::lexical_cast<std::string>(*(double*) data);
|
||||
break;
|
||||
default:
|
||||
msg(MSG_ERROR, "failed to parse float of length %hu", length);
|
||||
msg(LOG_ERR, "failed to parse float of length %hu", length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,7 @@ IpfixDbWriterSQL::IpfixDbWriterSQL(const char* dbtype, const char* host, const c
|
|||
tableColumnsCreateString.append(c.dataType);
|
||||
first = false;
|
||||
}
|
||||
msg(MSG_INFO, "IpfixDbWriter: columns are %s", tableColumnsString.c_str());
|
||||
msg(LOG_NOTICE, "IpfixDbWriter: columns are %s", tableColumnsString.c_str());
|
||||
|
||||
|
||||
/**count columns*/
|
||||
|
|
|
@ -42,13 +42,13 @@ int IpfixFlowInspectorExporter::connectToDB()
|
|||
std::string err;
|
||||
context = redisConnect(dbHost.c_str(), dbPort);
|
||||
if (context->err) {
|
||||
msg(MSG_FATAL,"IpfixFlowInspectorExporter: Redis connect failed. Error: %s", context->errstr);
|
||||
msg(LOG_CRIT,"IpfixFlowInspectorExporter: Redis connect failed. Error: %s", context->errstr);
|
||||
redisFree(context);
|
||||
context = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG,"IpfixFlowInspectorExporter: Connection to Redis successful");
|
||||
msg(LOG_INFO,"IpfixFlowInspectorExporter: Connection to Redis successful");
|
||||
dbError = false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ void IpfixFlowInspectorExporter::processDataDataRecord(const IpfixRecord::Source
|
|||
IpfixRecord::Data* data)
|
||||
{
|
||||
std::string json_string;
|
||||
msg(MSG_DEBUG, "IpfixFlowInspectorExporter: Processing data record");
|
||||
msg(LOG_INFO, "IpfixFlowInspectorExporter: Processing data record");
|
||||
|
||||
if (dbError) {
|
||||
msg(MSG_DEBUG, "IpfixFlowInspectorExporter: reconnecting to DB");
|
||||
msg(LOG_INFO, "IpfixFlowInspectorExporter: reconnecting to DB");
|
||||
connectToDB();
|
||||
if (dbError) return;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ int IpfixFlowInspectorExporter::writeToDb()
|
|||
redisReply *reply;
|
||||
reply = (redisReply*)redisCommand(context, "RPUSH %s %s", dbName.c_str(), elem.c_str());
|
||||
if (!reply) {
|
||||
msg(MSG_ERROR, "IpfixFlowInspectorExporter: Error while writing to redis queue: %s", reply->str);
|
||||
msg(LOG_ERR, "IpfixFlowInspectorExporter: Error while writing to redis queue: %s", reply->str);
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
bufferedObjects.pop_front();
|
||||
|
@ -202,7 +202,7 @@ void IpfixFlowInspectorExporter::onDataRecord(IpfixDataRecord* record)
|
|||
return;
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "IpfixFlowInspectorExporter: Data record received will be passed for processing");
|
||||
msg(LOG_INFO, "IpfixFlowInspectorExporter: Data record received will be passed for processing");
|
||||
processDataDataRecord(*record->sourceID.get(), *record->templateInfo.get(),
|
||||
record->dataLength, record->data);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ IpfixFlowInspectorExporterCfg::IpfixFlowInspectorExporterCfg(XMLElement* elem)
|
|||
database = e->getFirstText();
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown IpfixFlowInspectorExporter config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown IpfixFlowInspectorExporter config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ IpfixFlowInspectorExporterCfg::~IpfixFlowInspectorExporterCfg()
|
|||
IpfixFlowInspectorExporter* IpfixFlowInspectorExporterCfg::createInstance()
|
||||
{
|
||||
instance = new IpfixFlowInspectorExporter(hostname, database, port);
|
||||
msg(MSG_DEBUG, "IpfixFlowInspectorExporter configuration host %s queue %s port %i\n", hostname.c_str(), database.c_str(), port);
|
||||
msg(LOG_INFO, "IpfixFlowInspectorExporter configuration host %s queue %s port %i\n", hostname.c_str(), database.c_str(), port);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ Observer::Observer(const std::string& interface, bool offline, uint64_t maxpacke
|
|||
|
||||
Observer::~Observer()
|
||||
{
|
||||
msg(MSG_DEBUG, "Observer: destructor called");
|
||||
msg(LOG_INFO, "Observer: destructor called");
|
||||
|
||||
// to make sure that exitFlag is set and performShutdown() is called
|
||||
shutdown(false);
|
||||
|
@ -117,12 +117,12 @@ Observer::~Observer()
|
|||
/* collect and output statistics */
|
||||
pcap_stat pstats;
|
||||
if (captureDevice && pcap_stats(captureDevice, &pstats)==0) {
|
||||
msg(MSG_DIALOG, "PCAP statistics (INFO: if statistics were activated, this information does not contain correct data!):");
|
||||
msg(MSG_DIALOG, "Number of packets received on interface: %u", pstats.ps_recv);
|
||||
msg(MSG_DIALOG, "Number of packets dropped by PCAP: %u", pstats.ps_drop);
|
||||
msg(LOG_WARNING, "PCAP statistics (INFO: if statistics were activated, this information does not contain correct data!):");
|
||||
msg(LOG_WARNING, "Number of packets received on interface: %u", pstats.ps_recv);
|
||||
msg(LOG_WARNING, "Number of packets dropped by PCAP: %u", pstats.ps_drop);
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "freeing pcap/devices");
|
||||
msg(LOG_INFO, "freeing pcap/devices");
|
||||
if(captureDevice) {
|
||||
pcap_close(captureDevice);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ Observer::~Observer()
|
|||
free(captureInterface);
|
||||
delete[] filter_exp;
|
||||
if (fileName) { free(fileName); fileName = NULL; }
|
||||
msg(MSG_DEBUG, "successful shutdown");
|
||||
msg(LOG_INFO, "successful shutdown");
|
||||
}
|
||||
/*
|
||||
This is the main observer loop. It graps packets from libpcap and
|
||||
|
@ -155,22 +155,22 @@ void *Observer::observerThread(void *arg)
|
|||
obs->registerCurrentThread();
|
||||
bool file_eof = false;
|
||||
|
||||
msg(MSG_INFO, "Observer started with following parameters:");
|
||||
msg(MSG_INFO, " - readFromFile=%d", obs->readFromFile);
|
||||
if (obs->fileName) msg(MSG_INFO, " - fileName=%s", obs->fileName);
|
||||
if (obs->captureInterface) msg(MSG_INFO, " - captureInterface=%s", obs->captureInterface);
|
||||
msg(MSG_INFO, " - filterString='%s'", (obs->filter_exp ? obs->filter_exp : "none"));
|
||||
msg(MSG_INFO, " - maxPackets=%lu", obs->maxPackets);
|
||||
msg(MSG_INFO, " - capturelen=%d", obs->capturelen);
|
||||
msg(MSG_INFO, " - dataLinkType=%d", obs->dataLinkType);
|
||||
msg(LOG_NOTICE, "Observer started with following parameters:");
|
||||
msg(LOG_NOTICE, " - readFromFile=%d", obs->readFromFile);
|
||||
if (obs->fileName) msg(LOG_NOTICE, " - fileName=%s", obs->fileName);
|
||||
if (obs->captureInterface) msg(LOG_NOTICE, " - captureInterface=%s", obs->captureInterface);
|
||||
msg(LOG_NOTICE, " - filterString='%s'", (obs->filter_exp ? obs->filter_exp : "none"));
|
||||
msg(LOG_NOTICE, " - maxPackets=%lu", obs->maxPackets);
|
||||
msg(LOG_NOTICE, " - capturelen=%d", obs->capturelen);
|
||||
msg(LOG_NOTICE, " - dataLinkType=%d", obs->dataLinkType);
|
||||
if (obs->readFromFile) {
|
||||
msg(MSG_INFO, " - autoExit=%d", obs->autoExit);
|
||||
msg(MSG_INFO, " - stretchTime=%f", obs->stretchTime);
|
||||
msg(MSG_INFO, " - replaceTimestampsFromFile=%s", obs->replaceTimestampsFromFile==true?"true":"false");
|
||||
msg(LOG_NOTICE, " - autoExit=%d", obs->autoExit);
|
||||
msg(LOG_NOTICE, " - stretchTime=%f", obs->stretchTime);
|
||||
msg(LOG_NOTICE, " - replaceTimestampsFromFile=%s", obs->replaceTimestampsFromFile==true?"true":"false");
|
||||
}
|
||||
|
||||
// start capturing packets
|
||||
msg(MSG_INFO, "now running capturing thread for device %s", obs->captureInterface);
|
||||
msg(LOG_NOTICE, "now running capturing thread for device %s", obs->captureInterface);
|
||||
|
||||
|
||||
if(!obs->readFromFile) {
|
||||
|
@ -185,8 +185,8 @@ void *Observer::observerThread(void *arg)
|
|||
int result = select(FD_SETSIZE, &fd_wait, NULL, NULL, &st);
|
||||
if (result == -1) {
|
||||
if (errno==EINTR) continue; // just continue on interrupted system call
|
||||
msg(MSG_FATAL, "select() on pcap file descriptor returned -1, error: %s", strerror(errno));
|
||||
msg(MSG_FATAL, "shutting down observer");
|
||||
msg(LOG_CRIT, "select() on pcap file descriptor returned -1, error: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "shutting down observer");
|
||||
break;
|
||||
}
|
||||
if (result == 0) {
|
||||
|
@ -200,12 +200,12 @@ void *Observer::observerThread(void *arg)
|
|||
that can act as a via LD_PRELOAD used overlay function.
|
||||
unfortunately I don't have an URL ready -Freek
|
||||
*/
|
||||
DPRINTFL(MSG_VDEBUG, "trying to get packet from pcap");
|
||||
DPRINTFL(LOG_DEBUG, "trying to get packet from pcap");
|
||||
pcapData = pcap_next(obs->captureDevice, &packetHeader);
|
||||
if(!pcapData)
|
||||
/* no packet data was available */
|
||||
continue;
|
||||
DPRINTFL(MSG_VDEBUG, "got new packet!");
|
||||
DPRINTFL(LOG_DEBUG, "got new packet!");
|
||||
|
||||
// show current packet as c-structure on stdout
|
||||
//for (unsigned int i=0; i<packetHeader.caplen; i++) {
|
||||
|
@ -228,9 +228,9 @@ void *Observer::observerThread(void *arg)
|
|||
obs->processedPackets++;
|
||||
|
||||
while (!obs->exitFlag) {
|
||||
DPRINTFL(MSG_VDEBUG, "trying to push packet to queue");
|
||||
DPRINTFL(LOG_DEBUG, "trying to push packet to queue");
|
||||
if ((have_send = obs->send(p))) {
|
||||
DPRINTFL(MSG_VDEBUG, "packet pushed");
|
||||
DPRINTFL(LOG_DEBUG, "packet pushed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -254,19 +254,19 @@ void *Observer::observerThread(void *arg)
|
|||
// read-from-file loop
|
||||
while(!obs->exitFlag && (obs->maxPackets==0 || obs->processedPackets<obs->maxPackets)) {
|
||||
|
||||
DPRINTFL(MSG_VDEBUG, "trying to get packet from pcap file");
|
||||
DPRINTFL(LOG_DEBUG, "trying to get packet from pcap file");
|
||||
pcapData=pcap_next(obs->captureDevice, &packetHeader);
|
||||
if(!pcapData) {
|
||||
/* no packet data was available */
|
||||
if(feof(fh))
|
||||
msg(MSG_DIALOG, "Observer: reached end of file (%lu packets)", obs->processedPackets);
|
||||
msg(LOG_WARNING, "Observer: reached end of file (%lu packets)", obs->processedPackets);
|
||||
file_eof = true;
|
||||
break;
|
||||
}
|
||||
DPRINTFL(MSG_VDEBUG, "got new packet!");
|
||||
DPRINTFL(LOG_DEBUG, "got new packet!");
|
||||
if (obs->stretchTime > 0) {
|
||||
if (gettimeofday(&now, NULL) < 0) {
|
||||
msg(MSG_FATAL, "Error gettimeofday: %s", strerror(errno));
|
||||
msg(LOG_CRIT, "Error gettimeofday: %s", strerror(errno));
|
||||
break;
|
||||
}
|
||||
if(firstPacket)
|
||||
|
@ -292,12 +292,12 @@ void *Observer::observerThread(void *arg)
|
|||
wait_spec.tv_sec = wait_val.tv_sec;
|
||||
wait_spec.tv_nsec = wait_val.tv_usec * 1000;
|
||||
if(nanosleep(&wait_spec, NULL) != 0)
|
||||
msg(MSG_INFO, "Observer: nanosleep returned nonzero value, errno=%u (%s)", errno, strerror(errno));
|
||||
msg(LOG_NOTICE, "Observer: nanosleep returned nonzero value, errno=%u (%s)", errno, strerror(errno));
|
||||
}
|
||||
else if (delta_now.tv_sec > (delta_to_be.tv_sec + 1) && obs->stretchTime!=INFINITY)
|
||||
if (!obs->slowMessageShown) {
|
||||
obs->slowMessageShown = true;
|
||||
msg(MSG_ERROR, "Observer: reading from file is more than 1 second behind schedule!");
|
||||
msg(LOG_ERR, "Observer: reading from file is more than 1 second behind schedule!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,9 +325,9 @@ void *Observer::observerThread(void *arg)
|
|||
obs->processedPackets++;
|
||||
|
||||
while (!obs->exitFlag) {
|
||||
DPRINTFL(MSG_VDEBUG, "trying to push packet to queue");
|
||||
DPRINTFL(LOG_DEBUG, "trying to push packet to queue");
|
||||
if ((have_send = obs->send(p))) {
|
||||
DPRINTFL(MSG_VDEBUG, "packet pushed");
|
||||
DPRINTFL(LOG_DEBUG, "packet pushed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ void *Observer::observerThread(void *arg)
|
|||
obs->shutdownVermont();
|
||||
}
|
||||
|
||||
msg(MSG_DEBUG, "exiting observer thread");
|
||||
msg(LOG_INFO, "exiting observer thread");
|
||||
obs->unregisterCurrentThread();
|
||||
pthread_exit((void *)1);
|
||||
}
|
||||
|
@ -365,48 +365,48 @@ bool Observer::prepare(const std::string& filter)
|
|||
|
||||
if (!readFromFile) {
|
||||
// query all available capture devices
|
||||
msg(MSG_INFO, "Finding devices");
|
||||
msg(LOG_NOTICE, "Finding devices");
|
||||
if(pcap_findalldevs(&allDevices, errorBuffer) == -1) {
|
||||
msg(MSG_FATAL, "error getting list of interfaces: %s", errorBuffer);
|
||||
msg(LOG_CRIT, "error getting list of interfaces: %s", errorBuffer);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for(pcap_if_t *dev = allDevices; dev != NULL; dev=dev->next) {
|
||||
msg(MSG_DEBUG, "PCAP: name=%s, desc=%s", dev->name, dev->description);
|
||||
msg(LOG_INFO, "PCAP: name=%s, desc=%s", dev->name, dev->description);
|
||||
}
|
||||
|
||||
msg(MSG_INFO,
|
||||
msg(LOG_NOTICE,
|
||||
"pcap opening interface=%s, promisc=%d, snaplen=%d, timeout=%d",
|
||||
captureInterface, pcap_promisc, capturelen, pcap_timeout
|
||||
);
|
||||
captureDevice=pcap_open_live(captureInterface, capturelen, pcap_promisc, pcap_timeout, errorBuffer);
|
||||
// check for errors
|
||||
if(!captureDevice) {
|
||||
msg(MSG_FATAL, "Error initializing pcap interface: %s", errorBuffer);
|
||||
msg(LOG_CRIT, "Error initializing pcap interface: %s", errorBuffer);
|
||||
goto out1;
|
||||
}
|
||||
|
||||
// make reads non-blocking
|
||||
if(pcap_setnonblock(captureDevice, 1, errorBuffer) == -1) {
|
||||
msg(MSG_FATAL, "Error setting pcap interface to non-blocking: %s", errorBuffer);
|
||||
msg(LOG_CRIT, "Error setting pcap interface to non-blocking: %s", errorBuffer);
|
||||
goto out2;
|
||||
}
|
||||
|
||||
/* we need the netmask for the pcap_compile */
|
||||
if(pcap_lookupnet(captureInterface, &network, &netmask, errorBuffer) == -1) {
|
||||
msg(MSG_ERROR, "unable to determine netmask/network: %s", errorBuffer);
|
||||
msg(LOG_ERR, "unable to determine netmask/network: %s", errorBuffer);
|
||||
network=0;
|
||||
netmask=0;
|
||||
}
|
||||
i_network.s_addr=network;
|
||||
i_netmask.s_addr=netmask;
|
||||
msg(MSG_DEBUG, "pcap seems to run on network %s", inet_ntoa(i_network));
|
||||
msg(MSG_INFO, "pcap seems to run on netmask %s", inet_ntoa(i_netmask));
|
||||
msg(LOG_INFO, "pcap seems to run on network %s", inet_ntoa(i_network));
|
||||
msg(LOG_NOTICE, "pcap seems to run on netmask %s", inet_ntoa(i_netmask));
|
||||
} else {
|
||||
captureDevice=pcap_open_offline(fileName, errorBuffer);
|
||||
// check for errors
|
||||
if(!captureDevice) {
|
||||
msg(MSG_FATAL, "Error opening pcap file %s: %s", fileName, errorBuffer);
|
||||
msg(LOG_CRIT, "Error opening pcap file %s: %s", fileName, errorBuffer);
|
||||
goto out1;
|
||||
}
|
||||
|
||||
|
@ -416,20 +416,20 @@ bool Observer::prepare(const std::string& filter)
|
|||
dataLinkType = pcap_datalink(captureDevice);
|
||||
|
||||
if (filter_exp) {
|
||||
msg(MSG_DEBUG, "compiling pcap filter code from: %s", filter_exp);
|
||||
msg(LOG_INFO, "compiling pcap filter code from: %s", filter_exp);
|
||||
if(pcap_compile(captureDevice, &pcap_filter, filter_exp, 1, netmask) == -1) {
|
||||
msg(MSG_FATAL, "unable to validate+compile pcap filter");
|
||||
msg(LOG_CRIT, "unable to validate+compile pcap filter");
|
||||
goto out2;
|
||||
}
|
||||
|
||||
if(pcap_setfilter(captureDevice, &pcap_filter) == -1) {
|
||||
msg(MSG_FATAL, "unable to attach filter to pcap: %s", pcap_geterr(captureDevice));
|
||||
msg(LOG_CRIT, "unable to attach filter to pcap: %s", pcap_geterr(captureDevice));
|
||||
goto out3;
|
||||
}
|
||||
/* you may free an attached code, see man-page */
|
||||
pcap_freecode(&pcap_filter);
|
||||
} else {
|
||||
msg(MSG_DEBUG, "using no pcap filter");
|
||||
msg(LOG_INFO, "using no pcap filter");
|
||||
}
|
||||
|
||||
ready=true;
|
||||
|
@ -473,24 +473,24 @@ void Observer::performStart()
|
|||
if(!ready)
|
||||
THROWEXCEPTION("Can't start capturing, observer is not ready");
|
||||
|
||||
msg(MSG_DEBUG, "now starting capturing thread");
|
||||
msg(LOG_INFO, "now starting capturing thread");
|
||||
thread.run(this);
|
||||
}
|
||||
|
||||
void Observer::performShutdown()
|
||||
{
|
||||
/* be sure the thread is ending */
|
||||
msg(MSG_DEBUG, "joining the ObserverThread, may take a while (until next pcap data is received)");
|
||||
msg(LOG_INFO, "joining the ObserverThread, may take a while (until next pcap data is received)");
|
||||
connected.shutdown();
|
||||
thread.join();
|
||||
msg(MSG_DEBUG, "ObserverThread joined");
|
||||
msg(LOG_INFO, "ObserverThread joined");
|
||||
}
|
||||
|
||||
|
||||
/* you cannot change the caplen of an already running observer */
|
||||
bool Observer::setCaptureLen(int x)
|
||||
{
|
||||
msg(MSG_DEBUG, "Observer: setting capture length to %d bytes", x);
|
||||
msg(LOG_INFO, "Observer: setting capture length to %d bytes", x);
|
||||
/* we cant change pcap caplen if alredy pcap_open() called */
|
||||
if(ready) {
|
||||
THROWEXCEPTION("changing capture len on-the-fly is not supported by pcap");
|
||||
|
@ -527,7 +527,7 @@ void Observer::setOfflineSpeed(float m)
|
|||
if((1 - stretchTimeInt * m) > 0.1)
|
||||
stretchTimeInt = 0; // use float
|
||||
else
|
||||
msg(MSG_INFO, "Observer: speed multiplier set to %f in order to allow integer multiplication.", 1.0/stretchTimeInt);
|
||||
msg(LOG_NOTICE, "Observer: speed multiplier set to %f in order to allow integer multiplication.", 1.0/stretchTimeInt);
|
||||
}
|
||||
else
|
||||
stretchTimeInt = 0;
|
||||
|
@ -542,7 +542,7 @@ void Observer::setOfflineAutoExit(bool autoexit)
|
|||
bool Observer::setPacketTimeout(int ms)
|
||||
{
|
||||
if(ready) {
|
||||
msg(MSG_ERROR, "changing read timeout on-the-fly is not supported by pcap");
|
||||
msg(LOG_ERR, "changing read timeout on-the-fly is not supported by pcap");
|
||||
return false;
|
||||
}
|
||||
pcap_timeout=ms;
|
||||
|
|
|
@ -74,7 +74,7 @@ ObserverCfg::ObserverCfg(XMLElement* elem)
|
|||
maxPackets = getInt("maxPackets");
|
||||
} else if (e->matches("next")) { // ignore next
|
||||
} else {
|
||||
msg(MSG_FATAL, "Unknown observer config statement %s\n", e->getName().c_str());
|
||||
msg(LOG_CRIT, "Unknown observer config statement %s\n", e->getName().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -94,13 +94,13 @@ Observer* ObserverCfg::createInstance()
|
|||
|
||||
if (capture_len) {
|
||||
if(!instance->setCaptureLen(capture_len)) {
|
||||
msg(MSG_FATAL, "Observer: wrong snaplen specified - using %d",
|
||||
msg(LOG_CRIT, "Observer: wrong snaplen specified - using %d",
|
||||
instance->getCaptureLen());
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance->prepare(pcap_filter.c_str())) {
|
||||
msg(MSG_FATAL, "Observer: preparing failed");
|
||||
msg(LOG_CRIT, "Observer: preparing failed");
|
||||
THROWEXCEPTION("Observer setup failed!");
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ void PCAPExporterFile::performShutdown()
|
|||
{
|
||||
if (dumper) {
|
||||
if (-1 == pcap_dump_flush(dumper)) {
|
||||
msg(MSG_FATAL, "PCAPExporterFile: Could not flush dump file");
|
||||
msg(LOG_CRIT, "PCAPExporterFile: Could not flush dump file");
|
||||
}
|
||||
pcap_dump_close(dumper);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ PCAPExporterFileCfg::PCAPExporterFileCfg(XMLElement* elem)
|
|||
} else if (e->matches("linkType")) {
|
||||
int tmp = pcap_datalink_name_to_val(e->getFirstText().c_str());
|
||||
if (tmp == -1) {
|
||||
msg(MSG_ERROR, "Found illegal link type");
|
||||
msg(LOG_ERR, "Found illegal link type");
|
||||
} else {
|
||||
link_type = tmp;
|
||||
}
|
||||
|
|
|
@ -222,21 +222,21 @@ void PCAPExporterPipe::performStart()
|
|||
THROWEXCEPTION("Could not open dummy device: %s", pcap_geterr(dummy));
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Started PCAPExporterPipe with the following parameters:");
|
||||
msg(LOG_NOTICE, "Started PCAPExporterPipe with the following parameters:");
|
||||
if (fifoReaderCmd != ""){
|
||||
msg(MSG_INFO, " - fifoReaderCmd = %s", fifoReaderCmd.c_str());
|
||||
msg(MSG_INFO, " - fifoReaderPid = %d", fifoReaderPid);
|
||||
msg(LOG_NOTICE, " - fifoReaderCmd = %s", fifoReaderCmd.c_str());
|
||||
msg(LOG_NOTICE, " - fifoReaderPid = %d", fifoReaderPid);
|
||||
} else {
|
||||
THROWEXCEPTION("No fifoReaderCmd specified!");
|
||||
}
|
||||
if (logFileName != ""){
|
||||
msg(MSG_INFO, " - logfileBaseName = %s", logFileName.c_str());
|
||||
msg(MSG_INFO, " - appenddate = %s", appenddate ? "true" : "false");
|
||||
msg(LOG_NOTICE, " - logfileBaseName = %s", logFileName.c_str());
|
||||
msg(LOG_NOTICE, " - appenddate = %s", appenddate ? "true" : "false");
|
||||
}
|
||||
else
|
||||
msg(MSG_ERROR, "No Logfile specified - dumping to stdout!");
|
||||
msg(MSG_INFO, " - sigKillTimeout = %d" , sigKillTimeout);
|
||||
msg(MSG_INFO, " - restartInterval = %u seconds" , restartInterval);
|
||||
msg(LOG_ERR, "No Logfile specified - dumping to stdout!");
|
||||
msg(LOG_NOTICE, " - sigKillTimeout = %d" , sigKillTimeout);
|
||||
msg(LOG_NOTICE, " - restartInterval = %u seconds" , restartInterval);
|
||||
|
||||
startProcess();
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ void PCAPExporterPipe::startProcess()
|
|||
}
|
||||
|
||||
fifoReaderPid = execCmd(fifoReaderCmd);
|
||||
msg(MSG_INFO, "Started process with fifoReaderCmd \'%s\' and fifoReaderPid = %d",
|
||||
msg(LOG_NOTICE, "Started process with fifoReaderCmd \'%s\' and fifoReaderPid = %d",
|
||||
fifoReaderCmd.c_str(), fifoReaderPid);
|
||||
|
||||
pcapFile = fdopen(fd[1], "w");
|
||||
|
@ -288,11 +288,11 @@ void PCAPExporterPipe::stopProcess()
|
|||
if (!dumper) return;
|
||||
|
||||
if (-1 == pcap_dump_flush(dumper)) {
|
||||
msg(MSG_ERROR, "PCAPExporterPipe: Could not flush dump file");
|
||||
msg(LOG_ERR, "PCAPExporterPipe: Could not flush dump file");
|
||||
}
|
||||
|
||||
/*if (fclose(pcapFile)) {
|
||||
msg(MSG_ERROR, "PCAPExporterPipe: failed to close pipe handle, error %d (%s)", errno, strerror(errno));
|
||||
msg(LOG_ERR, "PCAPExporterPipe: failed to close pipe handle, error %d (%s)", errno, strerror(errno));
|
||||
}*/
|
||||
|
||||
pcap_dump_close(dumper);
|
||||
|
@ -301,7 +301,7 @@ void PCAPExporterPipe::stopProcess()
|
|||
kill_all(fifoReaderPid);
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Stopped process with fifoReaderCmd \'%s\' and fifoReaderPid = %d",
|
||||
msg(LOG_NOTICE, "Stopped process with fifoReaderCmd \'%s\' and fifoReaderPid = %d",
|
||||
fifoReaderCmd.c_str(), fifoReaderPid);
|
||||
}
|
||||
|
||||
|
@ -310,31 +310,31 @@ void PCAPExporterPipe::stopProcess()
|
|||
*/
|
||||
void PCAPExporterPipe::receive(Packet* packet)
|
||||
{
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive() called");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive() called");
|
||||
if (onRestart){
|
||||
DPRINTF("Dropping incoming packet, as attached process is not ready");
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive() ended");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive() ended");
|
||||
return;
|
||||
}
|
||||
if (fifoReaderPid == 0){
|
||||
msg(MSG_VDEBUG, "fifoReaderPid = 0...this might happen during reconfiguration");
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive() ended");
|
||||
msg(LOG_DEBUG, "fifoReaderPid = 0...this might happen during reconfiguration");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive() ended");
|
||||
return;
|
||||
}
|
||||
if (restartInterval) {
|
||||
if (nextRestart.tv_sec==0) {
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive(): updating nextRestart");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive(): updating nextRestart");
|
||||
nextRestart = packet->timestamp;
|
||||
nextRestart.tv_sec += restartInterval;
|
||||
} else if (compareTime(nextRestart, packet->timestamp)<0) {
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive(): restarting process");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive(): restarting process");
|
||||
|
||||
// we need to unregister our signal handlers, as we get race conditions with the signal handler for restarting the process
|
||||
unregisterSignalHandlers();
|
||||
stopProcess();
|
||||
startProcess();
|
||||
registerSignalHandlers();
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive(): updating nextRestart");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive(): updating nextRestart");
|
||||
nextRestart.tv_sec += ((packet->timestamp.tv_sec-nextRestart.tv_sec)/restartInterval+1)*restartInterval;
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ void PCAPExporterPipe::receive(Packet* packet)
|
|||
|
||||
statBytesForwarded += packet->data_length;
|
||||
statPktsForwarded++;
|
||||
DPRINTFL(MSG_VDEBUG, "PCAPExporterPipe::receive() ended");
|
||||
DPRINTFL(LOG_DEBUG, "PCAPExporterPipe::receive() ended");
|
||||
}
|
||||
|
||||
void PCAPExporterPipe::handleSigPipe(int sig)
|
||||
|
@ -374,7 +374,7 @@ void PCAPExporterPipe::handleSigChld(int sig)
|
|||
|
||||
if(!isRunning(fifoReaderPid)){
|
||||
//waitpid(fifoReaderPid, NULL, 0);
|
||||
msg(MSG_ERROR, "Process of fifoReaderCmd \'%s\' with fifoReaderPid %d is not running!",
|
||||
msg(LOG_ERR, "Process of fifoReaderCmd \'%s\' with fifoReaderPid %d is not running!",
|
||||
fifoReaderCmd.c_str(), fifoReaderPid);
|
||||
startProcess();
|
||||
}
|
||||
|
@ -407,18 +407,18 @@ void PCAPExporterPipe::kill_pid(int pid)
|
|||
{
|
||||
int i = sigKillTimeout;
|
||||
std::string path = "/proc/" + boost::lexical_cast<std::string>(pid);
|
||||
/*msg(MSG_DEBUG, "Sending SIGTERM to pid %u", pid);
|
||||
/*msg(LOG_INFO, "Sending SIGTERM to pid %u", pid);
|
||||
if (kill(pid, SIGTERM)) {
|
||||
msg(MSG_ERROR, "Failed to call kill(%u, SIGTERM), error code %u (%s)", pid, errno, strerror(errno));
|
||||
msg(LOG_ERR, "Failed to call kill(%u, SIGTERM), error code %u (%s)", pid, errno, strerror(errno));
|
||||
}*/
|
||||
while(i--){
|
||||
msg(MSG_INFO, "waiting for pid %d, but no longer than %d seconds...", pid, i+1);
|
||||
msg(LOG_NOTICE, "waiting for pid %d, but no longer than %d seconds...", pid, i+1);
|
||||
if (!isRunning(fifoReaderPid)) return;
|
||||
sleep(1);
|
||||
}
|
||||
msg(MSG_DEBUG, "Sending SIGKILL to pid %u", pid);
|
||||
msg(LOG_INFO, "Sending SIGKILL to pid %u", pid);
|
||||
if (kill(pid, SIGKILL)) {
|
||||
msg(MSG_ERROR, "Failed to call kill(%u, SIGKILL), error code %u (%s)", pid, errno, strerror(errno));
|
||||
msg(LOG_ERR, "Failed to call kill(%u, SIGKILL), error code %u (%s)", pid, errno, strerror(errno));
|
||||
}
|
||||
waitpid(fifoReaderPid, NULL, 0);
|
||||
}
|
||||
|
@ -488,15 +488,15 @@ void PCAPExporterPipe::kill_all(int ppid)
|
|||
for (std::vector<int>::iterator it = my_ppids.begin(); it != my_ppids.end(); it++) {
|
||||
if (atoi(token) == *it) {
|
||||
#if BOOST_FILESYSTEM_VERSION == 3
|
||||
msg(MSG_DEBUG, "Pid %s is a child of %d", dir_iterator->path().filename().string().c_str(), *it );
|
||||
msg(LOG_INFO, "Pid %s is a child of %d", dir_iterator->path().filename().string().c_str(), *it );
|
||||
my_pids.push_back(boost::lexical_cast<int>(dir_iterator->path().filename()));
|
||||
my_ppids.push_back(boost::lexical_cast<int>(dir_iterator->path().filename()));
|
||||
#elif BOOST_FILE_SYSTEM_VERSION == 2
|
||||
msg(MSG_DEBUG, "Pid %s is a child of %d", dir_iterator->leaf().c_str(), *it );
|
||||
msg(LOG_INFO, "Pid %s is a child of %d", dir_iterator->leaf().c_str(), *it );
|
||||
my_pids.push_back(boost::lexical_cast<int>(dir_iterator->leaf()));
|
||||
my_ppids.push_back(boost::lexical_cast<int>(dir_iterator->leaf()));
|
||||
#else
|
||||
msg(MSG_DEBUG, "Pid %s is a child of %d", dir_iterator->path().filename().c_str(), *it );
|
||||
msg(LOG_INFO, "Pid %s is a child of %d", dir_iterator->path().filename().c_str(), *it );
|
||||
my_pids.push_back(boost::lexical_cast<int>(dir_iterator->path().filename()));
|
||||
my_ppids.push_back(boost::lexical_cast<int>(dir_iterator->path().filename()));
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ PCAPExporterPipeCfg::PCAPExporterPipeCfg(XMLElement* elem)
|
|||
} else if (e->matches("linkType")) {
|
||||
int tmp = pcap_datalink_name_to_val(e->getFirstText().c_str());
|
||||
if (tmp == -1) {
|
||||
msg(MSG_ERROR, "Found illegal link type");
|
||||
msg(LOG_ERR, "Found illegal link type");
|
||||
} else {
|
||||
link_type = tmp;
|
||||
}
|
||||
|
|
|
@ -102,22 +102,22 @@ PSAMPExporterModule* PSAMPExporterCfg::createInstance()
|
|||
recordsPerPacket = 1;
|
||||
}
|
||||
|
||||
msg(MSG_INFO, "Set maximum records per packet to %d", recordsPerPacket);
|
||||
msg(LOG_NOTICE, "Set maximum records per packet to %d", recordsPerPacket);
|
||||
instance->setMaxRecords(recordsPerPacket);
|
||||
}
|
||||
if (exportDelay) {
|
||||
msg(MSG_INFO, "Set maximum export timeout to %d", exportDelay);
|
||||
msg(LOG_NOTICE, "Set maximum export timeout to %d", exportDelay);
|
||||
instance->setExportTimeout(exportDelay);
|
||||
}
|
||||
if (templateRefreshTime /* || templateRefreshRate */) {
|
||||
msg(MSG_DIALOG, "Exporter: Configuration of templateRefreshRate/Time not yet supported.");
|
||||
msg(LOG_WARNING, "Exporter: Configuration of templateRefreshRate/Time not yet supported.");
|
||||
}
|
||||
for (unsigned i = 0; i != collectors.size(); ++i) {
|
||||
char vrf_log[VRF_LOG_LEN] = "";
|
||||
if (!collectors[i]->getVrfName().empty()) {
|
||||
snprintf(vrf_log, VRF_LOG_LEN, "[%.*s] ", IFNAMSIZ, collectors[i]->getVrfName().c_str());
|
||||
}
|
||||
msg(MSG_DEBUG, "%sPsampExporter: adding collector %s://%s:%d on VRF %s",
|
||||
msg(LOG_INFO, "%sPsampExporter: adding collector %s://%s:%d on VRF %s",
|
||||
vrf_log,
|
||||
collectors[i]->getProtocol()==ipfix_transport_protocol::SCTP?"SCTP":"UDP",
|
||||
collectors[i]->getIpAddress().c_str(),
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue